@sd-jwt/core 0.3.2-next.108 → 0.3.2-next.110

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.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _sd_jwt_types from '@sd-jwt/types';
2
- import { Base64urlString, Signer, Verifier, kbHeader, kbPayload, KbVerifier, JwtPayload, SDJWTCompact, Hasher, DisclosureFrame, HasherAndAlg, SaltGenerator, SDJWTConfig, KBOptions } from '@sd-jwt/types';
2
+ import { Base64urlString, Signer, Verifier, kbHeader, kbPayload, KbVerifier, JwtPayload, SDJWTCompact, Hasher, PresentationFrame, DisclosureFrame, HasherAndAlg, SaltGenerator, SDJWTConfig, KBOptions } from '@sd-jwt/types';
3
3
  import { Disclosure } from '@sd-jwt/utils';
4
4
 
5
5
  type JwtData<Header extends Record<string, unknown>, Payload extends Record<string, unknown>> = {
@@ -55,7 +55,7 @@ declare class SDJwt<Header extends Record<string, unknown> = Record<string, unkn
55
55
  kbJwt?: KBJwt<KBHeader, KBPayload>;
56
56
  }>;
57
57
  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>>;
58
- present(keys: string[], hasher: Hasher): Promise<SDJWTCompact>;
58
+ present<T extends Record<string, unknown>>(presentFrame: PresentationFrame<T> | undefined, hasher: Hasher): Promise<SDJWTCompact>;
59
59
  encodeSDJwt(): SDJWTCompact;
60
60
  keys(hasher: Hasher): Promise<string[]>;
61
61
  presentableKeys(hasher: Hasher): Promise<string[]>;
