@sd-jwt/sd-jwt-vc 0.3.2-next.99 → 0.4.1-next.12

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/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # 0.4.0 (2024-03-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * change SDJwtPayload to SdJwtPayload ([9f06ef7](https://github.com/openwallet-foundation-labs/sd-jwt-js/commit/9f06ef7bd31a1dff4e9bf988e425200a5e1aa82d))
12
+ * make sdjwt instance non abstract ([#122](https://github.com/openwallet-foundation-labs/sd-jwt-js/issues/122)) ([e85aae8](https://github.com/openwallet-foundation-labs/sd-jwt-js/commit/e85aae89910f5d9468e29ef14ef3b3d3215b86fd))
13
+
14
+
15
+ ### Features
16
+
17
+ * add new package for sd-jwt-vc ([ed99188](https://github.com/openwallet-foundation-labs/sd-jwt-js/commit/ed99188f13184d58db64b4211e39fb67f3f78cb5))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sd-jwt/sd-jwt-vc",
3
- "version": "0.3.2-next.99+94f33f1",
3
+ "version": "0.4.1-next.12+eb259c7",
4
4
  "description": "sd-jwt draft 7 implementation in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -39,11 +39,11 @@
39
39
  },
40
40
  "license": "Apache-2.0",
41
41
  "dependencies": {
42
- "@sd-jwt/core": "0.3.2-next.99+94f33f1"
42
+ "@sd-jwt/core": "0.4.1-next.12+eb259c7"
43
43
  },
44
44
  "devDependencies": {
45
- "@sd-jwt/crypto-nodejs": "0.3.2-next.99+94f33f1",
46
- "@sd-jwt/types": "0.3.2-next.99+94f33f1"
45
+ "@sd-jwt/crypto-nodejs": "0.4.1-next.12+eb259c7",
46
+ "@sd-jwt/types": "0.4.1-next.12+eb259c7"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
@@ -61,5 +61,5 @@
61
61
  "esm"
62
62
  ]
63
63
  },
64
- "gitHead": "94f33f1931393345ad1d0977adad67d407615607"
64
+ "gitHead": "eb259c74a386b0ca867b373f6ffa08b6b6b78d7b"
65
65
  }
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { SDJwtInstance } from '@sd-jwt/core';
2
- import { DisclosureFrame } from '@sd-jwt/types';
2
+ import type { DisclosureFrame } from '@sd-jwt/types';
3
3
  import { SDJWTException } from '../../utils/dist';
4
- import { SdJwtVcPayload } from './sd-jwt-vc-payload';
4
+ import type { SdJwtVcPayload } from './sd-jwt-vc-payload';
5
5
 
6
6
  export { SdJwtVcPayload } from './sd-jwt-vc-payload';
7
7
 
@@ -1,4 +1,4 @@
1
- import { SdJwtPayload } from '@sd-jwt/core';
1
+ import type { SdJwtPayload } from '@sd-jwt/core';
2
2
 
3
3
  export interface SdJwtVcPayload extends SdJwtPayload {
4
4
  // The Issuer of the Verifiable Credential. The value of iss MUST be a URI. See [RFC7519] for more information.
@@ -1,9 +1,9 @@
1
1
  import { digest, generateSalt } from '@sd-jwt/crypto-nodejs';
2
- import { DisclosureFrame } from '@sd-jwt/types';
2
+ import type { DisclosureFrame } from '@sd-jwt/types';
3
3
  import { describe, test, expect } from 'vitest';
4
4
  import { SDJwtVcInstance } from '..';
5
5
  import { createSignerVerifier } from '../../test/app-e2e.spec';
6
- import { SdJwtVcPayload } from '../sd-jwt-vc-payload';
6
+ import type { SdJwtVcPayload } from '../sd-jwt-vc-payload';
7
7
 
8
8
  const iss = 'ExampleIssuer';
9
9
  const vct = 'https://example.com/schema/1';
@@ -1,8 +1,13 @@
1
1
  import Crypto from 'node:crypto';
2
2
  import { SDJwtVcInstance, SdJwtVcPayload } from '../src/index';
3
- import { DisclosureFrame, Signer, Verifier } from '@sd-jwt/types';
4
- import fs from 'fs';
5
- import path from 'path';
3
+ import type {
4
+ DisclosureFrame,
5
+ PresentationFrame,
6
+ Signer,
7
+ Verifier,
8
+ } from '@sd-jwt/types';
9
+ import fs from 'node:fs';
10
+ import path from 'node:path';
6
11
  import { describe, expect, test } from 'vitest';
7
12
  import { digest, generateSalt } from '@sd-jwt/crypto-nodejs';
8
13
 
@@ -53,6 +58,9 @@ describe('App', () => {
53
58
  data2: {
54
59
  hi: 'bye',
55
60
  },
61
+ iat,
62
+ iss,
63
+ vct,
56
64
  };
57
65
  const disclosureFrame: DisclosureFrame<typeof claims> = {
58
66
  _sd: ['firstname', 'id', 'data2'],
@@ -72,8 +80,7 @@ describe('App', () => {
72
80
  },
73
81
  };
74
82
 
75
- const expectedPayload: SdJwtVcPayload = { iat, iss, vct, ...claims };
76
- const encodedSdjwt = await sdjwt.issue(expectedPayload, disclosureFrame);
83
+ const encodedSdjwt = await sdjwt.issue(claims, disclosureFrame);
77
84
  expect(encodedSdjwt).toBeDefined();
78
85
  const validated = await sdjwt.validate(encodedSdjwt);
79
86
  expect(validated).toBeDefined();
@@ -101,7 +108,7 @@ describe('App', () => {
101
108
  'vct',
102
109
  ]);
103
110
  const payloads = await decoded.getClaims(digest);
104
- expect(payloads).toEqual(expectedPayload);
111
+ expect(payloads).toEqual(claims);
105
112
  const presentableKeys = await decoded.presentableKeys(digest);
106
113
  expect(presentableKeys).toEqual([
107
114
  'data.list',
@@ -114,7 +121,10 @@ describe('App', () => {
114
121
  'id',
115
122
  ]);
116
123
 
117
- const presentationFrame = ['firstname', 'id'];
124
+ const presentationFrame = {
125
+ firstname: true,
126
+ id: true,
127
+ };
118
128
  const presentedSDJwt = await sdjwt.present(encodedSdjwt, presentationFrame);
119
129
  expect(presentedSDJwt).toBeDefined();
120
130
 
@@ -228,7 +238,7 @@ async function JSONtest(filename: string) {
228
238
 
229
239
  const presentedSDJwt = await sdjwt.present(
230
240
  encodedSdjwt,
231
- test.presentationKeys,
241
+ test.presentationFrames,
232
242
  );
233
243
 
234
244
  expect(presentedSDJwt).toBeDefined();
@@ -254,7 +264,7 @@ async function JSONtest(filename: string) {
254
264
  type TestJson = {
255
265
  claims: object;
256
266
  disclosureFrame: DisclosureFrame<object>;
257
- presentationKeys: string[];
267
+ presentationFrames: PresentationFrame<object>;
258
268
  presenatedClaims: object;
259
269
  requiredClaimKeys: string[];
260
270
  };
@@ -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": {