@sphereon/oid4vci-client 0.10.4-unstable.2 → 0.10.4-unstable.21

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.
Files changed (98) hide show
  1. package/dist/AccessTokenClient.d.ts +5 -5
  2. package/dist/AccessTokenClient.d.ts.map +1 -1
  3. package/dist/AccessTokenClient.js +42 -22
  4. package/dist/AccessTokenClient.js.map +1 -1
  5. package/dist/AccessTokenClientV1_0_11.d.ts +29 -0
  6. package/dist/AccessTokenClientV1_0_11.d.ts.map +1 -0
  7. package/dist/AccessTokenClientV1_0_11.js +212 -0
  8. package/dist/AccessTokenClientV1_0_11.js.map +1 -0
  9. package/dist/AuthorizationCodeClient.d.ts +4 -4
  10. package/dist/AuthorizationCodeClient.d.ts.map +1 -1
  11. package/dist/AuthorizationCodeClient.js +14 -3
  12. package/dist/AuthorizationCodeClient.js.map +1 -1
  13. package/dist/AuthorizationCodeClientV1_0_11.d.ts +9 -0
  14. package/dist/AuthorizationCodeClientV1_0_11.d.ts.map +1 -0
  15. package/dist/AuthorizationCodeClientV1_0_11.js +132 -0
  16. package/dist/AuthorizationCodeClientV1_0_11.js.map +1 -0
  17. package/dist/CredentialOfferClient.d.ts.map +1 -1
  18. package/dist/CredentialOfferClient.js +14 -25
  19. package/dist/CredentialOfferClient.js.map +1 -1
  20. package/dist/CredentialOfferClientV1_0_11.d.ts +10 -0
  21. package/dist/CredentialOfferClientV1_0_11.d.ts.map +1 -0
  22. package/dist/CredentialOfferClientV1_0_11.js +103 -0
  23. package/dist/CredentialOfferClientV1_0_11.js.map +1 -0
  24. package/dist/CredentialRequestClient.d.ts +1 -1
  25. package/dist/CredentialRequestClient.d.ts.map +1 -1
  26. package/dist/CredentialRequestClient.js +9 -6
  27. package/dist/CredentialRequestClient.js.map +1 -1
  28. package/dist/CredentialRequestClientBuilder.d.ts +3 -3
  29. package/dist/CredentialRequestClientBuilder.d.ts.map +1 -1
  30. package/dist/CredentialRequestClientBuilder.js +2 -2
  31. package/dist/CredentialRequestClientBuilder.js.map +1 -1
  32. package/dist/CredentialRequestClientBuilderV1_0_11.d.ts +46 -0
  33. package/dist/CredentialRequestClientBuilderV1_0_11.d.ts.map +1 -0
  34. package/dist/CredentialRequestClientBuilderV1_0_11.js +117 -0
  35. package/dist/CredentialRequestClientBuilderV1_0_11.js.map +1 -0
  36. package/dist/CredentialRequestClientV1_0_11.d.ts +44 -0
  37. package/dist/CredentialRequestClientV1_0_11.d.ts.map +1 -0
  38. package/dist/CredentialRequestClientV1_0_11.js +151 -0
  39. package/dist/CredentialRequestClientV1_0_11.js.map +1 -0
  40. package/dist/MetadataClient.d.ts +5 -15
  41. package/dist/MetadataClient.d.ts.map +1 -1
  42. package/dist/MetadataClient.js +13 -33
  43. package/dist/MetadataClient.js.map +1 -1
  44. package/dist/MetadataClientV1_0_11.d.ts +31 -0
  45. package/dist/MetadataClientV1_0_11.d.ts.map +1 -0
  46. package/dist/MetadataClientV1_0_11.js +182 -0
  47. package/dist/MetadataClientV1_0_11.js.map +1 -0
  48. package/dist/OpenID4VCIClient.d.ts +5 -17
  49. package/dist/OpenID4VCIClient.d.ts.map +1 -1
  50. package/dist/OpenID4VCIClient.js +3 -74
  51. package/dist/OpenID4VCIClient.js.map +1 -1
  52. package/dist/OpenID4VCIClientV1_0_11.d.ts +107 -0
  53. package/dist/OpenID4VCIClientV1_0_11.d.ts.map +1 -0
  54. package/dist/OpenID4VCIClientV1_0_11.js +462 -0
  55. package/dist/OpenID4VCIClientV1_0_11.js.map +1 -0
  56. package/dist/functions/OpenIDUtils.d.ts +12 -0
  57. package/dist/functions/OpenIDUtils.d.ts.map +1 -0
  58. package/dist/functions/OpenIDUtils.js +37 -0
  59. package/dist/functions/OpenIDUtils.js.map +1 -0
  60. package/dist/index.d.ts +8 -1
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +8 -1
  63. package/dist/index.js.map +1 -1
  64. package/lib/AccessTokenClient.ts +54 -22
  65. package/lib/AccessTokenClientV1_0_11.ts +255 -0
  66. package/lib/AuthorizationCodeClient.ts +31 -11
  67. package/lib/AuthorizationCodeClientV1_0_11.ts +167 -0
  68. package/lib/CredentialOfferClient.ts +13 -25
  69. package/lib/CredentialOfferClientV1_0_11.ts +112 -0
  70. package/lib/CredentialRequestClient.ts +11 -7
  71. package/lib/CredentialRequestClientBuilder.ts +9 -8
  72. package/lib/CredentialRequestClientBuilderV1_0_11.ts +156 -0
  73. package/lib/CredentialRequestClientV1_0_11.ts +190 -0
  74. package/lib/MetadataClient.ts +26 -48
  75. package/lib/MetadataClientV1_0_11.ts +186 -0
  76. package/lib/OpenID4VCIClient.ts +10 -92
  77. package/lib/OpenID4VCIClientV1_0_11.ts +644 -0
  78. package/lib/__tests__/AccessTokenClient.spec.ts +34 -6
  79. package/lib/__tests__/CredentialRequestClient.spec.ts +56 -39
  80. package/lib/__tests__/CredentialRequestClientBuilder.spec.ts +4 -4
  81. package/lib/__tests__/CredentialRequestClientV1_0_11.spec.ts +316 -0
  82. package/lib/__tests__/EBSIE2E.spec.test.ts +2 -2
  83. package/lib/__tests__/IT.spec.ts +222 -11
  84. package/lib/__tests__/IssuanceInitiation.spec.ts +32 -51
  85. package/lib/__tests__/IssuanceInitiationV1_0_11.spec.ts +62 -0
  86. package/lib/__tests__/MattrE2E.spec.test.ts +2 -2
  87. package/lib/__tests__/MetadataClient.spec.ts +70 -6
  88. package/lib/__tests__/MetadataMocks.ts +41 -2
  89. package/lib/__tests__/OpenID4VCIClient.spec.ts +1 -1
  90. package/lib/__tests__/{OpenID4VCIClientPAR.spec.ts → OpenID4VCIClientPARV1_0_11.spec.ts} +5 -5
  91. package/lib/__tests__/OpenID4VCIClientV1_0_11.spec.ts +202 -0
  92. package/lib/__tests__/ProofOfPossessionBuilder.spec.ts +1 -1
  93. package/lib/__tests__/SdJwt.spec.ts +31 -21
  94. package/lib/__tests__/SphereonE2E.spec.test.ts +3 -3
  95. package/lib/__tests__/data/VciDataFixtures.ts +664 -27
  96. package/lib/functions/OpenIDUtils.ts +25 -0
  97. package/lib/index.ts +8 -1
  98. package/package.json +3 -3
