@sd-jwt/sd-jwt-vc 0.12.1-next.1 → 0.12.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/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -9
- package/dist/index.mjs +10 -9
- package/package.json +7 -7
- package/src/sd-jwt-vc-instance.ts +9 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDJWTConfig, kbPayload, kbHeader, DisclosureFrame } from '@sd-jwt/types';
|
|
2
|
-
import { SdJwtPayload, SDJwtInstance } from '@sd-jwt/core';
|
|
2
|
+
import { SdJwtPayload, SDJwtInstance, VerifierOptions } from '@sd-jwt/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Logo metadata used in rendering a credential.
|
|
@@ -217,7 +217,7 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
217
217
|
* Verifies the SD-JWT-VC. It will validate the signature, the keybindings when required, the status, and the VCT.
|
|
218
218
|
* @param currentDate current time in seconds
|
|
219
219
|
*/
|
|
220
|
-
verify(encodedSDJwt: string, requiredClaimKeys?: string[], requireKeyBindings?: boolean,
|
|
220
|
+
verify(encodedSDJwt: string, requiredClaimKeys?: string[], requireKeyBindings?: boolean, options?: VerifierOptions): Promise<VerificationResult>;
|
|
221
221
|
/**
|
|
222
222
|
* Gets VCT Metadata of the raw SD-JWT-VC. Returns the type metadata format. If the SD-JWT-VC is invalid or does not contain a vct claim, an error is thrown.
|
|
223
223
|
* @param encodedSDJwt
|
|
@@ -257,7 +257,7 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
257
257
|
/**
|
|
258
258
|
* Verifies the status of the SD-JWT-VC.
|
|
259
259
|
* @param result
|
|
260
|
-
* @param
|
|
260
|
+
* @param options
|
|
261
261
|
*/
|
|
262
262
|
private verifyStatus;
|
|
263
263
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDJWTConfig, kbPayload, kbHeader, DisclosureFrame } from '@sd-jwt/types';
|
|
2
|
-
import { SdJwtPayload, SDJwtInstance } from '@sd-jwt/core';
|
|
2
|
+
import { SdJwtPayload, SDJwtInstance, VerifierOptions } from '@sd-jwt/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Logo metadata used in rendering a credential.
|
|
@@ -217,7 +217,7 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
217
217
|
* Verifies the SD-JWT-VC. It will validate the signature, the keybindings when required, the status, and the VCT.
|
|
218
218
|
* @param currentDate current time in seconds
|
|
219
219
|
*/
|
|
220
|
-
verify(encodedSDJwt: string, requiredClaimKeys?: string[], requireKeyBindings?: boolean,
|
|
220
|
+
verify(encodedSDJwt: string, requiredClaimKeys?: string[], requireKeyBindings?: boolean, options?: VerifierOptions): Promise<VerificationResult>;
|
|
221
221
|
/**
|
|
222
222
|
* Gets VCT Metadata of the raw SD-JWT-VC. Returns the type metadata format. If the SD-JWT-VC is invalid or does not contain a vct claim, an error is thrown.
|
|
223
223
|
* @param encodedSDJwt
|
|
@@ -257,7 +257,7 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
257
257
|
/**
|
|
258
258
|
* Verifies the status of the SD-JWT-VC.
|
|
259
259
|
* @param result
|
|
260
|
-
* @param
|
|
260
|
+
* @param options
|
|
261
261
|
*/
|
|
262
262
|
private verifyStatus;
|
|
263
263
|
}
|
package/dist/index.js
CHANGED
|
@@ -131,8 +131,8 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
|
|
|
131
131
|
* Verifies the SD-JWT-VC. It will validate the signature, the keybindings when required, the status, and the VCT.
|
|
132
132
|
* @param currentDate current time in seconds
|
|
133
133
|
*/
|
|
134
|
-
verify(
|
|
135
|
-
return __async(this,
|
|
134
|
+
verify(encodedSDJwt, requiredClaimKeys, requireKeyBindings, options) {
|
|
135
|
+
return __async(this, null, function* () {
|
|
136
136
|
const result = yield __superGet(_SDJwtVcInstance.prototype, this, "verify").call(this, encodedSDJwt, requiredClaimKeys, requireKeyBindings).then((res) => {
|
|
137
137
|
return {
|
|
138
138
|
payload: res.payload,
|
|
@@ -140,7 +140,7 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
|
|
|
140
140
|
kb: res.kb
|
|
141
141
|
};
|
|
142
142
|
});
|
|
143
|
-
yield this.verifyStatus(result,
|
|
143
|
+
yield this.verifyStatus(result, options);
|
|
144
144
|
if (this.userConfig.loadTypeMetadataFormat) {
|
|
145
145
|
yield this.verifyVct(result);
|
|
146
146
|
}
|
|
@@ -292,11 +292,11 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
|
|
|
292
292
|
/**
|
|
293
293
|
* Verifies the status of the SD-JWT-VC.
|
|
294
294
|
* @param result
|
|
295
|
-
* @param
|
|
295
|
+
* @param options
|
|
296
296
|
*/
|
|
297
|
-
verifyStatus(result,
|
|
297
|
+
verifyStatus(result, options) {
|
|
298
298
|
return __async(this, null, function* () {
|
|
299
|
-
var _a, _b, _c;
|
|
299
|
+
var _a, _b, _c, _d;
|
|
300
300
|
if (result.payload.status) {
|
|
301
301
|
if (result.payload.status.status_list) {
|
|
302
302
|
const fetcher = (_a = this.userConfig.statusListFetcher) != null ? _a : this.statusListFetcher.bind(this);
|
|
@@ -304,15 +304,16 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
|
|
|
304
304
|
result.payload.status.status_list.uri
|
|
305
305
|
);
|
|
306
306
|
const slJWT = import_core.Jwt.fromEncode(statusListJWT);
|
|
307
|
-
yield slJWT.verify(this.userConfig.verifier,
|
|
308
|
-
|
|
307
|
+
yield slJWT.verify(this.userConfig.verifier, options);
|
|
308
|
+
const currentDate = (_b = options == null ? void 0 : options.currentDate) != null ? _b : Math.floor(Date.now() / 1e3);
|
|
309
|
+
if (((_c = slJWT.payload) == null ? void 0 : _c.exp) && slJWT.payload.exp < currentDate) {
|
|
309
310
|
throw new import_utils.SDJWTException("Status list is expired");
|
|
310
311
|
}
|
|
311
312
|
const statusList = (0, import_jwt_status_list.getListFromStatusListJWT)(statusListJWT);
|
|
312
313
|
const status = statusList.getStatus(
|
|
313
314
|
result.payload.status.status_list.idx
|
|
314
315
|
);
|
|
315
|
-
const statusValidator = (
|
|
316
|
+
const statusValidator = (_d = this.userConfig.statusValidator) != null ? _d : this.statusValidator.bind(this);
|
|
316
317
|
yield statusValidator(status);
|
|
317
318
|
}
|
|
318
319
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -99,8 +99,8 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
|
|
|
99
99
|
* Verifies the SD-JWT-VC. It will validate the signature, the keybindings when required, the status, and the VCT.
|
|
100
100
|
* @param currentDate current time in seconds
|
|
101
101
|
*/
|
|
102
|
-
verify(
|
|
103
|
-
return __async(this,
|
|
102
|
+
verify(encodedSDJwt, requiredClaimKeys, requireKeyBindings, options) {
|
|
103
|
+
return __async(this, null, function* () {
|
|
104
104
|
const result = yield __superGet(_SDJwtVcInstance.prototype, this, "verify").call(this, encodedSDJwt, requiredClaimKeys, requireKeyBindings).then((res) => {
|
|
105
105
|
return {
|
|
106
106
|
payload: res.payload,
|
|
@@ -108,7 +108,7 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
|
|
|
108
108
|
kb: res.kb
|
|
109
109
|
};
|
|
110
110
|
});
|
|
111
|
-
yield this.verifyStatus(result,
|
|
111
|
+
yield this.verifyStatus(result, options);
|
|
112
112
|
if (this.userConfig.loadTypeMetadataFormat) {
|
|
113
113
|
yield this.verifyVct(result);
|
|
114
114
|
}
|
|
@@ -260,11 +260,11 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
|
|
|
260
260
|
/**
|
|
261
261
|
* Verifies the status of the SD-JWT-VC.
|
|
262
262
|
* @param result
|
|
263
|
-
* @param
|
|
263
|
+
* @param options
|
|
264
264
|
*/
|
|
265
|
-
verifyStatus(result,
|
|
265
|
+
verifyStatus(result, options) {
|
|
266
266
|
return __async(this, null, function* () {
|
|
267
|
-
var _a, _b, _c;
|
|
267
|
+
var _a, _b, _c, _d;
|
|
268
268
|
if (result.payload.status) {
|
|
269
269
|
if (result.payload.status.status_list) {
|
|
270
270
|
const fetcher = (_a = this.userConfig.statusListFetcher) != null ? _a : this.statusListFetcher.bind(this);
|
|
@@ -272,15 +272,16 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
|
|
|
272
272
|
result.payload.status.status_list.uri
|
|
273
273
|
);
|
|
274
274
|
const slJWT = Jwt.fromEncode(statusListJWT);
|
|
275
|
-
yield slJWT.verify(this.userConfig.verifier,
|
|
276
|
-
|
|
275
|
+
yield slJWT.verify(this.userConfig.verifier, options);
|
|
276
|
+
const currentDate = (_b = options == null ? void 0 : options.currentDate) != null ? _b : Math.floor(Date.now() / 1e3);
|
|
277
|
+
if (((_c = slJWT.payload) == null ? void 0 : _c.exp) && slJWT.payload.exp < currentDate) {
|
|
277
278
|
throw new SDJWTException("Status list is expired");
|
|
278
279
|
}
|
|
279
280
|
const statusList = getListFromStatusListJWT(statusListJWT);
|
|
280
281
|
const status = statusList.getStatus(
|
|
281
282
|
result.payload.status.status_list.idx
|
|
282
283
|
);
|
|
283
|
-
const statusValidator = (
|
|
284
|
+
const statusValidator = (_d = this.userConfig.statusValidator) != null ? _d : this.statusValidator.bind(this);
|
|
284
285
|
yield statusValidator(status);
|
|
285
286
|
}
|
|
286
287
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sd-jwt/sd-jwt-vc",
|
|
3
|
-
"version": "0.12.1-next.
|
|
3
|
+
"version": "0.12.1-next.2+1eefb26",
|
|
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.12.1-next.
|
|
43
|
-
"@sd-jwt/jwt-status-list": "0.12.1-next.
|
|
44
|
-
"@sd-jwt/utils": "0.12.1-next.
|
|
42
|
+
"@sd-jwt/core": "0.12.1-next.2+1eefb26",
|
|
43
|
+
"@sd-jwt/jwt-status-list": "0.12.1-next.2+1eefb26",
|
|
44
|
+
"@sd-jwt/utils": "0.12.1-next.2+1eefb26",
|
|
45
45
|
"ajv": "^8.17.1",
|
|
46
46
|
"ajv-formats": "^3.0.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@sd-jwt/crypto-nodejs": "0.12.1-next.
|
|
50
|
-
"@sd-jwt/types": "0.12.1-next.
|
|
49
|
+
"@sd-jwt/crypto-nodejs": "0.12.1-next.2+1eefb26",
|
|
50
|
+
"@sd-jwt/types": "0.12.1-next.2+1eefb26",
|
|
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": "
|
|
70
|
+
"gitHead": "1eefb262c40ea23e999cdef6e75222e5b4df1e2c"
|
|
71
71
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Jwt, SDJwt, SDJwtInstance } from '@sd-jwt/core';
|
|
1
|
+
import { Jwt, SDJwt, SDJwtInstance, type VerifierOptions } from '@sd-jwt/core';
|
|
2
2
|
import type { DisclosureFrame, Hasher, Verifier } from '@sd-jwt/types';
|
|
3
3
|
import { SDJWTException } from '@sd-jwt/utils';
|
|
4
4
|
import type { SdJwtVcPayload } from './sd-jwt-vc-payload';
|
|
@@ -110,9 +110,10 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
110
110
|
*/
|
|
111
111
|
async verify(
|
|
112
112
|
encodedSDJwt: string,
|
|
113
|
+
//TODO: we need to move these values in options, causing a breaking change
|
|
113
114
|
requiredClaimKeys?: string[],
|
|
114
115
|
requireKeyBindings?: boolean,
|
|
115
|
-
|
|
116
|
+
options?: VerifierOptions,
|
|
116
117
|
) {
|
|
117
118
|
// Call the parent class's verify method
|
|
118
119
|
const result: VerificationResult = await super
|
|
@@ -125,7 +126,7 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
125
126
|
};
|
|
126
127
|
});
|
|
127
128
|
|
|
128
|
-
await this.verifyStatus(result,
|
|
129
|
+
await this.verifyStatus(result, options);
|
|
129
130
|
if (this.userConfig.loadTypeMetadataFormat) {
|
|
130
131
|
await this.verifyVct(result);
|
|
131
132
|
}
|
|
@@ -302,11 +303,11 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
302
303
|
/**
|
|
303
304
|
* Verifies the status of the SD-JWT-VC.
|
|
304
305
|
* @param result
|
|
305
|
-
* @param
|
|
306
|
+
* @param options
|
|
306
307
|
*/
|
|
307
308
|
private async verifyStatus(
|
|
308
309
|
result: VerificationResult,
|
|
309
|
-
|
|
310
|
+
options?: VerifierOptions,
|
|
310
311
|
): Promise<void> {
|
|
311
312
|
if (result.payload.status) {
|
|
312
313
|
//checks if a status field is present in the payload based on https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-02.html
|
|
@@ -325,8 +326,10 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
325
326
|
StatusListJWTPayload
|
|
326
327
|
>(statusListJWT);
|
|
327
328
|
// check if the status list has a valid signature. The presence of the verifier is checked in the parent class.
|
|
328
|
-
await slJWT.verify(this.userConfig.verifier as Verifier,
|
|
329
|
+
await slJWT.verify(this.userConfig.verifier as Verifier, options);
|
|
329
330
|
|
|
331
|
+
const currentDate =
|
|
332
|
+
options?.currentDate ?? Math.floor(Date.now() / 1000);
|
|
330
333
|
//check if the status list is expired
|
|
331
334
|
if (slJWT.payload?.exp && (slJWT.payload.exp as number) < currentDate) {
|
|
332
335
|
throw new SDJWTException('Status list is expired');
|