@shieldfive/crypto 1.0.0-rc.4 → 1.0.0-rc.6
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/CHANGELOG.md +41 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/types.d.ts +2 -0
- package/dist/internal/types.d.ts.map +1 -1
- package/dist/internal/types.js +9 -0
- package/dist/internal/types.js.map +1 -1
- package/dist/vault/index.d.ts +214 -0
- package/dist/vault/index.d.ts.map +1 -0
- package/dist/vault/index.js +520 -0
- package/dist/vault/index.js.map +1 -0
- package/package.json +6 -1
- package/spec/key-derivation.md +2 -0
- package/spec/vault-formats.md +101 -0
- package/src/index.ts +2 -1
- package/src/internal/types.ts +9 -0
- package/src/vault/index.ts +805 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,43 @@ All notable changes to `@shieldfive/crypto` will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 1.0.0-rc.6
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `buildUploadProofV3` (`@shieldfive/crypto/vault`): the upload proof for a
|
|
13
|
+
PQ-hybrid object, in the frame the ShieldFive server verifies — base64 of
|
|
14
|
+
`[0x03][0x03] || HMAC-SHA256(proofKey, [0x03][0x03] || header || chunk_0)`.
|
|
15
|
+
Two clients now produce it (the web app and the MCP server's upload path) and
|
|
16
|
+
a second hand-written implementation is how they would silently diverge. The
|
|
17
|
+
test builds the same frame independently with `node:crypto` and compares.
|
|
18
|
+
|
|
19
|
+
## 1.0.0-rc.5 — 2026-09-18
|
|
20
|
+
|
|
21
|
+
No change to any file-encryption suite. Adds `@shieldfive/crypto/vault`,
|
|
22
|
+
which gives non-browser clients a single reviewed implementation of the
|
|
23
|
+
formats the web app stores, plus the new agent-grant wrap.
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- **Vault key chain.** `wrapChainKey` and `unwrapChainKey` implement the
|
|
28
|
+
AES-256-GCM raw-key wrap used by `fk_wrapped`, `csk_wrapped` and
|
|
29
|
+
`pqk_fk_wrapped`.
|
|
30
|
+
- **Name envelopes.** `parseNameEnvelope`, `decryptName` (v4 and v6, with the
|
|
31
|
+
web app's fallback when `kdf` is missing) and `encryptNameV6` (AAD = row
|
|
32
|
+
UUID).
|
|
33
|
+
- **Agent grants.** `createGrantCredential`, `formatConnectionString` and
|
|
34
|
+
`parseConnectionString`, `hashGrantToken`, `deriveGrantWrapKey` (new HKDF
|
|
35
|
+
label `shieldfive/v1/agent-grant/wrap`), and `wrapKeyForGrant` /
|
|
36
|
+
`unwrapKeyForGrant` (kinds `folder`, `file`, `file_pq`, `name`), and
|
|
37
|
+
`decryptNameWithKey`, and `wrapGrantSecret` / `unwrapGrantSecret` for the owner's
|
|
38
|
+
copy of a grant secret, authenticated against a `canonicalGrantScope` (new
|
|
39
|
+
HKDF label `shieldfive/v1/agent-grant/secret`). Every wrap is bound to its grant, object kind and
|
|
40
|
+
object id.
|
|
41
|
+
- `spec/vault-formats.md`, and vectors generated from an independent
|
|
42
|
+
implementation (`@noble/hashes` Argon2id plus raw Web Crypto) in
|
|
43
|
+
`tests/vectors/vault-vectors.json`.
|
|
44
|
+
|
|
8
45
|
## 1.0.0-rc.3 — 2026-08-03
|
|
9
46
|
|
|
10
47
|
No wire-format changes; suite `0x03` and the identity bundle are untouched. Adds
|
|
@@ -265,7 +302,7 @@ top-level exports that downstream consumers depend on.
|
|
|
265
302
|
(it was pinned at `1.0.0-alpha.11`). The constant is informational
|
|
266
303
|
only — it is never written into file output or any test vector.
|
|
267
304
|
- Corrected a backwards source comment in the `aes-gcm-v2` suite: the
|
|
268
|
-
cross-file nonce-prefix space
|
|
305
|
+
cross-file nonce-prefix space _widens_ from 2^32 to 2^64 (the comment
|
|
269
306
|
previously said "shrinks"). No behavior change — the README and
|
|
270
307
|
CHANGELOG already described it correctly as widening.
|
|
271
308
|
|
|
@@ -288,9 +325,9 @@ top-level exports that downstream consumers depend on.
|
|
|
288
325
|
### Added
|
|
289
326
|
|
|
290
327
|
- Cipher suite 0x04 `aes-gcm-v2`: 8-byte HKDF-derived nonce prefix
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
328
|
+
- 4-byte BE chunk counter. Widens the cross-file IV-collision
|
|
329
|
+
space from 2^32 to 2^64 while keeping the IV at 12 bytes. v1
|
|
330
|
+
(suite 0x01) stays decrypt-only on the umbrella export.
|
|
294
331
|
- Optional sender-attribution signatures (`src/identity/sign.ts`).
|
|
295
332
|
Detached Ed25519 (alg 0x01) over
|
|
296
333
|
`header_unauthenticated_bytes || concat(chunk_macs)`, appended as
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export * as kdfArgon2id from './kdf/argon2id.js';
|
|
|
34
34
|
export * as identity from './identity/index.js';
|
|
35
35
|
export * as inbound from './identity/inbound.js';
|
|
36
36
|
export * as migrationV0 from './migration/v0-bridge.js';
|
|
37
|
+
export * as vault from './vault/index.js';
|
|
37
38
|
import { type ProgressCallback } from './internal/types.js';
|
|
38
39
|
export interface AutoDecryptOptions {
|
|
39
40
|
blob: Blob;
|
|
@@ -54,7 +55,7 @@ export interface AutoDecryptOptions {
|
|
|
54
55
|
*/
|
|
55
56
|
export declare function autoDecryptBlob(options: AutoDecryptOptions): Promise<Blob>;
|
|
56
57
|
/** Library version, also written into format documentation. */
|
|
57
|
-
export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-rc.
|
|
58
|
+
export declare const SHIELDFIVE_CRYPTO_VERSION = "1.0.0-rc.6";
|
|
58
59
|
/** Default cipher suite for new files when not specified by the caller. */
|
|
59
60
|
export declare const DEFAULT_SUITE: 3;
|
|
60
61
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EACL,wBAAwB,EACxB,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAK3B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,EACZ,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,KAAK,EACL,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,SAAS,GACV,MAAM,qBAAqB,CAAA;AAK5B,OAAO,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,UAAU,EACV,WAAW,GACZ,MAAM,wBAAwB,CAAA;AAK/B,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,OAAO,GACR,MAAM,uBAAuB,CAAA;AAU9B,OAAO,EACL,WAAW,IAAI,mBAAmB,EAClC,cAAc,IAAI,sBAAsB,EACzC,MAAM,4BAA4B,CAAA;AACnC,eAAO,MAAM,QAAQ;;;CAGpB,CAAA;AACD,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAA;AACtD,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAA;AACvD,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAA;AAC1D,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAA;AACtD,OAAO,KAAK,eAAe,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,OAAO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MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAA;AACvD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AAMzC,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAMhF,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,IAAI,CAAA;IACV,sEAAsE;IACtE,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,kEAAkE;IAClE,kBAAkB,CAAC,EAAE,UAAU,CAAA;IAC/B,6DAA6D;IAC7D,WAAW,CAAC,EAAE,UAAU,CAAA;IACxB,wCAAwC;IACxC,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAC9B;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAsFf;AAED,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,eAAe,CAAA;AAErD,2EAA2E;AAC3E,eAAO,MAAM,aAAa,GAAuC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,7 @@ export * as kdfArgon2id from './kdf/argon2id.js';
|
|
|
53
53
|
export * as identity from './identity/index.js';
|
|
54
54
|
export * as inbound from './identity/inbound.js';
|
|
55
55
|
export * as migrationV0 from './migration/v0-bridge.js';
|
|
56
|
+
export * as vault from './vault/index.js';
|
|
56
57
|
// ──────────────────────────────────────────────────────────────────────
|
|
57
58
|
// Auto-routing decryptor
|
|
58
59
|
// ──────────────────────────────────────────────────────────────────────
|
|
@@ -141,7 +142,7 @@ export async function autoDecryptBlob(options) {
|
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
/** Library version, also written into format documentation. */
|
|
144
|
-
export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.
|
|
145
|
+
export const SHIELDFIVE_CRYPTO_VERSION = '1.0.0-rc.6';
|
|
145
146
|
/** Default cipher suite for new files when not specified by the caller. */
|
|
146
147
|
export const DEFAULT_SUITE = SUITE.PQ_HYBRID_XCHACHA_MLKEM1024_V1;
|
|
147
148
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,yEAAyE;AACzE,oBAAoB;AACpB,yEAAyE;AACzE,OAAO,EACL,wBAAwB,EACxB,aAAa,EACb,0BAA0B,EAC1B,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAE3B,yEAAyE;AACzE,iCAAiC;AACjC,yEAAyE;AACzE,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,EACZ,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,KAAK,EACL,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAS5B,yEAAyE;AACzE,gDAAgD;AAChD,yEAAyE;AACzE,OAAO,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,UAAU,EACV,WAAW,GACZ,MAAM,wBAAwB,CAAA;AAE/B,yEAAyE;AACzE,kBAAkB;AAClB,yEAAyE;AACzE,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,OAAO,GACR,MAAM,uBAAuB,CAAA;AAE9B,yEAAyE;AACzE,qDAAqD;AACrD,sEAAsE;AACtE,sEAAsE;AACtE,sEAAsE;AACtE,sEAAsE;AACtE,yCAAyC;AACzC,yEAAyE;AACzE,OAAO,EACL,WAAW,IAAI,mBAAmB,EAClC,cAAc,IAAI,sBAAsB,GACzC,MAAM,4BAA4B,CAAA;AACnC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,WAAW,EAAE,mBAAmB;IAChC,cAAc,EAAE,sBAAsB;CACvC,CAAA;AACD,OAAO,KAAK,QAAQ,MAA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AAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAClE,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,IAAI,WAAW,CACnB,oCAAqC,KAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CACrE,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,+DAA+D;AAC/D,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAY,CAAA;AAErD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,8BAA8B,CAAA"}
|
package/dist/internal/types.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export declare const HKDF_INFO: Readonly<{
|
|
|
60
60
|
INBOUND_ENVELOPE: "shieldfive/v1/inbound/envelope-key";
|
|
61
61
|
INBOUND_SIGNING_SEED: "shieldfive/v1/inbound/ed25519-signing-seed";
|
|
62
62
|
ARGON2ID_SALT_COMPRESSION: "shieldfive/v1/argon2id/salt-compression";
|
|
63
|
+
AGENT_GRANT_WRAP: "shieldfive/v1/agent-grant/wrap";
|
|
64
|
+
AGENT_GRANT_SECRET: "shieldfive/v1/agent-grant/secret";
|
|
63
65
|
}>;
|
|
64
66
|
/** AAD domain string mixed into every chunk's authenticator */
|
|
65
67
|
export declare const CHUNK_AAD_DOMAIN = "shieldfive/v1/chunk";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,YAAY,CAAA;IACpB,eAAe,CAAC,CAAC,SAAS,eAAe,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;CACxD,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAA;AAElD;;;GAGG;AACH,eAAO,M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internal/types.js
CHANGED
|
@@ -80,6 +80,15 @@ export const HKDF_INFO = Object.freeze({
|
|
|
80
80
|
// published (ml_kem || x25519) bundle so a guest can detect a key swap.
|
|
81
81
|
INBOUND_SIGNING_SEED: 'shieldfive/v1/inbound/ed25519-signing-seed',
|
|
82
82
|
ARGON2ID_SALT_COMPRESSION: 'shieldfive/v1/argon2id/salt-compression',
|
|
83
|
+
// Agent grants (src/vault): the grant secret, generated in the owner's client
|
|
84
|
+
// and never sent to the server, is expanded into the key that wraps the
|
|
85
|
+
// grant's scope-root folder keys. Salt = the grant id.
|
|
86
|
+
AGENT_GRANT_WRAP: 'shieldfive/v1/agent-grant/wrap',
|
|
87
|
+
// The owner's copy of a grant secret is wrapped under a key derived from the
|
|
88
|
+
// vault root key with this label, authenticated against the grant's scope,
|
|
89
|
+
// so no other key wrapped under RK can stand in for it and a server that
|
|
90
|
+
// edits the grant's scope makes the secret stop opening.
|
|
91
|
+
AGENT_GRANT_SECRET: 'shieldfive/v1/agent-grant/secret',
|
|
83
92
|
});
|
|
84
93
|
/** AAD domain string mixed into every chunk's authenticator */
|
|
85
94
|
export const CHUNK_AAD_DOMAIN = 'shieldfive/v1/chunk';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,cAAc,EAAE,IAAI;IACpB,qBAAqB,EAAE,IAAI;IAC3B,8BAA8B,EAAE,IAAI;IACpC,cAAc,EAAE,IAAI;CACZ,CAAA;AAUV,MAAM,CAAC,MAAM,WAAW,GAA+B;IACrD,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,gBAAgB;IACxC,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE,uBAAuB;IACtD,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE,gCAAgC;IACxE,CAAC,KAAK,CAAC,cAAc,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,sEAAsE;IACtE,wEAAwE;IACxE,oBAAoB,EAAE,4CAA4C;IAClE,yBAAyB,EAAE,yCAAyC;IACpE,8EAA8E;IAC9E,wEAAwE;IACxE,uDAAuD;IACvD,gBAAgB,EAAE,gCAAgC;IAClD,6EAA6E;IAC7E,2EAA2E;IAC3E,yEAAyE;IACzE,yDAAyD;IACzD,kBAAkB,EAAE,kCAAkC;CACvD,CAAC,CAAA;AAEF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAA;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vault key chain, name envelopes and agent grants.
|
|
3
|
+
*
|
|
4
|
+
* These are the formats the ShieldFive web app already writes to its
|
|
5
|
+
* database, reproduced here so every non-browser client (the MCP server, the
|
|
6
|
+
* CLI, the mobile app) opens them with ONE reviewed implementation instead of
|
|
7
|
+
* each carrying its own copy.
|
|
8
|
+
*
|
|
9
|
+
* Key chain folders.fk_wrapped / files.csk_wrapped / files.pqk_fk_wrapped:
|
|
10
|
+
* AES-256-GCM, 12-byte random IV stored beside the ciphertext,
|
|
11
|
+
* no AAD. The wrapping key is the parent folder key, or the vault
|
|
12
|
+
* root key for top-level objects.
|
|
13
|
+
*
|
|
14
|
+
* Names files.name / folders.name: a JSON envelope
|
|
15
|
+
* {v, ct, iv, tag, salt, kdf?}. The AES-256-GCM key is
|
|
16
|
+
* Argon2id(password = the base64 text of the parent folder key,
|
|
17
|
+
* salt). v6 additionally authenticates the row UUID as AAD so a
|
|
18
|
+
* server cannot move a name onto another row.
|
|
19
|
+
*
|
|
20
|
+
* Agent grant A fresh 32-byte secret, generated in the owner's browser and
|
|
21
|
+
* never sent to the server, wraps the grant's scope-root keys.
|
|
22
|
+
* Wrapping key = HKDF-SHA-256(secret, salt = grant id,
|
|
23
|
+
* info = HKDF_INFO.AGENT_GRANT_WRAP). Every wrap authenticates
|
|
24
|
+
* the grant id, the object kind and the object id as AAD.
|
|
25
|
+
*
|
|
26
|
+
* Nothing in this module is a new primitive: it composes AES-256-GCM,
|
|
27
|
+
* HKDF-SHA-256, SHA-256 and libsodium's Argon2id13.
|
|
28
|
+
*/
|
|
29
|
+
/** Raised for any envelope or wrap that does not open. Never carries key bytes. */
|
|
30
|
+
export declare class VaultCryptoError extends Error {
|
|
31
|
+
readonly code: "unwrap_failed" | "name_decrypt_failed" | "unsupported_envelope" | "invalid_input" | "invalid_connection_string";
|
|
32
|
+
constructor(code: VaultCryptoError["code"], message: string);
|
|
33
|
+
}
|
|
34
|
+
/** A wrapped key as the database stores it: base64 ciphertext+tag and base64 IV. */
|
|
35
|
+
export interface WrappedKey {
|
|
36
|
+
wrapped: string;
|
|
37
|
+
iv: string;
|
|
38
|
+
}
|
|
39
|
+
/** Wrap a 32-byte key under a 32-byte key (the fk/csk/pqk chain format). */
|
|
40
|
+
export declare function wrapChainKey(wrappingKey: Uint8Array, key: Uint8Array): Promise<WrappedKey>;
|
|
41
|
+
/** Open one hop of the key chain. Throws `unwrap_failed` on a wrong key or tampering. */
|
|
42
|
+
export declare function unwrapChainKey(wrappingKey: Uint8Array, wrapped: WrappedKey): Promise<Uint8Array>;
|
|
43
|
+
export type NameKdfLevel = "interactive" | "moderate";
|
|
44
|
+
export interface NameEnvelope {
|
|
45
|
+
v: 4 | 6;
|
|
46
|
+
ct: string;
|
|
47
|
+
iv: string;
|
|
48
|
+
tag: string;
|
|
49
|
+
salt: string;
|
|
50
|
+
kdf?: NameKdfLevel;
|
|
51
|
+
}
|
|
52
|
+
/** Parse a stored name. Returns null for anything that is not a v4/v6 envelope. */
|
|
53
|
+
export declare function parseNameEnvelope(raw: string | null | undefined): NameEnvelope | null;
|
|
54
|
+
/**
|
|
55
|
+
* Derive the per-envelope name key. The Argon2id password is the base64 TEXT
|
|
56
|
+
* of the folder key, byte-for-byte what the web app passes to libsodium; the
|
|
57
|
+
* input is already 256 bits of entropy, so the cost level is a compatibility
|
|
58
|
+
* parameter, not a security one.
|
|
59
|
+
*/
|
|
60
|
+
export declare function deriveNameKey(folderKey: Uint8Array, salt: Uint8Array, level: NameKdfLevel): Promise<Uint8Array>;
|
|
61
|
+
/**
|
|
62
|
+
* Decrypt a v4 or v6 name. `rowId` is the database UUID of the row the name
|
|
63
|
+
* belongs to and is REQUIRED for v6 (it is the AAD). An envelope written
|
|
64
|
+
* without a `kdf` field is tried at interactive, then moderate, which is the
|
|
65
|
+
* web app's own fallback order for a device that cannot know the level.
|
|
66
|
+
*/
|
|
67
|
+
export declare function decryptName(options: {
|
|
68
|
+
envelope: NameEnvelope;
|
|
69
|
+
folderKey: Uint8Array;
|
|
70
|
+
rowId?: string;
|
|
71
|
+
}): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Decrypt a name with an already-derived name key (a grant's `name` wrap),
|
|
74
|
+
* for objects whose parent key the caller does not hold.
|
|
75
|
+
*/
|
|
76
|
+
export declare function decryptNameWithKey(options: {
|
|
77
|
+
envelope: NameEnvelope;
|
|
78
|
+
nameKey: Uint8Array;
|
|
79
|
+
rowId?: string;
|
|
80
|
+
}): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* The name key for one envelope: what an owner wraps as a grant's `name`
|
|
83
|
+
* object. For an envelope without a `kdf` field the level is found by opening
|
|
84
|
+
* it, the same fallback `decryptName` uses, so the wrapped key always works.
|
|
85
|
+
*/
|
|
86
|
+
export declare function deriveNameKeyForEnvelope(options: {
|
|
87
|
+
envelope: NameEnvelope;
|
|
88
|
+
parentKey: Uint8Array;
|
|
89
|
+
rowId?: string;
|
|
90
|
+
}): Promise<Uint8Array>;
|
|
91
|
+
/** Encrypt a name as a v6 envelope bound to `rowId`, at the web app's default level. */
|
|
92
|
+
export declare function encryptNameV6(options: {
|
|
93
|
+
name: string;
|
|
94
|
+
folderKey: Uint8Array;
|
|
95
|
+
rowId: string;
|
|
96
|
+
}): Promise<NameEnvelope>;
|
|
97
|
+
export declare const GRANT_CONNECTION_PREFIX = "sf-grant-v1:";
|
|
98
|
+
/**
|
|
99
|
+
* What a grant wrap covers.
|
|
100
|
+
*
|
|
101
|
+
* folder a folder key (scope roots, and top-level folders for whole-vault)
|
|
102
|
+
* file the key a file's `csk_wrapped` holds: the content key for suites
|
|
103
|
+
* 0x00-0x02, the classical envelope key for 0x03
|
|
104
|
+
* file_pq the combined content key of a suite-0x03 file
|
|
105
|
+
* name the Argon2id-derived key of ONE name envelope, for objects whose
|
|
106
|
+
* name is sealed under a key outside the grant (a scope root's own
|
|
107
|
+
* name, a file at the vault root). Opens that envelope only.
|
|
108
|
+
*
|
|
109
|
+
* `file`, `file_pq` and `name` are only issued for objects whose parent key the
|
|
110
|
+
* grant does not hold; everything below a scope root is reached by the chain.
|
|
111
|
+
*/
|
|
112
|
+
export type GrantObjectKind = "folder" | "file" | "file_pq" | "name";
|
|
113
|
+
export interface GrantCredential {
|
|
114
|
+
grantId: string;
|
|
115
|
+
/** Sent to the server as a bearer token. The server stores only its SHA-256. */
|
|
116
|
+
token: Uint8Array;
|
|
117
|
+
/** Never leaves the client. Wraps the grant's keys. */
|
|
118
|
+
secret: Uint8Array;
|
|
119
|
+
/** SHA-256 of the owner's ML-KEM public key at grant creation, hex. */
|
|
120
|
+
publicKeyFingerprint: string;
|
|
121
|
+
}
|
|
122
|
+
/** SHA-256 of an ML-KEM public key, hex. Pinned in the connection string. */
|
|
123
|
+
export declare function publicKeyFingerprint(mlKemPublicKey: Uint8Array): string;
|
|
124
|
+
/**
|
|
125
|
+
* The upload proof for a PQ-hybrid (Suite 0x03) object, in the frame the
|
|
126
|
+
* ShieldFive server verifies:
|
|
127
|
+
*
|
|
128
|
+
* base64( [0x03][0x03] || HMAC-SHA256(proofKey, [0x03][0x03] || header || chunk_0) )
|
|
129
|
+
*
|
|
130
|
+
* `chunk_0` is the first frame INCLUDING its 4-byte big-endian length prefix.
|
|
131
|
+
* The server re-reads exactly those ranges from storage and recomputes the MAC,
|
|
132
|
+
* so a matching proof says the object storage holds is the object the client
|
|
133
|
+
* encrypted — it does not, and cannot, say anything about the plaintext.
|
|
134
|
+
*
|
|
135
|
+
* It lives here because it is a keyed construction over ShieldFive's own
|
|
136
|
+
* container format, and the clients that produce it (the web app, and the MCP
|
|
137
|
+
* server's upload path) must produce byte-identical frames. A second
|
|
138
|
+
* hand-written implementation is how the two silently diverge.
|
|
139
|
+
*/
|
|
140
|
+
export declare function buildUploadProofV3(options: {
|
|
141
|
+
/** The per-upload proof key the server issued, hex. */
|
|
142
|
+
proofKeyHex: string;
|
|
143
|
+
/** The complete ciphertext, or at least header + first chunk frame. */
|
|
144
|
+
ciphertext: Uint8Array;
|
|
145
|
+
}): Promise<string>;
|
|
146
|
+
/** Fresh token + secret for a new grant. Call in the owner's unlocked client. */
|
|
147
|
+
export declare function createGrantCredential(options: {
|
|
148
|
+
grantId: string;
|
|
149
|
+
mlKemPublicKey: Uint8Array;
|
|
150
|
+
}): GrantCredential;
|
|
151
|
+
/** `sf-grant-v1:<grant_id>.<token>.<secret>.<pk_fingerprint>` (base64url, hex). */
|
|
152
|
+
export declare function formatConnectionString(c: GrantCredential): string;
|
|
153
|
+
export declare function parseConnectionString(value: string): GrantCredential;
|
|
154
|
+
/** The bearer value a client sends. */
|
|
155
|
+
export declare function grantBearerToken(c: Pick<GrantCredential, "token">): string;
|
|
156
|
+
/** What the server stores and looks up: SHA-256 of the bearer token's bytes, hex. */
|
|
157
|
+
export declare function hashGrantToken(bearer: string): string;
|
|
158
|
+
/** GK = HKDF-SHA-256(secret, salt = utf8(grant id), info = AGENT_GRANT_WRAP). */
|
|
159
|
+
export declare function deriveGrantWrapKey(secret: Uint8Array, grantId: string): Promise<Uint8Array>;
|
|
160
|
+
/** Wrap a folder key or file content key for a grant, bound to (grant, kind, object). */
|
|
161
|
+
export declare function wrapKeyForGrant(options: {
|
|
162
|
+
grantWrapKey: Uint8Array;
|
|
163
|
+
grantId: string;
|
|
164
|
+
kind: GrantObjectKind;
|
|
165
|
+
objectId: string;
|
|
166
|
+
key: Uint8Array;
|
|
167
|
+
}): Promise<WrappedKey>;
|
|
168
|
+
export declare function unwrapKeyForGrant(options: {
|
|
169
|
+
grantWrapKey: Uint8Array;
|
|
170
|
+
grantId: string;
|
|
171
|
+
kind: GrantObjectKind;
|
|
172
|
+
objectId: string;
|
|
173
|
+
wrapped: WrappedKey;
|
|
174
|
+
}): Promise<Uint8Array>;
|
|
175
|
+
/** What a grant covers, as the owner decided it when creating the grant. */
|
|
176
|
+
export interface GrantScope {
|
|
177
|
+
grantId: string;
|
|
178
|
+
scopeAll: boolean;
|
|
179
|
+
includeMedia: boolean;
|
|
180
|
+
/** Scope-root folder ids (empty for a whole-vault grant). */
|
|
181
|
+
rootIds: readonly string[];
|
|
182
|
+
/** The grant's own trash folder, or null for a read-only grant. */
|
|
183
|
+
trashFolderId: string | null;
|
|
184
|
+
/** Top-level folders a whole-vault grant must never cover (the Bin, and Media unless opted in). */
|
|
185
|
+
excludedIds: readonly string[];
|
|
186
|
+
/**
|
|
187
|
+
* keyFingerprint() of those folders' keys. A server can relabel a row with
|
|
188
|
+
* another folder's wrapped key; it cannot change a key's fingerprint, so the
|
|
189
|
+
* owner's browser refuses to hand an excluded folder's key to the grant under
|
|
190
|
+
* any id.
|
|
191
|
+
*/
|
|
192
|
+
excludedKeyFingerprints: readonly string[];
|
|
193
|
+
}
|
|
194
|
+
/** SHA-256 of a 32-byte key, hex. Reveals nothing usable about a random key. */
|
|
195
|
+
export declare function keyFingerprint(key: Uint8Array): string;
|
|
196
|
+
/** A canonical, order-independent string for a scope. Any change to the scope changes it. */
|
|
197
|
+
export declare function canonicalGrantScope(scope: GrantScope): string;
|
|
198
|
+
/**
|
|
199
|
+
* Wrap a grant secret for the owner: AES-256-GCM under HKDF(RK, grant id,
|
|
200
|
+
* AGENT_GRANT_SECRET), with the canonical scope as AAD. Only the owner's
|
|
201
|
+
* vault root key opens it, and only for exactly this scope.
|
|
202
|
+
*/
|
|
203
|
+
export declare function wrapGrantSecret(options: {
|
|
204
|
+
rootKey: Uint8Array;
|
|
205
|
+
scope: GrantScope;
|
|
206
|
+
secret: Uint8Array;
|
|
207
|
+
}): Promise<WrappedKey>;
|
|
208
|
+
/** Open the owner's copy of a grant secret. Fails if the scope differs in any way from the one it was wrapped for. */
|
|
209
|
+
export declare function unwrapGrantSecret(options: {
|
|
210
|
+
rootKey: Uint8Array;
|
|
211
|
+
scope: GrantScope;
|
|
212
|
+
wrapped: WrappedKey;
|
|
213
|
+
}): Promise<Uint8Array>;
|
|
214
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vault/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AA+BH,mFAAmF;AACnF,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EACT,eAAe,GACf,qBAAqB,GACrB,sBAAsB,GACtB,eAAe,GACf,2BAA2B,CAAC;gBACpB,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM;CAK5D;AAgED,oFAAoF;AACpF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,4EAA4E;AAC5E,wBAAsB,YAAY,CAChC,WAAW,EAAE,UAAU,EACvB,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,UAAU,CAAC,CAMrB;AAED,yFAAyF;AACzF,wBAAsB,cAAc,CAClC,WAAW,EAAE,UAAU,EACvB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,UAAU,CAAC,CAcrB;AAMD,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,UAAU,CAAC;AAEtD,MAAM,WAAW,YAAY;IAC3B,CAA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