@sd-jwt/sd-jwt-vc 0.8.1-next.1 → 0.8.1-next.2

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/README.md CHANGED
@@ -103,7 +103,7 @@ const sdjwt = new SDJwtVcInstance({
103
103
  });
104
104
  ```
105
105
 
106
- The library will load load the type metadata format based on the `vct` value according to the [SD-JWT-VC specification](https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-04.html#name-type-metadata) and validate this schema.
106
+ The library will load load the type metadata format based on the `vct` value according to the [SD-JWT-VC specification](https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-08.html#name-sd-jwt-vc-type-metadata) and validate this schema.
107
107
 
108
108
  Since at this point the display is not yet implemented, the library will only validate the schema and return the type metadata format. In the future the values of the type metadata can be fetched via a function call.
109
109
 
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import { SDJWTConfig, kbPayload, kbHeader, DisclosureFrame } from '@sd-jwt/types
2
2
  import { SdJwtPayload, SDJwtInstance } from '@sd-jwt/core';
3
3
 
4
4
  /**
5
- * https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-04.html#name-type-metadata-format
5
+ * https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-08.html#name-type-metadata-format
6
6
  */
7
7
  type TypeMetadataFormat = {
8
8
  vct: string;
@@ -86,12 +86,6 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
86
86
  * Verifies the SD-JWT-VC. It will validate the signature, the keybindings when required, the status, and the VCT.
87
87
  */
88
88
  verify(encodedSDJwt: string, requiredClaimKeys?: string[], requireKeyBindings?: boolean): Promise<VerificationResult>;
89
- /**
90
- * Default function to fetch the VCT from the uri. We assume that the vct is a URL that is used to fetch the VCT.
91
- * @param uri
92
- * @returns
93
- */
94
- private vctFetcher;
95
89
  /**
96
90
  * Validates the integrity of the response if the integrity is passed. If the integrity does not match, an error is thrown.
97
91
  * @param integrity
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { SDJWTConfig, kbPayload, kbHeader, DisclosureFrame } from '@sd-jwt/types
2
2
  import { SdJwtPayload, SDJwtInstance } from '@sd-jwt/core';
3
3
 
4
4
  /**
5
- * https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-04.html#name-type-metadata-format
5
+ * https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-08.html#name-type-metadata-format
6
6
  */
7
7
  type TypeMetadataFormat = {
8
8
  vct: string;
@@ -86,12 +86,6 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
86
86
  * Verifies the SD-JWT-VC. It will validate the signature, the keybindings when required, the status, and the VCT.
87
87
  */
88
88
  verify(encodedSDJwt: string, requiredClaimKeys?: string[], requireKeyBindings?: boolean): Promise<VerificationResult>;
89
- /**
90
- * Default function to fetch the VCT from the uri. We assume that the vct is a URL that is used to fetch the VCT.
91
- * @param uri
92
- * @returns
93
- */
94
- private vctFetcher;
95
89
  /**
96
90
  * Validates the integrity of the response if the integrity is passed. If the integrity does not match, an error is thrown.
97
91
  * @param integrity
package/dist/index.js CHANGED
@@ -147,19 +147,6 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
147
147
  return result;
148
148
  });
149
149
  }
150
- /**
151
- * Default function to fetch the VCT from the uri. We assume that the vct is a URL that is used to fetch the VCT.
152
- * @param uri
153
- * @returns
154
- */
155
- vctFetcher(uri, integrity) {
156
- return __async(this, null, function* () {
157
- const elements = uri.split("/");
158
- elements.splice(3, 0, ".well-known/vct");
159
- const url = elements.join("/");
160
- return this.fetch(url, integrity);
161
- });
162
- }
163
150
  /**
164
151
  * Validates the integrity of the response if the integrity is passed. If the integrity does not match, an error is thrown.
165
152
  * @param integrity
@@ -234,7 +221,7 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
234
221
  verifyVct(result) {
235
222
  return __async(this, null, function* () {
236
223
  var _a;
237
- const fetcher = (_a = this.userConfig.vctFetcher) != null ? _a : this.vctFetcher.bind(this);
224
+ const fetcher = (_a = this.userConfig.vctFetcher) != null ? _a : (uri, integrity) => this.fetch(uri, integrity);
238
225
  const typeMetadataFormat = yield fetcher(
239
226
  result.payload.vct,
240
227
  result.payload["vct#Integrity"]
package/dist/index.mjs CHANGED
@@ -115,19 +115,6 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
115
115
  return result;
116
116
  });
117
117
  }
118
- /**
119
- * Default function to fetch the VCT from the uri. We assume that the vct is a URL that is used to fetch the VCT.
120
- * @param uri
121
- * @returns
122
- */
123
- vctFetcher(uri, integrity) {
124
- return __async(this, null, function* () {
125
- const elements = uri.split("/");
126
- elements.splice(3, 0, ".well-known/vct");
127
- const url = elements.join("/");
128
- return this.fetch(url, integrity);
129
- });
130
- }
131
118
  /**
132
119
  * Validates the integrity of the response if the integrity is passed. If the integrity does not match, an error is thrown.
133
120
  * @param integrity
@@ -202,7 +189,7 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
202
189
  verifyVct(result) {
203
190
  return __async(this, null, function* () {
204
191
  var _a;
205
- const fetcher = (_a = this.userConfig.vctFetcher) != null ? _a : this.vctFetcher.bind(this);
192
+ const fetcher = (_a = this.userConfig.vctFetcher) != null ? _a : (uri, integrity) => this.fetch(uri, integrity);
206
193
  const typeMetadataFormat = yield fetcher(
207
194
  result.payload.vct,
208
195
  result.payload["vct#Integrity"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sd-jwt/sd-jwt-vc",
3
- "version": "0.8.1-next.1+1562d38",
3
+ "version": "0.8.1-next.2+2358c75",
4
4
  "description": "sd-jwt draft 7 implementation in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -39,15 +39,15 @@
39
39
  },
40
40
  "license": "Apache-2.0",
41
41
  "dependencies": {
42
- "@sd-jwt/core": "0.8.1-next.1+1562d38",
43
- "@sd-jwt/jwt-status-list": "0.8.1-next.1+1562d38",
44
- "@sd-jwt/utils": "0.8.1-next.1+1562d38",
42
+ "@sd-jwt/core": "0.8.1-next.2+2358c75",
43
+ "@sd-jwt/jwt-status-list": "0.8.1-next.2+2358c75",
44
+ "@sd-jwt/utils": "0.8.1-next.2+2358c75",
45
45
  "ajv": "^8.17.1",
46
46
  "ajv-formats": "^3.0.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@sd-jwt/crypto-nodejs": "0.8.1-next.1+1562d38",
50
- "@sd-jwt/types": "0.8.1-next.1+1562d38",
49
+ "@sd-jwt/crypto-nodejs": "0.8.1-next.2+2358c75",
50
+ "@sd-jwt/types": "0.8.1-next.2+2358c75",
51
51
  "jose": "^5.2.2",
52
52
  "msw": "^2.3.5"
53
53
  },
@@ -67,5 +67,5 @@
67
67
  "esm"
68
68
  ]
69
69
  },
70
- "gitHead": "1562d383b9a9b60ec8e175a8a4f2751975859ad3"
70
+ "gitHead": "2358c759887ee29b4c35a3ee0e93ebd8e8c26545"
71
71
  }
@@ -40,7 +40,7 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
40
40
  protected validateReservedFields(
41
41
  disclosureFrame: DisclosureFrame<SdJwtVcPayload>,
42
42
  ): void {
43
- //validate disclosureFrame according to https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-03.html#section-3.2.2.2
43
+ //validate disclosureFrame according to https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-08.html#section-3.2.2.2
44
44
  if (
45
45
  disclosureFrame?._sd &&
46
46
  Array.isArray(disclosureFrame._sd) &&
@@ -130,23 +130,6 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
130
130
  return result;
131
131
  }
132
132
 
133
- /**
134
- * Default function to fetch the VCT from the uri. We assume that the vct is a URL that is used to fetch the VCT.
135
- * @param uri
136
- * @returns
137
- */
138
- private async vctFetcher(
139
- uri: string,
140
- integrity?: string,
141
- ): Promise<TypeMetadataFormat> {
142
- // modify the uri based on https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-04.html#section-6.3.1
143
- const elements = uri.split('/');
144
- //insert a new element on the thrid position, but not replace it
145
- elements.splice(3, 0, '.well-known/vct');
146
- const url = elements.join('/');
147
- return this.fetch<TypeMetadataFormat>(url, integrity);
148
- }
149
-
150
133
  /**
151
134
  * Validates the integrity of the response if the integrity is passed. If the integrity does not match, an error is thrown.
152
135
  * @param integrity
@@ -227,14 +210,15 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
227
210
  result: VerificationResult,
228
211
  ): Promise<TypeMetadataFormat | undefined> {
229
212
  const fetcher: VcTFetcher =
230
- this.userConfig.vctFetcher ?? this.vctFetcher.bind(this);
213
+ this.userConfig.vctFetcher ??
214
+ ((uri, integrity) => this.fetch(uri, integrity));
231
215
  const typeMetadataFormat = await fetcher(
232
216
  result.payload.vct,
233
217
  result.payload['vct#Integrity'],
234
218
  );
235
219
 
236
220
  if (typeMetadataFormat.extends) {
237
- // implement based on https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-04.html#name-extending-type-metadata
221
+ // implement based on https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-08.html#name-extending-type-metadata
238
222
  //TODO: needs to be implemented. Unclear at this point which values will overwrite the values from the extended type metadata format
239
223
  }
240
224
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-04.html#name-type-metadata-format
2
+ * https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-08.html#name-type-metadata-format
3
3
  */
4
4
  export type TypeMetadataFormat = {
5
5
  vct: string; // REQUIRED. A URI that uniquely identifies the type. This URI MUST be dereferenceable to a JSON document that describes the type.
@@ -41,7 +41,7 @@ const restHandlers = [
41
41
  };
42
42
  return HttpResponse.json(res);
43
43
  }),
44
- http.get('http://exmaple.com/.well-known/vct/example', () => {
44
+ http.get('http://exmaple.com/example', () => {
45
45
  const res: TypeMetadataFormat = {
46
46
  vct: 'http://example.com/example',
47
47
  name: 'ExampleCredentialType',