zeyra 1.1.0 → 2.0.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 (58) hide show
  1. package/README.md +94 -47
  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/SigningAgent/class.d.ts +6 -0
  11. package/dist/SigningAgent/class.d.ts.map +1 -0
  12. package/dist/SigningAgent/class.js +12 -0
  13. package/dist/SigningAgent/class.js.map +1 -0
  14. package/dist/SigningCluster/class.d.ts +5 -0
  15. package/dist/SigningCluster/class.d.ts.map +1 -0
  16. package/dist/SigningCluster/class.js +20 -0
  17. package/dist/SigningCluster/class.js.map +1 -0
  18. package/dist/UnwrappingAgent/class.d.ts +6 -0
  19. package/dist/UnwrappingAgent/class.d.ts.map +1 -0
  20. package/dist/UnwrappingAgent/class.js +12 -0
  21. package/dist/UnwrappingAgent/class.js.map +1 -0
  22. package/dist/UnwrappingCluster/class.d.ts +5 -0
  23. package/dist/UnwrappingCluster/class.d.ts.map +1 -0
  24. package/dist/UnwrappingCluster/class.js +18 -0
  25. package/dist/UnwrappingCluster/class.js.map +1 -0
  26. package/dist/VerificationAgent/class.d.ts +6 -0
  27. package/dist/VerificationAgent/class.d.ts.map +1 -0
  28. package/dist/VerificationAgent/class.js +12 -0
  29. package/dist/VerificationAgent/class.js.map +1 -0
  30. package/dist/VerificationCluster/class.d.ts +5 -0
  31. package/dist/VerificationCluster/class.d.ts.map +1 -0
  32. package/dist/VerificationCluster/class.js +20 -0
  33. package/dist/VerificationCluster/class.js.map +1 -0
  34. package/dist/WrappingAgent/class.d.ts +6 -0
  35. package/dist/WrappingAgent/class.d.ts.map +1 -0
  36. package/dist/WrappingAgent/class.js +14 -0
  37. package/dist/WrappingAgent/class.js.map +1 -0
  38. package/dist/WrappingCluster/class.d.ts +5 -0
  39. package/dist/WrappingCluster/class.d.ts.map +1 -0
  40. package/dist/WrappingCluster/class.js +18 -0
  41. package/dist/WrappingCluster/class.js.map +1 -0
  42. package/dist/generateKeyset/index.d.ts +8 -0
  43. package/dist/generateKeyset/index.d.ts.map +1 -0
  44. package/dist/generateKeyset/index.js +23 -0
  45. package/dist/generateKeyset/index.js.map +1 -0
  46. package/dist/index.d.ts +13 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +13 -0
  49. package/dist/index.js.map +1 -0
  50. package/package.json +20 -11
  51. package/src/CipherAgent/class.js +0 -43
  52. package/src/CipherCluster/class.js +0 -57
  53. package/src/SigningAgent/class.js +0 -23
  54. package/src/SigningCluster/class.js +0 -34
  55. package/src/VerificationAgent/class.js +0 -29
  56. package/src/VerificationCluster/class.js +0 -35
  57. package/src/generateKeyset/index.js +0 -36
  58. package/src/index.js +0 -16
package/README.md CHANGED
@@ -1,26 +1,37 @@
1
1
  # Zeyra
2
2
 
3
- Managed WebCrypto helpers for storage-ready AES-GCM + ECDSA keysets, with lightweight agents and weakly cached clusters.
3
+ Client-side WebCrypto helpers for AES-GCM encryption, ECDSA signatures, and RSA-OAEP key wrapping, 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, and RSA-OAEP 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`.
4
10
 
5
11
  ## Features
6
12
 
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
13
+ - AES-GCM 256 encryption/decryption via `CipherAgent` and `CipherCluster`
14
+ - ECDSA P-256 sign/verify via `SigningAgent`, `VerificationAgent`, and clusters
15
+ - RSA-OAEP 4096 wrap/unwrap for AES-GCM JWKs
16
+ - `generateKeyset()` yields `cipherJwk`, `signingJwk`, `verificationJwk`, `wrappingJwk`, `unwrappingJwk`
17
+ - Cluster classes cache agents with `WeakRef`; they are a lightweight optimization, not a full end-to-end solution
18
+ - Byte-oriented clusters return raw `Uint8Array` / `ArrayBuffer` (no base64); use `bytecodec` for JSON, compression, and encoding
19
+ - TypeScript source; published package ships compiled JS + `.d.ts`
14
20
 
15
21
  ## Requirements
16
22
 
17
- - Node.js 18+ (global `crypto.subtle`)
18
- - ESM environment (`"type": "module"` in `package.json`)
23
+ - Node.js 18+ for server/edge usage
24
+ - ESM environment (`"type": "module"`)
25
+ - `bytecodec` for JSON/bytes/compression helpers
19
26
 
20
27
  ## Installation
21
28
 
22
- ```bash
29
+ ```sh
23
30
  npm install zeyra
31
+ # or
32
+ pnpm add zeyra
33
+ # or
34
+ yarn add zeyra
24
35
  ```
