@sphereon/oid4vci-client 0.8.2-unstable.75 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/AuthorizationCodeClient.js +13 -5
- package/dist/AuthorizationCodeClient.js.map +1 -1
- package/dist/OpenID4VCIClient.d.ts +18 -11
- package/dist/OpenID4VCIClient.d.ts.map +1 -1
- package/dist/OpenID4VCIClient.js +88 -67
- package/dist/OpenID4VCIClient.js.map +1 -1
- package/lib/AuthorizationCodeClient.ts +17 -5
- package/lib/OpenID4VCIClient.ts +112 -76
- package/lib/__tests__/OpenID4VCIClient.spec.ts +7 -7
- package/lib/__tests__/SphereonE2E.spec.test.ts +2 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorizationCodeClient.d.ts","sourceRoot":"","sources":["../lib/AuthorizationCodeClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,EAGxB,iCAAiC,EACjC,mBAAmB,EACnB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"AuthorizationCodeClient.d.ts","sourceRoot":"","sources":["../lib/AuthorizationCodeClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,EAGxB,iCAAiC,EACjC,mBAAmB,EACnB,sBAAsB,EAItB,QAAQ,EAGT,MAAM,0BAA0B,CAAC;AAKlC,eAAO,MAAM,6BAA6B;UAOlC,QAAQ;sBACI,sBAAsB;0BAClB,wBAAwB;;;MAG5C,QAAQ,MAAM,CA4FjB,CAAC"}
|
|
@@ -14,7 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.createAuthorizationRequestUrl = void 0;
|
|
16
16
|
const oid4vci_common_1 = require("@sphereon/oid4vci-common");
|
|
17
|
-
const oid4vci_common_2 = require("@sphereon/oid4vci-common");
|
|
18
17
|
const debug_1 = __importDefault(require("debug"));
|
|
19
18
|
const debug = (0, debug_1.default)('sphereon:oid4vci');
|
|
20
19
|
const createAuthorizationRequestUrl = ({ pkce, endpointMetadata, authorizationRequest, credentialOffer, credentialsSupported, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -64,12 +63,21 @@ const createAuthorizationRequestUrl = ({ pkce, endpointMetadata, authorizationRe
|
|
|
64
63
|
}
|
|
65
64
|
else if (parEndpoint && parMode !== oid4vci_common_1.PARMode.NEVER) {
|
|
66
65
|
debug(`USING PAR with endpoint ${parEndpoint}`);
|
|
67
|
-
const parResponse = yield (0,
|
|
66
|
+
const parResponse = yield (0, oid4vci_common_1.formPost)(parEndpoint, (0, oid4vci_common_1.convertJsonToURI)(queryObj, {
|
|
67
|
+
mode: oid4vci_common_1.JsonURIMode.X_FORM_WWW_URLENCODED,
|
|
68
|
+
uriTypeProperties: ['client_id', 'request_uri', 'redirect_uri', 'scope', 'authorization_details', 'issuer_state'],
|
|
69
|
+
}), { contentType: 'application/x-www-form-urlencoded', accept: 'application/json' });
|
|
68
70
|
if (parResponse.errorBody || !parResponse.successBody) {
|
|
69
|
-
|
|
71
|
+
console.log(JSON.stringify(parResponse.errorBody));
|
|
72
|
+
console.log('Falling back to regular request URI, since PAR failed');
|
|
73
|
+
if (parMode === oid4vci_common_1.PARMode.REQUIRE) {
|
|
74
|
+
throw Error(`PAR error: ${parResponse.origResponse.statusText}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
debug(`PAR response: ${(parResponse.successBody, null, 2)}`);
|
|
79
|
+
queryObj = { request_uri: parResponse.successBody.request_uri };
|
|
70
80
|
}
|
|
71
|
-
debug(`PAR response: ${(parResponse.successBody, null, 2)}`);
|
|
72
|
-
queryObj = { request_uri: parResponse.successBody.request_uri };
|
|
73
81
|
}
|
|
74
82
|
debug(`Object that will become query params: ` + JSON.stringify(queryObj, null, 2));
|
|
75
83
|
const url = (0, oid4vci_common_1.convertJsonToURI)(queryObj, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorizationCodeClient.js","sourceRoot":"","sources":["../lib/AuthorizationCodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"AuthorizationCodeClient.js","sourceRoot":"","sources":["../lib/AuthorizationCodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAckC;AAClC,kDAA0B;AAE1B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,kBAAkB,CAAC,CAAC;AAEjC,MAAM,6BAA6B,GAAG,CAAO,EAClD,IAAI,EACJ,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,GAOrB,EAAmB,EAAE;;IACpB,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,oBAAoB,CAAC;IACvD,IAAI,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,oBAAoB,CAAC;IAC3D,MAAM,OAAO,GAAG,CAAA,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,wBAAwB,0CAAE,qCAAqC;QAC/F,CAAC,CAAC,wBAAO,CAAC,OAAO;QACjB,CAAC,CAAC,MAAA,oBAAoB,CAAC,OAAO,mCAAI,wBAAO,CAAC,IAAI,CAAC;IACjD,gFAAgF;IAChF,iGAAiG;IACjG,IAAI,CAAC,KAAK,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACpC,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,KAAK,CAAC,mFAAmF,CAAC,CAAC;QACnG,CAAC;QACD,MAAM,KAAK,GAAG,eAAe,CAAC,gBAAgB,CAAC,WAAW,CAAC;QAE3D,wCAAwC;QACxC,6DAA6D;QAC7D,aAAa;QACb,oBAAoB,GAAG,KAAK;aACzB,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,IA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l, CredentialResponse, CredentialSupported, EndpointMetadataResult, JWK, OID4VCICredentialFormat, OpenId4VCIVersion, PKCEOpts, ProofOfPossessionCallbacks } from '@sphereon/oid4vci-common';
|
|
2
2
|
import { CredentialFormat } from '@sphereon/ssi-types';
|
|
3
|
+
export interface OpenID4VCIClientState {
|
|
4
|
+
credentialIssuer: string;
|
|
5
|
+
credentialOffer?: CredentialOfferRequestWithBaseUrl;
|
|
6
|
+
clientId?: string;
|
|
7
|
+
kid?: string;
|
|
8
|
+
jwk?: JWK;
|
|
9
|
+
alg?: Alg | string;
|
|
10
|
+
endpointMetadata?: EndpointMetadataResult;
|
|
11
|
+
accessTokenResponse?: AccessTokenResponse;
|
|
12
|
+
authorizationRequestOpts?: AuthorizationRequestOpts;
|
|
13
|
+
pkce: PKCEOpts;
|
|
14
|
+
authorizationURL?: string;
|
|
15
|
+
}
|
|
3
16
|
export declare class OpenID4VCIClient {
|
|
4
|
-
private readonly
|
|
5
|
-
private readonly _credentialIssuer;
|
|
6
|
-
private _clientId?;
|
|
7
|
-
private _kid;
|
|
8
|
-
private _jwk;
|
|
9
|
-
private _alg;
|
|
10
|
-
private _endpointMetadata;
|
|
11
|
-
private _accessTokenResponse;
|
|
12
|
-
private _pkce;
|
|
13
|
-
private _authorizationRequestOpts?;
|
|
14
|
-
private _authorizationURL?;
|
|
17
|
+
private readonly _state;
|
|
15
18
|
private constructor();
|
|
16
19
|
static fromCredentialIssuer({ kid, alg, retrieveServerMetadata, clientId, credentialIssuer, pkce, authorizationRequest, createAuthorizationRequestURL, }: {
|
|
17
20
|
credentialIssuer: string;
|
|
@@ -23,6 +26,9 @@ export declare class OpenID4VCIClient {
|
|
|
23
26
|
authorizationRequest?: AuthorizationRequestOpts;
|
|
24
27
|
pkce?: PKCEOpts;
|
|
25
28
|
}): Promise<OpenID4VCIClient>;
|
|
29
|
+
static fromState({ state }: {
|
|
30
|
+
state: OpenID4VCIClientState | string;
|
|
31
|
+
}): Promise<OpenID4VCIClient>;
|
|
26
32
|
static fromURI({ uri, kid, alg, retrieveServerMetadata, clientId, pkce, createAuthorizationRequestURL, authorizationRequest, resolveOfferUri, }: {
|
|
27
33
|
uri: string;
|
|
28
34
|
kid?: string;
|
|
@@ -66,6 +72,7 @@ export declare class OpenID4VCIClient {
|
|
|
66
72
|
deferredCredentialAwait?: boolean;
|
|
67
73
|
deferredCredentialIntervalInMS?: number;
|
|
68
74
|
}): Promise<CredentialResponse>;
|
|
75
|
+
exportState(): Promise<string>;
|
|
69
76
|
getCredentialsSupported(restrictToInitiationTypes: boolean, format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[]): CredentialSupported[];
|
|
70
77
|
getCredentialOfferTypes(): string[][];
|
|
71
78
|
issuerSupportedFlowTypes(): AuthzFlowType[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenID4VCIClient.d.ts","sourceRoot":"","sources":["../lib/OpenID4VCIClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,GAAG,EACH,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,EAGb,iCAAiC,EACjC,kBAAkB,EAClB,mBAAmB,EAEnB,sBAAsB,EAKtB,GAAG,EAEH,uBAAuB,EACvB,iBAAiB,EACjB,QAAQ,EACR,0BAA0B,EAE3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAavD,
|
|
1
|
+
{"version":3,"file":"OpenID4VCIClient.d.ts","sourceRoot":"","sources":["../lib/OpenID4VCIClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,GAAG,EACH,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,EAGb,iCAAiC,EACjC,kBAAkB,EAClB,mBAAmB,EAEnB,sBAAsB,EAKtB,GAAG,EAEH,uBAAuB,EACvB,iBAAiB,EACjB,QAAQ,EACR,0BAA0B,EAE3B,MAAM,0BAA0B,CAAC;AAClC,OAAO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,qBAAqB,IAAI,MAAM;IAK/B,6BAA6B,IAAI,OAAO;IAIxC,6BAA6B,IAAI,MAAM;IAK9C;;OAEG;IACI,MAAM;IAeb,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,4BAA4B;CAcrC"}
|
package/dist/OpenID4VCIClient.js
CHANGED
|
@@ -24,22 +24,31 @@ const ProofOfPossessionBuilder_1 = require("./ProofOfPossessionBuilder");
|
|
|
24
24
|
const AuthorizationUtil_1 = require("./functions/AuthorizationUtil");
|
|
25
25
|
const debug = (0, debug_1.default)('sphereon:oid4vci');
|
|
26
26
|
class OpenID4VCIClient {
|
|
27
|
-
constructor({ credentialOffer, clientId, kid, alg, credentialIssuer, pkce, authorizationRequest, }) {
|
|
27
|
+
constructor({ credentialOffer, clientId, kid, alg, credentialIssuer, pkce, authorizationRequest, jwk, endpointMetadata, accessTokenResponse, authorizationRequestOpts, authorizationURL, }) {
|
|
28
28
|
var _a;
|
|
29
|
-
this._pkce = { disabled: false, codeChallengeMethod: oid4vci_common_1.CodeChallengeMethod.S256 };
|
|
30
|
-
this._credentialOffer = credentialOffer;
|
|
31
29
|
const issuer = credentialIssuer !== null && credentialIssuer !== void 0 ? credentialIssuer : (credentialOffer ? (0, oid4vci_common_1.getIssuerFromCredentialOfferPayload)(credentialOffer.credential_offer) : undefined);
|
|
32
30
|
if (!issuer) {
|
|
33
31
|
throw Error('No credential issuer supplied or deduced from offer');
|
|
34
32
|
}
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
jwk,
|
|
43
|
+
endpointMetadata,
|
|
44
|
+
accessTokenResponse,
|
|
45
|
+
authorizationURL,
|
|
46
|
+
};
|
|
47
|
+
// Running syncAuthorizationRequestOpts later as it is using the state
|
|
48
|
+
if (!this._state.authorizationRequestOpts) {
|
|
49
|
+
this._state.authorizationRequestOpts = this.syncAuthorizationRequestOpts(authorizationRequest);
|
|
50
|
+
}
|
|
51
|
+
debug(`Authorization req options: ${JSON.stringify(this._state.authorizationRequestOpts, null, 2)}`);
|
|
43
52
|
}
|
|
44
53
|
static fromCredentialIssuer({ kid, alg, retrieveServerMetadata, clientId, credentialIssuer, pkce, authorizationRequest, createAuthorizationRequestURL, }) {
|
|
45
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -60,6 +69,12 @@ class OpenID4VCIClient {
|
|
|
60
69
|
return client;
|
|
61
70
|
});
|
|
62
71
|
}
|
|
72
|
+
static fromState({ state }) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const clientState = typeof state === 'string' ? JSON.parse(state) : state;
|
|
75
|
+
return new OpenID4VCIClient(clientState);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
63
78
|
static fromURI({ uri, kid, alg, retrieveServerMetadata, clientId, pkce, createAuthorizationRequestURL, authorizationRequest, resolveOfferUri, }) {
|
|
64
79
|
var _a;
|
|
65
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -78,7 +93,7 @@ class OpenID4VCIClient {
|
|
|
78
93
|
if (credentialOfferClient.supportedFlows.includes(oid4vci_common_1.AuthzFlowType.AUTHORIZATION_CODE_FLOW) &&
|
|
79
94
|
(createAuthorizationRequestURL === undefined || createAuthorizationRequestURL)) {
|
|
80
95
|
yield client.createAuthorizationRequestUrl({ authorizationRequest, pkce });
|
|
81
|
-
debug(`Authorization Request URL: ${client.
|
|
96
|
+
debug(`Authorization Request URL: ${client._state.authorizationURL}`);
|
|
82
97
|
}
|
|
83
98
|
return client;
|
|
84
99
|
});
|
|
@@ -92,37 +107,38 @@ class OpenID4VCIClient {
|
|
|
92
107
|
createAuthorizationRequestUrl(opts) {
|
|
93
108
|
var _a;
|
|
94
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
if (!this.
|
|
110
|
+
if (!this._state.authorizationURL) {
|
|
96
111
|
this.calculatePKCEOpts(opts === null || opts === void 0 ? void 0 : opts.pkce);
|
|
97
|
-
this.
|
|
98
|
-
if (!this.
|
|
112
|
+
this._state.authorizationRequestOpts = this.syncAuthorizationRequestOpts(opts === null || opts === void 0 ? void 0 : opts.authorizationRequest);
|
|
113
|
+
if (!this._state.authorizationRequestOpts) {
|
|
99
114
|
throw Error(`No Authorization Request options present or provided in this call`);
|
|
100
115
|
}
|
|
101
116
|
// todo: Probably can go with current logic in MetadataClient who will always set the authorization_endpoint when found
|
|
102
117
|
// handling this because of the support for v1_0-08
|
|
103
|
-
if (((_a = this.
|
|
104
|
-
|
|
118
|
+
if (((_a = this._state.endpointMetadata) === null || _a === void 0 ? void 0 : _a.credentialIssuerMetadata) &&
|
|
119
|
+
'authorization_endpoint' in this._state.endpointMetadata.credentialIssuerMetadata) {
|
|
120
|
+
this._state.endpointMetadata.authorization_endpoint = this._state.endpointMetadata.credentialIssuerMetadata.authorization_endpoint;
|
|
105
121
|
}
|
|
106
|
-
this.
|
|
107
|
-
pkce: this.
|
|
122
|
+
this._state.authorizationURL = yield (0, AuthorizationCodeClient_1.createAuthorizationRequestUrl)({
|
|
123
|
+
pkce: this._state.pkce,
|
|
108
124
|
endpointMetadata: this.endpointMetadata,
|
|
109
|
-
authorizationRequest: this.
|
|
125
|
+
authorizationRequest: this._state.authorizationRequestOpts,
|
|
110
126
|
credentialOffer: this.credentialOffer,
|
|
111
127
|
credentialsSupported: this.getCredentialsSupported(true),
|
|
112
128
|
});
|
|
113
129
|
}
|
|
114
|
-
return this.
|
|
130
|
+
return this._state.authorizationURL;
|
|
115
131
|
});
|
|
116
132
|
}
|
|
117
133
|
retrieveServerMetadata() {
|
|
118
134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
135
|
this.assertIssuerData();
|
|
120
|
-
if (!this.
|
|
136
|
+
if (!this._state.endpointMetadata) {
|
|
121
137
|
if (this.credentialOffer) {
|
|
122
|
-
this.
|
|
138
|
+
this._state.endpointMetadata = yield MetadataClient_1.MetadataClient.retrieveAllMetadataFromCredentialOffer(this.credentialOffer);
|
|
123
139
|
}
|
|
124
|
-
else if (this.
|
|
125
|
-
this.
|
|
140
|
+
else if (this._state.credentialIssuer) {
|
|
141
|
+
this._state.endpointMetadata = yield MetadataClient_1.MetadataClient.retrieveAllMetadata(this._state.credentialIssuer);
|
|
126
142
|
}
|
|
127
143
|
else {
|
|
128
144
|
throw Error(`Cannot retrieve issuer metadata without either a credential offer, or issuer value`);
|
|
@@ -132,7 +148,7 @@ class OpenID4VCIClient {
|
|
|
132
148
|
});
|
|
133
149
|
}
|
|
134
150
|
calculatePKCEOpts(pkce) {
|
|
135
|
-
this.
|
|
151
|
+
this._state.pkce = (0, AuthorizationUtil_1.generateMissingPKCEOpts)(Object.assign(Object.assign({}, this._state.pkce), pkce));
|
|
136
152
|
}
|
|
137
153
|
acquireAccessToken(opts) {
|
|
138
154
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -141,31 +157,31 @@ class OpenID4VCIClient {
|
|
|
141
157
|
let { redirectUri } = opts !== null && opts !== void 0 ? opts : {};
|
|
142
158
|
const code = (_a = opts === null || opts === void 0 ? void 0 : opts.code) !== null && _a !== void 0 ? _a : ((opts === null || opts === void 0 ? void 0 : opts.authorizationResponse) ? (0, oid4vci_common_1.toAuthorizationResponsePayload)(opts.authorizationResponse).code : undefined);
|
|
143
159
|
if (opts === null || opts === void 0 ? void 0 : opts.codeVerifier) {
|
|
144
|
-
this.
|
|
160
|
+
this._state.pkce.codeVerifier = opts.codeVerifier;
|
|
145
161
|
}
|
|
146
162
|
this.assertIssuerData();
|
|
147
163
|
if (clientId) {
|
|
148
|
-
this.
|
|
164
|
+
this._state.clientId = clientId;
|
|
149
165
|
}
|
|
150
|
-
if (!this.
|
|
166
|
+
if (!this._state.accessTokenResponse) {
|
|
151
167
|
const accessTokenClient = new AccessTokenClient_1.AccessTokenClient();
|
|
152
|
-
if (redirectUri && redirectUri !== ((_b = this.
|
|
153
|
-
console.log(`Redirect URI mismatch between access-token (${redirectUri}) and authorization request (${(_c = this.
|
|
168
|
+
if (redirectUri && redirectUri !== ((_b = this._state.authorizationRequestOpts) === null || _b === void 0 ? void 0 : _b.redirectUri)) {
|
|
169
|
+
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.`);
|
|
154
170
|
}
|
|
155
|
-
if (((_d = this.
|
|
156
|
-
redirectUri = this.
|
|
171
|
+
if (((_d = this._state.authorizationRequestOpts) === null || _d === void 0 ? void 0 : _d.redirectUri) && !redirectUri) {
|
|
172
|
+
redirectUri = this._state.authorizationRequestOpts.redirectUri;
|
|
157
173
|
}
|
|
158
|
-
const response = yield accessTokenClient.acquireAccessToken(Object.assign(Object.assign({ credentialOffer: this.credentialOffer, metadata: this.endpointMetadata, credentialIssuer: this.getIssuer(), pin }, (!this.
|
|
174
|
+
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,
|
|
159
175
|
redirectUri, asOpts: { clientId: this.clientId } }));
|
|
160
176
|
if (response.errorBody) {
|
|
161
177
|
debug(`Access token error:\r\n${response.errorBody}`);
|
|
162
|
-
throw Error(`Retrieving an access token from ${(_e = this.
|
|
178
|
+
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}`);
|
|
163
179
|
}
|
|
164
180
|
else if (!response.successBody) {
|
|
165
181
|
debug(`Access token error. No success body`);
|
|
166
|
-
throw Error(`Retrieving an access token from ${(_f = this.
|
|
182
|
+
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`);
|
|
167
183
|
}
|
|
168
|
-
this.
|
|
184
|
+
this._state.accessTokenResponse = response.successBody;
|
|
169
185
|
}
|
|
170
186
|
return this.accessTokenResponse;
|
|
171
187
|
});
|
|
@@ -177,11 +193,11 @@ class OpenID4VCIClient {
|
|
|
177
193
|
throw new Error(oid4vci_common_1.KID_JWK_X5C_ERROR + `. jwk: ${jwk !== undefined}, kid: ${kid !== undefined}`);
|
|
178
194
|
}
|
|
179
195
|
if (alg)
|
|
180
|
-
this.
|
|
196
|
+
this._state.alg = alg;
|
|
181
197
|
if (jwk)
|
|
182
|
-
this.
|
|
198
|
+
this._state.jwk = jwk;
|
|
183
199
|
if (kid)
|
|
184
|
-
this.
|
|
200
|
+
this._state.kid = kid;
|
|
185
201
|
const requestBuilder = this.credentialOffer
|
|
186
202
|
? CredentialRequestClientBuilder_1.CredentialRequestClientBuilder.fromCredentialOffer({
|
|
187
203
|
credentialOffer: this.credentialOffer,
|
|
@@ -228,11 +244,11 @@ class OpenID4VCIClient {
|
|
|
228
244
|
})
|
|
229
245
|
.withIssuer(this.getIssuer())
|
|
230
246
|
.withAlg(this.alg);
|
|
231
|
-
if (this.
|
|
232
|
-
proofBuilder.withJWK(this.
|
|
247
|
+
if (this._state.jwk) {
|
|
248
|
+
proofBuilder.withJWK(this._state.jwk);
|
|
233
249
|
}
|
|
234
|
-
if (this.
|
|
235
|
-
proofBuilder.withKid(this.
|
|
250
|
+
if (this._state.kid) {
|
|
251
|
+
proofBuilder.withKid(this._state.kid);
|
|
236
252
|
}
|
|
237
253
|
if (this.clientId) {
|
|
238
254
|
proofBuilder.withClientId(this.clientId);
|
|
@@ -248,15 +264,20 @@ class OpenID4VCIClient {
|
|
|
248
264
|
});
|
|
249
265
|
if (response.errorBody) {
|
|
250
266
|
debug(`Credential request error:\r\n${JSON.stringify(response.errorBody)}`);
|
|
251
|
-
throw Error(`Retrieving a credential from ${(_b = this.
|
|
267
|
+
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}`);
|
|
252
268
|
}
|
|
253
269
|
else if (!response.successBody) {
|
|
254
270
|
debug(`Credential request error. No success body`);
|
|
255
|
-
throw Error(`Retrieving a credential from ${(_c = this.
|
|
271
|
+
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`);
|
|
256
272
|
}
|
|
257
273
|
return response.successBody;
|
|
258
274
|
});
|
|
259
275
|
}
|
|
276
|
+
exportState() {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
+
return JSON.stringify(this._state);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
260
281
|
// FIXME: We really should convert <v11 to v12 objects first. Right now the logic doesn't map nicely and is brittle.
|
|
261
282
|
// We should resolve IDs to objects first in case of strings.
|
|
262
283
|
// When < v11 convert into a v12 object. When v12 object retain it.
|
|
@@ -299,19 +320,19 @@ class OpenID4VCIClient {
|
|
|
299
320
|
}
|
|
300
321
|
issuerSupportedFlowTypes() {
|
|
301
322
|
var _a, _b, _c, _d;
|
|
302
|
-
return ((_b = (_a = this.credentialOffer) === null || _a === void 0 ? void 0 : _a.supportedFlows) !== null && _b !== void 0 ? _b : (((_d = (_c = this.
|
|
323
|
+
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] : []));
|
|
303
324
|
}
|
|
304
325
|
isFlowTypeSupported(flowType) {
|
|
305
326
|
return this.issuerSupportedFlowTypes().includes(flowType);
|
|
306
327
|
}
|
|
307
328
|
get authorizationURL() {
|
|
308
|
-
return this.
|
|
329
|
+
return this._state.authorizationURL;
|
|
309
330
|
}
|
|
310
331
|
hasAuthorizationURL() {
|
|
311
332
|
return !!this.authorizationURL;
|
|
312
333
|
}
|
|
313
334
|
get credentialOffer() {
|
|
314
|
-
return this.
|
|
335
|
+
return this._state.credentialOffer;
|
|
315
336
|
}
|
|
316
337
|
version() {
|
|
317
338
|
var _a, _b;
|
|
@@ -320,39 +341,39 @@ class OpenID4VCIClient {
|
|
|
320
341
|
get endpointMetadata() {
|
|
321
342
|
this.assertServerMetadata();
|
|
322
343
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
323
|
-
return this.
|
|
344
|
+
return this._state.endpointMetadata;
|
|
324
345
|
}
|
|
325
346
|
get kid() {
|
|
326
347
|
this.assertIssuerData();
|
|
327
|
-
if (!this.
|
|
348
|
+
if (!this._state.kid) {
|
|
328
349
|
throw new Error('No value for kid is supplied');
|
|
329
350
|
}
|
|
330
|
-
return this.
|
|
351
|
+
return this._state.kid;
|
|
331
352
|
}
|
|
332
353
|
get alg() {
|
|
333
354
|
this.assertIssuerData();
|
|
334
|
-
if (!this.
|
|
355
|
+
if (!this._state.alg) {
|
|
335
356
|
throw new Error('No value for alg is supplied');
|
|
336
357
|
}
|
|
337
|
-
return this.
|
|
358
|
+
return this._state.alg;
|
|
338
359
|
}
|
|
339
360
|
set clientId(value) {
|
|
340
|
-
this.
|
|
361
|
+
this._state.clientId = value;
|
|
341
362
|
}
|
|
342
363
|
get clientId() {
|
|
343
|
-
return this.
|
|
364
|
+
return this._state.clientId;
|
|
344
365
|
}
|
|
345
366
|
hasAccessTokenResponse() {
|
|
346
|
-
return !!this.
|
|
367
|
+
return !!this._state.accessTokenResponse;
|
|
347
368
|
}
|
|
348
369
|
get accessTokenResponse() {
|
|
349
370
|
this.assertAccessToken();
|
|
350
371
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
351
|
-
return this.
|
|
372
|
+
return this._state.accessTokenResponse;
|
|
352
373
|
}
|
|
353
374
|
getIssuer() {
|
|
354
375
|
this.assertIssuerData();
|
|
355
|
-
return this.
|
|
376
|
+
return this._state.credentialIssuer;
|
|
356
377
|
}
|
|
357
378
|
getAccessTokenEndpoint() {
|
|
358
379
|
this.assertIssuerData();
|
|
@@ -386,35 +407,35 @@ class OpenID4VCIClient {
|
|
|
386
407
|
return (_c = (_b = this.endpointMetadata.credentialIssuerMetadata) === null || _b === void 0 ? void 0 : _b.authorization_endpoint) === null || _c === void 0 ? void 0 : _c.includes('ebsi.eu');
|
|
387
408
|
}
|
|
388
409
|
assertIssuerData() {
|
|
389
|
-
if (!this.
|
|
410
|
+
if (!this._state.credentialIssuer) {
|
|
390
411
|
throw Error(`No credential issuer value present`);
|
|
391
412
|
}
|
|
392
|
-
else if (!this.
|
|
413
|
+
else if (!this._state.credentialOffer && this._state.endpointMetadata && this.issuerSupportedFlowTypes().length === 0) {
|
|
393
414
|
throw Error(`No issuance initiation or credential offer present`);
|
|
394
415
|
}
|
|
395
416
|
}
|
|
396
417
|
assertServerMetadata() {
|
|
397
|
-
if (!this.
|
|
418
|
+
if (!this._state.endpointMetadata) {
|
|
398
419
|
throw Error('No server metadata');
|
|
399
420
|
}
|
|
400
421
|
}
|
|
401
422
|
assertAccessToken() {
|
|
402
|
-
if (!this.
|
|
423
|
+
if (!this._state.accessTokenResponse) {
|
|
403
424
|
throw Error(`No access token present`);
|
|
404
425
|
}
|
|
405
426
|
}
|
|
406
427
|
syncAuthorizationRequestOpts(opts) {
|
|
407
|
-
var _a;
|
|
408
|
-
let authorizationRequestOpts = Object.assign(Object.assign({}, this.
|
|
428
|
+
var _a, _b;
|
|
429
|
+
let authorizationRequestOpts = Object.assign(Object.assign({}, (_a = this._state) === null || _a === void 0 ? void 0 : _a.authorizationRequestOpts), opts);
|
|
409
430
|
if (!authorizationRequestOpts) {
|
|
410
431
|
// We only set a redirectUri if no options are provided.
|
|
411
432
|
// Note that this only works for mobile apps, that can handle a code query param on the default openid-credential-offer deeplink.
|
|
412
433
|
// Provide your own options if that is not desired!
|
|
413
434
|
authorizationRequestOpts = { redirectUri: `${oid4vci_common_1.DefaultURISchemes.CREDENTIAL_OFFER}://` };
|
|
414
435
|
}
|
|
415
|
-
const clientId = (
|
|
436
|
+
const clientId = (_b = authorizationRequestOpts.clientId) !== null && _b !== void 0 ? _b : this._state.clientId;
|
|
416
437
|
// sync clientId
|
|
417
|
-
this.
|
|
438
|
+
this._state.clientId = clientId;
|
|
418
439
|
authorizationRequestOpts.clientId = clientId;
|
|
419
440
|
return authorizationRequestOpts;
|
|
420
441
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenID4VCIClient.js","sourceRoot":"","sources":["../lib/OpenID4VCIClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAwBkC;AAElC,kDAA0B;AAE1B,2DAAwD;AACxD,uEAA0E;AAC1E,mEAAgE;AAChE,qFAAkF;AAClF,qDAAkD;AAClD,yEAAsE;AACtE,qEAAwE;AAExE,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,kBAAkB,CAAC,CAAC;AAExC,MAAa,gBAAgB;IAc3B,YAAoB,EAClB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G,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;AArjBD,4CAqjBC"}
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
CredentialOfferRequestWithBaseUrl,
|
|
7
7
|
CredentialSupported,
|
|
8
8
|
EndpointMetadataResult,
|
|
9
|
+
formPost,
|
|
9
10
|
JsonURIMode,
|
|
10
11
|
PARMode,
|
|
11
12
|
PKCEOpts,
|
|
12
13
|
PushedAuthorizationResponse,
|
|
13
14
|
ResponseType,
|
|
14
15
|
} from '@sphereon/oid4vci-common';
|
|
15
|
-
import { formPost } from '@sphereon/oid4vci-common';
|
|
16
16
|
import Debug from 'debug';
|
|
17
17
|
|
|
18
18
|
const debug = Debug('sphereon:oid4vci');
|
|
@@ -91,12 +91,24 @@ export const createAuthorizationRequestUrl = async ({
|
|
|
91
91
|
throw Error(`PAR mode is set to required by Authorization Server does not support PAR!`);
|
|
92
92
|
} else if (parEndpoint && parMode !== PARMode.NEVER) {
|
|
93
93
|
debug(`USING PAR with endpoint ${parEndpoint}`);
|
|
94
|
-
const parResponse = await formPost<PushedAuthorizationResponse>(
|
|
94
|
+
const parResponse = await formPost<PushedAuthorizationResponse>(
|
|
95
|
+
parEndpoint,
|
|
96
|
+
convertJsonToURI(queryObj, {
|
|
97
|
+
mode: JsonURIMode.X_FORM_WWW_URLENCODED,
|
|
98
|
+
uriTypeProperties: ['client_id', 'request_uri', 'redirect_uri', 'scope', 'authorization_details', 'issuer_state'],
|
|
99
|
+
}),
|
|
100
|
+
{ contentType: 'application/x-www-form-urlencoded', accept: 'application/json' },
|
|
101
|
+
);
|
|
95
102
|
if (parResponse.errorBody || !parResponse.successBody) {
|
|
96
|
-
|
|
103
|
+
console.log(JSON.stringify(parResponse.errorBody));
|
|
104
|
+
console.log('Falling back to regular request URI, since PAR failed');
|
|
105
|
+
if (parMode === PARMode.REQUIRE) {
|
|
106
|
+
throw Error(`PAR error: ${parResponse.origResponse.statusText}`);
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
debug(`PAR response: ${(parResponse.successBody, null, 2)}`);
|
|
110
|
+
queryObj = { request_uri: parResponse.successBody.request_uri };
|
|
97
111
|
}
|
|
98
|
-
debug(`PAR response: ${(parResponse.successBody, null, 2)}`);
|
|
99
|
-
queryObj = { request_uri: parResponse.successBody.request_uri };
|
|
100
112
|
}
|
|
101
113
|
|
|
102
114
|
debug(`Object that will become query params: ` + JSON.stringify(queryObj, null, 2));
|
package/lib/OpenID4VCIClient.ts
CHANGED
|
@@ -36,19 +36,22 @@ import { generateMissingPKCEOpts } from './functions/AuthorizationUtil';
|
|
|
36
36
|
|
|
37
37
|
const debug = Debug('sphereon:oid4vci');
|
|
38
38
|
|
|
39
|
+
export interface OpenID4VCIClientState {
|
|
40
|
+
credentialIssuer: string;
|
|
41
|
+
credentialOffer?: CredentialOfferRequestWithBaseUrl;
|
|
42
|
+
clientId?: string;
|
|
43
|
+
kid?: string;
|
|
44
|
+
jwk?: JWK;
|
|
45
|
+
alg?: Alg | string;
|
|
46
|
+
endpointMetadata?: EndpointMetadataResult;
|
|
47
|
+
accessTokenResponse?: AccessTokenResponse;
|
|
48
|
+
authorizationRequestOpts?: AuthorizationRequestOpts;
|
|
49
|
+
pkce: PKCEOpts;
|
|
50
|
+
authorizationURL?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
39
53
|
export class OpenID4VCIClient {
|
|
40
|
-
private readonly
|
|
41
|
-
private readonly _credentialIssuer: string;
|
|
42
|
-
private _clientId?: string;
|
|
43
|
-
private _kid: string | undefined;
|
|
44
|
-
private _jwk: JWK | undefined;
|
|
45
|
-
private _alg: Alg | string | undefined;
|
|
46
|
-
private _endpointMetadata: EndpointMetadataResult | undefined;
|
|
47
|
-
private _accessTokenResponse: AccessTokenResponse | undefined;
|
|
48
|
-
private _pkce: PKCEOpts = { disabled: false, codeChallengeMethod: CodeChallengeMethod.S256 };
|
|
49
|
-
private _authorizationRequestOpts?: AuthorizationRequestOpts;
|
|
50
|
-
|
|
51
|
-
private _authorizationURL?: string;
|
|
54
|
+
private readonly _state: OpenID4VCIClientState;
|
|
52
55
|
|
|
53
56
|
private constructor({
|
|
54
57
|
credentialOffer,
|
|
@@ -58,6 +61,11 @@ export class OpenID4VCIClient {
|
|
|
58
61
|
credentialIssuer,
|
|
59
62
|
pkce,
|
|
60
63
|
authorizationRequest,
|
|
64
|
+
jwk,
|
|
65
|
+
endpointMetadata,
|
|
66
|
+
accessTokenResponse,
|
|
67
|
+
authorizationRequestOpts,
|
|
68
|
+
authorizationURL,
|
|
61
69
|
}: {
|
|
62
70
|
credentialOffer?: CredentialOfferRequestWithBaseUrl;
|
|
63
71
|
kid?: string;
|
|
@@ -66,20 +74,35 @@ export class OpenID4VCIClient {
|
|
|
66
74
|
credentialIssuer?: string;
|
|
67
75
|
pkce?: PKCEOpts;
|
|
68
76
|
authorizationRequest?: AuthorizationRequestOpts; // Can be provided here, or when manually calling createAuthorizationUrl
|
|
77
|
+
jwk?: JWK;
|
|
78
|
+
endpointMetadata?: EndpointMetadataResult;
|
|
79
|
+
accessTokenResponse?: AccessTokenResponse;
|
|
80
|
+
authorizationRequestOpts?: AuthorizationRequestOpts;
|
|
81
|
+
authorizationURL?: string;
|
|
69
82
|
}) {
|
|
70
|
-
this._credentialOffer = credentialOffer;
|
|
71
83
|
const issuer = credentialIssuer ?? (credentialOffer ? getIssuerFromCredentialOfferPayload(credentialOffer.credential_offer) : undefined);
|
|
72
84
|
if (!issuer) {
|
|
73
85
|
throw Error('No credential issuer supplied or deduced from offer');
|
|
74
86
|
}
|
|
75
|
-
this.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
this._state = {
|
|
88
|
+
credentialOffer,
|
|
89
|
+
credentialIssuer: issuer,
|
|
90
|
+
kid,
|
|
91
|
+
alg,
|
|
92
|
+
// 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
|
|
93
|
+
clientId: clientId ?? (credentialOffer && getClientIdFromCredentialOfferPayload(credentialOffer.credential_offer)) ?? kid?.split('#')[0],
|
|
94
|
+
pkce: { disabled: false, codeChallengeMethod: CodeChallengeMethod.S256, ...pkce },
|
|
95
|
+
authorizationRequestOpts,
|
|
96
|
+
jwk,
|
|
97
|
+
endpointMetadata,
|
|
98
|
+
accessTokenResponse,
|
|
99
|
+
authorizationURL,
|
|
100
|
+
};
|
|
101
|
+
// Running syncAuthorizationRequestOpts later as it is using the state
|
|
102
|
+
if (!this._state.authorizationRequestOpts) {
|
|
103
|
+
this._state.authorizationRequestOpts = this.syncAuthorizationRequestOpts(authorizationRequest);
|
|
104
|
+
}
|
|
105
|
+
debug(`Authorization req options: ${JSON.stringify(this._state.authorizationRequestOpts, null, 2)}`);
|
|
83
106
|
}
|
|
84
107
|
|
|
85
108
|
public static async fromCredentialIssuer({
|
|
@@ -118,6 +141,12 @@ export class OpenID4VCIClient {
|
|
|
118
141
|
return client;
|
|
119
142
|
}
|
|
120
143
|
|
|
144
|
+
public static async fromState({ state }: { state: OpenID4VCIClientState | string }): Promise<OpenID4VCIClient> {
|
|
145
|
+
const clientState = typeof state === 'string' ? JSON.parse(state) : state;
|
|
146
|
+
|
|
147
|
+
return new OpenID4VCIClient(clientState);
|
|
148
|
+
}
|
|
149
|
+
|
|
121
150
|
public static async fromURI({
|
|
122
151
|
uri,
|
|
123
152
|
kid,
|
|
@@ -157,7 +186,7 @@ export class OpenID4VCIClient {
|
|
|
157
186
|
(createAuthorizationRequestURL === undefined || createAuthorizationRequestURL)
|
|
158
187
|
) {
|
|
159
188
|
await client.createAuthorizationRequestUrl({ authorizationRequest, pkce });
|
|
160
|
-
debug(`Authorization Request URL: ${client.
|
|
189
|
+
debug(`Authorization Request URL: ${client._state.authorizationURL}`);
|
|
161
190
|
}
|
|
162
191
|
|
|
163
192
|
return client;
|
|
@@ -170,36 +199,39 @@ export class OpenID4VCIClient {
|
|
|
170
199
|
* @param opts
|
|
171
200
|
*/
|
|
172
201
|
public async createAuthorizationRequestUrl(opts?: { authorizationRequest?: AuthorizationRequestOpts; pkce?: PKCEOpts }): Promise<string> {
|
|
173
|
-
if (!this.
|
|
202
|
+
if (!this._state.authorizationURL) {
|
|
174
203
|
this.calculatePKCEOpts(opts?.pkce);
|
|
175
|
-
this.
|
|
176
|
-
if (!this.
|
|
204
|
+
this._state.authorizationRequestOpts = this.syncAuthorizationRequestOpts(opts?.authorizationRequest);
|
|
205
|
+
if (!this._state.authorizationRequestOpts) {
|
|
177
206
|
throw Error(`No Authorization Request options present or provided in this call`);
|
|
178
207
|
}
|
|
179
208
|
|
|
180
209
|
// todo: Probably can go with current logic in MetadataClient who will always set the authorization_endpoint when found
|
|
181
210
|
// handling this because of the support for v1_0-08
|
|
182
|
-
if (
|
|
183
|
-
this.
|
|
211
|
+
if (
|
|
212
|
+
this._state.endpointMetadata?.credentialIssuerMetadata &&
|
|
213
|
+
'authorization_endpoint' in this._state.endpointMetadata.credentialIssuerMetadata
|
|
214
|
+
) {
|
|
215
|
+
this._state.endpointMetadata.authorization_endpoint = this._state.endpointMetadata.credentialIssuerMetadata.authorization_endpoint as string;
|
|
184
216
|
}
|
|
185
|
-
this.
|
|
186
|
-
pkce: this.
|
|
217
|
+
this._state.authorizationURL = await createAuthorizationRequestUrl({
|
|
218
|
+
pkce: this._state.pkce,
|
|
187
219
|
endpointMetadata: this.endpointMetadata,
|
|
188
|
-
authorizationRequest: this.
|
|
220
|
+
authorizationRequest: this._state.authorizationRequestOpts,
|
|
189
221
|
credentialOffer: this.credentialOffer,
|
|
190
222
|
credentialsSupported: this.getCredentialsSupported(true),
|
|
191
223
|
});
|
|
192
224
|
}
|
|
193
|
-
return this.
|
|
225
|
+
return this._state.authorizationURL;
|
|
194
226
|
}
|
|
195
227
|
|
|
196
228
|
public async retrieveServerMetadata(): Promise<EndpointMetadataResult> {
|
|
197
229
|
this.assertIssuerData();
|
|
198
|
-
if (!this.
|
|
230
|
+
if (!this._state.endpointMetadata) {
|
|
199
231
|
if (this.credentialOffer) {
|
|
200
|
-
this.
|
|
201
|
-
} else if (this.
|
|
202
|
-
this.
|
|
232
|
+
this._state.endpointMetadata = await MetadataClient.retrieveAllMetadataFromCredentialOffer(this.credentialOffer);
|
|
233
|
+
} else if (this._state.credentialIssuer) {
|
|
234
|
+
this._state.endpointMetadata = await MetadataClient.retrieveAllMetadata(this._state.credentialIssuer);
|
|
203
235
|
} else {
|
|
204
236
|
throw Error(`Cannot retrieve issuer metadata without either a credential offer, or issuer value`);
|
|
205
237
|
}
|
|
@@ -209,7 +241,7 @@ export class OpenID4VCIClient {
|
|
|
209
241
|
}
|
|
210
242
|
|
|
211
243
|
private calculatePKCEOpts(pkce?: PKCEOpts) {
|
|
212
|
-
this.
|
|
244
|
+
this._state.pkce = generateMissingPKCEOpts({ ...this._state.pkce, ...pkce });
|
|
213
245
|
}
|
|
214
246
|
|
|
215
247
|
public async acquireAccessToken(opts?: {
|
|
@@ -225,23 +257,23 @@ export class OpenID4VCIClient {
|
|
|
225
257
|
const code = opts?.code ?? (opts?.authorizationResponse ? toAuthorizationResponsePayload(opts.authorizationResponse).code : undefined);
|
|
226
258
|
|
|
227
259
|
if (opts?.codeVerifier) {
|
|
228
|
-
this.
|
|
260
|
+
this._state.pkce.codeVerifier = opts.codeVerifier;
|
|
229
261
|
}
|
|
230
262
|
this.assertIssuerData();
|
|
231
263
|
|
|
232
264
|
if (clientId) {
|
|
233
|
-
this.
|
|
265
|
+
this._state.clientId = clientId;
|
|
234
266
|
}
|
|
235
|
-
if (!this.
|
|
267
|
+
if (!this._state.accessTokenResponse) {
|
|
236
268
|
const accessTokenClient = new AccessTokenClient();
|
|
237
269
|
|
|
238
|
-
if (redirectUri && redirectUri !== this.
|
|
270
|
+
if (redirectUri && redirectUri !== this._state.authorizationRequestOpts?.redirectUri) {
|
|
239
271
|
console.log(
|
|
240
|
-
`Redirect URI mismatch between access-token (${redirectUri}) and authorization request (${this.
|
|
272
|
+
`Redirect URI mismatch between access-token (${redirectUri}) and authorization request (${this._state.authorizationRequestOpts?.redirectUri}). According to the specification that is not allowed.`,
|
|
241
273
|
);
|
|
242
274
|
}
|
|
243
|
-
if (this.
|
|
244
|
-
redirectUri = this.
|
|
275
|
+
if (this._state.authorizationRequestOpts?.redirectUri && !redirectUri) {
|
|
276
|
+
redirectUri = this._state.authorizationRequestOpts.redirectUri;
|
|
245
277
|
}
|
|
246
278
|
|
|
247
279
|
const response = await accessTokenClient.acquireAccessToken({
|
|
@@ -249,7 +281,7 @@ export class OpenID4VCIClient {
|
|
|
249
281
|
metadata: this.endpointMetadata,
|
|
250
282
|
credentialIssuer: this.getIssuer(),
|
|
251
283
|
pin,
|
|
252
|
-
...(!this.
|
|
284
|
+
...(!this._state.pkce.disabled && { codeVerifier: this._state.pkce.codeVerifier }),
|
|
253
285
|
code,
|
|
254
286
|
redirectUri,
|
|
255
287
|
asOpts: { clientId: this.clientId },
|
|
@@ -258,18 +290,18 @@ export class OpenID4VCIClient {
|
|
|
258
290
|
if (response.errorBody) {
|
|
259
291
|
debug(`Access token error:\r\n${response.errorBody}`);
|
|
260
292
|
throw Error(
|
|
261
|
-
`Retrieving an access token from ${this.
|
|
293
|
+
`Retrieving an access token from ${this._state.endpointMetadata?.token_endpoint} for issuer ${this.getIssuer()} failed with status: ${
|
|
262
294
|
response.origResponse.status
|
|
263
295
|
}`,
|
|
264
296
|
);
|
|
265
297
|
} else if (!response.successBody) {
|
|
266
298
|
debug(`Access token error. No success body`);
|
|
267
299
|
throw Error(
|
|
268
|
-
`Retrieving an access token from ${this.
|
|
300
|
+
`Retrieving an access token from ${this._state.endpointMetadata
|
|
269
301
|
?.token_endpoint} for issuer ${this.getIssuer()} failed as there was no success response body`,
|
|
270
302
|
);
|
|
271
303
|
}
|
|
272
|
-
this.
|
|
304
|
+
this._state.accessTokenResponse = response.successBody;
|
|
273
305
|
}
|
|
274
306
|
|
|
275
307
|
return this.accessTokenResponse;
|
|
@@ -302,9 +334,9 @@ export class OpenID4VCIClient {
|
|
|
302
334
|
throw new Error(KID_JWK_X5C_ERROR + `. jwk: ${jwk !== undefined}, kid: ${kid !== undefined}`);
|
|
303
335
|
}
|
|
304
336
|
|
|
305
|
-
if (alg) this.
|
|
306
|
-
if (jwk) this.
|
|
307
|
-
if (kid) this.
|
|
337
|
+
if (alg) this._state.alg = alg;
|
|
338
|
+
if (jwk) this._state.jwk = jwk;
|
|
339
|
+
if (kid) this._state.kid = kid;
|
|
308
340
|
|
|
309
341
|
const requestBuilder = this.credentialOffer
|
|
310
342
|
? CredentialRequestClientBuilder.fromCredentialOffer({
|
|
@@ -358,11 +390,11 @@ export class OpenID4VCIClient {
|
|
|
358
390
|
.withIssuer(this.getIssuer())
|
|
359
391
|
.withAlg(this.alg);
|
|
360
392
|
|
|
361
|
-
if (this.
|
|
362
|
-
proofBuilder.withJWK(this.
|
|
393
|
+
if (this._state.jwk) {
|
|
394
|
+
proofBuilder.withJWK(this._state.jwk);
|
|
363
395
|
}
|
|
364
|
-
if (this.
|
|
365
|
-
proofBuilder.withKid(this.
|
|
396
|
+
if (this._state.kid) {
|
|
397
|
+
proofBuilder.withKid(this._state.kid);
|
|
366
398
|
}
|
|
367
399
|
|
|
368
400
|
if (this.clientId) {
|
|
@@ -380,20 +412,24 @@ export class OpenID4VCIClient {
|
|
|
380
412
|
if (response.errorBody) {
|
|
381
413
|
debug(`Credential request error:\r\n${JSON.stringify(response.errorBody)}`);
|
|
382
414
|
throw Error(
|
|
383
|
-
`Retrieving a credential from ${this.
|
|
415
|
+
`Retrieving a credential from ${this._state.endpointMetadata?.credential_endpoint} for issuer ${this.getIssuer()} failed with status: ${
|
|
384
416
|
response.origResponse.status
|
|
385
417
|
}`,
|
|
386
418
|
);
|
|
387
419
|
} else if (!response.successBody) {
|
|
388
420
|
debug(`Credential request error. No success body`);
|
|
389
421
|
throw Error(
|
|
390
|
-
`Retrieving a credential from ${this.
|
|
422
|
+
`Retrieving a credential from ${this._state.endpointMetadata
|
|
391
423
|
?.credential_endpoint} for issuer ${this.getIssuer()} failed as there was no success response body`,
|
|
392
424
|
);
|
|
393
425
|
}
|
|
394
426
|
return response.successBody;
|
|
395
427
|
}
|
|
396
428
|
|
|
429
|
+
public async exportState(): Promise<string> {
|
|
430
|
+
return JSON.stringify(this._state);
|
|
431
|
+
}
|
|
432
|
+
|
|
397
433
|
// FIXME: We really should convert <v11 to v12 objects first. Right now the logic doesn't map nicely and is brittle.
|
|
398
434
|
// We should resolve IDs to objects first in case of strings.
|
|
399
435
|
// When < v11 convert into a v12 object. When v12 object retain it.
|
|
@@ -437,7 +473,7 @@ export class OpenID4VCIClient {
|
|
|
437
473
|
issuerSupportedFlowTypes(): AuthzFlowType[] {
|
|
438
474
|
return (
|
|
439
475
|
this.credentialOffer?.supportedFlows ??
|
|
440
|
-
(this.
|
|
476
|
+
(this._state.endpointMetadata?.credentialIssuerMetadata?.authorization_endpoint ? [AuthzFlowType.AUTHORIZATION_CODE_FLOW] : [])
|
|
441
477
|
);
|
|
442
478
|
}
|
|
443
479
|
|
|
@@ -446,7 +482,7 @@ export class OpenID4VCIClient {
|
|
|
446
482
|
}
|
|
447
483
|
|
|
448
484
|
get authorizationURL(): string | undefined {
|
|
449
|
-
return this.
|
|
485
|
+
return this._state.authorizationURL;
|
|
450
486
|
}
|
|
451
487
|
|
|
452
488
|
public hasAuthorizationURL(): boolean {
|
|
@@ -454,7 +490,7 @@ export class OpenID4VCIClient {
|
|
|
454
490
|
}
|
|
455
491
|
|
|
456
492
|
get credentialOffer(): CredentialOfferRequestWithBaseUrl | undefined {
|
|
457
|
-
return this.
|
|
493
|
+
return this._state.credentialOffer;
|
|
458
494
|
}
|
|
459
495
|
|
|
460
496
|
public version(): OpenId4VCIVersion {
|
|
@@ -464,46 +500,46 @@ export class OpenID4VCIClient {
|
|
|
464
500
|
public get endpointMetadata(): EndpointMetadataResult {
|
|
465
501
|
this.assertServerMetadata();
|
|
466
502
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
467
|
-
return this.
|
|
503
|
+
return this._state.endpointMetadata!;
|
|
468
504
|
}
|
|
469
505
|
|
|
470
506
|
get kid(): string {
|
|
471
507
|
this.assertIssuerData();
|
|
472
|
-
if (!this.
|
|
508
|
+
if (!this._state.kid) {
|
|
473
509
|
throw new Error('No value for kid is supplied');
|
|
474
510
|
}
|
|
475
|
-
return this.
|
|
511
|
+
return this._state.kid;
|
|
476
512
|
}
|
|
477
513
|
|
|
478
514
|
get alg(): string {
|
|
479
515
|
this.assertIssuerData();
|
|
480
|
-
if (!this.
|
|
516
|
+
if (!this._state.alg) {
|
|
481
517
|
throw new Error('No value for alg is supplied');
|
|
482
518
|
}
|
|
483
|
-
return this.
|
|
519
|
+
return this._state.alg;
|
|
484
520
|
}
|
|
485
521
|
|
|
486
522
|
set clientId(value: string | undefined) {
|
|
487
|
-
this.
|
|
523
|
+
this._state.clientId = value;
|
|
488
524
|
}
|
|
489
525
|
|
|
490
526
|
get clientId(): string | undefined {
|
|
491
|
-
return this.
|
|
527
|
+
return this._state.clientId;
|
|
492
528
|
}
|
|
493
529
|
|
|
494
530
|
public hasAccessTokenResponse(): boolean {
|
|
495
|
-
return !!this.
|
|
531
|
+
return !!this._state.accessTokenResponse;
|
|
496
532
|
}
|
|
497
533
|
|
|
498
534
|
get accessTokenResponse(): AccessTokenResponse {
|
|
499
535
|
this.assertAccessToken();
|
|
500
536
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
501
|
-
return this.
|
|
537
|
+
return this._state.accessTokenResponse!;
|
|
502
538
|
}
|
|
503
539
|
|
|
504
540
|
public getIssuer(): string {
|
|
505
541
|
this.assertIssuerData();
|
|
506
|
-
return this.
|
|
542
|
+
return this._state.credentialIssuer;
|
|
507
543
|
}
|
|
508
544
|
|
|
509
545
|
public getAccessTokenEndpoint(): string {
|
|
@@ -546,36 +582,36 @@ export class OpenID4VCIClient {
|
|
|
546
582
|
}
|
|
547
583
|
|
|
548
584
|
private assertIssuerData(): void {
|
|
549
|
-
if (!this.
|
|
585
|
+
if (!this._state.credentialIssuer) {
|
|
550
586
|
throw Error(`No credential issuer value present`);
|
|
551
|
-
} else if (!this.
|
|
587
|
+
} else if (!this._state.credentialOffer && this._state.endpointMetadata && this.issuerSupportedFlowTypes().length === 0) {
|
|
552
588
|
throw Error(`No issuance initiation or credential offer present`);
|
|
553
589
|
}
|
|
554
590
|
}
|
|
555
591
|
|
|
556
592
|
private assertServerMetadata(): void {
|
|
557
|
-
if (!this.
|
|
593
|
+
if (!this._state.endpointMetadata) {
|
|
558
594
|
throw Error('No server metadata');
|
|
559
595
|
}
|
|
560
596
|
}
|
|
561
597
|
|
|
562
598
|
private assertAccessToken(): void {
|
|
563
|
-
if (!this.
|
|
599
|
+
if (!this._state.accessTokenResponse) {
|
|
564
600
|
throw Error(`No access token present`);
|
|
565
601
|
}
|
|
566
602
|
}
|
|
567
603
|
|
|
568
604
|
private syncAuthorizationRequestOpts(opts?: AuthorizationRequestOpts): AuthorizationRequestOpts {
|
|
569
|
-
let authorizationRequestOpts = { ...this.
|
|
605
|
+
let authorizationRequestOpts = { ...this._state?.authorizationRequestOpts, ...opts } as AuthorizationRequestOpts;
|
|
570
606
|
if (!authorizationRequestOpts) {
|
|
571
607
|
// We only set a redirectUri if no options are provided.
|
|
572
608
|
// Note that this only works for mobile apps, that can handle a code query param on the default openid-credential-offer deeplink.
|
|
573
609
|
// Provide your own options if that is not desired!
|
|
574
610
|
authorizationRequestOpts = { redirectUri: `${DefaultURISchemes.CREDENTIAL_OFFER}://` };
|
|
575
611
|
}
|
|
576
|
-
const clientId = authorizationRequestOpts.clientId ?? this.
|
|
612
|
+
const clientId = authorizationRequestOpts.clientId ?? this._state.clientId;
|
|
577
613
|
// sync clientId
|
|
578
|
-
this.
|
|
614
|
+
this._state.clientId = clientId;
|
|
579
615
|
authorizationRequestOpts.clientId = clientId;
|
|
580
616
|
return authorizationRequestOpts;
|
|
581
617
|
}
|
|
@@ -28,7 +28,7 @@ describe('OpenID4VCIClient should', () => {
|
|
|
28
28
|
it('should successfully construct an authorization request url', async () => {
|
|
29
29
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
30
30
|
// @ts-ignore
|
|
31
|
-
client.
|
|
31
|
+
client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
|
|
32
32
|
const url = await client.createAuthorizationRequestUrl({
|
|
33
33
|
authorizationRequest: {
|
|
34
34
|
scope: 'openid TestCredential',
|
|
@@ -54,7 +54,7 @@ describe('OpenID4VCIClient should', () => {
|
|
|
54
54
|
it("injects 'openid' as the first scope if not provided", async () => {
|
|
55
55
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
56
56
|
// @ts-ignore
|
|
57
|
-
client.
|
|
57
|
+
client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
|
|
58
58
|
|
|
59
59
|
const url = await client.createAuthorizationRequestUrl({
|
|
60
60
|
pkce: {
|
|
@@ -85,7 +85,7 @@ describe('OpenID4VCIClient should', () => {
|
|
|
85
85
|
|
|
86
86
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
87
87
|
// @ts-ignore
|
|
88
|
-
client.
|
|
88
|
+
client._state.endpointMetadata = {
|
|
89
89
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
90
90
|
// @ts-ignore
|
|
91
91
|
credentialIssuerMetadata: {
|
|
@@ -93,7 +93,7 @@ describe('OpenID4VCIClient should', () => {
|
|
|
93
93
|
token_endpoint: `${MOCK_URL}/token`,
|
|
94
94
|
},
|
|
95
95
|
};
|
|
96
|
-
// client.
|
|
96
|
+
// client._state.endpointMetadata.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
|
|
97
97
|
|
|
98
98
|
await expect(
|
|
99
99
|
client.createAuthorizationRequestUrl({
|
|
@@ -110,7 +110,7 @@ describe('OpenID4VCIClient should', () => {
|
|
|
110
110
|
it('create an authorization request url with authorization_details array property', async () => {
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
112
112
|
// @ts-ignore
|
|
113
|
-
client.
|
|
113
|
+
client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
|
|
114
114
|
|
|
115
115
|
await expect(
|
|
116
116
|
client.createAuthorizationRequestUrl({
|
|
@@ -146,7 +146,7 @@ describe('OpenID4VCIClient should', () => {
|
|
|
146
146
|
it('create an authorization request url with authorization_details object property', async () => {
|
|
147
147
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
148
148
|
// @ts-ignore
|
|
149
|
-
client.
|
|
149
|
+
client._state.endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
|
|
150
150
|
|
|
151
151
|
await expect(
|
|
152
152
|
client.createAuthorizationRequestUrl({
|
|
@@ -173,7 +173,7 @@ describe('OpenID4VCIClient should', () => {
|
|
|
173
173
|
it('create an authorization request url with authorization_details and scope', async () => {
|
|
174
174
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
175
175
|
// @ts-ignore
|
|
176
|
-
client.
|
|
176
|
+
client._state.endpointMetadata.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
|
|
177
177
|
|
|
178
178
|
await expect(
|
|
179
179
|
client.createAuthorizationRequestUrl({
|
|
@@ -10,7 +10,7 @@ import { v4 } from 'uuid';
|
|
|
10
10
|
|
|
11
11
|
import { OpenID4VCIClient } from '..';
|
|
12
12
|
|
|
13
|
-
export const UNIT_TEST_TIMEOUT =
|
|
13
|
+
export const UNIT_TEST_TIMEOUT = 60000;
|
|
14
14
|
|
|
15
15
|
const ISSUER_URL = 'https://ssi.sphereon.com/pf3';
|
|
16
16
|
|
|
@@ -66,7 +66,7 @@ describe('OID4VCI-Client using Sphereon issuer should', () => {
|
|
|
66
66
|
},
|
|
67
67
|
UNIT_TEST_TIMEOUT,
|
|
68
68
|
);
|
|
69
|
-
|
|
69
|
+
xit(
|
|
70
70
|
'succeed in a full flow with the client using OpenID4VCI version 11 and jwt_vc_json',
|
|
71
71
|
async () => {
|
|
72
72
|
await test('jwt_vc_json');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/oid4vci-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "OpenID for Verifiable Credential Issuance (OpenID4VCI) client",
|
|
5
5
|
"source": "lib/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"build": "tsc"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@sphereon/oid4vci-common": "0.
|
|
18
|
+
"@sphereon/oid4vci-common": "0.9.0",
|
|
19
19
|
"@sphereon/ssi-types": "^0.18.1",
|
|
20
20
|
"cross-fetch": "^3.1.8",
|
|
21
21
|
"debug": "^4.3.4"
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"OIDC4VCI",
|
|
70
70
|
"OID4VCI"
|
|
71
71
|
],
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "eb17a5cae215b854b189e5f3d3b2e2146f7f4e16"
|
|
73
73
|
}
|