dataspace-client-sdk-node 0.2.2 → 0.2.3

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 (30) hide show
  1. package/README.md +12 -14
  2. package/package.json +1 -1
  3. package/TODO_PROMPT_NEXT_STEPS.md +0 -185
  4. package/artifacts/update-smart-wallet.js +0 -1016
  5. package/dist/builders.d.ts +0 -12
  6. package/dist/builders.js +0 -17
  7. package/dist/client.d.ts +0 -453
  8. package/dist/client.js +0 -1755
  9. package/dist/consent/pdfSignatureVerification.d.ts +0 -18
  10. package/dist/consent/pdfSignatureVerification.js +0 -23
  11. package/dist/index.d.ts +0 -5
  12. package/dist/index.js +0 -9
  13. package/dist/sdk/dataspace-wallet-sdk-node/MultiWalletClient.d.ts +0 -9
  14. package/dist/sdk/dataspace-wallet-sdk-node/MultiWalletClient.js +0 -21
  15. package/dist/sdk/dataspace-wallet-sdk-node/WalletClient.d.ts +0 -26
  16. package/dist/sdk/dataspace-wallet-sdk-node/WalletClient.js +0 -36
  17. package/dist/sdk/dataspace-wallet-sdk-node/index.d.ts +0 -6
  18. package/dist/sdk/dataspace-wallet-sdk-node/index.js +0 -6
  19. package/dist/sdk/dataspace-wallet-sdk-node/provider.d.ts +0 -24
  20. package/dist/sdk/dataspace-wallet-sdk-node/provider.js +0 -1
  21. package/dist/sdk/dataspace-wallet-sdk-node/providers/memory-provider.d.ts +0 -41
  22. package/dist/sdk/dataspace-wallet-sdk-node/providers/memory-provider.js +0 -216
  23. package/dist/sdk/dataspace-wallet-sdk-node/providers/seed-provider.d.ts +0 -22
  24. package/dist/sdk/dataspace-wallet-sdk-node/providers/seed-provider.js +0 -28
  25. package/dist/sdk/dataspace-wallet-sdk-node/types.d.ts +0 -51
  26. package/dist/sdk/dataspace-wallet-sdk-node/types.js +0 -1
  27. package/dist/types.d.ts +0 -556
  28. package/dist/types.js +0 -1
  29. package/dist/vp-token.d.ts +0 -37
  30. package/dist/vp-token.js +0 -56