25
36
 
26
37
  ## Quickstart (agents)
@@ -34,18 +45,17 @@ import {
34
45
  VerificationAgent,
35
46
  } from "zeyra";
36
47
 
37
- // One-time key material for a resource
38
- const { symmetricJwk, privateJwk, publicJwk } = await generateKeyset();
48
+ const { cipherJwk, signingJwk, verificationJwk } = await generateKeyset();
49
+
50
+ const cipher = new CipherAgent(cipherJwk);
51
+ const signer = new SigningAgent(signingJwk);
52
+ const verifier = new VerificationAgent(verificationJwk);
39
53
 
40
- // Writers: encrypt + sign
41
- const cipher = new CipherAgent(symmetricJwk);
42
- const signer = new SigningAgent(privateJwk);
43
54
  const payload = await cipher.encrypt(Bytes.fromString("hello world"));
44
- const signature = await signer.sign(payload.ciphertext);
55
+ const ciphertextBytes = new Uint8Array(payload.ciphertext);
56
+ const signature = await signer.sign(ciphertextBytes);
45
57
 
46
- // Readers / servers: verify ownership + decrypt
47
- const verifier = new VerificationAgent(publicJwk);
48
- const authorized = await verifier.verify(payload.ciphertext, signature);
58
+ const authorized = await verifier.verify(ciphertextBytes, signature);
49
59
  const plaintext = Bytes.toString(await cipher.decrypt(payload));
50
60
  ```
51
61
 
@@ -59,54 +69,91 @@ import {
59
69
  VerificationCluster,
60
70
  } from "zeyra";
61
71
 
62
- const { symmetricJwk, privateJwk, publicJwk } = await generateKeyset();
72
+ const { cipherJwk, signingJwk, verificationJwk } = await generateKeyset();
63
73
 
64
74
  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);
75
+ const artifact = await CipherCluster.encrypt(cipherJwk, resource);
76
+ // artifact: { iv: Uint8Array, ciphertext: ArrayBuffer }
67
77
 
68
- // VerificationCluster is designed to run on a per-resource server node.
78
+ const signature = await SigningCluster.sign(signingJwk, resource.id);
69
79
  const authorized = await VerificationCluster.verify(
70
- publicJwk,
80
+ verificationJwk,
71
81
  resource.id,
72
82
  signature
73
83
  );
74
84
 
75
- const decrypted = await CipherCluster.decrypt(symmetricJwk, artifact);
85
+ const decrypted = await CipherCluster.decrypt(cipherJwk, artifact);
86
+ ```
87
+
88
+ ## Key wrapping flow
89
+
90
+ ```js
91
+ import { generateKeyset, WrappingCluster, UnwrappingCluster } from "zeyra";
92
+
93
+ const { cipherJwk, wrappingJwk, unwrappingJwk } = await generateKeyset();
94
+
95
+ const wrapped = await WrappingCluster.wrap(wrappingJwk, cipherJwk);
96
+ const unwrappedCipherJwk = await UnwrappingCluster.unwrap(
97
+ unwrappingJwk,
98
+ wrapped
99
+ );
76
100
  ```
77
101
 
78
102
  ## API
79
103
 
80
- - `generateKeyset()` -> `{ symmetricJwk, publicJwk, privateJwk }` (all exportable JWKs)
81
- - `new CipherAgent(symmetricJwk)`
104
+ - `generateKeyset()` -> `{ cipherJwk, verificationJwk, signingJwk, wrappingJwk, unwrappingJwk }`
105
+ - `new CipherAgent(cipherJwk)`
82
106
  - `.encrypt(Uint8Array)` -> `{ iv: Uint8Array, ciphertext: ArrayBuffer }`
