zeyra 1.1.0 → 2.1.0

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 (90) hide show
  1. package/README.md +183 -97
  2. package/dist/CipherAgent/class.d.ts +13 -0
  3. package/dist/CipherAgent/class.d.ts.map +1 -0
  4. package/dist/CipherAgent/class.js +19 -0
  5. package/dist/CipherAgent/class.js.map +1 -0
  6. package/dist/CipherCluster/class.d.ts +12 -0
  7. package/dist/CipherCluster/class.d.ts.map +1 -0
  8. package/dist/CipherCluster/class.js +27 -0
  9. package/dist/CipherCluster/class.js.map +1 -0
  10. package/dist/HmacAgent/class.d.ts +7 -0
  11. package/dist/HmacAgent/class.d.ts.map +1 -0
  12. package/dist/HmacAgent/class.js +15 -0
  13. package/dist/HmacAgent/class.js.map +1 -0
  14. package/dist/SigningAgent/class.d.ts +6 -0
  15. package/dist/SigningAgent/class.d.ts.map +1 -0
  16. package/dist/SigningAgent/class.js +12 -0
  17. package/dist/SigningAgent/class.js.map +1 -0
  18. package/dist/SigningCluster/class.d.ts +5 -0
  19. package/dist/SigningCluster/class.d.ts.map +1 -0
  20. package/dist/SigningCluster/class.js +20 -0
  21. package/dist/SigningCluster/class.js.map +1 -0
  22. package/dist/UnwrappingAgent/class.d.ts +6 -0
  23. package/dist/UnwrappingAgent/class.d.ts.map +1 -0
  24. package/dist/UnwrappingAgent/class.js +12 -0
  25. package/dist/UnwrappingAgent/class.js.map +1 -0
  26. package/dist/UnwrappingCluster/class.d.ts +5 -0
  27. package/dist/UnwrappingCluster/class.d.ts.map +1 -0
  28. package/dist/UnwrappingCluster/class.js +18 -0
  29. package/dist/UnwrappingCluster/class.js.map +1 -0
  30. package/dist/VerificationAgent/class.d.ts +6 -0
  31. package/dist/VerificationAgent/class.d.ts.map +1 -0
  32. package/dist/VerificationAgent/class.js +12 -0
  33. package/dist/VerificationAgent/class.js.map +1 -0
  34. package/dist/VerificationCluster/class.d.ts +5 -0
  35. package/dist/VerificationCluster/class.d.ts.map +1 -0
  36. package/dist/VerificationCluster/class.js +20 -0
  37. package/dist/VerificationCluster/class.js.map +1 -0
  38. package/dist/WrappingAgent/class.d.ts +6 -0
  39. package/dist/WrappingAgent/class.d.ts.map +1 -0
  40. package/dist/WrappingAgent/class.js +14 -0
  41. package/dist/WrappingAgent/class.js.map +1 -0
  42. package/dist/WrappingCluster/class.d.ts +5 -0
  43. package/dist/WrappingCluster/class.d.ts.map +1 -0
  44. package/dist/WrappingCluster/class.js +18 -0
  45. package/dist/WrappingCluster/class.js.map +1 -0
  46. package/dist/deriveRootKeys/deriveCipherKey.d.ts +2 -0
  47. package/dist/deriveRootKeys/deriveCipherKey.d.ts.map +1 -0
  48. package/dist/deriveRootKeys/deriveCipherKey.js +5 -0
  49. package/dist/deriveRootKeys/deriveCipherKey.js.map +1 -0
  50. package/dist/deriveRootKeys/deriveHmacKey.d.ts +2 -0
  51. package/dist/deriveRootKeys/deriveHmacKey.d.ts.map +1 -0
  52. package/dist/deriveRootKeys/deriveHmacKey.js +5 -0
  53. package/dist/deriveRootKeys/deriveHmacKey.js.map +1 -0
  54. package/dist/deriveRootKeys/index.d.ts +6 -0
  55. package/dist/deriveRootKeys/index.d.ts.map +1 -0
  56. package/dist/deriveRootKeys/index.js +21 -0
  57. package/dist/deriveRootKeys/index.js.map +1 -0
  58. package/dist/generateKeyset/generateCipherKey/index.d.ts +2 -0
  59. package/dist/generateKeyset/generateCipherKey/index.d.ts.map +1 -0
  60. package/dist/generateKeyset/generateCipherKey/index.js +5 -0
  61. package/dist/generateKeyset/generateCipherKey/index.js.map +1 -0
  62. package/dist/generateKeyset/generateHmacKey/index.d.ts +2 -0
  63. package/dist/generateKeyset/generateHmacKey/index.d.ts.map +1 -0
  64. package/dist/generateKeyset/generateHmacKey/index.js +5 -0
  65. package/dist/generateKeyset/generateHmacKey/index.js.map +1 -0
  66. package/dist/generateKeyset/generateSignPair/index.d.ts +5 -0
  67. package/dist/generateKeyset/generateSignPair/index.d.ts.map +1 -0
  68. package/dist/generateKeyset/generateSignPair/index.js +7 -0
  69. package/dist/generateKeyset/generateSignPair/index.js.map +1 -0
  70. package/dist/generateKeyset/generateWrapPair/index.d.ts +5 -0
  71. package/dist/generateKeyset/generateWrapPair/index.d.ts.map +1 -0
  72. package/dist/generateKeyset/generateWrapPair/index.js +12 -0
  73. package/dist/generateKeyset/generateWrapPair/index.js.map +1 -0
  74. package/dist/generateKeyset/index.d.ts +9 -0
  75. package/dist/generateKeyset/index.d.ts.map +1 -0
  76. package/dist/generateKeyset/index.js +19 -0
  77. package/dist/generateKeyset/index.js.map +1 -0
  78. package/dist/index.d.ts +20 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +19 -0
  81. package/dist/index.js.map +1 -0
  82. package/package.json +63 -53
  83. package/src/CipherAgent/class.js +0 -43
  84. package/src/CipherCluster/class.js +0 -57
  85. package/src/SigningAgent/class.js +0 -23
  86. package/src/SigningCluster/class.js +0 -34
  87. package/src/VerificationAgent/class.js +0 -29
  88. package/src/VerificationCluster/class.js +0 -35
  89. package/src/generateKeyset/index.js +0 -36
  90. package/src/index.js +0 -16
