@sphereon/ssi-sdk.oid4vci-issuer 0.33.1-feature.vcdm2.tsup.32 → 0.33.1-next.3
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/IssuerInstance.d.ts +26 -0
- package/dist/IssuerInstance.d.ts.map +1 -0
- package/dist/IssuerInstance.js +52 -0
- package/dist/IssuerInstance.js.map +1 -0
- package/dist/agent/OID4VCIIssuer.d.ts +25 -0
- package/dist/agent/OID4VCIIssuer.d.ts.map +1 -0
- package/dist/agent/OID4VCIIssuer.js +210 -0
- package/dist/agent/OID4VCIIssuer.js.map +1 -0
- package/dist/functions.d.ts +74 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/functions.js +328 -0
- package/dist/functions.js.map +1 -0
- package/dist/index.d.ts +6 -206
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -927
- package/dist/index.js.map +1 -1
- package/dist/state-manager/TypeOrmStateManager.d.ts +1 -0
- package/dist/state-manager/TypeOrmStateManager.d.ts.map +1 -0
- package/dist/state-manager/TypeOrmStateManager.js +2 -0
- package/dist/state-manager/TypeOrmStateManager.js.map +1 -0
- package/dist/state-manager/oid4vcState/IAbstractMachineStateStore.d.ts +39 -0
- package/dist/state-manager/oid4vcState/IAbstractMachineStateStore.d.ts.map +1 -0
- package/dist/state-manager/oid4vcState/IAbstractMachineStateStore.js +3 -0
- package/dist/state-manager/oid4vcState/IAbstractMachineStateStore.js.map +1 -0
- package/dist/state-manager/oid4vcState/MachineStateStore.d.ts +1 -0
- package/dist/state-manager/oid4vcState/MachineStateStore.d.ts.map +1 -0
- package/dist/state-manager/oid4vcState/MachineStateStore.js +137 -0
- package/dist/state-manager/oid4vcState/MachineStateStore.js.map +1 -0
- package/dist/types/IOID4VCIIssuer.d.ts +90 -0
- package/dist/types/IOID4VCIIssuer.d.ts.map +1 -0
- package/dist/types/IOID4VCIIssuer.js +3 -0
- package/dist/types/IOID4VCIIssuer.js.map +1 -0
- package/package.json +28 -38
- package/src/functions.ts +1 -1
- package/src/types/IOID4VCIIssuer.ts +1 -1
- package/dist/index.cjs +0 -959
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -210
|
@@ -0,0 +1,328 @@
|
|
|
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.getJwtVerifyCallback = getJwtVerifyCallback;
|
|
16
|
+
exports.getAccessTokenKeyRef = getAccessTokenKeyRef;
|
|
17
|
+
exports.getAccessTokenSignerCallback = getAccessTokenSignerCallback;
|
|
18
|
+
exports.getCredentialSignerCallback = getCredentialSignerCallback;
|
|
19
|
+
exports.createVciIssuerBuilder = createVciIssuerBuilder;
|
|
20
|
+
exports.createVciIssuer = createVciIssuer;
|
|
21
|
+
exports.createAuthRequestUriCallback = createAuthRequestUriCallback;
|
|
22
|
+
exports.createVerifyAuthResponseCallback = createVerifyAuthResponseCallback;
|
|
23
|
+
const oid4vci_issuer_1 = require("@sphereon/oid4vci-issuer");
|
|
24
|
+
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
25
|
+
const ssi_sdk_ext_identifier_resolution_1 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
|
|
26
|
+
const ssi_sdk_agent_config_1 = require("@sphereon/ssi-sdk.agent-config");
|
|
27
|
+
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
28
|
+
const utils_1 = require("@veramo/utils");
|
|
29
|
+
const did_jwt_1 = require("did-jwt");
|
|
30
|
+
const jwt_decode_1 = require("jwt-decode");
|
|
31
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
32
|
+
const did_auth_siop_1 = require("@sphereon/did-auth-siop");
|
|
33
|
+
function getJwtVerifyCallback({ verifyOpts }, _context) {
|
|
34
|
+
return (args) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
var _a, _b, _c;
|
|
36
|
+
const resolver = (0, ssi_sdk_ext_did_utils_1.getAgentResolver)(_context, {
|
|
37
|
+
resolverResolution: true,
|
|
38
|
+
uniresolverResolution: true,
|
|
39
|
+
localResolution: true,
|
|
40
|
+
});
|
|
41
|
+
verifyOpts = Object.assign(Object.assign({}, verifyOpts), { resolver: verifyOpts === null || verifyOpts === void 0 ? void 0 : verifyOpts.resolver }); // Resolver separately as that is a function
|
|
42
|
+
if (!(verifyOpts === null || verifyOpts === void 0 ? void 0 : verifyOpts.resolver) || typeof ((_a = verifyOpts === null || verifyOpts === void 0 ? void 0 : verifyOpts.resolver) === null || _a === void 0 ? void 0 : _a.resolve) !== 'function') {
|
|
43
|
+
verifyOpts.resolver = resolver;
|
|
44
|
+
}
|
|
45
|
+
const result = yield _context.agent.jwtVerifyJwsSignature({ jws: args.jwt });
|
|
46
|
+
if (!result.error) {
|
|
47
|
+
const identifier = result.jws.signatures[0].identifier;
|
|
48
|
+
if (!identifier) {
|
|
49
|
+
return Promise.reject(Error('the jws did not contain a signature with an identifier'));
|
|
50
|
+
}
|
|
51
|
+
const jwkInfo = identifier.jwks[0];
|
|
52
|
+
if (!jwkInfo) {
|
|
53
|
+
return Promise.reject(Error(`the identifier of type ${identifier.method} is missing jwks (ExternalJwkInfo)`));
|
|
54
|
+
}
|
|
55
|
+
const { alg } = jwkInfo.jwk;
|
|
56
|
+
const header = (0, jwt_decode_1.jwtDecode)(args.jwt, { header: true });
|
|
57
|
+
const payload = (0, jwt_decode_1.jwtDecode)(args.jwt, { header: false });
|
|
58
|
+
const kid = (_b = args.kid) !== null && _b !== void 0 ? _b : header.kid;
|
|
59
|
+
//const jwk = !kid ? jwkInfo.jwk : undefined // TODO double-check if this is correct
|
|
60
|
+
const jwk = jwkInfo.jwk; // FIXME workaround IATAB2B-57
|
|
61
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({ alg }, identifier), { jwt: { header, payload } }), (kid && { kid })), (jwk && { jwk }));
|
|
62
|
+
}
|
|
63
|
+
const decodedJwt = (yield (0, did_jwt_1.decodeJWT)(args.jwt));
|
|
64
|
+
const kid = (_c = args.kid) !== null && _c !== void 0 ? _c : decodedJwt.header.kid;
|
|
65
|
+
if (!kid || !kid.startsWith('did:')) {
|
|
66
|
+
// No DID method present in header. We already performed the validation above. So return that
|
|
67
|
+
return {
|
|
68
|
+
alg: decodedJwt.header.alg,
|
|
69
|
+
jwt: decodedJwt,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const did = kid.split('#')[0];
|
|
73
|
+
const didResult = yield (0, did_jwt_1.verifyJWT)(args.jwt, verifyOpts);
|
|
74
|
+
if (!didResult.verified) {
|
|
75
|
+
console.log(`JWT invalid: ${args.jwt}`);
|
|
76
|
+
throw Error('JWT did not verify successfully');
|
|
77
|
+
}
|
|
78
|
+
const didResolution = yield resolver.resolve(did);
|
|
79
|
+
if (!didResolution || !didResolution.didDocument) {
|
|
80
|
+
throw Error(`Could not resolve did: ${did}, metadata: ${didResolution === null || didResolution === void 0 ? void 0 : didResolution.didResolutionMetadata}`);
|
|
81
|
+
}
|
|
82
|
+
const alg = decodedJwt.header.alg;
|
|
83
|
+
return {
|
|
84
|
+
alg,
|
|
85
|
+
kid,
|
|
86
|
+
did,
|
|
87
|
+
didDocument: didResolution.didDocument,
|
|
88
|
+
jwt: decodedJwt,
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function getAccessTokenKeyRef(opts, context) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
let identifier = (0, ssi_sdk_ext_identifier_resolution_1.legacyKeyRefsToIdentifierOpts)(opts);
|
|
95
|
+
return yield context.agent.identifierManagedGet(identifier);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function getAccessTokenSignerCallback(opts, context) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const signer = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
let dataString, encoding;
|
|
102
|
+
const resolution = yield (0, ssi_sdk_ext_identifier_resolution_1.legacyKeyRefsToIdentifierOpts)(opts);
|
|
103
|
+
const keyRef = resolution.kmsKeyRef;
|
|
104
|
+
if (!keyRef) {
|
|
105
|
+
throw Error('Cannot sign access tokens without a key ref');
|
|
106
|
+
}
|
|
107
|
+
if (typeof data === 'string') {
|
|
108
|
+
dataString = data;
|
|
109
|
+
encoding = undefined;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
dataString = (0, utils_1.bytesToBase64)(data);
|
|
113
|
+
encoding = 'base64';
|
|
114
|
+
}
|
|
115
|
+
return context.agent.keyManagerSign({ keyRef, data: dataString, encoding });
|
|
116
|
+
});
|
|
117
|
+
function accessTokenSignerCallback(jwt, kid) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
120
|
+
const issuer = (_b = (_a = opts.idOpts) === null || _a === void 0 ? void 0 : _a.issuer) !== null && _b !== void 0 ? _b : (typeof ((_c = opts.idOpts) === null || _c === void 0 ? void 0 : _c.identifier) === 'string' ? opts.idOpts.identifier : ((_g = (_f = (_e = (_d = opts.didOpts) === null || _d === void 0 ? void 0 : _d.idOpts) === null || _e === void 0 ? void 0 : _e.identifier) === null || _f === void 0 ? void 0 : _f.toString()) !== null && _g !== void 0 ? _g : opts === null || opts === void 0 ? void 0 : opts.iss));
|
|
121
|
+
if (!issuer) {
|
|
122
|
+
throw Error('No issuer configured for access tokens');
|
|
123
|
+
}
|
|
124
|
+
let kidHeader = (_j = (_h = jwt === null || jwt === void 0 ? void 0 : jwt.header) === null || _h === void 0 ? void 0 : _h.kid) !== null && _j !== void 0 ? _j : kid;
|
|
125
|
+
if (!kidHeader) {
|
|
126
|
+
if (((_k = opts.idOpts) === null || _k === void 0 ? void 0 : _k.method) === 'did' ||
|
|
127
|
+
((_l = opts.idOpts) === null || _l === void 0 ? void 0 : _l.method) === 'kid' ||
|
|
128
|
+
(typeof ((_m = opts.didOpts) === null || _m === void 0 ? void 0 : _m.idOpts.identifier) === 'string' && ((_q = (_p = (_o = opts.didOpts) === null || _o === void 0 ? void 0 : _o.idOpts) === null || _p === void 0 ? void 0 : _p.identifier) === null || _q === void 0 ? void 0 : _q.startsWith('did:')))) {
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
kidHeader = (_v = (_s = (_r = opts.idOpts) === null || _r === void 0 ? void 0 : _r.kid) !== null && _s !== void 0 ? _s : (_u = (_t = opts.didOpts) === null || _t === void 0 ? void 0 : _t.idOpts) === null || _u === void 0 ? void 0 : _u.kid) !== null && _v !== void 0 ? _v : (_x = (_w = opts === null || opts === void 0 ? void 0 : opts.didOpts) === null || _w === void 0 ? void 0 : _w.identifierOpts) === null || _x === void 0 ? void 0 : _x.kid;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return yield (0, did_jwt_1.createJWT)(jwt.payload, { signer, issuer }, Object.assign(Object.assign(Object.assign({}, jwt.header), (kidHeader && { kid: kidHeader })), { typ: 'JWT' }));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return accessTokenSignerCallback;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function getCredentialSignerCallback(idOpts, context) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
function issueVCCallback(args) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
var _a, _b, _c;
|
|
144
|
+
const { jwtVerifyResult, format, statusLists } = args;
|
|
145
|
+
const credential = args.credential; // TODO: SDJWT
|
|
146
|
+
let proofFormat;
|
|
147
|
+
const resolution = yield context.agent.identifierManagedGet(idOpts);
|
|
148
|
+
proofFormat = (format === null || format === void 0 ? void 0 : format.includes('ld')) ? 'lds' : 'jwt';
|
|
149
|
+
const issuer = (_a = resolution.issuer) !== null && _a !== void 0 ? _a : resolution.kmsKeyRef;
|
|
150
|
+
if (ssi_types_1.CredentialMapper.isW3cCredential(credential)) {
|
|
151
|
+
if (!credential.issuer) {
|
|
152
|
+
credential.issuer = { id: issuer };
|
|
153
|
+
}
|
|
154
|
+
else if (typeof credential.issuer === 'object' && !credential.issuer.id) {
|
|
155
|
+
credential.issuer.id = issuer;
|
|
156
|
+
}
|
|
157
|
+
const subjectIsArray = Array.isArray(credential.credentialSubject);
|
|
158
|
+
let credentialSubjects = Array.isArray(credential.credentialSubject) ? credential.credentialSubject : [credential.credentialSubject];
|
|
159
|
+
credentialSubjects = credentialSubjects.map((subject) => {
|
|
160
|
+
if (!subject.id) {
|
|
161
|
+
subject.id = jwtVerifyResult.did;
|
|
162
|
+
}
|
|
163
|
+
return subject;
|
|
164
|
+
});
|
|
165
|
+
credential.credentialSubject = subjectIsArray ? credentialSubjects : credentialSubjects[0];
|
|
166
|
+
// TODO: We should extend the plugin capabilities of issuance so we do not have to tuck this into the sign callback
|
|
167
|
+
if ((0, ssi_sdk_agent_config_1.contextHasPlugin)(context, 'slAddStatusToCredential')) {
|
|
168
|
+
// Add status list if enabled (and when the input has a credentialStatus object (can be empty))
|
|
169
|
+
const credentialStatusVC = yield context.agent.slAddStatusToCredential({ credential, statusLists });
|
|
170
|
+
if (credential.credentialStatus && !credential.credentialStatus.statusListCredential) {
|
|
171
|
+
credential.credentialStatus = credentialStatusVC.credentialStatus;
|
|
172
|
+
// TODO update statusLists somehow?
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const result = yield context.agent.createVerifiableCredential(Object.assign({ credential: credential, proofFormat, removeOriginalFields: false, fetchRemoteContexts: true, domain: typeof credential.issuer === 'object' ? credential.issuer.id : credential.issuer }, (resolution.kid && { header: { kid: resolution.kid } })));
|
|
176
|
+
return (proofFormat === 'jwt' && 'jwt' in result.proof ? result.proof.jwt : result);
|
|
177
|
+
}
|
|
178
|
+
else if (ssi_types_1.CredentialMapper.isSdJwtDecodedCredentialPayload(credential)) {
|
|
179
|
+
const sdJwtPayload = credential;
|
|
180
|
+
if (sdJwtPayload.iss === undefined) {
|
|
181
|
+
sdJwtPayload.iss = issuer;
|
|
182
|
+
}
|
|
183
|
+
if (sdJwtPayload.iat === undefined) {
|
|
184
|
+
sdJwtPayload.iat = Math.floor(new Date().getTime() / 1000);
|
|
185
|
+
}
|
|
186
|
+
let disclosureFrame;
|
|
187
|
+
if ('disclosureFrame' in credential) {
|
|
188
|
+
disclosureFrame = credential['disclosureFrame'];
|
|
189
|
+
delete credential['disclosureFrame'];
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
disclosureFrame = {
|
|
193
|
+
_sd: credential['_sd'],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
if ((0, ssi_sdk_agent_config_1.contextHasPlugin)(context, 'slAddStatusToSdJwtCredential')) {
|
|
197
|
+
if ((sdJwtPayload.status && sdJwtPayload.status.status_list) || (statusLists && statusLists.length > 0)) {
|
|
198
|
+
// Add status list if enabled (and when the input has a credentialStatus object (can be empty))
|
|
199
|
+
const sdJwtPayloadWithStatus = yield context.agent.slAddStatusToSdJwtCredential({ credential: sdJwtPayload, statusLists });
|
|
200
|
+
if ((_c = (_b = sdJwtPayload.status) === null || _b === void 0 ? void 0 : _b.status_list) === null || _c === void 0 ? void 0 : _c.idx) {
|
|
201
|
+
if (!sdJwtPayloadWithStatus.status || !sdJwtPayloadWithStatus.status.status_list) {
|
|
202
|
+
// sdJwtPayload and sdJwtPayloadWithStatus is the same for now, but we should use the result anyway as this could be subject to change
|
|
203
|
+
return Promise.reject(Error('slAddStatusToSdJwtCredential did not return a status_list'));
|
|
204
|
+
}
|
|
205
|
+
// Update statusListId & statusListIndex back to the credential session TODO SSISDK-4 This is not a clean way to do this.
|
|
206
|
+
if (statusLists && statusLists.length > 0) {
|
|
207
|
+
const statusList = statusLists[0];
|
|
208
|
+
statusList.statusListId = sdJwtPayloadWithStatus.status.status_list.uri;
|
|
209
|
+
statusList.statusListIndex = sdJwtPayloadWithStatus.status.status_list.idx;
|
|
210
|
+
}
|
|
211
|
+
sdJwtPayload.status.status_list.idx = sdJwtPayloadWithStatus.status.status_list.idx;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const result = yield context.agent.createSdJwtVc({
|
|
216
|
+
credentialPayload: sdJwtPayload,
|
|
217
|
+
disclosureFrame: disclosureFrame,
|
|
218
|
+
resolution,
|
|
219
|
+
});
|
|
220
|
+
return result.credential;
|
|
221
|
+
} /*else if (CredentialMapper.isMsoMdocDecodedCredential(credential)) {
|
|
222
|
+
TODO
|
|
223
|
+
}*/
|
|
224
|
+
return Promise.reject('VC issuance failed, an incorrect or unsupported credential was supplied');
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return issueVCCallback;
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function createVciIssuerBuilder(args, context) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
233
|
+
const { issuerOpts, issuerMetadata, authorizationServerMetadata } = args;
|
|
234
|
+
const builder = new oid4vci_issuer_1.VcIssuerBuilder();
|
|
235
|
+
// @ts-ignore
|
|
236
|
+
const resolver = (_k = (_e = (_a = args.resolver) !== null && _a !== void 0 ? _a : (_d = (_c = (_b = args === null || args === void 0 ? void 0 : args.issuerOpts) === null || _b === void 0 ? void 0 : _b.didOpts) === null || _c === void 0 ? void 0 : _c.resolveOpts) === null || _d === void 0 ? void 0 : _d.resolver) !== null && _e !== void 0 ? _e : (_j = (_h = (_g = (_f = args.issuerOpts) === null || _f === void 0 ? void 0 : _f.didOpts) === null || _g === void 0 ? void 0 : _g.resolveOpts) === null || _h === void 0 ? void 0 : _h.jwtVerifyOpts) === null || _j === void 0 ? void 0 : _j.resolver) !== null && _k !== void 0 ? _k : (0, ssi_sdk_ext_did_utils_1.getAgentResolver)(context);
|
|
237
|
+
if (!resolver) {
|
|
238
|
+
throw Error('A Resolver is necessary to verify DID JWTs');
|
|
239
|
+
}
|
|
240
|
+
const idOpts = (0, ssi_sdk_ext_identifier_resolution_1.legacyKeyRefsToIdentifierOpts)({ didOpts: issuerOpts.didOpts, idOpts: issuerOpts.idOpts });
|
|
241
|
+
const jwtVerifyOpts = Object.assign(Object.assign(Object.assign({}, (_m = (_l = issuerOpts === null || issuerOpts === void 0 ? void 0 : issuerOpts.didOpts) === null || _l === void 0 ? void 0 : _l.resolveOpts) === null || _m === void 0 ? void 0 : _m.jwtVerifyOpts), (_p = (_o = args === null || args === void 0 ? void 0 : args.issuerOpts) === null || _o === void 0 ? void 0 : _o.resolveOpts) === null || _p === void 0 ? void 0 : _p.jwtVerifyOpts), { resolver, audience: issuerMetadata.credential_issuer });
|
|
242
|
+
builder.withIssuerMetadata(issuerMetadata);
|
|
243
|
+
builder.withAuthorizationMetadata(authorizationServerMetadata);
|
|
244
|
+
// builder.withUserPinRequired(issuerOpts.userPinRequired ?? false) was removed from implementers draft v1
|
|
245
|
+
builder.withCredentialSignerCallback(yield getCredentialSignerCallback(idOpts, context));
|
|
246
|
+
if (issuerOpts.asClientOpts) {
|
|
247
|
+
builder.withASClientMetadata(issuerOpts.asClientOpts);
|
|
248
|
+
// @ts-ignore
|
|
249
|
+
// const authorizationServer = issuerMetadata.authorization_servers[0] as string
|
|
250
|
+
// Set the OIDC verifier
|
|
251
|
+
// builder.withJWTVerifyCallback(oidcAccessTokenVerifyCallback({clientMetadata: issuerOpts.asClientOpts, credentialIssuer: issuerMetadata.credential_issuer as string, authorizationServer}))
|
|
252
|
+
}
|
|
253
|
+
// Do not use it when asClient is used
|
|
254
|
+
builder.withJWTVerifyCallback(getJwtVerifyCallback({ verifyOpts: jwtVerifyOpts }, context));
|
|
255
|
+
if (args.credentialDataSupplier) {
|
|
256
|
+
builder.withCredentialDataSupplier(args.credentialDataSupplier);
|
|
257
|
+
}
|
|
258
|
+
builder.withInMemoryCNonceState();
|
|
259
|
+
builder.withInMemoryCredentialOfferState();
|
|
260
|
+
builder.withInMemoryCredentialOfferURIState();
|
|
261
|
+
return builder;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function createVciIssuer(_a, context_1) {
|
|
265
|
+
return __awaiter(this, arguments, void 0, function* ({ issuerOpts, issuerMetadata, authorizationServerMetadata, credentialDataSupplier, }, context) {
|
|
266
|
+
return (yield createVciIssuerBuilder({
|
|
267
|
+
issuerOpts,
|
|
268
|
+
issuerMetadata,
|
|
269
|
+
authorizationServerMetadata,
|
|
270
|
+
credentialDataSupplier,
|
|
271
|
+
}, context)).build();
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
function createAuthRequestUriCallback(opts) {
|
|
275
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
276
|
+
function authRequestUriCallback() {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
+
const path = opts.path.replace(':definitionId', opts.presentationDefinitionId);
|
|
279
|
+
return (0, cross_fetch_1.default)(path, {
|
|
280
|
+
method: 'POST',
|
|
281
|
+
headers: {
|
|
282
|
+
'Content-Type': 'application/json',
|
|
283
|
+
},
|
|
284
|
+
}).then((response) => __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
if (response.status >= 400) {
|
|
286
|
+
return Promise.reject(Error(yield response.text()));
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
const responseData = yield response.json();
|
|
290
|
+
if (!responseData.authRequestURI) {
|
|
291
|
+
return Promise.reject(Error('Missing auth request uri in response body'));
|
|
292
|
+
}
|
|
293
|
+
return responseData.authRequestURI;
|
|
294
|
+
}
|
|
295
|
+
}));
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return authRequestUriCallback;
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function createVerifyAuthResponseCallback(opts) {
|
|
302
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
+
function verifyAuthResponseCallback(correlationId) {
|
|
304
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
305
|
+
return (0, cross_fetch_1.default)(opts.path, {
|
|
306
|
+
method: 'POST',
|
|
307
|
+
headers: {
|
|
308
|
+
'Content-Type': 'application/json',
|
|
309
|
+
},
|
|
310
|
+
body: JSON.stringify({ definitionId: opts.presentationDefinitionId, correlationId }),
|
|
311
|
+
}).then((response) => __awaiter(this, void 0, void 0, function* () {
|
|
312
|
+
if (response.status >= 400) {
|
|
313
|
+
return Promise.reject(Error(yield response.text()));
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
const responseData = yield response.json();
|
|
317
|
+
if (!responseData.status) {
|
|
318
|
+
return Promise.reject(Error('Missing status in response body'));
|
|
319
|
+
}
|
|
320
|
+
return responseData.status === did_auth_siop_1.AuthorizationResponseStateStatus.VERIFIED;
|
|
321
|
+
}
|
|
322
|
+
}));
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
return verifyAuthResponseCallback;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.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,CAAC,IAAI,EAAE;oBACtB,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE;wBACP,cAAc,EAAE,kBAAkB;qBACnC;oBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,wBAAwB,EAAE,aAAa,EAAE,CAAC;iBACrF,CAAC,CAAC,IAAI,CAAC,CAAO,QAAQ,EAAoB,EAAE;oBAC3C,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;wBAC3B,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;oBACrD,CAAC;yBAAM,CAAC;wBACN,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;wBAE1C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;4BACzB,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC,CAAA;wBACjE,CAAC;wBAED,OAAO,YAAY,CAAC,MAAM,KAAK,gDAAgC,CAAC,QAAQ,CAAA;oBAC1E,CAAC;gBACH,CAAC,CAAA,CAAC,CAAA;YACJ,CAAC;SAAA;QAED,OAAO,0BAA0B,CAAA;IACnC,CAAC;CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,210 +1,10 @@
|
|
|
1
|
-
import { IPluginMethodMap, IAgentContext, IDIDManager, IResolver, IKeyManager, ICredentialIssuer, IAgentPlugin } from '@veramo/core';
|
|
2
|
-
import { CredentialDataSupplier, VcIssuer, CredentialSignerCallback, VcIssuerBuilder } from '@sphereon/oid4vci-issuer';
|
|
3
|
-
import { Grant, CredentialConfigurationSupported, JsonLdIssuerCredentialDefinition, CredentialDataSupplierInput, QRCodeOpts, StatusListOpts, CredentialOfferMode, CredentialOfferSession, CredentialRequest, CredentialResponse, AccessTokenRequest, AccessTokenResponse, ClientMetadata, CredentialIssuerMetadataOpts, IssuerMetadata, AuthorizationServerMetadata, JwtVerifyResult, Jwt } from '@sphereon/oid4vci-common';
|
|
4
|
-
import { ResolveOpts, IDIDOptions } from '@sphereon/ssi-sdk-ext.did-utils';
|
|
5
|
-
import * as _sphereon_ssi_sdk_ext_identifier_resolution from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
6
|
-
import { IIdentifierResolution, ManagedIdentifierOptsOrResult } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
7
|
-
import { IOID4VCIStore } from '@sphereon/ssi-sdk.oid4vci-issuer-store';
|
|
8
|
-
import { ICredential } from '@sphereon/ssi-types';
|
|
9
|
-
import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
|
|
10
|
-
import { JWTVerifyOptions } from 'did-jwt';
|
|
11
|
-
import { Resolvable } from 'did-resolver';
|
|
12
|
-
|
|
13
|
-
type IssuerCredentialDefinition = JsonLdIssuerCredentialDefinition;
|
|
14
|
-
interface IOID4VCIIssuer extends IPluginMethodMap {
|
|
15
|
-
oid4vciCreateOfferURI(createArgs: ICreateOfferArgs, context: IRequiredContext): Promise<ICreateCredentialOfferURIResult>;
|
|
16
|
-
oid4vciIssueCredential(issueArgs: IIssueCredentialArgs, context: IRequiredContext): Promise<CredentialResponse>;
|
|
17
|
-
oid4vciCreateAccessTokenResponse(accessTokenArgs: IAssertValidAccessTokenArgs, context: IRequiredContext): Promise<AccessTokenResponse>;
|
|
18
|
-
oid4vciGetInstance(args: IIssuerInstanceArgs, context: IRequiredContext): Promise<IssuerInstance>;
|
|
19
|
-
}
|
|
20
|
-
interface IOID4VCIIssuerOpts {
|
|
21
|
-
defaultStoreId?: string;
|
|
22
|
-
defaultNamespace?: string;
|
|
23
|
-
resolveOpts?: ResolveOpts;
|
|
24
|
-
returnSessions?: boolean;
|
|
25
|
-
}
|
|
26
|
-
interface ICreateOfferArgs extends IIssuerInstanceArgs {
|
|
27
|
-
grants?: Grant;
|
|
28
|
-
credentials?: Record<string, CredentialConfigurationSupported>;
|
|
29
|
-
credentialDefinition?: IssuerCredentialDefinition;
|
|
30
|
-
credentialOfferUri?: string;
|
|
31
|
-
credentialDataSupplierInput?: CredentialDataSupplierInput;
|
|
32
|
-
redirectUri?: string;
|
|
33
|
-
correlationId?: string;
|
|
34
|
-
sessionLifeTimeInSec?: number;
|
|
35
|
-
qrCodeOpts?: QRCodeOpts;
|
|
36
|
-
client_id?: string;
|
|
37
|
-
statusListOpts?: Array<StatusListOpts>;
|
|
38
|
-
offerMode?: CredentialOfferMode;
|
|
39
|
-
baseUri?: string;
|
|
40
|
-
scheme?: string;
|
|
41
|
-
pinLength?: number;
|
|
42
|
-
}
|
|
43
|
-
interface IIssueCredentialArgs extends IIssuerInstanceArgs {
|
|
44
|
-
credentialRequest: CredentialRequest;
|
|
45
|
-
credential?: ICredential;
|
|
46
|
-
credentialDataSupplier?: CredentialDataSupplier;
|
|
47
|
-
credentialDataSupplierInput?: CredentialDataSupplierInput;
|
|
48
|
-
newCNonce?: string;
|
|
49
|
-
cNonceExpiresIn?: number;
|
|
50
|
-
tokenExpiresIn?: number;
|
|
51
|
-
responseCNonce?: string;
|
|
52
|
-
}
|
|
53
|
-
interface IAssertValidAccessTokenArgs extends IIssuerInstanceArgs {
|
|
54
|
-
request: AccessTokenRequest;
|
|
55
|
-
expirationDuration: number;
|
|
56
|
-
}
|
|
57
|
-
interface IIssuerInstanceArgs {
|
|
58
|
-
credentialIssuer: string;
|
|
59
|
-
storeId?: string;
|
|
60
|
-
namespace?: string;
|
|
61
|
-
}
|
|
62
|
-
interface IIssuerInstanceOptions extends IMetadataOptions {
|
|
63
|
-
issuerOpts?: IIssuerOptions;
|
|
64
|
-
metadataOpts?: CredentialIssuerMetadataOpts;
|
|
65
|
-
}
|
|
66
|
-
interface IIssuerOptions {
|
|
67
|
-
asClientOpts?: ClientMetadata;
|
|
68
|
-
idOpts?: ManagedIdentifierOptsOrResult;
|
|
69
|
-
resolveOpts?: ResolveOpts;
|
|
70
|
-
/**
|
|
71
|
-
* @deprecated: use idOpts
|
|
72
|
-
*/
|
|
73
|
-
didOpts?: IDIDOptions;
|
|
74
|
-
userPinRequired?: boolean;
|
|
75
|
-
cNonceExpiresIn?: number;
|
|
76
|
-
/**
|
|
77
|
-
* Used in the callbacks for the first party flow
|
|
78
|
-
*/
|
|
79
|
-
presentationDefinitionId?: string;
|
|
80
|
-
}
|
|
81
|
-
interface IMetadataOptions {
|
|
82
|
-
credentialIssuer: string;
|
|
83
|
-
storeId?: string;
|
|
84
|
-
storeNamespace?: string;
|
|
85
|
-
}
|
|
86
|
-
type ICreateCredentialOfferURIResult = {
|
|
87
|
-
uri: string;
|
|
88
|
-
session?: CredentialOfferSession;
|
|
89
|
-
userPin?: string;
|
|
90
|
-
userPinLength?: number;
|
|
91
|
-
};
|
|
92
|
-
type IRequiredContext = IAgentContext<IIdentifierResolution & IDIDManager & IResolver & IKeyManager & ICredentialIssuer & IOID4VCIStore & IJwtService>;
|
|
93
|
-
|
|
94
|
-
declare class IssuerInstance {
|
|
95
|
-
private _issuer;
|
|
96
|
-
private readonly _metadataOptions;
|
|
97
|
-
private readonly _issuerOptions;
|
|
98
|
-
private _issuerMetadata;
|
|
99
|
-
private readonly _authorizationServerMetadata;
|
|
100
|
-
constructor({ issuerOpts, metadataOpts, issuerMetadata, authorizationServerMetadata, }: {
|
|
101
|
-
issuerOpts: IIssuerOptions;
|
|
102
|
-
metadataOpts: IMetadataOptions;
|
|
103
|
-
issuerMetadata: IssuerMetadata;
|
|
104
|
-
authorizationServerMetadata: AuthorizationServerMetadata;
|
|
105
|
-
});
|
|
106
|
-
get(opts: {
|
|
107
|
-
context: IRequiredContext;
|
|
108
|
-
credentialDataSupplier?: CredentialDataSupplier;
|
|
109
|
-
}): Promise<VcIssuer>;
|
|
110
|
-
get issuerOptions(): IIssuerOptions;
|
|
111
|
-
get metadataOptions(): IMetadataOptions;
|
|
112
|
-
get issuerMetadata(): IssuerMetadata;
|
|
113
|
-
set issuerMetadata(value: IssuerMetadata);
|
|
114
|
-
get authorizationServerMetadata(): AuthorizationServerMetadata;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
declare class OID4VCIIssuer implements IAgentPlugin {
|
|
118
|
-
private static readonly _DEFAULT_OPTS_KEY;
|
|
119
|
-
private readonly instances;
|
|
120
|
-
readonly schema: any;
|
|
121
|
-
readonly methods: IOID4VCIIssuer;
|
|
122
|
-
private _opts;
|
|
123
|
-
constructor(opts?: IOID4VCIIssuerOpts);
|
|
124
|
-
private oid4vciCreateOfferURI;
|
|
125
|
-
private oid4vciIssueCredential;
|
|
126
|
-
private oid4vciCreateAccessTokenResponse;
|
|
127
|
-
private getExternalAS;
|
|
128
|
-
private createIssuerInstance;
|
|
129
|
-
oid4vciGetInstance(args: IIssuerInstanceArgs, context: IRequiredContext): Promise<IssuerInstance>;
|
|
130
|
-
private getIssuerOptsFromStore;
|
|
131
|
-
private getMetadataOpts;
|
|
132
|
-
private getIssuerMetadata;
|
|
133
|
-
private getAuthorizationServerMetadataFromStore;
|
|
134
|
-
private storeId;
|
|
135
|
-
private namespace;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
declare function getJwtVerifyCallback({ verifyOpts }: {
|
|
139
|
-
verifyOpts?: JWTVerifyOptions;
|
|
140
|
-
}, _context: IRequiredContext): (args: {
|
|
141
|
-
jwt: string;
|
|
142
|
-
kid?: string;
|
|
143
|
-
}) => Promise<JwtVerifyResult>;
|
|
144
|
-
declare function getAccessTokenKeyRef(opts: {
|
|
145
|
-
/**
|
|
146
|
-
* Uniform identifier options
|
|
147
|
-
*/
|
|
148
|
-
idOpts?: ManagedIdentifierOptsOrResult;
|
|
149
|
-
/**
|
|
150
|
-
* @deprecated
|
|
151
|
-
*/
|
|
152
|
-
iss?: string;
|
|
153
|
-
/**
|
|
154
|
-
* @deprecated
|
|
155
|
-
*/
|
|
156
|
-
keyRef?: string;
|
|
157
|
-
/**
|
|
158
|
-
* @deprecated
|
|
159
|
-
*/
|
|
160
|
-
didOpts?: IDIDOptions;
|
|
161
|
-
}, context: IRequiredContext): Promise<_sphereon_ssi_sdk_ext_identifier_resolution.ManagedIdentifierResult>;
|
|
162
|
-
declare function getAccessTokenSignerCallback(opts: {
|
|
163
|
-
/**
|
|
164
|
-
* Uniform identifier options
|
|
165
|
-
*/
|
|
166
|
-
idOpts?: ManagedIdentifierOptsOrResult;
|
|
167
|
-
/**
|
|
168
|
-
* @deprecated
|
|
169
|
-
*/
|
|
170
|
-
iss?: string;
|
|
171
|
-
/**
|
|
172
|
-
* @deprecated
|
|
173
|
-
*/
|
|
174
|
-
keyRef?: string;
|
|
175
|
-
/**
|
|
176
|
-
* @deprecated
|
|
177
|
-
*/
|
|
178
|
-
didOpts?: IDIDOptions;
|
|
179
|
-
}, context: IRequiredContext): Promise<(jwt: Jwt, kid?: string) => Promise<string>>;
|
|
180
|
-
declare function getCredentialSignerCallback(idOpts: ManagedIdentifierOptsOrResult & {
|
|
181
|
-
crypto?: Crypto;
|
|
182
|
-
}, context: IRequiredContext): Promise<CredentialSignerCallback>;
|
|
183
|
-
declare function createVciIssuerBuilder(args: {
|
|
184
|
-
issuerOpts: IIssuerOptions;
|
|
185
|
-
issuerMetadata: IssuerMetadata;
|
|
186
|
-
authorizationServerMetadata: AuthorizationServerMetadata;
|
|
187
|
-
resolver?: Resolvable;
|
|
188
|
-
credentialDataSupplier?: CredentialDataSupplier;
|
|
189
|
-
}, context: IRequiredContext): Promise<VcIssuerBuilder>;
|
|
190
|
-
declare function createVciIssuer({ issuerOpts, issuerMetadata, authorizationServerMetadata, credentialDataSupplier, }: {
|
|
191
|
-
issuerOpts: IIssuerOptions;
|
|
192
|
-
issuerMetadata: IssuerMetadata;
|
|
193
|
-
authorizationServerMetadata: AuthorizationServerMetadata;
|
|
194
|
-
credentialDataSupplier?: CredentialDataSupplier;
|
|
195
|
-
}, context: IRequiredContext): Promise<VcIssuer>;
|
|
196
|
-
declare function createAuthRequestUriCallback(opts: {
|
|
197
|
-
path: string;
|
|
198
|
-
presentationDefinitionId: string;
|
|
199
|
-
}): Promise<() => Promise<string>>;
|
|
200
|
-
declare function createVerifyAuthResponseCallback(opts: {
|
|
201
|
-
path: string;
|
|
202
|
-
presentationDefinitionId: string;
|
|
203
|
-
}): Promise<(correlationId: string) => Promise<boolean>>;
|
|
204
|
-
|
|
205
1
|
/**
|
|
206
2
|
* @public
|
|
207
3
|
*/
|
|
208
4
|
declare const schema: any;
|
|
209
|
-
|
|
210
|
-
export {
|
|
5
|
+
export { schema };
|
|
6
|
+
export { OID4VCIIssuer } from './agent/OID4VCIIssuer';
|
|
7
|
+
export * from './functions';
|
|
8
|
+
export * from './IssuerInstance';
|
|
9
|
+
export * from './types/IOID4VCIIssuer';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,MAAM,KAAmC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA"}
|