这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
22d67ca
fix: Add documentation comment for keyPath option in DecryptOptions
tarasglek Dec 24, 2024
c875ef9
docs: Convert DecryptOptions comments to TSDoc format
tarasglek Dec 24, 2024
c120f03
plumb path through
tarasglek Dec 24, 2024
4ba1da6
feat: Add Noble cipher implementation for SOPS-style AES256_GCM encry…
tarasglek Dec 24, 2024
0211926
refactor: Split decrypt function into base and convenient implementat…
tarasglek Dec 24, 2024
0758d40
refactor: Separate decryption and type conversion in decrypt functions
tarasglek Dec 24, 2024
90c21d5
feat: Add EncryptedData and ParsedEncryptedData interfaces for better…
tarasglek Dec 24, 2024
9b6fce5
refactor: Uncomment and integrate encrypt method into cipher-noble im…
tarasglek Dec 24, 2024
cdfaba4
refactor: Separate encrypt core logic from SOPS format handling
tarasglek Dec 24, 2024
9117907
refactor: Reorganize cipher-noble.ts with code cleanup and type impro…
tarasglek Dec 24, 2024
8cd1c78
refactor: Simplify error message conversion using String() instead of…
tarasglek Dec 24, 2024
8703347
refactor: Rename decryptConvenient to decryptSOPS and use Number methods
tarasglek Dec 24, 2024
7745691
refactor: Extract datatype conversion into separate function
tarasglek Dec 24, 2024
6397efd
feat: Add SOPSDataType enum for type-safe SOPS data handling
tarasglek Dec 24, 2024
00608cc
refactor: Reorder enum values and update type conversion function
tarasglek Dec 24, 2024
cdcc86b
docs: Add JSDoc comments to cipher functions
tarasglek Dec 24, 2024
899929e
refactor: Update decrypt function documentation comment
tarasglek Dec 24, 2024
73993d8
refactor: Make `additionalData` a required parameter in decryption fu…
tarasglek Dec 24, 2024
6ea69d8
refactor: Update decrypt function signature and parameter handling
tarasglek Dec 24, 2024
9ef1725
refactor: Move UTF-8 conversion from decrypt to decryptSOPS
tarasglek Dec 24, 2024
6a43f39
refactor: Simplify SOPS decryption utility and improve documentation
tarasglek Dec 24, 2024
be743aa
feat: Add bytes type support to SOPS decryption with utf8ToBytes conv…
tarasglek Dec 24, 2024
37ce5dd
feat: Add datatype validation in parse function for SOPS data type
tarasglek Dec 24, 2024
2ae4d5a
refactor: Simplify decryptValue function with new decryption method
tarasglek Dec 24, 2024
9b3338d
fix: Convert decryption key and handle Uint8Array result in decryptValue
tarasglek Dec 24, 2024
bbef137
checkpoint
tarasglek Dec 24, 2024
b34f353
fix: Improve path handling and error logging in decryption function
tarasglek Dec 24, 2024
ef11e79
refactor: Improve AAD path filtering using regex to exclude numeric i…
tarasglek Dec 24, 2024
535ea57
refactor: Replace `[0-9]` with `\d` in regex for better readability
tarasglek Dec 24, 2024
544cf03
ini files have a weird path
tarasglek Dec 24, 2024
eaf1494
comment
tarasglek Dec 24, 2024
13ed88c
feat: Add DecryptedValue type and enhance convertDecryptedValue function
tarasglek Dec 25, 2024
047dbb9
refactor: Simplify base64 to Uint8Array conversion using native methods
tarasglek Dec 25, 2024
c3a3943
refactor: Replace Buffer with Uint8Array for base64 decoding in age e…
tarasglek Dec 25, 2024
ffd9fdb
fix: Improve AAD path filtering to handle numeric path segments
tarasglek Dec 25, 2024
d1abff4
refactor: Replace Buffer with Uint8Array in decrypt.ts
tarasglek Dec 25, 2024
81d133d
refactor: Extract path conversion logic into `path2gopath` utility fu…
tarasglek Dec 25, 2024
6ad3580
refactor: Reorder comments and clean up whitespace in decrypt.ts
tarasglek Dec 25, 2024
ce6e0a5
refactor: Improve error handling in decryptValue with detailed error …
tarasglek Dec 25, 2024
6951db0
load unencrypted json from file
tarasglek Dec 25, 2024
e58ac99
refactor: Reorder isEmpty function and remove unnecessary blank line
tarasglek Dec 25, 2024
0a27743
refactor: Add type annotation to isEmpty function
tarasglek Dec 25, 2024
262a1e6
refactor: Remove isEmpty function and simplify empty check in decrypt…
tarasglek Dec 25, 2024
d3a324d
refactor: Replace Noble Ciphers utils with TextEncoder/TextDecoder
tarasglek Dec 25, 2024
68309f3
get ready for moving funcs
tarasglek Dec 25, 2024
15f191f
refactor: Rename `decrypt` to `decryptAesGcm` for clarity and precision
tarasglek Dec 25, 2024
e23452c
refactor
tarasglek Dec 25, 2024
401461e
refactor: Consolidate decryption functions into single `decryptSOPSVa…
tarasglek Dec 25, 2024
941917c
refactor: Remove commented-out decryptSOPS function implementation
tarasglek Dec 25, 2024
d36451f
typo
tarasglek Dec 25, 2024
3a0d948
refactor: Move and update comment for decryptSOPSValue function
tarasglek Dec 25, 2024
b6e0dcb
docs: Improve documentation for decryptSOPSValue function
tarasglek Dec 25, 2024
2074ed7
fix: Correct minor documentation formatting in decrypt function
tarasglek Dec 25, 2024
95f2926
fix: Add error handling for AES-GCM decryption with detailed error me…
tarasglek Dec 25, 2024
746b1e7
fix: Add explicit Uint8Array typing for decrypted variable in decrypt…
tarasglek Dec 25, 2024
97713b6
refactor: Simplify error handling and structure in decryptSOPSValue f…
tarasglek Dec 25, 2024
408807f
docs: Add comprehensive JSDoc documentation for decrypt() function
tarasglek Dec 25, 2024
c847b69
jsdoc
tarasglek Dec 25, 2024
010fe24
format
tarasglek Dec 25, 2024
39c16d9
refactor: Improve type safety for datatype exhaustive check in conver…
tarasglek Dec 25, 2024
cba7d33
simpler
tarasglek Dec 25, 2024
2432f79
Review fixes, dep updates, drop eslint
humphd Dec 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm lint:eslint
- run: pnpm lint:oxlint

name: Lint

Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ secret.yaml
secrets.yaml
secret.yml
secrets.yaml
secret.json
secrets.json
secret.ini
secrets.ini
secret.env
secrets.env
.aider*
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json.schemastore.org/prettierrc",
"overrides": [{ "files": ".nvmrc", "options": { "parser": "yaml" } }],
"plugins": ["prettier-plugin-curly", "prettier-plugin-packagejson"],
"plugins": ["prettier-plugin-packagejson"],
"useTabs": false
}
2 changes: 1 addition & 1 deletion .sops.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
creation_rules:
# Extra config to only encrypt the actual secret data keys
- path_regexp: \.(yml|yaml|json|ini|env)$
- path_regexp: \.(yml|yaml|json|env)$
key_groups:
- age:
- age1je6kjhzuhdjy3fqptpttxjh5k8q46vygzlgtpuq3030c947pc5tqz9dqvr # see key.txt
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Features

- Supports decryption of SOPS files encrypted with `age`.
- Compatible with various file formats including `.env`, `.ini`, `.json`, and `.yaml`.
- Compatible with various file formats including `.env`, `.json`, and `.yaml`.
- Provides utility functions for loading and decrypting different types of SOPS files or strings.
- Allows decrypted all or part of a SOPS encrypted data.

Expand All @@ -28,7 +28,7 @@ import { decrypt, loadSopsFile } from "sops-age";

async function decryptSopsFile(filePath, secretKey) {
try {
// Load the SOPS file (auto-detects file types env, ini, json, yaml from extension)
// Load the SOPS file (auto-detects file types env, json, yaml from extension)
const sopsData = await loadSopsFile(filePath);

// Decrypt the data using the secret key
Expand All @@ -50,7 +50,6 @@ decryptSopsFile(filePath, secretKey);
`sops-age` supports the following file types:

- `.env`
- `.ini`
- `.json`
- `.yaml` / `.yml`

Expand All @@ -60,7 +59,7 @@ The library automatically detects the file type based on the file extension. You

### `loadSopsFile(path, [sopsFileType])`

Loads a SOPS file from the specified path. The `sopsFileType` parameter is optional and can be used to manually specify the file type (`env`, `ini`, `json`, `yaml`) when it can't be inferred from the file extension.
Loads a SOPS file from the specified path. The `sopsFileType` parameter is optional and can be used to manually specify the file type (`env`, `json`, `yaml`) when it can't be inferred from the file extension.

### `decrypt(sops, { secretKey: "AGE-key...", [keyPath] })`

Expand All @@ -78,7 +77,6 @@ const DB_URI = await decrypt(sopsData, { secretKey, keyPath: "DB_URI" });
### Parsing Functions

- `parseSopsEnv(envString)`
- `parseSopsIni(iniString)`
- `parseSopsJson(json)`
- `parseSopsYaml(yamlString)`

Expand Down
49 changes: 17 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"format": "prettier . --write --cache",
"format-check": "prettier . --check --cache",
"lint": "pnpm run-s lint:*",
"lint:eslint": "eslint . .*js --max-warnings 0",
"lint:oxlint": "oxlint",
"lint:knip": "knip",
"lint:packages": "pnpm dedupe --check",
"test": "vitest",
Expand All @@ -38,45 +38,30 @@
"*": "prettier --ignore-unknown --write"
},
"dependencies": {
"@noble/ciphers": "^1.1.3",
"age-encryption": "^0.1.5",
"dotenv": "^16.4.5",
"ini": "^4.1.2",
"dotenv": "^16.4.7",
"lodash-es": "^4.17.21",
"yaml": "^2.4.1",
"zod": "^3.22.4"
"yaml": "^2.6.1",
"zod": "^3.24.1"
},
"devDependencies": {
"@release-it/conventional-changelog": "^8.0.1",
"@types/eslint": "^8.56.6",
"@types/ini": "^4.1.0",
"@release-it/conventional-changelog": "^8.0.2",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.11.30",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@vitest/coverage-v8": "^1.4.0",
"@types/node": "^20.17.10",
"@vitest/coverage-v8": "^1.6.0",
"console-fail-test": "^0.2.3",
"eslint": "^8.57.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-jsonc": "^2.14.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-perfectionist": "^2.7.0",
"eslint-plugin-regexp": "^2.4.0",
"eslint-plugin-vitest": "^0.4.0",
"eslint-plugin-yml": "^1.13.2",
"husky": "^9.0.11",
"jsonc-eslint-parser": "^2.4.0",
"knip": "^5.6.0",
"lint-staged": "^15.2.2",
"husky": "^9.1.7",
"knip": "^5.41.1",
"lint-staged": "^15.3.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"prettier-plugin-curly": "^0.2.1",
"prettier-plugin-packagejson": "^2.4.12",
"release-it": "^17.1.1",
"typescript": "^5.4.3",
"oxlint": "^0.15.3",
"prettier": "4.0.0-alpha.10",
"prettier-plugin-packagejson": "^2.5.6",
"release-it": "^17.11.0",
"typescript": "^5.7.2",
"unbuild": "^2.0.0",
"vitest": "^1.4.0",
"yaml-eslint-parser": "^1.2.2"
"vitest": "^1.6.0"
},
"packageManager": "pnpm@9",
"engines": {
Expand Down
Loading
Loading