@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/types.d.ts DELETED
@@ -1,234 +0,0 @@
1
- import { SdJwtVcPayload as SdJwtPayload } from '@sd-jwt/sd-jwt-vc';
2
- import { Hasher, kbHeader, KBOptions, kbPayload, SaltGenerator, Signer } from '@sd-jwt/types';
3
- import { IIdentifierResolution, ManagedIdentifierResult } from '@sphereon/ssi-sdk-ext.identifier-resolution';
4
- import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
5
- import { X509CertificateChainValidationOpts } from '@sphereon/ssi-sdk-ext.x509-utils';
6
- import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc';
7
- import { HasherSync, JoseSignatureAlgorithm, SdJwtTypeMetadata } from '@sphereon/ssi-types';
8
- import { DIDDocumentSection, IAgentContext, IDIDManager, IKeyManager, IPluginMethodMap, IResolver } from '@veramo/core';
9
- export declare const sdJwtPluginContextMethods: Array<string>;
10
- /**
11
- * My Agent Plugin description.
12
- *
13
- * This is the interface that describes what your plugin can do.
14
- * The methods listed here, will be directly available to the veramo agent where your plugin is going to be used.
15
- * Depending on the agent configuration, other agent plugins, as well as the application where the agent is used
16
- * will be able to call these methods.
17
- *
18
- * To build a schema for your plugin using standard tools, you must link to this file in your package.json.
19
- * Example:
20
- * ```
21
- * "veramo": {
22
- * "pluginInterfaces": {
23
- * "IMyAgentPlugin": "./src/types/IMyAgentPlugin.ts"
24
- * }
25
- * },
26
- * ```
27
- *
28
- * @beta
29
- */
30
- export interface ISDJwtPlugin extends IPluginMethodMap {
31
- /**
32
- * Your plugin method description
33
- *
34
- * @param args - Input parameters for this method
35
- * @param context - The required context where this method can run.
36
- * Declaring a context type here lets other developers know which other plugins
37
- * need to also be installed for this method to work.
38
- */
39
- /**
40
- * Create a signed SD-JWT credential.
41
- * @param args - Arguments necessary for the creation of a SD-JWT credential.
42
- * @param context - This reserved param is automatically added and handled by the framework, *do not override*
43
- */
44
- createSdJwtVc(args: ICreateSdJwtVcArgs, context: IRequiredContext): Promise<ICreateSdJwtVcResult>;
45
- /**
46
- * Create a signed SD-JWT presentation.
47
- * @param args - Arguments necessary for the creation of a SD-JWT presentation.
48
- * @param context - This reserved param is automatically added and handled by the framework, *do not override*
49
- */
50
- createSdJwtPresentation(args: ICreateSdJwtPresentationArgs, context: IRequiredContext): Promise<ICreateSdJwtPresentationResult>;
51
- /**
52
- * Verify a signed SD-JWT credential.
53
- * @param args - Arguments necessary for the verification of a SD-JWT credential.
54
- * @param context - This reserved param is automatically added and handled by the framework, *do not override*
55
- */
56
- verifySdJwtVc(args: IVerifySdJwtVcArgs, context: IRequiredContext): Promise<IVerifySdJwtVcResult>;
57
- /**
58
- * Verify a signed SD-JWT presentation.
59
- * @param args - Arguments necessary for the verification of a SD-JWT presentation.
60
- * @param context - This reserved param is automatically added and handled by the framework, *do not override*
61
- */
62
- verifySdJwtPresentation(args: IVerifySdJwtPresentationArgs, context: IRequiredContext): Promise<IVerifySdJwtPresentationResult>;
63
- /**
64
- * Fetch and validate Type Metadata.
65
- * @param args - Arguments necessary for fetching and validating the type metadata.
66
- * @param context - This reserved param is automatically added and handled by the framework, *do not override*
67
- */
68
- fetchSdJwtTypeMetadataFromVctUrl(args: FetchSdJwtTypeMetadataFromVctUrlArgs, context: IRequiredContext): Promise<SdJwtTypeMetadata>;
69
- }
70
- export declare function contextHasSDJwtPlugin(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ISDJwtPlugin>;
71
- /**
72
- * ICreateSdJwtVcArgs
73
- *
74
- * @beta
75
- */
76
- export interface SdJwtVcPayload extends SdJwtPayload {
77
- x5c?: string[];
78
- }
79
- export interface ICreateSdJwtVcArgs {
80
- credentialPayload: SdJwtVcPayload;
81
- disclosureFrame?: IDisclosureFrame;
82
- resolution?: ManagedIdentifierResult;
83
- }
84
- /**
85
- * @beta
86
- */
87
- export interface IDisclosureFrame {
88
- _sd?: string[];
89
- _sd_decoy?: number;
90
- [x: string]: string[] | number | IDisclosureFrame | undefined;
91
- }
92
- /**
93
- * ICreateSdJwtVcResult
94
- *
95
- * @beta
96
- */
97
- export interface ICreateSdJwtVcResult {
98
- /**
99
- * the encoded sd-jwt credential
100
- */
101
- credential: string;
102
- }
103
- /**
104
- *
105
- * @beta
106
- */
107
- export interface ICreateSdJwtPresentationArgs {
108
- /**
109
- * Encoded SD-JWT credential
110
- */
111
- presentation: string;
112
- presentationFrame?: IPresentationFrame;
113
- /**
114
- * Allows to override the holder. Normally it will be looked up from the cnf or sub values
115
- */
116
- holder?: string;
117
- /**
118
- * Information to include to add key binding.
119
- */
120
- kb?: KBOptions;
121
- }
122
- /**
123
- * @beta
124
- */
125
- export interface IPresentationFrame {
126
- [x: string]: boolean | IPresentationFrame;
127
- }
128
- /**
129
- * Created presentation
130
- * @beta
131
- */
132
- export interface ICreateSdJwtPresentationResult {
133
- /**
134
- * Encoded presentation.
135
- */
136
- presentation: string;
137
- }
138
- /**
139
- * @beta
140
- */
141
- export interface IVerifySdJwtVcArgs {
142
- credential: string;
143
- opts?: {
144
- x5cValidation?: X509CertificateChainValidationOpts;
145
- };
146
- }
147
- /**
148
- * @beta
149
- */
150
- export type IVerifySdJwtVcResult = {
151
- payload: SdJwtPayload;
152
- header: Record<string, unknown>;
153
- kb?: {
154
- header: kbHeader;
155
- payload: kbPayload;
156
- };
157
- };
158
- /**
159
- * @beta
160
- */
161
- export interface IVerifySdJwtPresentationArgs {
162
- presentation: string;
163
- requiredClaimKeys?: string[];
164
- kb?: boolean;
165
- }
166
- /**
167
- * @beta
168
- */
169
- export type IVerifySdJwtPresentationResult = {
170
- payload: unknown;
171
- header: Record<string, unknown> | undefined;
172
- kb?: {
173
- header: kbHeader;
174
- payload: kbPayload;
175
- };
176
- };
177
- export type SignKeyArgs = {
178
- identifier: string;
179
- vmRelationship: DIDDocumentSection;
180
- resolution?: ManagedIdentifierResult;
181
- };
182
- export type SignKeyResult = {
183
- alg: JoseSignatureAlgorithm;
184
- key: {
185
- kid?: string;
186
- kmsKeyRef: string;
187
- x5c?: string[];
188
- jwkThumbprint?: string;
189
- };
190
- };
191
- /**
192
- * This context describes the requirements of this plugin.
193
- * For this plugin to function properly, the agent needs to also have other plugins installed that implement the
194
- * interfaces declared here.
195
- * You can also define requirements on a more granular level, for each plugin method or event handler of your plugin.
196
- *
197
- * @beta
198
- */
199
- export type IRequiredContext = IAgentContext<IDIDManager & IIdentifierResolution & IJwtService & IResolver & IKeyManager & ImDLMdoc>;
200
- export type SdJwtVerifySignature = (data: string, signature: string, publicKey: JsonWebKey) => Promise<boolean>;
201
- export interface SdJWTImplementation {
202
- saltGenerator?: SaltGenerator;
203
- hasher?: HasherSync;
204
- verifySignature?: SdJwtVerifySignature;
205
- }
206
- export interface Claims {
207
- /**
208
- * Subject of the SD-JWT
209
- */
210
- sub?: string;
211
- cnf?: {
212
- jwk?: JsonWebKey;
213
- kid?: string;
214
- };
215
- [key: string]: unknown;
216
- }
217
- export type FetchSdJwtTypeMetadataFromVctUrlArgs = {
218
- vct: string;
219
- vctIntegrity?: string;
220
- opts?: FetchSdJwtTypeMetadataFromVctUrlOpts;
221
- };
222
- export type FetchSdJwtTypeMetadataFromVctUrlOpts = {
223
- hasher?: HasherSync | Hasher;
224
- };
225
- export type GetSignerForIdentifierArgs = {
226
- identifier: string;
227
- resolution?: ManagedIdentifierResult;
228
- };
229
- export type GetSignerResult = {
230
- signer: Signer;
231
- alg?: string;
232
- signingKey?: SignKeyResult;
233
- };
234
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAA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AAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAC/G,MAAM,WAAW,mBAAmB;IAClC,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,eAAe,CAAC,EAAE,oBAAoB,CAAA;CACvC;AAED,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE;QACJ,GAAG,CAAC,EAAE,UAAU,CAAA;QAChB,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;IAED,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,MAAM,oCAAoC,GAAG;IACjD,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,oCAAoC,CAAA;CAC5C,CAAA;AAED,MAAM,MAAM,oCAAoC,GAAG;IACjD,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,uBAAuB,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,aAAa,CAAA;CAC3B,CAAA"}
package/dist/types.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sdJwtPluginContextMethods = void 0;
4
- exports.contextHasSDJwtPlugin = contextHasSDJwtPlugin;
5
- const ssi_sdk_agent_config_1 = require("@sphereon/ssi-sdk.agent-config");
6
- exports.sdJwtPluginContextMethods = ['createSdJwtVc', 'createSdJwtPresentation', 'verifySdJwtVc', 'verifySdJwtPresentation'];
7
- function contextHasSDJwtPlugin(context) {
8
- return (0, ssi_sdk_agent_config_1.contextHasPlugin)(context, 'verifySdJwtVc');
9
- }
10
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA6EA,sDAEC;AA1ED,yEAAiE;AAKpD,QAAA,yBAAyB,GAAkB,CAAC,eAAe,EAAE,yBAAyB,EAAE,eAAe,EAAE,yBAAyB,CAAC,CAAA;AAmEhJ,SAAgB,qBAAqB,CAAC,OAAwC;IAC5E,OAAO,IAAA,uCAAgB,EAAC,OAAO,EAAE,eAAe,CAAC,CAAA;AACnD,CAAC"}
package/dist/utils.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import { SdJwtTypeMetadata } from '@sphereon/ssi-types';
2
- import { HasherSync } from '@sd-jwt/types';
3
- import { Hasher } from '@sd-jwt/types';
4
- export declare function fetchUrlWithErrorHandling(url: string): Promise<Response>;
5
- export type IntegrityAlg = 'sha256' | 'sha384' | 'sha512';
6
- export declare function extractHashFromIntegrity(integrityValue?: string): string | undefined;
7
- export declare function validateIntegrity({ input, integrityValue, hasher, }: {
8
- input: any;
9
- integrityValue?: string;
10
- hasher: HasherSync | Hasher;
11
- }): Promise<boolean>;
12
- export declare function createIntegrity({ input, hasher, alg, }: {
13
- input: any;
14
- hasher: HasherSync | Hasher;
15
- alg?: IntegrityAlg;
16
- }): Promise<string>;
17
- export declare function assertValidTypeMetadata(metadata: SdJwtTypeMetadata, vct: string): void;
18
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAGtC,wBAAsB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAM9E;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAUzD,wBAAgB,wBAAwB,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEpF;AAED,wBAAsB,iBAAiB,CAAC,EACtC,KAAK,EACL,cAAc,EACd,MAAM,GACP,EAAE;IACD,KAAK,EAAE,GAAG,CAAA;IACV,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,UAAU,GAAG,MAAM,CAAA;CAC5B,GAAG,OAAO,CAAC,OAAO,CAAC,CAUnB;AAED,wBAAsB,eAAe,CAAC,EACpC,KAAK,EACL,MAAM,EACN,GAAc,GACf,EAAE;IACD,KAAK,EAAE,GAAG,CAAA;IACV,MAAM,EAAE,UAAU,GAAG,MAAM,CAAA;IAC3B,GAAG,CAAC,EAAE,YAAY,CAAA;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CAGlB;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAItF"}
package/dist/utils.js DELETED
@@ -1,85 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.fetchUrlWithErrorHandling = fetchUrlWithErrorHandling;
36
- exports.extractHashFromIntegrity = extractHashFromIntegrity;
37
- exports.validateIntegrity = validateIntegrity;
38
- exports.createIntegrity = createIntegrity;
39
- exports.assertValidTypeMetadata = assertValidTypeMetadata;
40
- const u8a = __importStar(require("uint8arrays"));
41
- // Helper function to fetch API with error handling
42
- function fetchUrlWithErrorHandling(url) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const response = yield fetch(url);
45
- if (!response.ok) {
46
- throw new Error(`${response.status}: ${response.statusText}`);
47
- }
48
- return response;
49
- });
50
- }
51
- function extractHashAlgFromIntegrity(integrityValue) {
52
- const val = integrityValue === null || integrityValue === void 0 ? void 0 : integrityValue.toLowerCase().trim().split('-')[0];
53
- if (val === 'sha256' || val === 'sha384' || val === 'sha512') {
54
- return val;
55
- }
56
- return undefined;
57
- }
58
- function extractHashFromIntegrity(integrityValue) {
59
- return integrityValue === null || integrityValue === void 0 ? void 0 : integrityValue.toLowerCase().trim().split('-')[1];
60
- }
61
- function validateIntegrity(_a) {
62
- return __awaiter(this, arguments, void 0, function* ({ input, integrityValue, hasher, }) {
63
- if (!integrityValue) {
64
- return true;
65
- }
66
- const alg = extractHashAlgFromIntegrity(integrityValue);
67
- if (!alg) {
68
- return false;
69
- }
70
- const calculatedHash = yield createIntegrity({ hasher, input, alg });
71
- return calculatedHash == integrityValue;
72
- });
73
- }
74
- function createIntegrity(_a) {
75
- return __awaiter(this, arguments, void 0, function* ({ input, hasher, alg = 'sha256', }) {
76
- const calculatedHash = yield hasher(typeof input === 'string' ? input : JSON.stringify(input), alg);
77
- return `${alg}-${u8a.toString(calculatedHash, 'base64')}`;
78
- });
79
- }
80
- function assertValidTypeMetadata(metadata, vct) {
81
- if (metadata.vct !== vct) {
82
- throw new Error('VCT mismatch in metadata and credential');
83
- }
84
- }
85
- //# sourceMappingURL=utils.js.map
package/dist/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,8DAMC;AAYD,4DAEC;AAED,8CAkBC;AAED,0CAWC;AAED,0DAIC;AAhED,iDAAkC;AAIlC,mDAAmD;AACnD,SAAsB,yBAAyB,CAAC,GAAW;;QACzD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;QACjC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;QAC/D,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;CAAA;AAID,SAAS,2BAA2B,CAAC,cAAuB;IAC1D,MAAM,GAAG,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IAC9D,IAAI,GA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