@sphereon/ssi-sdk.sd-jwt 0.33.1-next.3 → 0.33.1-next.73
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.cjs +595 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +334 -0
- package/dist/index.d.ts +334 -4
- package/dist/index.js +562 -20
- package/dist/index.js.map +1 -1
- package/package.json +35 -24
- package/src/__tests__/sd-jwt-integrity.test.ts +1 -1
- package/src/__tests__/sd-jwt.test.ts +2 -1
- package/src/action-handler.ts +2 -2
- package/src/defaultCallbacks.ts +4 -3
- package/src/types.ts +1 -1
- package/src/utils.ts +4 -4
- package/dist/action-handler.d.ts +0 -89
- package/dist/action-handler.d.ts.map +0 -1
- package/dist/action-handler.js +0 -397
- package/dist/action-handler.js.map +0 -1
- package/dist/defaultCallbacks.d.ts +0 -6
- package/dist/defaultCallbacks.d.ts.map +0 -1
- package/dist/defaultCallbacks.js +0 -55
- package/dist/defaultCallbacks.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/trustAnchors.d.ts +0 -3
- package/dist/trustAnchors.d.ts.map +0 -1
- package/dist/trustAnchors.js +0 -20
- package/dist/trustAnchors.js.map +0 -1
- package/dist/types.d.ts +0 -234
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -10
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -18
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -85
- package/dist/utils.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,334 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { SdJwtVcPayload as SdJwtVcPayload$1, SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc';
|
|
2
|
+
import { SaltGenerator, KBOptions, kbHeader, kbPayload, Hasher, Signer, HasherSync as HasherSync$1 } from '@sd-jwt/types';
|
|
3
|
+
import { X509CertificateChainValidationOpts } from '@sphereon/ssi-sdk-ext.x509-utils';
|
|
4
|
+
import { HasherSync, JsonWebKey, SdJwtTypeMetadata, JoseSignatureAlgorithm } from '@sphereon/ssi-types';
|
|
5
|
+
import { IPluginMethodMap, IAgentContext, IDIDManager, IResolver, IKeyManager, DIDDocumentSection, IAgentPlugin } from '@veramo/core';
|
|
6
|
+
import { ManagedIdentifierResult, IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
7
|
+
import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
|
|
8
|
+
import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc';
|
|
9
|
+
|
|
10
|
+
declare const sdJwtPluginContextMethods: Array<string>;
|
|
11
|
+
/**
|
|
12
|
+
* My Agent Plugin description.
|
|
13
|
+
*
|
|
14
|
+
* This is the interface that describes what your plugin can do.
|
|
15
|
+
* The methods listed here, will be directly available to the veramo agent where your plugin is going to be used.
|
|
16
|
+
* Depending on the agent configuration, other agent plugins, as well as the application where the agent is used
|
|
17
|
+
* will be able to call these methods.
|
|
18
|
+
*
|
|
19
|
+
* To build a schema for your plugin using standard tools, you must link to this file in your package.json.
|
|
20
|
+
* Example:
|
|
21
|
+
* ```
|
|
22
|
+
* "veramo": {
|
|
23
|
+
* "pluginInterfaces": {
|
|
24
|
+
* "IMyAgentPlugin": "./src/types/IMyAgentPlugin.ts"
|
|
25
|
+
* }
|
|
26
|
+
* },
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @beta
|
|
30
|
+
*/
|
|
31
|
+
interface ISDJwtPlugin extends IPluginMethodMap {
|
|
32
|
+
/**
|
|
33
|
+
* Your plugin method description
|
|
34
|
+
*
|
|
35
|
+
* @param args - Input parameters for this method
|
|
36
|
+
* @param context - The required context where this method can run.
|
|
37
|
+
* Declaring a context type here lets other developers know which other plugins
|
|
38
|
+
* need to also be installed for this method to work.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Create a signed SD-JWT credential.
|
|
42
|
+
* @param args - Arguments necessary for the creation of a SD-JWT credential.
|
|
43
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
44
|
+
*/
|
|
45
|
+
createSdJwtVc(args: ICreateSdJwtVcArgs, context: IRequiredContext): Promise<ICreateSdJwtVcResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a signed SD-JWT presentation.
|
|
48
|
+
* @param args - Arguments necessary for the creation of a SD-JWT presentation.
|
|
49
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
50
|
+
*/
|
|
51
|
+
createSdJwtPresentation(args: ICreateSdJwtPresentationArgs, context: IRequiredContext): Promise<ICreateSdJwtPresentationResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Verify a signed SD-JWT credential.
|
|
54
|
+
* @param args - Arguments necessary for the verification of a SD-JWT credential.
|
|
55
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
56
|
+
*/
|
|
57
|
+
verifySdJwtVc(args: IVerifySdJwtVcArgs, context: IRequiredContext): Promise<IVerifySdJwtVcResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Verify a signed SD-JWT presentation.
|
|
60
|
+
* @param args - Arguments necessary for the verification of a SD-JWT presentation.
|
|
61
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
62
|
+
*/
|
|
63
|
+
verifySdJwtPresentation(args: IVerifySdJwtPresentationArgs, context: IRequiredContext): Promise<IVerifySdJwtPresentationResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Fetch and validate Type Metadata.
|
|
66
|
+
* @param args - Arguments necessary for fetching and validating the type metadata.
|
|
67
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
68
|
+
*/
|
|
69
|
+
fetchSdJwtTypeMetadataFromVctUrl(args: FetchSdJwtTypeMetadataFromVctUrlArgs, context: IRequiredContext): Promise<SdJwtTypeMetadata>;
|
|
70
|
+
}
|
|
71
|
+
declare function contextHasSDJwtPlugin(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ISDJwtPlugin>;
|
|
72
|
+
/**
|
|
73
|
+
* ICreateSdJwtVcArgs
|
|
74
|
+
*
|
|
75
|
+
* @beta
|
|
76
|
+
*/
|
|
77
|
+
interface SdJwtVcPayload extends SdJwtVcPayload$1 {
|
|
78
|
+
x5c?: string[];
|
|
79
|
+
}
|
|
80
|
+
interface ICreateSdJwtVcArgs {
|
|
81
|
+
credentialPayload: SdJwtVcPayload;
|
|
82
|
+
disclosureFrame?: IDisclosureFrame;
|
|
83
|
+
resolution?: ManagedIdentifierResult;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @beta
|
|
87
|
+
*/
|
|
88
|
+
interface IDisclosureFrame {
|
|
89
|
+
_sd?: string[];
|
|
90
|
+
_sd_decoy?: number;
|
|
91
|
+
[x: string]: string[] | number | IDisclosureFrame | undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* ICreateSdJwtVcResult
|
|
95
|
+
*
|
|
96
|
+
* @beta
|
|
97
|
+
*/
|
|
98
|
+
interface ICreateSdJwtVcResult {
|
|
99
|
+
/**
|
|
100
|
+
* the encoded sd-jwt credential
|
|
101
|
+
*/
|
|
102
|
+
credential: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @beta
|
|
107
|
+
*/
|
|
108
|
+
interface ICreateSdJwtPresentationArgs {
|
|
109
|
+
/**
|
|
110
|
+
* Encoded SD-JWT credential
|
|
111
|
+
*/
|
|
112
|
+
presentation: string;
|
|
113
|
+
presentationFrame?: IPresentationFrame;
|
|
114
|
+
/**
|
|
115
|
+
* Allows to override the holder. Normally it will be looked up from the cnf or sub values
|
|
116
|
+
*/
|
|
117
|
+
holder?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Information to include to add key binding.
|
|
120
|
+
*/
|
|
121
|
+
kb?: KBOptions;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @beta
|
|
125
|
+
*/
|
|
126
|
+
interface IPresentationFrame {
|
|
127
|
+
[x: string]: boolean | IPresentationFrame;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Created presentation
|
|
131
|
+
* @beta
|
|
132
|
+
*/
|
|
133
|
+
interface ICreateSdJwtPresentationResult {
|
|
134
|
+
/**
|
|
135
|
+
* Encoded presentation.
|
|
136
|
+
*/
|
|
137
|
+
presentation: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @beta
|
|
141
|
+
*/
|
|
142
|
+
interface IVerifySdJwtVcArgs {
|
|
143
|
+
credential: string;
|
|
144
|
+
opts?: {
|
|
145
|
+
x5cValidation?: X509CertificateChainValidationOpts;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @beta
|
|
150
|
+
*/
|
|
151
|
+
type IVerifySdJwtVcResult = {
|
|
152
|
+
payload: SdJwtVcPayload$1;
|
|
153
|
+
header: Record<string, unknown>;
|
|
154
|
+
kb?: {
|
|
155
|
+
header: kbHeader;
|
|
156
|
+
payload: kbPayload;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* @beta
|
|
161
|
+
*/
|
|
162
|
+
interface IVerifySdJwtPresentationArgs {
|
|
163
|
+
presentation: string;
|
|
164
|
+
requiredClaimKeys?: string[];
|
|
165
|
+
kb?: boolean;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* @beta
|
|
169
|
+
*/
|
|
170
|
+
type IVerifySdJwtPresentationResult = {
|
|
171
|
+
payload: unknown;
|
|
172
|
+
header: Record<string, unknown> | undefined;
|
|
173
|
+
kb?: {
|
|
174
|
+
header: kbHeader;
|
|
175
|
+
payload: kbPayload;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
type SignKeyArgs = {
|
|
179
|
+
identifier: string;
|
|
180
|
+
vmRelationship: DIDDocumentSection;
|
|
181
|
+
resolution?: ManagedIdentifierResult;
|
|
182
|
+
};
|
|
183
|
+
type SignKeyResult = {
|
|
184
|
+
alg: JoseSignatureAlgorithm;
|
|
185
|
+
key: {
|
|
186
|
+
kid?: string;
|
|
187
|
+
kmsKeyRef: string;
|
|
188
|
+
x5c?: string[];
|
|
189
|
+
jwkThumbprint?: string;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* This context describes the requirements of this plugin.
|
|
194
|
+
* For this plugin to function properly, the agent needs to also have other plugins installed that implement the
|
|
195
|
+
* interfaces declared here.
|
|
196
|
+
* You can also define requirements on a more granular level, for each plugin method or event handler of your plugin.
|
|
197
|
+
*
|
|
198
|
+
* @beta
|
|
199
|
+
*/
|
|
200
|
+
type IRequiredContext = IAgentContext<IDIDManager & IIdentifierResolution & IJwtService & IResolver & IKeyManager & ImDLMdoc>;
|
|
201
|
+
type SdJwtVerifySignature = (data: string, signature: string, publicKey: JsonWebKey) => Promise<boolean>;
|
|
202
|
+
interface SdJWTImplementation {
|
|
203
|
+
saltGenerator?: SaltGenerator;
|
|
204
|
+
hasher?: HasherSync;
|
|
205
|
+
verifySignature?: SdJwtVerifySignature;
|
|
206
|
+
}
|
|
207
|
+
interface Claims {
|
|
208
|
+
/**
|
|
209
|
+
* Subject of the SD-JWT
|
|
210
|
+
*/
|
|
211
|
+
sub?: string;
|
|
212
|
+
cnf?: {
|
|
213
|
+
jwk?: JsonWebKey;
|
|
214
|
+
kid?: string;
|
|
215
|
+
};
|
|
216
|
+
[key: string]: unknown;
|
|
217
|
+
}
|
|
218
|
+
type FetchSdJwtTypeMetadataFromVctUrlArgs = {
|
|
219
|
+
vct: string;
|
|
220
|
+
vctIntegrity?: string;
|
|
221
|
+
opts?: FetchSdJwtTypeMetadataFromVctUrlOpts;
|
|
222
|
+
};
|
|
223
|
+
type FetchSdJwtTypeMetadataFromVctUrlOpts = {
|
|
224
|
+
hasher?: HasherSync | Hasher;
|
|
225
|
+
};
|
|
226
|
+
type GetSignerForIdentifierArgs = {
|
|
227
|
+
identifier: string;
|
|
228
|
+
resolution?: ManagedIdentifierResult;
|
|
229
|
+
};
|
|
230
|
+
type GetSignerResult = {
|
|
231
|
+
signer: Signer;
|
|
232
|
+
alg?: string;
|
|
233
|
+
signingKey?: SignKeyResult;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @beta
|
|
238
|
+
* SD-JWT plugin
|
|
239
|
+
*/
|
|
240
|
+
declare class SDJwtPlugin implements IAgentPlugin {
|
|
241
|
+
private readonly trustAnchorsInPEM;
|
|
242
|
+
private readonly registeredImplementations;
|
|
243
|
+
private _signers;
|
|
244
|
+
private _defaultSigner?;
|
|
245
|
+
constructor(registeredImplementations?: SdJWTImplementation & {
|
|
246
|
+
signers?: Record<string, Signer>;
|
|
247
|
+
defaultSigner?: Signer;
|
|
248
|
+
}, trustAnchorsInPEM?: string[]);
|
|
249
|
+
readonly methods: ISDJwtPlugin;
|
|
250
|
+
private getSignerForIdentifier;
|
|
251
|
+
/**
|
|
252
|
+
* Create a signed SD-JWT credential.
|
|
253
|
+
* @param args - Arguments necessary for the creation of a SD-JWT credential.
|
|
254
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
255
|
+
* @returns A signed SD-JWT credential.
|
|
256
|
+
*/
|
|
257
|
+
createSdJwtVc(args: ICreateSdJwtVcArgs, context: IRequiredContext): Promise<ICreateSdJwtVcResult>;
|
|
258
|
+
/**
|
|
259
|
+
* Get the key to sign the SD-JWT
|
|
260
|
+
* @param args - consists of twp arguments: identifier like a did and other forms of identifiers and vmRelationship which represents the purpose of the key
|
|
261
|
+
* @param context - agent instance
|
|
262
|
+
* @returns the key to sign the SD-JWT
|
|
263
|
+
*/
|
|
264
|
+
getSignKey(args: SignKeyArgs, context: IRequiredContext): Promise<SignKeyResult>;
|
|
265
|
+
/**
|
|
266
|
+
* Create a signed SD-JWT presentation.
|
|
267
|
+
* @param args - Arguments necessary for the creation of a SD-JWT presentation.
|
|
268
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
269
|
+
* @returns A signed SD-JWT presentation.
|
|
270
|
+
*/
|
|
271
|
+
createSdJwtPresentation(args: ICreateSdJwtPresentationArgs, context: IRequiredContext): Promise<ICreateSdJwtPresentationResult>;
|
|
272
|
+
/**
|
|
273
|
+
* Verify a signed SD-JWT credential.
|
|
274
|
+
* @param args - Arguments necessary for the verify a SD-JWT credential.
|
|
275
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
276
|
+
* @returns
|
|
277
|
+
*/
|
|
278
|
+
verifySdJwtVc(args: IVerifySdJwtVcArgs, context: IRequiredContext): Promise<IVerifySdJwtVcResult>;
|
|
279
|
+
/**
|
|
280
|
+
* Verify the key binding of a SD-JWT by validating the signature of the key bound to the SD-JWT
|
|
281
|
+
* @param sdjwt - SD-JWT instance
|
|
282
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
283
|
+
* @param data - signed data
|
|
284
|
+
* @param signature - The signature
|
|
285
|
+
* @param payload - The payload of the SD-JWT
|
|
286
|
+
* @returns
|
|
287
|
+
*/
|
|
288
|
+
private verifyKb;
|
|
289
|
+
/**
|
|
290
|
+
* Validates the signature of a SD-JWT
|
|
291
|
+
* @param sdjwt - SD-JWT instance
|
|
292
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
293
|
+
* @param data - signed data
|
|
294
|
+
* @param signature - The signature
|
|
295
|
+
* @returns
|
|
296
|
+
*/
|
|
297
|
+
verify(sdjwt: SDJwtVcInstance, context: IRequiredContext, data: string, signature: string, opts?: {
|
|
298
|
+
x5cValidation?: X509CertificateChainValidationOpts;
|
|
299
|
+
}): Promise<boolean>;
|
|
300
|
+
/**
|
|
301
|
+
* Verify a signed SD-JWT presentation.
|
|
302
|
+
* @param args - Arguments necessary for the verify a SD-JWT presentation.
|
|
303
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
304
|
+
* @returns
|
|
305
|
+
*/
|
|
306
|
+
verifySdJwtPresentation(args: IVerifySdJwtPresentationArgs, context: IRequiredContext): Promise<IVerifySdJwtPresentationResult>;
|
|
307
|
+
/**
|
|
308
|
+
* Fetch and validate Type Metadata.
|
|
309
|
+
* @param args - Arguments necessary for fetching and validating the type metadata.
|
|
310
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
311
|
+
* @returns
|
|
312
|
+
*/
|
|
313
|
+
fetchSdJwtTypeMetadataFromVctUrl(args: FetchSdJwtTypeMetadataFromVctUrlArgs, context: IRequiredContext): Promise<SdJwtTypeMetadata>;
|
|
314
|
+
private verifySignatureCallback;
|
|
315
|
+
private getJwk;
|
|
316
|
+
private extractBase64FromDIDJwk;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
declare function fetchUrlWithErrorHandling(url: string): Promise<Response>;
|
|
320
|
+
type IntegrityAlg = 'sha256' | 'sha384' | 'sha512';
|
|
321
|
+
declare function extractHashFromIntegrity(integrityValue?: string): string | undefined;
|
|
322
|
+
declare function validateIntegrity({ input, integrityValue, hasher, }: {
|
|
323
|
+
input: any;
|
|
324
|
+
integrityValue?: string;
|
|
325
|
+
hasher: HasherSync$1 | Hasher;
|
|
326
|
+
}): Promise<boolean>;
|
|
327
|
+
declare function createIntegrity({ input, hasher, alg, }: {
|
|
328
|
+
input: any;
|
|
329
|
+
hasher: HasherSync$1 | Hasher;
|
|
330
|
+
alg?: IntegrityAlg;
|
|
331
|
+
}): Promise<string>;
|
|
332
|
+
declare function assertValidTypeMetadata(metadata: SdJwtTypeMetadata, vct: string): void;
|
|
333
|
+
|
|
334
|
+
export { type Claims, type FetchSdJwtTypeMetadataFromVctUrlArgs, type FetchSdJwtTypeMetadataFromVctUrlOpts, type GetSignerForIdentifierArgs, type GetSignerResult, type ICreateSdJwtPresentationArgs, type ICreateSdJwtPresentationResult, type ICreateSdJwtVcArgs, type ICreateSdJwtVcResult, type IDisclosureFrame, type IPresentationFrame, type IRequiredContext, type ISDJwtPlugin, type IVerifySdJwtPresentationArgs, type IVerifySdJwtPresentationResult, type IVerifySdJwtVcArgs, type IVerifySdJwtVcResult, type IntegrityAlg, SDJwtPlugin, type SdJWTImplementation, type SdJwtVcPayload, type SdJwtVerifySignature, type SignKeyArgs, type SignKeyResult, assertValidTypeMetadata, contextHasSDJwtPlugin, createIntegrity, extractHashFromIntegrity, fetchUrlWithErrorHandling, sdJwtPluginContextMethods, validateIntegrity };
|