@de-otio/chaoskb-client 0.3.6 → 0.3.7
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/dist/cli/bootstrap.d.ts +11 -3
- package/dist/cli/bootstrap.d.ts.map +1 -1
- package/dist/cli/bootstrap.js +181 -126
- package/dist/cli/bootstrap.js.map +1 -1
- package/dist/cli/commands/config.d.ts +7 -4
- package/dist/cli/commands/config.d.ts.map +1 -1
- package/dist/cli/commands/config.js +161 -134
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/devices.d.ts.map +1 -1
- package/dist/cli/commands/devices.js +58 -33
- package/dist/cli/commands/devices.js.map +1 -1
- package/dist/cli/commands/export.d.ts.map +1 -1
- package/dist/cli/commands/export.js +6 -9
- package/dist/cli/commands/export.js.map +1 -1
- package/dist/cli/commands/import.js +1 -1
- package/dist/cli/commands/import.js.map +1 -1
- package/dist/cli/commands/projects.d.ts.map +1 -1
- package/dist/cli/commands/projects.js +33 -10
- package/dist/cli/commands/projects.js.map +1 -1
- package/dist/cli/commands/rotate-key.d.ts +3 -3
- package/dist/cli/commands/rotate-key.d.ts.map +1 -1
- package/dist/cli/commands/rotate-key.js +88 -35
- package/dist/cli/commands/rotate-key.js.map +1 -1
- package/dist/cli/commands/setup-sync.d.ts.map +1 -1
- package/dist/cli/commands/setup-sync.js +22 -4
- package/dist/cli/commands/setup-sync.js.map +1 -1
- package/dist/cli/mcp-server.d.ts.map +1 -1
- package/dist/cli/mcp-server.js +90 -42
- package/dist/cli/mcp-server.js.map +1 -1
- package/dist/crypto/aad.d.ts +2 -5
- package/dist/crypto/aad.d.ts.map +1 -1
- package/dist/crypto/aad.js +2 -8
- package/dist/crypto/aad.js.map +1 -1
- package/dist/crypto/aead.d.ts +8 -16
- package/dist/crypto/aead.d.ts.map +1 -1
- package/dist/crypto/aead.js +10 -36
- package/dist/crypto/aead.js.map +1 -1
- package/dist/crypto/blob-id.d.ts +2 -3
- package/dist/crypto/blob-id.d.ts.map +1 -1
- package/dist/crypto/blob-id.js +2 -30
- package/dist/crypto/blob-id.js.map +1 -1
- package/dist/crypto/canonical-json.d.ts +5 -3
- package/dist/crypto/canonical-json.d.ts.map +1 -1
- package/dist/crypto/canonical-json.js +5 -85
- package/dist/crypto/canonical-json.js.map +1 -1
- package/dist/crypto/commitment.d.ts +3 -9
- package/dist/crypto/commitment.d.ts.map +1 -1
- package/dist/crypto/commitment.js +3 -27
- package/dist/crypto/commitment.js.map +1 -1
- package/dist/crypto/encryption-service.d.ts +3 -0
- package/dist/crypto/encryption-service.d.ts.map +1 -1
- package/dist/crypto/encryption-service.js +10 -6
- package/dist/crypto/encryption-service.js.map +1 -1
- package/dist/crypto/envelope-cbor.d.ts +4 -34
- package/dist/crypto/envelope-cbor.d.ts.map +1 -1
- package/dist/crypto/envelope-cbor.js +4 -121
- package/dist/crypto/envelope-cbor.js.map +1 -1
- package/dist/crypto/envelope.d.ts +1 -31
- package/dist/crypto/envelope.d.ts.map +1 -1
- package/dist/crypto/envelope.js +31 -137
- package/dist/crypto/envelope.js.map +1 -1
- package/dist/crypto/hkdf.d.ts +7 -11
- package/dist/crypto/hkdf.d.ts.map +1 -1
- package/dist/crypto/hkdf.js +9 -18
- package/dist/crypto/hkdf.js.map +1 -1
- package/dist/crypto/index.d.ts +9 -4
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +9 -4
- package/dist/crypto/index.js.map +1 -1
- package/dist/crypto/ssh-keys.d.ts +17 -10
- package/dist/crypto/ssh-keys.d.ts.map +1 -1
- package/dist/crypto/ssh-keys.js +28 -108
- package/dist/crypto/ssh-keys.js.map +1 -1
- package/dist/crypto/types.d.ts +18 -88
- package/dist/crypto/types.d.ts.map +1 -1
- package/dist/crypto/types.js +3 -0
- package/dist/crypto/types.js.map +1 -1
- package/dist/pipeline/content-pipeline.d.ts.map +1 -1
- package/dist/pipeline/content-pipeline.js +19 -3
- package/dist/pipeline/content-pipeline.js.map +1 -1
- package/dist/pipeline/extract.d.ts +8 -0
- package/dist/pipeline/extract.d.ts.map +1 -1
- package/dist/pipeline/extract.js +15 -4
- package/dist/pipeline/extract.js.map +1 -1
- package/dist/pipeline/fetch-browser.d.ts +29 -0
- package/dist/pipeline/fetch-browser.d.ts.map +1 -0
- package/dist/pipeline/fetch-browser.js +98 -0
- package/dist/pipeline/fetch-browser.js.map +1 -0
- package/package.json +4 -1
- package/dist/crypto/argon2.d.ts +0 -11
- package/dist/crypto/argon2.d.ts.map +0 -1
- package/dist/crypto/argon2.js +0 -33
- package/dist/crypto/argon2.js.map +0 -1
- package/dist/crypto/invite.d.ts +0 -31
- package/dist/crypto/invite.d.ts.map +0 -1
- package/dist/crypto/invite.js +0 -139
- package/dist/crypto/invite.js.map +0 -1
- package/dist/crypto/keyring.d.ts +0 -37
- package/dist/crypto/keyring.d.ts.map +0 -1
- package/dist/crypto/keyring.js +0 -219
- package/dist/crypto/keyring.js.map +0 -1
- package/dist/crypto/known-keys.d.ts +0 -34
- package/dist/crypto/known-keys.d.ts.map +0 -1
- package/dist/crypto/known-keys.js +0 -114
- package/dist/crypto/known-keys.js.map +0 -1
- package/dist/crypto/project-keys.d.ts +0 -26
- package/dist/crypto/project-keys.d.ts.map +0 -1
- package/dist/crypto/project-keys.js +0 -69
- package/dist/crypto/project-keys.js.map +0 -1
- package/dist/crypto/secure-buffer.d.ts +0 -31
- package/dist/crypto/secure-buffer.d.ts.map +0 -1
- package/dist/crypto/secure-buffer.js +0 -61
- package/dist/crypto/secure-buffer.js.map +0 -1
- package/dist/crypto/tiers/enhanced.d.ts +0 -25
- package/dist/crypto/tiers/enhanced.d.ts.map +0 -1
- package/dist/crypto/tiers/enhanced.js +0 -56
- package/dist/crypto/tiers/enhanced.js.map +0 -1
- package/dist/crypto/tiers/maximum.d.ts +0 -19
- package/dist/crypto/tiers/maximum.d.ts.map +0 -1
- package/dist/crypto/tiers/maximum.js +0 -25
- package/dist/crypto/tiers/maximum.js.map +0 -1
- package/dist/crypto/tiers/standard.d.ts +0 -27
- package/dist/crypto/tiers/standard.d.ts.map +0 -1
- package/dist/crypto/tiers/standard.js +0 -155
- package/dist/crypto/tiers/standard.js.map +0 -1
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
interface PinnedKey {
|
|
2
|
-
fingerprint: string;
|
|
3
|
-
publicKey: string;
|
|
4
|
-
source: string;
|
|
5
|
-
firstSeen: string;
|
|
6
|
-
verifiedAt: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Pin a key for an identifier (e.g., "github:alice").
|
|
10
|
-
* Throws if the identifier is already pinned with a different fingerprint.
|
|
11
|
-
*/
|
|
12
|
-
export declare function pinKey(identifier: string, fingerprint: string, publicKey: string, source: string): void;
|
|
13
|
-
/**
|
|
14
|
-
* Get a pinned key by identifier.
|
|
15
|
-
*/
|
|
16
|
-
export declare function getPinnedKey(identifier: string): PinnedKey | null;
|
|
17
|
-
/**
|
|
18
|
-
* Check a key against the pin store.
|
|
19
|
-
*/
|
|
20
|
-
export declare function checkKeyPin(identifier: string, fingerprint: string): 'match' | 'mismatch' | 'new';
|
|
21
|
-
/**
|
|
22
|
-
* Update a pinned key after verified rotation (e.g., new key confirmed on GitHub).
|
|
23
|
-
*/
|
|
24
|
-
export declare function updatePinnedKey(identifier: string, fingerprint: string, publicKey: string, source: string): void;
|
|
25
|
-
export declare class KeyMismatchError extends Error {
|
|
26
|
-
readonly identifier: string;
|
|
27
|
-
readonly pinnedFingerprint: string;
|
|
28
|
-
readonly newFingerprint: string;
|
|
29
|
-
readonly pinnedSource: string;
|
|
30
|
-
readonly newSource: string;
|
|
31
|
-
constructor(identifier: string, pinnedFingerprint: string, newFingerprint: string, pinnedSource: string, newSource: string);
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=known-keys.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"known-keys.d.ts","sourceRoot":"","sources":["../../crypto/known-keys.ts"],"names":[],"mappings":"AASA,UAAU,SAAS;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAkCD;;;GAGG;AACH,wBAAgB,MAAM,CACpB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,IAAI,CA8BN;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAGjE;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,GAAG,UAAU,GAAG,KAAK,CAO9B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,IAAI,CAUN;AAED,qBAAa,gBAAiB,SAAQ,KAAK;aAEvB,UAAU,EAAE,MAAM;aAClB,iBAAiB,EAAE,MAAM;aACzB,cAAc,EAAE,MAAM;aACtB,YAAY,EAAE,MAAM;aACpB,SAAS,EAAE,MAAM;gBAJjB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM;CAUpC"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'node:crypto';
|
|
2
|
-
import * as fs from 'node:fs';
|
|
3
|
-
import * as path from 'node:path';
|
|
4
|
-
import * as os from 'node:os';
|
|
5
|
-
function getKnownKeysPath() {
|
|
6
|
-
return path.join(os.homedir(), '.chaoskb', 'known_keys.json');
|
|
7
|
-
}
|
|
8
|
-
function fingerprintsEqual(a, b) {
|
|
9
|
-
const aBuf = Buffer.from(a);
|
|
10
|
-
const bBuf = Buffer.from(b);
|
|
11
|
-
if (aBuf.length !== bBuf.length)
|
|
12
|
-
return false;
|
|
13
|
-
return crypto.timingSafeEqual(aBuf, bBuf);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Trust on First Use (TOFU) key pinning for invite recipients.
|
|
17
|
-
*
|
|
18
|
-
* When we first see a recipient's public key (from GitHub, GitLab, or direct),
|
|
19
|
-
* we pin it. On subsequent invites, we check if the key has changed.
|
|
20
|
-
* A key mismatch triggers a warning; a conflict with an independent source
|
|
21
|
-
* is a hard block.
|
|
22
|
-
*/
|
|
23
|
-
function loadStore() {
|
|
24
|
-
try {
|
|
25
|
-
return JSON.parse(fs.readFileSync(getKnownKeysPath(), 'utf-8'));
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
return {};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function saveStore(store) {
|
|
32
|
-
const dir = path.dirname(getKnownKeysPath());
|
|
33
|
-
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
34
|
-
fs.writeFileSync(getKnownKeysPath(), JSON.stringify(store, null, 2), { mode: 0o600 });
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Pin a key for an identifier (e.g., "github:alice").
|
|
38
|
-
* Throws if the identifier is already pinned with a different fingerprint.
|
|
39
|
-
*/
|
|
40
|
-
export function pinKey(identifier, fingerprint, publicKey, source) {
|
|
41
|
-
const store = loadStore();
|
|
42
|
-
const existing = store[identifier];
|
|
43
|
-
if (existing && !fingerprintsEqual(existing.fingerprint, fingerprint)) {
|
|
44
|
-
throw new KeyMismatchError(identifier, existing.fingerprint, fingerprint, existing.source, source);
|
|
45
|
-
}
|
|
46
|
-
if (existing && fingerprintsEqual(existing.fingerprint, fingerprint)) {
|
|
47
|
-
// Same key — update verifiedAt
|
|
48
|
-
existing.verifiedAt = new Date().toISOString();
|
|
49
|
-
saveStore(store);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
// New key — pin it
|
|
53
|
-
store[identifier] = {
|
|
54
|
-
fingerprint,
|
|
55
|
-
publicKey,
|
|
56
|
-
source,
|
|
57
|
-
firstSeen: new Date().toISOString(),
|
|
58
|
-
verifiedAt: new Date().toISOString(),
|
|
59
|
-
};
|
|
60
|
-
saveStore(store);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Get a pinned key by identifier.
|
|
64
|
-
*/
|
|
65
|
-
export function getPinnedKey(identifier) {
|
|
66
|
-
const store = loadStore();
|
|
67
|
-
return store[identifier] ?? null;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Check a key against the pin store.
|
|
71
|
-
*/
|
|
72
|
-
export function checkKeyPin(identifier, fingerprint) {
|
|
73
|
-
const store = loadStore();
|
|
74
|
-
const existing = store[identifier];
|
|
75
|
-
if (!existing)
|
|
76
|
-
return 'new';
|
|
77
|
-
if (fingerprintsEqual(existing.fingerprint, fingerprint))
|
|
78
|
-
return 'match';
|
|
79
|
-
return 'mismatch';
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Update a pinned key after verified rotation (e.g., new key confirmed on GitHub).
|
|
83
|
-
*/
|
|
84
|
-
export function updatePinnedKey(identifier, fingerprint, publicKey, source) {
|
|
85
|
-
const store = loadStore();
|
|
86
|
-
store[identifier] = {
|
|
87
|
-
fingerprint,
|
|
88
|
-
publicKey,
|
|
89
|
-
source,
|
|
90
|
-
firstSeen: store[identifier]?.firstSeen ?? new Date().toISOString(),
|
|
91
|
-
verifiedAt: new Date().toISOString(),
|
|
92
|
-
};
|
|
93
|
-
saveStore(store);
|
|
94
|
-
}
|
|
95
|
-
export class KeyMismatchError extends Error {
|
|
96
|
-
identifier;
|
|
97
|
-
pinnedFingerprint;
|
|
98
|
-
newFingerprint;
|
|
99
|
-
pinnedSource;
|
|
100
|
-
newSource;
|
|
101
|
-
constructor(identifier, pinnedFingerprint, newFingerprint, pinnedSource, newSource) {
|
|
102
|
-
super(`Key mismatch for ${identifier}:\n` +
|
|
103
|
-
` Pinned: ${pinnedFingerprint} (source: ${pinnedSource})\n` +
|
|
104
|
-
` Received: ${newFingerprint} (source: ${newSource})\n` +
|
|
105
|
-
`This may indicate a compromised key source. The operation was blocked.`);
|
|
106
|
-
this.identifier = identifier;
|
|
107
|
-
this.pinnedFingerprint = pinnedFingerprint;
|
|
108
|
-
this.newFingerprint = newFingerprint;
|
|
109
|
-
this.pinnedSource = pinnedSource;
|
|
110
|
-
this.newSource = newSource;
|
|
111
|
-
this.name = 'KeyMismatchError';
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=known-keys.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"known-keys.js","sourceRoot":"","sources":["../../crypto/known-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,SAAS,gBAAgB;IACvB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAChE,CAAC;AAYD,SAAS,iBAAiB,CAAC,CAAS,EAAE,CAAS;IAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC9C,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;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IACA;IACA;IACA;IALlB,YACkB,UAAkB,EAClB,iBAAyB,EACzB,cAAsB,EACtB,YAAoB,EACpB,SAAiB;QAEjC,KAAK,CACH,oBAAoB,UAAU,KAAK;YACnC,eAAe,iBAAiB,aAAa,YAAY,KAAK;YAC9D,eAAe,cAAc,aAAa,SAAS,KAAK;YACxD,wEAAwE,CACzE,CAAC;QAXc,eAAU,GAAV,UAAU,CAAQ;QAClB,sBAAiB,GAAjB,iBAAiB,CAAQ;QACzB,mBAAc,GAAd,cAAc,CAAQ;QACtB,iBAAY,GAAZ,YAAY,CAAQ;QACpB,cAAS,GAAT,SAAS,CAAQ;QAQjC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ISecureBuffer } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Create a new random project key and wrap it with the personal master key.
|
|
4
|
-
*
|
|
5
|
-
* Uses HKDF to derive a wrapping key from the master key, then encrypts
|
|
6
|
-
* the project key with XChaCha20-Poly1305. AAD can include a project name
|
|
7
|
-
* for binding.
|
|
8
|
-
*
|
|
9
|
-
* @param personalMasterKey - The user's personal master key
|
|
10
|
-
* @param projectName - Optional project name for AAD binding
|
|
11
|
-
* @returns The project key (SecureBuffer) and the wrapped (encrypted) form
|
|
12
|
-
*/
|
|
13
|
-
export declare function createProjectKey(personalMasterKey: ISecureBuffer, projectName?: string): {
|
|
14
|
-
projectKey: ISecureBuffer;
|
|
15
|
-
wrappedKey: Uint8Array;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Unwrap a project key using the personal master key.
|
|
19
|
-
*
|
|
20
|
-
* @param wrappedKey - The wrapped project key (nonce || ciphertext || tag)
|
|
21
|
-
* @param personalMasterKey - The user's personal master key
|
|
22
|
-
* @param projectName - Optional project name for AAD binding (must match what was used during wrapping)
|
|
23
|
-
* @returns The unwrapped project key as a SecureBuffer
|
|
24
|
-
*/
|
|
25
|
-
export declare function unwrapProjectKey(wrappedKey: Uint8Array, personalMasterKey: ISecureBuffer, projectName?: string): ISecureBuffer;
|
|
26
|
-
//# sourceMappingURL=project-keys.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-keys.d.ts","sourceRoot":"","sources":["../../crypto/project-keys.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKhD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,iBAAiB,EAAE,aAAa,EAChC,WAAW,CAAC,EAAE,MAAM,GACnB;IAAE,UAAU,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CA8BvD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,aAAa,EAChC,WAAW,CAAC,EAAE,MAAM,GACnB,aAAa,CA+Bf"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from 'node:crypto';
|
|
2
|
-
import { aeadEncrypt, aeadDecrypt } from './aead.js';
|
|
3
|
-
import { deriveKey } from './hkdf.js';
|
|
4
|
-
import { SecureBuffer } from './secure-buffer.js';
|
|
5
|
-
const PROJECT_KEY_LENGTH = 32;
|
|
6
|
-
const WRAP_INFO = 'chaoskb-project-wrap';
|
|
7
|
-
/**
|
|
8
|
-
* Create a new random project key and wrap it with the personal master key.
|
|
9
|
-
*
|
|
10
|
-
* Uses HKDF to derive a wrapping key from the master key, then encrypts
|
|
11
|
-
* the project key with XChaCha20-Poly1305. AAD can include a project name
|
|
12
|
-
* for binding.
|
|
13
|
-
*
|
|
14
|
-
* @param personalMasterKey - The user's personal master key
|
|
15
|
-
* @param projectName - Optional project name for AAD binding
|
|
16
|
-
* @returns The project key (SecureBuffer) and the wrapped (encrypted) form
|
|
17
|
-
*/
|
|
18
|
-
export function createProjectKey(personalMasterKey, projectName) {
|
|
19
|
-
// Generate random 32-byte project key
|
|
20
|
-
const projectKeyBytes = randomBytes(PROJECT_KEY_LENGTH);
|
|
21
|
-
// Derive a wrapping key via HKDF
|
|
22
|
-
const wrappingKey = deriveKey(new Uint8Array(personalMasterKey.buffer), WRAP_INFO);
|
|
23
|
-
// AAD: project name if available, otherwise empty
|
|
24
|
-
const aad = projectName
|
|
25
|
-
? new TextEncoder().encode(projectName)
|
|
26
|
-
: new Uint8Array(0);
|
|
27
|
-
// Encrypt project key with XChaCha20-Poly1305
|
|
28
|
-
const { nonce, ciphertext, tag } = aeadEncrypt(wrappingKey, projectKeyBytes, aad);
|
|
29
|
-
// Zero wrapping key and plaintext project key bytes
|
|
30
|
-
wrappingKey.fill(0);
|
|
31
|
-
// Serialize: nonce(24) || ciphertext || tag(16)
|
|
32
|
-
const wrappedKey = new Uint8Array(nonce.length + ciphertext.length + tag.length);
|
|
33
|
-
wrappedKey.set(nonce, 0);
|
|
34
|
-
wrappedKey.set(ciphertext, nonce.length);
|
|
35
|
-
wrappedKey.set(tag, nonce.length + ciphertext.length);
|
|
36
|
-
const projectKey = SecureBuffer.from(projectKeyBytes);
|
|
37
|
-
return { projectKey, wrappedKey };
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Unwrap a project key using the personal master key.
|
|
41
|
-
*
|
|
42
|
-
* @param wrappedKey - The wrapped project key (nonce || ciphertext || tag)
|
|
43
|
-
* @param personalMasterKey - The user's personal master key
|
|
44
|
-
* @param projectName - Optional project name for AAD binding (must match what was used during wrapping)
|
|
45
|
-
* @returns The unwrapped project key as a SecureBuffer
|
|
46
|
-
*/
|
|
47
|
-
export function unwrapProjectKey(wrappedKey, personalMasterKey, projectName) {
|
|
48
|
-
const NONCE_SIZE = 24;
|
|
49
|
-
const TAG_SIZE = 16;
|
|
50
|
-
if (wrappedKey.length < NONCE_SIZE + TAG_SIZE + 1) {
|
|
51
|
-
throw new Error('Wrapped key is too short');
|
|
52
|
-
}
|
|
53
|
-
// Derive the same wrapping key
|
|
54
|
-
const wrappingKey = deriveKey(new Uint8Array(personalMasterKey.buffer), WRAP_INFO);
|
|
55
|
-
// Split wrapped key into nonce, ciphertext, tag
|
|
56
|
-
const nonce = wrappedKey.slice(0, NONCE_SIZE);
|
|
57
|
-
const ciphertext = wrappedKey.slice(NONCE_SIZE, wrappedKey.length - TAG_SIZE);
|
|
58
|
-
const tag = wrappedKey.slice(wrappedKey.length - TAG_SIZE);
|
|
59
|
-
// AAD: project name if available, otherwise empty
|
|
60
|
-
const aad = projectName
|
|
61
|
-
? new TextEncoder().encode(projectName)
|
|
62
|
-
: new Uint8Array(0);
|
|
63
|
-
// Decrypt
|
|
64
|
-
const projectKeyBytes = aeadDecrypt(wrappingKey, nonce, ciphertext, tag, aad);
|
|
65
|
-
// Zero wrapping key
|
|
66
|
-
wrappingKey.fill(0);
|
|
67
|
-
return SecureBuffer.from(Buffer.from(projectKeyBytes));
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=project-keys.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-keys.js","sourceRoot":"","sources":["../../crypto/project-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,iBAAgC,EAChC,WAAoB;IAEpB,sCAAsC;IACtC,MAAM,eAAe,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAExD,iCAAiC;IACjC,MAAM,WAAW,GAAG,SAAS,CAC3B,IAAI,U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C/B,MAAM,WAAW,GAAG,SAAS,CAC3B,IAAI,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,EACxC,SAAS,CACV,CAAC;IAEF,gDAAgD;IAChD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;IAC9E,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;IAE3D,kDAAkD;IAClD,MAAM,GAAG,GAAG,WAAW;QACrB,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC;QACvC,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAEtB,UAAU;IACV,MAAM,eAAe,GAAG,WAAW,CAAC,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAE9E,oBAAoB;IACpB,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEpB,OAAO,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ISecureBuffer } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Memory-locked buffer for sensitive key material.
|
|
4
|
-
* Uses sodium_malloc (mlock'd pages) and sodium_memzero on dispose.
|
|
5
|
-
*/
|
|
6
|
-
export declare class SecureBuffer implements ISecureBuffer {
|
|
7
|
-
private _buffer;
|
|
8
|
-
private _disposed;
|
|
9
|
-
private constructor();
|
|
10
|
-
/** Read the buffer contents. Throws if disposed. */
|
|
11
|
-
get buffer(): Buffer;
|
|
12
|
-
/** Byte length of the buffer. */
|
|
13
|
-
get length(): number;
|
|
14
|
-
/** Whether the buffer has been zeroed and disposed. */
|
|
15
|
-
get isDisposed(): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Zero the buffer contents and mark as disposed.
|
|
18
|
-
* Safe to call multiple times (idempotent).
|
|
19
|
-
*/
|
|
20
|
-
dispose(): void;
|
|
21
|
-
/** Support `using` keyword (TC39 Explicit Resource Management). */
|
|
22
|
-
[Symbol.dispose](): void;
|
|
23
|
-
/**
|
|
24
|
-
* Copy data into a new SecureBuffer and zero the source.
|
|
25
|
-
* The source buffer is zeroed after copying regardless of type.
|
|
26
|
-
*/
|
|
27
|
-
static from(data: Buffer | Uint8Array): SecureBuffer;
|
|
28
|
-
/** Allocate a new zeroed SecureBuffer of the given length. */
|
|
29
|
-
static alloc(length: number): SecureBuffer;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=secure-buffer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secure-buffer.d.ts","sourceRoot":"","sources":["../../crypto/secure-buffer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;GAGG;AACH,qBAAa,YAAa,YAAW,aAAa;IAChD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO;IAIP,oDAAoD;IACpD,IAAI,MAAM,IAAI,MAAM,CAKnB;IAED,iCAAiC;IACjC,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,uDAAuD;IACvD,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;;OAGG;IACH,OAAO,IAAI,IAAI;IAQf,mEAAmE;IACnE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAIxB;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY;IASpD,8DAA8D;IAC9D,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;CAK3C"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import sodium from 'sodium-native';
|
|
2
|
-
/**
|
|
3
|
-
* Memory-locked buffer for sensitive key material.
|
|
4
|
-
* Uses sodium_malloc (mlock'd pages) and sodium_memzero on dispose.
|
|
5
|
-
*/
|
|
6
|
-
export class SecureBuffer {
|
|
7
|
-
_buffer;
|
|
8
|
-
_disposed = false;
|
|
9
|
-
constructor(length) {
|
|
10
|
-
this._buffer = sodium.sodium_malloc(length);
|
|
11
|
-
}
|
|
12
|
-
/** Read the buffer contents. Throws if disposed. */
|
|
13
|
-
get buffer() {
|
|
14
|
-
if (this._disposed) {
|
|
15
|
-
throw new Error('SecureBuffer has been disposed');
|
|
16
|
-
}
|
|
17
|
-
return this._buffer;
|
|
18
|
-
}
|
|
19
|
-
/** Byte length of the buffer. */
|
|
20
|
-
get length() {
|
|
21
|
-
return this._buffer.byteLength;
|
|
22
|
-
}
|
|
23
|
-
/** Whether the buffer has been zeroed and disposed. */
|
|
24
|
-
get isDisposed() {
|
|
25
|
-
return this._disposed;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Zero the buffer contents and mark as disposed.
|
|
29
|
-
* Safe to call multiple times (idempotent).
|
|
30
|
-
*/
|
|
31
|
-
dispose() {
|
|
32
|
-
if (this._disposed) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
sodium.sodium_memzero(this._buffer);
|
|
36
|
-
this._disposed = true;
|
|
37
|
-
}
|
|
38
|
-
/** Support `using` keyword (TC39 Explicit Resource Management). */
|
|
39
|
-
[Symbol.dispose]() {
|
|
40
|
-
this.dispose();
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Copy data into a new SecureBuffer and zero the source.
|
|
44
|
-
* The source buffer is zeroed after copying regardless of type.
|
|
45
|
-
*/
|
|
46
|
-
static from(data) {
|
|
47
|
-
const sb = new SecureBuffer(data.byteLength);
|
|
48
|
-
const buf = Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
|
49
|
-
buf.copy(sb._buffer);
|
|
50
|
-
// Zero the source
|
|
51
|
-
sodium.sodium_memzero(buf);
|
|
52
|
-
return sb;
|
|
53
|
-
}
|
|
54
|
-
/** Allocate a new zeroed SecureBuffer of the given length. */
|
|
55
|
-
static alloc(length) {
|
|
56
|
-
const sb = new SecureBuffer(length);
|
|
57
|
-
sodium.sodium_memzero(sb._buffer);
|
|
58
|
-
return sb;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=secure-buffer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secure-buffer.js","sourceRoot":"","sources":["../../crypto/secure-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,eAAe,CAAC;AAInC;;;GAGG;AACH,MAAM,OAAO,YAAY;IACf,OAAO,CAAS;IAChB,SAAS,GAAG,KAAK,CAAC;IAE1B,YAAoB,MAAc;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED,oDAAoD;IACpD,IAAI,MAAM;QACR,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,iCAAiC;IACjC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IACjC,CAAC;IAED,uDAAuD;IACvD,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QACD,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,mEAAmE;IACnE,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,IAAyB;QACnC,MAAM,EAAE,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACtG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QACrB,kBAAkB;QAClB,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,8DAA8D;IAC9D,MAAM,CAAC,KAAK,CAAC,MAAc;QACzB,MAAM,EAAE,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QACpC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAClC,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ISecureBuffer } from '../types.js';
|
|
2
|
-
export { wrapMasterKey, unwrapMasterKeyEd25519, unwrapMasterKeyRSA } from './standard.js';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Enhanced tier is deprecated. New installations use Standard or Maximum only.
|
|
5
|
-
*
|
|
6
|
-
* Enhanced tier: BIP39 24-word recovery key.
|
|
7
|
-
*
|
|
8
|
-
* The master key is a 256-bit random value which maps directly to a 24-word
|
|
9
|
-
* BIP39 mnemonic. Either the mnemonic or the SSH-wrapped key can recover.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Use Standard tier (SSH key wrapping) instead.
|
|
13
|
-
*
|
|
14
|
-
* Encode a 256-bit master key as a 24-word BIP39 mnemonic.
|
|
15
|
-
* The master key bytes are used directly as the entropy.
|
|
16
|
-
*/
|
|
17
|
-
export declare function generateRecoveryKey(masterKey: ISecureBuffer): string;
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated Use Standard tier (SSH key wrapping) instead.
|
|
20
|
-
*
|
|
21
|
-
* Decode a 24-word BIP39 mnemonic back to the 256-bit master key.
|
|
22
|
-
* Returns a SecureBuffer containing the recovered key.
|
|
23
|
-
*/
|
|
24
|
-
export declare function recoverFromMnemonic(mnemonic: string): ISecureBuffer;
|
|
25
|
-
//# sourceMappingURL=enhanced.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enhanced.d.ts","sourceRoot":"","sources":["../../../crypto/tiers/enhanced.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE1F;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAQpE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAoBnE"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// Enhanced tier removed — see doc/analysis/zero-config-sync/security-tiers.md
|
|
2
|
-
// This file is deprecated. The zero-config sync implementation uses only two tiers:
|
|
3
|
-
// - Standard: SSH key wrapping (automatic, zero-config)
|
|
4
|
-
// - Maximum: Argon2id passphrase derivation
|
|
5
|
-
// The Enhanced (BIP39 mnemonic) tier added complexity without meaningful security
|
|
6
|
-
// benefit over the Standard tier's SSH-based recovery. Retained for backward
|
|
7
|
-
// compatibility with existing Enhanced-tier users.
|
|
8
|
-
import * as bip39 from 'bip39';
|
|
9
|
-
import { SecureBuffer } from '../secure-buffer.js';
|
|
10
|
-
// Re-export standard tier wrapping for dual-path recovery
|
|
11
|
-
export { wrapMasterKey, unwrapMasterKeyEd25519, unwrapMasterKeyRSA } from './standard.js';
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Enhanced tier is deprecated. New installations use Standard or Maximum only.
|
|
14
|
-
*
|
|
15
|
-
* Enhanced tier: BIP39 24-word recovery key.
|
|
16
|
-
*
|
|
17
|
-
* The master key is a 256-bit random value which maps directly to a 24-word
|
|
18
|
-
* BIP39 mnemonic. Either the mnemonic or the SSH-wrapped key can recover.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use Standard tier (SSH key wrapping) instead.
|
|
22
|
-
*
|
|
23
|
-
* Encode a 256-bit master key as a 24-word BIP39 mnemonic.
|
|
24
|
-
* The master key bytes are used directly as the entropy.
|
|
25
|
-
*/
|
|
26
|
-
export function generateRecoveryKey(masterKey) {
|
|
27
|
-
if (masterKey.length !== 32) {
|
|
28
|
-
throw new Error(`Master key must be 32 bytes (256 bits), got ${masterKey.length}`);
|
|
29
|
-
}
|
|
30
|
-
const entropy = Buffer.from(masterKey.buffer).toString('hex');
|
|
31
|
-
const mnemonic = bip39.entropyToMnemonic(entropy);
|
|
32
|
-
return mnemonic;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated Use Standard tier (SSH key wrapping) instead.
|
|
36
|
-
*
|
|
37
|
-
* Decode a 24-word BIP39 mnemonic back to the 256-bit master key.
|
|
38
|
-
* Returns a SecureBuffer containing the recovered key.
|
|
39
|
-
*/
|
|
40
|
-
export function recoverFromMnemonic(mnemonic) {
|
|
41
|
-
const trimmed = mnemonic.trim().toLowerCase();
|
|
42
|
-
if (!bip39.validateMnemonic(trimmed)) {
|
|
43
|
-
throw new Error('Invalid BIP39 mnemonic');
|
|
44
|
-
}
|
|
45
|
-
const words = trimmed.split(/\s+/);
|
|
46
|
-
if (words.length !== 24) {
|
|
47
|
-
throw new Error(`Expected 24-word mnemonic, got ${words.length} words`);
|
|
48
|
-
}
|
|
49
|
-
const entropyHex = bip39.mnemonicToEntropy(trimmed);
|
|
50
|
-
const entropyBytes = Buffer.from(entropyHex, 'hex');
|
|
51
|
-
if (entropyBytes.length !== 32) {
|
|
52
|
-
throw new Error(`Recovered entropy must be 32 bytes, got ${entropyBytes.length}`);
|
|
53
|
-
}
|
|
54
|
-
return SecureBuffer.from(entropyBytes);
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=enhanced.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enhanced.js","sourceRoot":"","sources":["../../../crypto/tiers/enhanced.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,oFAAoF;AACpF,0DAA0D;AAC1D,8CAA8C;AAC9C,kFAAkF;AAClF,6EAA6E;AAC7E,mDAAmD;AAEnD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE1F;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAwB;IAC1D,IAAI,SAAS,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,+CAA+C,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAClD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE9C,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,CAAC,MAAM,QAAQ,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACpD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAEpD,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,2CAA2C,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,OAAO,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ISecureBuffer } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Maximum tier: Argon2id passphrase derivation.
|
|
4
|
-
*
|
|
5
|
-
* The master key is derived from a user-chosen passphrase.
|
|
6
|
-
* No recovery path — if the passphrase is lost, data is lost.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Derive a master key from a passphrase using Argon2id.
|
|
10
|
-
*
|
|
11
|
-
* @param passphrase - User passphrase
|
|
12
|
-
* @param salt - Optional 16-byte salt. If not provided, a random one is generated.
|
|
13
|
-
* @returns Object with the derived master key and the salt (for server storage)
|
|
14
|
-
*/
|
|
15
|
-
export declare function deriveFromPassphrase(passphrase: string, salt?: Uint8Array): {
|
|
16
|
-
masterKey: ISecureBuffer;
|
|
17
|
-
salt: Uint8Array;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=maximum.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"maximum.d.ts","sourceRoot":"","sources":["../../../crypto/tiers/maximum.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD;;;;;GAKG;AAEH;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,UAAU,GAChB;IAAE,SAAS,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAUhD"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from 'node:crypto';
|
|
2
|
-
import { deriveFromPassphrase as argon2Derive } from '../argon2.js';
|
|
3
|
-
const SALT_LENGTH = 16;
|
|
4
|
-
/**
|
|
5
|
-
* Maximum tier: Argon2id passphrase derivation.
|
|
6
|
-
*
|
|
7
|
-
* The master key is derived from a user-chosen passphrase.
|
|
8
|
-
* No recovery path — if the passphrase is lost, data is lost.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Derive a master key from a passphrase using Argon2id.
|
|
12
|
-
*
|
|
13
|
-
* @param passphrase - User passphrase
|
|
14
|
-
* @param salt - Optional 16-byte salt. If not provided, a random one is generated.
|
|
15
|
-
* @returns Object with the derived master key and the salt (for server storage)
|
|
16
|
-
*/
|
|
17
|
-
export function deriveFromPassphrase(passphrase, salt) {
|
|
18
|
-
const actualSalt = salt ?? new Uint8Array(randomBytes(SALT_LENGTH));
|
|
19
|
-
if (actualSalt.length !== SALT_LENGTH) {
|
|
20
|
-
throw new Error(`Salt must be ${SALT_LENGTH} bytes, got ${actualSalt.length}`);
|
|
21
|
-
}
|
|
22
|
-
const masterKey = argon2Derive(passphrase, actualSalt);
|
|
23
|
-
return { masterKey, salt: actualSalt };
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=maximum.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"maximum.js","sourceRoot":"","sources":["../../../crypto/tiers/maximum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,MAAM,cAAc,CAAC;AAGpE,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;;;GAKG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAkB,EAClB,IAAiB;IAEjB,MAAM,UAAU,GAAG,IAAI,IAAI,IAAI,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;IAEpE,IAAI,UAAU,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,gBAAgB,WAAW,eAAe,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAEvD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'node:crypto';
|
|
2
|
-
import type { ISecureBuffer, SSHKeyInfo } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Standard tier: SSH key wrapping.
|
|
5
|
-
*
|
|
6
|
-
* For Ed25519 keys: crypto_box_seal (ephemeral X25519 ECDH + XSalsa20-Poly1305)
|
|
7
|
-
* For RSA keys: RSA-OAEP-SHA256 KEM + XChaCha20-Poly1305 DEM
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Wrap a master key with an SSH public key.
|
|
11
|
-
* Ed25519: uses crypto_box_seal after converting to X25519.
|
|
12
|
-
* RSA: uses RSA-OAEP KEM + XChaCha20-Poly1305 DEM.
|
|
13
|
-
*/
|
|
14
|
-
export declare function wrapMasterKey(masterKey: ISecureBuffer, sshPublicKey: SSHKeyInfo): Uint8Array;
|
|
15
|
-
/**
|
|
16
|
-
* Unwrap a master key with an SSH private key (Ed25519).
|
|
17
|
-
* @param wrappedKey - The sealed box
|
|
18
|
-
* @param ed25519SecretKey - The 64-byte Ed25519 secret key
|
|
19
|
-
*/
|
|
20
|
-
export declare function unwrapMasterKeyEd25519(wrappedKey: Uint8Array, ed25519SecretKey: Uint8Array, ed25519PublicKey: Uint8Array): ISecureBuffer;
|
|
21
|
-
/**
|
|
22
|
-
* Unwrap a master key wrapped with RSA-OAEP KEM + DEM.
|
|
23
|
-
* @param wrappedKey - Serialized [4-byte wrappedWKLen][wrappedWK][nonce][ct][tag]
|
|
24
|
-
* @param rsaPrivateKey - RSA private key in PEM or DER format
|
|
25
|
-
*/
|
|
26
|
-
export declare function unwrapMasterKeyRSA(wrappedKey: Uint8Array, rsaPrivateKey: crypto.KeyObject): ISecureBuffer;
|
|
27
|
-
//# sourceMappingURL=standard.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard.d.ts","sourceRoot":"","sources":["../../../crypto/tiers/standard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAMtC,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI7D;;;;;GAKG;AAEH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,GAAG,UAAU,CAO5F;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,UAAU,EAC5B,gBAAgB,EAAE,UAAU,GAC3B,aAAa,CAmBf;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,MAAM,CAAC,SAAS,GAC9B,aAAa,CA0Cf"}
|