@sd-jwt/core 0.20.1 → 0.21.0-alpha-20260916100413

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 (68) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +82 -80
  3. package/dist/index.cjs +1526 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +696 -0
  6. package/dist/index.d.mts +537 -527
  7. package/dist/index.mjs +1422 -1998
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +29 -49
  10. package/CHANGELOG.md +0 -39
  11. package/dist/index.d.ts +0 -686
  12. package/dist/index.js +0 -2100
  13. package/src/decode/decode.ts +0 -407
  14. package/src/decode/index.ts +0 -1
  15. package/src/decoy.ts +0 -15
  16. package/src/flattenJSON.ts +0 -99
  17. package/src/generalJSON.ts +0 -157
  18. package/src/index.ts +0 -1000
  19. package/src/jwt.ts +0 -286
  20. package/src/kbjwt.ts +0 -101
  21. package/src/present/index.ts +0 -1
  22. package/src/present/present.ts +0 -216
  23. package/src/sdjwt.ts +0 -384
  24. package/src/test/decode/decode.spec.ts +0 -197
  25. package/src/test/decoy.spec.ts +0 -30
  26. package/src/test/flattenJSON.spec.ts +0 -122
  27. package/src/test/generalJSON.spec.ts +0 -198
  28. package/src/test/index.spec.ts +0 -986
  29. package/src/test/jwt.spec.ts +0 -301
  30. package/src/test/kbjwt.spec.ts +0 -555
  31. package/src/test/pass.spec.ts +0 -7
  32. package/src/test/present/present.spec.ts +0 -305
  33. package/src/test/sdjwt.spec.ts +0 -384
  34. package/src/test/types/type.spec.ts +0 -88
  35. package/src/test/utils/base64url.spec.ts +0 -33
  36. package/src/test/utils/disclosure.spec.ts +0 -170
  37. package/src/test/utils/error.spec.ts +0 -15
  38. package/src/types/index.ts +0 -2
  39. package/src/types/type.ts +0 -270
  40. package/src/types/verification-error.ts +0 -55
  41. package/src/utils/base64url.ts +0 -6
  42. package/src/utils/disclosure.ts +0 -121
  43. package/src/utils/error.ts +0 -25
  44. package/src/utils/index.ts +0 -3
  45. package/src/utils/strict-json.ts +0 -17
  46. package/test/app-e2e.spec.ts +0 -292
  47. package/test/array_data_types.json +0 -31
  48. package/test/array_full_sd.json +0 -21
  49. package/test/array_in_sd.json +0 -13
  50. package/test/array_nested_in_plain.json +0 -29
  51. package/test/array_none_disclosed.json +0 -17
  52. package/test/array_of_nulls.json +0 -15
  53. package/test/array_of_objects.json +0 -65
  54. package/test/array_of_scalars.json +0 -19
  55. package/test/array_recursive_sd.json +0 -35
  56. package/test/array_recursive_sd_some_disclosed.json +0 -63
  57. package/test/complex.json +0 -43
  58. package/test/header_mod.json +0 -48
  59. package/test/json_serialization.json +0 -48
  60. package/test/key_binding.json +0 -48
  61. package/test/no_sd.json +0 -36
  62. package/test/object_data_types.json +0 -62
  63. package/test/recursions.json +0 -117
  64. package/test/rfc9901-audit-fixes.spec.ts +0 -252
  65. package/test/rfc9901-validation.spec.ts +0 -150
  66. package/test/tsconfig.json +0 -4
  67. package/tsconfig.json +0 -7
  68. package/vitest.config.mts +0 -4