83
107
  - `.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.
108
+ - `new SigningAgent(signingJwk)`
109
+ - `.sign(Uint8Array)` -> `ArrayBuffer` (ECDSA P-256 / SHA-256)
110
+ - `new VerificationAgent(verificationJwk)`
111
+ - `.verify(Uint8Array, ArrayBuffer)` -> `boolean`
112
+ - `new WrappingAgent(wrappingJwk)`
113
+ - `.wrap(cipherJwk)` -> `ArrayBuffer` (RSA-OAEP / SHA-256)
114
+ - `new UnwrappingAgent(unwrappingJwk)`
115
+ - `.unwrap(ArrayBuffer)` -> `JsonWebKey`
116
+ - `CipherCluster.encrypt(cipherJwk, resource)` -> `{ iv, ciphertext }`
117
+ - `CipherCluster.decrypt(cipherJwk, artifact)` -> `resource`
118
+ - `SigningCluster.sign(signingJwk, value)` -> `ArrayBuffer`
119
+ - `VerificationCluster.verify(verificationJwk, value, signature)` -> `boolean`
120
+ - `WrappingCluster.wrap(wrappingJwk, cipherJwk)` -> `ArrayBuffer`
121
+ - `UnwrappingCluster.unwrap(unwrappingJwk, wrapped)` -> `JsonWebKey`
122
+
123
+ ## Serialization helpers
124
+
125
+ Zeyra keeps clusters byte-oriented. Use `bytecodec` when you need to serialize or store artifacts.
126
+
127
+ ```js
128
+ import { Bytes } from "bytecodec";
129
+
130
+ const artifact = await CipherCluster.encrypt(cipherJwk, resource);
131
+ const ciphertextB64 = Bytes.toBase64UrlString(
132
+ new Uint8Array(artifact.ciphertext)
133
+ );
134
+ const ivB64 = Bytes.toBase64UrlString(artifact.iv);
135
+ ```
96
136
 
97
137
  ## Testing and benchmarks
98
138
 
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`
139
+ - Build: `npm run build` (outputs `dist/`)
140
+ - Run tests: `npm test` (builds `dist/`, then runs `node --test`)
141
+ - Run benchmarks: `npm run bench`
101
142
  - Pass iterations: `npm run bench -- --iterations=500`
102
- - Reports ops/sec for encryption and the full encrypt/sign/verify/decrypt pipeline.
143
+
144
+ ## Benchmarks (local)
145
+
146
+ Results will vary by hardware, runtime, and payload size. Run `npm run bench` to reproduce.
147
+
148
+ - Node v22.14.0 (Windows), iterations=200
149
+ - encrypt only: 44.68ms (4476.3 ops/sec)
150
+ - full pipeline: 115.15ms (1736.9 ops/sec)
103
151
 
104
152
  ## Notes
105
153
 
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.
154
+ - Zeyra is intended for client-side encryption workflows; server/edge usage is supported where WebCrypto is available.
155
+ - Cluster helpers cache keys with `WeakRef` and keep `CryptoKey` material private inside agents.
156
+ - `CipherCluster` compresses JSON payloads before encryption; `SigningCluster`/`VerificationCluster` sign JSON values.
110
157
 
111
158
  ## License
112
159
 
