@oneie/sdk 0.17.3 → 0.17.5

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.
Files changed (86) hide show
  1. package/README.md +4 -0
  2. package/dist/.build-fingerprint +1 -0
  3. package/dist/age.d.ts +96 -0
  4. package/dist/age.d.ts.map +1 -0
  5. package/dist/age.js +487 -0
  6. package/dist/age.js.map +1 -0
  7. package/dist/blocks.d.ts +8 -4
  8. package/dist/blocks.d.ts.map +1 -1
  9. package/dist/blocks.js +17 -5
  10. package/dist/blocks.js.map +1 -1
  11. package/dist/edge/solve.d.ts +38 -0
  12. package/dist/edge/solve.d.ts.map +1 -0
  13. package/dist/edge/solve.js +334 -0
  14. package/dist/edge/solve.js.map +1 -0
  15. package/dist/edge/types.d.ts +216 -0
  16. package/dist/edge/types.d.ts.map +1 -0
  17. package/dist/edge/types.js +21 -0
  18. package/dist/edge/types.js.map +1 -0
  19. package/dist/edge/validate.d.ts +19 -0
  20. package/dist/edge/validate.d.ts.map +1 -0
  21. package/dist/edge/validate.js +89 -0
  22. package/dist/edge/validate.js.map +1 -0
  23. package/dist/edge.d.ts +9 -0
  24. package/dist/edge.d.ts.map +1 -0
  25. package/dist/edge.js +8 -0
  26. package/dist/edge.js.map +1 -0
  27. package/dist/fn-allowlist.d.ts +1 -1
  28. package/dist/fn-allowlist.d.ts.map +1 -1
  29. package/dist/fn-allowlist.js +14 -0
  30. package/dist/fn-allowlist.js.map +1 -1
  31. package/dist/gateway.d.ts +18 -1
  32. package/dist/gateway.d.ts.map +1 -1
  33. package/dist/gateway.js +77 -3
  34. package/dist/gateway.js.map +1 -1
  35. package/dist/generated/fn-map.d.ts +2 -2
  36. package/dist/generated/fn-map.d.ts.map +1 -1
  37. package/dist/generated/fn-map.js +114 -13
  38. package/dist/generated/fn-map.js.map +1 -1
  39. package/dist/generated/schemas.d.ts +56 -14
  40. package/dist/generated/schemas.d.ts.map +1 -1
  41. package/dist/generated/schemas.js +32 -1
  42. package/dist/generated/schemas.js.map +1 -1
  43. package/dist/market.d.ts.map +1 -1
  44. package/dist/market.js +6 -0
  45. package/dist/market.js.map +1 -1
  46. package/dist/message-key.d.ts +20 -0
  47. package/dist/message-key.d.ts.map +1 -0
  48. package/dist/message-key.js +46 -0
  49. package/dist/message-key.js.map +1 -0
  50. package/dist/message-lock.d.ts +56 -0
  51. package/dist/message-lock.d.ts.map +1 -0
  52. package/dist/message-lock.js +157 -0
  53. package/dist/message-lock.js.map +1 -0
  54. package/dist/receiver-layers.d.ts +1 -1
  55. package/dist/receiver-layers.d.ts.map +1 -1
  56. package/dist/receiver-layers.js +36 -0
  57. package/dist/receiver-layers.js.map +1 -1
  58. package/dist/receivers.d.ts +1397 -50
  59. package/dist/receivers.d.ts.map +1 -1
  60. package/dist/receivers.js +1423 -62
  61. package/dist/receivers.js.map +1 -1
  62. package/dist/secrets-give.d.ts +120 -0
  63. package/dist/secrets-give.d.ts.map +1 -0
  64. package/dist/secrets-give.js +160 -0
  65. package/dist/secrets-give.js.map +1 -0
  66. package/dist/secrets-grant.d.ts +52 -0
  67. package/dist/secrets-grant.d.ts.map +1 -0
  68. package/dist/secrets-grant.js +55 -0
  69. package/dist/secrets-grant.js.map +1 -0
  70. package/dist/secrets-key.d.ts +20 -0
  71. package/dist/secrets-key.d.ts.map +1 -0
  72. package/dist/secrets-key.js +47 -0
  73. package/dist/secrets-key.js.map +1 -0
  74. package/dist/secrets-one-vault.d.ts +21 -0
  75. package/dist/secrets-one-vault.d.ts.map +1 -0
  76. package/dist/secrets-one-vault.js +38 -0
  77. package/dist/secrets-one-vault.js.map +1 -0
  78. package/dist/secrets.d.ts +195 -0
  79. package/dist/secrets.d.ts.map +1 -0
  80. package/dist/secrets.js +377 -0
  81. package/dist/secrets.js.map +1 -0
  82. package/dist/templates.js +6 -6
  83. package/dist/templates.js.map +1 -1
  84. package/dist/work-contract-grammar.json +41 -0
  85. package/package.json +37 -2
  86. package/src/generated/funs.json +1 -0
package/README.md CHANGED
@@ -47,6 +47,7 @@ highways.forEach(h => console.log(`${h.path}: ${h.net}`));
47
47
  | `@oneie/sdk/meta` | `metaCatalog()`, `metaRecipe()`, `metaSchema()` — the self-describing surface over `RECEIVERS` |
48
48
  | `@oneie/sdk/openapi` | `buildReceiverPayload()` — generate the receiver `oneOf` for `openapi.yaml` (`bun run generate:openapi`) |
