@sd-jwt/sd-jwt-vc 0.17.2-next.2 → 0.17.2-next.4

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
@@ -133,7 +133,7 @@ type TypeMetadataFormat = {
133
133
  claims?: Claim[];
134
134
  };
135
135
 
136
- type VcTFetcher = (uri: string, integrity?: string) => Promise<TypeMetadataFormat>;
136
+ type VcTFetcher = (uri: string, integrity?: string) => Promise<TypeMetadataFormat | undefined>;
137
137
 
138
138
  type StatusListFetcher = (uri: string) => Promise<string>;
139
139
  type StatusValidator = (status: number) => Promise<void>;
@@ -215,7 +215,7 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
215
215
  * @param encodedSDJwt
216
216
  * @returns
217
217
  */
218
- getVct(encodedSDJwt: string): Promise<TypeMetadataFormat>;
218
+ getVct(encodedSDJwt: string): Promise<TypeMetadataFormat | undefined>;
219
219
  /**
220
220
  * Validates the integrity of the response if the integrity is passed. If the integrity does not match, an error is thrown.
221
221
  * @param integrity
package/dist/index.d.ts CHANGED
@@ -133,7 +133,7 @@ type TypeMetadataFormat = {
133
133
  claims?: Claim[];
134
134
  };
135
135
 
136
- type VcTFetcher = (uri: string, integrity?: string) => Promise<TypeMetadataFormat>;
136
+ type VcTFetcher = (uri: string, integrity?: string) => Promise<TypeMetadataFormat | undefined>;
137
137
 
138
138
  type StatusListFetcher = (uri: string) => Promise<string>;
139
139
  type StatusValidator = (status: number) => Promise<void>;
@@ -215,7 +215,7 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
215
215
  * @param encodedSDJwt
216
216
  * @returns
217
217
  */
218
- getVct(encodedSDJwt: string): Promise<TypeMetadataFormat>;
218
+ getVct(encodedSDJwt: string): Promise<TypeMetadataFormat | undefined>;
219
219
  /**
220
220
  * Validates the integrity of the response if the integrity is passed. If the integrity does not match, an error is thrown.
221
221
  * @param integrity
package/dist/index.js CHANGED
@@ -218,7 +218,7 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
218
218
  verifyVct(result) {
219
219
  return __async(this, null, function* () {
220
220
  const typeMetadataFormat = yield this.fetchVct(result);
221
- if (typeMetadataFormat.extends) {
221
+ if (typeMetadataFormat == null ? void 0 : typeMetadataFormat.extends) {
222
222
  }
223
223
  return typeMetadataFormat;
224
224
  });
package/dist/index.mjs CHANGED
@@ -196,7 +196,7 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
196
196
  verifyVct(result) {
197
197
  return __async(this, null, function* () {
198
198
  const typeMetadataFormat = yield this.fetchVct(result);
199
- if (typeMetadataFormat.extends) {
199
+ if (typeMetadataFormat == null ? void 0 : typeMetadataFormat.extends) {
200
200
  }
201
201
  return typeMetadataFormat;
202
202
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sd-jwt/sd-jwt-vc",
3
- "version": "0.17.2-next.2+4a4c1b0",
3
+ "version": "0.17.2-next.4+213de7e",
4
4
  "description": "sd-jwt draft 7 implementation in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -38,13 +38,13 @@
38
38
  },
39
39
  "license": "Apache-2.0",
40
40
  "dependencies": {
41
- "@sd-jwt/core": "0.17.2-next.2+4a4c1b0",
42
- "@sd-jwt/jwt-status-list": "0.17.2-next.2+4a4c1b0",
43
- "@sd-jwt/utils": "0.17.2-next.2+4a4c1b0"
41
+ "@sd-jwt/core": "0.17.2-next.4+213de7e",
42
+ "@sd-jwt/jwt-status-list": "0.17.2-next.4+213de7e",
43
+ "@sd-jwt/utils": "0.17.2-next.4+213de7e"
44
44
  },
45
45
  "devDependencies": {
46
- "@sd-jwt/crypto-nodejs": "0.17.2-next.2+4a4c1b0",
47
- "@sd-jwt/types": "0.17.2-next.2+4a4c1b0",
46
+ "@sd-jwt/crypto-nodejs": "0.17.2-next.4+213de7e",
47
+ "@sd-jwt/types": "0.17.2-next.4+213de7e",
48
48
  "jose": "^6.1.2",
49
49
  "msw": "^2.12.3"
50
50
  },
@@ -64,5 +64,5 @@
64
64
  "esm"
65
65
  ]
66
66
  },
67
- "gitHead": "4a4c1b0c04615bcf0e455d51cd1b9234cbcd0d78"
67
+ "gitHead": "213de7e85b9820ca638ba3362fe4deee808e236e"
68
68
  }
@@ -134,7 +134,7 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
134
134
  * @param encodedSDJwt
135
135
  * @returns
136
136
  */
