@williamthorsen/toolbelt.secrets 0.6.2 โ 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.meta/changelog.json
CHANGED
|
@@ -1,4 +1,65 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.6.4",
|
|
4
|
+
"date": "2026-11-15",
|
|
5
|
+
"sections": [
|
|
6
|
+
{
|
|
7
|
+
"title": "๐ Bug fixes",
|
|
8
|
+
"audience": "all",
|
|
9
|
+
"items": [
|
|
10
|
+
{
|
|
11
|
+
"description": "Fixes the issue that the store returned by `createKeychainStore` copied only the message of the error raised when `/usr/bin/security` could not be launched, and keeps that error as the `cause` of the thrown error, so that a caller can read its `code`, such as `ENOENT`. (#616)",
|
|
12
|
+
"hash": "8084dc35d104faa81d114f6fff714607a3ef9eaf",
|
|
13
|
+
"entry": 2
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"title": "๐ Security",
|
|
19
|
+
"audience": "all",
|
|
20
|
+
"items": [
|
|
21
|
+
{
|
|
22
|
+
"description": "Removes the password from the error that a `createKeychainStore` store's `findSecret` or `setSecret` throws when `security` prints the password as a malformed hexadecimal value or without double quotes, which exposed the secret to any log or output that recorded the error. (#615)",
|
|
23
|
+
"hash": "b3c8d68ae37136738224d8a30cf00b7632c05889",
|
|
24
|
+
"entry": 1
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"title": "โป๏ธ Refactoring",
|
|
30
|
+
"audience": "dev",
|
|
31
|
+
"items": [
|
|
32
|
+
{
|
|
33
|
+
"description": "Renames the private helpers `itemArgs` and `keychainArgs` in `packages/secrets/src/internal/securityCommands.ts` to `buildItemArgs` and `buildKeychainArgs`, which matches the neighboring `buildDeleteArgs`, `buildFindArgs`, and `buildHasArgs`. (#630)",
|
|
34
|
+
"hash": "6d7f6ad8849027520eab3fecb991be5a7e59af3c",
|
|
35
|
+
"entry": 1
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"title": "๐งช Tests",
|
|
41
|
+
"audience": "dev",
|
|
42
|
+
"items": [
|
|
43
|
+
{
|
|
44
|
+
"description": "Makes the read-only examples in `createKeychainStore.tool.test.ts` share one seeded keychain per file and gives each example that writes or deletes a keychain of its own that contains only the items that the example needs. (#619)",
|
|
45
|
+
"hash": "1b438a190f61ac824900cd2021b1a40b5247c6ae",
|
|
46
|
+
"entry": 1
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"version": "0.6.3",
|
|
54
|
+
"date": "2026-11-12",
|
|
55
|
+
"sections": [
|
|
56
|
+
{
|
|
57
|
+
"title": "๐ฆ Dependencies",
|
|
58
|
+
"audience": "dev",
|
|
59
|
+
"items": [{ "description": "Bumped `@williamthorsen/toolbelt.errors` to 0.10.1" }]
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
},
|
|
2
63
|
{
|
|
3
64
|
"version": "0.6.2",
|
|
4
65
|
"date": "2026-11-12",
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.6.4 โ 2026-11-15
|
|
6
|
+
|
|
7
|
+
### ๐ Bug fixes
|
|
8
|
+
|
|
9
|
+
- Fixes the issue that the store returned by `createKeychainStore` copied only the message of the error raised when `/usr/bin/security` could not be launched, and keeps that error as the `cause` of the thrown error, so that a caller can read its `code`, such as `ENOENT`. (#616)
|
|
10
|
+
|
|
11
|
+
### ๐ Security
|
|
12
|
+
|
|
13
|
+
- Removes the password from the error that a `createKeychainStore` store's `findSecret` or `setSecret` throws when `security` prints the password as a malformed hexadecimal value or without double quotes, which exposed the secret to any log or output that recorded the error. (#615)
|
|
14
|
+
|
|
15
|
+
### โป๏ธ Refactoring
|
|
16
|
+
|
|
17
|
+
- Renames the private helpers `itemArgs` and `keychainArgs` in `packages/secrets/src/internal/securityCommands.ts` to `buildItemArgs` and `buildKeychainArgs`, which matches the neighboring `buildDeleteArgs`, `buildFindArgs`, and `buildHasArgs`. (#630)
|
|
18
|
+
|
|
19
|
+
### ๐งช Tests
|
|
20
|
+
|
|
21
|
+
- Makes the read-only examples in `createKeychainStore.tool.test.ts` share one seeded keychain per file and gives each example that writes or deletes a keychain of its own that contains only the items that the example needs. (#619)
|
|
22
|
+
|
|
23
|
+
## 0.6.3 โ 2026-11-12
|
|
24
|
+
|
|
25
|
+
### ๐ฆ Dependencies
|
|
26
|
+
|
|
27
|
+
- Bumped `@williamthorsen/toolbelt.errors` to 0.10.1
|
|
28
|
+
|
|
5
29
|
## 0.6.2 โ 2026-11-12
|
|
6
30
|
|
|
7
31
|
### Notes
|
package/README.md
CHANGED
|
@@ -2,7 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Utilities for storing and retrieving secrets in the OS credential store.
|
|
4
4
|
|
|
5
|
-
<!-- section:release-notes
|
|
5
|
+
<!-- section:release-notes -->
|
|
6
|
+
## Release notes โ v0.6.4 (2026-11-15)
|
|
7
|
+
|
|
8
|
+
### ๐ Bug fixes
|
|
9
|
+
|
|
10
|
+
- Fixes the issue that the store returned by `createKeychainStore` copied only the message of the error raised when `/usr/bin/security` could not be launched, and keeps that error as the `cause` of the thrown error, so that a caller can read its `code`, such as `ENOENT`. (#616)
|
|
11
|
+
|
|
12
|
+
### ๐ Security
|
|
13
|
+
|
|
14
|
+
- Removes the password from the error that a `createKeychainStore` store's `findSecret` or `setSecret` throws when `security` prints the password as a malformed hexadecimal value or without double quotes, which exposed the secret to any log or output that recorded the error. (#615)
|
|
15
|
+
<!-- /section:release-notes -->
|
|
6
16
|
|
|
7
17
|
## Installation
|
|
8
18
|
|
|
@@ -14,14 +14,15 @@ export function parseSecurityPassword(stderr) {
|
|
|
14
14
|
}
|
|
15
15
|
function decodeHexForm(value) {
|
|
16
16
|
const hex = HEX_FORM_PATTERN.exec(value)?.groups?.['hex'];
|
|
17
|
-
if (hex === undefined)
|
|
18
|
-
throw new Error(`Malformed hexadecimal password in the output of \`security\`: ${value}`);
|
|
17
|
+
if (hex === undefined) {
|
|
18
|
+
throw new Error(`Malformed hexadecimal password in the output of \`security\`: a value of ${value.length} characters that does not continue 0x with pairs of hex digits`);
|
|
19
|
+
}
|
|
19
20
|
return new TextDecoder('utf-8', { fatal: true }).decode(Buffer.from(hex, 'hex'));
|
|
20
21
|
}
|
|
21
22
|
function readQuotedForm(value) {
|
|
22
23
|
const end = value.lastIndexOf(QUOTE);
|
|
23
24
|
if (!value.startsWith(QUOTE) || end === 0) {
|
|
24
|
-
throw new Error(`Unquoted password in the output of \`security\`: ${value}`);
|
|
25
|
+
throw new Error(`Unquoted password in the output of \`security\`: a value of ${value.length} characters that is not enclosed in double quotes`);
|
|
25
26
|
}
|
|
26
27
|
return value.slice(QUOTE.length, end);
|
|
27
28
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { chainError } from '@williamthorsen/toolbelt.errors/candidate';
|
|
2
3
|
const SECURITY_PATH = '/usr/bin/security';
|
|
3
4
|
const TIMEOUT_MS = 30_000;
|
|
4
5
|
export function runSecurity(args, input) {
|
|
@@ -8,7 +9,7 @@ export function runSecurity(args, input) {
|
|
|
8
9
|
timeout: TIMEOUT_MS,
|
|
9
10
|
});
|
|
10
11
|
if (error !== undefined)
|
|
11
|
-
throw
|
|
12
|
+
throw chainError(`Could not run ${SECURITY_PATH}`, error);
|
|
12
13
|
if (status === null) {
|
|
13
14
|
throw new Error(`${SECURITY_PATH} was killed before it exited. It may have been waiting on a prompt.`);
|
|
14
15
|
}
|
|
@@ -3,13 +3,13 @@ const MAX_LINE_BYTES = 4095;
|
|
|
3
3
|
const HEX_CHARACTERS_PER_BYTE = 2;
|
|
4
4
|
const LINE_BREAK_PATTERN = /[\n\r]/;
|
|
5
5
|
export function buildDeleteArgs(query, keychain) {
|
|
6
|
-
return ['delete-generic-password', ...
|
|
6
|
+
return ['delete-generic-password', ...buildItemArgs(query), ...buildKeychainArgs(keychain)];
|
|
7
7
|
}
|
|
8
8
|
export function buildFindArgs(query, keychain) {
|
|
9
|
-
return ['find-generic-password', ...
|
|
9
|
+
return ['find-generic-password', ...buildItemArgs(query), '-g', ...buildKeychainArgs(keychain)];
|
|
10
10
|
}
|
|
11
11
|
export function buildHasArgs(query, keychain) {
|
|
12
|
-
return ['find-generic-password', ...
|
|
12
|
+
return ['find-generic-password', ...buildItemArgs(query), ...buildKeychainArgs(keychain)];
|
|
13
13
|
}
|
|
14
14
|
export function composeSetLine(query, secret, keychain) {
|
|
15
15
|
const { account = '', service } = query;
|
|
@@ -36,15 +36,15 @@ function assertOneLine(value, field) {
|
|
|
36
36
|
return;
|
|
37
37
|
throw new UnstorableSecretError(`The ${field} contains a line break, which \`security\` reads as the end of a command.`);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return Buffer.from(secret, 'utf8').toString('hex');
|
|
41
|
-
}
|
|
42
|
-
function itemArgs({ account = '', service }) {
|
|
39
|
+
function buildItemArgs({ account = '', service }) {
|
|
43
40
|
return ['-a', account, '-s', service];
|
|
44
41
|
}
|
|
45
|
-
function
|
|
42
|
+
function buildKeychainArgs(keychain) {
|
|
46
43
|
return keychain === undefined ? [] : [keychain];
|
|
47
44
|
}
|
|
45
|
+
function encodeHex(secret) {
|
|
46
|
+
return Buffer.from(secret, 'utf8').toString('hex');
|
|
47
|
+
}
|
|
48
48
|
function quote(value) {
|
|
49
49
|
return `"${value.replaceAll('\\', '\\\\').replaceAll('"', String.raw `\"`)}"`;
|
|
50
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@williamthorsen/toolbelt.secrets",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Utilities for storing and retrieving secrets in the OS credential store",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"credentials",
|
|
@@ -45,10 +45,11 @@
|
|
|
45
45
|
"dist/*"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@williamthorsen/toolbelt.errors": "0.
|
|
48
|
+
"@williamthorsen/toolbelt.errors": "0.11.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@williamthorsen/toolbelt.testing": "0.8.
|
|
51
|
+
"@williamthorsen/toolbelt.testing": "0.8.4",
|
|
52
|
+
"@williamthorsen/toolbelt.vitest": "0.13.5"
|
|
52
53
|
},
|
|
53
54
|
"engines": {
|
|
54
55
|
"node": ">=24.0.0"
|