49
49
  | `@oneie/sdk/client` | `SubstrateClient` as a direct subpath (skips the barrel) |
50
+ | `@oneie/sdk/edge` | `solve()`, `validate()`, `EdgeBudget`, `EdgeUnbound`, `EdgeGrammar` (a construct outside the pinned grammar), `EdgeIr` (graph and `funs.json` from different IRs) + the `Graph`/`Funs`/`Patch` types — the pure TypeQL evaluator over a RAM graph (no I/O; Worker-safe subpath) |
50
51
  | `@oneie/sdk/brain` | `BrainClient` — CF-Worker-safe substrate client (use this, never the bare barrel, in a Worker) |
51
52
  | `@oneie/sdk/blocks` | `normalizeBlockProps()` — land an agent's generated copy on the fields the block that RENDERS reads. Puck's family collapse unions every member's fields into one registration, so a prop can be declared, accepted and still invisible; this resolves the member and rewrites the keys onto its own vocabulary. Schema-agnostic: pass your own `BlockSchema` |
52
53
  | `@oneie/sdk/fn-allowlist` | The TypeQL functions callable through `fn()` — one list, so a caller and the gateway cannot disagree |
@@ -54,6 +55,9 @@ highways.forEach(h => console.log(`${h.path}: ${h.net}`));
54
55
  | `@oneie/sdk/role-actions` | `minTier()` — the per-action floor the tier is compared against |
55
56
  | `@oneie/sdk/receiver-action` | `receiverAction()` — the receiver a role-gated action resolves to |
56
57
  | `@oneie/sdk/gateway` | `GatewayClient` — typed client for the `api.one.ie` gateway |
58
+ | `@oneie/sdk/age` | `sealText()`, `openText()`, `encrypt()`, `decrypt()`, `AgeError` — age-encryption.org/v1 for X25519 locks (`age1…`); interoperates with the `age` CLI both ways. A byte copy of the web app's `lib/key/age.ts`, guarded by a test |
59
+ | `@oneie/sdk/message-key` | `deriveMessageKey()`, `messageKeyFromPhrase()`, `messageIdentityText()` — the one key's message child (`message-x25519-v1`): your lock and the `AGE-SECRET-KEY-1…` that opens it |
60
+ | `@oneie/sdk/message-lock` | `lockMessage()`, `signSuiPersonalMessage()`, `verifySuiPersonalMessage()`, `verifyLockRecord()` — publish and check a lock under a name, signed by the account's Sui key |
57
61
  | `@oneie/sdk/gateway-meta` | `gatewayMetadata()`, `gatewayMetadataHeader()`, `GATEWAY_META_KEYS` — the five `cf-aig-metadata` words (group · actor · signal · via · tags) every model call carries; channels re-exports it |
58
62
  | `@oneie/sdk/free-tier` | `freeTierVerdict()`, `checkFreeModel()`, `FREE_MODELS`, `FREE_REQUESTS_PER_DAY` — the free-tier table and its verdict, one source for web and channels |
59
63
  | `@oneie/sdk/types` | Type definitions only — `Outcome<T>`, `Signal`, and friends |