137
- async getVct(encodedSDJwt: string): Promise<TypeMetadataFormat> {
137
+ async getVct(encodedSDJwt: string): Promise<TypeMetadataFormat | undefined> {
138
138
  // Call the parent class's verify method
139
139
  const { payload, header } = await SDJwt.extractJwt<
140
140
  Record<string, unknown>,
@@ -168,7 +168,7 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
168
168
  // validate the integrity of the response according to https://www.w3.org/TR/SRI/
169
169
  const arrayBuffer = await response.arrayBuffer();
170
170
  const alg = integrity.split('-')[0];
171
- //TODO: error handling when a hasher is passed that is not supporting the required algorithm acording to the spec
171
+ //TODO: error handling when a hasher is passed that is not supporting the required algorithm according to the spec
172
172
  const hashBuffer = await (this.userConfig.hasher as Hasher)(
173
173
  arrayBuffer,
174
174
  alg,
@@ -221,7 +221,7 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
221
221
  ): Promise<TypeMetadataFormat | undefined> {
222
222
  const typeMetadataFormat = await this.fetchVct(result);
223
223
 
224
- if (typeMetadataFormat.extends) {
224
+ if (typeMetadataFormat?.extends) {
225
225
  // implement based on https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-08.html#name-extending-type-metadata
226
226
  //TODO: needs to be implemented. Unclear at this point which values will overwrite the values from the extended type metadata format
227
227
  }
@@ -236,7 +236,7 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
236
236
  */
237
237
  private async fetchVct(
238
238
  result: VerificationResult,
239
- ): Promise<TypeMetadataFormat> {
239
+ ): Promise<TypeMetadataFormat | undefined> {
240
240
  if (!result.payload.vct) {
241
241
  throw new SDJWTException('vct claim is required');
242
242
  }
@@ -3,4 +3,4 @@ import type { TypeMetadataFormat } from './sd-jwt-vc-type-metadata-format';
3
3
  export type VcTFetcher = (
4
4
  uri: string,
5
5
  integrity?: string,
6
- ) => Promise<TypeMetadataFormat>;
6
+ ) => Promise<TypeMetadataFormat | undefined>;
@@ -87,7 +87,7 @@ describe('App', () => {
87
87
  expectedPayload,
88
88
  disclosureFrame as unknown as DisclosureFrame<SdJwtVcPayload>,
89
89
  );
90
- expect(encodedSdjwt).rejects.toThrowError();
90
+ await expect(encodedSdjwt).rejects.toThrowError();
91
91
  });
92
92
  });
93
93
 
@@ -149,7 +149,7 @@ describe('Revocation', () => {
149
149
  const expectedPayload: SdJwtVcPayload = { iat, iss, vct, ...claims };
150
150
  const encodedSdjwt = await sdjwt.issue(expectedPayload);
151
151
  const result = sdjwt.verify(encodedSdjwt);
152
- expect(result).rejects.toThrowError('Status is not valid');
152
+ await expect(result).rejects.toThrowError('Status is not valid');
153
153
  });
154
154
 
155
155
  test('test to fetch the statuslist', async () => {
@@ -145,7 +145,9 @@ describe('App', () => {
145
145
  });
146
146
 
147
147
  const requiredClaimKeys = ['firstname', 'id', 'data.ssn'];
148
- const verified = await sdjwt.verify(encodedSdjwt, requiredClaimKeys);
148
+ const verified = await sdjwt.verify(encodedSdjwt, {
149
+ requiredClaimKeys,
150
+ });
149
151
  expect(verified).toBeDefined();
150
152
  });
151
153
 
@@ -239,7 +241,7 @@ async function JSONtest(filename: string) {
239
241
  payload,
240
242
  });