package/dist/index.d.mts CHANGED
@@ -1,102 +1,100 @@
1
- export { base64UrlToUint8Array, base64urlDecode, base64urlEncode, uint8ArrayToBase64Url } from '@owf/identity-common';
2
-
3
- declare const SD_SEPARATOR = "~";
4
- declare const SD_LIST_KEY = "...";
5
- declare const SD_DIGEST = "_sd";
6
- declare const SD_DECOY = "_sd_decoy";
7
- declare const KB_JWT_TYP = "kb+jwt";
8
- type SDJWTCompact = string;
9
- type Base64urlString = string;
10
- type DisclosureData<T> = [string, string, T] | [string, T];
11
- declare const encodePathSegment: (segment: string) => string;
12
- declare const encodePath: (segments: string[]) => string;
13
- declare const IANA_HASH_ALGORITHMS: readonly ["sha-256", "sha-256-128", "sha-256-120", "sha-256-96", "sha-256-64", "sha-256-32", "sha-384", "sha-512", "sha3-224", "sha3-256", "sha3-384", "sha3-512", "blake2s-256", "blake2b-256", "blake2b-512", "k12-256", "k12-512"];
14
- type HashAlgorithm = (typeof IANA_HASH_ALGORITHMS)[number];
15
- declare const DEFAULT_SECURE_HASH_ALGORITHMS: readonly ["sha-256", "sha-384", "sha-512", "sha3-256", "sha3-384", "sha3-512", "blake2s-256", "blake2b-256", "blake2b-512", "k12-256", "k12-512"];
16
- type SDJWTConfig<T = unknown> = {
17
- omitTyp?: boolean;
18
- hasher?: Hasher;
19
- hashAlg?: HashAlgorithm;
20
- allowedDisclosureHashAlgorithms?: ReadonlyArray<HashAlgorithm>;
21
- saltGenerator?: SaltGenerator;
22
- signer?: Signer;
23
- signAlg?: string;
24
- verifier?: Verifier<T>;
25
- kbSigner?: Signer;
26
- kbSignAlg?: string;
27
- kbVerifier?: KbVerifier;
1
+ import { base64UrlToUint8Array, base64urlDecode, base64urlEncode, uint8ArrayToBase64Url } from "@owf/identity-common";
2
+ //#region src/types/type.d.ts
3
+ export declare const SD_SEPARATOR = "~";
4
+ export declare const SD_LIST_KEY = "...";
5
+ export declare const SD_DIGEST = "_sd";
6
+ export declare const SD_DECOY = "_sd_decoy";
7
+ export declare const KB_JWT_TYP = "kb+jwt";
8
+ export type SDJWTCompact = string;
9
+ export type Base64urlString = string;
10
+ export type DisclosureData<T> = [string, string, T] | [string, T];
11
+ export declare const encodePathSegment: (segment: string) => string;
12
+ export declare const encodePath: (segments: string[]) => string;
13
+ export declare const IANA_HASH_ALGORITHMS: readonly ["sha-256", "sha-256-128", "sha-256-120", "sha-256-96", "sha-256-64", "sha-256-32", "sha-384", "sha-512", "sha3-224", "sha3-256", "sha3-384", "sha3-512", "blake2s-256", "blake2b-256", "blake2b-512", "k12-256", "k12-512"];
14
+ export type HashAlgorithm = (typeof IANA_HASH_ALGORITHMS)[number];
15
+ export declare const DEFAULT_SECURE_HASH_ALGORITHMS: readonly ["sha-256", "sha-384", "sha-512", "sha3-256", "sha3-384", "sha3-512", "blake2s-256", "blake2b-256", "blake2b-512", "k12-256", "k12-512"];
16
+ export type SDJWTConfig<T = unknown> = {
17
+ omitTyp?: boolean;
18
+ hasher?: Hasher;
19
+ hashAlg?: HashAlgorithm;
20
+ allowedDisclosureHashAlgorithms?: ReadonlyArray<HashAlgorithm>;
21
+ saltGenerator?: SaltGenerator;
22
+ signer?: Signer;
23
+ signAlg?: string;
24
+ verifier?: Verifier<T>;
25
+ kbSigner?: Signer;
26
+ kbSignAlg?: string;
27
+ kbVerifier?: KbVerifier;
28
28
  };
29
- type kbHeader = {
30
- typ: 'kb+jwt';
31
- alg: string;
29
+ export type kbHeader = {
30
+ typ: 'kb+jwt';
31
+ alg: string;
32
32
  };
33
- type kbPayload = {
34
- iat: number;
35
- aud: string;
36
- nonce: string;
37
- sd_hash: string;
33
+ export type kbPayload = {
34
+ iat: number;
35
+ aud: string;
36
+ nonce: string;
37
+ sd_hash: string;
38
38
  };
39
- type KBOptions = {
40
- payload: Omit<kbPayload, 'sd_hash'>;
39
+ export type KBOptions = {
40
+ payload: Omit<kbPayload, 'sd_hash'>;
41
41
  };
42
42
  interface RsaOtherPrimesInfo {
43
- d?: string;
44
- r?: string;
45
- t?: string;
43
+ d?: string;
44
+ r?: string;
45
+ t?: string;
46
46
  }
47
47
  interface JsonWebKey {
48
- alg?: string;
49
- crv?: string;
50
- d?: string;
51
- dp?: string;
52
- dq?: string;
53
- e?: string;
54
- ext?: boolean;
55
- k?: string;
56
- key_ops?: string[];
57
- kty?: string;
58
- n?: string;
59
- oth?: RsaOtherPrimesInfo[];
60
- p?: string;
61
- q?: string;
62
- qi?: string;
63
- use?: string;
64
- x?: string;
65
- y?: string;
48
+ alg?: string;
49
+ crv?: string;
50
+ d?: string;
51
+ dp?: string;
52
+ dq?: string;
53
+ e?: string;
54
+ ext?: boolean;
55
+ k?: string;
56
+ key_ops?: string[];
57
+ kty?: string;
58
+ n?: string;
59
+ oth?: RsaOtherPrimesInfo[];
60
+ p?: string;
61
+ q?: string;
62
+ qi?: string;
63
+ use?: string;
64
+ x?: string;
65
+ y?: string;
66
66
  }
67
- interface JwtPayload {
68
- cnf?: {
69
- jwk: JsonWebKey;
70
- };
71
- exp?: number;
72
- [key: string]: unknown;
67
+ export interface JwtPayload {
68
+ cnf?: {
69
+ jwk: JsonWebKey;
70
+ };
71
+ exp?: number;
72
+ [key: string]: unknown;
73
73
  }
74
- type OrPromise<T> = T | Promise<T>;
75
- type Signer = (data: string) => OrPromise<string>;
76
- type Verifier<T = unknown> = (data: string, sig: string, options?: T) => OrPromise<boolean>;
77
- type KbVerifier = (data: string, sig: string, payload: JwtPayload) => OrPromise<boolean>;
78
- type Hasher = (data: string | ArrayBuffer, alg: string) => OrPromise<Uint8Array>;
79
- type SaltGenerator = (length: number) => OrPromise<string>;
80
- type HasherAndAlg = {
81
- hasher: Hasher;
82
- alg: string;
74
+ export type OrPromise<T> = T | Promise<T>;
75
+ export type Signer = (data: string) => OrPromise<string>;
76
+ export type Verifier<T = unknown> = (data: string, sig: string, options?: T) => OrPromise<boolean>;
77
+ export type KbVerifier = (data: string, sig: string, payload: JwtPayload) => OrPromise<boolean>;
78
+ export type Hasher = (data: string | ArrayBuffer, alg: string) => OrPromise<Uint8Array>;
79
+ export type SaltGenerator = (length: number) => OrPromise<string>;
80
+ export type HasherAndAlg = {
81
+ hasher: Hasher;
82
+ alg: string;
83
83
  };
84
- type SignerSync = (data: string) => string;
85
- type VerifierSync = (data: string, sig: string) => boolean;
86
- type HasherSync = (data: string, alg: string) => Uint8Array;
87
- type SaltGeneratorSync = (length: number) => string;
88
- type HasherAndAlgSync = {
89
- hasher: HasherSync;
90
- alg: string;
84
+ export type SignerSync = (data: string) => string;
85
+ export type VerifierSync = (data: string, sig: string) => boolean;
86
+ export type HasherSync = (data: string, alg: string) => Uint8Array;
87
+ export type SaltGeneratorSync = (length: number) => string;
88
+ export type HasherAndAlgSync = {
89
+ hasher: HasherSync;
90
+ alg: string;
91
91
  };
92
- type NonNever<T> = {
93
- [P in keyof T as T[P] extends never ? never : P]: T[P];
92
+ type NonNever<T> = { [P in keyof T as T[P] extends never ? never : P]: T[P]; };
93
+ export type SD<Payload> = {
94
+ [SD_DIGEST]?: Array<keyof Payload>;
94
95
  };
95
- type SD<Payload> = {
96
- [SD_DIGEST]?: Array<keyof Payload>;
97
- };
98
- type DECOY = {
99
- [SD_DECOY]?: number;
96
+ export type DECOY = {
97
+ [SD_DECOY]?: number;
100
98
  };
101
99
  /**
102
100
  * This is a disclosureFrame type that is used to represent the structure of what is being disclosed.
@@ -134,14 +132,12 @@ type DECOY = {
134
132
  * }
135
133
  *
136
134
  */
137
- type Frame<Payload> = Payload extends Array<infer U> ? U extends object ? Record<number, Frame<U>> & SD<Payload> & DECOY : SD<Payload> & DECOY : Payload extends Record<string, unknown> ? NonNever<{
138
- [K in keyof Payload]?: NonNullable<Payload[K]> extends object ? Frame<Payload[K]> : never;
139
- } & SD<Payload> & DECOY> : SD<Payload> & DECOY;
135
+ type Frame<Payload> = Payload extends Array<infer U> ? U extends object ? Record<number, Frame<U>> & SD<Payload> & DECOY : SD<Payload> & DECOY : Payload extends Record<string, unknown> ? NonNever<{ [K in keyof Payload]?: NonNullable<Payload[K]> extends object ? Frame<Payload[K]> : never; } & SD<Payload> & DECOY> : SD<Payload> & DECOY;
140
136
  /**
141
137
  * This is a disclosureFrame type that is used to represent the structure of what is being disclosed.
142
138
  */
143
- type Extensible = Record<string, unknown | boolean>;
144
- type DisclosureFrame<T extends Extensible> = Frame<T>;
139
+ export type Extensible = Record<string, unknown | boolean>;
140
+ export type DisclosureFrame<T extends Extensible> = Frame<T>;
145
141
  /**
146
142
  * This is a presentationFrame type that is used to represent the structure of what is being presented.
147
143
  * PresentationFrame is made from the payload type.
@@ -185,373 +181,385 @@ type DisclosureFrame<T extends Extensible> = Frame<T>;
185
181
  data2: true,
186
182
  };
187
183
  */
188
- type PFrame<Payload> = Payload extends Array<infer U> ? U extends object ? Record<number, PFrame<U> | boolean> | boolean : Record<number, boolean> | boolean : {
189
- [K in keyof Payload]?: NonNullable<Payload[K]> extends object ? PFrame<Payload[K]> | boolean : boolean;
190
- };
191
- type PresentationFrame<T extends Extensible> = PFrame<T>;
192
-
184
+ type PFrame<Payload> = Payload extends Array<infer U> ? U extends object ? Record<number, PFrame<U> | boolean> | boolean : Record<number, boolean> | boolean : { [K in keyof Payload]?: NonNullable<Payload[K]> extends object ? PFrame<Payload[K]> | boolean : boolean; };
185
+ export type PresentationFrame<T extends Extensible> = PFrame<T>;
186
+ //#endregion
187
+ //#region src/types/verification-error.d.ts
193
188
  /**
194
189
  * Error codes for SD-JWT verification errors.
195
190
  */
196
- type VerificationErrorCode = 'HASHER_NOT_FOUND' | 'VERIFIER_NOT_FOUND' | 'INVALID_SD_JWT' | 'INVALID_JWT_FORMAT' | 'JWT_NOT_YET_VALID' | 'JWT_EXPIRED' | 'INVALID_JWT_SIGNATURE' | 'MISSING_REQUIRED_CLAIMS' | 'KEY_BINDING_JWT_MISSING' | 'KEY_BINDING_VERIFIER_NOT_FOUND' | 'KEY_BINDING_SIGNATURE_INVALID' | 'KEY_BINDING_SD_HASH_INVALID' | 'STATUS_VERIFICATION_FAILED' | 'STATUS_INVALID' | 'VCT_VERIFICATION_FAILED' | 'UNKNOWN_ERROR';
191
+ export type VerificationErrorCode = 'HASHER_NOT_FOUND' | 'VERIFIER_NOT_FOUND' | 'INVALID_SD_JWT' | 'INVALID_JWT_FORMAT' | 'JWT_NOT_YET_VALID' | 'JWT_EXPIRED' | 'INVALID_JWT_SIGNATURE' | 'MISSING_REQUIRED_CLAIMS' | 'KEY_BINDING_JWT_MISSING' | 'KEY_BINDING_VERIFIER_NOT_FOUND' | 'KEY_BINDING_SIGNATURE_INVALID' | 'KEY_BINDING_SD_HASH_INVALID' | 'STATUS_VERIFICATION_FAILED' | 'STATUS_INVALID' | 'VCT_VERIFICATION_FAILED' | 'UNKNOWN_ERROR';
197
192
  /**
198
193
  * Represents a single verification error.
199
194
  */
200
- type VerificationError = {
201
- /**
202
- * The error code identifying the type of error.
203
- */
204
- code: VerificationErrorCode;
205
- /**
206
- * Human-readable error message.
207
- */
208
- message: string;
209
- /**
210
- * Optional additional details about the error.
211
- */
212
- details?: unknown;
195
+ export type VerificationError = {
196
+ /**
197
+ * The error code identifying the type of error.
198
+ */
199
+ code: VerificationErrorCode;
200
+ /**
201
+ * Human-readable error message.
202
+ */
203
+ message: string;
204
+ /**
205
+ * Optional additional details about the error.
206
+ */
207
+ details?: unknown;
213
208
  };
214
209
  /**
215
210
  * Result type for safe verification that collects all errors.
216
211
  */
217
- type SafeVerifyResult<T> = {
218
- success: true;
219
- data: T;
220
- errors?: never;
212
+ export type SafeVerifyResult<T> = {
213
+ success: true;
214
+ data: T;
215
+ errors?: never;
221
216
  } | {
222
- success: false;
223
- data?: never;
224
- errors: VerificationError[];
225
- };
226
-
227
- type FlattenJSONData = {
228
- jwtData: {
229
- protected: string;
230
- payload: string;
231
- signature: string;
232
- };
233
- disclosures: Array<string>;
234
- kb_jwt?: string;
217
+ success: false;
218
+ data?: never;
219
+ errors: VerificationError[];
235
220
  };
236
- type FlattenJSONSerialized = {
221
+ //#endregion
222
+ //#region src/flattenJSON.d.ts
223
+ export type FlattenJSONData = {
224
+ jwtData: {
225
+ protected: string;
237
226
  payload: string;
238
227
  signature: string;
239
- protected: string;
240
- header: {
241
- disclosures: Array<string>;
242
- kb_jwt?: string;
243
- };
228
+ };
229
+ disclosures: Array<string>;
230
+ kb_jwt?: string;
244
231
  };
245
- declare class FlattenJSON {
232
+ export type FlattenJSONSerialized = {
233
+ payload: string;
234
+ signature: string;
235
+ protected: string;
236
+ header: {
246
237
  disclosures: Array<string>;
247
238
  kb_jwt?: string;
248
- payload: string;
249
- signature: string;
250
- protected: string;
251
- constructor(data: FlattenJSONData);
252
- static fromEncode(encodedSdJwt: string): FlattenJSON;
253
- static fromSerialized(json: FlattenJSONSerialized): FlattenJSON;
254
- toJson(): FlattenJSONSerialized;
255
- toEncoded(): string;
239
+ };
240
+ };
241
+ export declare class FlattenJSON {
242
+ disclosures: Array<string>;
243
+ kb_jwt?: string;
244
+ payload: string;
245
+ signature: string;
246
+ protected: string;
247
+ constructor(data: FlattenJSONData);
248
+ static fromEncode(encodedSdJwt: string): FlattenJSON;
249
+ static fromSerialized(json: FlattenJSONSerialized): FlattenJSON;
250
+ toJson(): FlattenJSONSerialized;
251
+ toEncoded(): string;
256
252
  }
257
-
258
- type GeneralJSONData = {
259
- payload: string;
260
- disclosures: Array<string>;
261
- kb_jwt?: string;
262
- signatures: Array<{
263
- protected: string;
264
- signature: string;
265
- kid?: string;
266
- }>;
253
+ //#endregion
254
+ //#region src/generalJSON.d.ts
255
+ export type GeneralJSONData = {
256
+ payload: string;
257
+ disclosures: Array<string>;
258
+ kb_jwt?: string;
259
+ signatures: Array<{
260
+ protected: string;
261
+ signature: string;
262
+ kid?: string;
263
+ }>;
267
264
  };
268
- type GeneralJSONSerialized = {
269
- payload: string;
270
- signatures: Array<{
271
- header: {
272
- disclosures?: Array<string>;
273
- kid?: string;
274
- kb_jwt?: string;
275
- [key: string]: unknown;
276
- };
277
- protected: string;
278
- signature: string;
279
- }>;
265
+ export type GeneralJSONSerialized = {
266
+ payload: string;
267
+ signatures: Array<{
268
+ header: {
269
+ disclosures?: Array<string>;
270
+ kid?: string;
271
+ kb_jwt?: string;
272
+ [key: string]: unknown;
273
+ };
274
+ protected: string;
275
+ signature: string;
276
+ }>;
280
277
  };
281
- declare class GeneralJSON {
278
+ export declare class GeneralJSON {
279
+ payload: string;
280
+ disclosures: Array<string>;
281
+ kb_jwt?: string;
282
+ signatures: Array<{
283
+ protected: string;
284
+ signature: string;
285
+ kid?: string;
286
+ }>;
287
+ constructor(data: GeneralJSONData);
288
+ static fromEncode(encodedSdJwt: string): GeneralJSON;
289
+ static fromSerialized(json: GeneralJSONSerialized): GeneralJSON;
290
+ toJson(): {
282
291
  payload: string;
283
- disclosures: Array<string>;
284
- kb_jwt?: string;
285
- signatures: Array<{
286
- protected: string;
287
- signature: string;
288
- kid?: string;
289
- }>;
290
- constructor(data: GeneralJSONData);
291
- static fromEncode(encodedSdJwt: string): GeneralJSON;
292
- static fromSerialized(json: GeneralJSONSerialized): GeneralJSON;
293
- toJson(): {
294
- payload: string;
295
- signatures: ({
296
- header: {
297
- kid: string | undefined;
298
- disclosures?: undefined;
299
- kb_jwt?: undefined;
300
- };
301
- protected: string;
302
- signature: string;
303
- } | {
304
- header: {
305
- disclosures: string[];
306
- kid: string | undefined;
307
- kb_jwt: string | undefined;
308
- };
309
- protected: string;
310
- signature: string;
311
- })[];
312
- };
313
- toEncoded(index: number): string;
314
- addSignature(protectedHeader: Record<string, unknown>, signer: Signer, kid?: string): Promise<void>;
292
+ signatures: ({
293
+ header: {
294
+ kid: string | undefined;
295
+ disclosures?: undefined;
296
+ kb_jwt?: undefined;
297
+ };
298
+ protected: string;
299
+ signature: string;
300
+ } | {
301
+ header: {
302
+ disclosures: string[];
303
+ kid: string | undefined;
304
+ kb_jwt: string | undefined;
305
+ };
306
+ protected: string;
307
+ signature: string;
308
+ })[];
309
+ };
310
+ toEncoded(index: number): string;
311
+ addSignature(protectedHeader: Record<string, unknown>, signer: Signer, kid?: string): Promise<void>;
315
312
  }
316
-
317
- type JwtData<Header extends Record<string, unknown>, Payload extends Record<string, unknown>> = {
318
- header?: Header;
319
- payload?: Payload;
320
- signature?: Base64urlString;
321
- encoded?: string;
313
+ //#endregion
314
+ //#region src/jwt.d.ts
315
+ export type JwtData<Header extends Record<string, unknown>, Payload extends Record<string, unknown>> = {
316
+ header?: Header;
317
+ payload?: Payload;
318
+ signature?: Base64urlString;
319
+ encoded?: string;
322
320
  };
323
321
  /**
324
322
  * Options for the JWT verifier
325
323
  */
326
- type VerifierOptions = {
327
- /**
328
- * current time in seconds since epoch
329
- */
330
- currentDate?: number;
331
- /**
332
- * allowed skew for the current time in seconds. Positive value that will lower the iat and nbf checks, and increase the exp check.
333
- */
334
- skewSeconds?: number;
335
- /**
336
- * required claim keys for the payload.
337
- * If the payload does not contain these keys, the verification will fail.
338
- */
339
- requiredClaimKeys?: string[];
340
- /**
341
- * Expected audience for the processed SD-JWT payload.
342
- */
343
- expectedAudience?: string | string[];
344
- /**
345
- * Allowed JOSE algorithms for issuer-signed JWTs. `none` is always rejected.
346
- */
347
- allowedIssuerAlgorithms?: string[];
348
- /**
349
- * nonce used to verify the key binding jwt to prevent replay attacks.
350
- */
351
- keyBindingNonce?: string;
352
- /**
353
- * Expected audience for the Key Binding JWT.
354
- */
355
- expectedKeyBindingAudience?: string | string[];
356
- /**
357
- * Maximum acceptable age of the Key Binding JWT, in seconds.
358
- */
359
- keyBindingMaxAgeSeconds?: number;
360
- /**
361
- * Internal option used by SD-JWT validation to defer claim checks until after
362
- * disclosures are processed.
363
- */
364
- skipJwtClaimValidation?: boolean;
365
- /**
366
- * disable the verification of the status claim in the payload.
367
- *
368
- * @default false
369
- */
370
- disableStatusVerification?: boolean;
371
- /**
372
- * any other custom options
373
- */
374
- [key: string]: unknown;
324
+ export type VerifierOptions = {
325
+ /**
326
+ * current time in seconds since epoch
327
+ */
328
+ currentDate?: number;
329
+ /**
330
+ * allowed skew for the current time in seconds. Positive value that will lower the iat and nbf checks, and increase the exp check.
331
+ */
332
+ skewSeconds?: number;
333
+ /**
334
+ * required claim keys for the payload.
335
+ * If the payload does not contain these keys, the verification will fail.
336
+ */
337
+ requiredClaimKeys?: string[];
338
+ /**
339
+ * Expected audience for the processed SD-JWT payload.
340
+ */
341
+ expectedAudience?: string | string[];
342
+ /**
343
+ * Allowed JOSE algorithms for issuer-signed JWTs. `none` is always rejected.
344
+ */
345
+ allowedIssuerAlgorithms?: string[];
346
+ /**
347
+ * nonce used to verify the key binding jwt to prevent replay attacks.
348
+ */
349
+ keyBindingNonce?: string;
350
+ /**
351
+ * Expected audience for the Key Binding JWT.
352
+ */
353
+ expectedKeyBindingAudience?: string | string[];
354
+ /**
355
+ * Maximum acceptable age of the Key Binding JWT, in seconds.
356
+ */
357
+ keyBindingMaxAgeSeconds?: number;
358
+ /**
359
+ * Internal option used by SD-JWT validation to defer claim checks until after
360
+ * disclosures are processed.
361
+ */
362
+ skipJwtClaimValidation?: boolean;
363
+ /**
364
+ * disable the verification of the status claim in the payload.
365
+ *
366
+ * @default false
367
+ */
368
+ disableStatusVerification?: boolean;
369
+ /**
370
+ * any other custom options
371
+ */
372
+ [key: string]: unknown;
375
373
  };
376
- declare const validateJwtPayload: (payload: Record<string, unknown> | undefined, options?: VerifierOptions) => void;
377
- declare class Jwt<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>> {
378
- header?: Header;
379
- payload?: Payload;
380
- signature?: Base64urlString;
381
- private encoded?;
382
- constructor(data?: JwtData<Header, Payload>);
383
- static decodeJWT<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>>(jwt: string): {
384
- header: Header;
385
- payload: Payload;
386
- signature: Base64urlString;
387
- };
388
- static fromEncode<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>>(encodedJwt: string): Jwt<Header, Payload>;
389
- setHeader(header: Header): Jwt<Header, Payload>;
390
- setPayload(payload: Payload): Jwt<Header, Payload>;
391
- protected getUnsignedToken(): string;
392
- sign(signer: Signer): Promise<string>;
393
- encodeJwt(): string;
374
+ export declare const validateJwtPayload: (payload: Record<string, unknown> | undefined, options?: VerifierOptions) => void;
375
+ export declare class Jwt<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>> {
376
+ header?: Header;
377
+ payload?: Payload;
378
+ signature?: Base64urlString;
379
+ private encoded?;
380
+ constructor(data?: JwtData<Header, Payload>);
381
+ static decodeJWT<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>>(jwt: string): {
382
+ header: Header;
383
+ payload: Payload;
384
+ signature: Base64urlString;
385
+ };
386
+ static fromEncode<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>>(encodedJwt: string): Jwt<Header, Payload>;
387
+ setHeader(header: Header): Jwt<Header, Payload>;
388
+ setPayload(payload: Payload): Jwt<Header, Payload>;
389
+ protected getUnsignedToken(): string;
390
+ sign(signer: Signer): Promise<string>;
391
+ encodeJwt(): string;
392
+ /**
393
+ * Verify the JWT using the provided verifier function.
394
+ * It checks the signature and validates the iat, nbf, and exp claims if they are present.
395
+ * @param verifier
396
+ * @param options - Options for verification, such as current date and skew seconds
397
+ * @returns
398
+ */
399
+ verify<T>(verifier: Verifier<T>, options?: T & VerifierOptions): Promise<{
400
+ payload: Payload | undefined;
401
+ header: Header | undefined;
402
+ }>;
403
+ }
404
+ //#endregion
405
+ //#region src/kbjwt.d.ts
406
+ export declare class KBJwt<Header extends kbHeader = kbHeader, Payload extends kbPayload = kbPayload> extends Jwt<Header, Payload> {
407
+ verifyKB(values: {
408
+ verifier: KbVerifier;
409
+ payload: Record<string, unknown>;
410
+ nonce: string;
394
411
  /**
395
- * Verify the JWT using the provided verifier function.
396
- * It checks the signature and validates the iat, nbf, and exp claims if they are present.
397
- * @param verifier
398
- * @param options - Options for verification, such as current date and skew seconds
399
- * @returns
412
+ * Options forwarded to the common JWT verification, e.g. currentDate and
413
+ * skewSeconds used to validate the iat, nbf and exp claims.
400
414
  */
401
- verify<T>(verifier: Verifier<T>, options?: T & VerifierOptions): Promise<{
402
- payload: Payload | undefined;
403
- header: Header | undefined;
404
- }>;
405
- }
406
-
407
- declare class KBJwt<Header extends kbHeader = kbHeader, Payload extends kbPayload = kbPayload> extends Jwt<Header, Payload> {
408
- verifyKB(values: {
409
- verifier: KbVerifier;
410
- payload: Record<string, unknown>;
411
- nonce: string;
412
- /**
413
- * Options forwarded to the common JWT verification, e.g. currentDate and
414
- * skewSeconds used to validate the iat, nbf and exp claims.
415
- */
416
- options?: VerifierOptions;
417
- }): Promise<{
418
- payload: Payload;
419
- header: Header;
420
- }>;
421
- static fromKBEncode<Header extends kbHeader = kbHeader, Payload extends kbPayload = kbPayload>(encodedJwt: string): KBJwt<Header, Payload>;
415
+ options?: VerifierOptions;
416
+ }): Promise<{
417
+ payload: Payload;
418
+ header: Header;
419
+ }>;
420
+ static fromKBEncode<Header extends kbHeader = kbHeader, Payload extends kbPayload = kbPayload>(encodedJwt: string): KBJwt<Header, Payload>;
422
421
  }
423
-
424
- declare class Disclosure<T = unknown> {
425
- salt: string;
426
- key?: string;
427
- value: T;
428
- _digest: string | undefined;
429
- private _encoded;
430
- constructor(data: DisclosureData<T>, _meta?: {
431
- digest: string;
432
- encoded: string;
433
- });
434
- static fromEncode<T>(s: string, hash: HasherAndAlg): Promise<Disclosure<T>>;
435
- static fromEncodeSync<T>(s: string, hash: HasherAndAlgSync): Disclosure<T>;
436
- static fromArray<T>(item: DisclosureData<T>, _meta?: {
437
- digest: string;
438
- encoded: string;
439
- }): Disclosure<T>;
440
- encode(): string;
441
- decode(): DisclosureData<T>;
442
- digest(hash: HasherAndAlg): Promise<string>;
443
- digestSync(hash: HasherAndAlgSync): string;
422
+ //#endregion
423
+ //#region src/utils/disclosure.d.ts
424
+ export declare class Disclosure<T = unknown> {
425
+ salt: string;
426
+ key?: string;
427
+ value: T;
428
+ _digest: string | undefined;
429
+ private _encoded;
430
+ constructor(data: DisclosureData<T>, _meta?: {
431
+ digest: string;
432
+ encoded: string;
433
+ });
434
+ static fromEncode<T>(s: string, hash: HasherAndAlg): Promise<Disclosure<T>>;
435
+ static fromEncodeSync<T>(s: string, hash: HasherAndAlgSync): Disclosure<T>;
436
+ static fromArray<T>(item: DisclosureData<T>, _meta?: {
437
+ digest: string;
438
+ encoded: string;
439
+ }): Disclosure<T>;
440
+ encode(): string;
441
+ decode(): DisclosureData<T>;
442
+ digest(hash: HasherAndAlg): Promise<string>;
443
+ digestSync(hash: HasherAndAlgSync): string;
444
444
  }
445
-
446
- declare class SDJWTException extends Error {
447
- details?: unknown;
448
- constructor(message: string, details?: unknown);
449
- getFullMessage(): string;
445
+ //#endregion
446
+ //#region src/utils/error.d.ts
447
+ export declare class SDJWTException extends Error {
448
+ details?: unknown;
449
+ constructor(message: string, details?: unknown);
450
+ getFullMessage(): string;
450
451
  }
451
452
  /**
452
453
  * Narrows an unknown caught value to an Error instance.
453
454
  */
454
- declare function ensureError(value: unknown): Error;
455
-
456
- type SDJwtData<Header extends Record<string, unknown>, Payload extends Record<string, unknown>, KBHeader extends kbHeader = kbHeader, KBPayload extends kbPayload = kbPayload> = {
457
- jwt?: Jwt<Header, Payload>;
458
- disclosures?: Array<Disclosure>;
459
- kbJwt?: KBJwt<KBHeader, KBPayload>;
455
+ export declare function ensureError(value: unknown): Error;
456
+ //#endregion
457
+ //#region src/sdjwt.d.ts
458
+ export type SDJwtData<Header extends Record<string, unknown>, Payload extends Record<string, unknown>, KBHeader extends kbHeader = kbHeader, KBPayload extends kbPayload = kbPayload> = {
459
+ jwt?: Jwt<Header, Payload>;
460
+ disclosures?: Array<Disclosure>;
461
+ kbJwt?: KBJwt<KBHeader, KBPayload>;
460
462
  };
461
- declare class SDJwt<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>, KBHeader extends kbHeader = kbHeader, KBPayload extends kbPayload = kbPayload> {
462
- jwt?: Jwt<Header, Payload>;
463
- disclosures?: Array<Disclosure>;
463
+ export declare class SDJwt<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>, KBHeader extends kbHeader = kbHeader, KBPayload extends kbPayload = kbPayload> {
464
+ jwt?: Jwt<Header, Payload>;
465
+ disclosures?: Array<Disclosure>;
466
+ kbJwt?: KBJwt<KBHeader, KBPayload>;
467
+ constructor(data?: SDJwtData<Header, Payload, KBHeader, KBPayload>);
468
+ static decodeSDJwt<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>, KBHeader extends kbHeader = kbHeader, KBPayload extends kbPayload = kbPayload>(sdjwt: SDJWTCompact, hasher: Hasher): Promise<{
469
+ jwt: Jwt<Header, Payload>;
470
+ disclosures: Array<Disclosure>;
464
471
  kbJwt?: KBJwt<KBHeader, KBPayload>;
465
- constructor(data?: SDJwtData<Header, Payload, KBHeader, KBPayload>);
466
- static decodeSDJwt<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>, KBHeader extends kbHeader = kbHeader, KBPayload extends kbPayload = kbPayload>(sdjwt: SDJWTCompact, hasher: Hasher): Promise<{
467
- jwt: Jwt<Header, Payload>;
468
- disclosures: Array<Disclosure>;
469
- kbJwt?: KBJwt<KBHeader, KBPayload>;
470
- }>;
471
- static extractJwt<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>>(encodedSdJwt: SDJWTCompact): Promise<Jwt<Header, Payload>>;
472
- static fromEncode<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>, KBHeader extends kbHeader = kbHeader, KBPayload extends kbPayload = kbPayload>(encodedSdJwt: SDJWTCompact, hasher: Hasher): Promise<SDJwt<Header, Payload>>;
473
- present<T extends Record<string, unknown>>(presentFrame: PresentationFrame<T> | undefined, hasher: Hasher): Promise<SDJWTCompact>;
474
- getPresentDisclosures<T extends Record<string, unknown>>(presentFrame: PresentationFrame<T> | undefined, hasher: Hasher): Promise<Disclosure<unknown>[]>;
475
- encodeSDJwt(): SDJWTCompact;
476
- keys(hasher: Hasher): Promise<string[]>;
477
- presentableKeys(hasher: Hasher): Promise<string[]>;
478
- getClaims<T>(hasher: Hasher): Promise<T>;
472
+ }>;
473
+ static extractJwt<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>>(encodedSdJwt: SDJWTCompact): Promise<Jwt<Header, Payload>>;
474
+ static fromEncode<Header extends Record<string, unknown> = Record<string, unknown>, Payload extends Record<string, unknown> = Record<string, unknown>, KBHeader extends kbHeader = kbHeader, KBPayload extends kbPayload = kbPayload>(encodedSdJwt: SDJWTCompact, hasher: Hasher): Promise<SDJwt<Header, Payload>>;
475
+ present<T extends Record<string, unknown>>(presentFrame: PresentationFrame<T> | undefined, hasher: Hasher): Promise<SDJWTCompact>;
476
+ getPresentDisclosures<T extends Record<string, unknown>>(presentFrame: PresentationFrame<T> | undefined, hasher: Hasher): Promise<Disclosure<unknown>[]>;
477
+ encodeSDJwt(): SDJWTCompact;
478
+ keys(hasher: Hasher): Promise<string[]>;
479
+ presentableKeys(hasher: Hasher): Promise<string[]>;
480
+ getClaims<T>(hasher: Hasher): Promise<T>;
479
481
  }
480
- declare const listKeys: (obj: Record<string, unknown>, prefix?: string) => string[];
481
- declare const pack: <T extends Record<string, unknown>>(claims: T, disclosureFrame: DisclosureFrame<T> | undefined, hash: HasherAndAlg, saltGenerator: SaltGenerator, seenSalts?: Set<string>, seenDigests?: Set<string>) => Promise<{
482
- packedClaims: Record<string, unknown> | Array<Record<string, unknown>>;
483
- disclosures: Array<Disclosure>;
482
+ export declare const listKeys: (obj: Record<string, unknown>, prefix?: string) => string[];
483
+ export declare const pack: <T extends Record<string, unknown>>(claims: T, disclosureFrame: DisclosureFrame<T> | undefined, hash: HasherAndAlg, saltGenerator: SaltGenerator, seenSalts?: Set<string>, seenDigests?: Set<string>) => Promise<{
484
+ packedClaims: Record<string, unknown> | Array<Record<string, unknown>>;
485
+ disclosures: Array<Disclosure>;
484
486
  }>;
485
-
486
- declare const decodeJwt: <H extends Record<string, unknown>, T extends Record<string, unknown>>(jwt: string) => {
487
- header: H;
488
- payload: T;
489
- signature: string;
487
+ //#endregion
488
+ //#region src/decode/decode.d.ts
489
+ /**
490
+ * Decode a JWT with `decodeJwt` from `@owf/identity-common`, rethrowing failures as an `SDJWTException`.
491
+ */
492
+ export declare const decodeJwt: <H extends Record<string, unknown>, T extends Record<string, unknown>>(jwt: string) => {
493
+ header: H;
494
+ payload: T;
495
+ signature: string;
490
496
  };
491
- declare const splitSdJwt: (sdjwt: string) => {
492
- jwt: string;
493
- disclosures: string[];
494
- kbJwt?: string;
497
+ export declare const splitSdJwt: (sdjwt: string) => {
498
+ jwt: string;
499
+ disclosures: string[];
500
+ kbJwt?: string;
495
501
  };
496
- declare const decodeSdJwt: (sdjwt: string, hasher: Hasher) => Promise<DecodedSDJwt>;
497
- declare const decodeSdJwtSync: (sdjwt: string, hasher: HasherSync) => DecodedSDJwt;
498
- declare const getClaims: <T = Record<string, unknown>>(rawPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: Hasher) => Promise<T>;
499
- declare const getClaimsSync: <T = Record<string, unknown>>(rawPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: HasherSync) => T;
500
- declare const unpackObj: (obj: unknown, map: Record<string, Disclosure>) => {
501
- unpackedObj: unknown;
502
- disclosureKeymap: Record<string, string>;
502
+ export declare const decodeSdJwt: (sdjwt: string, hasher: Hasher) => Promise<DecodedSDJwt>;
503
+ export declare const decodeSdJwtSync: (sdjwt: string, hasher: HasherSync) => DecodedSDJwt;
504
+ export declare const getClaims: <T = Record<string, unknown>>(rawPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: Hasher) => Promise<T>;
505
+ export declare const getClaimsSync: <T = Record<string, unknown>>(rawPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: HasherSync) => T;
506
+ export declare const unpackObj: (obj: unknown, map: Record<string, Disclosure>) => {
507
+ unpackedObj: unknown;
508
+ disclosureKeymap: Record<string, string>;
503
509
  };
504
- declare const createHashMapping: (disclosures: Array<Disclosure>, hash: HasherAndAlg) => Promise<Record<string, Disclosure<unknown>>>;
505
- declare const createHashMappingSync: (disclosures: Array<Disclosure>, hash: HasherAndAlgSync) => Record<string, Disclosure<unknown>>;
506
- declare const getSDAlgAndPayload: (SdJwtPayload: Record<string, unknown>, allowedAlgorithms?: ReadonlyArray<HashAlgorithm>) => {
507
- _sd_alg: string;
508
- payload: {
509
- [x: string]: unknown;
510
- };
510
+ export declare const createHashMapping: (disclosures: Array<Disclosure>, hash: HasherAndAlg) => Promise<Record<string, Disclosure<unknown>>>;
511
+ export declare const createHashMappingSync: (disclosures: Array<Disclosure>, hash: HasherAndAlgSync) => Record<string, Disclosure<unknown>>;
512
+ export declare const getSDAlgAndPayload: (SdJwtPayload: Record<string, unknown>, allowedAlgorithms?: ReadonlyArray<HashAlgorithm>) => {
513
+ _sd_alg: string;
514
+ payload: {
515
+ [x: string]: unknown;
516
+ };
511
517
  };
512
- declare const unpack: (SdJwtPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: Hasher) => Promise<{
513
- unpackedObj: unknown;
514
- disclosureKeymap: Record<string, string>;
518
+ export declare const unpack: (SdJwtPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: Hasher) => Promise<{
519
+ unpackedObj: unknown;
520
+ disclosureKeymap: Record<string, string>;
515
521
  }>;
516
- declare const unpackSync: (SdJwtPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: HasherSync) => {
517
- unpackedObj: unknown;
518
- disclosureKeymap: Record<string, string>;
522
+ export declare const unpackSync: (SdJwtPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: HasherSync) => {
523
+ unpackedObj: unknown;
524
+ disclosureKeymap: Record<string, string>;
519
525
  };
520
- type DecodedSDJwt = {
521
- jwt: {
522
- header: Record<string, unknown>;
523
- payload: Record<string, unknown>;
524
- signature: string;
525
- };
526
- disclosures: Array<Disclosure>;
527
- kbJwt?: {
528
- header: Record<string, unknown>;
529
- payload: Record<string, unknown>;
530
- signature: string;
531
- };
526
+ export type DecodedSDJwt = {
527
+ jwt: {
528
+ header: Record<string, unknown>;
529
+ payload: Record<string, unknown>;
530
+ signature: string;
531
+ };
532
+ disclosures: Array<Disclosure>;
533
+ kbJwt?: {
534
+ header: Record<string, unknown>;
535
+ payload: Record<string, unknown>;
536
+ signature: string;
537
+ };
532
538
  };
533
-
534
- declare const createDecoy: (hash: HasherAndAlg, saltGenerator: SaltGenerator) => Promise<string>;
535
-
536
- declare const presentableKeys: (rawPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: Hasher) => Promise<string[]>;
537
- declare const presentableKeysSync: (rawPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: HasherSync) => string[];
538
- declare const present: <T extends Record<string, unknown>>(sdJwt: string, presentFrame: PresentationFrame<T>, hasher: Hasher) => Promise<string>;
539
- declare const presentSync: <T extends Record<string, unknown>>(sdJwt: string, presentFrame: PresentationFrame<T>, hasher: HasherSync) => string;
539
+ //#endregion
540
+ //#region src/decoy.d.ts
541
+ export declare const createDecoy: (hash: HasherAndAlg, saltGenerator: SaltGenerator) => Promise<string>;
542
+ //#endregion
543
+ //#region src/present/present.d.ts
544
+ export declare const presentableKeys: (rawPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: Hasher) => Promise<string[]>;
545
+ export declare const presentableKeysSync: (rawPayload: Record<string, unknown>, disclosures: Array<Disclosure>, hasher: HasherSync) => string[];
546
+ export declare const present: <T extends Record<string, unknown>>(sdJwt: string, presentFrame: PresentationFrame<T>, hasher: Hasher) => Promise<string>;
547
+ export declare const presentSync: <T extends Record<string, unknown>>(sdJwt: string, presentFrame: PresentationFrame<T>, hasher: HasherSync) => string;
540
548
  /**
541
549
  * Transform the object keys into an array of strings. We are not sorting the array in any way.
542
550
  * @param obj The object to transform
543
551
  * @param prefix The prefix to add to the keys
544
552
  * @returns
545
553
  */
546
- declare const transformPresentationFrame: (obj: PresentationFrame<Extensible>, prefix?: string[]) => string[];
547
- type SerializedDisclosure = {
548
- digest: string;
549
- encoded: string;
550
- salt: string;
551
- key: string | undefined;
552
- value: unknown;
554
+ export declare const transformPresentationFrame: (obj: PresentationFrame<Extensible>, prefix?: string[]) => string[];
555
+ export type SerializedDisclosure = {
556
+ digest: string;
557
+ encoded: string;
558
+ salt: string;
559
+ key: string | undefined;
560
+ value: unknown;
553
561
  };
554
- declare const createHashMappingForSerializedDisclosure: (disclosures: SerializedDisclosure[]) => Record<string, Disclosure<unknown>>;
562
+ export declare const createHashMappingForSerializedDisclosure: (disclosures: SerializedDisclosure[]) => Record<string, Disclosure<unknown>>;
555
563
  /**
556
564
  * This function selects the serialized disclosures from the payload
557
565
  * and array of serialized disclosure based on the presentation frame.
@@ -560,127 +568,129 @@ declare const createHashMappingForSerializedDisclosure: (disclosures: Serialized
560
568
  * @param disclosures: SerializedDisclosure[]
561
569
  * @param presentationFrame: PresentationFrame<T>
562
570
  */
563
- declare const selectDisclosures: <T extends Record<string, unknown>>(payload: Record<string, unknown>, disclosures: SerializedDisclosure[], presentationFrame: PresentationFrame<T>) => SerializedDisclosure[];
564
-
565
- type SdJwtPayload = Record<string, unknown>;
566
- declare class SDJwtInstance<ExtendedPayload extends SdJwtPayload, T = unknown> {
567
- protected type?: string;
568
- static readonly DEFAULT_hashAlg = "sha-256";
569
- protected userConfig: SDJWTConfig<T>;
570
- constructor(userConfig?: SDJWTConfig<T>);
571
- private createKBJwt;
572
- private SignJwt;
573
- private VerifyJwt;
574
- issue<Payload extends ExtendedPayload>(payload: Payload, disclosureFrame?: DisclosureFrame<Payload>, options?: {
575
- header?: object;
576
- }): Promise<SDJWTCompact>;
577
- /**
578
- * Validates if the payload contains any reserved claim names. If so it will throw an error.
579
- * @param payload
580
- * @returns
581
- */
582
- protected validateReservedFields<T extends ExtendedPayload>(payload: T): void;
583
- protected validateDisclosureFrame<T extends ExtendedPayload>(_disclosureFrame?: DisclosureFrame<T>): void;
584
- present<T extends Record<string, unknown>>(encodedSDJwt: string, presentationFrame?: PresentationFrame<T>, options?: {
585
- kb?: KBOptions;
586
- }): Promise<SDJWTCompact>;
587
- verify(encodedSDJwt: string, options?: T & VerifierOptions): Promise<{
588
- payload: ExtendedPayload;
589
- header: Record<string, unknown> | undefined;
590
- kb?: undefined;
591
- } | {
592
- payload: ExtendedPayload;
593
- header: Record<string, unknown> | undefined;
594
- kb: {
595
- payload: kbPayload;
596
- header: kbHeader;
597
- };
598
- }>;
599
- /**
600
- * Safe verification that collects all errors instead of failing fast.
601
- * Returns a result object with either the verified data or an array of all errors.
602
- *
603
- * @param encodedSDJwt - The encoded SD-JWT to verify
604
- * @param options - Verification options
605
- * @returns A SafeVerifyResult containing either success data or collected errors
606
- */
607
- safeVerify(encodedSDJwt: string, options?: T & VerifierOptions): Promise<SafeVerifyResult<{
608
- payload: ExtendedPayload;
609
- header: Record<string, unknown> | undefined;
610
- kb?: {
611
- payload: Record<string, unknown>;
612
- header: Record<string, unknown>;
613
- };
614
- }>>;
615
- private calculateSDHash;
616
- /**
617
- * This function is for validating the SD JWT
618
- * Checking signature, if provided the iat and exp when provided and return its the claims
619
- * @param encodedSDJwt
620
- * @param options
621
- * @returns
622
- */
623
- validate(encodedSDJwt: string, options?: T & VerifierOptions): Promise<{
624
- payload: ExtendedPayload;
625
- header: Record<string, unknown> | undefined;
626
- }>;
627
- config(newConfig: SDJWTConfig): void;
628
- encode(sdJwt: SDJwt): SDJWTCompact;
629
- decode(endcodedSDJwt: SDJWTCompact): Promise<SDJwt<Record<string, unknown>, Record<string, unknown>, kbHeader, kbPayload>>;
630
- keys(endcodedSDJwt: SDJWTCompact): Promise<string[]>;
631
- presentableKeys(endcodedSDJwt: SDJWTCompact): Promise<string[]>;
632
- getClaims(endcodedSDJwt: SDJWTCompact): Promise<unknown>;
633
- toFlattenJSON(endcodedSDJwt: SDJWTCompact): FlattenJSON;
634
- toGeneralJSON(endcodedSDJwt: SDJWTCompact): GeneralJSON;
571
+ export declare const selectDisclosures: <T extends Record<string, unknown>>(payload: Record<string, unknown>, disclosures: SerializedDisclosure[], presentationFrame: PresentationFrame<T>) => SerializedDisclosure[];
572
+ //#endregion
573
+ //#region src/index.d.ts
574
+ export type SdJwtPayload = Record<string, unknown>;
575
+ export declare class SDJwtInstance<ExtendedPayload extends SdJwtPayload, T = unknown> {
576
+ protected type?: string;
577
+ static readonly DEFAULT_hashAlg = "sha-256";
578
+ protected userConfig: SDJWTConfig<T>;
579
+ constructor(userConfig?: SDJWTConfig<T>);
580
+ private createKBJwt;
581
+ private SignJwt;
582
+ private VerifyJwt;
583
+ issue<Payload extends ExtendedPayload>(payload: Payload, disclosureFrame?: DisclosureFrame<Payload>, options?: {
584
+ header?: object;
585
+ }): Promise<SDJWTCompact>;
586
+ /**
587
+ * Validates if the payload contains any reserved claim names. If so it will throw an error.
588
+ * @param payload
589
+ * @returns
590
+ */
591
+ protected validateReservedFields<T extends ExtendedPayload>(payload: T): void;
592
+ protected validateDisclosureFrame<T extends ExtendedPayload>(_disclosureFrame?: DisclosureFrame<T>): void;
593
+ present<T extends Record<string, unknown>>(encodedSDJwt: string, presentationFrame?: PresentationFrame<T>, options?: {
594
+ kb?: KBOptions;
595
+ }): Promise<SDJWTCompact>;
596
+ verify(encodedSDJwt: string, options?: T & VerifierOptions): Promise<{
597
+ payload: ExtendedPayload;
598
+ header: Record<string, unknown> | undefined;
599
+ kb?: undefined;
600
+ } | {
601
+ payload: ExtendedPayload;
602
+ header: Record<string, unknown> | undefined;
603
+ kb: {
604
+ payload: kbPayload;
605
+ header: kbHeader;
606
+ };
607
+ }>;
608
+ /**
609
+ * Safe verification that collects all errors instead of failing fast.
610
+ * Returns a result object with either the verified data or an array of all errors.
611
+ *
612
+ * @param encodedSDJwt - The encoded SD-JWT to verify
613
+ * @param options - Verification options
614
+ * @returns A SafeVerifyResult containing either success data or collected errors
615
+ */
616
+ safeVerify(encodedSDJwt: string, options?: T & VerifierOptions): Promise<SafeVerifyResult<{
617
+ payload: ExtendedPayload;
618
+ header: Record<string, unknown> | undefined;
619
+ kb?: {
620
+ payload: Record<string, unknown>;
621
+ header: Record<string, unknown>;
622
+ };
623
+ }>>;
624
+ private calculateSDHash;
625
+ /**
626
+ * This function is for validating the SD JWT
627
+ * Checking signature, if provided the iat and exp when provided and return its the claims
628
+ * @param encodedSDJwt
629
+ * @param options
630
+ * @returns
631
+ */
632
+ validate(encodedSDJwt: string, options?: T & VerifierOptions): Promise<{
633
+ payload: ExtendedPayload;
634
+ header: Record<string, unknown> | undefined;
635
+ }>;
636
+ config(newConfig: SDJWTConfig): void;
637
+ encode(sdJwt: SDJwt): SDJWTCompact;
638
+ decode(endcodedSDJwt: SDJWTCompact): Promise<SDJwt<Record<string, unknown>, Record<string, unknown>, kbHeader, kbPayload>>;
639
+ keys(endcodedSDJwt: SDJWTCompact): Promise<string[]>;
640
+ presentableKeys(endcodedSDJwt: SDJWTCompact): Promise<string[]>;
641
+ getClaims(endcodedSDJwt: SDJWTCompact): Promise<unknown>;
642
+ toFlattenJSON(endcodedSDJwt: SDJWTCompact): FlattenJSON;
643
+ toGeneralJSON(endcodedSDJwt: SDJWTCompact): GeneralJSON;
635
644
  }
636
- declare class SDJwtGeneralJSONInstance<ExtendedPayload extends SdJwtPayload> {
637
- protected type?: string;
638
- static readonly DEFAULT_hashAlg = "sha-256";
639
- protected userConfig: SDJWTConfig;
640
- constructor(userConfig?: SDJWTConfig);
641
- private createKBJwt;
642
- private encodeObj;
643
- issue<Payload extends ExtendedPayload>(payload: Payload, disclosureFrame: DisclosureFrame<Payload> | undefined, options: {
644
- sigs: Array<{
645
- signer: Signer;
646
- alg: string;
647
- kid: string;
648
- header?: Record<string, unknown>;
649
- }>;
650
- }): Promise<GeneralJSON>;
651
- /**
652
- * Validates if the payload contains any reserved claim names. If so it will throw an error.
653
- * @param payload
654
- * @returns
655
- */
656
- protected validateReservedFields<T extends ExtendedPayload>(payload: T): void;
657
- protected validateDisclosureFrame<T extends ExtendedPayload>(_disclosureFrame?: DisclosureFrame<T>): void;
658
- present<T extends Record<string, unknown>>(generalJSON: GeneralJSON, presentationFrame?: PresentationFrame<T>, options?: {
659
- kb?: KBOptions;
660
- }): Promise<GeneralJSON>;
661
- verify(generalJSON: GeneralJSON, options?: VerifierOptions): Promise<{
662
- payload: ExtendedPayload;
663
- headers: Record<string, unknown>[];
664
- kb?: undefined;
665
- } | {
666
- payload: ExtendedPayload;
667
- headers: Record<string, unknown>[];
668
- kb: {
669
- payload: kbPayload;
670
- header: kbHeader;
671
- };
645
+ export declare class SDJwtGeneralJSONInstance<ExtendedPayload extends SdJwtPayload> {
646
+ protected type?: string;
647
+ static readonly DEFAULT_hashAlg = "sha-256";
648
+ protected userConfig: SDJWTConfig;
649
+ constructor(userConfig?: SDJWTConfig);
650
+ private createKBJwt;
651
+ private encodeObj;
652
+ issue<Payload extends ExtendedPayload>(payload: Payload, disclosureFrame: DisclosureFrame<Payload> | undefined, options: {
653
+ sigs: Array<{
654
+ signer: Signer;
655
+ alg: string;
656
+ kid: string;
657
+ header?: Record<string, unknown>;
672
658
  }>;
673
- private calculateSDHash;
674
- validate(generalJSON: GeneralJSON, options?: VerifierOptions): Promise<{
675
- payload: ExtendedPayload;
676
- headers: Record<string, unknown>[];
677
- }>;
678
- config(newConfig: SDJWTConfig): void;
679
- encode(sdJwt: GeneralJSON, index: number): SDJWTCompact;
680
- decode(endcodedSDJwt: SDJWTCompact): GeneralJSON;
681
- keys(generalSdjwt: GeneralJSON): Promise<string[]>;
682
- presentableKeys(generalSdjwt: GeneralJSON): Promise<string[]>;
683
- getClaims(generalSdjwt: GeneralJSON): Promise<unknown>;
659
+ }): Promise<GeneralJSON>;
660
+ /**
661
+ * Validates if the payload contains any reserved claim names. If so it will throw an error.
662
+ * @param payload
663
+ * @returns
664
+ */
665
+ protected validateReservedFields<T extends ExtendedPayload>(payload: T): void;
666
+ protected validateDisclosureFrame<T extends ExtendedPayload>(_disclosureFrame?: DisclosureFrame<T>): void;
667
+ present<T extends Record<string, unknown>>(generalJSON: GeneralJSON, presentationFrame?: PresentationFrame<T>, options?: {
668
+ kb?: KBOptions;
669
+ }): Promise<GeneralJSON>;
670
+ verify(generalJSON: GeneralJSON, options?: VerifierOptions): Promise<{
671
+ payload: ExtendedPayload;
672
+ headers: Record<string, unknown>[];
673
+ kb?: undefined;
674
+ } | {
675
+ payload: ExtendedPayload;
676
+ headers: Record<string, unknown>[];
677
+ kb: {
678
+ payload: kbPayload;
679
+ header: kbHeader;
680
+ };
681
+ }>;
682
+ private calculateSDHash;
683
+ validate(generalJSON: GeneralJSON, options?: VerifierOptions): Promise<{
684
+ payload: ExtendedPayload;
685
+ headers: Record<string, unknown>[];
686
+ }>;
687
+ config(newConfig: SDJWTConfig): void;
688
+ encode(sdJwt: GeneralJSON, index: number): SDJWTCompact;
689
+ decode(endcodedSDJwt: SDJWTCompact): GeneralJSON;
690
+ keys(generalSdjwt: GeneralJSON): Promise<string[]>;
691
+ presentableKeys(generalSdjwt: GeneralJSON): Promise<string[]>;
692
+ getClaims(generalSdjwt: GeneralJSON): Promise<unknown>;
684
693
  }
685
-
686
- export { type Base64urlString, type DECOY, DEFAULT_SECURE_HASH_ALGORITHMS, type DecodedSDJwt, Disclosure, type DisclosureData, type DisclosureFrame, type Extensible, FlattenJSON, type FlattenJSONData, type FlattenJSONSerialized, GeneralJSON, type GeneralJSONData, type GeneralJSONSerialized, type HashAlgorithm, type Hasher, type HasherAndAlg, type HasherAndAlgSync, type HasherSync, IANA_HASH_ALGORITHMS, Jwt, type JwtData, type JwtPayload, KBJwt, type KBOptions, KB_JWT_TYP, type KbVerifier, type OrPromise, type PresentationFrame, type SD, type SDJWTCompact, type SDJWTConfig, SDJWTException, SDJwt, type SDJwtData, SDJwtGeneralJSONInstance, SDJwtInstance, SD_DECOY, SD_DIGEST, SD_LIST_KEY, SD_SEPARATOR, type SafeVerifyResult, type SaltGenerator, type SaltGeneratorSync, type SdJwtPayload, type SerializedDisclosure, type Signer, type SignerSync, type VerificationError, type VerificationErrorCode, type Verifier, type VerifierOptions, type VerifierSync, createDecoy, createHashMapping, createHashMappingForSerializedDisclosure, createHashMappingSync, decodeJwt, decodeSdJwt, decodeSdJwtSync, encodePath, encodePathSegment, ensureError, getClaims, getClaimsSync, getSDAlgAndPayload, type kbHeader, type kbPayload, listKeys, pack, present, presentSync, presentableKeys, presentableKeysSync, selectDisclosures, splitSdJwt, transformPresentationFrame, unpack, unpackObj, unpackSync, validateJwtPayload };
694
+ //#endregion
695
+ export { base64UrlToUint8Array, base64urlDecode, base64urlEncode, uint8ArrayToBase64Url };
696
+ //# sourceMappingURL=index.d.mts.map