@@ -87,7 +87,7 @@ declare class SDJwtInstance<ExtendedPayload extends SdJwtPayload> {
87
87
  * @returns
88
88
  */
89
89
  protected validateReservedFields<T extends ExtendedPayload>(disclosureFrame: DisclosureFrame<T>): void;
90
- present(encodedSDJwt: string, presentationKeys?: string[], options?: {
90
+ present<T extends Record<string, unknown>>(encodedSDJwt: string, presentationFrame?: PresentationFrame<T>, options?: {
91
91
  kb?: KBOptions;
92
92
  }): Promise<SDJWTCompact>;
93
93
  verify(encodedSDJwt: string, requiredClaimKeys?: string[], requireKeyBindings?: boolean): Promise<{
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _sd_jwt_types from '@sd-jwt/types';
2
- import { Base64urlString, Signer, Verifier, kbHeader, kbPayload, KbVerifier, JwtPayload, SDJWTCompact, Hasher, DisclosureFrame, HasherAndAlg, SaltGenerator, SDJWTConfig, KBOptions } from '@sd-jwt/types';
2
+ import { Base64urlString, Signer, Verifier, kbHeader, kbPayload, KbVerifier, JwtPayload, SDJWTCompact, Hasher, PresentationFrame, DisclosureFrame, HasherAndAlg, SaltGenerator, SDJWTConfig, KBOptions } from '@sd-jwt/types';
3
3
  import { Disclosure } from '@sd-jwt/utils';
4
4
 
5
5
  type JwtData<Header extends Record<string, unknown>, Payload extends Record<string, unknown>> = {
@@ -55,7 +55,7 @@ declare class SDJwt<Header extends Record<string, unknown> = Record<string, unkn
55
55
  kbJwt?: KBJwt<KBHeader, KBPayload>;
56
56
  }>;
57
57
  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>>;
58
- present(keys: string[], hasher: Hasher): Promise<SDJWTCompact>;
58
+ present<T extends Record<string, unknown>>(presentFrame: PresentationFrame<T> | undefined, hasher: Hasher): Promise<SDJWTCompact>;
59
59
  encodeSDJwt(): SDJWTCompact;
60
60
  keys(hasher: Hasher): Promise<string[]>;
61
61
  presentableKeys(hasher: Hasher): Promise<string[]>;
@@ -87,7 +87,7 @@ declare class SDJwtInstance<ExtendedPayload extends SdJwtPayload> {
87
87
  * @returns
88
88
  */
89
89
  protected validateReservedFields<T extends ExtendedPayload>(disclosureFrame: DisclosureFrame<T>): void;
90
- present(encodedSDJwt: string, presentationKeys?: string[], options?: {
90
+ present<T extends Record<string, unknown>>(encodedSDJwt: string, presentationFrame?: PresentationFrame<T>, options?: {
91
91
  kb?: KBOptions;
92
92
  }): Promise<SDJWTCompact>;
93
93
  verify(encodedSDJwt: string, requiredClaimKeys?: string[], requireKeyBindings?: boolean): Promise<{
package/dist/index.js CHANGED
@@ -195,6 +195,7 @@ var createDecoy = (hash, saltGenerator) => __async(void 0, null, function* () {
195
195
  var import_utils4 = require("@sd-jwt/utils");
196
196
  var import_types2 = require("@sd-jwt/types");
197
197
  var import_decode2 = require("@sd-jwt/decode");
198
+ var import_present = require("@sd-jwt/present");
198
199
  var SDJwt = class _SDJwt {
199
200
  constructor(data) {
200
201
  this.jwt = data == null ? void 0 : data.jwt;
@@ -239,7 +240,7 @@ var SDJwt = class _SDJwt {
239
240
  });
240
241
  });
241
242
  }
242
- present(keys, hasher) {
243
+ present(presentFrame, hasher) {
243
244
  return __async(this, null, function* () {
244
245
  var _a;
245
246
  if (!((_a = this.jwt) == null ? void 0 : _a.payload) || !this.disclosures) {
@@ -253,14 +254,8 @@ var SDJwt = class _SDJwt {
253
254
  this.disclosures,
254
255
  hasher
255
256
  );
256
- const presentableKeys = Object.keys(disclosureKeymap);
257
- const missingKeys = keys.filter((k) => !presentableKeys.includes(k));
258
- if (missingKeys.length > 0) {
259
- throw new import_utils4.SDJWTException(
260
- `Invalid sd-jwt: invalid present keys: ${missingKeys.join(", ")}`
261
- );
262
- }
263
- const disclosures = keys.map((k) => hashmap[disclosureKeymap[k]]);
257
+ const keys = presentFrame ? (0, import_present.transformPresentationFrame)(presentFrame) : yield this.presentableKeys(hasher);
258
+ const disclosures = keys.map((k) => hashmap[disclosureKeymap[k]]).filter((d) => d !== void 0);
264
259
  const presentSDJwt = new _SDJwt({
265
260
  jwt: this.jwt,
266
261
  disclosures,
@@ -510,19 +505,18 @@ var _SDJwtInstance = class _SDJwtInstance {
510
505
  validateReservedFields(disclosureFrame) {
511
506
  return;
512
507
  }
513
- present(encodedSDJwt, presentationKeys, options) {
508
+ present(encodedSDJwt, presentationFrame, options) {
514
509
  return __async(this, null, function* () {
515
- var _a, _b;
510
+ var _a;
516
511
  if (!this.userConfig.hasher) {
517
512
  throw new import_utils5.SDJWTException("Hasher not found");
518
513
  }
519
514
  const hasher = this.userConfig.hasher;
520
515
  const sdjwt = yield SDJwt.fromEncode(encodedSDJwt, hasher);
521
- const sortedpresentationKeys = (_a = presentationKeys == null ? void 0 : presentationKeys.sort()) != null ? _a : yield sdjwt.presentableKeys(hasher);
522
- if (!((_b = sdjwt.jwt) == null ? void 0 : _b.payload))
516
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload))
523
517
  throw new import_utils5.SDJWTException("Payload not found");
524
518
  const presentSdJwtWithoutKb = yield sdjwt.present(
525
- sortedpresentationKeys,
519
+ presentationFrame,
526
520
  hasher
527
521
  );
528
522
  if (!(options == null ? void 0 : options.kb)) {
@@ -534,7 +528,7 @@ var _SDJwtInstance = class _SDJwtInstance {
534
528
  hasher
535
529
  );
536
530
  sdjwt.kbJwt = yield this.createKBJwt(options.kb, sdHashStr);
537
- return sdjwt.present(sortedpresentationKeys, hasher);
531
+ return sdjwt.present(presentationFrame, hasher);
538
532
  });
539
533
  }
540
534
  // This function is for verifying the SD JWT
package/dist/index.mjs CHANGED
@@ -175,6 +175,7 @@ import {
175
175
  SD_SEPARATOR
176
176
  } from "@sd-jwt/types";
177
177
  import { createHashMapping, getSDAlgAndPayload, unpack } from "@sd-jwt/decode";
178
+ import { transformPresentationFrame } from "@sd-jwt/present";
178
179
  var SDJwt = class _SDJwt {
179
180
  constructor(data) {
180
181
  this.jwt = data == null ? void 0 : data.jwt;
@@ -219,7 +220,7 @@ var SDJwt = class _SDJwt {
219
220
  });
220
221
  });
221
222
  }
222
- present(keys, hasher) {
223
+ present(presentFrame, hasher) {
223
224
  return __async(this, null, function* () {
224
225
  var _a;
225
226
  if (!((_a = this.jwt) == null ? void 0 : _a.payload) || !this.disclosures) {
@@ -233,14 +234,8 @@ var SDJwt = class _SDJwt {
233
234
  this.disclosures,
234
235
  hasher
235
236
  );
236
- const presentableKeys = Object.keys(disclosureKeymap);
237
- const missingKeys = keys.filter((k) => !presentableKeys.includes(k));
238
- if (missingKeys.length > 0) {
239
- throw new SDJWTException3(
240
- `Invalid sd-jwt: invalid present keys: ${missingKeys.join(", ")}`
241
- );
242
- }
243
- const disclosures = keys.map((k) => hashmap[disclosureKeymap[k]]);
237
+ const keys = presentFrame ? transformPresentationFrame(presentFrame) : yield this.presentableKeys(hasher);
238
+ const disclosures = keys.map((k) => hashmap[disclosureKeymap[k]]).filter((d) => d !== void 0);
244
239
  const presentSDJwt = new _SDJwt({
245
240
  jwt: this.jwt,
246
241
  disclosures,
@@ -396,7 +391,7 @@ var pack = (claims, disclosureFrame, hash, saltGenerator) => __async(void 0, nul
396
391
 
397
392
  // src/index.ts
398
393
  import {
399
- KB_JWT_TYP as KB_JWT_TYP3
394
+ KB_JWT_TYP as KB_JWT_TYP2
400
395
  } from "@sd-jwt/types";
401
396
  import { getSDAlgAndPayload as getSDAlgAndPayload2 } from "@sd-jwt/decode";
402
397
  var _SDJwtInstance = class _SDJwtInstance {
@@ -417,7 +412,7 @@ var _SDJwtInstance = class _SDJwtInstance {
417
412
  const { payload } = options;
418
413
  const kbJwt = new KBJwt({
419
414
  header: {
420
- typ: KB_JWT_TYP3,
415
+ typ: KB_JWT_TYP2,
421
416
  alg: this.userConfig.kbSignAlg
422
417
  },
423
418
  payload: __spreadProps(__spreadValues({}, payload), { sd_hash: sdHash })
@@ -492,19 +487,18 @@ var _SDJwtInstance = class _SDJwtInstance {
492
487
  validateReservedFields(disclosureFrame) {
493
488
  return;
494
489
  }
495
- present(encodedSDJwt, presentationKeys, options) {
490
+ present(encodedSDJwt, presentationFrame, options) {
496
491
  return __async(this, null, function* () {
497
- var _a, _b;
492
+ var _a;
498
493
  if (!this.userConfig.hasher) {
499
494
  throw new SDJWTException4("Hasher not found");
500
495
  }
501
496
  const hasher = this.userConfig.hasher;
502
497
  const sdjwt = yield SDJwt.fromEncode(encodedSDJwt, hasher);
503
- const sortedpresentationKeys = (_a = presentationKeys == null ? void 0 : presentationKeys.sort()) != null ? _a : yield sdjwt.presentableKeys(hasher);
504
- if (!((_b = sdjwt.jwt) == null ? void 0 : _b.payload))
498
+ if (!((_a = sdjwt.jwt) == null ? void 0 : _a.payload))
505
499
  throw new SDJWTException4("Payload not found");
506
500
  const presentSdJwtWithoutKb = yield sdjwt.present(
507
- sortedpresentationKeys,
501
+ presentationFrame,
508
502
  hasher
509
503
  );
510
504
  if (!(options == null ? void 0 : options.kb)) {
@@ -516,7 +510,7 @@ var _SDJwtInstance = class _SDJwtInstance {
516
510
  hasher
517
511
  );
518
512
  sdjwt.kbJwt = yield this.createKBJwt(options.kb, sdHashStr);
519
- return sdjwt.present(sortedpresentationKeys, hasher);
513
+ return sdjwt.present(presentationFrame, hasher);
520
514
  });
521
515
  }
522
516
  // This function is for verifying the SD JWT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sd-jwt/core",
3
- "version": "0.3.2-next.108+34b24c0",
3
+ "version": "0.3.2-next.110+10aa828",
4
4
  "description": "sd-jwt draft 7 implementation in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -38,12 +38,13 @@
38
38
  },
39
39
  "license": "Apache-2.0",
40
40
  "devDependencies": {
41
- "@sd-jwt/crypto-nodejs": "0.3.2-next.108+34b24c0"
41
+ "@sd-jwt/crypto-nodejs": "0.3.2-next.110+10aa828"
42
42
  },
43
43
  "dependencies": {
44
- "@sd-jwt/decode": "0.3.2-next.108+34b24c0",
45
- "@sd-jwt/types": "0.3.2-next.108+34b24c0",
46
- "@sd-jwt/utils": "0.3.2-next.108+34b24c0"
44
+ "@sd-jwt/decode": "0.3.2-next.110+10aa828",
45
+ "@sd-jwt/present": "0.3.2-next.110+10aa828",
46
+ "@sd-jwt/types": "0.3.2-next.110+10aa828",
47
+ "@sd-jwt/utils": "0.3.2-next.110+10aa828"
47
48
  },
48
49
  "publishConfig": {
49
50
  "access": "public"
@@ -61,5 +62,5 @@
61
62
  "esm"
62
63
  ]
63
64
  },
64
- "gitHead": "34b24c079dc2c63286b2f2e8d5202c54a9163ee5"
65
+ "gitHead": "10aa828afa2b75787459bfde444a8e4d318825f9"
65
66
  }
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  Hasher,
8
8
  KBOptions,
9
9
  KB_JWT_TYP,
10
+ PresentationFrame,
10
11
  SDJWTCompact,
11
12
  SDJWTConfig,
12
13
  } from '@sd-jwt/types';
@@ -139,9 +140,9 @@ export class SDJwtInstance<ExtendedPayload extends SdJwtPayload> {
139
140
  return;
140
141
  }
141
142
 
142
- public async present(
143
+ public async present<T extends Record<string, unknown>>(
143
144
  encodedSDJwt: string,
144
- presentationKeys?: string[],
145
+ presentationFrame?: PresentationFrame<T>,
145
146
  options?: {
146
147
  kb?: KBOptions;
147
148
  },
@@ -153,12 +154,9 @@ export class SDJwtInstance<ExtendedPayload extends SdJwtPayload> {
153
154
 
154
155
  const sdjwt = await SDJwt.fromEncode(encodedSDJwt, hasher);
155
156
 
156
- const sortedpresentationKeys =
157
- presentationKeys?.sort() ?? (await sdjwt.presentableKeys(hasher));
158
-
159
157
  if (!sdjwt.jwt?.payload) throw new SDJWTException('Payload not found');
160
158
  const presentSdJwtWithoutKb = await sdjwt.present(
161
- sortedpresentationKeys,
159
+ presentationFrame,
162
160
  hasher,
163
161
  );
164
162
 
@@ -173,7 +171,7 @@ export class SDJwtInstance<ExtendedPayload extends SdJwtPayload> {
173
171
  );
174
172
 
175
173
  sdjwt.kbJwt = await this.createKBJwt(options.kb, sdHashStr);
176
- return sdjwt.present(sortedpresentationKeys, hasher);
174
+ return sdjwt.present(presentationFrame, hasher);
177
175
  }
178
176
 
179
177
  // This function is for verifying the SD JWT
package/src/sdjwt.ts CHANGED
@@ -6,19 +6,18 @@ import {
6
6
  DisclosureFrame,
7
7
  Hasher,
8
8
  HasherAndAlg,
9
- KBOptions,
10
- KB_JWT_TYP,
9
+ PresentationFrame,
11
10
  SDJWTCompact,
12
11
  SD_DECOY,
13
12
  SD_DIGEST,
14
13
  SD_LIST_KEY,
15
14
  SD_SEPARATOR,
16
15
  SaltGenerator,
17
- Signer,
18
16
  kbHeader,
19
17
  kbPayload,
20
18
  } from '@sd-jwt/types';
21
19
  import { createHashMapping, getSDAlgAndPayload, unpack } from '@sd-jwt/decode';
20
+ import { transformPresentationFrame } from '@sd-jwt/present';
22
21
 
23
22
  export type SDJwtData<
24
23
  Header extends Record<string, unknown>,
@@ -117,7 +116,10 @@ export class SDJwt<
117
116
  });
118
117
  }
119
118
 
120
- public async present(keys: string[], hasher: Hasher): Promise<SDJWTCompact> {
119
+ public async present<T extends Record<string, unknown>>(
120
+ presentFrame: PresentationFrame<T> | undefined,
121
+ hasher: Hasher,
122
+ ): Promise<SDJWTCompact> {
121
123
  if (!this.jwt?.payload || !this.disclosures) {
122
124
  throw new SDJWTException('Invalid sd-jwt: jwt or disclosures is missing');
123
125
  }
@@ -130,15 +132,12 @@ export class SDJwt<
130
132
  hasher,
131
133
  );
132
134
 
133
- const presentableKeys = Object.keys(disclosureKeymap);
134
- const missingKeys = keys.filter((k) => !presentableKeys.includes(k));
135
- if (missingKeys.length > 0) {
136
- throw new SDJWTException(
137
- `Invalid sd-jwt: invalid present keys: ${missingKeys.join(', ')}`,
138
- );
139
- }
140
-
141
- const disclosures = keys.map((k) => hashmap[disclosureKeymap[k]]);
135
+ const keys = presentFrame
136
+ ? transformPresentationFrame(presentFrame)
137
+ : await this.presentableKeys(hasher);
138
+ const disclosures = keys
139
+ .map((k) => hashmap[disclosureKeymap[k]])
140
+ .filter((d) => d !== undefined);
142
141
  const presentSDJwt = new SDJwt({
143
142
  jwt: this.jwt,
144
143
  disclosures,
@@ -53,15 +53,19 @@ describe('index', () => {
53
53
 
54
54
  expect(credential).toBeDefined();
55
55
 
56
- const presentation = await sdjwt.present(credential, ['foo'], {
57
- kb: {
58
- payload: {
59
- aud: '1',
60
- iat: 1,
61
- nonce: '342',
56
+ const presentation = await sdjwt.present(
57
+ credential,
58
+ { foo: true },
59
+ {
60
+ kb: {
61
+ payload: {
62
+ aud: '1',
63
+ iat: 1,
64
+ nonce: '342',
65
+ },
62
66
  },
63
67
  },
64
- });
68
+ );
65
69
 
66
70
  expect(presentation).toBeDefined();
67
71
  });
@@ -163,15 +167,19 @@ describe('index', () => {
163
167
  },
164
168
  );
165
169
 
166
- const presentation = await sdjwt.present(credential, ['foo'], {
167
- kb: {
168
- payload: {
169
- aud: '',
170
- iat: 1,
171
- nonce: '342',
170
+ const presentation = await sdjwt.present(
171
+ credential,
172
+ { foo: true },
173
+ {
174
+ kb: {
175
+ payload: {
176
+ aud: '',
177
+ iat: 1,
178
+ nonce: '342',
179
+ },
172
180
  },
173
181
  },
174
- });
182
+ );
175
183
 
176
184
  try {
177
185
  await sdjwt.verify(presentation);
@@ -235,15 +243,19 @@ describe('index', () => {
235
243
  },
236
244
  );
237
245
 
238
- const presentation = await sdjwt.present(credential, ['foo'], {
239
- kb: {
240
- payload: {
241
- aud: '1',
242
- iat: 1,
243
- nonce: '342',
246
+ const presentation = await sdjwt.present(
247
+ credential,
248
+ { foo: true },
249
+ {
250
+ kb: {
251
+ payload: {
252
+ aud: '1',
253
+ iat: 1,
254
+ nonce: '342',
255
+ },
244
256
  },
245
257
  },
246
- });
258
+ );
247
259
 
248
260
  const results = await sdjwt.verify(presentation, ['foo'], true);
249
261
  expect(results).toBeDefined();
@@ -341,15 +353,19 @@ describe('index', () => {
341
353
  },
342
354
  );
343
355
 
344
- const presentation = await sdjwt.present(credential, ['foo'], {
345
- kb: {
346
- payload: {
347
- aud: '1',
348
- iat: 1,
349
- nonce: '342',
356
+ const presentation = await sdjwt.present(
357
+ credential,
358
+ { foo: true },
359
+ {
360
+ kb: {
361
+ payload: {
362
+ aud: '1',
363
+ iat: 1,
364
+ nonce: '342',
365
+ },
350
366
  },
351
367
  },
352
- });
368
+ );
353
369
  try {
354
370
  const results = await sdjwt.verify(presentation, ['foo'], true);
355
371
  } catch (e) {
@@ -381,15 +397,19 @@ describe('index', () => {
381
397
  },
382
398
  );
383
399
  try {
384
- const presentation = await sdjwt.present(credential, ['foo'], {
385
- kb: {
386
- payload: {
387
- aud: '1',
388
- iat: 1,
389
- nonce: '342',
400
+ const presentation = await sdjwt.present(
401
+ credential,
402
+ { foo: true },
403
+ {
404
+ kb: {
405
+ payload: {
406
+ aud: '1',
407
+ iat: 1,
408
+ nonce: '342',
409
+ },
390
410
  },
391
411
  },
392
- });
412
+ );
393
413
  } catch (e) {
394
414
  expect(e).toBeDefined();
395
415
  }
@@ -419,15 +439,19 @@ describe('index', () => {
419
439
  },
420
440
  );
421
441
 
422
- const presentation = await sdjwt.present(credential, ['foo'], {
423
- kb: {
424
- payload: {
425
- aud: '1',
426
- iat: 1,
427
- nonce: '342',
442
+ const presentation = await sdjwt.present(
443
+ credential,
444
+ { foo: true },
445
+ {
446
+ kb: {
447
+ payload: {
448
+ aud: '1',
449
+ iat: 1,
450
+ nonce: '342',
451
+ },
428
452
  },
429
453
  },
430
- });
454
+ );
431
455
  try {
432
456
  const results = await sdjwt.verify(presentation, ['foo'], true);
433
457
  } catch (e) {
@@ -458,15 +482,19 @@ describe('index', () => {
458
482
  },
459
483
  );
460
484
 
461
- const presentation = sdjwt.present(credential, ['foo'], {
462
- kb: {
463
- payload: {
464
- aud: '1',
465
- iat: 1,
466
- nonce: '342',
485
+ const presentation = sdjwt.present(
486
+ credential,
487
+ { foo: true },
488
+ {
489
+ kb: {
490
+ payload: {
491
+ aud: '1',
492
+ iat: 1,
493
+ nonce: '342',
494
+ },
467
495
  },
468
496
  },
469
- });
497
+ );
470
498
  expect(presentation).rejects.toThrow(
471
499
  'Key Binding sign algorithm not specified',
472
500
  );
@@ -496,7 +524,7 @@ describe('index', () => {
496
524
  expect(sdjwt.presentableKeys('')).rejects.toThrow('Hasher not found');
497
525
  expect(sdjwt.getClaims('')).rejects.toThrow('Hasher not found');
498
526
  expect(() => sdjwt.decode('')).toThrowError('Hasher not found');
499
- expect(sdjwt.present(credential, ['foo'])).rejects.toThrow(
527
+ expect(sdjwt.present(credential, { foo: true })).rejects.toThrow(
500
528
  'Hasher not found',
501
529
  );
502
530
  });
@@ -1,6 +1,11 @@
1
1
  import Crypto from 'node:crypto';
2
2
  import { SDJwtInstance, SdJwtPayload } from '../src';
3
- import { DisclosureFrame, Signer, Verifier } from '@sd-jwt/types';
3
+ import {
4
+ DisclosureFrame,
5
+ PresentationFrame,
6
+ Signer,
7
+ Verifier,
8
+ } from '@sd-jwt/types';
4
9
  import fs from 'fs';
5
10
  import path from 'path';
6
11
  import { describe, expect, test } from 'vitest';
@@ -105,7 +110,10 @@ describe('App', () => {
105
110
  'id',
106
111
  ]);
107
112
 
108
- const presentationFrame = ['firstname', 'id'];
113
+ const presentationFrame = {
114
+ firstname: true,
115
+ id: true,
116
+ };
109
117
  const presentedSDJwt = await sdjwt.present(encodedSdjwt, presentationFrame);
110
118
  expect(presentedSDJwt).toBeDefined();
111
119
 
@@ -215,7 +223,7 @@ async function JSONtest(filename: string) {
215
223
 
216
224
  const presentedSDJwt = await sdjwt.present(
217
225
  encodedSdjwt,
218
- test.presentationKeys,
226
+ test.presentationFrames,
219
227
  );
220
228
 
221
229
  expect(presentedSDJwt).toBeDefined();
@@ -236,7 +244,7 @@ async function JSONtest(filename: string) {
236
244
  type TestJson = {
237
245
  claims: SdJwtPayload;
238
246
  disclosureFrame: DisclosureFrame<SdJwtPayload>;
239
- presentationKeys: string[];
247
+ presentationFrames: PresentationFrame<SdJwtPayload>;
240
248
  presenatedClaims: object;
241
249
  requiredClaimKeys: string[];
242
250
  };
@@ -7,14 +7,16 @@
7
7
  "_sd": [0, 1, 2, 3, 4, 5]
8
8
  }
9
9
  },
10
- "presentationKeys": [
11
- "data_types.0",
12
- "data_types.1",
13
- "data_types.2",
14
- "data_types.3",
15
- "data_types.4",
16
- "data_types.5"
17
- ],
10
+ "presentationFrames": {
11
+ "data_types": {
12
+ "0": true,
13
+ "1": true,
14
+ "2": true,
15
+ "3": true,
16
+ "4": true,
17
+ "5": true
18
+ }
19
+ },
18
20
  "presenatedClaims": {
19
21
  "data_types": [null, 42, 3.14, "foo", ["Test"], { "foo": "bar" }]
20
22
  },
@@ -11,7 +11,7 @@
11
11
  "_sd": ["13", "18", "21"]
12
12
  }
13
13
  },
14
- "presentationKeys": ["is_over.18"],
14
+ "presentationFrames": { "is_over": { "18": true } },
15
15
  "presenatedClaims": {
16
16
  "is_over": {
17
17
  "18": false
@@ -5,7 +5,7 @@
5
5
  "disclosureFrame": {
6
6
  "_sd": ["sd_array"]
7
7
  },
8
- "presentationKeys": ["sd_array"],
8
+ "presentationFrames": { "sd_array": true },
9
9
  "presenatedClaims": {
10
10
  "sd_array": ["32", "23"]
11
11
  },
@@ -12,7 +12,16 @@
12
12
  }
13
13
  }
14
14
  },
15
- "presentationKeys": ["nested_array.0.0", "nested_array.1.1"],
15
+ "presentationFrames": {
16
+ "nested_array": {
17
+ "0": {
18
+ "0": true
19
+ },
20
+ "1": {
21
+ "1": true
22
+ }
23
+ }
24
+ },
16
25
  "presenatedClaims": {
17
26
  "nested_array": [["foo"], ["qux"]]
18
27
  },
@@ -11,7 +11,7 @@
11
11
  "_sd": ["13", "18", "21"]
12
12
  }
13
13
  },
14
- "presentationKeys": [],
14
+ "presentationFrames": {},
15
15
  "presenatedClaims": {},
16
16
  "requiredClaimKeys": []
17
17
  }
@@ -7,7 +7,7 @@
7
7
  "_sd": [1, 2]
8
8
  }
9
9
  },
10
- "presentationKeys": [],
10
+ "presentationFrames": {},
11
11
  "presenatedClaims": {
12
12
  "null_values": [null, null]
13
13
  },
@@ -28,7 +28,14 @@
28
28
  "_sd": ["foo"]
29
29
  }
30
30
  },
31
- "presentationKeys": ["addresses.1", "array_with_one_sd_object.foo"],
31
+ "presentationFrames": {
32
+ "addresses": {
33
+ "1": true
34
+ },
35
+ "array_with_one_sd_object": {
36
+ "foo": true
37
+ }
38
+ },
32
39
  "presenatedClaims": {
33
40
  "addresses": [
34
41
  {
@@ -7,7 +7,11 @@
7
7
  "_sd": [0, 1]
8
8
  }
9
9
  },
10
- "presentationKeys": ["nationalities.1"],
10
+ "presentationFrames": {
11
+ "nationalities": {
12
+ "1": true
13
+ }
14
+ },
11
15
  "presenatedClaims": {
12
16
  "nationalities": ["CA", "DE"]
13
17
  },
@@ -26,7 +26,7 @@
26
26
  "_sd": [0, 1]
27
27
  }
28
28
  },
29
- "presentationKeys": [],
29
+ "presentationFrames": {},
30
30
  "presenatedClaims": {
31
31
  "array_with_recursive_sd": ["boring", []],
32
32
  "test2": []
@@ -25,12 +25,20 @@
25
25
  "_sd": [0, 1]
26
26
  }
27
27
  },
28
- "presentationKeys": [
29
- "array_with_recursive_sd.1.baz",
30
- "array_with_recursive_sd.2.1",
31
- "test2.0",
32
- "test2.1"
33
- ],
28
+ "presentationFrames": {
29
+ "array_with_recursive_sd": {
30
+ "1": {
31
+ "baz": true
32
+ },
33
+ "2": {
34
+ "1": true
35
+ }
36
+ },
37
+ "test2": {
38
+ "0": true,
39
+ "1": true
40
+ }
41
+ },
34
42
  "presenatedClaims": {
35
43
  "array_with_recursive_sd": [
36
44
  "boring",
package/test/complex.json CHANGED
@@ -31,7 +31,7 @@
31
31
  "_sd": ["hi"]
32
32
  }
33
33
  },
34
- "presentationKeys": ["firstname", "id"],
34
+ "presentationFrames": { "firstname": true, "id": true },
35
35
  "presenatedClaims": {
36
36
  "lastname": "Doe",
37
37
  "ssn": "123-45-6789",
@@ -24,7 +24,11 @@
24
24
  "birthdate"
25
25
  ]
26
26
  },
27
- "presentationKeys": ["given_name", "family_name", "address"],
27
+ "presentationFrames": {
28
+ "given_name": true,
29
+ "family_name": true,
30
+ "address": true
31
+ },
28
32
  "presenatedClaims": {
29
33
  "given_name": "John",
30
34
  "family_name": "Deo",
@@ -24,7 +24,11 @@
24
24
  "birthdate"
25
25
  ]
26
26
  },
27
- "presentationKeys": ["given_name", "family_name", "address"],
27
+ "presentationFrames": {
28
+ "given_name": true,
29
+ "family_name": true,
30
+ "address": true
31
+ },
28
32
  "presenatedClaims": {
29
33
  "given_name": "John",
30
34
  "family_name": "Deo",
@@ -24,7 +24,11 @@
24
24
  "birthdate"
25
25
  ]
26
26
  },
27
- "presentationKeys": ["given_name", "family_name", "address"],
27
+ "presentationFrames": {
28
+ "given_name": true,
29
+ "family_name": true,
30
+ "address": true
31
+ },
28
32
  "presenatedClaims": {
29
33
  "given_name": "John",
30
34
  "family_name": "Deo",
package/test/no_sd.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "test2": ["foo", "bar"]
14
14
  },
15
15
  "disclosureFrame": {},
16
- "presentationKeys": [],
16
+ "presentationFrames": {},
17
17
  "presenatedClaims": {
18
18
  "recursive": [
19
19
  "boring",
@@ -25,15 +25,17 @@
25
25
  ]
26
26
  }
27
27
  },
28
- "presentationKeys": [
29
- "value_Data_types.test_null",
30
- "value_Data_types.test_int",
31
- "value_Data_types.test_float",
32
- "value_Data_types.test_str",
33
- "value_Data_types.test_bool",
34
- "value_Data_types.test_arr",
35
- "value_Data_types.test_object"
36
- ],
28
+ "presentationFrames": {
29
+ "value_Data_types": {
30
+ "test_null": true,
31
+ "test_int": true,
32
+ "test_float": true,
33
+ "test_str": true,
34
+ "test_bool": true,
35
+ "test_arr": true,
36
+ "test_object": true
37
+ }
38
+ },
37
39
  "presenatedClaims": {
38
40
  "value_Data_types": {
39
41
  "test_null": null,
@@ -50,23 +50,42 @@
50
50
  }
51
51
  }
52
52
  },
53
- "presentationKeys": [
54
- "foo.1",
55
- "bar.green",
56
- "qux.0",
57
- "qux.0.0",
58
- "qux.0.1",
59
- "baz.0",
60
- "baz.0.0",
61
- "baz.0.1",
62
- "baz.1",
63
- "baz.1.0",
64
- "baz.1.1",
65
- "animals.snake",
66
- "animals.snake.age",
67
- "animals.bird",
68
- "animals.bird.age"
69
- ],
53
+ "presentationFrames": {
54
+ "foo": {
55
+ "1": true
56
+ },
57
+ "bar": {
58
+ "green": true
59
+ },
60
+ "qux": {
61
+ "0": {
62
+ "0": true,
63
+ "1": true
64
+ },
65
+ "1": {
66
+ "0": true,
67
+ "1": true
68
+ }
69
+ },
70
+ "baz": {
71
+ "0": {
72
+ "0": true,
73
+ "1": true
74
+ },
75
+ "1": {
76
+ "0": true,
77
+ "1": true
78
+ }
79
+ },
80
+ "animals": {
81
+ "snake": {
82
+ "age": true
83
+ },
84
+ "bird": {
85
+ "age": true
86
+ }
87
+ }
88
+ },
70
89
  "presenatedClaims": {
71
90
  "foo": ["two"],
72
91
  "bar": {