241
243
 
242
- const presentedSDJwt = await sdjwt.present<typeof claims>(
244
+ const presentedSDJwt = await sdjwt.present(
243
245
  encodedSdjwt,
244
246
  test.presentationFrames,
245
247
  );
@@ -249,13 +251,15 @@ async function JSONtest(filename: string) {
249
251
  const presentationClaims = await sdjwt.getClaims(presentedSDJwt);
250
252
 
251
253
  expect(presentationClaims).toEqual({
252
- ...test.presenatedClaims,
254
+ ...test.presentedClaims,
253
255
  iat,
254
256
  iss,
255
257
  vct,
256
258
  });
257
259
 
258
- const verified = await sdjwt.verify(encodedSdjwt, test.requiredClaimKeys);
260
+ const verified = await sdjwt.verify(encodedSdjwt, {
261
+ requiredClaimKeys: test.requiredClaimKeys,
262
+ });
259
263
 
260
264
  expect(verified).toBeDefined();
261
265
  expect(verified).toStrictEqual({
@@ -267,9 +271,11 @@ async function JSONtest(filename: string) {
267
271
 
268
272
  type TestJson = {
269
273
  claims: object;
270
- disclosureFrame: DisclosureFrame<object>;
271
- presentationFrames: PresentationFrame<object>;
272
- presenatedClaims: object;
274
+ // biome-ignore lint/complexity/noBannedTypes: we want an empty object in this case
275
+ disclosureFrame: DisclosureFrame<{}>;
276
+ // biome-ignore lint/complexity/noBannedTypes: we want an empty object in this case
277
+ presentationFrames: PresentationFrame<{}>;
278
+ presentedClaims: object;
273
279
  requiredClaimKeys: string[];
274
280
  };
275
281
 
@@ -17,7 +17,7 @@
17
17
  "5": true
18
18
  }
19
19
  },
20
- "presenatedClaims": {
20
+ "presentedClaims": {
21
21
  "data_types": [null, 42, 3.14, "foo", ["Test"], { "foo": "bar" }]
22
22
  },
23
23
  "requiredClaimKeys": [
@@ -12,7 +12,7 @@
12
12
  }
13
13
  },
14
14
  "presentationFrames": { "is_over": { "18": true } },
15
- "presenatedClaims": {
15
+ "presentedClaims": {
16
16
  "is_over": {
17
17
  "18": false
18
18
  }
@@ -6,7 +6,7 @@
6
6
  "_sd": ["sd_array"]
7
7
  },
8
8
  "presentationFrames": { "sd_array": true },
9
- "presenatedClaims": {
9
+ "presentedClaims": {
10
10
  "sd_array": ["32", "23"]
11
11
  },
12
12
  "requiredClaimKeys": ["sd_array"]
@@ -22,7 +22,7 @@
22
22
  }
23
23
  }
24
24
  },
25
- "presenatedClaims": {
25
+ "presentedClaims": {
26
26
  "nested_array": [["foo"], ["qux"]]
27
27
  },
28
28
  "requiredClaimKeys": ["nested_array.0.0", "nested_array.1.0"]
@@ -12,6 +12,6 @@
12
12
  }
13
13
  },
14
14
  "presentationFrames": {},
15
- "presenatedClaims": {},
15
+ "presentedClaims": {},
16
16
  "requiredClaimKeys": []
17
17
  }
