@sphereon/oid4vci-client 0.2.0 → 0.4.1-next.285
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/LICENSE +201 -201
- package/README.md +494 -371
- package/dist/AccessTokenClient.d.ts +30 -0
- package/dist/AccessTokenClient.d.ts.map +1 -0
- package/dist/AccessTokenClient.js +222 -0
- package/dist/AccessTokenClient.js.map +1 -0
- package/dist/AuthorizationDetailsBuilder.d.ts +11 -0
- package/dist/AuthorizationDetailsBuilder.d.ts.map +1 -0
- package/dist/AuthorizationDetailsBuilder.js +44 -0
- package/dist/AuthorizationDetailsBuilder.js.map +1 -0
- package/dist/CredentialOfferClient.d.ts +10 -0
- package/dist/CredentialOfferClient.d.ts.map +1 -0
- package/dist/CredentialOfferClient.js +101 -0
- package/dist/CredentialOfferClient.js.map +1 -0
- package/dist/CredentialRequestClient.d.ts +33 -0
- package/dist/CredentialRequestClient.d.ts.map +1 -0
- package/dist/CredentialRequestClient.js +118 -0
- package/dist/CredentialRequestClient.js.map +1 -0
- package/dist/CredentialRequestClientBuilder.d.ts +34 -0
- package/dist/CredentialRequestClientBuilder.d.ts.map +1 -0
- package/dist/CredentialRequestClientBuilder.js +87 -0
- package/dist/CredentialRequestClientBuilder.js.map +1 -0
- package/dist/{main/lib/MetadataClient.d.ts → MetadataClient.d.ts} +39 -38
- package/dist/MetadataClient.d.ts.map +1 -0
- package/dist/MetadataClient.js +148 -0
- package/dist/MetadataClient.js.map +1 -0
- package/dist/OpenID4VCIClient.d.ts +75 -0
- package/dist/OpenID4VCIClient.d.ts.map +1 -0
- package/dist/OpenID4VCIClient.js +403 -0
- package/dist/OpenID4VCIClient.js.map +1 -0
- package/dist/ProofOfPossessionBuilder.d.ts +38 -0
- package/dist/ProofOfPossessionBuilder.d.ts.map +1 -0
- package/dist/ProofOfPossessionBuilder.js +129 -0
- package/dist/ProofOfPossessionBuilder.js.map +1 -0
- package/dist/functions/ProofUtil.d.ts +29 -0
- package/dist/functions/ProofUtil.d.ts.map +1 -0
- package/dist/functions/ProofUtil.js +104 -0
- package/dist/functions/ProofUtil.js.map +1 -0
- package/dist/functions/index.d.ts +4 -0
- package/dist/functions/index.d.ts.map +1 -0
- package/dist/{main → functions}/index.js +20 -18
- package/dist/functions/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/{main/lib/index.js → index.js} +25 -24
- package/dist/index.js.map +1 -0
- package/lib/AccessTokenClient.ts +249 -0
- package/lib/AuthorizationDetailsBuilder.ts +46 -0
- package/lib/CredentialOfferClient.ts +108 -0
- package/lib/CredentialRequestClient.ts +137 -0
- package/lib/CredentialRequestClientBuilder.ts +110 -0
- package/lib/MetadataClient.ts +147 -0
- package/lib/OpenID4VCIClient.ts +523 -0
- package/lib/ProofOfPossessionBuilder.ts +181 -0
- package/lib/__tests__/AccessTokenClient.spec.ts +225 -0
- package/lib/__tests__/AuthorizationDetailsBuilder.spec.ts +65 -0
- package/lib/__tests__/AuthzFlowType.spec.ts +39 -0
- package/lib/__tests__/CredentialRequestClient.spec.ts +291 -0
- package/lib/__tests__/CredentialRequestClientBuilder.spec.ts +121 -0
- package/lib/__tests__/HttpUtils.spec.ts +37 -0
- package/lib/__tests__/IT.spec.ts +173 -0
- package/lib/__tests__/IssuanceInitiation.spec.ts +48 -0
- package/lib/__tests__/JsonURIConversions.spec.ts +146 -0
- package/lib/__tests__/MetadataClient.spec.ts +203 -0
- package/lib/__tests__/MetadataMocks.ts +444 -0
- package/lib/__tests__/OpenID4VCIClient.spec.ts +166 -0
- package/lib/__tests__/OpenID4VCIClientPAR.spec.ts +112 -0
- package/lib/__tests__/ProofOfPossessionBuilder.spec.ts +110 -0
- package/lib/__tests__/data/VciDataFixtures.ts +744 -0
- package/lib/functions/ProofUtil.ts +120 -0
- package/lib/functions/index.ts +3 -0
- package/{dist/main/lib/index.d.ts → lib/index.ts} +8 -7
- package/package.json +68 -71
- package/CHANGELOG.md +0 -21
- package/dist/main/index.d.ts +0 -1
- package/dist/main/lib/AccessTokenClient.d.ts +0 -20
- package/dist/main/lib/AccessTokenClient.js +0 -141
- package/dist/main/lib/CredentialRequestClient.d.ts +0 -31
- package/dist/main/lib/CredentialRequestClient.js +0 -66
- package/dist/main/lib/CredentialRequestClientBuilder.d.ts +0 -21
- package/dist/main/lib/CredentialRequestClientBuilder.js +0 -56
- package/dist/main/lib/IssuanceInitiation.d.ts +0 -5
- package/dist/main/lib/IssuanceInitiation.js +0 -29
- package/dist/main/lib/MetadataClient.js +0 -127
- package/dist/main/lib/functions/Encoding.d.ts +0 -17
- package/dist/main/lib/functions/Encoding.js +0 -138
- package/dist/main/lib/functions/HttpUtils.d.ts +0 -17
- package/dist/main/lib/functions/HttpUtils.js +0 -133
- package/dist/main/lib/functions/ProofUtil.d.ts +0 -9
- package/dist/main/lib/functions/ProofUtil.js +0 -76
- package/dist/main/lib/functions/index.d.ts +0 -3
- package/dist/main/lib/functions/index.js +0 -20
- package/dist/main/lib/types/Authorization.types.d.ts +0 -66
- package/dist/main/lib/types/Authorization.types.js +0 -35
- package/dist/main/lib/types/CredentialIssuance.types.d.ts +0 -88
- package/dist/main/lib/types/CredentialIssuance.types.js +0 -8
- package/dist/main/lib/types/Generic.types.d.ts +0 -19
- package/dist/main/lib/types/Generic.types.js +0 -11
- package/dist/main/lib/types/OAuth2ASMetadata.d.ts +0 -37
- package/dist/main/lib/types/OAuth2ASMetadata.js +0 -3
- package/dist/main/lib/types/OID4VCIServerMetadata.d.ts +0 -65
- package/dist/main/lib/types/OID4VCIServerMetadata.js +0 -3
- package/dist/main/lib/types/Oidc4vciErrors.d.ts +0 -3
- package/dist/main/lib/types/Oidc4vciErrors.js +0 -7
- package/dist/main/lib/types/index.d.ts +0 -6
- package/dist/main/lib/types/index.js +0 -23
- package/dist/main/tsconfig.build.tsbuildinfo +0 -1
|
@@ -0,0 +1,403 @@
|
|
|
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.OpenID4VCIClient = void 0;
|
|
16
|
+
const oid4vci_common_1 = require("@sphereon/oid4vci-common");
|
|
17
|
+
const IssuerMetadataUtils_1 = require("@sphereon/oid4vci-common/dist/functions/IssuerMetadataUtils");
|
|
18
|
+
const debug_1 = __importDefault(require("debug"));
|
|
19
|
+
const AccessTokenClient_1 = require("./AccessTokenClient");
|
|
20
|
+
const CredentialOfferClient_1 = require("./CredentialOfferClient");
|
|
21
|
+
const CredentialRequestClientBuilder_1 = require("./CredentialRequestClientBuilder");
|
|
22
|
+
const MetadataClient_1 = require("./MetadataClient");
|
|
23
|
+
const ProofOfPossessionBuilder_1 = require("./ProofOfPossessionBuilder");
|
|
24
|
+
const functions_1 = require("./functions");
|
|
25
|
+
const debug = (0, debug_1.default)('sphereon:oid4vci');
|
|
26
|
+
class OpenID4VCIClient {
|
|
27
|
+
constructor(credentialOffer, flowType, kid, alg, clientId) {
|
|
28
|
+
if (!credentialOffer.supportedFlows.includes(flowType)) {
|
|
29
|
+
throw Error(`Flows ${flowType} is not supported by issuer ${credentialOffer.credential_offer_uri}`);
|
|
30
|
+
}
|
|
31
|
+
this._flowType = flowType;
|
|
32
|
+
this._credentialOffer = credentialOffer;
|
|
33
|
+
this._kid = kid;
|
|
34
|
+
this._alg = alg;
|
|
35
|
+
this._clientId = clientId;
|
|
36
|
+
}
|
|
37
|
+
static fromURI({ uri, flowType, kid, alg, retrieveServerMetadata, clientId, resolveOfferUri, }) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const client = new OpenID4VCIClient(yield CredentialOfferClient_1.CredentialOfferClient.fromURI(uri, { resolve: resolveOfferUri }), flowType, kid, alg, clientId);
|
|
40
|
+
if (retrieveServerMetadata === undefined || retrieveServerMetadata) {
|
|
41
|
+
yield client.retrieveServerMetadata();
|
|
42
|
+
}
|
|
43
|
+
return client;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
retrieveServerMetadata() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
this.assertIssuerData();
|
|
49
|
+
if (!this._endpointMetadata) {
|
|
50
|
+
this._endpointMetadata = yield MetadataClient_1.MetadataClient.retrieveAllMetadataFromCredentialOffer(this.credentialOffer);
|
|
51
|
+
}
|
|
52
|
+
return this.endpointMetadata;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
createAuthorizationRequestUrl({ clientId, codeChallengeMethod, codeChallenge, authorizationDetails, redirectUri, scope, }) {
|
|
56
|
+
var _a;
|
|
57
|
+
// Scope and authorization_details can be used in the same authorization request
|
|
58
|
+
// https://datatracker.ietf.org/doc/html/draft-ietf-oauth-rar-23#name-relationship-to-scope-param
|
|
59
|
+
if (!scope && !authorizationDetails) {
|
|
60
|
+
throw Error('Please provide a scope or authorization_details');
|
|
61
|
+
}
|
|
62
|
+
// todo: handling this because of the support for v1_0-08
|
|
63
|
+
if (this._endpointMetadata && this._endpointMetadata.issuerMetadata && 'authorization_endpoint' in this._endpointMetadata.issuerMetadata) {
|
|
64
|
+
this._endpointMetadata.authorization_endpoint = this._endpointMetadata.issuerMetadata.authorization_endpoint;
|
|
65
|
+
}
|
|
66
|
+
if (!((_a = this._endpointMetadata) === null || _a === void 0 ? void 0 : _a.authorization_endpoint)) {
|
|
67
|
+
throw Error('Server metadata does not contain authorization endpoint');
|
|
68
|
+
}
|
|
69
|
+
// add 'openid' scope if not present
|
|
70
|
+
if (scope && !scope.includes('openid')) {
|
|
71
|
+
scope = `openid ${scope}`;
|
|
72
|
+
}
|
|
73
|
+
//fixme: handle this for v11
|
|
74
|
+
const queryObj = {
|
|
75
|
+
response_type: oid4vci_common_1.ResponseType.AUTH_CODE,
|
|
76
|
+
client_id: clientId,
|
|
77
|
+
code_challenge_method: codeChallengeMethod,
|
|
78
|
+
code_challenge: codeChallenge,
|
|
79
|
+
authorization_details: JSON.stringify(this.handleAuthorizationDetails(authorizationDetails)),
|
|
80
|
+
redirect_uri: redirectUri,
|
|
81
|
+
scope: scope,
|
|
82
|
+
};
|
|
83
|
+
return (0, functions_1.convertJsonToURI)(queryObj, {
|
|
84
|
+
baseUrl: this._endpointMetadata.authorization_endpoint,
|
|
85
|
+
uriTypeProperties: ['redirect_uri', 'scope', 'authorization_details'],
|
|
86
|
+
version: this.version(),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
acquirePushedAuthorizationRequestURI({ clientId, codeChallengeMethod, codeChallenge, authorizationDetails, redirectUri, scope, }) {
|
|
90
|
+
var _a;
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
// Scope and authorization_details can be used in the same authorization request
|
|
93
|
+
// https://datatracker.ietf.org/doc/html/draft-ietf-oauth-rar-23#name-relationship-to-scope-param
|
|
94
|
+
if (!scope && !authorizationDetails) {
|
|
95
|
+
throw Error('Please provide a scope or authorization_details');
|
|
96
|
+
}
|
|
97
|
+
// Authorization servers supporting PAR SHOULD include the URL of their pushed authorization request endpoint in their authorization server metadata document
|
|
98
|
+
// Note that the presence of pushed_authorization_request_endpoint is sufficient for a client to determine that it may use the PAR flow.
|
|
99
|
+
// What happens if it doesn't ???
|
|
100
|
+
// let parEndpoint: string
|
|
101
|
+
if (!((_a = this._endpointMetadata) === null || _a === void 0 ? void 0 : _a.issuerMetadata) ||
|
|
102
|
+
!('pushed_authorization_request_endpoint' in this._endpointMetadata.issuerMetadata) ||
|
|
103
|
+
typeof this._endpointMetadata.issuerMetadata.pushed_authorization_request_endpoint !== 'string') {
|
|
104
|
+
throw Error('Server metadata does not contain pushed authorization request endpoint');
|
|
105
|
+
}
|
|
106
|
+
const parEndpoint = this._endpointMetadata.issuerMetadata.pushed_authorization_request_endpoint;
|
|
107
|
+
// add 'openid' scope if not present
|
|
108
|
+
if (scope && !scope.includes('openid')) {
|
|
109
|
+
scope = `openid ${scope}`;
|
|
110
|
+
}
|
|
111
|
+
//fixme: handle this for v11
|
|
112
|
+
const queryObj = {
|
|
113
|
+
response_type: oid4vci_common_1.ResponseType.AUTH_CODE,
|
|
114
|
+
client_id: clientId,
|
|
115
|
+
code_challenge_method: codeChallengeMethod,
|
|
116
|
+
code_challenge: codeChallenge,
|
|
117
|
+
authorization_details: JSON.stringify(this.handleAuthorizationDetails(authorizationDetails)),
|
|
118
|
+
redirect_uri: redirectUri,
|
|
119
|
+
scope: scope,
|
|
120
|
+
};
|
|
121
|
+
return yield (0, functions_1.formPost)(parEndpoint, JSON.stringify(queryObj));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
handleAuthorizationDetails(authorizationDetails) {
|
|
125
|
+
if (authorizationDetails) {
|
|
126
|
+
if (Array.isArray(authorizationDetails)) {
|
|
127
|
+
return authorizationDetails.map((value) => this.handleLocations(Object.assign({}, value)));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return this.handleLocations(Object.assign({}, authorizationDetails));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return authorizationDetails;
|
|
134
|
+
}
|
|
135
|
+
handleLocations(authorizationDetails) {
|
|
136
|
+
var _a;
|
|
137
|
+
if (authorizationDetails && (((_a = this.endpointMetadata.issuerMetadata) === null || _a === void 0 ? void 0 : _a.authorization_server) || this.endpointMetadata.authorization_endpoint)) {
|
|
138
|
+
if (authorizationDetails.locations) {
|
|
139
|
+
if (Array.isArray(authorizationDetails.locations)) {
|
|
140
|
+
authorizationDetails.locations.push(this.endpointMetadata.issuer);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
authorizationDetails.locations = [authorizationDetails.locations, this.endpointMetadata.issuer];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
authorizationDetails.locations = this.endpointMetadata.issuer;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return authorizationDetails;
|
|
151
|
+
}
|
|
152
|
+
acquireAccessToken(opts) {
|
|
153
|
+
var _a, _b;
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const { pin, clientId, codeVerifier, code, redirectUri } = opts !== null && opts !== void 0 ? opts : {};
|
|
156
|
+
this.assertIssuerData();
|
|
157
|
+
if (clientId) {
|
|
158
|
+
this._clientId = clientId;
|
|
159
|
+
}
|
|
160
|
+
if (!this._accessTokenResponse) {
|
|
161
|
+
const accessTokenClient = new AccessTokenClient_1.AccessTokenClient();
|
|
162
|
+
const response = yield accessTokenClient.acquireAccessToken({
|
|
163
|
+
credentialOffer: this.credentialOffer,
|
|
164
|
+
metadata: this.endpointMetadata,
|
|
165
|
+
pin,
|
|
166
|
+
codeVerifier,
|
|
167
|
+
code,
|
|
168
|
+
redirectUri,
|
|
169
|
+
asOpts: { clientId },
|
|
170
|
+
});
|
|
171
|
+
if (response.errorBody) {
|
|
172
|
+
debug(`Access token error:\r\n${response.errorBody}`);
|
|
173
|
+
throw Error(`Retrieving an access token from ${(_a = this._endpointMetadata) === null || _a === void 0 ? void 0 : _a.token_endpoint} for issuer ${this.getIssuer()} failed with status: ${response.origResponse.status}`);
|
|
174
|
+
}
|
|
175
|
+
else if (!response.successBody) {
|
|
176
|
+
debug(`Access token error. No success body`);
|
|
177
|
+
throw Error(`Retrieving an access token from ${(_b = this._endpointMetadata) === null || _b === void 0 ? void 0 : _b.token_endpoint} for issuer ${this.getIssuer()} failed as there was no success response body`);
|
|
178
|
+
}
|
|
179
|
+
this._accessTokenResponse = response.successBody;
|
|
180
|
+
}
|
|
181
|
+
return this.accessTokenResponse;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
acquireCredentials({ credentialTypes, proofCallbacks, format, kid, alg, jti, }) {
|
|
185
|
+
var _a, _b, _c;
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
if (alg) {
|
|
188
|
+
this._alg = alg;
|
|
189
|
+
}
|
|
190
|
+
if (kid) {
|
|
191
|
+
this._kid = kid;
|
|
192
|
+
}
|
|
193
|
+
const requestBuilder = CredentialRequestClientBuilder_1.CredentialRequestClientBuilder.fromCredentialOffer({
|
|
194
|
+
credentialOffer: this.credentialOffer,
|
|
195
|
+
metadata: this.endpointMetadata,
|
|
196
|
+
});
|
|
197
|
+
requestBuilder.withTokenFromResponse(this.accessTokenResponse);
|
|
198
|
+
if ((_a = this.endpointMetadata) === null || _a === void 0 ? void 0 : _a.issuerMetadata) {
|
|
199
|
+
const metadata = this.endpointMetadata.issuerMetadata;
|
|
200
|
+
const types = Array.isArray(credentialTypes) ? credentialTypes : [credentialTypes];
|
|
201
|
+
if (metadata.credentials_supported && Array.isArray(metadata.credentials_supported)) {
|
|
202
|
+
for (const type of types) {
|
|
203
|
+
let typeSupported = false;
|
|
204
|
+
for (const credentialSupported of metadata.credentials_supported) {
|
|
205
|
+
if (!credentialSupported.types || credentialSupported.types.length === 0) {
|
|
206
|
+
throw Error('types is required in the credentials supported');
|
|
207
|
+
}
|
|
208
|
+
if (credentialSupported.types.indexOf(type) != -1) {
|
|
209
|
+
typeSupported = true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (!typeSupported) {
|
|
213
|
+
throw Error(`Not all credential types ${JSON.stringify(credentialTypes)} are supported by issuer ${this.getIssuer()}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else if (metadata.credentials_supported && !Array.isArray(metadata.credentials_supported)) {
|
|
218
|
+
const credentialsSupported = metadata.credentials_supported;
|
|
219
|
+
if (types.some((type) => !metadata.credentials_supported || !credentialsSupported[type])) {
|
|
220
|
+
throw Error(`Not all credential types ${JSON.stringify(credentialTypes)} are supported by issuer ${this.getIssuer()}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// todo: Format check? We might end up with some disjoint type / format combinations supported by the server
|
|
224
|
+
}
|
|
225
|
+
const credentialRequestClient = requestBuilder.build();
|
|
226
|
+
const proofBuilder = ProofOfPossessionBuilder_1.ProofOfPossessionBuilder.fromAccessTokenResponse({
|
|
227
|
+
accessTokenResponse: this.accessTokenResponse,
|
|
228
|
+
callbacks: proofCallbacks,
|
|
229
|
+
version: this.version(),
|
|
230
|
+
})
|
|
231
|
+
.withIssuer(this.getIssuer())
|
|
232
|
+
.withAlg(this.alg)
|
|
233
|
+
.withKid(this.kid);
|
|
234
|
+
if (this.clientId) {
|
|
235
|
+
proofBuilder.withClientId(this.clientId);
|
|
236
|
+
}
|
|
237
|
+
if (jti) {
|
|
238
|
+
proofBuilder.withJti(jti);
|
|
239
|
+
}
|
|
240
|
+
const response = yield credentialRequestClient.acquireCredentialsUsingProof({
|
|
241
|
+
proofInput: proofBuilder,
|
|
242
|
+
credentialTypes: credentialTypes,
|
|
243
|
+
format,
|
|
244
|
+
});
|
|
245
|
+
if (response.errorBody) {
|
|
246
|
+
debug(`Credential request error:\r\n${response.errorBody}`);
|
|
247
|
+
throw Error(`Retrieving a credential from ${(_b = this._endpointMetadata) === null || _b === void 0 ? void 0 : _b.credential_endpoint} for issuer ${this.getIssuer()} failed with status: ${response.origResponse.status}`);
|
|
248
|
+
}
|
|
249
|
+
else if (!response.successBody) {
|
|
250
|
+
debug(`Credential request error. No success body`);
|
|
251
|
+
throw Error(`Retrieving a credential from ${(_c = this._endpointMetadata) === null || _c === void 0 ? void 0 : _c.credential_endpoint} for issuer ${this.getIssuer()} failed as there was no success response body`);
|
|
252
|
+
}
|
|
253
|
+
return response.successBody;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
getCredentialsSupported(restrictToInitiationTypes, supportedType) {
|
|
257
|
+
return (0, IssuerMetadataUtils_1.getSupportedCredentials)({
|
|
258
|
+
issuerMetadata: this.endpointMetadata.issuerMetadata,
|
|
259
|
+
version: this.version(),
|
|
260
|
+
supportedType,
|
|
261
|
+
credentialTypes: restrictToInitiationTypes ? this.getCredentialTypes() : undefined,
|
|
262
|
+
});
|
|
263
|
+
/*//FIXME: delegate to getCredentialsSupported from IssuerMetadataUtils
|
|
264
|
+
let credentialsSupported = this.endpointMetadata?.issuerMetadata?.credentials_supported
|
|
265
|
+
|
|
266
|
+
if (this.version() === OpenId4VCIVersion.VER_1_0_08 || typeof credentialsSupported === 'object') {
|
|
267
|
+
const issuerMetadata = this.endpointMetadata.issuerMetadata as IssuerMetadataV1_0_08
|
|
268
|
+
const v8CredentialsSupported = issuerMetadata.credentials_supported
|
|
269
|
+
credentialsSupported = []
|
|
270
|
+
credentialsSupported = Object.entries(v8CredentialsSupported).map((key, value) => )
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
if (!credentialsSupported) {
|
|
276
|
+
return []
|
|
277
|
+
} else if (!restrictToInitiationTypes) {
|
|
278
|
+
return credentialsSupported
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
/!**
|
|
284
|
+
* the following (not array part is a legacy code from version 1_0-08 which jff implementors used)
|
|
285
|
+
*!/
|
|
286
|
+
if (!Array.isArray(credentialsSupported)) {
|
|
287
|
+
const credentialsSupportedV8: CredentialSupportedV1_0_08 = credentialsSupported as CredentialSupportedV1_0_08;
|
|
288
|
+
const initiationTypes = supportedType ? [supportedType] : this.getCredentialTypes();
|
|
289
|
+
const supported: IssuerCredentialSubject = {};
|
|
290
|
+
for (const [key, value] of Object.entries(credentialsSupportedV8)) {
|
|
291
|
+
if (initiationTypes.includes(key)) {
|
|
292
|
+
supported[key] = value;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// todo: fix this later. we're returning CredentialSupportedV1_0_08 as a list of CredentialSupported (for v09 onward)
|
|
296
|
+
return supported as unknown as CredentialSupported[];
|
|
297
|
+
}
|
|
298
|
+
const initiationTypes = supportedType ? [supportedType] : this.getCredentialTypes()
|
|
299
|
+
const credentialSupportedOverlap: CredentialSupported[] = []
|
|
300
|
+
for (const supported of credentialsSupported) {
|
|
301
|
+
const supportedTypeOverlap: string[] = []
|
|
302
|
+
for (const type of supported.types) {
|
|
303
|
+
initiationTypes.includes(type)
|
|
304
|
+
supportedTypeOverlap.push(type)
|
|
305
|
+
}
|
|
306
|
+
if (supportedTypeOverlap.length > 0) {
|
|
307
|
+
credentialSupportedOverlap.push({
|
|
308
|
+
...supported,
|
|
309
|
+
types: supportedTypeOverlap
|
|
310
|
+
})
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return credentialSupportedOverlap as CredentialSupported[]*/
|
|
314
|
+
}
|
|
315
|
+
getCredentialMetadata(type) {
|
|
316
|
+
return this.getCredentialsSupported(false, type);
|
|
317
|
+
}
|
|
318
|
+
// todo https://sphereon.atlassian.net/browse/VDX-184
|
|
319
|
+
getCredentialTypes() {
|
|
320
|
+
if (this.credentialOffer.version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11) {
|
|
321
|
+
return typeof this.credentialOffer.original_credential_offer.credential_type === 'string'
|
|
322
|
+
? [this.credentialOffer.original_credential_offer.credential_type]
|
|
323
|
+
: this.credentialOffer.original_credential_offer.credential_type;
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
// FIXME: this for sure isn't correct. It would also include VerifiableCredential. The whole call to this getCredentialsTypes should be changed to begin with
|
|
327
|
+
return this.credentialOffer.credential_offer.credentials.flatMap((c) => (typeof c === 'string' ? c : c.types));
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
get flowType() {
|
|
331
|
+
return this._flowType;
|
|
332
|
+
}
|
|
333
|
+
issuerSupportedFlowTypes() {
|
|
334
|
+
return this.credentialOffer.supportedFlows;
|
|
335
|
+
}
|
|
336
|
+
get credentialOffer() {
|
|
337
|
+
return this._credentialOffer;
|
|
338
|
+
}
|
|
339
|
+
version() {
|
|
340
|
+
return this.credentialOffer.version;
|
|
341
|
+
}
|
|
342
|
+
get endpointMetadata() {
|
|
343
|
+
this.assertServerMetadata();
|
|
344
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
345
|
+
return this._endpointMetadata;
|
|
346
|
+
}
|
|
347
|
+
get kid() {
|
|
348
|
+
this.assertIssuerData();
|
|
349
|
+
if (!this._kid) {
|
|
350
|
+
throw new Error('No value for kid is supplied');
|
|
351
|
+
}
|
|
352
|
+
return this._kid;
|
|
353
|
+
}
|
|
354
|
+
get alg() {
|
|
355
|
+
this.assertIssuerData();
|
|
356
|
+
if (!this._alg) {
|
|
357
|
+
throw new Error('No value for alg is supplied');
|
|
358
|
+
}
|
|
359
|
+
return this._alg;
|
|
360
|
+
}
|
|
361
|
+
get clientId() {
|
|
362
|
+
/*if (!this._clientId) {
|
|
363
|
+
throw Error('No client id present');
|
|
364
|
+
}*/
|
|
365
|
+
return this._clientId;
|
|
366
|
+
}
|
|
367
|
+
get accessTokenResponse() {
|
|
368
|
+
this.assertAccessToken();
|
|
369
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
370
|
+
return this._accessTokenResponse;
|
|
371
|
+
}
|
|
372
|
+
getIssuer() {
|
|
373
|
+
this.assertIssuerData();
|
|
374
|
+
return this._endpointMetadata ? this.endpointMetadata.issuer : this.getIssuer();
|
|
375
|
+
}
|
|
376
|
+
getAccessTokenEndpoint() {
|
|
377
|
+
this.assertIssuerData();
|
|
378
|
+
return this.endpointMetadata
|
|
379
|
+
? this.endpointMetadata.token_endpoint
|
|
380
|
+
: AccessTokenClient_1.AccessTokenClient.determineTokenURL({ issuerOpts: { issuer: this.getIssuer() } });
|
|
381
|
+
}
|
|
382
|
+
getCredentialEndpoint() {
|
|
383
|
+
this.assertIssuerData();
|
|
384
|
+
return this.endpointMetadata ? this.endpointMetadata.credential_endpoint : `${this.getIssuer()}/credential`;
|
|
385
|
+
}
|
|
386
|
+
assertIssuerData() {
|
|
387
|
+
if (!this._credentialOffer) {
|
|
388
|
+
throw Error(`No issuance initiation or credential offer present`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
assertServerMetadata() {
|
|
392
|
+
if (!this._endpointMetadata) {
|
|
393
|
+
throw Error('No server metadata');
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
assertAccessToken() {
|
|
397
|
+
if (!this._accessTokenResponse) {
|
|
398
|
+
throw Error(`No access token present`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
exports.OpenID4VCIClient = OpenID4VCIClient;
|
|
403
|
+
//# sourceMappingURL=OpenID4VCIClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenID4VCIClient.js","sourceRoot":"","sources":["../lib/OpenID4VCIClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAiBkC;AAClC,qGAAsG;AAGtG,kDAA0B;AAE1B,2DAAwD;AACxD,mEAAgE;AAChE,qFAAkF;AAClF,qDAAkD;AAClD,yEAAsE;AACtE,2CAAyD;AAEzD,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,kBAAkB,CAAC,CAAC;AAmBxC,MAAa,gBAAgB;IAS3B,YACE,eAAkD,EAClD,QAAuB,EACvB,GAAY,EACZ,GAAkB,EAClB,QAAiB;QAEjB,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACtD,MAAM,KAAK,CAAC,SAAS,QAAQ,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gBAAgB,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,gBAAgB;YAC1B,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,cAAc;YACtC,CAAC,CAAC,qCAAiB,CAAC,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;IACxF,CAAC;IAEM,qBAAqB;QAC1B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC;IAC9G,CAAC;IAEO,gBAAgB;QACtB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YAC1B,MAAM,KAAK,CAAC,oDAAoD,CAAC,CAAC;SACnE;IACH,CAAC;IAEO,oBAAoB;QAC1B,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC3B,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;SACnC;IACH,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC9B,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAC;SACxC;IACH,CAAC;CACF;AAzdD,4CAydC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AccessTokenResponse, Alg, EndpointMetadata, Jwt, OpenId4VCIVersion, ProofOfPossession, ProofOfPossessionCallbacks, Typ } from '@sphereon/oid4vci-common';
|
|
2
|
+
export declare class ProofOfPossessionBuilder {
|
|
3
|
+
private readonly proof?;
|
|
4
|
+
private readonly callbacks?;
|
|
5
|
+
private version;
|
|
6
|
+
private kid?;
|
|
7
|
+
private clientId?;
|
|
8
|
+
private issuer?;
|
|
9
|
+
private jwt?;
|
|
10
|
+
private alg?;
|
|
11
|
+
private jti?;
|
|
12
|
+
private cNonce?;
|
|
13
|
+
private typ?;
|
|
14
|
+
private constructor();
|
|
15
|
+
static fromJwt({ jwt, callbacks, version, }: {
|
|
16
|
+
jwt: Jwt;
|
|
17
|
+
callbacks: ProofOfPossessionCallbacks;
|
|
18
|
+
version: OpenId4VCIVersion;
|
|
19
|
+
}): ProofOfPossessionBuilder;
|
|
20
|
+
static fromAccessTokenResponse({ accessTokenResponse, callbacks, version, }: {
|
|
21
|
+
accessTokenResponse: AccessTokenResponse;
|
|
22
|
+
callbacks: ProofOfPossessionCallbacks;
|
|
23
|
+
version: OpenId4VCIVersion;
|
|
24
|
+
}): ProofOfPossessionBuilder;
|
|
25
|
+
static fromProof(proof: ProofOfPossession, version: OpenId4VCIVersion): ProofOfPossessionBuilder;
|
|
26
|
+
withClientId(clientId: string): ProofOfPossessionBuilder;
|
|
27
|
+
withKid(kid: string): ProofOfPossessionBuilder;
|
|
28
|
+
withIssuer(issuer: string): ProofOfPossessionBuilder;
|
|
29
|
+
withAlg(alg: Alg | string): ProofOfPossessionBuilder;
|
|
30
|
+
withJti(jti: string): ProofOfPossessionBuilder;
|
|
31
|
+
withTyp(typ: Typ): ProofOfPossessionBuilder;
|
|
32
|
+
withAccessTokenNonce(cNonce: string): ProofOfPossessionBuilder;
|
|
33
|
+
withAccessTokenResponse(accessToken: AccessTokenResponse): ProofOfPossessionBuilder;
|
|
34
|
+
withEndpointMetadata(endpointMetadata: EndpointMetadata): ProofOfPossessionBuilder;
|
|
35
|
+
withJwt(jwt: Jwt): ProofOfPossessionBuilder;
|
|
36
|
+
build(): Promise<ProofOfPossession>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ProofOfPossessionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProofOfPossessionBuilder.d.ts","sourceRoot":"","sources":["../lib/ProofOfPossessionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,GAAG,EACH,gBAAgB,EAChB,GAAG,E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M,GAAG,wBAAwB;IAKpD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,wBAAwB;IAK9C,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,wBAAwB;IAK3C,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,wBAAwB;IAK9D,uBAAuB,CAAC,WAAW,EAAE,mBAAmB,GAAG,wBAAwB;IAOnF,oBAAoB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,wBAAwB;IAKlF,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,wBAAwB;IA+B9B,KAAK,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAoBjD"}
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ProofOfPossessionBuilder = void 0;
|
|
13
|
+
const oid4vci_common_1 = require("@sphereon/oid4vci-common");
|
|
14
|
+
const functions_1 = require("./functions");
|
|
15
|
+
class ProofOfPossessionBuilder {
|
|
16
|
+
constructor({ proof, callbacks, jwt, accessTokenResponse, version, }) {
|
|
17
|
+
this.proof = proof;
|
|
18
|
+
this.callbacks = callbacks;
|
|
19
|
+
if (jwt) {
|
|
20
|
+
this.withJwt(jwt);
|
|
21
|
+
}
|
|
22
|
+
if (accessTokenResponse) {
|
|
23
|
+
this.withAccessTokenResponse(accessTokenResponse);
|
|
24
|
+
}
|
|
25
|
+
this.version = version;
|
|
26
|
+
}
|
|
27
|
+
static fromJwt({ jwt, callbacks, version, }) {
|
|
28
|
+
return new ProofOfPossessionBuilder({ callbacks, jwt, version });
|
|
29
|
+
}
|
|
30
|
+
static fromAccessTokenResponse({ accessTokenResponse, callbacks, version, }) {
|
|
31
|
+
return new ProofOfPossessionBuilder({ callbacks, accessTokenResponse, version });
|
|
32
|
+
}
|
|
33
|
+
static fromProof(proof, version) {
|
|
34
|
+
return new ProofOfPossessionBuilder({ proof, version });
|
|
35
|
+
}
|
|
36
|
+
withClientId(clientId) {
|
|
37
|
+
this.clientId = clientId;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
withKid(kid) {
|
|
41
|
+
this.kid = kid;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
withIssuer(issuer) {
|
|
45
|
+
this.issuer = issuer;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
withAlg(alg) {
|
|
49
|
+
this.alg = alg;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
withJti(jti) {
|
|
53
|
+
this.jti = jti;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
withTyp(typ) {
|
|
57
|
+
this.typ = typ;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
withAccessTokenNonce(cNonce) {
|
|
61
|
+
this.cNonce = cNonce;
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
withAccessTokenResponse(accessToken) {
|
|
65
|
+
if (accessToken.c_nonce) {
|
|
66
|
+
this.withAccessTokenNonce(accessToken.c_nonce);
|
|
67
|
+
}
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
withEndpointMetadata(endpointMetadata) {
|
|
71
|
+
this.withIssuer(endpointMetadata.issuer);
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
withJwt(jwt) {
|
|
75
|
+
if (!jwt) {
|
|
76
|
+
throw new Error(oid4vci_common_1.NO_JWT_PROVIDED);
|
|
77
|
+
}
|
|
78
|
+
this.jwt = jwt;
|
|
79
|
+
if (!jwt.header) {
|
|
80
|
+
throw Error(`No JWT header present`);
|
|
81
|
+
}
|
|
82
|
+
else if (!jwt.payload) {
|
|
83
|
+
throw Error(`No JWT payload present`);
|
|
84
|
+
}
|
|
85
|
+
if (jwt.header.kid) {
|
|
86
|
+
this.withKid(jwt.header.kid);
|
|
87
|
+
}
|
|
88
|
+
if (jwt.header.typ) {
|
|
89
|
+
this.withTyp(jwt.header.typ);
|
|
90
|
+
}
|
|
91
|
+
if (this.version >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11) {
|
|
92
|
+
this.withTyp('openid4vci-proof+jwt');
|
|
93
|
+
}
|
|
94
|
+
this.withAlg(jwt.header.alg);
|
|
95
|
+
if (jwt.payload) {
|
|
96
|
+
if (jwt.payload.iss)
|
|
97
|
+
this.withClientId(jwt.payload.iss);
|
|
98
|
+
if (jwt.payload.aud)
|
|
99
|
+
this.withIssuer(jwt.payload.aud);
|
|
100
|
+
if (jwt.payload.jti)
|
|
101
|
+
this.withJti(jwt.payload.jti);
|
|
102
|
+
if (jwt.payload.nonce)
|
|
103
|
+
this.withAccessTokenNonce(jwt.payload.nonce);
|
|
104
|
+
}
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
build() {
|
|
108
|
+
var _a;
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
if (this.proof) {
|
|
111
|
+
return Promise.resolve(this.proof);
|
|
112
|
+
}
|
|
113
|
+
else if (this.callbacks) {
|
|
114
|
+
return yield (0, functions_1.createProofOfPossession)(this.callbacks, {
|
|
115
|
+
typ: (_a = this.typ) !== null && _a !== void 0 ? _a : (this.version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11 ? 'jwt' : 'openid4vci-proof+jwt'),
|
|
116
|
+
kid: this.kid,
|
|
117
|
+
jti: this.jti,
|
|
118
|
+
alg: this.alg,
|
|
119
|
+
issuer: this.issuer,
|
|
120
|
+
clientId: this.clientId,
|
|
121
|
+
nonce: this.cNonce,
|
|
122
|
+
}, this.jwt);
|
|
123
|
+
}
|
|
124
|
+
throw new Error(oid4vci_common_1.PROOF_CANT_BE_CONSTRUCTED);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.ProofOfPossessionBuilder = ProofOfPossessionBuilder;
|
|
129
|
+
//# sourceMappingURL=ProofOfPossessionBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProofOfPossessionBuilder.js","sourceRoot":"","sources":["../lib/ProofOfPossessionBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAWkC;AAElC,2CAAsD;AAEtD,MAAa,wBAAwB;IAenC,YAAoB,EAClB,KAAK,EACL,SAAS,EACT,GAAG,EACH,mBAAmB,EACnB,OAAO,GAOR;QACC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SACnB;QACD,IAAI,mBAAmB,EAAE;YACvB,IAAI,CAAC,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;SACnD;QACD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,EACb,GAAG,EACH,SAAS,EACT,OAAO,GAKR;QACC,OAAO,IAAI,wBAAwB,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,CAAC,uBAAuB,CAAC,EAC7B,mBAAmB,EACnB,SAAS,EACT,OAAO,GAKR;QACC,OAAO,IAAI,wBAAwB,CAAC,EAAE,SAAS,EAAE,mBAAmB,EA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CAAC;IACd,CAAC;IAEY,KAAK;;;YAChB,IAAI,IAAI,CAAC,KAAK,EAAE;gBACd,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpC;iBAAM,IAAI,IAAI,CAAC,SAAS,EAAE;gBACzB,OAAO,MAAM,IAAA,mCAAuB,EAClC,IAAI,CAAC,SAAS,EACd;oBACE,GAAG,EAAE,MAAA,IAAI,CAAC,GAAG,mCAAI,CAAC,IAAI,CAAC,OAAO,GAAG,kCAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,sBAAsB,CAAC;oBAC/F,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,KAAK,EAAE,IAAI,CAAC,MAAM;iBACnB,EACD,IAAI,CAAC,GAAG,CACT,CAAC;aACH;YACD,MAAM,IAAI,KAAK,CAAC,0CAAyB,CAAC,CAAC;;KAC5C;CACF;AArKD,4DAqKC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Jwt, ProofOfPossession, ProofOfPossessionCallbacks, Typ } from '@sphereon/oid4vci-common';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* - proofOfPossessionCallback: JWTSignerCallback
|
|
5
|
+
* Mandatory if you want to create (sign) ProofOfPossession
|
|
6
|
+
* - proofOfPossessionVerifierCallback?: JWTVerifyCallback
|
|
7
|
+
* If exists, verifies the ProofOfPossession
|
|
8
|
+
* - proofOfPossessionCallbackArgs: ProofOfPossessionCallbackArgs
|
|
9
|
+
* arguments needed for signing ProofOfPossession
|
|
10
|
+
* @param callbacks:
|
|
11
|
+
* - proofOfPossessionCallback: JWTSignerCallback
|
|
12
|
+
* Mandatory to create (sign) ProofOfPossession
|
|
13
|
+
* - proofOfPossessionVerifierCallback?: JWTVerifyCallback
|
|
14
|
+
* If exists, verifies the ProofOfPossession
|
|
15
|
+
* @param jwtProps
|
|
16
|
+
* @param existingJwt
|
|
17
|
+
* - Optional, clientId of the party requesting the credential
|
|
18
|
+
*/
|
|
19
|
+
export declare const createProofOfPossession: (callbacks: ProofOfPossessionCallbacks, jwtProps?: JwtProps, existingJwt?: Jwt) => Promise<ProofOfPossession>;
|
|
20
|
+
export interface JwtProps {
|
|
21
|
+
typ?: Typ;
|
|
22
|
+
kid?: string;
|
|
23
|
+
issuer?: string;
|
|
24
|
+
clientId?: string;
|
|
25
|
+
alg?: string;
|
|
26
|
+
jti?: string;
|
|
27
|
+
nonce?: string;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ProofUtil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProofUtil.d.ts","sourceRoot":"","sources":["../../lib/functions/ProofUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,GAAG,EAAyB,iBAAiB,EAAE,0BAA0B,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAKrJ;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,cACvB,0BAA0B,aAC1B,QAAQ,gBACL,GAAG,KAChB,QAAQ,iBAAiB,CA0B3B,CAAC;AAQF,MAAM,WAAW,QAAQ;IACvB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|