@@ -0,0 +1,462 @@
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 MetadataClient 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) => {
321
+ if (typeof c === 'string') {
322
+ return [c];
323
+ }
324
+ else if ('types' in c) {
325
+ return c.types;
326
+ }
327
+ else if ('vct' in c) {
328
+ return [c.vct];
329
+ }
330
+ else {
331
+ return c.credential_definition.types;
332
+ }
333
+ });
334
+ }
335
+ // we don't have this for v13. v13 only has credential_configuration_ids which is not translatable to type
336
+ return [];
337
+ }
338
+ issuerSupportedFlowTypes() {
339
+ var _a, _b, _c, _d;
340
+ 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] : []));
341
+ }
342
+ isFlowTypeSupported(flowType) {
343
+ return this.issuerSupportedFlowTypes().includes(flowType);
344
+ }
345
+ get authorizationURL() {
346
+ return this._state.authorizationURL;
347
+ }
348
+ hasAuthorizationURL() {
349
+ return !!this.authorizationURL;
350
+ }
351
+ get credentialOffer() {
352
+ return this._state.credentialOffer;
353
+ }
354
+ version() {
355
+ var _a, _b;
356
+ 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;
357
+ }
358
+ get endpointMetadata() {
359
+ this.assertServerMetadata();
360
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
361
+ return this._state.endpointMetadata;
362
+ }
363
+ get kid() {
364
+ this.assertIssuerData();
365
+ if (!this._state.kid) {
366
+ throw new Error('No value for kid is supplied');
367
+ }
368
+ return this._state.kid;
369
+ }
370
+ get alg() {
371
+ this.assertIssuerData();
372
+ if (!this._state.alg) {
373
+ throw new Error('No value for alg is supplied');
374
+ }
375
+ return this._state.alg;
376
+ }
377
+ set clientId(value) {
378
+ this._state.clientId = value;
379
+ }
380
+ get clientId() {
381
+ return this._state.clientId;
382
+ }
383
+ hasAccessTokenResponse() {
384
+ return !!this._state.accessTokenResponse;
385
+ }
386
+ get accessTokenResponse() {
387
+ this.assertAccessToken();
388
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
389
+ return this._state.accessTokenResponse;
390
+ }
391
+ getIssuer() {
392
+ this.assertIssuerData();
393
+ return this._state.credentialIssuer;
394
+ }
395
+ getAccessTokenEndpoint() {
396
+ this.assertIssuerData();
397
+ return this.endpointMetadata
398
+ ? this.endpointMetadata.token_endpoint
399
+ : AccessTokenClientV1_0_11_1.AccessTokenClientV1_0_11.determineTokenURL({ issuerOpts: { issuer: this.getIssuer() } });
400
+ }
401
+ getCredentialEndpoint() {
402
+ this.assertIssuerData();
403
+ return this.endpointMetadata ? this.endpointMetadata.credential_endpoint : `${this.getIssuer()}/credential`;
404
+ }
405
+ hasDeferredCredentialEndpoint() {
406
+ return !!this.getAccessTokenEndpoint();
407
+ }
408
+ getDeferredCredentialEndpoint() {
409
+ this.assertIssuerData();
410
+ return this.endpointMetadata ? this.endpointMetadata.credential_endpoint : `${this.getIssuer()}/credential`;
411
+ }
412
+ /**
413
+ * Too bad we need a method like this, but EBSI is not exposing metadata
414
+ */
415
+ isEBSI() {
416
+ var _a, _b, _c, _d;
417
+ if (((_a = this.credentialOffer) === null || _a === void 0 ? void 0 : _a.credential_offer)['credentials'] &&
418
+ ((_b = this.credentialOffer) === null || _b === void 0 ? void 0 : _b.credential_offer).credentials.find((cred) =>
419
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
420
+ // @ts-ignore
421
+ typeof cred !== 'string' && 'trust_framework' in cred && 'name' in cred.trust_framework && cred.trust_framework.name.includes('ebsi'))) {
422
+ return true;
423
+ }
424
+ this.assertIssuerData();
425
+ 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');
426
+ }
427
+ assertIssuerData() {
428
+ if (!this._state.credentialIssuer) {
429
+ throw Error(`No credential issuer value present`);
430
+ }
431
+ else if (!this._state.credentialOffer && this._state.endpointMetadata && this.issuerSupportedFlowTypes().length === 0) {
432
+ throw Error(`No issuance initiation or credential offer present`);
433
+ }
434
+ }
435
+ assertServerMetadata() {
436
+ if (!this._state.endpointMetadata) {
437
+ throw Error('No server metadata');
438
+ }
439
+ }
440
+ assertAccessToken() {
441
+ if (!this._state.accessTokenResponse) {
442
+ throw Error(`No access token present`);
443
+ }
444
+ }
445
+ syncAuthorizationRequestOpts(opts) {
446
+ var _a, _b;
447
+ let authorizationRequestOpts = Object.assign(Object.assign({}, (_a = this._state) === null || _a === void 0 ? void 0 : _a.authorizationRequestOpts), opts);
448
+ if (!authorizationRequestOpts) {
449
+ // We only set a redirectUri if no options are provided.
450
+ // Note that this only works for mobile apps, that can handle a code query param on the default openid-credential-offer deeplink.
451
+ // Provide your own options if that is not desired!
452
+ authorizationRequestOpts = { redirectUri: `${oid4vci_common_1.DefaultURISchemes.CREDENTIAL_OFFER}://` };
453
+ }
454
+ const clientId = (_b = authorizationRequestOpts.clientId) !== null && _b !== void 0 ? _b : this._state.clientId;
455
+ // sync clientId
456
+ this._state.clientId = clientId;
457
+ authorizationRequestOpts.clientId = clientId;
458
+ return authorizationRequestOpts;
459
+ }
460
+ }
461
+ exports.OpenID4VCIClientV1_0_11 = OpenID4VCIClientV1_0_11;
462
+ //# sourceMappingURL=OpenID4VCIClientV1_0_11.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenID4VCIClientV1_0_11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A8B,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;AA7kBD,0DA6kBC"}
@@ -0,0 +1,12 @@
1
+ import { OpenIDResponse, WellKnownEndpoints } from '@sphereon/oid4vci-common';
2
+ /**
3
+ * Allows to retrieve information from a well-known location
4
+ *
5
+ * @param host The host
6
+ * @param endpointType The endpoint type, currently supports OID4VCI, OIDC and OAuth2 endpoint types
7
+ * @param opts Options, like for instance whether an error should be thrown in case the endpoint doesn't exist
8
+ */
9
+ export declare const retrieveWellknown: <T>(host: string, endpointType: WellKnownEndpoints, opts?: {
10
+ errorOnNotFound?: boolean;
11
+ }) => Promise<OpenIDResponse<T>>;
12
+ //# sourceMappingURL=OpenIDUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenIDUtils.d.ts","sourceRoot":"","sources":["../../lib/functions/OpenIDUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAItF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,YACtB,MAAM,gBACE,kBAAkB,SACzB;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,+BAUrC,CAAA"}
@@ -0,0 +1,37 @@
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.retrieveWellknown = void 0;
16
+ const oid4vci_common_1 = require("@sphereon/oid4vci-common");
17
+ const debug_1 = __importDefault(require("debug"));
18
+ const debug = (0, debug_1.default)('sphereon:openid4vci:openid-utils');
19
+ /**
20
+ * Allows to retrieve information from a well-known location
21
+ *
22
+ * @param host The host
23
+ * @param endpointType The endpoint type, currently supports OID4VCI, OIDC and OAuth2 endpoint types
24
+ * @param opts Options, like for instance whether an error should be thrown in case the endpoint doesn't exist
25
+ */
26
+ const retrieveWellknown = (host, endpointType, opts) => __awaiter(void 0, void 0, void 0, function* () {
27
+ const result = yield (0, oid4vci_common_1.getJson)(`${host.endsWith('/') ? host.slice(0, -1) : host}${endpointType}`, {
28
+ exceptionOnHttpErrorStatus: opts === null || opts === void 0 ? void 0 : opts.errorOnNotFound,
29
+ });
30
+ if (result.origResponse.status >= 400) {
31
+ // We only get here when error on not found is false
32
+ debug(`host ${host} with endpoint type ${endpointType} status: ${result.origResponse.status}, ${result.origResponse.statusText}`);
33
+ }
34
+ return result;
35
+ });
36
+ exports.retrieveWellknown = retrieveWellknown;
37
+ //# sourceMappingURL=OpenIDUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenIDUtils.js","sourceRoot":"","sources":["../../lib/functions/OpenIDUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAAsF;AACtF,kDAA0B;AAE1B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,kCAAkC,CAAC,CAAC;AACxD;;;;;;GAMG;AACI,MAAM,iBAAiB,GAAG,CAC/B,IAAY,EACZ,YAAgC,EAChC,IAAoC,EACR,EAAE;IAC9B,MAAM,MAAM,GAAsB,MAAM,IAAA,wBAAO,EAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,YAAY,EAAE,EAAE;QACnH,0BAA0B,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,eAAe;KAClD,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;QACtC,oDAAoD;QACpD,KAAK,CAAC,QAAQ,IAAI,uBAAuB,YAAY,YAAY,MAAM,CAAC,YAAY,CAAC,MAAM,KAAK,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC;IACpI,CAAC;IACD,OAAO,MAAM,CAAC;AACd,CAAC,CAAA,CAAA;AAbY,QAAA,iBAAiB,qBAa7B"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,17 @@
1
1
  export * from './AccessTokenClient';
