@sphereon/oid4vci-client 0.10.3-next.8 → 0.10.4-next.119
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/README.md +24 -5
- package/dist/AccessTokenClient.d.ts +5 -5
- package/dist/AccessTokenClient.d.ts.map +1 -1
- package/dist/AccessTokenClient.js +51 -37
- package/dist/AccessTokenClient.js.map +1 -1
- package/dist/AccessTokenClientV1_0_11.d.ts +29 -0
- package/dist/AccessTokenClientV1_0_11.d.ts.map +1 -0
- package/dist/AccessTokenClientV1_0_11.js +209 -0
- package/dist/AccessTokenClientV1_0_11.js.map +1 -0
- package/dist/AuthorizationCodeClient.d.ts +9 -4
- package/dist/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/AuthorizationCodeClient.js +102 -18
- package/dist/AuthorizationCodeClient.js.map +1 -1
- package/dist/AuthorizationCodeClientV1_0_11.d.ts +9 -0
- package/dist/AuthorizationCodeClientV1_0_11.d.ts.map +1 -0
- package/dist/AuthorizationCodeClientV1_0_11.js +134 -0
- package/dist/AuthorizationCodeClientV1_0_11.js.map +1 -0
- package/dist/CredentialOfferClient.d.ts.map +1 -1
- package/dist/CredentialOfferClient.js +18 -13
- package/dist/CredentialOfferClient.js.map +1 -1
- package/dist/CredentialOfferClientV1_0_11.d.ts +10 -0
- package/dist/CredentialOfferClientV1_0_11.d.ts.map +1 -0
- package/dist/CredentialOfferClientV1_0_11.js +101 -0
- package/dist/CredentialOfferClientV1_0_11.js.map +1 -0
- package/dist/CredentialOfferClientV1_0_13.d.ts +10 -0
- package/dist/CredentialOfferClientV1_0_13.d.ts.map +1 -0
- package/dist/CredentialOfferClientV1_0_13.js +94 -0
- package/dist/CredentialOfferClientV1_0_13.js.map +1 -0
- package/dist/CredentialRequestClient.d.ts +20 -7
- package/dist/CredentialRequestClient.d.ts.map +1 -1
- package/dist/CredentialRequestClient.js +46 -30
- package/dist/CredentialRequestClient.js.map +1 -1
- package/dist/CredentialRequestClientBuilder.d.ts +11 -6
- package/dist/CredentialRequestClientBuilder.d.ts.map +1 -1
- package/dist/CredentialRequestClientBuilder.js +22 -9
- package/dist/CredentialRequestClientBuilder.js.map +1 -1
- package/dist/CredentialRequestClientBuilderV1_0_11.d.ts +48 -0
- package/dist/CredentialRequestClientBuilderV1_0_11.d.ts.map +1 -0
- package/dist/CredentialRequestClientBuilderV1_0_11.js +121 -0
- package/dist/CredentialRequestClientBuilderV1_0_11.js.map +1 -0
- package/dist/CredentialRequestClientV1_0_11.d.ts +50 -0
- package/dist/CredentialRequestClientV1_0_11.d.ts.map +1 -0
- package/dist/CredentialRequestClientV1_0_11.js +151 -0
- package/dist/CredentialRequestClientV1_0_11.js.map +1 -0
- package/dist/MetadataClient.d.ts +5 -15
- package/dist/MetadataClient.d.ts.map +1 -1
- package/dist/MetadataClient.js +41 -44
- package/dist/MetadataClient.js.map +1 -1
- package/dist/MetadataClientV1_0_11.d.ts +31 -0
- package/dist/MetadataClientV1_0_11.d.ts.map +1 -0
- package/dist/MetadataClientV1_0_11.js +182 -0
- package/dist/MetadataClientV1_0_11.js.map +1 -0
- package/dist/MetadataClientV1_0_13.d.ts +31 -0
- package/dist/MetadataClientV1_0_13.d.ts.map +1 -0
- package/dist/MetadataClientV1_0_13.js +181 -0
- package/dist/MetadataClientV1_0_13.js.map +1 -0
- package/dist/OpenID4VCIClient.d.ts +14 -19
- package/dist/OpenID4VCIClient.d.ts.map +1 -1
- package/dist/OpenID4VCIClient.js +111 -61
- package/dist/OpenID4VCIClient.js.map +1 -1
- package/dist/OpenID4VCIClientV1_0_11.d.ts +108 -0
- package/dist/OpenID4VCIClientV1_0_11.d.ts.map +1 -0
- package/dist/OpenID4VCIClientV1_0_11.js +449 -0
- package/dist/OpenID4VCIClientV1_0_11.js.map +1 -0
- package/dist/OpenID4VCIClientV1_0_13.d.ts +112 -0
- package/dist/OpenID4VCIClientV1_0_13.d.ts.map +1 -0
- package/dist/OpenID4VCIClientV1_0_13.js +478 -0
- package/dist/OpenID4VCIClientV1_0_13.js.map +1 -0
- package/dist/ProofOfPossessionBuilder.d.ts +14 -3
- package/dist/ProofOfPossessionBuilder.d.ts.map +1 -1
- package/dist/ProofOfPossessionBuilder.js +20 -21
- package/dist/ProofOfPossessionBuilder.js.map +1 -1
- package/dist/functions/OpenIDUtils.d.ts +12 -0
- package/dist/functions/OpenIDUtils.d.ts.map +1 -0
- package/dist/functions/OpenIDUtils.js +37 -0
- package/dist/functions/OpenIDUtils.js.map +1 -0
- package/dist/functions/index.d.ts +2 -3
- package/dist/functions/index.d.ts.map +1 -1
- package/dist/functions/index.js +2 -3
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/notifications.d.ts +4 -0
- package/dist/functions/notifications.d.ts.map +1 -0
- package/dist/functions/notifications.js +39 -0
- package/dist/functions/notifications.js.map +1 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -1
- package/lib/AccessTokenClient.ts +59 -34
- package/lib/AccessTokenClientV1_0_11.ts +250 -0
- package/lib/AuthorizationCodeClient.ts +131 -28
- package/lib/AuthorizationCodeClientV1_0_11.ts +170 -0
- package/lib/CredentialOfferClient.ts +21 -8
- package/lib/CredentialOfferClientV1_0_11.ts +112 -0
- package/lib/CredentialOfferClientV1_0_13.ts +103 -0
- package/lib/CredentialRequestClient.ts +65 -26
- package/lib/CredentialRequestClientBuilder.ts +34 -16
- package/lib/CredentialRequestClientBuilderV1_0_11.ts +163 -0
- package/lib/CredentialRequestClientV1_0_11.ts +197 -0
- package/lib/MetadataClient.ts +64 -49
- package/lib/MetadataClientV1_0_11.ts +189 -0
- package/lib/MetadataClientV1_0_13.ts +188 -0
- package/lib/OpenID4VCIClient.ts +132 -68
- package/lib/OpenID4VCIClientV1_0_11.ts +635 -0
- package/lib/OpenID4VCIClientV1_0_13.ts +677 -0
- package/lib/ProofOfPossessionBuilder.ts +41 -11
- package/lib/__tests__/AccessTokenClient.spec.ts +40 -12
- package/lib/__tests__/AuthorizationDetailsBuilder.spec.ts +0 -12
- package/lib/__tests__/CredentialRequestClient.spec.ts +87 -50
- package/lib/__tests__/CredentialRequestClientBuilder.spec.ts +18 -12
- package/lib/__tests__/CredentialRequestClientV1_0_11.spec.ts +317 -0
- package/lib/__tests__/EBSIE2E.spec.test.ts +2 -2
- package/lib/__tests__/HttpUtils.spec.ts +1 -1
- package/lib/__tests__/IT.spec.ts +264 -14
- package/lib/__tests__/IssuanceInitiation.spec.ts +59 -4
- package/lib/__tests__/IssuanceInitiationV1_0_11.spec.ts +62 -0
- package/lib/__tests__/MattrE2E.spec.test.ts +2 -2
- package/lib/__tests__/MetadataClient.spec.ts +53 -3
- package/lib/__tests__/MetadataMocks.ts +42 -2
- package/lib/__tests__/OpenID4VCIClient.spec.ts +58 -2
- package/lib/__tests__/{OpenID4VCIClientPAR.spec.ts → OpenID4VCIClientPARV1_0_11.spec.ts} +5 -5
- package/lib/__tests__/OpenID4VCIClientV1_0_11.spec.ts +226 -0
- package/lib/__tests__/OpenID4VCIClientV1_0_13.spec.ts +204 -0
- package/lib/__tests__/ProofOfPossessionBuilder.spec.ts +1 -1
- package/lib/__tests__/SdJwt.spec.ts +36 -30
- package/lib/__tests__/SphereonE2E.spec.test.ts +10 -7
- package/lib/__tests__/data/VciDataFixtures.ts +712 -27
- package/lib/functions/OpenIDUtils.ts +25 -0
- package/lib/functions/index.ts +2 -3
- package/lib/functions/notifications.ts +32 -0
- package/lib/index.ts +16 -1
- package/lib/types/index.ts +6 -0
- package/package.json +4 -4
- package/dist/functions/ProofUtil.d.ts +0 -30
- package/dist/functions/ProofUtil.d.ts.map +0 -1
- package/dist/functions/ProofUtil.js +0 -106
- package/dist/functions/ProofUtil.js.map +0 -1
- package/lib/functions/ProofUtil.ts +0 -128
|
@@ -0,0 +1,449 @@
|
|
|
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.OpenID4VCIClientV1_0_11 = void 0;
|
|
16
|
+
const oid4vci_common_1 = require("@sphereon/oid4vci-common");
|
|
17
|
+
const debug_1 = __importDefault(require("debug"));
|
|
18
|
+
const AccessTokenClientV1_0_11_1 = require("./AccessTokenClientV1_0_11");
|
|
19
|
+
const AuthorizationCodeClientV1_0_11_1 = require("./AuthorizationCodeClientV1_0_11");
|
|
20
|
+
const CredentialOfferClientV1_0_11_1 = require("./CredentialOfferClientV1_0_11");
|
|
21
|
+
const CredentialRequestClientBuilderV1_0_11_1 = require("./CredentialRequestClientBuilderV1_0_11");
|
|
22
|
+
const MetadataClientV1_0_11_1 = require("./MetadataClientV1_0_11");
|
|
23
|
+
const ProofOfPossessionBuilder_1 = require("./ProofOfPossessionBuilder");
|
|
24
|
+
const AuthorizationUtil_1 = require("./functions/AuthorizationUtil");
|
|
25
|
+
const debug = (0, debug_1.default)('sphereon:oid4vci');
|
|
26
|
+
class OpenID4VCIClientV1_0_11 {
|
|
27
|
+
constructor({ credentialOffer, clientId, kid, alg, credentialIssuer, pkce, authorizationRequest, jwk, endpointMetadata, accessTokenResponse, authorizationRequestOpts, authorizationCodeResponse, authorizationURL, }) {
|
|
28
|
+
var _a;
|
|
29
|
+
const issuer = credentialIssuer !== null && credentialIssuer !== void 0 ? credentialIssuer : (credentialOffer ? (0, oid4vci_common_1.getIssuerFromCredentialOfferPayload)(credentialOffer.credential_offer) : undefined);
|
|
30
|
+
if (!issuer) {
|
|
31
|
+
throw Error('No credential issuer supplied or deduced from offer');
|
|
32
|
+
}
|
|
33
|
+
this._state = {
|
|
34
|
+
credentialOffer,
|
|
35
|
+
credentialIssuer: issuer,
|
|
36
|
+
kid,
|
|
37
|
+
alg,
|
|
38
|
+
// TODO: We need to refactor this and always explicitly call createAuthorizationRequestUrl, so we can have a credential selection first and use the kid as a default for the client id
|
|
39
|
+
clientId: (_a = clientId !== null && clientId !== void 0 ? clientId : (credentialOffer && (0, oid4vci_common_1.getClientIdFromCredentialOfferPayload)(credentialOffer.credential_offer))) !== null && _a !== void 0 ? _a : kid === null || kid === void 0 ? void 0 : kid.split('#')[0],
|
|
40
|
+
pkce: Object.assign({ disabled: false, codeChallengeMethod: oid4vci_common_1.CodeChallengeMethod.S256 }, pkce),
|
|
41
|
+
authorizationRequestOpts,
|
|
42
|
+
authorizationCodeResponse,
|
|
43
|
+
jwk,
|
|
44
|
+
endpointMetadata,
|
|
45
|
+
accessTokenResponse,
|
|
46
|
+
authorizationURL,
|
|
47
|
+
};
|
|
48
|
+
// Running syncAuthorizationRequestOpts later as it is using the state
|
|
49
|
+
if (!this._state.authorizationRequestOpts) {
|
|
50
|
+
this._state.authorizationRequestOpts = this.syncAuthorizationRequestOpts(authorizationRequest);
|
|
51
|
+
}
|
|
52
|
+
debug(`Authorization req options: ${JSON.stringify(this._state.authorizationRequestOpts, null, 2)}`);
|
|
53
|
+
}
|
|
54
|
+
static fromCredentialIssuer({ kid, alg, retrieveServerMetadata, clientId, credentialIssuer, pkce, authorizationRequest, createAuthorizationRequestURL, }) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const client = new OpenID4VCIClientV1_0_11({
|
|
57
|
+
kid,
|
|
58
|
+
alg,
|
|
59
|
+
clientId: clientId !== null && clientId !== void 0 ? clientId : authorizationRequest === null || authorizationRequest === void 0 ? void 0 : authorizationRequest.clientId,
|
|
60
|
+
credentialIssuer,
|
|
61
|
+
pkce,
|
|
62
|
+
authorizationRequest,
|
|
63
|
+
});
|
|
64
|
+
if (retrieveServerMetadata === undefined || retrieveServerMetadata) {
|
|
65
|
+
yield client.retrieveServerMetadata();
|
|
66
|
+
}
|
|
67
|
+
if (createAuthorizationRequestURL === undefined || createAuthorizationRequestURL) {
|
|
68
|
+
yield client.createAuthorizationRequestUrl({ authorizationRequest, pkce });
|
|
69
|
+
}
|
|
70
|
+
return client;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
static fromState({ state }) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const clientState = typeof state === 'string' ? JSON.parse(state) : state;
|
|
76
|
+
return new OpenID4VCIClientV1_0_11(clientState);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
static fromURI({ uri, kid, alg, retrieveServerMetadata, clientId, pkce, createAuthorizationRequestURL, authorizationRequest, resolveOfferUri, }) {
|
|
80
|
+
var _a;
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const credentialOfferClient = yield CredentialOfferClientV1_0_11_1.CredentialOfferClientV1_0_11.fromURI(uri, { resolve: resolveOfferUri });
|
|
83
|
+
const client = new OpenID4VCIClientV1_0_11({
|
|
84
|
+
credentialOffer: credentialOfferClient,
|
|
85
|
+
kid,
|
|
86
|
+
alg,
|
|
87
|
+
clientId: (_a = clientId !== null && clientId !== void 0 ? clientId : authorizationRequest === null || authorizationRequest === void 0 ? void 0 : authorizationRequest.clientId) !== null && _a !== void 0 ? _a : credentialOfferClient.clientId,
|
|
88
|
+
pkce,
|
|
89
|
+
authorizationRequest,
|
|
90
|
+
});
|
|
91
|
+
if (retrieveServerMetadata === undefined || retrieveServerMetadata) {
|
|
92
|
+
yield client.retrieveServerMetadata();
|
|
93
|
+
}
|
|
94
|
+
if (credentialOfferClient.supportedFlows.includes(oid4vci_common_1.AuthzFlowType.AUTHORIZATION_CODE_FLOW) &&
|
|
95
|
+
(createAuthorizationRequestURL === undefined || createAuthorizationRequestURL)) {
|
|
96
|
+
yield client.createAuthorizationRequestUrl({ authorizationRequest, pkce });
|
|
97
|
+
debug(`Authorization Request URL: ${client._state.authorizationURL}`);
|
|
98
|
+
}
|
|
99
|
+
return client;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Allows you to create an Authorization Request URL when using an Authorization Code flow. This URL needs to be accessed using the front channel (browser)
|
|
104
|
+
*
|
|
105
|
+
* The Identity provider would present a login screen typically; after you authenticated, it would redirect to the provided redirectUri; which can be same device or cross-device
|
|
106
|
+
* @param opts
|
|
107
|
+
*/
|
|
108
|
+
createAuthorizationRequestUrl(opts) {
|
|
109
|
+
var _a;
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
if (!this._state.authorizationURL) {
|
|
112
|
+
this.calculatePKCEOpts(opts === null || opts === void 0 ? void 0 : opts.pkce);
|
|
113
|
+
this._state.authorizationRequestOpts = this.syncAuthorizationRequestOpts(opts === null || opts === void 0 ? void 0 : opts.authorizationRequest);
|
|
114
|
+
if (!this._state.authorizationRequestOpts) {
|
|
115
|
+
throw Error(`No Authorization Request options present or provided in this call`);
|
|
116
|
+
}
|
|
117
|
+
// todo: Probably can go with current logic in MetadataClientV1_0_13 who will always set the authorization_endpoint when found
|
|
118
|
+
// handling this because of the support for v1_0-08
|
|
119
|
+
if (((_a = this._state.endpointMetadata) === null || _a === void 0 ? void 0 : _a.credentialIssuerMetadata) &&
|
|
120
|
+
'authorization_endpoint' in this._state.endpointMetadata.credentialIssuerMetadata) {
|
|
121
|
+
this._state.endpointMetadata.authorization_endpoint = this._state.endpointMetadata.credentialIssuerMetadata.authorization_endpoint;
|
|
122
|
+
}
|
|
123
|
+
this._state.authorizationURL = yield (0, AuthorizationCodeClientV1_0_11_1.createAuthorizationRequestUrlV1_0_11)({
|
|
124
|
+
pkce: this._state.pkce,
|
|
125
|
+
endpointMetadata: this.endpointMetadata,
|
|
126
|
+
authorizationRequest: this._state.authorizationRequestOpts,
|
|
127
|
+
credentialOffer: this.credentialOffer,
|
|
128
|
+
credentialsSupported: Object.values(this.getCredentialsSupported()),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return this._state.authorizationURL;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
retrieveServerMetadata() {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
this.assertIssuerData();
|
|
137
|
+
if (!this._state.endpointMetadata) {
|
|
138
|
+
if (this.credentialOffer) {
|
|
139
|
+
this._state.endpointMetadata = yield MetadataClientV1_0_11_1.MetadataClientV1_0_11.retrieveAllMetadataFromCredentialOffer(this.credentialOffer);
|
|
140
|
+
}
|
|
141
|
+
else if (this._state.credentialIssuer) {
|
|
142
|
+
this._state.endpointMetadata = yield MetadataClientV1_0_11_1.MetadataClientV1_0_11.retrieveAllMetadata(this._state.credentialIssuer);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
throw Error(`Cannot retrieve issuer metadata without either a credential offer, or issuer value`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return this.endpointMetadata;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
calculatePKCEOpts(pkce) {
|
|
152
|
+
this._state.pkce = (0, AuthorizationUtil_1.generateMissingPKCEOpts)(Object.assign(Object.assign({}, this._state.pkce), pkce));
|
|
153
|
+
}
|
|
154
|
+
acquireAccessToken(opts) {
|
|
155
|
+
var _a, _b, _c, _d, _e, _f;
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
const { pin, clientId } = opts !== null && opts !== void 0 ? opts : {};
|
|
158
|
+
let { redirectUri } = opts !== null && opts !== void 0 ? opts : {};
|
|
159
|
+
if (opts === null || opts === void 0 ? void 0 : opts.authorizationResponse) {
|
|
160
|
+
this._state.authorizationCodeResponse = Object.assign({}, (0, oid4vci_common_1.toAuthorizationResponsePayload)(opts.authorizationResponse));
|
|
161
|
+
}
|
|
162
|
+
else if (opts === null || opts === void 0 ? void 0 : opts.code) {
|
|
163
|
+
this._state.authorizationCodeResponse = { code: opts.code };
|
|
164
|
+
}
|
|
165
|
+
const code = (_a = this._state.authorizationCodeResponse) === null || _a === void 0 ? void 0 : _a.code;
|
|
166
|
+
if (opts === null || opts === void 0 ? void 0 : opts.codeVerifier) {
|
|
167
|
+
this._state.pkce.codeVerifier = opts.codeVerifier;
|
|
168
|
+
}
|
|
169
|
+
this.assertIssuerData();
|
|
170
|
+
if (clientId) {
|
|
171
|
+
this._state.clientId = clientId;
|
|
172
|
+
}
|
|
173
|
+
if (!this._state.accessTokenResponse) {
|
|
174
|
+
const accessTokenClient = new AccessTokenClientV1_0_11_1.AccessTokenClientV1_0_11();
|
|
175
|
+
if (redirectUri && redirectUri !== ((_b = this._state.authorizationRequestOpts) === null || _b === void 0 ? void 0 : _b.redirectUri)) {
|
|
176
|
+
console.log(`Redirect URI mismatch between access-token (${redirectUri}) and authorization request (${(_c = this._state.authorizationRequestOpts) === null || _c === void 0 ? void 0 : _c.redirectUri}). According to the specification that is not allowed.`);
|
|
177
|
+
}
|
|
178
|
+
if (((_d = this._state.authorizationRequestOpts) === null || _d === void 0 ? void 0 : _d.redirectUri) && !redirectUri) {
|
|
179
|
+
redirectUri = this._state.authorizationRequestOpts.redirectUri;
|
|
180
|
+
}
|
|
181
|
+
const response = yield accessTokenClient.acquireAccessToken(Object.assign(Object.assign({ credentialOffer: this.credentialOffer, metadata: this.endpointMetadata, credentialIssuer: this.getIssuer(), pin }, (!this._state.pkce.disabled && { codeVerifier: this._state.pkce.codeVerifier })), { code,
|
|
182
|
+
redirectUri, asOpts: { clientId: this.clientId } }));
|
|
183
|
+
if (response.errorBody) {
|
|
184
|
+
debug(`Access token error:\r\n${JSON.stringify(response.errorBody)}`);
|
|
185
|
+
throw Error(`Retrieving an access token from ${(_e = this._state.endpointMetadata) === null || _e === void 0 ? void 0 : _e.token_endpoint} for issuer ${this.getIssuer()} failed with status: ${response.origResponse.status}`);
|
|
186
|
+
}
|
|
187
|
+
else if (!response.successBody) {
|
|
188
|
+
debug(`Access token error. No success body`);
|
|
189
|
+
throw Error(`Retrieving an access token from ${(_f = this._state.endpointMetadata) === null || _f === void 0 ? void 0 : _f.token_endpoint} for issuer ${this.getIssuer()} failed as there was no success response body`);
|
|
190
|
+
}
|
|
191
|
+
this._state.accessTokenResponse = response.successBody;
|
|
192
|
+
}
|
|
193
|
+
return this.accessTokenResponse;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
acquireCredentials({ credentialTypes, context, proofCallbacks, format, kid, jwk, alg, jti, deferredCredentialAwait, deferredCredentialIntervalInMS, }) {
|
|
197
|
+
var _a, _b, _c;
|
|
198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
if ([jwk, kid].filter((v) => v !== undefined).length > 1) {
|
|
200
|
+
throw new Error(oid4vci_common_1.KID_JWK_X5C_ERROR + `. jwk: ${jwk !== undefined}, kid: ${kid !== undefined}`);
|
|
201
|
+
}
|
|
202
|
+
if (alg)
|
|
203
|
+
this._state.alg = alg;
|
|
204
|
+
if (jwk)
|
|
205
|
+
this._state.jwk = jwk;
|
|
206
|
+
if (kid)
|
|
207
|
+
this._state.kid = kid;
|
|
208
|
+
const requestBuilder = this.credentialOffer
|
|
209
|
+
? CredentialRequestClientBuilderV1_0_11_1.CredentialRequestClientBuilderV1_0_11.fromCredentialOffer({
|
|
210
|
+
credentialOffer: this.credentialOffer,
|
|
211
|
+
metadata: this.endpointMetadata,
|
|
212
|
+
})
|
|
213
|
+
: CredentialRequestClientBuilderV1_0_11_1.CredentialRequestClientBuilderV1_0_11.fromCredentialIssuer({
|
|
214
|
+
credentialIssuer: this.getIssuer(),
|
|
215
|
+
credentialTypes,
|
|
216
|
+
metadata: this.endpointMetadata,
|
|
217
|
+
version: this.version(),
|
|
218
|
+
});
|
|
219
|
+
requestBuilder.withTokenFromResponse(this.accessTokenResponse);
|
|
220
|
+
requestBuilder.withDeferredCredentialAwait(deferredCredentialAwait !== null && deferredCredentialAwait !== void 0 ? deferredCredentialAwait : false, deferredCredentialIntervalInMS);
|
|
221
|
+
if ((_a = this.endpointMetadata) === null || _a === void 0 ? void 0 : _a.credentialIssuerMetadata) {
|
|
222
|
+
const metadata = this.endpointMetadata.credentialIssuerMetadata;
|
|
223
|
+
const types = Array.isArray(credentialTypes) ? credentialTypes : [credentialTypes];
|
|
224
|
+
if (metadata.credentials_supported && Array.isArray(metadata.credentials_supported)) {
|
|
225
|
+
let typeSupported = false;
|
|
226
|
+
metadata.credentials_supported.forEach((supportedCredential) => {
|
|
227
|
+
const subTypes = (0, oid4vci_common_1.getTypesFromCredentialSupported)(supportedCredential);
|
|
228
|
+
if (subTypes.every((t, i) => types[i] === t) ||
|
|
229
|
+
(types.length === 1 && (types[0] === supportedCredential.id || subTypes.includes(types[0])))) {
|
|
230
|
+
typeSupported = true;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
if (!typeSupported) {
|
|
234
|
+
console.log(`Not all credential types ${JSON.stringify(credentialTypes)} are present in metadata for ${this.getIssuer()}`);
|
|
235
|
+
// throw Error(`Not all credential types ${JSON.stringify(credentialTypes)} are supported by issuer ${this.getIssuer()}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else if (metadata.credentials_supported && !Array.isArray(metadata.credentials_supported)) {
|
|
239
|
+
const credentialsSupported = metadata.credentials_supported;
|
|
240
|
+
if (types.some((type) => !metadata.credentials_supported || !credentialsSupported[type])) {
|
|
241
|
+
throw Error(`Not all credential types ${JSON.stringify(credentialTypes)} are supported by issuer ${this.getIssuer()}`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// todo: Format check? We might end up with some disjoint type / format combinations supported by the server
|
|
245
|
+
}
|
|
246
|
+
const credentialRequestClient = requestBuilder.build();
|
|
247
|
+
const proofBuilder = ProofOfPossessionBuilder_1.ProofOfPossessionBuilder.fromAccessTokenResponse({
|
|
248
|
+
accessTokenResponse: this.accessTokenResponse,
|
|
249
|
+
callbacks: proofCallbacks,
|
|
250
|
+
version: this.version(),
|
|
251
|
+
})
|
|
252
|
+
.withIssuer(this.getIssuer())
|
|
253
|
+
.withAlg(this.alg);
|
|
254
|
+
if (this._state.jwk) {
|
|
255
|
+
proofBuilder.withJWK(this._state.jwk);
|
|
256
|
+
}
|
|
257
|
+
if (this._state.kid) {
|
|
258
|
+
proofBuilder.withKid(this._state.kid);
|
|
259
|
+
}
|
|
260
|
+
if (this.clientId) {
|
|
261
|
+
proofBuilder.withClientId(this.clientId);
|
|
262
|
+
}
|
|
263
|
+
if (jti) {
|
|
264
|
+
proofBuilder.withJti(jti);
|
|
265
|
+
}
|
|
266
|
+
const response = yield credentialRequestClient.acquireCredentialsUsingProof({
|
|
267
|
+
proofInput: proofBuilder,
|
|
268
|
+
credentialTypes,
|
|
269
|
+
context,
|
|
270
|
+
format,
|
|
271
|
+
});
|
|
272
|
+
if (response.errorBody) {
|
|
273
|
+
debug(`Credential request error:\r\n${JSON.stringify(response.errorBody)}`);
|
|
274
|
+
throw Error(`Retrieving a credential from ${(_b = this._state.endpointMetadata) === null || _b === void 0 ? void 0 : _b.credential_endpoint} for issuer ${this.getIssuer()} failed with status: ${response.origResponse.status}`);
|
|
275
|
+
}
|
|
276
|
+
else if (!response.successBody) {
|
|
277
|
+
debug(`Credential request error. No success body`);
|
|
278
|
+
throw Error(`Retrieving a credential from ${(_c = this._state.endpointMetadata) === null || _c === void 0 ? void 0 : _c.credential_endpoint} for issuer ${this.getIssuer()} failed as there was no success response body`);
|
|
279
|
+
}
|
|
280
|
+
return response.successBody;
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
exportState() {
|
|
284
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
return JSON.stringify(this._state);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
// FIXME: We really should convert <v11 to v12 objects first. Right now the logic doesn't map nicely and is brittle.
|
|
289
|
+
// We should resolve IDs to objects first in case of strings.
|
|
290
|
+
// When < v11 convert into a v12 object. When v12 object retain it.
|
|
291
|
+
// Then match the object array on server metadata
|
|
292
|
+
getCredentialsSupportedV11(restrictToInitiationTypes, format) {
|
|
293
|
+
return (0, oid4vci_common_1.getSupportedCredentials)({
|
|
294
|
+
issuerMetadata: this.endpointMetadata.credentialIssuerMetadata,
|
|
295
|
+
version: this.version(),
|
|
296
|
+
format: format,
|
|
297
|
+
types: restrictToInitiationTypes ? this.getCredentialOfferTypes() : undefined,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
getCredentialsSupported(format) {
|
|
301
|
+
return (0, oid4vci_common_1.getSupportedCredentials)({
|
|
302
|
+
issuerMetadata: this.endpointMetadata.credentialIssuerMetadata,
|
|
303
|
+
version: this.version(),
|
|
304
|
+
format: format,
|
|
305
|
+
types: undefined,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
getCredentialOfferTypes() {
|
|
309
|
+
if (!this.credentialOffer) {
|
|
310
|
+
return [];
|
|
311
|
+
}
|
|
312
|
+
else if (this.credentialOffer.version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11) {
|
|
313
|
+
const orig = this.credentialOffer.original_credential_offer;
|
|
314
|
+
const types = typeof orig.credential_type === 'string' ? [orig.credential_type] : orig.credential_type;
|
|
315
|
+
const result = [];
|
|
316
|
+
result[0] = types;
|
|
317
|
+
return result;
|
|
318
|
+
}
|
|
319
|
+
else if (this.credentialOffer.version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_13) {
|
|
320
|
+
return this.credentialOffer.credential_offer.credentials.map((c) => { var _a; return (_a = (0, oid4vci_common_1.getTypesFromObject)(c)) !== null && _a !== void 0 ? _a : []; });
|
|
321
|
+
}
|
|
322
|
+
// we don't support > V11
|
|
323
|
+
throw Error(`This class only supports version 11 and lower! Version: ${this.version()}`);
|
|
324
|
+
}
|
|
325
|
+
issuerSupportedFlowTypes() {
|
|
326
|
+
var _a, _b, _c, _d;
|
|
327
|
+
return ((_b = (_a = this.credentialOffer) === null || _a === void 0 ? void 0 : _a.supportedFlows) !== null && _b !== void 0 ? _b : (((_d = (_c = this._state.endpointMetadata) === null || _c === void 0 ? void 0 : _c.credentialIssuerMetadata) === null || _d === void 0 ? void 0 : _d.authorization_endpoint) ? [oid4vci_common_1.AuthzFlowType.AUTHORIZATION_CODE_FLOW] : []));
|
|
328
|
+
}
|
|
329
|
+
isFlowTypeSupported(flowType) {
|
|
330
|
+
return this.issuerSupportedFlowTypes().includes(flowType);
|
|
331
|
+
}
|
|
332
|
+
get authorizationURL() {
|
|
333
|
+
return this._state.authorizationURL;
|
|
334
|
+
}
|
|
335
|
+
hasAuthorizationURL() {
|
|
336
|
+
return !!this.authorizationURL;
|
|
337
|
+
}
|
|
338
|
+
get credentialOffer() {
|
|
339
|
+
return this._state.credentialOffer;
|
|
340
|
+
}
|
|
341
|
+
version() {
|
|
342
|
+
var _a, _b;
|
|
343
|
+
return (_b = (_a = this.credentialOffer) === null || _a === void 0 ? void 0 : _a.version) !== null && _b !== void 0 ? _b : oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11;
|
|
344
|
+
}
|
|
345
|
+
get endpointMetadata() {
|
|
346
|
+
this.assertServerMetadata();
|
|
347
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
348
|
+
return this._state.endpointMetadata;
|
|
349
|
+
}
|
|
350
|
+
get kid() {
|
|
351
|
+
this.assertIssuerData();
|
|
352
|
+
if (!this._state.kid) {
|
|
353
|
+
throw new Error('No value for kid is supplied');
|
|
354
|
+
}
|
|
355
|
+
return this._state.kid;
|
|
356
|
+
}
|
|
357
|
+
get alg() {
|
|
358
|
+
this.assertIssuerData();
|
|
359
|
+
if (!this._state.alg) {
|
|
360
|
+
throw new Error('No value for alg is supplied');
|
|
361
|
+
}
|
|
362
|
+
return this._state.alg;
|
|
363
|
+
}
|
|
364
|
+
set clientId(value) {
|
|
365
|
+
this._state.clientId = value;
|
|
366
|
+
}
|
|
367
|
+
get clientId() {
|
|
368
|
+
return this._state.clientId;
|
|
369
|
+
}
|
|
370
|
+
hasAccessTokenResponse() {
|
|
371
|
+
return !!this._state.accessTokenResponse;
|
|
372
|
+
}
|
|
373
|
+
get accessTokenResponse() {
|
|
374
|
+
this.assertAccessToken();
|
|
375
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
376
|
+
return this._state.accessTokenResponse;
|
|
377
|
+
}
|
|
378
|
+
getIssuer() {
|
|
379
|
+
this.assertIssuerData();
|
|
380
|
+
return this._state.credentialIssuer;
|
|
381
|
+
}
|
|
382
|
+
getAccessTokenEndpoint() {
|
|
383
|
+
this.assertIssuerData();
|
|
384
|
+
return this.endpointMetadata
|
|
385
|
+
? this.endpointMetadata.token_endpoint
|
|
386
|
+
: AccessTokenClientV1_0_11_1.AccessTokenClientV1_0_11.determineTokenURL({ issuerOpts: { issuer: this.getIssuer() } });
|
|
387
|
+
}
|
|
388
|
+
getCredentialEndpoint() {
|
|
389
|
+
this.assertIssuerData();
|
|
390
|
+
return this.endpointMetadata ? this.endpointMetadata.credential_endpoint : `${this.getIssuer()}/credential`;
|
|
391
|
+
}
|
|
392
|
+
hasDeferredCredentialEndpoint() {
|
|
393
|
+
return !!this.getAccessTokenEndpoint();
|
|
394
|
+
}
|
|
395
|
+
getDeferredCredentialEndpoint() {
|
|
396
|
+
this.assertIssuerData();
|
|
397
|
+
return this.endpointMetadata ? this.endpointMetadata.credential_endpoint : `${this.getIssuer()}/credential`;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Too bad we need a method like this, but EBSI is not exposing metadata
|
|
401
|
+
*/
|
|
402
|
+
isEBSI() {
|
|
403
|
+
var _a, _b, _c, _d;
|
|
404
|
+
if (((_a = this.credentialOffer) === null || _a === void 0 ? void 0 : _a.credential_offer)['credentials'] &&
|
|
405
|
+
((_b = this.credentialOffer) === null || _b === void 0 ? void 0 : _b.credential_offer).credentials.find((cred) =>
|
|
406
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
407
|
+
// @ts-ignore
|
|
408
|
+
typeof cred !== 'string' && 'trust_framework' in cred && 'name' in cred.trust_framework && cred.trust_framework.name.includes('ebsi'))) {
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
this.assertIssuerData();
|
|
412
|
+
return ((_d = (_c = this.endpointMetadata.credentialIssuerMetadata) === null || _c === void 0 ? void 0 : _c.authorization_endpoint) === null || _d === void 0 ? void 0 : _d.includes('ebsi.eu')) === true;
|
|
413
|
+
}
|
|
414
|
+
assertIssuerData() {
|
|
415
|
+
if (!this._state.credentialIssuer) {
|
|
416
|
+
throw Error(`No credential issuer value present`);
|
|
417
|
+
}
|
|
418
|
+
else if (!this._state.credentialOffer && this._state.endpointMetadata && this.issuerSupportedFlowTypes().length === 0) {
|
|
419
|
+
throw Error(`No issuance initiation or credential offer present`);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
assertServerMetadata() {
|
|
423
|
+
if (!this._state.endpointMetadata) {
|
|
424
|
+
throw Error('No server metadata');
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
assertAccessToken() {
|
|
428
|
+
if (!this._state.accessTokenResponse) {
|
|
429
|
+
throw Error(`No access token present`);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
syncAuthorizationRequestOpts(opts) {
|
|
433
|
+
var _a, _b;
|
|
434
|
+
let authorizationRequestOpts = Object.assign(Object.assign({}, (_a = this._state) === null || _a === void 0 ? void 0 : _a.authorizationRequestOpts), opts);
|
|
435
|
+
if (!authorizationRequestOpts) {
|
|
436
|
+
// We only set a redirectUri if no options are provided.
|
|
437
|
+
// Note that this only works for mobile apps, that can handle a code query param on the default openid-credential-offer deeplink.
|
|
438
|
+
// Provide your own options if that is not desired!
|
|
439
|
+
authorizationRequestOpts = { redirectUri: `${oid4vci_common_1.DefaultURISchemes.CREDENTIAL_OFFER}://` };
|
|
440
|
+
}
|
|
441
|
+
const clientId = (_b = authorizationRequestOpts.clientId) !== null && _b !== void 0 ? _b : this._state.clientId;
|
|
442
|
+
// sync clientId
|
|
443
|
+
this._state.clientId = clientId;
|
|
444
|
+
authorizationRequestOpts.clientId = clientId;
|
|
445
|
+
return authorizationRequestOpts;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
exports.OpenID4VCIClientV1_0_11 = OpenID4VCIClientV1_0_11;
|
|
449
|
+
//# sourceMappingURL=OpenID4VCIClientV1_0_11.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenID4VCIClientV1_0_11.js","sourceRoot":"","sources":["../lib/OpenID4VCIClientV1_0_11.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DA2BkC;AAElC,kDAA0B;AAE1B,yEAAsE;AACtE,qFAAwF;AACxF,iFAA8E;AAC9E,mGAAgG;AAChG,mEAAgE;AAChE,yEAAsE;AACtE,qEAAwE;AAExE,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,kBAAkB,CAAC,CAAC;AAkBxC,MAAa,uBAAuB;IAGlC,YAAoB,EAClB,eAAe,EACf,QAAQ,EACR,GAAG,EACH,GAAG,EACH,gBAAgB,EAChB,IAAI,EACJ,oBAAoB,EACpB,GAAG,EACH,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,GAejB;;QACC,MAAM,MAAM,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAA,oDAAmC,EAAC,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C1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAClC,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;YACrC,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAEO,4BAA4B,CAAC,IAA+B;;QAClE,IAAI,wBAAwB,GAAG,gCAAK,MAAA,IAAI,CAAC,MAAM,0CAAE,wBAAwB,GAAK,IAAI,CAA8B,CAAC;QACjH,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAC9B,wDAAwD;YACxD,iIAAiI;YACjI,mDAAmD;YACnD,wBAAwB,GAAG,EAAE,WAAW,EAAE,GAAG,kCAAiB,CAAC,gBAAgB,KAAK,EAAE,CAAC;QACzF,CAAC;QACD,MAAM,QAAQ,GAAG,MAAA,wBAAwB,CAAC,QAAQ,mCAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC3E,gBAAgB;QAChB,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAChC,wBAAwB,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC7C,OAAO,wBAAwB,CAAC;IAClC,CAAC;CACF;AAjkBD,0DAikBC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { AccessTokenResponse, Alg, AuthorizationRequestOpts, AuthorizationResponse, AuthzFlowType, CredentialConfigurationSupportedV1_0_13, CredentialOfferRequestWithBaseUrl, CredentialResponse, EndpointMetadataResultV1_0_13, JWK, NotificationRequest, NotificationResult, OID4VCICredentialFormat, OpenId4VCIVersion, PKCEOpts, ProofOfPossessionCallbacks } from '@sphereon/oid4vci-common';
|
|
2
|
+
import { CredentialFormat } from '@sphereon/ssi-types';
|
|
3
|
+
import { CredentialRequestOpts } from './CredentialRequestClient';
|
|
4
|
+
export interface OpenID4VCIClientStateV1_0_13 {
|
|
5
|
+
credentialIssuer: string;
|
|
6
|
+
credentialOffer?: CredentialOfferRequestWithBaseUrl;
|
|
7
|
+
clientId?: string;
|
|
8
|
+
kid?: string;
|
|
9
|
+
jwk?: JWK;
|
|
10
|
+
alg?: Alg | string;
|
|
11
|
+
endpointMetadata?: EndpointMetadataResultV1_0_13;
|
|
12
|
+
accessTokenResponse?: AccessTokenResponse;
|
|
13
|
+
authorizationRequestOpts?: AuthorizationRequestOpts;
|
|
14
|
+
authorizationCodeResponse?: AuthorizationResponse;
|
|
15
|
+
pkce: PKCEOpts;
|
|
16
|
+
accessToken?: string;
|
|
17
|
+
authorizationURL?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class OpenID4VCIClientV1_0_13 {
|
|
20
|
+
private readonly _state;
|
|
21
|
+
private constructor();
|
|
22
|
+
static fromCredentialIssuer({ kid, alg, retrieveServerMetadata, clientId, credentialIssuer, pkce, authorizationRequest, createAuthorizationRequestURL, }: {
|
|
23
|
+
credentialIssuer: string;
|
|
24
|
+
kid?: string;
|
|
25
|
+
alg?: Alg | string;
|
|
26
|
+
retrieveServerMetadata?: boolean;
|
|
27
|
+
clientId?: string;
|
|
28
|
+
createAuthorizationRequestURL?: boolean;
|
|
29
|
+
authorizationRequest?: AuthorizationRequestOpts;
|
|
30
|
+
pkce?: PKCEOpts;
|
|
31
|
+
}): Promise<OpenID4VCIClientV1_0_13>;
|
|
32
|
+
static fromState({ state }: {
|
|
33
|
+
state: OpenID4VCIClientStateV1_0_13 | string;
|
|
34
|
+
}): Promise<OpenID4VCIClientV1_0_13>;
|
|
35
|
+
static fromURI({ uri, kid, alg, retrieveServerMetadata, clientId, pkce, createAuthorizationRequestURL, authorizationRequest, resolveOfferUri, }: {
|
|
36
|
+
uri: string;
|
|
37
|
+
kid?: string;
|
|
38
|
+
alg?: Alg | string;
|
|
39
|
+
retrieveServerMetadata?: boolean;
|
|
40
|
+
createAuthorizationRequestURL?: boolean;
|
|
41
|
+
resolveOfferUri?: boolean;
|
|
42
|
+
pkce?: PKCEOpts;
|
|
43
|
+
clientId?: string;
|
|
44
|
+
authorizationRequest?: AuthorizationRequestOpts;
|
|
45
|
+
}): Promise<OpenID4VCIClientV1_0_13>;
|
|
46
|
+
/**
|
|
47
|
+
* Allows you to create an Authorization Request URL when using an Authorization Code flow. This URL needs to be accessed using the front channel (browser)
|
|
48
|
+
*
|
|
49
|
+
* The Identity provider would present a login screen typically; after you authenticated, it would redirect to the provided redirectUri; which can be same device or cross-device
|
|
50
|
+
* @param opts
|
|
51
|
+
*/
|
|
52
|
+
createAuthorizationRequestUrl(opts?: {
|
|
53
|
+
authorizationRequest?: AuthorizationRequestOpts;
|
|
54
|
+
pkce?: PKCEOpts;
|
|
55
|
+
}): Promise<string>;
|
|
56
|
+
retrieveServerMetadata(): Promise<EndpointMetadataResultV1_0_13>;
|
|
57
|
+
private calculatePKCEOpts;
|
|
58
|
+
acquireAccessToken(opts?: {
|
|
59
|
+
pin?: string;
|
|
60
|
+
clientId?: string;
|
|
61
|
+
codeVerifier?: string;
|
|
62
|
+
authorizationResponse?: string | AuthorizationResponse;
|
|
63
|
+
code?: string;
|
|
64
|
+
redirectUri?: string;
|
|
65
|
+
}): Promise<AccessTokenResponse>;
|
|
66
|
+
acquireCredentials({ credentialIdentifier, credentialTypes, context, proofCallbacks, format, kid, jwk, alg, jti, deferredCredentialAwait, deferredCredentialIntervalInMS, }: {
|
|
67
|
+
credentialIdentifier?: string;
|
|
68
|
+
credentialTypes?: string | string[];
|
|
69
|
+
context?: string[];
|
|
70
|
+
proofCallbacks: ProofOfPossessionCallbacks<any>;
|
|
71
|
+
format?: CredentialFormat | OID4VCICredentialFormat;
|
|
72
|
+
kid?: string;
|
|
73
|
+
jwk?: JWK;
|
|
74
|
+
alg?: Alg | string;
|
|
75
|
+
jti?: string;
|
|
76
|
+
deferredCredentialAwait?: boolean;
|
|
77
|
+
deferredCredentialIntervalInMS?: number;
|
|
78
|
+
experimentalHolderIssuanceSupported?: boolean;
|
|
79
|
+
}): Promise<CredentialResponse & {
|
|
80
|
+
access_token: string;
|
|
81
|
+
}>;
|
|
82
|
+
exportState(): Promise<string>;
|
|
83
|
+
getCredentialsSupported(format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[]): Record<string, CredentialConfigurationSupportedV1_0_13>;
|
|
84
|
+
sendNotification(credentialRequestOpts: Partial<CredentialRequestOpts>, request: NotificationRequest, accessToken?: string): Promise<NotificationResult>;
|
|
85
|
+
issuerSupportedFlowTypes(): AuthzFlowType[];
|
|
86
|
+
isFlowTypeSupported(flowType: AuthzFlowType): boolean;
|
|
87
|
+
hasAuthorizationURL(): boolean;
|
|
88
|
+
get authorizationURL(): string | undefined;
|
|
89
|
+
get credentialOffer(): CredentialOfferRequestWithBaseUrl | undefined;
|
|
90
|
+
version(): OpenId4VCIVersion;
|
|
91
|
+
get endpointMetadata(): EndpointMetadataResultV1_0_13;
|
|
92
|
+
get kid(): string;
|
|
93
|
+
get alg(): string;
|
|
94
|
+
set clientId(value: string | undefined);
|
|
95
|
+
get clientId(): string | undefined;
|
|
96
|
+
hasAccessTokenResponse(): boolean;
|
|
97
|
+
get accessTokenResponse(): AccessTokenResponse;
|
|
98
|
+
getIssuer(): string;
|
|
99
|
+
getAccessTokenEndpoint(): string;
|
|
100
|
+
getCredentialEndpoint(): string;
|
|
101
|
+
hasDeferredCredentialEndpoint(): boolean;
|
|
102
|
+
getDeferredCredentialEndpoint(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Too bad we need a method like this, but EBSI is not exposing metadata
|
|
105
|
+
*/
|
|
106
|
+
isEBSI(): boolean;
|
|
107
|
+
private assertIssuerData;
|
|
108
|
+
private assertServerMetadata;
|
|
109
|
+
private assertAccessToken;
|
|
110
|
+
private syncAuthorizationRequestOpts;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=OpenID4VCIClientV1_0_13.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
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