@@ -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,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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/WrappingAgent/class.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAa;IACxB,OAAO,CAAC,UAAU,CAAqB;gBAC3B,WAAW,EAAE,UAAU;IAU7B,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC;CAexD"}
@@ -0,0 +1,14 @@
1
+ export class WrappingAgent {
2
+ keyPromise;
3
+ constructor(wrappingJwk) {
4
+ this.keyPromise = crypto.subtle.importKey("jwk", wrappingJwk, { name: "RSA-OAEP", hash: "SHA-256" }, false, ["wrapKey"]);
5
+ }
6
+ async wrap(cipherJwk) {
7
+ const wrappingKey = await this.keyPromise;
8
+ const aesKey = await crypto.subtle.importKey("jwk", cipherJwk, { name: "AES-GCM" }, true, ["encrypt", "decrypt"]);
9
+ return crypto.subtle.wrapKey("jwk", aesKey, wrappingKey, {
10
+ name: "RSA-OAEP",
11
+ });
12
+ }
13
+ }
14
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/WrappingAgent/class.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,aAAa;IAChB,UAAU,CAAqB;IACvC,YAAY,WAAuB;QACjC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CACvC,KAAK,EACL,WAAW,EACX,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,EACrC,KAAK,EACL,CAAC,SAAS,CAAC,CACZ,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAqB;QAC9B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;QAE1C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAC1C,KAAK,EACL,SAAS,EACT,EAAE,IAAI,EAAE,SAAS,EAAE,EACnB,IAAI,EACJ,CAAC,SAAS,EAAE,SAAS,CAAC,CACvB,CAAC;QAEF,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE;YACvD,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export declare class WrappingCluster {
2
+ #private;
3
+ static wrap(wrappingJwk: JsonWebKey, cipherJwk: JsonWebKey): Promise<ArrayBuffer>;
4
+ }
5
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/WrappingCluster/class.ts"],"names":[],"mappings":"AAEA,qBAAa,eAAe;;WAab,IAAI,CACf,WAAW,EAAE,UAAU,EACvB,SAAS,EAAE,UAAU,GACpB,OAAO,CAAC,WAAW,CAAC;CAIxB"}
@@ -0,0 +1,18 @@
1
+ import { WrappingAgent } from "../WrappingAgent/class.js";
2
+ export class WrappingCluster {
3
+ static #agents = new WeakMap();
4
+ static #loadAgent(wrappingJwk) {
5
+ const weakRef = WrappingCluster.#agents.get(wrappingJwk);
6
+ let agent = weakRef?.deref();
7
+ if (!agent) {
8
+ agent = new WrappingAgent(wrappingJwk);
9
+ WrappingCluster.#agents.set(wrappingJwk, new WeakRef(agent));
10
+ }
11
+ return agent;
12
+ }
13
+ static async wrap(wrappingJwk, cipherJwk) {
14
+ const agent = WrappingCluster.#loadAgent(wrappingJwk);
15
+ return await agent.wrap(cipherJwk);
16
+ }
17
+ }
18
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/WrappingCluster/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,OAAO,eAAe;IAC1B,MAAM,CAAC,OAAO,GAAG,IAAI,OAAO,EAAsC,CAAC;IAEnE,MAAM,CAAC,UAAU,CAAC,WAAuB;QACvC,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzD,IAAI,KAAK,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;YACvC,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,CACf,WAAuB,EACvB,SAAqB;QAErB,MAAM,KAAK,GAAG,eAAe,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACtD,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare function generateKeyset(): Promise<{
2
+ cipherJwk: JsonWebKey;
3
+ verificationJwk: JsonWebKey;
4
+ signingJwk: JsonWebKey;
5
+ wrappingJwk: JsonWebKey;
6
+ unwrappingJwk: JsonWebKey;
7
+ }>;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generateKeyset/index.ts"],"names":[],"mappings":"AAAA,wBAAsB,cAAc,IAAI,OAAO,CAAC;IAC9C,SAAS,EAAE,UAAU,CAAC;IACtB,eAAe,EAAE,UAAU,CAAC;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,UAAU,CAAC;IACxB,aAAa,EAAE,UAAU,CAAC;CAC3B,CAAC,CA0CD"}
@@ -0,0 +1,23 @@
1
+ export async function generateKeyset() {
2
+ const aesKey = await crypto.subtle.generateKey({ name: "AES-GCM", length: 256 }, true, ["encrypt", "decrypt"]);
3
+ const cipherJwk = await crypto.subtle.exportKey("jwk", aesKey);
4
+ const signPair = await crypto.subtle.generateKey({ name: "ECDSA", namedCurve: "P-256" }, true, ["sign", "verify"]);
5
+ const verificationJwk = await crypto.subtle.exportKey("jwk", signPair.publicKey);
6
+ const signingJwk = await crypto.subtle.exportKey("jwk", signPair.privateKey);
7
+ const wrapPair = await crypto.subtle.generateKey({
8
+ name: "RSA-OAEP",
9
+ modulusLength: 4096,
10
+ publicExponent: new Uint8Array([1, 0, 1]),
11
+ hash: "SHA-256",
12
+ }, true, ["wrapKey", "unwrapKey"]);
13
+ const wrappingJwk = await crypto.subtle.exportKey("jwk", wrapPair.publicKey);
14
+ const unwrappingJwk = await crypto.subtle.exportKey("jwk", wrapPair.privateKey);
15
+ return {
16
+ cipherJwk,
17
+ verificationJwk,
18
+ signingJwk,
19
+ wrappingJwk,
20
+ unwrappingJwk,
21
+ };
22
+ }
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generateKeyset/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,cAAc;IAOlC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,WAAW,CAC5C,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,EAChC,IAAI,EACJ,CAAC,SAAS,EAAE,SAAS,CAAC,CACvB,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE/D,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,WAAW,CAC9C,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EACtC,IAAI,EACJ,CAAC,MAAM,EAAE,QAAQ,CAAC,CACnB,CAAC;IACF,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CACnD,KAAK,EACL,QAAQ,CAAC,SAAS,CACnB,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAE7E,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,WAAW,CAC9C;QACE,IAAI,EAAE,UAAU;QAChB,aAAa,EAAE,IAAI;QACnB,cAAc,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACzC,IAAI,EAAE,SAAS;KAChB,EACD,IAAI,EACJ,CAAC,SAAS,EAAE,WAAW,CAAC,CACzB,CAAC;IACF,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC7E,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CACjD,KAAK,EACL,QAAQ,CAAC,UAAU,CACpB,CAAC;IAEF,OAAO;QACL,SAAS;QACT,eAAe;QACf,UAAU;QACV,WAAW;QACX,aAAa;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { generateKeyset } from "./generateKeyset/index.js";
2
+ import { CipherAgent } from "./CipherAgent/class.js";
3
+ import { SigningAgent } from "./SigningAgent/class.js";
4
+ import { VerificationAgent } from "./VerificationAgent/class.js";
5
+ import { CipherCluster } from "./CipherCluster/class.js";
6
+ import { SigningCluster } from "./SigningCluster/class.js";
7
+ import { VerificationCluster } from "./VerificationCluster/class.js";
8
+ import { WrappingAgent } from "./WrappingAgent/class.js";
9
+ import { WrappingCluster } from "./WrappingCluster/class.js";
10
+ import { UnwrappingAgent } from "./UnwrappingAgent/class.js";
11
+ import { UnwrappingCluster } from "./UnwrappingCluster/class.js";
12
+ export { generateKeyset, CipherAgent, SigningAgent, VerificationAgent, WrappingAgent, UnwrappingAgent, CipherCluster, SigningCluster, VerificationCluster, WrappingCluster, UnwrappingCluster, };
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,iBAAiB,GAClB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ import { generateKeyset } from "./generateKeyset/index.js";
2
+ import { CipherAgent } from "./CipherAgent/class.js";
3
+ import { SigningAgent } from "./SigningAgent/class.js";
4
+ import { VerificationAgent } from "./VerificationAgent/class.js";
5
+ import { CipherCluster } from "./CipherCluster/class.js";
6
+ import { SigningCluster } from "./SigningCluster/class.js";
7
+ import { VerificationCluster } from "./VerificationCluster/class.js";
8
+ import { WrappingAgent } from "./WrappingAgent/class.js";
9
+ import { WrappingCluster } from "./WrappingCluster/class.js";
10
+ import { UnwrappingAgent } from "./UnwrappingAgent/class.js";
11
+ import { UnwrappingCluster } from "./UnwrappingCluster/class.js";
12
+ export { generateKeyset, CipherAgent, SigningAgent, VerificationAgent, WrappingAgent, UnwrappingAgent, CipherCluster, SigningCluster, VerificationCluster, WrappingCluster, UnwrappingCluster, };
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,iBAAiB,GAClB,CAAC"}
package/package.json CHANGED
@@ -1,27 +1,32 @@
1
1
  {
2
2
  "name": "zeyra",
3
- "version": "1.1.0",
4
- "description": "Managed WebCrypto helpers for AES-GCM + ECDSA JWK keysets with storage-ready cluster APIs.",
3
+ "version": "2.0.0",
4
+ "description": "Client-side WebCrypto helpers for AES-GCM encryption, ECDSA signatures, and RSA-OAEP key wrapping.",
5
5
  "keywords": [
6
6
  "webcrypto",
7
7
  "aes-gcm",
8
8
  "ecdsa",
9
+ "rsa-oaep",
9
10
  "jwk",
10
11
  "encryption",
11
12
  "signature",
13
+ "key-wrapping",
14
+ "wrapping",
15
+ "unwrapping",
12
16
  "cluster",
13
17
  "keyset",
14
- "base64url",
15
18
  "compression",
16
- "storage",
17
- "transport"
19
+ "bytecodec",
20
+ "typescript"
18
21
  ],
19
22
  "license": "MIT",
20
23
  "type": "module",
21
- "main": "src/index.js",
24
+ "main": "dist/index.js",
25
+ "types": "dist/index.d.ts",
22
26
  "scripts": {
23
- "test": "node --test test.js && node test.js --bench",
24
- "bench": "node test.js --bench",
27
+ "build": "tsc -p tsconfig.json",
28
+ "test": "npm run build && node --test test.js && node test.js --bench",
29
+ "bench": "npm run build && node test.js --bench",
25
30
  "prepublishOnly": "npm test"
26
31
  },
27
32
  "repository": {
@@ -33,19 +38,23 @@
33
38
  },
34
39
  "homepage": "https://github.com/jortsupetterson/zeyra#readme",
35
40
  "dependencies": {
36
- "bytecodec": "^1.3.0"
41
+ "bytecodec": "^2.0.0"
42
+ },
43
+ "devDependencies": {
44
+ "typescript": "^5.5.4"
37
45
  },
38
46
  "engines": {
39
47
  "node": ">=18"
40
48
  },
41
49
  "exports": {
42
50
  ".": {
43
- "import": "./src/index.js"
51
+ "types": "./dist/index.d.ts",
52
+ "import": "./dist/index.js"
44
53
  },
45
54
  "./package.json": "./package.json"
46
55
  },
47
56
  "files": [
48
- "src",
57
+ "dist",
49
58
  "LICENSE",
50
59
  "README.md"
51
60
  ],
@@ -1,43 +0,0 @@
1
- export class CipherAgent {
2
- /**
3
- * @param {JsonWebKey} symmetricJwk // AES-GCM (kty:"oct", alg:"A256GCM")
4
- */
5
- constructor(symmetricJwk) {
6
- this.keyPromise = crypto.subtle.importKey(
7
- "jwk",
8
- symmetricJwk,
9
- { name: "AES-GCM" },
10
- false,
11
- ["encrypt", "decrypt"]
12
- );
13
- }
14
-
15
- /**
16
- * @param {Uint8Array} plaintext
17
- * @returns {Promise<{ iv: Uint8Array, ciphertext: ArrayBuffer }>}
18
- */
19
- async encrypt(plaintext) {
20
- const key = await this.keyPromise;
21
- const iv = crypto.getRandomValues(new Uint8Array(12));
22
- const ciphertext = await crypto.subtle.encrypt(
23
- { name: "AES-GCM", iv },
24
- key,
25
- plaintext
26
- );
27
- return { iv, ciphertext };
28
- }
29
-
30
- /**
31
- * @param {{ iv: Uint8Array, ciphertext: ArrayBuffer }} payload
32
- * @returns {Promise<Uint8Array>}
33
- */
34
- async decrypt({ iv, ciphertext }) {
35
- const key = await this.keyPromise;
36
- const plaintext = await crypto.subtle.decrypt(
37
- { name: "AES-GCM", iv },
38
- key,
39
- ciphertext
40
- );
41
- return new Uint8Array(plaintext);
42
- }
43
- }
@@ -1,57 +0,0 @@
1
- import { Bytes } from "bytecodec";
2
- import { CipherAgent } from "../CipherAgent/class.js";
3
-
4
- export class CipherCluster {
5
- /** @type {WeakMap<JsonWebKey, WeakRef<CipherAgent>>} */
6
- static #agents = new WeakMap();
7
-
8
- /**
9
- * @param {JsonWebKey} symmetricJwk
10
- * @returns {CipherAgent}
11
- */
12
- static #loadAgent(symmetricJwk) {
13
- const weakRef = CipherCluster.#agents.get(symmetricJwk);
14
- /** @type {CipherAgent | undefined} */
15
- let agent = weakRef?.deref();
16
- if (!agent) {
17
- agent = new CipherAgent(symmetricJwk);
18
- CipherCluster.#agents.set(symmetricJwk, new WeakRef(agent));
19
- }
20
- return agent;
21
- }
22
-
23
- /**
24
- * @param {JsonWebKey} symmetricJwk
25
- * @param {any} resource
26
- * @returns {Promise<{ digest: Base64URLString, ciphertext: Base64URLString, iv: Base64URLString }>}
27
- */
28
- static async encrypt(symmetricJwk, resource) {
29
- const agent = CipherCluster.#loadAgent(symmetricJwk);
30
- const bytes = Bytes.fromJSON(resource);
31
- const digest = await crypto.subtle.digest("SHA-256", bytes);
32
- const compressed = await Bytes.toCompressed(bytes);
33
- const envelope = await agent.encrypt(compressed);
34
- return {
35
- digest: Bytes.toBase64UrlString(digest),
36
- ciphertext: Bytes.toBase64UrlString(envelope.ciphertext),
37
- iv: Bytes.toBase64UrlString(envelope.iv),
38
- };
39
- }
40
-
41
- /**
42
- * @param {JsonWebKey} symmetricJwk
43
- * @param {{ digest: Base64URLString, ciphertext: Base64URLString, iv: Base64URLString }} artifact
44
- * @returns {Promise<any>}
45
- */
46
- static async decrypt(symmetricJwk, artifact) {
47
- const envelope = {
48
- ciphertext: Bytes.fromBase64UrlString(artifact.ciphertext),
49
- iv: Bytes.fromBase64UrlString(artifact.iv),
50
- };
51
- const agent = CipherCluster.#loadAgent(symmetricJwk);
52
- const bytes = await agent.decrypt(envelope);
53
- const decompressed = await Bytes.fromCompressed(bytes);
54
- const resource = Bytes.toJSON(decompressed);
55
- return { digest: artifact.digest, ...resource };
56
- }
57
- }
@@ -1,23 +0,0 @@
1
- export class SigningAgent {
2
- /**
3
- * @param {JsonWebKey} privateJwk // ECDSA P-256 private key
4
- */
5
- constructor(privateJwk) {
6
- this.keyPromise = crypto.subtle.importKey(
7
- "jwk",
8
- privateJwk,
9
- { name: "ECDSA", namedCurve: "P-256" },
10
- false,
11
- ["sign"]
12
- );
13
- }
14
-
15
- /**
16
- * @param {Uint8Array} bytes
17
- * @returns {Promise<ArrayBuffer>}
18
- */
19
- async sign(bytes) {
20
- const key = await this.keyPromise;
21
- return crypto.subtle.sign({ name: "ECDSA", hash: "SHA-256" }, key, bytes);
22
- }
23
- }
@@ -1,34 +0,0 @@
1
- import { Bytes } from "bytecodec";
2
- import { SigningAgent } from "../SigningAgent/class.js";
3
-
4
- export class SigningCluster {
5
- /** @type {WeakMap<JsonWebKey, WeakRef<SigningAgent>>} */
6
- static #agents = new WeakMap();
7
-
8
- /**
9
- * @param {JsonWebKey} privateJwk
10
- * @returns {SigningAgent}
11
- */
12
- static #loadAgent(privateJwk) {
13
- const weakRef = SigningCluster.#agents.get(privateJwk);
14
- /** @type {SigningAgent | undefined} */
15
- let agent = weakRef?.deref();
16
- if (!agent) {
17
- agent = new SigningAgent(privateJwk);
18
- SigningCluster.#agents.set(privateJwk, new WeakRef(agent));
19
- }
20
- return agent;
21
- }
22
-
23
- /**
24
- * @param {JsonWebKey} privateJwk
25
- * @param {any} value
26
- * @returns {Promise<Base64URLString>}
27
- */
28
- static async sign(privateJwk, value) {
29
- const agent = SigningCluster.#loadAgent(privateJwk);
30
- const bytes = Bytes.fromJSON(value);
31
- const signature = await agent.sign(bytes);
32
- return Bytes.toBase64UrlString(signature);
33
- }
34
- }
@@ -1,29 +0,0 @@
1
- export class VerificationAgent {
2
- /**
3
- * @param {JsonWebKey} publicJwk // ECDSA P-256 public key
4
- */
5
- constructor(publicJwk) {
6
- this.keyPromise = crypto.subtle.importKey(
7
- "jwk",
8
- publicJwk,
9
- { name: "ECDSA", namedCurve: "P-256" },
10
- false,
11
- ["verify"]
12
- );
13
- }
14
-
15
- /**
16
- * @param {Uint8Array} bytes
17
- * @param {ArrayBuffer} signature
18
- * @returns {Promise<boolean>}
19
- */
20
- async verify(bytes, signature) {
21
- const key = await this.keyPromise;
22
- return crypto.subtle.verify(
23
- { name: "ECDSA", hash: "SHA-256" },
24
- key,
25
- signature,
26
- bytes
27
- );
28
- }
29
- }
@@ -1,35 +0,0 @@
1
- import { Bytes } from "bytecodec";
2
- import { VerificationAgent } from "../VerificationAgent/class.js";
3
-
4
- export class VerificationCluster {
5
- /** @type {WeakMap<JsonWebKey, WeakRef<VerificationAgent>>} */
6
- static #agents = new WeakMap();
7
-
8
- /**
9
- * @param {JsonWebKey} publicJwk
10
- * @returns {VerificationAgent}
11
- */
12
- static #loadAgent(publicJwk) {
13
- const weakRef = VerificationCluster.#agents.get(publicJwk);
14
- /** @type {VerificationAgent | undefined} */
15
- let agent = weakRef?.deref();
16
- if (!agent) {
17
- agent = new VerificationAgent(publicJwk);
18
- VerificationCluster.#agents.set(publicJwk, new WeakRef(agent));
19
- }
20
- return agent;
21
- }
22
-
23
- /**
24
- * @param {JsonWebKey} publicJwk
25
- * @param {any} value
26
- * @param {Base64URLString} signature
27
- * @returns {Promise<boolean>}
28
- */
29
- static async verify(publicJwk, value, signature) {
30
- const agent = VerificationCluster.#loadAgent(publicJwk);
31
- const valueBytes = Bytes.fromJSON(value);
32
- const signatureBytes = Bytes.fromBase64UrlString(signature);
33
- return await agent.verify(valueBytes, signatureBytes);
34
- }
35
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * Generates a cryptographic keyset for a single resource.
3
- *
4
- * Returned keys:
5
- * - symmetricJwk: AES-GCM 256-bit key (JWK, kty:"oct") for encrypt/decrypt
6
- * - publicJwk: ECDSA P-256 public key (JWK) for verify
7
- * - privateJwk: ECDSA P-256 private key (JWK) for sign
8
- *
9
- * All keys are extractable and intended to be stored encrypted
10
- * or transported as data. Type definitions are expected to live
11
- * in a separate TypeScript types file.
12
- *
13
- * @returns {Promise<{
14
- * symmetricJwk: JsonWebKey,
15
- * publicJwk: JsonWebKey,
16
- * privateJwk: JsonWebKey
17
- * }>}
18
- */
19
- export async function generateKeyset() {
20
- const aesKey = await crypto.subtle.generateKey(
21
- { name: "AES-GCM", length: 256 },
22
- true,
23
- ["encrypt", "decrypt"]
24
- );
25
- const symmetricJwk = await crypto.subtle.exportKey("jwk", aesKey);
26
-
27
- const keyPair = await crypto.subtle.generateKey(
28
- { name: "ECDSA", namedCurve: "P-256" },
29
- true,
30
- ["sign", "verify"]
31
- );
32
- const publicJwk = await crypto.subtle.exportKey("jwk", keyPair.publicKey);
33
- const privateJwk = await crypto.subtle.exportKey("jwk", keyPair.privateKey);
34
-
35
- return { symmetricJwk, publicJwk, privateJwk };
36
- }
package/src/index.js DELETED
@@ -1,16 +0,0 @@
1
- import { generateKeyset } from "./generateKeyset/index.js";
2
- import { CipherAgent } from "./CipherAgent/class.js";
3
- import { SigningAgent } from "./SigningAgent/class.js";
4
- import { VerificationAgent } from "./VerificationAgent/class.js";
5
- import { CipherCluster } from "./CipherCluster/class.js";
6
- import { SigningCluster } from "./SigningCluster/class.js";
7
- import { VerificationCluster } from "./VerificationCluster/class.js";
8
- export {
9
- generateKeyset,
10
- CipherAgent,
11
- SigningAgent,
12
- VerificationAgent,
13
- CipherCluster,
14
- SigningCluster,
15
- VerificationCluster,
16
- };