@@ -8,7 +8,7 @@
8
8
  }
9
9
  },
10
10
  "presentationFrames": {},
11
- "presenatedClaims": {
11
+ "presentedClaims": {
12
12
  "null_values": [null, null]
13
13
  },
14
14
  "requiredClaimKeys": ["null_values.0", "null_values.1"]
@@ -36,7 +36,7 @@
36
36
  "foo": true
37
37
  }
38
38
  },
39
- "presenatedClaims": {
39
+ "presentedClaims": {
40
40
  "addresses": [
41
41
  {
42
42
  "street": "123 Main St",
@@ -12,7 +12,7 @@
12
12
  "1": true
13
13
  }
14
14
  },
15
- "presenatedClaims": {
15
+ "presentedClaims": {
16
16
  "nationalities": ["CA", "DE"]
17
17
  },
18
18
  "requiredClaimKeys": ["nationalities.0", "nationalities.1"]
@@ -27,7 +27,7 @@
27
27
  }
28
28
  },
29
29
  "presentationFrames": {},
30
- "presenatedClaims": {
30
+ "presentedClaims": {
31
31
  "array_with_recursive_sd": ["boring", []],
32
32
  "test2": []
33
33
  },
@@ -39,7 +39,7 @@
39
39
  "1": true
40
40
  }
41
41
  },
42
- "presenatedClaims": {
42
+ "presentedClaims": {
43
43
  "array_with_recursive_sd": [
44
44
  "boring",
45
45
  {
package/test/complex.json CHANGED
@@ -32,7 +32,7 @@
32
32
  }
33
33
  },
34
34
  "presentationFrames": { "firstname": true, "id": true },
35
- "presenatedClaims": {
35
+ "presentedClaims": {
36
36
  "lastname": "Doe",
37
37
  "ssn": "123-45-6789",
38
38
  "data": { "firstname": "John", "lastname": "Doe", "ssn": "123-45-6789" },
@@ -29,7 +29,7 @@
29
29
  "family_name": true,
30
30
  "address": true
31
31
  },
32
- "presenatedClaims": {
32
+ "presentedClaims": {
33
33
  "given_name": "John",
34
34
  "family_name": "Deo",
35
35
  "address": {
@@ -29,7 +29,7 @@
29
29
  "family_name": true,
30
30
  "address": true
31
31
  },
32
- "presenatedClaims": {
32
+ "presentedClaims": {
33
33
  "given_name": "John",
34
34
  "family_name": "Deo",
35
35
  "address": {
@@ -29,7 +29,7 @@
29
29
  "family_name": true,
30
30
  "address": true
31
31
  },
32
- "presenatedClaims": {
32
+ "presentedClaims": {
33
33
  "given_name": "John",
34
34
  "family_name": "Deo",
35
35
  "address": {
package/test/no_sd.json CHANGED
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "disclosureFrame": {},
16
16
  "presentationFrames": {},
17
- "presenatedClaims": {
17
+ "presentedClaims": {
18
18
  "recursive": [
19
19
  "boring",
20
20
  {
@@ -36,7 +36,7 @@
36
36
  "test_object": true
37
37
  }
38
38
  },
39
- "presenatedClaims": {
39
+ "presentedClaims": {
40
40
  "value_Data_types": {
41
41
  "test_null": null,
42
42
  "test_int": 42,
@@ -86,7 +86,7 @@
86
86
  }
87
87
  }
88
88
  },
89
- "presenatedClaims": {
89
+ "presentedClaims": {
90
90
  "foo": ["two"],
91
91
  "bar": {
92
92
  "green": 2