@sd-jwt/sd-jwt-vc 0.17.2-next.0 → 0.17.2-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 +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +4 -1
- package/dist/index.mjs +4 -1
- package/package.json +9 -9
- package/src/sd-jwt-vc-instance.ts +5 -1
- package/src/sd-jwt-vc-payload.ts +1 -1
- package/src/sd-jwt-vc-type-metadata-format.ts +1 -1
- package/src/test/vct.spec.ts +15 -3
package/dist/index.d.mts
CHANGED
|
@@ -126,7 +126,7 @@ type TypeMetadataFormat = {
|
|
|
126
126
|
/** OPTIONAL. URI of another type that this one extends. */
|
|
127
127
|
extends?: string;
|
|
128
128
|
/** OPTIONAL. Integrity metadata for the 'extends' field. */
|
|
129
|
-
'extends#
|
|
129
|
+
'extends#integrity'?: string;
|
|
130
130
|
/** OPTIONAL. Array of localized display metadata for the type. */
|
|
131
131
|
display?: Display[];
|
|
132
132
|
/** OPTIONAL. Array of claim metadata. */
|
|
@@ -162,7 +162,7 @@ interface SdJwtVcPayload extends SdJwtPayload {
|
|
|
162
162
|
exp?: number;
|
|
163
163
|
cnf?: unknown;
|
|
164
164
|
vct: string;
|
|
165
|
-
'vct#
|
|
165
|
+
'vct#integrity'?: string;
|
|
166
166
|
status?: SDJWTVCStatusReference;
|
|
167
167
|
sub?: string;
|
|
168
168
|
iat?: number;
|
|
@@ -209,6 +209,9 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
209
209
|
verify(encodedSDJwt: string, options?: VerifierOptions): Promise<VerificationResult>;
|
|
210
210
|
/**
|
|
211
211
|
* 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.
|
|
212
|
+
*
|
|
213
|
+
* It may return `undefined` if the fetcher returned an undefined value (instead of throwing an error).
|
|
214
|
+
*
|
|
212
215
|
* @param encodedSDJwt
|
|
213
216
|
* @returns
|
|
214
217
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -126,7 +126,7 @@ type TypeMetadataFormat = {
|
|
|
126
126
|
/** OPTIONAL. URI of another type that this one extends. */
|
|
127
127
|
extends?: string;
|
|
128
128
|
/** OPTIONAL. Integrity metadata for the 'extends' field. */
|
|
129
|
-
'extends#
|
|
129
|
+
'extends#integrity'?: string;
|
|
130
130
|
/** OPTIONAL. Array of localized display metadata for the type. */
|
|
131
131
|
display?: Display[];
|
|
132
132
|
/** OPTIONAL. Array of claim metadata. */
|
|
@@ -162,7 +162,7 @@ interface SdJwtVcPayload extends SdJwtPayload {
|
|
|
162
162
|
exp?: number;
|
|
163
163
|
cnf?: unknown;
|
|
164
164
|
vct: string;
|
|
165
|
-
'vct#
|
|
165
|
+
'vct#integrity'?: string;
|
|
166
166
|
status?: SDJWTVCStatusReference;
|
|
167
167
|
sub?: string;
|
|
168
168
|
iat?: number;
|
|
@@ -209,6 +209,9 @@ declare class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
209
209
|
verify(encodedSDJwt: string, options?: VerifierOptions): Promise<VerificationResult>;
|
|
210
210
|
/**
|
|
211
211
|
* 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.
|
|
212
|
+
*
|
|
213
|
+
* It may return `undefined` if the fetcher returned an undefined value (instead of throwing an error).
|
|
214
|
+
*
|
|
212
215
|
* @param encodedSDJwt
|
|
213
216
|
* @returns
|
|
214
217
|
*/
|
package/dist/index.js
CHANGED
|
@@ -138,6 +138,9 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
|
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* 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.
|
|
141
|
+
*
|
|
142
|
+
* It may return `undefined` if the fetcher returned an undefined value (instead of throwing an error).
|
|
143
|
+
*
|
|
141
144
|
* @param encodedSDJwt
|
|
142
145
|
* @returns
|
|
143
146
|
*/
|
|
@@ -235,7 +238,7 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
|
|
|
235
238
|
return this.fetchVctFromHeader(result.payload.vct, result);
|
|
236
239
|
}
|
|
237
240
|
const fetcher = (_b = this.userConfig.vctFetcher) != null ? _b : ((uri, integrity) => this.fetch(uri, integrity));
|
|
238
|
-
return fetcher(result.payload.vct, result.payload["vct#
|
|
241
|
+
return fetcher(result.payload.vct, result.payload["vct#integrity"]);
|
|
239
242
|
});
|
|
240
243
|
}
|
|
241
244
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -116,6 +116,9 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
|
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* 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.
|
|
119
|
+
*
|
|
120
|
+
* It may return `undefined` if the fetcher returned an undefined value (instead of throwing an error).
|
|
121
|
+
*
|
|
119
122
|
* @param encodedSDJwt
|
|
120
123
|
* @returns
|
|
121
124
|
*/
|
|
@@ -213,7 +216,7 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
|
|
|
213
216
|
return this.fetchVctFromHeader(result.payload.vct, result);
|
|
214
217
|
}
|
|
215
218
|
const fetcher = (_b = this.userConfig.vctFetcher) != null ? _b : ((uri, integrity) => this.fetch(uri, integrity));
|
|
216
|
-
return fetcher(result.payload.vct, result.payload["vct#
|
|
219
|
+
return fetcher(result.payload.vct, result.payload["vct#integrity"]);
|
|
217
220
|
});
|
|
218
221
|
}
|
|
219
222
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sd-jwt/sd-jwt-vc",
|
|
3
|
-
"version": "0.17.2-next.
|
|
3
|
+
"version": "0.17.2-next.2+4a4c1b0",
|
|
4
4
|
"description": "sd-jwt draft 7 implementation in typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
},
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@sd-jwt/core": "0.17.2-next.
|
|
42
|
-
"@sd-jwt/jwt-status-list": "0.17.2-next.
|
|
43
|
-
"@sd-jwt/utils": "0.17.2-next.
|
|
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"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@sd-jwt/crypto-nodejs": "0.17.2-next.
|
|
47
|
-
"@sd-jwt/types": "0.17.2-next.
|
|
48
|
-
"jose": "^6.1.
|
|
49
|
-
"msw": "^2.
|
|
46
|
+
"@sd-jwt/crypto-nodejs": "0.17.2-next.2+4a4c1b0",
|
|
47
|
+
"@sd-jwt/types": "0.17.2-next.2+4a4c1b0",
|
|
48
|
+
"jose": "^6.1.2",
|
|
49
|
+
"msw": "^2.12.3"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"esm"
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "4a4c1b0c04615bcf0e455d51cd1b9234cbcd0d78"
|
|
68
68
|
}
|
|
@@ -128,6 +128,9 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
130
|
* 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.
|
|
131
|
+
*
|
|
132
|
+
* It may return `undefined` if the fetcher returned an undefined value (instead of throwing an error).
|
|
133
|
+
*
|
|
131
134
|
* @param encodedSDJwt
|
|
132
135
|
* @returns
|
|
133
136
|
*/
|
|
@@ -222,6 +225,7 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
222
225
|
// implement based on https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-08.html#name-extending-type-metadata
|
|
223
226
|
//TODO: needs to be implemented. Unclear at this point which values will overwrite the values from the extended type metadata format
|
|
224
227
|
}
|
|
228
|
+
|
|
225
229
|
return typeMetadataFormat;
|
|
226
230
|
}
|
|
227
231
|
|
|
@@ -244,7 +248,7 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
244
248
|
const fetcher: VcTFetcher =
|
|
245
249
|
this.userConfig.vctFetcher ??
|
|
246
250
|
((uri, integrity) => this.fetch(uri, integrity));
|
|
247
|
-
return fetcher(result.payload.vct, result.payload['vct#
|
|
251
|
+
return fetcher(result.payload.vct, result.payload['vct#integrity']);
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
/**
|
package/src/sd-jwt-vc-payload.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface SdJwtVcPayload extends SdJwtPayload {
|
|
|
13
13
|
// REQUIRED. The type of the Verifiable Credential, e.g., https://credentials.example.com/identity_credential, as defined in Section 3.2.2.1.1.
|
|
14
14
|
vct: string;
|
|
15
15
|
// OPTIONAL. If passed, the loaded type metadata format has to be validated according to https://www.w3.org/TR/SRI/
|
|
16
|
-
'vct#
|
|
16
|
+
'vct#integrity'?: string;
|
|
17
17
|
// OPTIONAL. The information on how to read the status of the Verifiable Credential. See [https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-02.html] for more information.
|
|
18
18
|
status?: SDJWTVCStatusReference;
|
|
19
19
|
// OPTIONAL. The identifier of the Subject of the Verifiable Credential. The Issuer MAY use it to provide the Subject identifier known by the Issuer. There is no requirement for a binding to exist between sub and cnf claims.
|
|
@@ -136,7 +136,7 @@ export type TypeMetadataFormat = {
|
|
|
136
136
|
/** OPTIONAL. URI of another type that this one extends. */
|
|
137
137
|
extends?: string;
|
|
138
138
|
/** OPTIONAL. Integrity metadata for the 'extends' field. */
|
|
139
|
-
'extends#
|
|
139
|
+
'extends#integrity'?: string;
|
|
140
140
|
/** OPTIONAL. Array of localized display metadata for the type. */
|
|
141
141
|
display?: Display[];
|
|
142
142
|
/** OPTIONAL. Array of claim metadata. */
|
package/src/test/vct.spec.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { digest, generateSalt } from '@sd-jwt/crypto-nodejs';
|
|
|
4
4
|
import type { DisclosureFrame, Signer, Verifier } from '@sd-jwt/types';
|
|
5
5
|
import { HttpResponse, http } from 'msw';
|
|
6
6
|
import { setupServer } from 'msw/node';
|
|
7
|
-
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
|
|
7
|
+
import { afterAll, beforeAll, describe, expect, test, vitest } from 'vitest';
|
|
8
8
|
import { SDJwtVcInstance } from '..';
|
|
9
9
|
import type { SdJwtVcPayload } from '../sd-jwt-vc-payload';
|
|
10
10
|
import type { TypeMetadataFormat } from '../sd-jwt-vc-type-metadata-format';
|
|
@@ -85,19 +85,31 @@ describe('App', () => {
|
|
|
85
85
|
afterEach(() => server.resetHandlers());
|
|
86
86
|
|
|
87
87
|
test('VCT Validation', async () => {
|
|
88
|
+
// The method is private, so TS complains, but you can use spies on private method just fine.
|
|
89
|
+
// @ts-expect-error
|
|
90
|
+
const validateIntegritySpy = vitest.spyOn(sdjwt, 'validateIntegrity');
|
|
91
|
+
|
|
88
92
|
const expectedPayload: SdJwtVcPayload = {
|
|
89
93
|
iat,
|
|
90
94
|
iss,
|
|
91
95
|
vct,
|
|
92
|
-
'vct#
|
|
96
|
+
'vct#integrity': vctIntegrity,
|
|
93
97
|
...claims,
|
|
94
98
|
};
|
|
99
|
+
|
|
95
100
|
const encodedSdjwt = await sdjwt.issue(
|
|
96
101
|
expectedPayload,
|
|
97
102
|
disclosureFrame as unknown as DisclosureFrame<SdJwtVcPayload>,
|
|
98
103
|
);
|
|
99
104
|
|
|
100
105
|
await sdjwt.verify(encodedSdjwt);
|
|
106
|
+
|
|
107
|
+
// Ensure validateIntegrity method was called
|
|
108
|
+
expect(validateIntegritySpy).toHaveBeenCalledWith(
|
|
109
|
+
expect.any(Response),
|
|
110
|
+
vct,
|
|
111
|
+
vctIntegrity,
|
|
112
|
+
);
|
|
101
113
|
});
|
|
102
114
|
|
|
103
115
|
test('VCT from JWT header Validation', async () => {
|
|
@@ -133,7 +145,7 @@ describe('App', () => {
|
|
|
133
145
|
disclosureFrame as unknown as DisclosureFrame<SdJwtVcPayload>,
|
|
134
146
|
);
|
|
135
147
|
|
|
136
|
-
expect(sdjwt.verify(encodedSdjwt)).rejects.toThrowError(
|
|
148
|
+
await expect(sdjwt.verify(encodedSdjwt)).rejects.toThrowError(
|
|
137
149
|
`Request to ${vct} timed out`,
|
|
138
150
|
);
|
|
139
151
|
});
|