@sphereon/ssi-sdk.sd-jwt 0.33.1-feature.vcdm2.tsup.32 → 0.33.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/action-handler.d.ts +89 -0
- package/dist/action-handler.d.ts.map +1 -0
- package/dist/action-handler.js +397 -0
- package/dist/action-handler.js.map +1 -0
- package/dist/defaultCallbacks.d.ts +6 -0
- package/dist/defaultCallbacks.d.ts.map +1 -0
- package/dist/defaultCallbacks.js +55 -0
- package/dist/defaultCallbacks.js.map +1 -0
- package/dist/index.d.ts +4 -334
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -562
- package/dist/index.js.map +1 -1
- package/dist/trustAnchors.d.ts +3 -0
- package/dist/trustAnchors.d.ts.map +1 -0
- package/dist/trustAnchors.js +20 -0
- package/dist/trustAnchors.js.map +1 -0
- package/dist/types.d.ts +234 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +18 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +85 -0
- package/dist/utils.js.map +1 -0
- package/package.json +24 -35
- package/src/__tests__/sd-jwt-integrity.test.ts +1 -1
- package/src/__tests__/sd-jwt.test.ts +1 -2
- package/src/action-handler.ts +2 -2
- package/src/defaultCallbacks.ts +3 -4
- package/src/types.ts +1 -1
- package/src/utils.ts +4 -4
- package/dist/index.cjs +0 -595
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -334
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { SDJwtVcInstance } from '@sd-jwt/sd-jwt-vc';
|
|
2
|
+
import { Signer } from '@sd-jwt/types';
|
|
3
|
+
import { X509CertificateChainValidationOpts } from '@sphereon/ssi-sdk-ext.x509-utils';
|
|
4
|
+
import { SdJwtTypeMetadata } from '@sphereon/ssi-types';
|
|
5
|
+
import { IAgentPlugin } from '@veramo/core';
|
|
6
|
+
import { FetchSdJwtTypeMetadataFromVctUrlArgs, ICreateSdJwtPresentationArgs, ICreateSdJwtPresentationResult, ICreateSdJwtVcArgs, ICreateSdJwtVcResult, IRequiredContext, ISDJwtPlugin, IVerifySdJwtPresentationArgs, IVerifySdJwtPresentationResult, IVerifySdJwtVcArgs, IVerifySdJwtVcResult, SdJWTImplementation, SignKeyArgs, SignKeyResult } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* @beta
|
|
9
|
+
* SD-JWT plugin
|
|
10
|
+
*/
|
|
11
|
+
export declare class SDJwtPlugin implements IAgentPlugin {
|
|
12
|
+
private readonly trustAnchorsInPEM;
|
|
13
|
+
private readonly registeredImplementations;
|
|
14
|
+
private _signers;
|
|
15
|
+
private _defaultSigner?;
|
|
16
|
+
constructor(registeredImplementations?: SdJWTImplementation & {
|
|
17
|
+
signers?: Record<string, Signer>;
|
|
18
|
+
defaultSigner?: Signer;
|
|
19
|
+
}, trustAnchorsInPEM?: string[]);
|
|
20
|
+
readonly methods: ISDJwtPlugin;
|
|
21
|
+
private getSignerForIdentifier;
|
|
22
|
+
/**
|
|
23
|
+
* Create a signed SD-JWT credential.
|
|
24
|
+
* @param args - Arguments necessary for the creation of a SD-JWT credential.
|
|
25
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
26
|
+
* @returns A signed SD-JWT credential.
|
|
27
|
+
*/
|
|
28
|
+
createSdJwtVc(args: ICreateSdJwtVcArgs, context: IRequiredContext): Promise<ICreateSdJwtVcResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Get the key to sign the SD-JWT
|
|
31
|
+
* @param args - consists of twp arguments: identifier like a did and other forms of identifiers and vmRelationship which represents the purpose of the key
|
|
32
|
+
* @param context - agent instance
|
|
33
|
+
* @returns the key to sign the SD-JWT
|
|
34
|
+
*/
|
|
35
|
+
getSignKey(args: SignKeyArgs, context: IRequiredContext): Promise<SignKeyResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a signed SD-JWT presentation.
|
|
38
|
+
* @param args - Arguments necessary for the creation of a SD-JWT presentation.
|
|
39
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
40
|
+
* @returns A signed SD-JWT presentation.
|
|
41
|
+
*/
|
|
42
|
+
createSdJwtPresentation(args: ICreateSdJwtPresentationArgs, context: IRequiredContext): Promise<ICreateSdJwtPresentationResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Verify a signed SD-JWT credential.
|
|
45
|
+
* @param args - Arguments necessary for the verify a SD-JWT credential.
|
|
46
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
verifySdJwtVc(args: IVerifySdJwtVcArgs, context: IRequiredContext): Promise<IVerifySdJwtVcResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Verify the key binding of a SD-JWT by validating the signature of the key bound to the SD-JWT
|
|
52
|
+
* @param sdjwt - SD-JWT instance
|
|
53
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
54
|
+
* @param data - signed data
|
|
55
|
+
* @param signature - The signature
|
|
56
|
+
* @param payload - The payload of the SD-JWT
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
private verifyKb;
|
|
60
|
+
/**
|
|
61
|
+
* Validates the signature of a SD-JWT
|
|
62
|
+
* @param sdjwt - SD-JWT instance
|
|
63
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
64
|
+
* @param data - signed data
|
|
65
|
+
* @param signature - The signature
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
verify(sdjwt: SDJwtVcInstance, context: IRequiredContext, data: string, signature: string, opts?: {
|
|
69
|
+
x5cValidation?: X509CertificateChainValidationOpts;
|
|
70
|
+
}): Promise<boolean>;
|
|
71
|
+
/**
|
|
72
|
+
* Verify a signed SD-JWT presentation.
|
|
73
|
+
* @param args - Arguments necessary for the verify a SD-JWT presentation.
|
|
74
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
verifySdJwtPresentation(args: IVerifySdJwtPresentationArgs, context: IRequiredContext): Promise<IVerifySdJwtPresentationResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Fetch and validate Type Metadata.
|
|
80
|
+
* @param args - Arguments necessary for fetching and validating the type metadata.
|
|
81
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
fetchSdJwtTypeMetadataFromVctUrl(args: FetchSdJwtTypeMetadataFromVctUrlArgs, context: IRequiredContext): Promise<SdJwtTypeMetadata>;
|
|
85
|
+
private verifySignatureCallback;
|
|
86
|
+
private getJwk;
|
|
87
|
+
private extractBase64FromDIDJwk;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=action-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-handler.d.ts","sourceRoot":"","sources":["../src/action-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAA;AACnE,OAAO,EAAsE,MAAM,EAAY,MAAM,eAAe,CAAA;AAEpH,OAAO,EAAE,kCAAkC,EAAE,MAAM,kCAAkC,CAAA;AACrF,OAAO,EAAmB,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAM3C,OAAO,EAEL,oCAAoC,EAGpC,4BAA4B,EAC5B,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,4BAA4B,EAC5B,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EAEnB,WAAW,EACX,aAAa,EACd,MAAM,SAAS,CAAA;AAIhB;;;GAGG;AACH,qBAAa,WAAY,YAAW,YAAY;IAE9C,OAAO,CAAC,QAAQ,CAAC,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C;IAcrI;;;;;OAKG;IACG,gCAAgC,CAAC,IAAI,EAAE,oCAAoC,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiDzI,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,MAAM;IAcd,OAAO,CAAC,uBAAuB;CAOhC"}
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SDJwtPlugin = void 0;
|
|
16
|
+
const core_1 = require("@sd-jwt/core");
|
|
17
|
+
const sd_jwt_vc_1 = require("@sd-jwt/sd-jwt-vc");
|
|
18
|
+
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
19
|
+
const utils_1 = require("@veramo/utils");
|
|
20
|
+
const debug_1 = __importDefault(require("debug"));
|
|
21
|
+
const defaultCallbacks_1 = require("./defaultCallbacks");
|
|
22
|
+
const trustAnchors_1 = require("./trustAnchors");
|
|
23
|
+
const utils_2 = require("./utils");
|
|
24
|
+
const debug = (0, debug_1.default)('@sphereon/ssi-sdk.sd-jwt');
|
|
25
|
+
/**
|
|
26
|
+
* @beta
|
|
27
|
+
* SD-JWT plugin
|
|
28
|
+
*/
|
|
29
|
+
class SDJwtPlugin {
|
|
30
|
+
constructor(registeredImplementations, trustAnchorsInPEM) {
|
|
31
|
+
var _a;
|
|
32
|
+
// map the methods your plugin is declaring to their implementation
|
|
33
|
+
this.methods = {
|
|
34
|
+
createSdJwtVc: this.createSdJwtVc.bind(this),
|
|
35
|
+
createSdJwtPresentation: this.createSdJwtPresentation.bind(this),
|
|
36
|
+
verifySdJwtVc: this.verifySdJwtVc.bind(this),
|
|
37
|
+
verifySdJwtPresentation: this.verifySdJwtPresentation.bind(this),
|
|
38
|
+
fetchSdJwtTypeMetadataFromVctUrl: this.fetchSdJwtTypeMetadataFromVctUrl.bind(this),
|
|
39
|
+
};
|
|
40
|
+
this.trustAnchorsInPEM = trustAnchorsInPEM !== null && trustAnchorsInPEM !== void 0 ? trustAnchorsInPEM : [];
|
|
41
|
+
if (!registeredImplementations) {
|
|
42
|
+
registeredImplementations = {};
|
|
43
|
+
}
|
|
44
|
+
if (typeof (registeredImplementations === null || registeredImplementations === void 0 ? void 0 : registeredImplementations.hasher) !== 'function') {
|
|
45
|
+
registeredImplementations.hasher = defaultCallbacks_1.defaultGenerateDigest;
|
|
46
|
+
}
|
|
47
|
+
if (typeof (registeredImplementations === null || registeredImplementations === void 0 ? void 0 : registeredImplementations.saltGenerator) !== 'function') {
|
|
48
|
+
registeredImplementations.saltGenerator = defaultCallbacks_1.defaultGenerateSalt;
|
|
49
|
+
}
|
|
50
|
+
this.registeredImplementations = registeredImplementations;
|
|
51
|
+
this._signers = (_a = registeredImplementations === null || registeredImplementations === void 0 ? void 0 : registeredImplementations.signers) !== null && _a !== void 0 ? _a : {};
|
|
52
|
+
this._defaultSigner = registeredImplementations === null || registeredImplementations === void 0 ? void 0 : registeredImplementations.defaultSigner;
|
|
53
|
+
// Verify signature default is used below in the methods if not provided here, as it needs the context of the agent
|
|
54
|
+
}
|
|
55
|
+
getSignerForIdentifier(args, context) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const { identifier, resolution } = args;
|
|
58
|
+
if (Object.keys(this._signers).includes(identifier) && typeof this._signers[identifier] === 'function') {
|
|
59
|
+
return { signer: this._signers[identifier] };
|
|
60
|
+
}
|
|
61
|
+
else if (typeof this._defaultSigner === 'function') {
|
|
62
|
+
return { signer: this._defaultSigner };
|
|
63
|
+
}
|
|
64
|
+
const signingKey = yield this.getSignKey({ identifier, vmRelationship: 'assertionMethod', resolution }, context);
|
|
65
|
+
const { key, alg } = signingKey;
|
|
66
|
+
const signer = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
return context.agent.keyManagerSign({ keyRef: key.kmsKeyRef, data });
|
|
68
|
+
});
|
|
69
|
+
return { signer, alg, signingKey };
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create a signed SD-JWT credential.
|
|
74
|
+
* @param args - Arguments necessary for the creation of a SD-JWT credential.
|
|
75
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
76
|
+
* @returns A signed SD-JWT credential.
|
|
77
|
+
*/
|
|
78
|
+
createSdJwtVc(args, context) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const issuer = args.credentialPayload.iss;
|
|
81
|
+
if (!issuer) {
|
|
82
|
+
throw new Error('credential.issuer must not be empty');
|
|
83
|
+
}
|
|
84
|
+
const { alg, signer, signingKey } = yield this.getSignerForIdentifier({ identifier: issuer, resolution: args.resolution }, context);
|
|
85
|
+
const sdjwt = new sd_jwt_vc_1.SDJwtVcInstance({
|
|
86
|
+
signer,
|
|
87
|
+
hasher: this.registeredImplementations.hasher,
|
|
88
|
+
saltGenerator: this.registeredImplementations.saltGenerator,
|
|
89
|
+
signAlg: alg !== null && alg !== void 0 ? alg : 'ES256',
|
|
90
|
+
hashAlg: 'sha-256',
|
|
91
|
+
});
|
|
92
|
+
const credential = yield sdjwt.issue(args.credentialPayload, args.disclosureFrame, {
|
|
93
|
+
header: Object.assign(Object.assign({}, ((signingKey === null || signingKey === void 0 ? void 0 : signingKey.key.kid) !== undefined && { kid: signingKey.key.kid })), ((signingKey === null || signingKey === void 0 ? void 0 : signingKey.key.x5c) !== undefined && { x5c: signingKey.key.x5c })),
|
|
94
|
+
});
|
|
95
|
+
return { credential };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get the key to sign the SD-JWT
|
|
100
|
+
* @param args - consists of twp arguments: identifier like a did and other forms of identifiers and vmRelationship which represents the purpose of the key
|
|
101
|
+
* @param context - agent instance
|
|
102
|
+
* @returns the key to sign the SD-JWT
|
|
103
|
+
*/
|
|
104
|
+
getSignKey(args, context) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
var _a, _b, _c, _d;
|
|
107
|
+
// TODO Using identifierManagedGetByDid now (new managed identifier resolution). Evaluate of we need to implement more identifier types here
|
|
108
|
+
const { identifier, resolution } = Object.assign({}, args);
|
|
109
|
+
if (resolution) {
|
|
110
|
+
const key = resolution.key;
|
|
111
|
+
const alg = yield (0, ssi_sdk_ext_key_utils_1.signatureAlgorithmFromKey)({ key });
|
|
112
|
+
switch (resolution.method) {
|
|
113
|
+
case 'did':
|
|
114
|
+
debug(`Signing key ${key.publicKeyHex} found for identifier ${identifier}`);
|
|
115
|
+
return { alg, key: Object.assign(Object.assign({}, key), { kmsKeyRef: resolution.kmsKeyRef, kid: resolution.kid }) };
|
|
116
|
+
default:
|
|
117
|
+
if (((_a = key.meta) === null || _a === void 0 ? void 0 : _a.x509) && key.meta.x509.x5c) {
|
|
118
|
+
return { alg, key: { kid: resolution.kid, kmsKeyRef: resolution.kmsKeyRef, x5c: key.meta.x509.x5c } };
|
|
119
|
+
}
|
|
120
|
+
else if ((_b = key.meta) === null || _b === void 0 ? void 0 : _b.jwkThumbprint) {
|
|
121
|
+
return { alg, key: { kid: resolution.kid, kmsKeyRef: resolution.kmsKeyRef, jwkThumbprint: key.meta.jwkThumbprint } };
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
return { alg, key: { kid: resolution.kid, kmsKeyRef: resolution.kmsKeyRef } };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (identifier.startsWith('did:')) {
|
|
129
|
+
const didIdentifier = yield context.agent.identifierManagedGetByDid({ identifier });
|
|
130
|
+
if (!didIdentifier) {
|
|
131
|
+
throw new Error(`No identifier found with the given did: ${identifier}`);
|
|
132
|
+
}
|
|
133
|
+
const key = didIdentifier.key;
|
|
134
|
+
const alg = yield (0, ssi_sdk_ext_key_utils_1.signatureAlgorithmFromKey)({ key });
|
|
135
|
+
debug(`Signing key ${key.publicKeyHex} found for identifier ${identifier}`);
|
|
136
|
+
return { alg, key: Object.assign(Object.assign({}, key), { kmsKeyRef: didIdentifier.kmsKeyRef, kid: didIdentifier.kid }) };
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const kidIdentifier = yield context.agent.identifierManagedGetByKid({ identifier });
|
|
140
|
+
if (!kidIdentifier) {
|
|
141
|
+
throw new Error(`No identifier found with the given kid: ${identifier}`);
|
|
142
|
+
}
|
|
143
|
+
const key = kidIdentifier.key;
|
|
144
|
+
const alg = yield (0, ssi_sdk_ext_key_utils_1.signatureAlgorithmFromKey)({ key });
|
|
145
|
+
if (((_c = key.meta) === null || _c === void 0 ? void 0 : _c.x509) && key.meta.x509.x5c) {
|
|
146
|
+
return { alg, key: { kid: kidIdentifier.kid, kmsKeyRef: kidIdentifier.kmsKeyRef, x5c: key.meta.x509.x5c } };
|
|
147
|
+
}
|
|
148
|
+
else if ((_d = key.meta) === null || _d === void 0 ? void 0 : _d.jwkThumbprint) {
|
|
149
|
+
return { alg, key: { kid: kidIdentifier.kid, kmsKeyRef: kidIdentifier.kmsKeyRef, jwkThumbprint: key.meta.jwkThumbprint } };
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
return { alg, key: { kid: kidIdentifier.kid, kmsKeyRef: kidIdentifier.kmsKeyRef } };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Create a signed SD-JWT presentation.
|
|
159
|
+
* @param args - Arguments necessary for the creation of a SD-JWT presentation.
|
|
160
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
161
|
+
* @returns A signed SD-JWT presentation.
|
|
162
|
+
*/
|
|
163
|
+
createSdJwtPresentation(args, context) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
var _a, _b, _c, _d;
|
|
166
|
+
const cred = yield core_1.SDJwt.fromEncode(args.presentation, this.registeredImplementations.hasher);
|
|
167
|
+
const claims = yield cred.getClaims(this.registeredImplementations.hasher);
|
|
168
|
+
let holder;
|
|
169
|
+
// we primarly look for a cnf field, if it's not there we look for a sub field. If this is also not given, we throw an error since we can not sign it.
|
|
170
|
+
if (args.holder) {
|
|
171
|
+
holder = args.holder;
|
|
172
|
+
}
|
|
173
|
+
else if ((_a = claims.cnf) === null || _a === void 0 ? void 0 : _a.jwk) {
|
|
174
|
+
const jwk = claims.cnf.jwk;
|
|
175
|
+
holder = (0, ssi_sdk_ext_key_utils_1.calculateJwkThumbprint)({ jwk: jwk });
|
|
176
|
+
}
|
|
177
|
+
else if ((_b = claims.cnf) === null || _b === void 0 ? void 0 : _b.kid) {
|
|
178
|
+
holder = (_c = claims.cnf) === null || _c === void 0 ? void 0 : _c.kid;
|
|
179
|
+
}
|
|
180
|
+
else if (claims.sub) {
|
|
181
|
+
holder = claims.sub;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
throw new Error('invalid_argument: credential does not include a holder reference');
|
|
185
|
+
}
|
|
186
|
+
const { alg, signer } = yield this.getSignerForIdentifier({ identifier: holder }, context);
|
|
187
|
+
const sdjwt = new sd_jwt_vc_1.SDJwtVcInstance({
|
|
188
|
+
hasher: (_d = this.registeredImplementations.hasher) !== null && _d !== void 0 ? _d : defaultCallbacks_1.defaultGenerateDigest,
|
|
189
|
+
saltGenerator: this.registeredImplementations.saltGenerator,
|
|
190
|
+
kbSigner: signer,
|
|
191
|
+
kbSignAlg: alg !== null && alg !== void 0 ? alg : 'ES256',
|
|
192
|
+
});
|
|
193
|
+
const presentation = yield sdjwt.present(args.presentation, args.presentationFrame, { kb: args.kb });
|
|
194
|
+
return { presentation };
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Verify a signed SD-JWT credential.
|
|
199
|
+
* @param args - Arguments necessary for the verify a SD-JWT credential.
|
|
200
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
201
|
+
* @returns
|
|
202
|
+
*/
|
|
203
|
+
verifySdJwtVc(args, context) {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
var _a;
|
|
206
|
+
// callback
|
|
207
|
+
const verifier = (data, signature) => __awaiter(this, void 0, void 0, function* () { return this.verify(sdjwt, context, data, signature); });
|
|
208
|
+
const sdjwt = new sd_jwt_vc_1.SDJwtVcInstance({ verifier, hasher: (_a = this.registeredImplementations.hasher) !== null && _a !== void 0 ? _a : defaultCallbacks_1.defaultGenerateDigest });
|
|
209
|
+
const { header = {}, payload, kb } = yield sdjwt.verify(args.credential);
|
|
210
|
+
return { header, payload: payload, kb };
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Verify the key binding of a SD-JWT by validating the signature of the key bound to the SD-JWT
|
|
215
|
+
* @param sdjwt - SD-JWT instance
|
|
216
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
217
|
+
* @param data - signed data
|
|
218
|
+
* @param signature - The signature
|
|
219
|
+
* @param payload - The payload of the SD-JWT
|
|
220
|
+
* @returns
|
|
221
|
+
*/
|
|
222
|
+
verifyKb(sdjwt, context, data, signature, payload) {
|
|
223
|
+
if (!payload.cnf) {
|
|
224
|
+
throw Error('other method than cnf is not supported yet');
|
|
225
|
+
}
|
|
226
|
+
return this.verifySignatureCallback(context)(data, signature, this.getJwk(payload));
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Validates the signature of a SD-JWT
|
|
230
|
+
* @param sdjwt - SD-JWT instance
|
|
231
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
232
|
+
* @param data - signed data
|
|
233
|
+
* @param signature - The signature
|
|
234
|
+
* @returns
|
|
235
|
+
*/
|
|
236
|
+
verify(sdjwt, context, data, signature, opts) {
|
|
237
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
var _a, _b, _c, _d, _e, _f;
|
|
239
|
+
const decodedVC = yield sdjwt.decode(`${data}.${signature}`);
|
|
240
|
+
const issuer = decodedVC.jwt.payload.iss;
|
|
241
|
+
const header = decodedVC.jwt.header;
|
|
242
|
+
const x5c = header === null || header === void 0 ? void 0 : header.x5c;
|
|
243
|
+
let jwk = header.jwk;
|
|
244
|
+
if (x5c) {
|
|
245
|
+
const trustAnchors = new Set([...this.trustAnchorsInPEM]);
|
|
246
|
+
if (trustAnchors.size === 0) {
|
|
247
|
+
trustAnchors.add(trustAnchors_1.sphereonCA);
|
|
248
|
+
trustAnchors.add(trustAnchors_1.funkeTestCA);
|
|
249
|
+
}
|
|
250
|
+
const certificateValidationResult = yield context.agent.x509VerifyCertificateChain({
|
|
251
|
+
chain: x5c,
|
|
252
|
+
trustAnchors: Array.from(trustAnchors),
|
|
253
|
+
// TODO: Defaults to allowing untrusted certs! Fine for now, not when wallets go mainstream
|
|
254
|
+
opts: (_a = opts === null || opts === void 0 ? void 0 : opts.x5cValidation) !== null && _a !== void 0 ? _a : { trustRootWhenNoAnchors: true, allowNoTrustAnchorsFound: true },
|
|
255
|
+
});
|
|
256
|
+
if (certificateValidationResult.error || !(certificateValidationResult === null || certificateValidationResult === void 0 ? void 0 : certificateValidationResult.certificateChain)) {
|
|
257
|
+
return Promise.reject(Error(`Certificate chain validation failed. ${certificateValidationResult.message}`));
|
|
258
|
+
}
|
|
259
|
+
const certInfo = certificateValidationResult.certificateChain[0];
|
|
260
|
+
jwk = certInfo.publicKeyJWK;
|
|
261
|
+
}
|
|
262
|
+
if (!jwk && ((_b = header.kid) === null || _b === void 0 ? void 0 : _b.includes('did:'))) {
|
|
263
|
+
const didDoc = yield context.agent.resolveDid({ didUrl: header.kid });
|
|
264
|
+
if (!didDoc) {
|
|
265
|
+
throw new Error('invalid_issuer: issuer did not resolve to a did document');
|
|
266
|
+
}
|
|
267
|
+
//TODO SDK-20: This should be checking for an assertionMethod and not just an verificationMethod with an id
|
|
268
|
+
const didDocumentKey = (_d = (_c = didDoc.didDocument) === null || _c === void 0 ? void 0 : _c.verificationMethod) === null || _d === void 0 ? void 0 : _d.find((key) => key.id);
|
|
269
|
+
if (!didDocumentKey) {
|
|
270
|
+
throw new Error('invalid_issuer: issuer did document does not include referenced key');
|
|
271
|
+
}
|
|
272
|
+
//FIXME SDK-21: in case it's another did method, the value of the key can be also encoded as a base64url
|
|
273
|
+
// needs more checks. some DID methods do not expose the keys as publicKeyJwk
|
|
274
|
+
jwk = didDocumentKey.publicKeyJwk;
|
|
275
|
+
}
|
|
276
|
+
if (!jwk && issuer.includes('did:')) {
|
|
277
|
+
// TODO refactor
|
|
278
|
+
const didDoc = yield context.agent.resolveDid({ didUrl: issuer });
|
|
279
|
+
if (!didDoc) {
|
|
280
|
+
throw new Error('invalid_issuer: issuer did not resolve to a did document');
|
|
281
|
+
}
|
|
282
|
+
//TODO SDK-20: This should be checking for an assertionMethod and not just an verificationMethod with an id
|
|
283
|
+
const didDocumentKey = (_f = (_e = didDoc.didDocument) === null || _e === void 0 ? void 0 : _e.verificationMethod) === null || _f === void 0 ? void 0 : _f.find((key) => key.id);
|
|
284
|
+
if (!didDocumentKey) {
|
|
285
|
+
throw new Error('invalid_issuer: issuer did document does not include referenced key');
|
|
286
|
+
}
|
|
287
|
+
//FIXME SDK-21: in case it's another did method, the value of the key can be also encoded as a base64url
|
|
288
|
+
// needs more checks. some DID methods do not expose the keys as publicKeyJwk
|
|
289
|
+
jwk = didDocumentKey.publicKeyJwk;
|
|
290
|
+
}
|
|
291
|
+
if (!jwk) {
|
|
292
|
+
throw new Error('No valid public key found for signature verification');
|
|
293
|
+
}
|
|
294
|
+
return this.verifySignatureCallback(context)(data, signature, jwk);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Verify a signed SD-JWT presentation.
|
|
299
|
+
* @param args - Arguments necessary for the verify a SD-JWT presentation.
|
|
300
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
301
|
+
* @returns
|
|
302
|
+
*/
|
|
303
|
+
verifySdJwtPresentation(args, context) {
|
|
304
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
305
|
+
let sdjwt;
|
|
306
|
+
const verifier = (data, signature) => __awaiter(this, void 0, void 0, function* () { return this.verify(sdjwt, context, data, signature); });
|
|
307
|
+
const verifierKb = (data, signature, payload) => __awaiter(this, void 0, void 0, function* () { return this.verifyKb(sdjwt, context, data, signature, payload); });
|
|
308
|
+
sdjwt = new sd_jwt_vc_1.SDJwtVcInstance({
|
|
309
|
+
verifier,
|
|
310
|
+
hasher: this.registeredImplementations.hasher,
|
|
311
|
+
kbVerifier: verifierKb,
|
|
312
|
+
});
|
|
313
|
+
return sdjwt.verify(args.presentation, args.requiredClaimKeys, args.kb);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Fetch and validate Type Metadata.
|
|
318
|
+
* @param args - Arguments necessary for fetching and validating the type metadata.
|
|
319
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
320
|
+
* @returns
|
|
321
|
+
*/
|
|
322
|
+
fetchSdJwtTypeMetadataFromVctUrl(args, context) {
|
|
323
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
324
|
+
var _a, _b, _c;
|
|
325
|
+
const { vct, vctIntegrity, opts } = args;
|
|
326
|
+
const url = new URL(vct);
|
|
327
|
+
const response = yield (0, utils_2.fetchUrlWithErrorHandling)(url.toString());
|
|
328
|
+
const metadata = yield response.json();
|
|
329
|
+
(0, utils_2.assertValidTypeMetadata)(metadata, vct);
|
|
330
|
+
const validate = (vct, input, integrityValue, hasher) => __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
if (hasher && integrityValue) {
|
|
332
|
+
const validation = yield (0, utils_2.validateIntegrity)({ integrityValue, input, hasher });
|
|
333
|
+
if (!validation) {
|
|
334
|
+
return Promise.reject(Error(`Integrity check failed for vct: ${vct}, extends: ${metadata.extends}, integrity: ${integrityValue}}`));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
const hasher = ((_b = (_a = opts === null || opts === void 0 ? void 0 : opts.hasher) !== null && _a !== void 0 ? _a : this.registeredImplementations.hasher) !== null && _b !== void 0 ? _b : defaultCallbacks_1.defaultGenerateDigest);
|
|
339
|
+
if (hasher) {
|
|
340
|
+
if (vctIntegrity) {
|
|
341
|
+
yield validate(vct, metadata, vctIntegrity, hasher);
|
|
342
|
+
const vctValidation = yield (0, utils_2.validateIntegrity)({ integrityValue: vctIntegrity, input: metadata, hasher });
|
|
343
|
+
if (!vctValidation) {
|
|
344
|
+
return Promise.reject(Error(`Integrity check failed for vct: ${vct}, integrity: ${vctIntegrity}`));
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (metadata['extends#integrity']) {
|
|
348
|
+
const extendsMetadata = yield this.fetchSdJwtTypeMetadataFromVctUrl({ vct: metadata['extends#integrity'], opts }, context);
|
|
349
|
+
yield validate(vct, extendsMetadata, metadata['extends#integrity'], hasher);
|
|
350
|
+
}
|
|
351
|
+
if (metadata['schema_uri#integrity']) {
|
|
352
|
+
const schemaResponse = yield (0, utils_2.fetchUrlWithErrorHandling)(metadata.schema_uri);
|
|
353
|
+
const schema = yield schemaResponse.json();
|
|
354
|
+
yield validate(vct, schema, metadata['schema_uri#integrity'], hasher);
|
|
355
|
+
}
|
|
356
|
+
(_c = metadata.display) === null || _c === void 0 ? void 0 : _c.forEach((display) => {
|
|
357
|
+
var _a, _b, _c;
|
|
358
|
+
const simpleLogoIntegrity = (_c = (_b = (_a = display.rendering) === null || _a === void 0 ? void 0 : _a.simple) === null || _b === void 0 ? void 0 : _b.logo) === null || _c === void 0 ? void 0 : _c['uri#integrity'];
|
|
359
|
+
if (simpleLogoIntegrity) {
|
|
360
|
+
console.log('TODO: Logo integrity check');
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
return metadata;
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
verifySignatureCallback(context) {
|
|
368
|
+
if (typeof this.registeredImplementations.verifySignature === 'function') {
|
|
369
|
+
return this.registeredImplementations.verifySignature;
|
|
370
|
+
}
|
|
371
|
+
return (0, defaultCallbacks_1.defaultVerifySignature)(context);
|
|
372
|
+
}
|
|
373
|
+
getJwk(payload) {
|
|
374
|
+
var _a;
|
|
375
|
+
if (((_a = payload.cnf) === null || _a === void 0 ? void 0 : _a.jwk) !== undefined) {
|
|
376
|
+
return payload.cnf.jwk;
|
|
377
|
+
}
|
|
378
|
+
else if (payload.cnf !== undefined && 'kid' in payload.cnf && typeof payload.cnf.kid === 'string' && payload.cnf.kid.startsWith('did:jwk:')) {
|
|
379
|
+
// extract JWK from kid FIXME isn't there a did function for this already? Otherwise create one
|
|
380
|
+
// FIXME this is a quick-fix to make verification but we need a real solution
|
|
381
|
+
const encoded = this.extractBase64FromDIDJwk(payload.cnf.kid);
|
|
382
|
+
const decoded = (0, utils_1.decodeBase64url)(encoded);
|
|
383
|
+
const jwt = JSON.parse(decoded);
|
|
384
|
+
return jwt;
|
|
385
|
+
}
|
|
386
|
+
throw Error('Unable to extract JWK from SD-JWT payload');
|
|
387
|
+
}
|
|
388
|
+
extractBase64FromDIDJwk(did) {
|
|
389
|
+
const parts = did.split(':');
|
|
390
|
+
if (parts.length < 3) {
|
|
391
|
+
throw new Error('Invalid DID format');
|
|
392
|
+
}
|
|
393
|
+
return parts[2].split('#')[0];
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
exports.SDJwtPlugin = SDJwtPlugin;
|
|
397
|
+
//# sourceMappingURL=action-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-handler.js","sourceRoot":"","sources":["../src/action-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAyC;AACzC,iDAAmE;AAEnE,2EAAmG;AAInG,yCAA+C;AAC/C,kDAAyB;AACzB,yDAAuG;AACvG,iDAAwD;AACxD,mCAA+F;AAsB/F,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,0BAA0B,CAAC,CAAA;AAE/C;;;GAGG;AACH,MAAa,WAAW;IAOtB,YACE,yBAGC,EACD,iBAA4B;;QAmB9B,mEAAmE;QAC1D,YAAO,GAAiB;YAC/B,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,uBAAuB,EAAE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC;YAChE,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,uBAAuB,EAAE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC;YAChE,gCAAgC,EAAE,IAAI,CAAC,gCAAgC,CAAC,IAAI,CAAC,IAAI,CAAC;SACnF,CAAA;QAxBC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,EAAE,CAAA;QAChD,IAAI,CAAC,yBAAyB,EAAE,CAAC;YAC/B,yBAAyB,GAAG,EAAE,CAAA;QAChC,CAAC;QACD,IAAI,OAAO,CAAA,yBAAyB,aAAzB,yBAAyB,uBAAzB,yBAAyB,CA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CAAE,GAAG,MAAK,SAAS,EAAE,CAAC;YACnC,OAAO,OAAO,CAAC,GAAG,CAAC,GAAiB,CAAA;QACtC,CAAC;aAAM,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9I,+FAA+F;YAC/F,6EAA6E;YAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAC7D,MAAM,OAAO,GAAG,IAAA,uBAAe,EAAC,OAAO,CAAC,CAAA;YACxC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YAC/B,OAAO,GAAiB,CAAA;QAC1B,CAAC;QACD,MAAM,KAAK,CAAC,2CAA2C,CAAC,CAAA;IAC1D,CAAC;IAEO,uBAAuB,CAAC,GAAW;QACzC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;QACvC,CAAC;QACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/B,CAAC;CACF;AApYD,kCAoYC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HasherSync } from '@sphereon/ssi-types';
|
|
2
|
+
import { IRequiredContext, SdJwtVerifySignature } from './types';
|
|
3
|
+
export declare const defaultGenerateDigest: HasherSync;
|
|
4
|
+
export declare const defaultGenerateSalt: () => string;
|
|
5
|
+
export declare const defaultVerifySignature: (context: IRequiredContext) => SdJwtVerifySignature;
|
|
6
|
+
//# sourceMappingURL=defaultCallbacks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultCallbacks.d.ts","sourceRoot":"","sources":["../src/defaultCallbacks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAgB,MAAM,qBAAqB,CAAA;AAG9D,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEhE,eAAO,MAAM,qBAAqB,EAAE,UAInC,CAAA;AAED,eAAO,MAAM,mBAAmB,QAAO,MAEtC,CAAA;AAED,eAAO,MAAM,sBAAsB,YACvB,gBAAgB,KAAG,oBAM5B,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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.defaultVerifySignature = exports.defaultGenerateSalt = exports.defaultGenerateDigest = void 0;
|
|
36
|
+
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
37
|
+
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
38
|
+
const uuid_1 = require("uuid");
|
|
39
|
+
const u8a = __importStar(require("uint8arrays"));
|
|
40
|
+
const defaultGenerateDigest = (data, alg) => {
|
|
41
|
+
return (0, ssi_sdk_ext_key_utils_1.digestMethodParams)(alg.includes('256') ? 'SHA-256' : 'SHA-512').hash(typeof data === 'string' ? u8a.fromString(data, 'utf-8') : new Uint8Array(data));
|
|
42
|
+
};
|
|
43
|
+
exports.defaultGenerateDigest = defaultGenerateDigest;
|
|
44
|
+
const defaultGenerateSalt = () => {
|
|
45
|
+
return (0, uuid_1.v4)();
|
|
46
|
+
};
|
|
47
|
+
exports.defaultGenerateSalt = defaultGenerateSalt;
|
|
48
|
+
const defaultVerifySignature = (context) => (data, signature, publicKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
// The data and signature from the sd-jwt lib are a jwt header.payload and signature, so let's recombine into a compact jwt
|
|
50
|
+
const result = yield context.agent.jwtVerifyJwsSignature({ jws: `${data}.${signature}`, jwk: publicKey });
|
|
51
|
+
ssi_types_1.Loggers.DEFAULT.get('sd-jwt').info(`SD-JWT signature verified. Result: ${result.message}`);
|
|
52
|
+
return !result.error;
|
|
53
|
+
});
|
|
54
|
+
exports.defaultVerifySignature = defaultVerifySignature;
|
|
55
|
+
//# sourceMappingURL=defaultCallbacks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultCallbacks.js","sourceRoot":"","sources":["../src/defaultCallbacks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAAoE;AACpE,mDAA8D;AAC9D,+BAAyB;AACzB,iDAAkC;AAG3B,MAAM,qBAAqB,GAAe,CAAC,IAA0B,EAAE,GAAW,EAAc,EAAE;IACvG,OAAO,IAAA,0CAAkB,EAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CACzE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAChF,CAAA;AACH,CAAC,CAAA;AAJY,QAAA,qBAAqB,yBAIjC;AAEM,MAAM,mBAAmB,GAAG,GAAW,EAAE;IAC9C,OAAO,IAAA,SAAE,GAAE,CAAA;AACb,CAAC,CAAA;AAFY,QAAA,mBAAmB,uBAE/B;AAEM,MAAM,sBAAsB,GACjC,CAAC,OAAyB,EAAwB,EAAE,CACpD,CAAO,IAAY,EAAE,SAAiB,EAAE,SAAqB,EAAoB,EAAE;IACjF,2HAA2H;IAC3H,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,IAAI,SAAS,EAA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