2
+ export * from './AccessTokenClientV1_0_11';
3
+ export * from './AuthorizationCodeClient';
4
+ export * from './AuthorizationCodeClientV1_0_11';
2
5
  export * from './CredentialRequestClient';
3
6
  export * from './CredentialOfferClient';
4
- export * from './CredentialRequestClient';
7
+ export * from './CredentialOfferClientV1_0_11';
8
+ export * from './CredentialRequestClientV1_0_11';
5
9
  export * from './CredentialRequestClientBuilder';
10
+ export * from './CredentialRequestClientBuilderV1_0_11';
6
11
  export * from './functions';
7
12
  export * from './MetadataClient';
13
+ export * from './MetadataClientV1_0_11';
8
14
  export * from './OpenID4VCIClient';
15
+ export * from './OpenID4VCIClientV1_0_11';
9
16
  export * from './ProofOfPossessionBuilder';
10
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,yCAAyC,CAAC;AACxD,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -15,12 +15,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./AccessTokenClient"), exports);
18
+ __exportStar(require("./AccessTokenClientV1_0_11"), exports);
19
+ __exportStar(require("./AuthorizationCodeClient"), exports);
20
+ __exportStar(require("./AuthorizationCodeClientV1_0_11"), exports);
18
21
  __exportStar(require("./CredentialRequestClient"), exports);