@@ -0,0 +1 @@
1
+ 1a6627f660a842418195121604b077ef08b9123a6c42a7e7442f085f0e0c59de
package/dist/age.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ /**
2
+ * age — the open sealed-message format (age-encryption.org/v1), X25519 recipients only.
3
+ *
4
+ * WHY THIS FORMAT. A note sealed here opens in the `age` CLI, in Proton Pass, in
5
+ * rage, in any age tool — and a note sealed by any of them opens here. ONE adds no
6
+ * dialect: the gift is a standard key, not a standard-looking one. The test
7
+ * `tests/unit/key/age.test.ts` proves both directions against the real `age` binary
8
+ * when it is on the machine.
9
+ *
10
+ * WHAT IS IMPLEMENTED — the whole v1 spec for X25519, nothing more:
11
+ * · header `age-encryption.org/v1`, one `-> X25519 <share>` stanza per recipient,
12
+ * `--- <mac>` footer (HMAC-SHA256 under HKDF(file key, "header"))
13
+ * · wrap HKDF-SHA256(X25519 shared, salt = share‖recipient, "age-encryption.org/v1/X25519")
14
+ * → ChaCha20-Poly1305 with a zero nonce over the 16-byte file key
15
+ * · payload 16-byte nonce, HKDF(file key, nonce, "payload") → STREAM of 64 KiB
16
+ * ChaCha20-Poly1305 chunks, nonce = 11-byte counter ‖ last-chunk flag
17
+ * · armor `-----BEGIN AGE ENCRYPTED FILE-----`, 64-column base64
18
+ * Not implemented, by design: scrypt (passphrase) and ssh-* recipients. A file
19
+ * with such a stanza is refused as `unsupported`, never silently skipped.
20
+ *
21
+ * Primitives come from @noble (already in the bundle for the wallets) and @scure/base
22
+ * (bech32 for `age1…` / `AGE-SECRET-KEY-1…`). WebCrypto has no ChaCha20-Poly1305 and no
23
+ * X25519 in every browser ONE serves, which is why this is not `crypto.subtle`.
24
+ *
25
+ * Secrets: every derived key and the file key are zeroed before return. The caller
26
+ * owns the identity bytes it passes in.
27
+ */
28
+ export declare const AGE_VERSION_LINE = "age-encryption.org/v1";
29
+ export declare const AGE_ARMOR_BEGIN = "-----BEGIN AGE ENCRYPTED FILE-----";
30
+ export declare const AGE_ARMOR_END = "-----END AGE ENCRYPTED FILE-----";
31
+ /** The most reader stanzas a header may carry before it is refused (review F-04). */
32
+ export declare const MAX_STANZAS = 128;
33
+ export declare class AgeError extends Error {
34
+ readonly code: 'malformed' | 'unsupported' | 'no_identity' | 'tampered' | 'bad_key';
35
+ constructor(code: 'malformed' | 'unsupported' | 'no_identity' | 'tampered' | 'bad_key', detail: string);
36
+ }
37
+ /** `age1…` for a 32-byte X25519 public key. */
38
+ export declare function encodeRecipient(publicKey: Uint8Array): string;
39
+ /** The 32 public bytes behind an `age1…` recipient. */
40
+ export declare function decodeRecipient(recipient: string): Uint8Array;
41
+ /** `AGE-SECRET-KEY-1…` for a 32-byte X25519 secret — the form `age-keygen` writes. */
42
+ export declare function encodeIdentity(secret: Uint8Array): string;
43
+ /** The 32 secret bytes behind an `AGE-SECRET-KEY-1…` identity. */
44
+ export declare function decodeIdentity(identity: string): Uint8Array;
45
+ /** The recipient an identity answers to. */
46
+ export declare function recipientOf(secret: Uint8Array): string;
47
+ /**
48
+ * Seal `plaintext` for every `age1…` in `recipients`. Returns the binary age file;
49
+ * `armor()` turns it into text. Anyone holding any one of the recipients' identities
50
+ * can open it; nobody else can tell how many recipients there are beyond the stanza count.
51
+ */
52
+ export declare function encrypt(plaintext: Uint8Array, recipients: string[]): Uint8Array;
53
+ export interface Stanza {
54
+ type: string;
55
+ args: string[];
56
+ body: Uint8Array;
57
+ }
58
+ /** Pure, no secret: lets lib/key/sealed-post.ts judge a block's STRUCTURE with the same parser that opens it. */
59
+ export declare function parseHeader(file: Uint8Array): {
60
+ stanzas: Stanza[];
61
+ mac: Uint8Array;
62
+ upToDashes: Uint8Array;
63
+ payload: Uint8Array;
64
+ };
65
+ /**
66
+ * Open an age file with one or more X25519 identities (32-byte secrets). Tries every
67
+ * X25519 stanza against every identity; a file whose only stanzas are of another kind
68
+ * is `unsupported`, a file none of the identities can open is `no_identity`, and any
69
+ * byte changed after sealing is `tampered`.
70
+ */
71
+ export declare function decrypt(file: Uint8Array, identities: Uint8Array[]): Uint8Array;
72
+ /** Text form: BEGIN line, 64-column standard base64, END line. Pastes anywhere. */
73
+ export declare function armor(file: Uint8Array): string;
74
+ /**
75
+ * Strict armor, as the spec and the CCTV `armor_*` vectors define it: whitespace AROUND the block is
76
+ * ignored; inside it every line is exactly the BEGIN line, 64-column canonical base64 (the last line 1-64
77
+ * columns, never empty), the END line — LF or CRLF throughout, no blank lines, no trailing spaces, nothing
78
+ * before or after. A pasted email is not that; `extractArmored` turns one into this.
79
+ */
80
+ export declare function dearmor(text: string): Uint8Array;
81
+ /**
82
+ * The paste-box convenience, and a deliberate departure from the spec: find an armored block inside
83
+ * surrounding prose (an email quotes the note), tolerate CRLF, indentation and trailing spaces and blank
84
+ * lines, and hand back the canonical block. It decides nothing about the bytes — `dearmor` still does.
85
+ * Never use it on the server path: what is stored is always the machine-made strict form.
86
+ */
87
+ export declare function extractArmored(text: string): string;
88
+ /** Is this text an age file in either form? Cheap, for a paste box deciding what it was given. */
89
+ export declare function looksLikeAge(text: string): boolean;
90
+ /** Seal a string for recipients and hand back armored text. */
91
+ export declare function sealText(text: string, recipients: string[]): string;
92
+ /** Open armored (or raw) age text with identities and hand back the plaintext BYTES (a fixed-size capsule is bytes, not text). */
93
+ export declare function openBytes(ageText: string, identities: Uint8Array[]): Uint8Array;
94
+ /** Open armored (or raw) age text with identities and read the plaintext as UTF-8. */
95
+ export declare function openText(ageText: string, identities: Uint8Array[]): string;
96
+ //# sourceMappingURL=age.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"age.d.ts","sourceRoot":"","sources":["../src/age.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AASH,eAAO,MAAM,gBAAgB,0BAA0B,CAAA;AACvD,eAAO,MAAM,eAAe,uCAAuC,CAAA;AACnE,eAAO,MAAM,aAAa,qCAAqC,CAAA;AAK/D,qFAAqF;AACrF,eAAO,MAAM,WAAW,MAAM,CAAA;AAO9B,qBAAa,QAAS,SAAQ,KAAK;aAEf,IAAI,EAAE,WAAW,GAAG,aAAa,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS;gBAA1E,IAAI,EAAE,WAAW,GAAG,aAAa,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,EAC1F,MAAM,EAAE,MAAM;CAKjB;AAID,+CAA+C;AAC/C,wBAAgB,eAAe,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM,CAG7D;AAED,uDAAuD;AACvD,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAY7D;AAED,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAGzD;AAED,kEAAkE;AAClE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAY3D;AAED,4CAA4C;AAC5C,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAEtD;AA4DD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,UAAU,CA6B/E;AAID,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,IAAI,EAAE,UAAU,CAAA;CACjB;AAeD,iHAAiH;AACjH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,CA6DjI;AASD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,UAAU,CAiF9E;AAID,mFAAmF;AACnF,wBAAgB,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAK9C;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAqBhD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYnD;AAED,kGAAkG;AAClG,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGlD;AAID,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAEnE;AAED,kIAAkI;AAClI,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,UAAU,CAI/E;AAED,sFAAsF;AACtF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,CAE1E"}
package/dist/age.js ADDED
@@ -0,0 +1,487 @@
1
+ // age.ts — the SDK's copy of one.ie/web/src/lib/key/age.ts, byte-for-byte below this note.
2
+ // WHY A COPY: the CLI's runtime deps are commander + @oneie/sdk and nothing else, and a
3
+ // file under one.ie/web cannot be compiled into packages/cli (rootDir). A sibling subpath
4
+ // (`@oneie/sdk/age`) leaves wallet.ts — and the recover page bundled from it — untouched,
5
+ // the same reason key-identity.ts is its own module. Drift is guarded by
6
+ // tests/message-key.test.ts, which seals in one copy and opens in the other.
7
+ //
8
+ /**
9
+ * age — the open sealed-message format (age-encryption.org/v1), X25519 recipients only.
10
+ *
11
+ * WHY THIS FORMAT. A note sealed here opens in the `age` CLI, in Proton Pass, in
12
+ * rage, in any age tool — and a note sealed by any of them opens here. ONE adds no
13
+ * dialect: the gift is a standard key, not a standard-looking one. The test
14
+ * `tests/unit/key/age.test.ts` proves both directions against the real `age` binary
15
+ * when it is on the machine.
16
+ *
17
+ * WHAT IS IMPLEMENTED — the whole v1 spec for X25519, nothing more:
18
+ * · header `age-encryption.org/v1`, one `-> X25519 <share>` stanza per recipient,
19
+ * `--- <mac>` footer (HMAC-SHA256 under HKDF(file key, "header"))
20
+ * · wrap HKDF-SHA256(X25519 shared, salt = share‖recipient, "age-encryption.org/v1/X25519")
21
+ * → ChaCha20-Poly1305 with a zero nonce over the 16-byte file key
22
+ * · payload 16-byte nonce, HKDF(file key, nonce, "payload") → STREAM of 64 KiB
23
+ * ChaCha20-Poly1305 chunks, nonce = 11-byte counter ‖ last-chunk flag
24
+ * · armor `-----BEGIN AGE ENCRYPTED FILE-----`, 64-column base64
25
+ * Not implemented, by design: scrypt (passphrase) and ssh-* recipients. A file
26
+ * with such a stanza is refused as `unsupported`, never silently skipped.
27
+ *
28
+ * Primitives come from @noble (already in the bundle for the wallets) and @scure/base
29
+ * (bech32 for `age1…` / `AGE-SECRET-KEY-1…`). WebCrypto has no ChaCha20-Poly1305 and no
30
+ * X25519 in every browser ONE serves, which is why this is not `crypto.subtle`.
31
+ *
32
+ * Secrets: every derived key and the file key are zeroed before return. The caller
33
+ * owns the identity bytes it passes in.
34
+ */
35
+ import { chacha20poly1305 } from '@noble/ciphers/chacha.js';
36
+ import { x25519 } from '@noble/curves/ed25519.js';
37
+ import { hkdf } from '@noble/hashes/hkdf.js';
38
+ import { hmac } from '@noble/hashes/hmac.js';
39
+ import { sha256 } from '@noble/hashes/sha2.js';
40
+ import { base64, base64nopad, bech32 } from '@scure/base';
41
+ export const AGE_VERSION_LINE = 'age-encryption.org/v1';
42
+ export const AGE_ARMOR_BEGIN = '-----BEGIN AGE ENCRYPTED FILE-----';
43
+ export const AGE_ARMOR_END = '-----END AGE ENCRYPTED FILE-----';
44
+ const X25519_INFO = 'age-encryption.org/v1/X25519';
45
+ const RECIPIENT_HRP = 'age';
46
+ const IDENTITY_HRP = 'age-secret-key-';
47
+ const CHUNK = 64 * 1024;
48
+ /** The most reader stanzas a header may carry before it is refused (review F-04). */
49
+ export const MAX_STANZAS = 128;
50
+ const TAG = 16;
51
+ const enc = new TextEncoder();
52
+ const dec = new TextDecoder();
53
+ const utf8 = (s) => enc.encode(s);
54
+ export class AgeError extends Error {
55
+ code;
56
+ constructor(code, detail) {
57
+ super(detail);
58
+ this.code = code;
59
+ this.name = 'AgeError';
60
+ }
61
+ }
62
+ // ─── keys ────────────────────────────────────────────────────────────────────
63
+ /** `age1…` for a 32-byte X25519 public key. */
64
+ export function encodeRecipient(publicKey) {
65
+ if (publicKey.length !== 32)
66
+ throw new AgeError('bad_key', 'an X25519 public key is 32 bytes');
67
+ return bech32.encode(RECIPIENT_HRP, bech32.toWords(publicKey), false);
68
+ }
69
+ /** The 32 public bytes behind an `age1…` recipient. */
70
+ export function decodeRecipient(recipient) {
71
+ const r = recipient.trim();
72
+ let d;
73
+ try {
74
+ d = bech32.decode(r, false);
75
+ }
76
+ catch {
77
+ throw new AgeError('bad_key', 'not an age recipient (age1…)');
78
+ }
79
+ if (d.prefix !== RECIPIENT_HRP)
80
+ throw new AgeError('bad_key', `not an age recipient: prefix ${d.prefix}`);
81
+ const bytes = bech32.fromWords(d.words);
82
+ if (bytes.length !== 32)
83
+ throw new AgeError('bad_key', 'an age recipient carries 32 bytes');
84
+ return bytes;
85
+ }
86
+ /** `AGE-SECRET-KEY-1…` for a 32-byte X25519 secret — the form `age-keygen` writes. */
87
+ export function encodeIdentity(secret) {
88
+ if (secret.length !== 32)
89
+ throw new AgeError('bad_key', 'an X25519 secret is 32 bytes');
90
+ return bech32.encode(IDENTITY_HRP, bech32.toWords(secret), false).toUpperCase();
91
+ }
92
+ /** The 32 secret bytes behind an `AGE-SECRET-KEY-1…` identity. */
93
+ export function decodeIdentity(identity) {
94
+ const s = identity.trim().toLowerCase();
95
+ let d;
96
+ try {
97
+ d = bech32.decode(s, false);
98
+ }
99
+ catch {
100
+ throw new AgeError('bad_key', 'not an age identity (AGE-SECRET-KEY-1…)');
101
+ }
102
+ if (d.prefix !== IDENTITY_HRP)
103
+ throw new AgeError('bad_key', `not an age identity: prefix ${d.prefix}`);
104
+ const bytes = bech32.fromWords(d.words);
105
+ if (bytes.length !== 32)
106
+ throw new AgeError('bad_key', 'an age identity carries 32 bytes');
107
+ return bytes;
108
+ }
109
+ /** The recipient an identity answers to. */
110
+ export function recipientOf(secret) {
111
+ return encodeRecipient(x25519.getPublicKey(secret));
112
+ }
113
+ // ─── encrypt ─────────────────────────────────────────────────────────────────
114
+ function wrapFileKey(fileKey, recipientPub) {
115
+ const eph = x25519.utils.randomSecretKey();
116
+ let shared = null;
117
+ let wrapKey = null;
118
+ try {
119
+ const share = x25519.getPublicKey(eph);
120
+ // noble (v2) throws on a low-order point before it returns the all-zero secret, so the zero check
121
+ // below is the belt for a library that does not. Either way the caller sees an AgeError, never a raw Error.
122
+ try {
123
+ shared = x25519.getSharedSecret(eph, recipientPub);
124
+ }
125
+ catch {
126
+ throw new AgeError('bad_key', 'low-order recipient point');
127
+ }
128
+ if (shared.every((b) => b === 0))
129
+ throw new AgeError('bad_key', 'low-order recipient point');
130
+ const salt = new Uint8Array(64);
131
+ salt.set(share, 0);
132
+ salt.set(recipientPub, 32);
133
+ wrapKey = hkdf(sha256, shared, salt, utf8(X25519_INFO), 32);
134
+ const body = chacha20poly1305(wrapKey, new Uint8Array(12)).encrypt(fileKey);
135
+ return { share, body };
136
+ }
137
+ finally {
138
+ eph.fill(0);
139
+ shared?.fill(0);
140
+ wrapKey?.fill(0);
141
+ }
142
+ }
143
+ function headerMac(fileKey, headerUpToDashes) {
144
+ const macKey = hkdf(sha256, fileKey, new Uint8Array(0), utf8('header'), 32);
145
+ const mac = hmac(sha256, macKey, headerUpToDashes);
146
+ macKey.fill(0);
147
+ return mac;
148
+ }
149
+ function streamNonce(counter, last) {
150
+ const n = new Uint8Array(12);
151
+ // 11-byte big-endian counter; JS numbers cover 2^53 chunks, far beyond any message here.
152
+ let c = counter;
153
+ for (let i = 10; i >= 0 && c > 0; i--) {
154
+ n[i] = c % 256;
155
+ c = Math.floor(c / 256);
156
+ }
157
+ n[11] = last ? 1 : 0;
158
+ return n;
159
+ }
160
+ function concat(parts) {
161
+ const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
162
+ let o = 0;
163
+ for (const p of parts) {
164
+ out.set(p, o);
165
+ o += p.length;
166
+ }
167
+ return out;
168
+ }
169
+ /**
170
+ * Seal `plaintext` for every `age1…` in `recipients`. Returns the binary age file;
171
+ * `armor()` turns it into text. Anyone holding any one of the recipients' identities
172
+ * can open it; nobody else can tell how many recipients there are beyond the stanza count.
173
+ */
174
+ export function encrypt(plaintext, recipients) {
175
+ if (recipients.length === 0)
176
+ throw new AgeError('bad_key', 'seal it for at least one recipient');
177
+ const pubs = recipients.map(decodeRecipient);
178
+ const fileKey = crypto.getRandomValues(new Uint8Array(16));
179
+ try {
180
+ const lines = [AGE_VERSION_LINE];
181
+ for (const pub of pubs) {
182
+ const { share, body } = wrapFileKey(fileKey, pub);
183
+ lines.push(`-> X25519 ${base64nopad.encode(share)}`, base64nopad.encode(body));
184
+ }
185
+ lines.push('---');
186
+ const upToDashes = utf8(lines.join('\n'));
187
+ const mac = headerMac(fileKey, upToDashes);
188
+ const header = utf8(`${lines.join('\n')} ${base64nopad.encode(mac)}\n`);
189
+ const nonce = crypto.getRandomValues(new Uint8Array(16));
190
+ const payloadKey = hkdf(sha256, fileKey, nonce, utf8('payload'), 32);
191
+ const chunks = [header, nonce];
192
+ // The last chunk may be short, and may be empty only when the whole plaintext is.
193
+ const count = Math.max(1, Math.ceil(plaintext.length / CHUNK));
194
+ for (let i = 0; i < count; i++) {
195
+ const slice = plaintext.subarray(i * CHUNK, Math.min(plaintext.length, (i + 1) * CHUNK));
196
+ chunks.push(chacha20poly1305(payloadKey, streamNonce(i, i === count - 1)).encrypt(slice));
197
+ }
198
+ payloadKey.fill(0);
199
+ return concat(chunks);
200
+ }
201
+ finally {
202
+ fileKey.fill(0);
203
+ }
204
+ }
205
+ /**
206
+ * The header is a byte format, not text. It is scanned byte by byte: every byte of the header must be
207
+ * printable ASCII (or the line feed), as the spec requires, and the MAC is taken over the exact bytes
208
+ * that were sent, with the payload starting exactly where the footer line ends. A lossy UTF-8 decode
209
+ * (what this used to do) turns an invalid byte into U+FFFD, authenticates a different string than was
210
+ * sent and miscounts the payload offset — a sender who holds the file key could make ONE open a file
211
+ * the reference `age` rejects at the header. This module is imported (for two string constants)
212
+ * by routes that run in workerd, so no decoder with a non-default label is constructed at load: `dec`
213
+ * (default UTF-8, declared at the top) is the only one, and it only ever sees bytes the scan proved ASCII.
214
+ */
215
+ const HEADER_WINDOW = 1 << 20;
216
+ const TOKEN = /^[\x21-\x7e]+$/;
217
+ /** Pure, no secret: lets lib/key/sealed-post.ts judge a block's STRUCTURE with the same parser that opens it. */
218
+ export function parseHeader(file) {
219
+ const limit = Math.min(file.length, HEADER_WINDOW);
220
+ let pos = 0;
221
+ const nextLine = () => {
222
+ let end = pos;
223
+ while (end < limit && file[end] !== 0x0a) {
224
+ if (file[end] < 0x20 || file[end] > 0x7e)
225
+ throw new AgeError('malformed', 'header byte outside printable ASCII');
226
+ end++;
227
+ }
228
+ if (end >= limit)
229
+ throw new AgeError('malformed', 'header runs off the end of the file');
230
+ const line = dec.decode(file.subarray(pos, end)); // ASCII only by the scan above, so UTF-8 decoding is byte-exact
231
+ pos = end + 1;
232
+ return line;
233
+ };
234
+ if (nextLine() !== AGE_VERSION_LINE)
235
+ throw new AgeError('malformed', 'not an age file: missing version line');
236
+ const stanzas = [];
237
+ let footer = null;
238
+ let footerAt = 0;
239
+ while (footer === null) {
240
+ footerAt = pos;
241
+ const line = nextLine();
242
+ if (line.startsWith('---')) {
243
+ footer = line;
244
+ break;
245
+ }
246
+ if (!line.startsWith('-> '))
247
+ throw new AgeError('malformed', 'unexpected header line');
248
+ // A stanza line is `-> ` then 1+ arguments of visible ASCII separated by single spaces.
249
+ const tokens = line.slice(3).split(' ');
250
+ if (!tokens.every((t) => TOKEN.test(t)))
251
+ throw new AgeError('malformed', 'stanza arguments must be non-empty visible ASCII');
252
+ const [type, ...args] = tokens;
253
+ const bodyLines = [];
254
+ // A stanza body is 64-column lines ending in a line shorter than 64 (possibly empty).
255
+ for (;;) {
256
+ const b = nextLine();
257
+ bodyLines.push(b);
258
+ if (b.length < 64)
259
+ break;
260
+ if (b.length > 64)
261
+ throw new AgeError('malformed', 'stanza body line over 64 columns');
262
+ }
263
+ let body;
264
+ try {
265
+ body = base64nopad.decode(bodyLines.join(''));
266
+ }
267
+ catch {
268
+ throw new AgeError('malformed', 'stanza body is not base64');
269
+ }
270
+ stanzas.push({ type, args, body });
271
+ // Each X25519 stanza costs two curve operations on the opener's main thread, so an
272
+ // unbounded list is a way to freeze a tab with a paste (review F-04: 3000 took ~5 s).
273
+ // age sets no limit; a note for more readers than this is refused, never half-read.
274
+ if (stanzas.length > MAX_STANZAS)
275
+ throw new AgeError('unsupported', `sealed for more than ${MAX_STANZAS} readers`);
276
+ }
277
+ if (!footer.startsWith('--- '))
278
+ throw new AgeError('malformed', 'header footer must be `--- ` and a MAC');
279
+ let mac;
280
+ try {
281
+ mac = base64nopad.decode(footer.slice(4));
282
+ }
283
+ catch {
284
+ throw new AgeError('malformed', 'header MAC is not base64');
285
+ }
286
+ if (mac.length !== 32)
287
+ throw new AgeError('malformed', 'header MAC is not 32 bytes');
288
+ // The reference rule: an scrypt (passphrase) stanza must be the file's only stanza.
289
+ if (stanzas.some((s) => s.type === 'scrypt') && stanzas.length !== 1)
290
+ throw new AgeError('malformed', 'scrypt must be the only recipient');
291
+ return { stanzas, mac, upToDashes: file.subarray(0, footerAt + 3), payload: file.subarray(pos) };
292
+ }
293
+ function constantEqual(a, b) {
294
+ if (a.length !== b.length)
295
+ return false;
296
+ let d = 0;
297
+ for (let i = 0; i < a.length; i++)
298
+ d |= a[i] ^ b[i];
299
+ return d === 0;
300
+ }
301
+ /**
302
+ * Open an age file with one or more X25519 identities (32-byte secrets). Tries every
303
+ * X25519 stanza against every identity; a file whose only stanzas are of another kind
304
+ * is `unsupported`, a file none of the identities can open is `no_identity`, and any
305
+ * byte changed after sealing is `tampered`.
306
+ */
307
+ export function decrypt(file, identities) {
308
+ if (identities.length === 0)
309
+ throw new AgeError('no_identity', 'no identity to open it with');
310
+ const { stanzas, mac, upToDashes, payload } = parseHeader(file);
311
+ const x = stanzas.filter((s) => s.type === 'X25519');
312
+ if (x.length === 0) {
313
+ const kinds = [...new Set(stanzas.map((s) => s.type))].join(', ') || 'none';
314
+ throw new AgeError('unsupported', `no X25519 recipient in this file (stanzas: ${kinds})`);
315
+ }
316
+ let fileKey = null;
317
+ const pubs = identities.map((id) => x25519.getPublicKey(id));
318
+ for (const s of x) {
319
+ if (s.args.length !== 1 || s.body.length !== 32)
320
+ throw new AgeError('malformed', 'bad X25519 stanza');
321
+ let share;
322
+ try {
323
+ share = base64nopad.decode(s.args[0]);
324
+ }
325
+ catch {
326
+ throw new AgeError('malformed', 'X25519 share is not base64');
327
+ }
328
+ if (share.length !== 32)
329
+ throw new AgeError('malformed', 'X25519 share is not 32 bytes');
330
+ for (let k = 0; k < identities.length; k++) {
331
+ let shared;
332
+ try {
333
+ shared = x25519.getSharedSecret(identities[k], share);
334
+ }
335
+ catch {
336
+ // A low-order share is a malformed file (the reference: a header failure), not "someone else's key".
337
+ throw new AgeError('malformed', 'X25519 share is a low-order point');
338
+ }
339
+ if (shared.every((b) => b === 0))
340
+ throw new AgeError('malformed', 'X25519 share is a low-order point');
341
+ const salt = new Uint8Array(64);
342
+ salt.set(share, 0);
343
+ salt.set(pubs[k], 32);
344
+ const wrapKey = hkdf(sha256, shared, salt, utf8(X25519_INFO), 32);
345
+ shared.fill(0);
346
+ try {
347
+ fileKey = chacha20poly1305(wrapKey, new Uint8Array(12)).decrypt(s.body);
348
+ }
349
+ catch {
350
+ fileKey = null;
351
+ }
352
+ finally {
353
+ wrapKey.fill(0);
354
+ }
355
+ if (fileKey)
356
+ break;
357
+ }
358
+ if (fileKey)
359
+ break;
360
+ }
361
+ if (!fileKey)
362
+ throw new AgeError('no_identity', 'none of your keys opens this');
363
+ try {
364
+ if (!constantEqual(headerMac(fileKey, upToDashes), mac))
365
+ throw new AgeError('tampered', 'header MAC does not match');
366
+ if (payload.length < 16)
367
+ throw new AgeError('malformed', 'payload shorter than its nonce');
368
+ const nonce = payload.subarray(0, 16);
369
+ const payloadKey = hkdf(sha256, fileKey, nonce, utf8('payload'), 32);
370
+ try {
371
+ const body = payload.subarray(16);
372
+ const full = CHUNK + TAG;
373
+ const out = [];
374
+ let i = 0;
375
+ let offset = 0;
376
+ for (;;) {
377
+ const remaining = body.length - offset;
378
+ if (remaining < TAG)
379
+ throw new AgeError('malformed', 'payload chunk shorter than its tag');
380
+ const last = remaining <= full;
381
+ const size = last ? remaining : full;
382
+ // A trailing empty chunk is only legal when it is the whole payload.
383
+ if (last && size === TAG && i > 0)
384
+ throw new AgeError('malformed', 'empty final chunk');
385
+ try {
386
+ out.push(chacha20poly1305(payloadKey, streamNonce(i, last)).decrypt(body.subarray(offset, offset + size)));
387
+ }
388
+ catch {
389
+ throw new AgeError('tampered', `payload chunk ${i} does not authenticate`);
390
+ }
391
+ offset += size;
392
+ i++;
393
+ if (last)
394
+ break;
395
+ }
396
+ return concat(out);
397
+ }
398
+ finally {
399
+ payloadKey.fill(0);
400
+ }
401
+ }
402
+ finally {
403
+ fileKey.fill(0);
404
+ }
405
+ }
406
+ // ─── armor ───────────────────────────────────────────────────────────────────
407
+ /** Text form: BEGIN line, 64-column standard base64, END line. Pastes anywhere. */
408
+ export function armor(file) {
409
+ const b64 = base64.encode(file);
410
+ const lines = [];
411
+ for (let i = 0; i < b64.length; i += 64)
412
+ lines.push(b64.slice(i, i + 64));
413
+ return [AGE_ARMOR_BEGIN, ...lines, AGE_ARMOR_END].join('\n') + '\n';
414
+ }
415
+ /**
416
+ * Strict armor, as the spec and the CCTV `armor_*` vectors define it: whitespace AROUND the block is
417
+ * ignored; inside it every line is exactly the BEGIN line, 64-column canonical base64 (the last line 1-64
418
+ * columns, never empty), the END line — LF or CRLF throughout, no blank lines, no trailing spaces, nothing
419
+ * before or after. A pasted email is not that; `extractArmored` turns one into this.
420
+ */
421
+ export function dearmor(text) {
422
+ const t = text.replace(/^[ \t\r\n]+|[ \t\r\n]+$/g, '');
423
+ const lf = t.replace(/\r\n/g, '\n');
424
+ if (lf.includes('\r'))
425
+ throw new AgeError('malformed', 'armor: a bare carriage return');
426
+ const lines = lf.split('\n');
427
+ if (lines.length < 3 || lines[0] !== AGE_ARMOR_BEGIN || lines[lines.length - 1] !== AGE_ARMOR_END) {
428
+ throw new AgeError('malformed', 'no armored age block found');
429
+ }
430
+ const body = lines.slice(1, -1);
431
+ for (let i = 0; i < body.length; i++) {
432
+ const last = i === body.length - 1;
433
+ if (body[i].length > 64 || (!last && body[i].length !== 64) || body[i].length === 0) {
434
+ throw new AgeError('malformed', 'armor: lines must be 64 columns, the last 1-64');
435
+ }
436
+ if (!/^[A-Za-z0-9+/=]+$/.test(body[i]))
437
+ throw new AgeError('malformed', 'armored body is not base64');
438
+ }
439
+ try {
440
+ return base64.decode(body.join(''));
441
+ }
442
+ catch {
443
+ throw new AgeError('malformed', 'armored body is not base64');
444
+ }
445
+ }
446
+ /**
447
+ * The paste-box convenience, and a deliberate departure from the spec: find an armored block inside
448
+ * surrounding prose (an email quotes the note), tolerate CRLF, indentation and trailing spaces and blank
449
+ * lines, and hand back the canonical block. It decides nothing about the bytes — `dearmor` still does.
450
+ * Never use it on the server path: what is stored is always the machine-made strict form.
451
+ */
452
+ export function extractArmored(text) {
453
+ const t = text.replace(/\r\n?/g, '\n');
454
+ const start = t.indexOf(AGE_ARMOR_BEGIN);
455
+ const end = t.indexOf(AGE_ARMOR_END, start < 0 ? 0 : start);
456
+ if (start < 0 || end < 0)
457
+ throw new AgeError('malformed', 'no armored age block found');
458
+ const body = t
459
+ .slice(start + AGE_ARMOR_BEGIN.length, end)
460
+ .split('\n')
461
+ .map((l) => l.trim())
462
+ .filter((l) => l.length > 0);
463
+ if (body.length === 0)
464
+ throw new AgeError('malformed', 'armored block is empty');
465
+ return [AGE_ARMOR_BEGIN, ...body, AGE_ARMOR_END].join('\n');
466
+ }
467
+ /** Is this text an age file in either form? Cheap, for a paste box deciding what it was given. */
468
+ export function looksLikeAge(text) {
469
+ const t = text.trimStart();
470
+ return t.startsWith(AGE_ARMOR_BEGIN) || t.startsWith(AGE_VERSION_LINE);
471
+ }
472
+ // ─── text conveniences ───────────────────────────────────────────────────────
473
+ /** Seal a string for recipients and hand back armored text. */
474
+ export function sealText(text, recipients) {
475
+ return armor(encrypt(utf8(text), recipients));
476
+ }
477
+ /** Open armored (or raw) age text with identities and hand back the plaintext BYTES (a fixed-size capsule is bytes, not text). */
478
+ export function openBytes(ageText, identities) {
479
+ // Armored anywhere in the text (an email quotes prose around it); otherwise raw bytes.
480
+ const file = ageText.includes(AGE_ARMOR_BEGIN) ? dearmor(extractArmored(ageText)) : utf8(ageText);
481
+ return decrypt(file, identities);
482
+ }
483
+ /** Open armored (or raw) age text with identities and read the plaintext as UTF-8. */
484
+ export function openText(ageText, identities) {
485
+ return dec.decode(openBytes(ageText, identities));
486
+ }
487
+ //# sourceMappingURL=age.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"age.js","sourceRoot":"","sources":["../src/age.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,wFAAwF;AACxF,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