@@ -1,18 +0,0 @@
1
- export interface PdfVerifySubmission {
2
- pdf_buffer: Buffer;
3
- content_type: string;
4
- }
5
- export interface PdfVerifyResult {
6
- ok: boolean;
7
- signer?: string;
8
- signing_time?: string;
9
- notes?: string[];
10
- }
11
- export interface PdfSignatureVerificationApi {
12
- verifyPdfSignature(submission: PdfVerifySubmission): Promise<PdfVerifyResult>;
13
- }
14
- export declare class PdfSignatureVerificationHttpApi implements PdfSignatureVerificationApi {
15
- private readonly endpoint;
16
- constructor(endpoint: string);
17
- verifyPdfSignature(submission: PdfVerifySubmission): Promise<PdfVerifyResult>;
18
- }
@@ -1,23 +0,0 @@
1
- // pdfSignatureVerification.ts
2
- // Node.js SDK contract for PDF signature verification
3
- import fetch from 'node-fetch';
4
- export class PdfSignatureVerificationHttpApi {
5
- endpoint;
6
- constructor(endpoint) {
7
- this.endpoint = endpoint;
8
- }
9
- async verifyPdfSignature(submission) {
10
- const res = await fetch(this.endpoint, {
11
- method: 'POST',
12
- headers: { 'Content-Type': 'application/pdf' },
13
- body: submission.pdf_buffer,
14
- });
15
- if (!res.ok)
16
- throw new Error('PDF verification failed: ' + res.status);
17
- return (await res.json());
18
- }
19
- }
20
- // Usage (Node):
21
- // const api = new PdfSignatureVerificationHttpApi('https://api.example.com/verify-pdf');
22
- // const result = await api.verifyPdfSignature({ pdf_buffer, content_type: 'application/pdf' });
23
- // if (result.ok) { ... }
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './types.js';
2
- export * from './builders.js';
3
- export * from './vp-token.js';
4
- export * from './client.js';
5
- export * from './sdk/dataspace-wallet-sdk-node/index.js';
package/dist/index.js DELETED
@@ -1,9 +0,0 @@
1
- // TODO: AdapterCryptoSdkNode and other cryptography adapters should be re-exported here
2
- // to allow external consumers (tests, services) to import them from the SDK directly.
3
- // For now, consumers must import from gdc-common-utils-ts/adapters/node/crypto directly.
4
- // See subjectVaultPhoneResolution.test.ts for context and migration plan.
5
- export * from './types.js';
6
- export * from './builders.js';
7
- export * from './vp-token.js';
8
- export * from './client.js';
9
- export * from './sdk/dataspace-wallet-sdk-node/index.js';
@@ -1,9 +0,0 @@
1
- import type { WalletProvider } from './provider.js';
2
- import type { WalletContext } from './types.js';
3
- import { WalletClient } from './WalletClient.js';
4
- export declare class MultiWalletClient {
5
- private readonly provider;
6
- private readonly walletClients;
7
- constructor(provider: WalletProvider);
8
- forContext(context: WalletContext): WalletClient;
9
- }
@@ -1,21 +0,0 @@
1
- import { WalletClient } from './WalletClient.js';
2
- function contextKey(context) {
3
- return [context.tenantId, context.jurisdiction, context.sector, context.walletId ?? 'default'].join(':');
4
- }
5
- export class MultiWalletClient {
6
- provider;
7
- walletClients = new Map();
8
- constructor(provider) {
9
- this.provider = provider;
10
- }
11
- forContext(context) {
12
- const key = contextKey(context);
13
- const existing = this.walletClients.get(key);
14
- if (existing) {
15
- return existing;
16
- }
17
- const created = new WalletClient(this.provider, context);
18
- this.walletClients.set(key, created);
19
- return created;
20
- }
21
- }
@@ -1,26 +0,0 @@
1
- import type { WalletProvider } from './provider.js';
2
- import type { CompactJwsHeader, DecryptOptions, EncryptOptions, PublicJwk, SignOptions, VerifyOptions, WalletContext } from './types.js';
3
- export declare class WalletClient {
4
- private readonly provider;
5
- private readonly context;
6
- constructor(provider: WalletProvider, context: WalletContext);
7
- getPublicJwks(): Promise<PublicJwk[]>;
8
- sign(payload: Uint8Array | string, options?: SignOptions): Promise<string>;
9
- verify(payload: Uint8Array | string, signature: string, jwk: PublicJwk, options?: VerifyOptions): Promise<boolean>;
10
- signCompactJws(params: {
11
- header: CompactJwsHeader;
12
- claims: Record<string, unknown>;
13
- }): Promise<string>;
14
- signDetachedJws(params: {
15
- header: CompactJwsHeader;
16
- payload: Uint8Array | string;
17
- }): Promise<string>;
18
- buildCompactJwe(params: {
19
- plaintext: Uint8Array | string;
20
- recipientJwk: PublicJwk;
21
- contentType?: string;
22
- }): Promise<string>;
23
- decryptCompactJwe(jwe: string): Promise<Uint8Array>;
24
- encrypt(plaintext: Uint8Array | string, recipientJwk: PublicJwk, options?: EncryptOptions): Promise<string>;
25
- decrypt(ciphertext: string, options?: DecryptOptions): Promise<Uint8Array>;
26
- }
@@ -1,36 +0,0 @@
1
- // CompactJweHeader is used transitively through WalletProvider
2
- export class WalletClient {
3
- provider;
4
- context;
5
- constructor(provider, context) {
6
- this.provider = provider;
7
- this.context = context;
8
- }
9
- getPublicJwks() {
10
- return this.provider.getPublicJwks(this.context);
11
- }
12
- sign(payload, options) {
13
- return this.provider.sign(payload, this.context, options);
14
- }
15
- verify(payload, signature, jwk, options) {
16
- return this.provider.verify(payload, signature, jwk, options);
17
- }
18
- signCompactJws(params) {
19
- return this.provider.signCompactJws(this.context, params);
20
- }
21
- signDetachedJws(params) {
22
- return this.provider.signDetachedJws(this.context, params);
23
- }
24
- buildCompactJwe(params) {
25
- return this.provider.buildCompactJwe(this.context, params);
26
- }
27
- decryptCompactJwe(jwe) {
28
- return this.provider.decryptCompactJwe(jwe, this.context);
29
- }
30
- encrypt(plaintext, recipientJwk, options) {
31
- return this.provider.encrypt(plaintext, recipientJwk, options);
32
- }
33
- decrypt(ciphertext, options) {
34
- return this.provider.decrypt(ciphertext, this.context, options);
35
- }
36
- }
@@ -1,6 +0,0 @@
1
- export * from './types.js';
2
- export * from './provider.js';
3
- export * from './WalletClient.js';
4
- export * from './MultiWalletClient.js';
5
- export * from './providers/memory-provider.js';
6
- export * from './providers/seed-provider.js';
@@ -1,6 +0,0 @@
1
- export * from './types.js';
2
- export * from './provider.js';
3
- export * from './WalletClient.js';
4
- export * from './MultiWalletClient.js';
5
- export * from './providers/memory-provider.js';
6
- export * from './providers/seed-provider.js';
@@ -1,24 +0,0 @@
1
- import type { CompactJwsHeader, DecryptOptions, EncryptOptions, PublicJwk, SignOptions, VerifyOptions, WalletContext, WalletInitOptions, WalletProviderKind } from './types.js';
2
- export interface WalletProvider {
3
- readonly kind: WalletProviderKind;
4
- init?(options?: WalletInitOptions): Promise<void> | void;
5
- getPublicJwks(context: WalletContext): Promise<PublicJwk[]>;
6
- sign(payload: Uint8Array | string, context: WalletContext, options?: SignOptions): Promise<string>;
7
- verify(payload: Uint8Array | string, signature: string, jwk: PublicJwk, options?: VerifyOptions): Promise<boolean>;
8
- signCompactJws(context: WalletContext, params: {
9
- header: CompactJwsHeader;
10
- claims: Record<string, unknown>;
11
- }): Promise<string>;
12
- signDetachedJws(context: WalletContext, params: {
13
- header: CompactJwsHeader;
14
- payload: Uint8Array | string;
15
- }): Promise<string>;
16
- buildCompactJwe(context: WalletContext, params: {
17
- plaintext: Uint8Array | string;
18
- recipientJwk: PublicJwk;
19
- contentType?: string;
20
- }): Promise<string>;
21
- decryptCompactJwe(jwe: string, context: WalletContext): Promise<Uint8Array>;
22
- encrypt(plaintext: Uint8Array | string, recipientJwk: PublicJwk, options?: EncryptOptions): Promise<string>;
23
- decrypt(ciphertext: string, context: WalletContext, options?: DecryptOptions): Promise<Uint8Array>;
24
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,41 +0,0 @@
1
- import { type KeyObject } from 'node:crypto';
2
- import type { CompactJwsHeader, DecryptOptions, EncryptOptions, PrivateKeyRef, PublicJwk, SignOptions, VerifyOptions, WalletContext, WalletInitOptions, WalletProviderKind } from '../types.js';
3
- import type { WalletProvider } from '../provider.js';
4
- type StoredKeyPair = {
5
- signingPublicJwk: PublicJwk;
6
- signingPublicKey: KeyObject;
7
- signingPrivateKey: KeyObject;
8
- signingPrivateKeyRef: PrivateKeyRef;
9
- encryptionPublicJwk: PublicJwk;
10
- /** ML-KEM-768 secret key bytes (2400 bytes). Never exposed externally. */
11
- mlKemSecretKeyBytes: Uint8Array;
12
- encryptionPrivateKeyRef: PrivateKeyRef;
13
- };
14
- export declare class MemoryWalletProvider implements WalletProvider {
15
- readonly kind: WalletProviderKind;
16
- private readonly keysByContext;
17
- init(options?: WalletInitOptions): void;
18
- getPublicJwks(context: WalletContext): Promise<PublicJwk[]>;
19
- sign(payload: Uint8Array | string, context: WalletContext, options?: SignOptions): Promise<string>;
20
- verify(payload: Uint8Array | string, signature: string, jwk: PublicJwk, _options?: VerifyOptions): Promise<boolean>;
21
- signCompactJws(context: WalletContext, params: {
22
- header: CompactJwsHeader;
23
- claims: Record<string, unknown>;
24
- }): Promise<string>;
25
- encrypt(plaintext: Uint8Array | string, recipientJwk: PublicJwk, options?: EncryptOptions): Promise<string>;
26
- decrypt(ciphertext: string, context: WalletContext, options?: DecryptOptions): Promise<Uint8Array>;
27
- protected ensureKeyPair(context: WalletContext): StoredKeyPair;
28
- protected selectSigningKeyPair(context: WalletContext, keyId?: string): StoredKeyPair;
29
- protected selectEncryptionKeyPair(context: WalletContext, keyId?: string): StoredKeyPair;
30
- signDetachedJws(context: WalletContext, params: {
31
- header: CompactJwsHeader;
32
- payload: Uint8Array | string;
33
- }): Promise<string>;
34
- buildCompactJwe(context: WalletContext, params: {
35
- plaintext: Uint8Array | string;
36
- recipientJwk: PublicJwk;
37
- contentType?: string;
38
- }): Promise<string>;
39
- decryptCompactJwe(jwe: string, context: WalletContext): Promise<Uint8Array>;
40
- }
41
- export {};
@@ -1,216 +0,0 @@
1
- import { createCipheriv, createDecipheriv, createHash, createPublicKey, generateKeyPairSync, randomBytes, sign as cryptoSign, verify as cryptoVerify, } from 'node:crypto';
2
- import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';
3
- function contextKey(context) {
4
- return [context.tenantId, context.jurisdiction, context.sector, context.walletId ?? 'default'].join(':');
5
- }
6
- function normalizeBytes(input) {
7
- return typeof input === 'string' ? Buffer.from(input, 'utf8') : input;
8
- }
9
- function toBase64Url(buffer) {
10
- return Buffer.from(buffer).toString('base64url');
11
- }
12
- function fromBase64Url(value) {
13
- return Buffer.from(value, 'base64url');
14
- }
15
- function encodeJsonBase64Url(value) {
16
- return toBase64Url(Buffer.from(JSON.stringify(value), 'utf8'));
17
- }
18
- function buildKid(context, jwk) {
19
- const thumbprint = createHash('sha256')
20
- .update(JSON.stringify({
21
- crv: jwk.crv,
22
- e: jwk.e,
23
- kty: jwk.kty,
24
- n: jwk.n,
25
- x: jwk.x,
26
- y: jwk.y,
27
- }))
28
- .digest('base64url')
29
- .slice(0, 16);
30
- return `wallet:${context.tenantId}:${context.jurisdiction}:${context.sector}:${thumbprint}`;
31
- }
32
- function buildPrivateKeyRef(kid, algorithm) {
33
- return {
34
- kid,
35
- kind: 'managed',
36
- algorithm,
37
- };
38
- }
39
- function buildSigningKeyPair(context) {
40
- const generated = generateKeyPairSync('ec', {
41
- namedCurve: 'secp384r1',
42
- });
43
- const publicJwk = generated.publicKey.export({ format: 'jwk' });
44
- const kid = buildKid(context, publicJwk);
45
- const normalizedPublicJwk = {
46
- ...publicJwk,
47
- kid,
48
- alg: 'ES384',
49
- use: 'sig',
50
- key_ops: ['verify'],
51
- };
52
- return {
53
- publicJwk: normalizedPublicJwk,
54
- publicKey: createPublicKey({ key: normalizedPublicJwk, format: 'jwk' }),
55
- privateKey: generated.privateKey,
56
- privateKeyRef: buildPrivateKeyRef(kid, 'ES384'),
57
- };
58
- }
59
- /** Generate a ML-KEM-768 key pair for content-key encapsulation (JWE `encrypted_key`). */
60
- function buildMlKemEncryptionKeyPair(context) {
61
- const seed = randomBytes(64);
62
- const { publicKey: publicKeyBytes, secretKey: secretKeyBytes } = ml_kem768.keygen(seed);
63
- const x = toBase64Url(publicKeyBytes);
64
- const kid = createHash('sha256')
65
- .update(JSON.stringify({ crv: 'ML-KEM-768', kty: 'OKP', x }))
66
- .digest('base64url')
67
- .slice(0, 16);
68
- const fullKid = `wallet:${context.tenantId}:${context.jurisdiction}:${context.sector}:${kid}`;
69
- const publicJwk = {
70
- kty: 'OKP',
71
- crv: 'ML-KEM-768',
72
- x,
73
- kid: fullKid,
74
- alg: 'ML-KEM-768',
75
- use: 'enc',
76
- key_ops: ['wrapKey'],
77
- };
78
- return {
79
- publicJwk,
80
- secretKeyBytes,
81
- privateKeyRef: buildPrivateKeyRef(fullKid, 'ML-KEM-768'),
82
- };
83
- }
84
- export class MemoryWalletProvider {
85
- kind = 'mem';
86
- keysByContext = new Map();
87
- init(options) {
88
- for (const context of options?.contexts ?? []) {
89
- this.ensureKeyPair(context);
90
- }
91
- }
92
- async getPublicJwks(context) {
93
- const pair = this.ensureKeyPair(context);
94
- return [pair.signingPublicJwk, pair.encryptionPublicJwk];
95
- }
96
- async sign(payload, context, options) {
97
- const pair = this.selectSigningKeyPair(context, options?.keyId);
98
- const signature = cryptoSign('sha384', normalizeBytes(payload), pair.signingPrivateKey);
99
- return toBase64Url(signature);
100
- }
101
- async verify(payload, signature, jwk, _options) {
102
- const publicKey = createPublicKey({ key: jwk, format: 'jwk' });
103
- return cryptoVerify('sha384', normalizeBytes(payload), publicKey, fromBase64Url(signature));
104
- }
105
- async signCompactJws(context, params) {
106
- const pair = this.selectSigningKeyPair(context, params.header.kid);
107
- const header = {
108
- ...params.header,
109
- alg: params.header.alg || 'ES384',
110
- kid: params.header.kid || pair.signingPublicJwk.kid,
111
- };
112
- const signingInput = `${encodeJsonBase64Url(header)}.${encodeJsonBase64Url(params.claims)}`;
113
- const signature = cryptoSign('sha384', Buffer.from(signingInput, 'ascii'), pair.signingPrivateKey);
114
- return `${signingInput}.${toBase64Url(signature)}`;
115
- }
116
- async encrypt(plaintext, recipientJwk, options) {
117
- // Delegate to buildCompactJwe; returns a compact JWE string.
118
- return this.buildCompactJwe(undefined, {
119
- plaintext,
120
- recipientJwk,
121
- });
122
- }
123
- async decrypt(ciphertext, context, options) {
124
- // ciphertext is a compact JWE produced by encrypt / buildCompactJwe.
125
- return this.decryptCompactJwe(ciphertext, context);
126
- }
127
- ensureKeyPair(context) {
128
- const key = contextKey(context);
129
- const existing = this.keysByContext.get(key);
130
- if (existing) {
131
- return existing;
132
- }
133
- const signingKeyPair = buildSigningKeyPair(context);
134
- const encryptionKeyPair = buildMlKemEncryptionKeyPair(context);
135
- const pair = {
136
- signingPublicJwk: signingKeyPair.publicJwk,
137
- signingPublicKey: signingKeyPair.publicKey,
138
- signingPrivateKey: signingKeyPair.privateKey,
139
- signingPrivateKeyRef: signingKeyPair.privateKeyRef,
140
- encryptionPublicJwk: encryptionKeyPair.publicJwk,
141
- mlKemSecretKeyBytes: encryptionKeyPair.secretKeyBytes,
142
- encryptionPrivateKeyRef: encryptionKeyPair.privateKeyRef,
143
- };
144
- this.keysByContext.set(key, pair);
145
- return pair;
146
- }
147
- selectSigningKeyPair(context, keyId) {
148
- const pair = this.ensureKeyPair(context);
149
- if (keyId && pair.signingPrivateKeyRef.kid !== keyId) {
150
- throw new Error(`Wallet key not found for kid: ${keyId}`);
151
- }
152
- return pair;
153
- }
154
- selectEncryptionKeyPair(context, keyId) {
155
- const pair = this.ensureKeyPair(context);
156
- if (keyId && pair.encryptionPrivateKeyRef.kid !== keyId) {
157
- throw new Error(`Wallet key not found for kid: ${keyId}`);
158
- }
159
- return pair;
160
- }
161
- async signDetachedJws(context, params) {
162
- const pair = this.selectSigningKeyPair(context, params.header.kid);
163
- const header = {
164
- ...params.header,
165
- alg: params.header.alg || 'ES384',
166
- kid: params.header.kid || pair.signingPublicJwk.kid,
167
- b64: false,
168
- crit: ['b64'],
169
- };
170
- const payloadBytes = normalizeBytes(params.payload);
171
- const encodedHeader = encodeJsonBase64Url(header);
172
- const signingInput = Buffer.concat([Buffer.from(`${encodedHeader}.`, 'ascii'), payloadBytes]);
173
- const signature = cryptoSign('sha384', signingInput, pair.signingPrivateKey);
174
- return `${encodedHeader}..${toBase64Url(signature)}`;
175
- }
176
- async buildCompactJwe(context, params) {
177
- const kid = params.recipientJwk.kid;
178
- const header = {
179
- alg: 'ML-KEM-768',
180
- enc: 'A256GCM',
181
- ...(params.contentType ? { cty: params.contentType } : {}),
182
- ...(kid ? { kid } : {}),
183
- };
184
- const encodedHeader = encodeJsonBase64Url(header);
185
- // ML-KEM-768: encapsulate derives a 32-byte CEK and produces a cipherText (1088 bytes)
186
- // that the recipient can decapsulate with their secret key.
187
- const publicKeyBytes = fromBase64Url(params.recipientJwk.x);
188
- const { cipherText: encapsulatedKey, sharedSecret: cek } = ml_kem768.encapsulate(publicKeyBytes);
189
- const iv = randomBytes(12);
190
- const cipher = createCipheriv('aes-256-gcm', cek, iv);
191
- cipher.setAAD(Buffer.from(encodedHeader, 'ascii'));
192
- const ciphertext = Buffer.concat([cipher.update(normalizeBytes(params.plaintext)), cipher.final()]);
193
- const authTag = cipher.getAuthTag();
194
- return [
195
- encodedHeader,
196
- toBase64Url(encapsulatedKey),
197
- toBase64Url(iv),
198
- toBase64Url(ciphertext),
199
- toBase64Url(authTag),
200
- ].join('.');
201
- }
202
- async decryptCompactJwe(jwe, context) {
203
- const parts = jwe.split('.');
204
- if (parts.length !== 5) {
205
- throw new Error('Invalid compact JWE: expected 5 parts.');
206
- }
207
- const [encodedHeader, encapsulatedKeyB64, ivB64, ciphertextB64, tagB64] = parts;
208
- const pair = this.selectEncryptionKeyPair(context);
209
- // Recover CEK by decapsulating the ML-KEM ciphertext with the secret key.
210
- const cek = ml_kem768.decapsulate(fromBase64Url(encapsulatedKeyB64), pair.mlKemSecretKeyBytes);
211
- const decipher = createDecipheriv('aes-256-gcm', cek, fromBase64Url(ivB64));
212
- decipher.setAAD(Buffer.from(encodedHeader, 'ascii'));
213
- decipher.setAuthTag(fromBase64Url(tagB64));
214
- return Buffer.concat([decipher.update(fromBase64Url(ciphertextB64)), decipher.final()]);
215
- }
216
- }
@@ -1,22 +0,0 @@
1
- import type { WalletContext } from '../types.js';
2
- import { MemoryWalletProvider } from './memory-provider.js';
3
- /**
4
- * Dev-only provider.
5
- *
6
- * It stabilizes wallet identity selection from a seed, but it is not intended
7
- * for production custody or HSM-backed key management.
8
- */
9
- export declare class SeedWalletProvider extends MemoryWalletProvider {
10
- private readonly seed;
11
- readonly kind: "seed";
12
- constructor(seed: string);
13
- protected ensureKeyPair(context: WalletContext): {
14
- signingPublicJwk: import("../types.js").PublicJwk;
15
- signingPublicKey: import("node:crypto").KeyObject;
16
- signingPrivateKey: import("node:crypto").KeyObject;
17
- signingPrivateKeyRef: import("../types.js").PrivateKeyRef;
18
- encryptionPublicJwk: import("../types.js").PublicJwk;
19
- mlKemSecretKeyBytes: Uint8Array;
20
- encryptionPrivateKeyRef: import("../types.js").PrivateKeyRef;
21
- };
22
- }
@@ -1,28 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import { MemoryWalletProvider } from './memory-provider.js';
3
- function stableWalletId(seed, context) {
4
- return createHash('sha256')
5
- .update(`${seed}:${context.tenantId}:${context.jurisdiction}:${context.sector}:${context.walletId ?? 'default'}`)
6
- .digest('base64url')
7
- .slice(0, 24);
8
- }
9
- /**
10
- * Dev-only provider.
11
- *
12
- * It stabilizes wallet identity selection from a seed, but it is not intended
13
- * for production custody or HSM-backed key management.
14
- */
15
- export class SeedWalletProvider extends MemoryWalletProvider {
16
- seed;
17
- kind = 'seed';
18
- constructor(seed) {
19
- super();
20
- this.seed = seed;
21
- }
22
- ensureKeyPair(context) {
23
- return super.ensureKeyPair({
24
- ...context,
25
- walletId: stableWalletId(this.seed, context),
26
- });
27
- }
28
- }
@@ -1,51 +0,0 @@
1
- export type WalletContext = {
2
- tenantId: string;
3
- jurisdiction: string;
4
- sector: string;
5
- walletId?: string;
6
- };
7
- export type PublicJwk = JsonWebKey & {
8
- kid?: string;
9
- alg?: string;
10
- use?: string;
11
- key_ops?: string[];
12
- };
13
- export type PrivateKeyRef = {
14
- kid: string;
15
- kind: 'managed';
16
- algorithm: 'ES384' | 'ML-KEM-768' | 'RSA-OAEP-256/RS256';
17
- };
18
- export type SignOptions = {
19
- keyId?: string;
20
- algorithm?: 'ES384' | 'RS256';
21
- };
22
- export type VerifyOptions = {
23
- algorithm?: 'ES384' | 'RS256';
24
- };
25
- export type EncryptOptions = {
26
- keyId?: string;
27
- /** Defaults to ML-KEM-768 when recipient JWK has kty:'OKP', crv:'ML-KEM-768'; falls back to RSA-OAEP-256 for legacy RSA JWKs. */
28
- algorithm?: 'ML-KEM-768' | 'RSA-OAEP-256';
29
- };
30
- export type DecryptOptions = {
31
- keyId?: string;
32
- algorithm?: 'RSA-OAEP-256';
33
- };
34
- export type WalletProviderKind = 'mem' | 'seed' | 'external';
35
- export type WalletInitOptions = {
36
- contexts?: WalletContext[];
37
- };
38
- export type CompactJwsHeader = {
39
- alg: string;
40
- typ?: string;
41
- kid?: string;
42
- [key: string]: unknown;
43
- };
44
- export type CompactJweHeader = {
45
- /** KEM algorithm. ML-KEM-768 (post-quantum) or RSA-OAEP-256 (legacy). */
46
- alg: 'ML-KEM-768' | 'RSA-OAEP-256' | string;
47
- enc: 'A256GCM' | 'A128GCM' | string;
48
- cty?: string;
49
- kid?: string;
50
- [key: string]: unknown;
51
- };
@@ -1 +0,0 @@
1
- export {};