19
22
  __exportStar(require("./CredentialOfferClient"), exports);
20
- __exportStar(require("./CredentialRequestClient"), exports);
23
+ __exportStar(require("./CredentialOfferClientV1_0_11"), exports);
24
+ __exportStar(require("./CredentialRequestClientV1_0_11"), exports);
21
25
  __exportStar(require("./CredentialRequestClientBuilder"), exports);
26
+ __exportStar(require("./CredentialRequestClientBuilderV1_0_11"), exports);
22
27
  __exportStar(require("./functions"), exports);
23
28
  __exportStar(require("./MetadataClient"), exports);
29
+ __exportStar(require("./MetadataClientV1_0_11"), exports);
24
30
  __exportStar(require("./OpenID4VCIClient"), exports);
31
+ __exportStar(require("./OpenID4VCIClientV1_0_11"), exports);
25
32
  __exportStar(require("./ProofOfPossessionBuilder"), exports);
26
33
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,4DAA0C;AAC1C,0DAAwC;AACxC,4DAA0C;AAC1C,mEAAiD;AACjD,8CAA4B;AAC5B,mDAAiC;AACjC,qDAAmC;AACnC,6DAA2C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,6DAA2C;AAC3C,4DAA0C;AAC1C,mEAAiD;AACjD,4DAA0C;AAC1C,0DAAwC;AACxC,iEAA+C;AAC/C,mEAAiD;AACjD,mEAAiD;AACjD,0EAAwD;AACxD,8CAA4B;AAC5B,mDAAiC;AACjC,0DAAwC;AACxC,qDAAmC;AACnC,4DAA0C;AAC1C,6DAA2C"}