package/README.md CHANGED
@@ -1,113 +1,199 @@
1
- # Zeyra
2
-
3
- Managed WebCrypto helpers for storage-ready AES-GCM + ECDSA keysets, with lightweight agents and weakly cached clusters.
4
-
5
- ## Features
6
-
7
- - AES-GCM 256 encryption/decryption via `CipherAgent`
8
- - ECDSA P-256 signing/verification via `SigningAgent` and `VerificationAgent`
9
- - Managed clusters (`CipherCluster`, `SigningCluster`, `VerificationCluster`) cache agents with WeakRef for large keysets
10
- - `generateKeyset()` produces an exportable JWK bundle you can store or transport
11
- - Storage/transport-ready artifacts with base64url payloads and SHA-256 digests
12
- - Pure WebCrypto, no native add-ons; ships as ESM
13
- - Works with `bytecodec` for UTF-8, compression, and base64url conversions
14
-
15
- ## Requirements
16
-
17
- - Node.js 18+ (global `crypto.subtle`)
18
- - ESM environment (`"type": "module"` in `package.json`)
19
-
20
- ## Installation
21
-
22
- ```bash
23
- npm install zeyra
24
- ```
25
-
26
- ## Quickstart (agents)
1
+ # Zeyra
2
+
3
+ Client-side WebCrypto helpers for AES-GCM encryption, ECDSA signatures, RSA-OAEP key wrapping, HMAC, and key generation, with byte-oriented cluster helpers.
4
+
5
+ ## Compatibility
6
+
7
+ - WebCrypto (`crypto.subtle`) is stable in evergreen browsers; unprefixed support shipped in Chrome 37 (2014), Firefox 34 (2014), Edge 12 (2015), and Safari 11 (2017).
8
+ - Zeyra relies on AES-GCM, ECDSA P-256, RSA-OAEP, and HMAC SHA-256 plus wrap/unwrap; legacy EdgeHTML/IE have partial WebCrypto (notably missing ECDSA), so target Chromium Edge (79+, 2020) and modern browsers.
9
+ - ESM only; requires global `crypto.subtle`.
10
+
11
+ ## Features
12
+
13
+ - AES-GCM 256 encryption/decryption via `CipherAgent` and `CipherCluster`
14
+ - ECDSA P-256 sign/verify via `SigningAgent`, `VerificationAgent`, and clusters
15
+ - HMAC SHA-256 sign/verify via `HmacAgent` + key generation via `generateHmacKey()`
16
+ - RSA-OAEP 4096 wrap/unwrap for AES-GCM JWKs
17
+ - WebAuthn PRF root key derivation via `deriveRootKeys()`
18
+ - `generateKeyset()` yields `cipherJwk`, `signingJwk`, `verificationJwk`, `wrappingJwk`, `unwrappingJwk`, `hmacJwk`
19
+ - Individual key generators are available when you only need one key type.
20
+ - Cluster classes cache agents with `WeakRef`; they are a lightweight optimization, not a full end-to-end solution
21
+ - Byte-oriented clusters return raw `Uint8Array` / `ArrayBuffer` (no base64); use `bytecodec` for JSON, compression, and encoding
22
+ - TypeScript source; published package ships compiled JS + `.d.ts`
23
+
24
+ ## Requirements
25
+
26
+ - Node.js 18+ for server/edge usage
27
+ - ESM environment (`"type": "module"`)
28
+ - `bytecodec` for JSON/bytes/compression helpers
29
+
30
+ ## Installation
31
+
32
+ ```sh
33
+ npm install zeyra
34
+ # or
35
+ pnpm add zeyra
36
+ # or
37
+ yarn add zeyra
38
+ ```
39
+
40
+ ## Quickstart (agents)
41
+
42
+ ```js
43
+ import { Bytes } from "bytecodec";
44
+ import {
45
+ generateKeyset,
46
+ CipherAgent,
47
+ SigningAgent,
48
+ VerificationAgent,
49
+ } from "zeyra";
50
+
51
+ const { cipherJwk, signingJwk, verificationJwk } = await generateKeyset();
52
+
53
+ const cipher = new CipherAgent(cipherJwk);
54
+ const signer = new SigningAgent(signingJwk);
55
+ const verifier = new VerificationAgent(verificationJwk);
56
+
57
+ const payload = await cipher.encrypt(Bytes.fromString("hello world"));
58
+ const ciphertextBytes = new Uint8Array(payload.ciphertext);
59
+ const signature = await signer.sign(ciphertextBytes);
60
+
61
+ const authorized = await verifier.verify(ciphertextBytes, signature);
62
+ const plaintext = Bytes.toString(await cipher.decrypt(payload));
63
+ ```
64
+
65
+ ## Managed cluster flow
66
+
67
+ ```js
68
+ import {
69
+ generateKeyset,
70
+ CipherCluster,
71
+ SigningCluster,
72
+ VerificationCluster,
73
+ } from "zeyra";
74
+
75
+ const { cipherJwk, signingJwk, verificationJwk } = await generateKeyset();
76
+
77
+ const resource = { id: "file-123", body: "hello world" };
78
+ const artifact = await CipherCluster.encrypt(cipherJwk, resource);
79
+ // artifact: { iv: Uint8Array, ciphertext: ArrayBuffer }
80
+
81
+ const signature = await SigningCluster.sign(signingJwk, resource.id);
82
+ const authorized = await VerificationCluster.verify(
83
+ verificationJwk,
84
+ resource.id,
85
+ signature
86
+ );
87
+
88
+ const decrypted = await CipherCluster.decrypt(cipherJwk, artifact);
89
+ ```
90
+
91
+ ## Key wrapping flow
92
+
93
+ ```js
94
+ import { generateKeyset, WrappingCluster, UnwrappingCluster } from "zeyra";
95
+
96
+ const { cipherJwk, wrappingJwk, unwrappingJwk } = await generateKeyset();
97
+
98
+ const wrapped = await WrappingCluster.wrap(wrappingJwk, cipherJwk);
99
+ const unwrappedCipherJwk = await UnwrappingCluster.unwrap(
100
+ unwrappingJwk,
101
+ wrapped
102
+ );
103
+ ```
104
+
105
+ ## HMAC flow
27
106
 
28
107
  ```js
29
- import { Bytes } from "bytecodec";
30
- import {
31
- generateKeyset,
32
- CipherAgent,
33
- SigningAgent,
34
- VerificationAgent,
35
- } from "zeyra";
36
-
37
- // One-time key material for a resource
38
- const { symmetricJwk, privateJwk, publicJwk } = await generateKeyset();
108
+ import { generateHmacKey, HmacAgent } from "zeyra";
39
109
 
40
- // Writers: encrypt + sign
41
- const cipher = new CipherAgent(symmetricJwk);
42
- const signer = new SigningAgent(privateJwk);
43
- const payload = await cipher.encrypt(Bytes.fromString("hello world"));
44
- const signature = await signer.sign(payload.ciphertext);
110
+ const hmacJwk = await generateHmacKey();
111
+ const hmac = new HmacAgent(hmacJwk);
45
112
 
46
- // Readers / servers: verify ownership + decrypt
47
- const verifier = new VerificationAgent(publicJwk);
48
- const authorized = await verifier.verify(payload.ciphertext, signature);
49
- const plaintext = Bytes.toString(await cipher.decrypt(payload));
113
+ const challenge = new TextEncoder().encode("hello world");
114
+ const signature = await hmac.sign(challenge);
115
+ const authorized = await hmac.verify(challenge, signature);
50
116
  ```
51
117
 
52
- ## Managed cluster flow
118
+ ## PRF root key derivation
53
119
 
54
- ```js
55
- import {
56
- generateKeyset,
57
- CipherCluster,
58
- SigningCluster,
59
- VerificationCluster,
60
- } from "zeyra";
61
-
62
- const { symmetricJwk, privateJwk, publicJwk } = await generateKeyset();
120
+ Pass WebAuthn PRF results (from `assertion.getClientExtensionResults()?.prf?.results`) to derive HMAC + AES root keys.
63
121
 
64
- const resource = { id: "file-123", body: "hello world" };
65
- const artifact = await CipherCluster.encrypt(symmetricJwk, resource);
66
- const signature = await SigningCluster.sign(privateJwk, resource.id);
122
+ ```js
123
+ import { deriveRootKeys } from "zeyra";
67
124
 
68
- // VerificationCluster is designed to run on a per-resource server node.
69
- const authorized = await VerificationCluster.verify(
70
- publicJwk,
71
- resource.id,
72
- signature
73
- );
125
+ const prfResults = assertion.getClientExtensionResults()?.prf?.results;
126
+ const rootKeys = await deriveRootKeys(prfResults);
127
+ if (!rootKeys) throw new Error("Missing PRF results");
74
128
 
75
- const decrypted = await CipherCluster.decrypt(symmetricJwk, artifact);
129
+ const { hmacJwk, cipherJwk } = rootKeys;
76
130
  ```
77
131
 
78
132
  ## API
79
133
 
80
- - `generateKeyset()` -> `{ symmetricJwk, publicJwk, privateJwk }` (all exportable JWKs)
81
- - `new CipherAgent(symmetricJwk)`
134
+ - `generateKeyset()` -> `{ cipherJwk, verificationJwk, signingJwk, wrappingJwk, unwrappingJwk, hmacJwk }`
135
+ - `generateHmacKey()` -> `JsonWebKey` (HMAC SHA-256)
136
+ - `generateCipherKey()` -> `JsonWebKey` (AES-GCM 256)
137
+ - `generateSignPair()` -> `{ signingJwk, verificationJwk }` (ECDSA P-256)
138
+ - `generateWrapPair()` -> `{ wrappingJwk, unwrappingJwk }` (RSA-OAEP 4096)
139
+ - `deriveRootKeys(prfResults)` -> `{ hmacJwk, cipherJwk } | false`
140
+ - `new CipherAgent(cipherJwk)`
82
141
  - `.encrypt(Uint8Array)` -> `{ iv: Uint8Array, ciphertext: ArrayBuffer }`
83
142
  - `.decrypt({ iv, ciphertext })` -> `Uint8Array`
84
- - `new SigningAgent(privateJwk)`
85
- - `.sign(Uint8Array | ArrayBuffer)` -> `ArrayBuffer` (ECDSA P-256 / SHA-256)
86
- - `new VerificationAgent(publicJwk)`
87
- - `.verify(Uint8Array | ArrayBuffer, ArrayBuffer)` -> `boolean`
88
- - `CipherCluster.encrypt(symmetricJwk, resource)`
89
- - -> `{ digest, ciphertext, iv }` (all base64url strings; digest is SHA-256 of JSON bytes, pre-encryption, useful for version checks)
90
- - `CipherCluster.decrypt(symmetricJwk, artifact)`
91
- - -> `{ digest, ...resource }` (resource object restored from compressed JSON)
92
- - `SigningCluster.sign(privateJwk, value)` -> `Base64URLString`
93
- - `VerificationCluster.verify(publicJwk, value, signature)` -> `boolean`
94
-
95
- See the implementations in `src/index.js` and friends for details.
96
-
97
- ## Testing and benchmarks
98
-
99
- - Run tests: `npm test` (uses Node's built-in `node:test` runner against `test.js`)
100
- - Run microbenchmarks (skipped by default): `npm run bench`
101
- - Pass iterations: `npm run bench -- --iterations=500`
102
- - Reports ops/sec for encryption and the full encrypt/sign/verify/decrypt pipeline.
103
-
104
- ## Notes
105
-
106
- - CipherCluster assumes one unique random key per resource (no derivations or shared usage).
107
- - Cluster classes are intended for client-side usage; `VerificationCluster`/`VerificationAgent` can be hosted per-resource to pre-verify access before downstream identity or ACL checks.
108
- - Cluster serialization uses JSON and adds a `digest` field; avoid using `digest` in resource objects.
109
- - WeakRef caching keeps memory usage loose and GC-friendly by design.
110
-
111
- ## License
112
-
113
- MIT
143
+ - `new HmacAgent(hmacJwk)`
144
+ - `.sign(BufferSource)` -> `ArrayBuffer` (HMAC SHA-256)
145
+ - `.verify(BufferSource, BufferSource)` -> `boolean`
146
+ - `new SigningAgent(signingJwk)`
147
+ - `.sign(Uint8Array)` -> `ArrayBuffer` (ECDSA P-256 / SHA-256)
148
+ - `new VerificationAgent(verificationJwk)`
149
+ - `.verify(Uint8Array, ArrayBuffer)` -> `boolean`
150
+ - `new WrappingAgent(wrappingJwk)`
151
+ - `.wrap(cipherJwk)` -> `ArrayBuffer` (RSA-OAEP / SHA-256)
152
+ - `new UnwrappingAgent(unwrappingJwk)`
153
+ - `.unwrap(ArrayBuffer)` -> `JsonWebKey`
154
+ - `CipherCluster.encrypt(cipherJwk, resource)` -> `{ iv, ciphertext }`
155
+ - `CipherCluster.decrypt(cipherJwk, artifact)` -> `resource`
156
+ - `SigningCluster.sign(signingJwk, value)` -> `ArrayBuffer`
157
+ - `VerificationCluster.verify(verificationJwk, value, signature)` -> `boolean`
158
+ - `WrappingCluster.wrap(wrappingJwk, cipherJwk)` -> `ArrayBuffer`
159
+ - `UnwrappingCluster.unwrap(unwrappingJwk, wrapped)` -> `JsonWebKey`
160
+
161
+ ## Serialization helpers
162
+
163
+ Zeyra keeps clusters byte-oriented. Use `bytecodec` when you need to serialize or store artifacts.
164
+
165
+ ```js
166
+ import { Bytes } from "bytecodec";
167
+
168
+ const artifact = await CipherCluster.encrypt(cipherJwk, resource);
169
+ const ciphertextB64 = Bytes.toBase64UrlString(
170
+ new Uint8Array(artifact.ciphertext)
171
+ );
172
+ const ivB64 = Bytes.toBase64UrlString(artifact.iv);
173
+ ```
174
+
175
+ ## Testing and benchmarks
176
+
177
+ - Build: `npm run build` (outputs `dist/`)
178
+ - Run tests: `npm test` (builds `dist/`, then runs `node --test`)
179
+ - Run benchmarks: `npm run bench`
180
+ - Pass iterations: `npm run bench -- --iterations=500`
181
+
182
+ ## Benchmarks (local)
183
+
184
+ Results will vary by hardware, runtime, and payload size. Run `npm run bench` to reproduce.
185
+
186
+ - Node v22.14.0 (Windows), iterations=200
187
+ - encrypt only: 31.68ms (6313.6 ops/sec)
188
+ - hmac sign/verify: 40.48ms (4940.1 ops/sec)
189
+ - full pipeline: 122.61ms (1631.2 ops/sec)
190
+
191
+ ## Notes
192
+
193
+ - Zeyra is intended for client-side encryption workflows; server/edge usage is supported where WebCrypto is available.
194
+ - Cluster helpers cache keys with `WeakRef` and keep `CryptoKey` material private inside agents.
195
+ - `CipherCluster` compresses JSON payloads before encryption; `SigningCluster`/`VerificationCluster` sign JSON values.
196
+
197
+ ## License
198
+
199
+ MIT
@@ -0,0 +1,13 @@
1
+ export declare class CipherAgent {
2
+ private keyPromise;
3
+ constructor(cipherJwk: JsonWebKey);
4
+ encrypt(plaintext: Uint8Array): Promise<{
5
+ iv: Uint8Array;
6
+ ciphertext: ArrayBuffer;
7
+ }>;
8
+ decrypt({ iv, ciphertext, }: {
9
+ iv: Uint8Array<ArrayBufferLike>;
10
+ ciphertext: ArrayBuffer;
11
+ }): Promise<Uint8Array>;
12
+ }
13
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/CipherAgent/class.ts"],"names":[],"mappings":"AACA,qBAAa,WAAW;IACtB,OAAO,CAAC,UAAU,CAAqB;gBAC3B,SAAS,EAAE,UAAU;IAU3B,OAAO,CACX,SAAS,EAAE,UAAU,GACpB,OAAO,CAAC;QAAE,EAAE,EAAE,UAAU,CAAC;QAAC,UAAU,EAAE,WAAW,CAAA;KAAE,CAAC;IAWjD,OAAO,CAAC,EACZ,EAAE,EACF,UAAU,GACX,EAAE;QACD,EAAE,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;QAChC,UAAU,EAAE,WAAW,CAAC;KACzB,GAAG,OAAO,CAAC,UAAU,CAAC;CASxB"}
@@ -0,0 +1,19 @@
1
+ import { Bytes } from "bytecodec";
2
+ export class CipherAgent {
3
+ keyPromise;
4
+ constructor(cipherJwk) {
5
+ this.keyPromise = crypto.subtle.importKey("jwk", cipherJwk, { name: "AES-GCM" }, false, ["encrypt", "decrypt"]);
6
+ }
7
+ async encrypt(plaintext) {
8
+ const key = await this.keyPromise;
9
+ const iv = crypto.getRandomValues(new Uint8Array(12));
10
+ const ciphertext = await crypto.subtle.encrypt({ name: "AES-GCM", iv }, key, Bytes.toBufferSource(plaintext));
11
+ return { iv, ciphertext };
12
+ }
13
+ async decrypt({ iv, ciphertext, }) {
14
+ const key = await this.keyPromise;
15
+ const plaintext = await crypto.subtle.decrypt({ name: "AES-GCM", iv: Bytes.toBufferSource(iv) }, key, ciphertext);
16
+ return new Uint8Array(plaintext);
17
+ }
18
+ }
19
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/CipherAgent/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,MAAM,OAAO,WAAW;IACd,UAAU,CAAqB;IACvC,YAAY,SAAqB;QAC/B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CACvC,KAAK,EACL,SAAS,EACT,EAAE,IAAI,EAAE,SAAS,EAAE,EACnB,KAAK,EACL,CAAC,SAAS,EAAE,SAAS,CAAC,CACvB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CACX,SAAqB;QAErB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;QAClC,MAAM,EAAE,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;QACtD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAC5C,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,EACvB,GAAG,EACH,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAChC,CAAC;QACF,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EACZ,EAAE,EACF,UAAU,GAIX;QACC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;QAClC,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAC3C,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,EACjD,GAAG,EACH,UAAU,CACX,CAAC;QACF,OAAO,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ export declare class CipherCluster {
2
+ #private;
3
+ static encrypt(cipherJwk: JsonWebKey, resource: any): Promise<{
4
+ iv: Uint8Array;
5
+ ciphertext: ArrayBuffer;
6
+ }>;
7
+ static decrypt(cipherJwk: JsonWebKey, artifact: {
8
+ iv: Uint8Array;
9
+ ciphertext: ArrayBuffer;
10
+ }): Promise<any>;
11
+ }
12
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/CipherCluster/class.ts"],"names":[],"mappings":"AAGA,qBAAa,aAAa;;WAaX,OAAO,CAClB,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,GAAG,GACZ,OAAO,CAAC;QAAE,EAAE,EAAE,UAAU,CAAC;QAAC,UAAU,EAAE,WAAW,CAAA;KAAE,CAAC;WAQ1C,OAAO,CAClB,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE;QAAE,EAAE,EAAE,UAAU,CAAC;QAAC,UAAU,EAAE,WAAW,CAAA;KAAE,GACpD,OAAO,CAAC,GAAG,CAAC;CAMhB"}
@@ -0,0 +1,27 @@
1
+ import { Bytes } from "bytecodec";
2
+ import { CipherAgent } from "../CipherAgent/class.js";
3
+ export class CipherCluster {
4
+ static #agents = new WeakMap();
5
+ static #loadAgent(cipherJwk) {
6
+ const weakRef = CipherCluster.#agents.get(cipherJwk);
7
+ let agent = weakRef?.deref();
8
+ if (!agent) {
9
+ agent = new CipherAgent(cipherJwk);
10
+ CipherCluster.#agents.set(cipherJwk, new WeakRef(agent));
11
+ }
12
+ return agent;
13
+ }
14
+ static async encrypt(cipherJwk, resource) {
15
+ const agent = CipherCluster.#loadAgent(cipherJwk);
16
+ const bytes = Bytes.fromJSON(resource);
17
+ const compressed = await Bytes.toCompressed(bytes);
18
+ return await agent.encrypt(compressed);
19
+ }
20
+ static async decrypt(cipherJwk, artifact) {
21
+ const agent = CipherCluster.#loadAgent(cipherJwk);
22
+ const bytes = await agent.decrypt(artifact);
23
+ const decompressed = await Bytes.fromCompressed(bytes);
24
+ return Bytes.toJSON(decompressed);
25
+ }
26
+ }
27
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/CipherCluster/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,OAAO,aAAa;IACxB,MAAM,CAAC,OAAO,GAAG,IAAI,OAAO,EAAoC,CAAC;IAEjE,MAAM,CAAC,UAAU,CAAC,SAAqB;QACrC,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,KAAK,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;YACnC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,SAAqB,EACrB,QAAa;QAEb,MAAM,KAAK,GAAG,aAAa,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAClD,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEvC,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACnD,OAAO,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,SAAqB,EACrB,QAAqD;QAErD,MAAM,KAAK,GAAG,aAAa,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAClD,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACvD,OAAO,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare class HmacAgent {
2
+ private keyPromise;
3
+ constructor(hmacJwk: JsonWebKey);
4
+ sign(challenge: BufferSource): Promise<ArrayBuffer>;
5
+ verify(challenge: BufferSource, signature: BufferSource): Promise<boolean>;
6
+ }
7
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/HmacAgent/class.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAS;IACpB,OAAO,CAAC,UAAU,CAAqB;gBAE3B,OAAO,EAAE,UAAU;IAUzB,IAAI,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAKnD,MAAM,CACV,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,OAAO,CAAC;CAIpB"}
@@ -0,0 +1,15 @@
1
+ export class HmacAgent {
2
+ keyPromise;
3
+ constructor(hmacJwk) {
4
+ this.keyPromise = crypto.subtle.importKey("jwk", hmacJwk, { name: "HMAC", hash: "SHA-256" }, false, ["sign", "verify"]);
5
+ }
6
+ async sign(challenge) {
7
+ const key = await this.keyPromise;
8
+ return crypto.subtle.sign("HMAC", key, challenge);
9
+ }
10
+ async verify(challenge, signature) {
11
+ const key = await this.keyPromise;
12
+ return crypto.subtle.verify("HMAC", key, signature, challenge);
13
+ }
14
+ }
15
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/HmacAgent/class.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAS;IACZ,UAAU,CAAqB;IAEvC,YAAY,OAAmB;QAC7B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CACvC,KAAK,EACL,OAAO,EACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EACjC,KAAK,EACL,CAAC,MAAM,EAAE,QAAQ,CAAC,CACnB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAuB;QAChC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,MAAM,CACV,SAAuB,EACvB,SAAuB;QAEvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACjE,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ export declare class SigningAgent {
2
+ private keyPromise;
3
+ constructor(signingJwk: JsonWebKey);
4
+ sign(bytes: Uint8Array): Promise<ArrayBuffer>;
5
+ }
6
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/SigningAgent/class.ts"],"names":[],"mappings":"AACA,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAqB;gBAE3B,UAAU,EAAE,UAAU;IAU5B,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC;CAQpD"}
@@ -0,0 +1,12 @@
1
+ import { Bytes } from "bytecodec";
2
+ export class SigningAgent {
3
+ keyPromise;
4
+ constructor(signingJwk) {
5
+ this.keyPromise = crypto.subtle.importKey("jwk", signingJwk, { name: "ECDSA", namedCurve: "P-256" }, false, ["sign"]);
6
+ }
7
+ async sign(bytes) {
8
+ const key = await this.keyPromise;
9
+ return crypto.subtle.sign({ name: "ECDSA", hash: "SHA-256" }, key, Bytes.toBufferSource(bytes));
10
+ }
11
+ }
12
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/SigningAgent/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,MAAM,OAAO,YAAY;IACf,UAAU,CAAqB;IAEvC,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CACvC,KAAK,EACL,UAAU,EACV,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EACtC,KAAK,EACL,CAAC,MAAM,CAAC,CACT,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAiB;QAC1B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CACvB,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAClC,GAAG,EACH,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAC5B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export declare class SigningCluster {
2
+ #private;
3
+ static sign(signingJwk: JsonWebKey, value: any): Promise<ArrayBuffer>;
4
+ }
5
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/SigningCluster/class.ts"],"names":[],"mappings":"AAGA,qBAAa,cAAc;;WAaZ,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC;CAK5E"}
@@ -0,0 +1,20 @@
1
+ import { Bytes } from "bytecodec";
2
+ import { SigningAgent } from "../SigningAgent/class.js";
3
+ export class SigningCluster {
4
+ static #agents = new WeakMap();
5
+ static #loadAgent(signingJwk) {
6
+ const weakRef = SigningCluster.#agents.get(signingJwk);
7
+ let agent = weakRef?.deref();
8
+ if (!agent) {
9
+ agent = new SigningAgent(signingJwk);
10
+ SigningCluster.#agents.set(signingJwk, new WeakRef(agent));
11
+ }
12
+ return agent;
13
+ }
14
+ static async sign(signingJwk, value) {
15
+ const agent = SigningCluster.#loadAgent(signingJwk);
16
+ const bytes = Bytes.fromJSON(value);
17
+ return await agent.sign(bytes);
18
+ }
19
+ }
20
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/SigningCluster/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,MAAM,OAAO,cAAc;IACzB,MAAM,CAAC,OAAO,GAAG,IAAI,OAAO,EAAqC,CAAC;IAElE,MAAM,CAAC,UAAU,CAAC,UAAsB;QACtC,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACvD,IAAI,KAAK,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;YACrC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,UAAsB,EAAE,KAAU;QAClD,MAAM,KAAK,GAAG,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACpC,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare class UnwrappingAgent {
2
+ private keyPromise;
3
+ constructor(unwrappingJwk: JsonWebKey);
4
+ unwrap(wrapped: ArrayBuffer): Promise<JsonWebKey>;
5
+ }
6
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/UnwrappingAgent/class.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAqB;gBAC3B,aAAa,EAAE,UAAU;IAU/B,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;CAexD"}
@@ -0,0 +1,12 @@
1
+ export class UnwrappingAgent {
2
+ keyPromise;
3
+ constructor(unwrappingJwk) {
4
+ this.keyPromise = crypto.subtle.importKey("jwk", unwrappingJwk, { name: "RSA-OAEP", hash: "SHA-256" }, false, ["unwrapKey"]);
5
+ }
6
+ async unwrap(wrapped) {
7
+ const unwrappingKey = await this.keyPromise;
8
+ const aesKey = await crypto.subtle.unwrapKey("jwk", wrapped, unwrappingKey, { name: "RSA-OAEP" }, { name: "AES-GCM", length: 256 }, true, ["encrypt", "decrypt"]);
9
+ return crypto.subtle.exportKey("jwk", aesKey);
10
+ }
11
+ }
12
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/UnwrappingAgent/class.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;IAClB,UAAU,CAAqB;IACvC,YAAY,aAAyB;QACnC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CACvC,KAAK,EACL,aAAa,EACb,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,EACrC,KAAK,EACL,CAAC,WAAW,CAAC,CACd,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAoB;QAC/B,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;QAE5C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAC1C,KAAK,EACL,OAAO,EACP,aAAa,EACb,EAAE,IAAI,EAAE,UAAU,EAAE,EACpB,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,EAChC,IAAI,EACJ,CAAC,SAAS,EAAE,SAAS,CAAC,CACvB,CAAC;QAEF,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export declare class UnwrappingCluster {
2
+ #private;
3
+ static unwrap(unwrappingJwk: JsonWebKey, wrapped: ArrayBuffer): Promise<JsonWebKey>;
4
+ }
5
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/UnwrappingCluster/class.ts"],"names":[],"mappings":"AAEA,qBAAa,iBAAiB;;WAaf,MAAM,CACjB,aAAa,EAAE,UAAU,EACzB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC;CAIvB"}
@@ -0,0 +1,18 @@
1
+ import { UnwrappingAgent } from "../UnwrappingAgent/class.js";
2
+ export class UnwrappingCluster {
3
+ static #agents = new WeakMap();
4
+ static #loadAgent(unwrappingJwk) {
5
+ const weakRef = UnwrappingCluster.#agents.get(unwrappingJwk);
6
+ let agent = weakRef?.deref();
7
+ if (!agent) {
8
+ agent = new UnwrappingAgent(unwrappingJwk);
9
+ UnwrappingCluster.#agents.set(unwrappingJwk, new WeakRef(agent));
10
+ }
11
+ return agent;
12
+ }
13
+ static async unwrap(unwrappingJwk, wrapped) {
14
+ const agent = UnwrappingCluster.#loadAgent(unwrappingJwk);
15
+ return await agent.unwrap(wrapped);
16
+ }
17
+ }
18
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/UnwrappingCluster/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,MAAM,OAAO,iBAAiB;IAC5B,MAAM,CAAC,OAAO,GAAG,IAAI,OAAO,EAAwC,CAAC;IAErE,MAAM,CAAC,UAAU,CAAC,aAAyB;QACzC,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC7D,IAAI,KAAK,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;YAC3C,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,aAAyB,EACzB,OAAoB;QAEpB,MAAM,KAAK,GAAG,iBAAiB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QAC1D,OAAO,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare class VerificationAgent {
2
+ private keyPromise;
3
+ constructor(verificationJwk: JsonWebKey);
4
+ verify(bytes: Uint8Array, signature: ArrayBuffer): Promise<boolean>;
5
+ }
6
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/VerificationAgent/class.ts"],"names":[],"mappings":"AAEA,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAqB;gBAE3B,eAAe,EAAE,UAAU;IAUjC,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;CAS1E"}
@@ -0,0 +1,12 @@
1
+ import { Bytes } from "bytecodec";
2
+ export class VerificationAgent {
3
+ keyPromise;
4
+ constructor(verificationJwk) {
5
+ this.keyPromise = crypto.subtle.importKey("jwk", verificationJwk, { name: "ECDSA", namedCurve: "P-256" }, false, ["verify"]);
6
+ }
7
+ async verify(bytes, signature) {
8
+ const key = await this.keyPromise;
9
+ return crypto.subtle.verify({ name: "ECDSA", hash: "SHA-256" }, key, signature, Bytes.toBufferSource(bytes));
10
+ }
11
+ }
12
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/VerificationAgent/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,MAAM,OAAO,iBAAiB;IACpB,UAAU,CAAqB;IAEvC,YAAY,eAA2B;QACrC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CACvC,KAAK,EACL,eAAe,EACf,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EACtC,KAAK,EACL,CAAC,QAAQ,CAAC,CACX,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAiB,EAAE,SAAsB;QACpD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CACzB,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAClC,GAAG,EACH,SAAS,EACT,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAC5B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export declare class VerificationCluster {
2
+ #private;
3
+ static verify(verificationJwk: JsonWebKey, value: any, signature: ArrayBuffer): Promise<boolean>;
4
+ }
5
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/VerificationCluster/class.ts"],"names":[],"mappings":"AAGA,qBAAa,mBAAmB;;WAajB,MAAM,CACjB,eAAe,EAAE,UAAU,EAC3B,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,WAAW,GACrB,OAAO,CAAC,OAAO,CAAC;CAKpB"}
@@ -0,0 +1,20 @@
1
+ import { Bytes } from "bytecodec";
2
+ import { VerificationAgent } from "../VerificationAgent/class.js";
3
+ export class VerificationCluster {
4
+ static #agents = new WeakMap();
5
+ static #loadAgent(verificationJwk) {
6
+ const weakRef = VerificationCluster.#agents.get(verificationJwk);
7
+ let agent = weakRef?.deref();
8
+ if (!agent) {
9
+ agent = new VerificationAgent(verificationJwk);
10
+ VerificationCluster.#agents.set(verificationJwk, new WeakRef(agent));
11
+ }
12
+ return agent;
13
+ }
14
+ static async verify(verificationJwk, value, signature) {
15
+ const agent = VerificationCluster.#loadAgent(verificationJwk);
16
+ const valueBytes = Bytes.fromJSON(value);
17
+ return await agent.verify(valueBytes, signature);
18
+ }
19
+ }
20
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/VerificationCluster/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,OAAO,mBAAmB;IAC9B,MAAM,CAAC,OAAO,GAAG,IAAI,OAAO,EAA0C,CAAC;IAEvE,MAAM,CAAC,UAAU,CAAC,eAA2B;QAC3C,MAAM,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACjE,IAAI,KAAK,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,IAAI,iBAAiB,CAAC,eAAe,CAAC,CAAC;YAC/C,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,eAA2B,EAC3B,KAAU,EACV,SAAsB;QAEtB,MAAM,KAAK,GAAG,mBAAmB,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QAC9D,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,MAAM,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare class WrappingAgent {
2
+ private keyPromise;
3
+ constructor(wrappingJwk: JsonWebKey);
4
+ wrap(cipherJwk: JsonWebKey): Promise<ArrayBuffer>;
5
+ }
6
+ //# sourceMappingURL=class.d.ts.map