@sphereon/oid4vci-client 0.6.1-next.8 → 0.7.1-next.7

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.
@@ -1,16 +1,16 @@
1
- import { CredentialIssuerMetadata, CredentialOfferPayload, CredentialOfferRequestWithBaseUrl, EndpointMetadata, OpenIDResponse, WellKnownEndpoints } from '@sphereon/oid4vci-common';
1
+ import { CredentialIssuerMetadata, CredentialOfferPayload, CredentialOfferRequestWithBaseUrl, EndpointMetadataResult, OpenIDResponse, WellKnownEndpoints } from '@sphereon/oid4vci-common';
2
2
  export declare class MetadataClient {
3
3
  /**
4
4
  * Retrieve metadata using the Initiation obtained from a previous step
5
5
  *
6
6
  * @param credentialOffer
7
7
  */
8
- static retrieveAllMetadataFromCredentialOffer(credentialOffer: CredentialOfferRequestWithBaseUrl): Promise<EndpointMetadata>;
8
+ static retrieveAllMetadataFromCredentialOffer(credentialOffer: CredentialOfferRequestWithBaseUrl): Promise<EndpointMetadataResult>;
9
9
  /**
10
10
  * Retrieve the metada using the initiation request obtained from a previous step
11
11
  * @param request
12
12
  */
13
- static retrieveAllMetadataFromCredentialOfferRequest(request: CredentialOfferPayload): Promise<EndpointMetadata>;
13
+ static retrieveAllMetadataFromCredentialOfferRequest(request: CredentialOfferPayload): Promise<EndpointMetadataResult>;
14
14
  /**
15
15
  * Retrieve all metadata from an issuer
16
16
  * @param issuer The issuer URL
@@ -18,13 +18,15 @@ export declare class MetadataClient {
18
18
  */
19
19
  static retrieveAllMetadata(issuer: string, opts?: {
20
20
  errorOnNotFound: boolean;
21
- }): Promise<EndpointMetadata>;
21
+ }): Promise<EndpointMetadataResult>;
22
22
  /**
23
23
  * Retrieve only the OID4VCI metadata for the issuer. So no OIDC/OAuth2 metadata
24
24
  *
25
25
  * @param issuerHost The issuer hostname
26
26
  */
27
- static retrieveOpenID4VCIServerMetadata(issuerHost: string): Promise<OpenIDResponse<CredentialIssuerMetadata> | undefined>;
27
+ static retrieveOpenID4VCIServerMetadata(issuerHost: string, opts?: {
28
+ errorOnNotFound?: boolean;
29
+ }): Promise<OpenIDResponse<CredentialIssuerMetadata> | undefined>;
28
30
  /**
29
31
  * Allows to retrieve information from a well-known location
30
32
  *
@@ -1 +1 @@
1
- {"version":3,"file":"MetadataClient.d.ts","sourceRoot":"","sources":["../lib/MetadataClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,iCAAiC,EACjC,gBAAgB,EAIhB,cAAc,EACd,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAOlC,qBAAa,cAAc;IACzB;;;;OAIG;WACiB,sCAAsC,CAAC,eAAe,EAAE,iCAAiC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIzI;;;OAGG;WACiB,6CAA6C,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAO7H;;;;OAIG;WACiB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,eAAe,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwEvH;;;;OAIG;WACiB,gCAAgC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,wBAAwB,CAAC,GAAG,SAAS,CAAC;IAKvI;;;;;;OAMG;WACiB,iBAAiB,CAAC,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,kBAAkB,EAChC,IAAI,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,GACnC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CAU9B"}
1
+ {"version":3,"file":"MetadataClient.d.ts","sourceRoot":"","sources":["../lib/MetadataClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,wBAAwB,EACxB,sBAAsB,EACtB,iCAAiC,EACjC,sBAAsB,EAEtB,cAAc,EACd,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAOlC,qBAAa,cAAc;IACzB;;;;OAIG;WACiB,sCAAsC,CAAC,eAAe,EAAE,iCAAiC,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAI/I;;;OAGG;WACiB,6CAA6C,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAQnI;;;;OAIG;WACiB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,eAAe,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAgH7H;;;;OAIG;WACiB,gCAAgC,CAClD,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE;QACL,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,GACA,OAAO,CAAC,cAAc,CAAC,wBAAwB,CAAC,GAAG,SAAS,CAAC;IAMhE;;;;;;OAMG;WACiB,iBAAiB,CAAC,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,kBAAkB,EAChC,IAAI,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,GACnC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CAU9B"}
@@ -34,8 +34,9 @@ class MetadataClient {
34
34
  */
35
35
  static retrieveAllMetadataFromCredentialOfferRequest(request) {
36
36
  return __awaiter(this, void 0, void 0, function* () {
37
- if ((0, oid4vci_common_1.getIssuerFromCredentialOfferPayload)(request)) {
38
- return MetadataClient.retrieveAllMetadata((0, oid4vci_common_1.getIssuerFromCredentialOfferPayload)(request));
37
+ const issuer = (0, oid4vci_common_1.getIssuerFromCredentialOfferPayload)(request);
38
+ if (issuer) {
39
+ return MetadataClient.retrieveAllMetadata(issuer);
39
40
  }
40
41
  throw new Error("can't retrieve metadata from CredentialOfferRequest. No issuer field is present");
41
42
  });
@@ -46,70 +47,110 @@ class MetadataClient {
46
47
  * @param opts
47
48
  */
48
49
  static retrieveAllMetadata(issuer, opts) {
49
- var _a;
50
50
  return __awaiter(this, void 0, void 0, function* () {
51
51
  let token_endpoint;
52
52
  let credential_endpoint;
53
- const response = yield MetadataClient.retrieveOpenID4VCIServerMetadata(issuer);
54
- let issuerMetadata = response === null || response === void 0 ? void 0 : response.successBody;
55
- if (issuerMetadata) {
56
- debug(`Issuer ${issuer} OID4VCI well-known server metadata\r\n${issuerMetadata}`);
57
- credential_endpoint = issuerMetadata.credential_endpoint;
58
- token_endpoint = issuerMetadata.token_endpoint;
59
- if (!token_endpoint && issuerMetadata.authorization_server) {
60
- debug(`Issuer ${issuer} OID4VCI metadata has separate authorization_server ${issuerMetadata.authorization_server} that contains the token endpoint`);
61
- // Crossword uses this to separate the AS metadata. We fail when not found, since we now have no way of getting the token endpoint
62
- const response = yield this.retrieveWellknown(issuerMetadata.authorization_server, oid4vci_common_1.WellKnownEndpoints.OAUTH_AS, {
63
- errorOnNotFound: true,
64
- });
65
- token_endpoint = (_a = response.successBody) === null || _a === void 0 ? void 0 : _a.token_endpoint;
53
+ let authorization_endpoint;
54
+ let authorizationServerType = 'OID4VCI';
55
+ let authorization_server = issuer;
56
+ const oid4vciResponse = yield MetadataClient.retrieveOpenID4VCIServerMetadata(issuer, { errorOnNotFound: false }); // We will handle errors later, given we will also try other metadata locations
57
+ let credentialIssuerMetadata = oid4vciResponse === null || oid4vciResponse === void 0 ? void 0 : oid4vciResponse.successBody;
58
+ if (credentialIssuerMetadata) {
59
+ debug(`Issuer ${issuer} OID4VCI well-known server metadata\r\n${JSON.stringify(credentialIssuerMetadata)}`);
60
+ credential_endpoint = credentialIssuerMetadata.credential_endpoint;
61
+ if (credentialIssuerMetadata.token_endpoint) {
62
+ token_endpoint = credentialIssuerMetadata.token_endpoint;
66
63
  }
64
+ if (credentialIssuerMetadata.authorization_server) {
65
+ authorization_server = credentialIssuerMetadata.authorization_server;
66
+ }
67
+ if (credentialIssuerMetadata.authorization_endpoint) {
68
+ authorization_endpoint = credentialIssuerMetadata.authorization_endpoint;
69
+ }
70
+ }
71
+ // No specific OID4VCI endpoint. Either can be an OAuth2 AS or an OIDC IDP. Let's start with OIDC first
72
+ let response = yield MetadataClient.retrieveWellknown(authorization_server, oid4vci_common_1.WellKnownEndpoints.OPENID_CONFIGURATION, {
73
+ errorOnNotFound: false,
74
+ });
75
+ let authMetadata = response.successBody;
76
+ if (authMetadata) {
77
+ debug(`Issuer ${issuer} has OpenID Connect Server metadata in well-known location`);
78
+ authorizationServerType = 'OIDC';
67
79
  }
68
80
  else {
69
- // No specific OID4VCI endpoint. Either can be an OAuth2 AS or an OpenID IDP. Let's start with OIDC first
70
- let response = yield MetadataClient.retrieveWellknown(issuer, oid4vci_common_1.WellKnownEndpoints.OPENID_CONFIGURATION, {
71
- errorOnNotFound: false,
72
- });
73
- let asConfig = response.successBody;
74
- if (asConfig) {
75
- debug(`Issuer ${issuer} has OpenID Connect Server metadata in well-known location`);
81
+ // Now let's do OAuth2
82
+ response = yield MetadataClient.retrieveWellknown(authorization_server, oid4vci_common_1.WellKnownEndpoints.OAUTH_AS, { errorOnNotFound: false });
83
+ authMetadata = response.successBody;
84
+ }
85
+ if (!authMetadata) {
86
+ // We will always throw an error, no matter whether the user provided the option not to, because this is bad.
87
+ if (issuer !== authorization_server) {
88
+ throw Error(`Issuer ${issuer} provided a separate authorization server ${authorization_server}, but that server did not provide metadata`);
76
89
  }
77
- else {
78
- // Now oAuth2
79
- response = yield MetadataClient.retrieveWellknown(issuer, oid4vci_common_1.WellKnownEndpoints.OAUTH_AS, { errorOnNotFound: false });
80
- asConfig = response.successBody;
90
+ }
91
+ else {
92
+ if (!authorizationServerType) {
93
+ authorizationServerType = 'OAuth 2.0';
81
94
  }
82
- if (asConfig) {
83
- debug(`Issuer ${issuer} has oAuth2 Server metadata in well-known location`);
84
- issuerMetadata = asConfig;
85
- credential_endpoint = issuerMetadata.credential_endpoint;
86
- token_endpoint = issuerMetadata.token_endpoint;
95
+ debug(`Issuer ${issuer} has ${authorizationServerType} Server metadata in well-known location`);
96
+ if (!authMetadata.authorization_endpoint) {
97
+ throw Error(`Authorization Sever ${authorization_server} did not provide an authorization_endpoint`);
98
+ }
99
+ else if (authorization_endpoint && authMetadata.authorization_endpoint !== authorization_endpoint) {
100
+ throw Error(`Credential issuer has a different authorization_endpoint (${authorization_endpoint}) from the Authorization Server (${authMetadata.authorization_endpoint})`);
101
+ }
102
+ authorization_endpoint = authMetadata.authorization_endpoint;
103
+ if (!authMetadata.token_endpoint) {
104
+ throw Error(`Authorization Sever ${authorization_server} did not provide a token_endpoint`);
105
+ }
106
+ else if (token_endpoint && authMetadata.token_endpoint !== token_endpoint) {
107
+ throw Error(`Credential issuer has a different token_endpoint (${token_endpoint}) from the Authorization Server (${authMetadata.token_endpoint})`);
108
+ }
109
+ token_endpoint = authMetadata.token_endpoint;
110
+ if (authMetadata.credential_endpoint) {
111
+ if (credential_endpoint && authMetadata.credential_endpoint !== credential_endpoint) {
112
+ debug(`Credential issuer has a different credential_endpoint (${credential_endpoint}) from the Authorization Server (${authMetadata.token_endpoint}). Will use the issuer value`);
113
+ }
114
+ else {
115
+ credential_endpoint = authMetadata.credential_endpoint;
116
+ }
87
117
  }
88
118
  }
119
+ if (!authorization_endpoint) {
120
+ debug(`Issuer ${issuer} does not expose authorization_endpoint, so only pre-auth will be supported`);
121
+ }
89
122
  if (!token_endpoint) {
90
123
  debug(`Issuer ${issuer} does not have a token_endpoint listed in well-known locations!`);
91
124
  if (opts === null || opts === void 0 ? void 0 : opts.errorOnNotFound) {
92
- throw new Error(`Could not deduce the token endpoint for ${issuer}`);
125
+ throw Error(`Could not deduce the token_endpoint for ${issuer}`);
93
126
  }
94
127
  else {
95
- token_endpoint = `${issuer}${issuer.endsWith('/') ? '' : '/'}token`;
128
+ token_endpoint = `${issuer}${issuer.endsWith('/') ? 'token' : '/token'}`;
96
129
  }
97
130
  }
98
131
  if (!credential_endpoint) {
99
132
  debug(`Issuer ${issuer} does not have a credential_endpoint listed in well-known locations!`);
100
133
  if (opts === null || opts === void 0 ? void 0 : opts.errorOnNotFound) {
101
- throw new Error(`Could not deduce the credential endpoint for ${issuer}`);
134
+ throw Error(`Could not deduce the credential endpoint for ${issuer}`);
102
135
  }
103
136
  else {
104
- credential_endpoint = `${issuer}${issuer.endsWith('/') ? '' : '/'}credential`;
137
+ credential_endpoint = `${issuer}${issuer.endsWith('/') ? 'credential' : '/credential'}`;
105
138
  }
106
139
  }
140
+ if (!credentialIssuerMetadata && authMetadata) {
141
+ // Apparently everything worked out and the issuer is exposing everything in oAuth2/OIDC well-knowns. Spec is vague about this situation, but we can support it
142
+ credentialIssuerMetadata = authMetadata;
143
+ }
107
144
  debug(`Issuer ${issuer} token endpoint ${token_endpoint}, credential endpoint ${credential_endpoint}`);
108
145
  return {
109
146
  issuer,
110
147
  token_endpoint,
111
148
  credential_endpoint,
112
- issuerMetadata,
149
+ authorization_server,
150
+ authorization_endpoint,
151
+ authorizationServerType,
152
+ credentialIssuerMetadata: credentialIssuerMetadata,
153
+ authorizationServerMetadata: authMetadata,
113
154
  };
114
155
  });
115
156
  }
@@ -118,10 +159,11 @@ class MetadataClient {
118
159
  *
119
160
  * @param issuerHost The issuer hostname
120
161
  */
121
- static retrieveOpenID4VCIServerMetadata(issuerHost) {
162
+ static retrieveOpenID4VCIServerMetadata(issuerHost, opts) {
122
163
  return __awaiter(this, void 0, void 0, function* () {
123
- // Since the server metadata endpoint is optional we are not going to throw an error.
124
- return MetadataClient.retrieveWellknown(issuerHost, oid4vci_common_1.WellKnownEndpoints.OPENID4VCI_ISSUER, { errorOnNotFound: false });
164
+ return MetadataClient.retrieveWellknown(issuerHost, oid4vci_common_1.WellKnownEndpoints.OPENID4VCI_ISSUER, {
165
+ errorOnNotFound: (opts === null || opts === void 0 ? void 0 : opts.errorOnNotFound) === undefined ? true : opts.errorOnNotFound,
166
+ });
125
167
  });
126
168
  }
127
169
  /**
@@ -136,9 +178,9 @@ class MetadataClient {
136
178
  const result = yield (0, functions_1.getJson)(`${host.endsWith('/') ? host.slice(0, -1) : host}${endpointType}`, {
137
179
  exceptionOnHttpErrorStatus: opts === null || opts === void 0 ? void 0 : opts.errorOnNotFound,
138
180
  });
139
- if (result.origResponse.status === 404) {
181
+ if (result.origResponse.status >= 400) {
140
182
  // We only get here when error on not found is false
141
- debug(`host ${host} with endpoint type ${endpointType} was not found (404)`);
183
+ debug(`host ${host} with endpoint type ${endpointType} status: ${result.origResponse.status}, ${result.origResponse.statusText}`);
142
184
  }
143
185
  return result;
144
186
  });
@@ -1 +1 @@
1
- {"version":3,"file":"MetadataClient.js","sourceRoot":"","sources":["../lib/MetadataClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAUkC;AAClC,kDAA0B;AAE1B,2CAAsC;AAEtC,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,2BAA2B,CAAC,CAAC;AAEjD,MAAa,cAAc;IACzB;;;;OAIG;IACI,MAAM,CAAO,sCAAsC,CAAC,eAAkD;;YAC3G,OAAO,cAAc,CAAC,6CAA6C,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;QACxG,CAAC;KAAA;IAED;;;OAGG;IACI,MAAM,CAAO,6CAA6C,CAAC,OAA+B;;YAC/F,IAAI,IAAA,oDAAmC,EAAC,OAAO,CAAC,EAAE;gBAChD,OAAO,cAAc,CAAC,mBAAmB,CAAC,IAAA,oDAAmC,EAAC,OAAO,CAAW,CAAC,CAAC;aACnG;YACD,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;QACrG,CAAC;KAAA;IAED;;;;OAIG;IACI,MAAM,CAAO,mBAAmB,CAAC,MAAc,EAAE,IAAmC;;;YACzF,IAAI,cAAc,CAAC;YACnB,IAAI,mBAAmB,CAAC;YACxB,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,gCAAgC,CAAC,MAAM,CAAC,CAAC;YAC/E,IAAI,cAAc,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,C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,uBAAuB;gBACvB,wBAAwB,EAAE,wBAAwB;gBAClD,2BAA2B,EAAE,YAAY;aAC1C,CAAC;QACJ,CAAC;KAAA;IAED;;;;OAIG;IACI,MAAM,CAAO,gCAAgC,CAClD,UAAkB,EAClB,IAEC;;YAED,OAAO,cAAc,CAAC,iBAAiB,CAAC,UAAU,EAAE,mCAAkB,CAAC,iBAAiB,EAAE;gBACxF,eAAe,EAAE,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,eAAe,MAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe;aACnF,CAAC,CAAC;QACL,CAAC;KAAA;IAED;;;;;;OAMG;IACI,MAAM,CAAO,iBAAiB,CACnC,IAAY,EACZ,YAAgC,EAChC,IAAoC;;YAEpC,MAAM,MAAM,GAAsB,MAAM,IAAA,mBAAO,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;gBACjH,0BAA0B,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,eAAe;aAClD,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,IAAI,GAAG,EAAE;gBACrC,oDAAoD;gBACpD,KAAK,CAAC,QAAQ,IAAI,uBAAuB,YAAY,YAAY,MAAM,CAAC,YAAY,CAAC,MAAM,KAAK,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC;aACnI;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF;AAhLD,wCAgLC"}
@@ -1,4 +1,4 @@
1
- import { AccessTokenResponse, Alg, AuthzFlowType, CodeChallengeMethod, CredentialOfferRequestWithBaseUrl, CredentialResponse, CredentialSupported, EndpointMetadata, OID4VCICredentialFormat, OpenId4VCIVersion, OpenIDResponse, ProofOfPossessionCallbacks, PushedAuthorizationResponse } from '@sphereon/oid4vci-common';
1
+ import { AccessTokenResponse, Alg, AuthzFlowType, CodeChallengeMethod, CredentialOfferRequestWithBaseUrl, CredentialResponse, CredentialSupported, EndpointMetadata, EndpointMetadataResult, OID4VCICredentialFormat, OpenId4VCIVersion, OpenIDResponse, ProofOfPossessionCallbacks, PushedAuthorizationResponse } from '@sphereon/oid4vci-common';
2
2
  import { CredentialFormat } from '@sphereon/ssi-types';
3
3
  interface AuthDetails {
4
4
  type: 'openid_credential' | string;
@@ -59,7 +59,7 @@ export declare class OpenID4VCIClient {
59
59
  issuerSupportedFlowTypes(): AuthzFlowType[];
60
60
  get credentialOffer(): CredentialOfferRequestWithBaseUrl;
61
61
  version(): OpenId4VCIVersion;
62
- get endpointMetadata(): EndpointMetadata;
62
+ get endpointMetadata(): EndpointMetadataResult;
63
63
  get kid(): string;
64
64
  get alg(): string;
65
65
  get clientId(): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"OpenID4VCIClient.d.ts","sourceRoot":"","sources":["../lib/OpenID4VCIClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,GAAG,EAEH,aAAa,EACb,mBAAmB,EAEnB,iCAAiC,EACjC,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,0BAA0B,EAC1B,2BAA2B,EAE5B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAYvD,UAAU,WAAW;IACnB,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;IAE9C,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AAED,UAAU,eAAe;IACvB,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,9 +59,12 @@ class OpenID4VCIClient {
59
59
  if (!scope && !authorizationDetails) {
60
60
  throw Error('Please provide a scope or authorization_details');
61
61
  }
62
- // todo: handling this because of the support for v1_0-08
63
- if (this._endpointMetadata && this._endpointMetadata.issuerMetadata && 'authorization_endpoint' in this._endpointMetadata.issuerMetadata) {
64
- this._endpointMetadata.authorization_endpoint = this._endpointMetadata.issuerMetadata.authorization_endpoint;
62
+ // todo: Probably can go with current logic in MetadataClient who will always set the authorization_endpoint when found
63
+ // handling this because of the support for v1_0-08
64
+ if (this._endpointMetadata &&
65
+ this._endpointMetadata.credentialIssuerMetadata &&
66
+ 'authorization_endpoint' in this._endpointMetadata.credentialIssuerMetadata) {
67
+ this._endpointMetadata.authorization_endpoint = this._endpointMetadata.credentialIssuerMetadata.authorization_endpoint;
65
68
  }
66
69
  if (!((_a = this._endpointMetadata) === null || _a === void 0 ? void 0 : _a.authorization_endpoint)) {
67
70
  throw Error('Server metadata does not contain authorization endpoint');
@@ -98,12 +101,12 @@ class OpenID4VCIClient {
98
101
  // Note that the presence of pushed_authorization_request_endpoint is sufficient for a client to determine that it may use the PAR flow.
99
102
  // What happens if it doesn't ???
100
103
  // let parEndpoint: string
101
- if (!((_a = this._endpointMetadata) === null || _a === void 0 ? void 0 : _a.issuerMetadata) ||
102
- !('pushed_authorization_request_endpoint' in this._endpointMetadata.issuerMetadata) ||
103
- typeof this._endpointMetadata.issuerMetadata.pushed_authorization_request_endpoint !== 'string') {
104
+ if (!((_a = this._endpointMetadata) === null || _a === void 0 ? void 0 : _a.credentialIssuerMetadata) ||
105
+ !('pushed_authorization_request_endpoint' in this._endpointMetadata.credentialIssuerMetadata) ||
106
+ typeof this._endpointMetadata.credentialIssuerMetadata.pushed_authorization_request_endpoint !== 'string') {
104
107
  throw Error('Server metadata does not contain pushed authorization request endpoint');
105
108
  }
106
- const parEndpoint = this._endpointMetadata.issuerMetadata.pushed_authorization_request_endpoint;
109
+ const parEndpoint = this._endpointMetadata.credentialIssuerMetadata.pushed_authorization_request_endpoint;
107
110
  // add 'openid' scope if not present
108
111
  if (scope && !scope.includes('openid')) {
109
112
  scope = `openid ${scope}`;
@@ -134,7 +137,8 @@ class OpenID4VCIClient {
134
137
  }
135
138
  handleLocations(authorizationDetails) {
136
139
  var _a;
137
- if (authorizationDetails && (((_a = this.endpointMetadata.issuerMetadata) === null || _a === void 0 ? void 0 : _a.authorization_server) || this.endpointMetadata.authorization_endpoint)) {
140
+ if (authorizationDetails &&
141
+ (((_a = this.endpointMetadata.credentialIssuerMetadata) === null || _a === void 0 ? void 0 : _a.authorization_server) || this.endpointMetadata.authorization_endpoint)) {
138
142
  if (authorizationDetails.locations) {
139
143
  if (Array.isArray(authorizationDetails.locations)) {
140
144
  authorizationDetails.locations.push(this.endpointMetadata.issuer);
@@ -195,8 +199,8 @@ class OpenID4VCIClient {
195
199
  metadata: this.endpointMetadata,
196
200
  });
197
201
  requestBuilder.withTokenFromResponse(this.accessTokenResponse);
198
- if ((_a = this.endpointMetadata) === null || _a === void 0 ? void 0 : _a.issuerMetadata) {
199
- const metadata = this.endpointMetadata.issuerMetadata;
202
+ if ((_a = this.endpointMetadata) === null || _a === void 0 ? void 0 : _a.credentialIssuerMetadata) {
203
+ const metadata = this.endpointMetadata.credentialIssuerMetadata;
200
204
  const types = Array.isArray(credentialTypes) ? credentialTypes : [credentialTypes];
201
205
  if (metadata.credentials_supported && Array.isArray(metadata.credentials_supported)) {
202
206
  for (const type of types) {
@@ -255,7 +259,7 @@ class OpenID4VCIClient {
255
259
  }
256
260
  getCredentialsSupported(restrictToInitiationTypes, supportedType) {
257
261
  return (0, IssuerMetadataUtils_1.getSupportedCredentials)({
258
- issuerMetadata: this.endpointMetadata.issuerMetadata,
262
+ issuerMetadata: this.endpointMetadata.credentialIssuerMetadata,
259
263
  version: this.version(),
260
264
  supportedType,
261
265
  credentialTypes: restrictToInitiationTypes ? this.getCredentialTypes() : undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"OpenID4VCI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BAAoB;QAC1B,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC3B,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;SACnC;IACH,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC9B,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAC;SACxC;IACH,CAAC;CACF;AA/dD,4CA+dC"}
@@ -1,11 +1,11 @@
1
1
  import {
2
+ AuthorizationServerMetadata,
3
+ AuthorizationServerType,
2
4
  CredentialIssuerMetadata,
3
5
  CredentialOfferPayload,
4
6
  CredentialOfferRequestWithBaseUrl,
5
- EndpointMetadata,
7
+ EndpointMetadataResult,
6
8
  getIssuerFromCredentialOfferPayload,
7
- OAuth2ASMetadata,
8
- Oauth2ASWithOID4VCIMetadata,
9
9
  OpenIDResponse,
10
10
  WellKnownEndpoints,
11
11
  } from '@sphereon/oid4vci-common';
@@ -21,7 +21,7 @@ export class MetadataClient {
21
21
  *
22
22
  * @param credentialOffer
23
23
  */
24
- public static async retrieveAllMetadataFromCredentialOffer(credentialOffer: CredentialOfferRequestWithBaseUrl): Promise<EndpointMetadata> {
24
+ public static async retrieveAllMetadataFromCredentialOffer(credentialOffer: CredentialOfferRequestWithBaseUrl): Promise<EndpointMetadataResult> {
25
25
  return MetadataClient.retrieveAllMetadataFromCredentialOfferRequest(credentialOffer.credential_offer);
26
26
  }
27
27
 
@@ -29,9 +29,10 @@ export class MetadataClient {
29
29
  * Retrieve the metada using the initiation request obtained from a previous step
30
30
  * @param request
31
31
  */
32
- public static async retrieveAllMetadataFromCredentialOfferRequest(request: CredentialOfferPayload): Promise<EndpointMetadata> {
33
- if (getIssuerFromCredentialOfferPayload(request)) {
34
- return MetadataClient.retrieveAllMetadata(getIssuerFromCredentialOfferPayload(request) as string);
32
+ public static async retrieveAllMetadataFromCredentialOfferRequest(request: CredentialOfferPayload): Promise<EndpointMetadataResult> {
33
+ const issuer = getIssuerFromCredentialOfferPayload(request);
34
+ if (issuer) {
35
+ return MetadataClient.retrieveAllMetadata(issuer);
35
36
  }
36
37
  throw new Error("can't retrieve metadata from CredentialOfferRequest. No issuer field is present");
37
38
  }
@@ -41,75 +42,115 @@ export class MetadataClient {
41
42
  * @param issuer The issuer URL
42
43
  * @param opts
43
44
  */
44
- public static async retrieveAllMetadata(issuer: string, opts?: { errorOnNotFound: boolean }): Promise<EndpointMetadata> {
45
- let token_endpoint;
46
- let credential_endpoint;
47
- const response = await MetadataClient.retrieveOpenID4VCIServerMetadata(issuer);
48
- let issuerMetadata = response?.successBody;
49
- if (issuerMetadata) {
50
- debug(`Issuer ${issuer} OID4VCI well-known server metadata\r\n${issuerMetadata}`);
51
- credential_endpoint = issuerMetadata.credential_endpoint;
52
- token_endpoint = issuerMetadata.token_endpoint;
53
- if (!token_endpoint && issuerMetadata.authorization_server) {
54
- debug(
55
- `Issuer ${issuer} OID4VCI metadata has separate authorization_server ${issuerMetadata.authorization_server} that contains the token endpoint`,
56
- );
57
- // Crossword uses this to separate the AS metadata. We fail when not found, since we now have no way of getting the token endpoint
58
- const response: OpenIDResponse<OAuth2ASMetadata> = await this.retrieveWellknown(
59
- issuerMetadata.authorization_server,
60
- WellKnownEndpoints.OAUTH_AS,
61
- {
62
- errorOnNotFound: true,
63
- },
64
- );
65
- token_endpoint = response.successBody?.token_endpoint;
45
+ public static async retrieveAllMetadata(issuer: string, opts?: { errorOnNotFound: boolean }): Promise<EndpointMetadataResult> {
46
+ let token_endpoint: string | undefined;
47
+ let credential_endpoint: string | undefined;
48
+ let authorization_endpoint: string | undefined;
49
+ let authorizationServerType: AuthorizationServerType = 'OID4VCI';
50
+ let authorization_server: string = issuer;
51
+ const oid4vciResponse = await MetadataClient.retrieveOpenID4VCIServerMetadata(issuer, { errorOnNotFound: false }); // We will handle errors later, given we will also try other metadata locations
52
+ let credentialIssuerMetadata = oid4vciResponse?.successBody;
53
+ if (credentialIssuerMetadata) {
54
+ debug(`Issuer ${issuer} OID4VCI well-known server metadata\r\n${JSON.stringify(credentialIssuerMetadata)}`);
55
+ credential_endpoint = credentialIssuerMetadata.credential_endpoint;
56
+ if (credentialIssuerMetadata.token_endpoint) {
57
+ token_endpoint = credentialIssuerMetadata.token_endpoint;
58
+ }
59
+ if (credentialIssuerMetadata.authorization_server) {
60
+ authorization_server = credentialIssuerMetadata.authorization_server;
66
61
  }
62
+ if (credentialIssuerMetadata.authorization_endpoint) {
63
+ authorization_endpoint = credentialIssuerMetadata.authorization_endpoint;
64
+ }
65
+ }
66
+ // No specific OID4VCI endpoint. Either can be an OAuth2 AS or an OIDC IDP. Let's start with OIDC first
67
+ let response: OpenIDResponse<AuthorizationServerMetadata> = await MetadataClient.retrieveWellknown(
68
+ authorization_server,
69
+ WellKnownEndpoints.OPENID_CONFIGURATION,
70
+ {
71
+ errorOnNotFound: false,
72
+ },
73
+ );
74
+ let authMetadata = response.successBody;
75
+ if (authMetadata) {
76
+ debug(`Issuer ${issuer} has OpenID Connect Server metadata in well-known location`);
77
+ authorizationServerType = 'OIDC';
67
78
  } else {
68
- // No specific OID4VCI endpoint. Either can be an OAuth2 AS or an OpenID IDP. Let's start with OIDC first
69
- let response: OpenIDResponse<Oauth2ASWithOID4VCIMetadata> = await MetadataClient.retrieveWellknown(
70
- issuer,
71
- WellKnownEndpoints.OPENID_CONFIGURATION,
72
- {
73
- errorOnNotFound: false,
74
- },
75
- );
76
- let asConfig = response.successBody;
77
- if (asConfig) {
78
- debug(`Issuer ${issuer} has OpenID Connect Server metadata in well-known location`);
79
- } else {
80
- // Now oAuth2
81
- response = await MetadataClient.retrieveWellknown(issuer, WellKnownEndpoints.OAUTH_AS, { errorOnNotFound: false });
82
- asConfig = response.successBody;
79
+ // Now let's do OAuth2
80
+ response = await MetadataClient.retrieveWellknown(authorization_server, WellKnownEndpoints.OAUTH_AS, { errorOnNotFound: false });
81
+ authMetadata = response.successBody;
82
+ }
83
+ if (!authMetadata) {
84
+ // We will always throw an error, no matter whether the user provided the option not to, because this is bad.
85
+ if (issuer !== authorization_server) {
86
+ throw Error(`Issuer ${issuer} provided a separate authorization server ${authorization_server}, but that server did not provide metadata`);
87
+ }
88
+ } else {
89
+ if (!authorizationServerType) {
90
+ authorizationServerType = 'OAuth 2.0';
83
91
  }
84
- if (asConfig) {
85
- debug(`Issuer ${issuer} has oAuth2 Server metadata in well-known location`);
86
- issuerMetadata = asConfig;
87
- credential_endpoint = issuerMetadata.credential_endpoint;
88
- token_endpoint = issuerMetadata.token_endpoint;
92
+ debug(`Issuer ${issuer} has ${authorizationServerType} Server metadata in well-known location`);
93
+ if (!authMetadata.authorization_endpoint) {
94
+ throw Error(`Authorization Sever ${authorization_server} did not provide an authorization_endpoint`);
95
+ } else if (authorization_endpoint && authMetadata.authorization_endpoint !== authorization_endpoint) {
96
+ throw Error(
97
+ `Credential issuer has a different authorization_endpoint (${authorization_endpoint}) from the Authorization Server (${authMetadata.authorization_endpoint})`,
98
+ );
99
+ }
100
+ authorization_endpoint = authMetadata.authorization_endpoint;
101
+ if (!authMetadata.token_endpoint) {
102
+ throw Error(`Authorization Sever ${authorization_server} did not provide a token_endpoint`);
103
+ } else if (token_endpoint && authMetadata.token_endpoint !== token_endpoint) {
104
+ throw Error(
105
+ `Credential issuer has a different token_endpoint (${token_endpoint}) from the Authorization Server (${authMetadata.token_endpoint})`,
106
+ );
107
+ }
108
+ token_endpoint = authMetadata.token_endpoint;
109
+ if (authMetadata.credential_endpoint) {
110
+ if (credential_endpoint && authMetadata.credential_endpoint !== credential_endpoint) {
111
+ debug(
112
+ `Credential issuer has a different credential_endpoint (${credential_endpoint}) from the Authorization Server (${authMetadata.token_endpoint}). Will use the issuer value`,
113
+ );
114
+ } else {
115
+ credential_endpoint = authMetadata.credential_endpoint;
116
+ }
89
117
  }
90
118
  }
119
+
120
+ if (!authorization_endpoint) {
121
+ debug(`Issuer ${issuer} does not expose authorization_endpoint, so only pre-auth will be supported`);
122
+ }
91
123
  if (!token_endpoint) {
92
124
  debug(`Issuer ${issuer} does not have a token_endpoint listed in well-known locations!`);
93
125
  if (opts?.errorOnNotFound) {
94
- throw new Error(`Could not deduce the token endpoint for ${issuer}`);
126
+ throw Error(`Could not deduce the token_endpoint for ${issuer}`);
95
127
  } else {
96
- token_endpoint = `${issuer}${issuer.endsWith('/') ? '' : '/'}token`;
128
+ token_endpoint = `${issuer}${issuer.endsWith('/') ? 'token' : '/token'}`;
97
129
  }
98
130
  }
99
131
  if (!credential_endpoint) {
100
132
  debug(`Issuer ${issuer} does not have a credential_endpoint listed in well-known locations!`);
101
133
  if (opts?.errorOnNotFound) {
102
- throw new Error(`Could not deduce the credential endpoint for ${issuer}`);
134
+ throw Error(`Could not deduce the credential endpoint for ${issuer}`);
103
135
  } else {
104
- credential_endpoint = `${issuer}${issuer.endsWith('/') ? '' : '/'}credential`;
136
+ credential_endpoint = `${issuer}${issuer.endsWith('/') ? 'credential' : '/credential'}`;
105
137
  }
106
138
  }
139
+
140
+ if (!credentialIssuerMetadata && authMetadata) {
141
+ // Apparently everything worked out and the issuer is exposing everything in oAuth2/OIDC well-knowns. Spec is vague about this situation, but we can support it
142
+ credentialIssuerMetadata = authMetadata as CredentialIssuerMetadata;
143
+ }
107
144
  debug(`Issuer ${issuer} token endpoint ${token_endpoint}, credential endpoint ${credential_endpoint}`);
108
145
  return {
109
146
  issuer,
110
147
  token_endpoint,
111
148
  credential_endpoint,
112
- issuerMetadata,
149
+ authorization_server,
150
+ authorization_endpoint,
151
+ authorizationServerType,
152
+ credentialIssuerMetadata: credentialIssuerMetadata,
153
+ authorizationServerMetadata: authMetadata,
113
154
  };
114
155
  }
115
156
 
@@ -118,9 +159,15 @@ export class MetadataClient {
118
159
  *
119
160
  * @param issuerHost The issuer hostname
120
161
  */
121
- public static async retrieveOpenID4VCIServerMetadata(issuerHost: string): Promise<OpenIDResponse<CredentialIssuerMetadata> | undefined> {
122
- // Since the server metadata endpoint is optional we are not going to throw an error.
123
- return MetadataClient.retrieveWellknown(issuerHost, WellKnownEndpoints.OPENID4VCI_ISSUER, { errorOnNotFound: false });
162
+ public static async retrieveOpenID4VCIServerMetadata(
163
+ issuerHost: string,
164
+ opts?: {
165
+ errorOnNotFound?: boolean;
166
+ },
167
+ ): Promise<OpenIDResponse<CredentialIssuerMetadata> | undefined> {
168
+ return MetadataClient.retrieveWellknown(issuerHost, WellKnownEndpoints.OPENID4VCI_ISSUER, {
169
+ errorOnNotFound: opts?.errorOnNotFound === undefined ? true : opts.errorOnNotFound,
170
+ });
124
171
  }
125
172
 
126
173
  /**
@@ -138,9 +185,9 @@ export class MetadataClient {
138
185
  const result: OpenIDResponse<T> = await getJson(`${host.endsWith('/') ? host.slice(0, -1) : host}${endpointType}`, {
139
186
  exceptionOnHttpErrorStatus: opts?.errorOnNotFound,
140
187
  });
141
- if (result.origResponse.status === 404) {
188
+ if (result.origResponse.status >= 400) {
142
189
  // We only get here when error on not found is false
143
- debug(`host ${host} with endpoint type ${endpointType} was not found (404)`);
190
+ debug(`host ${host} with endpoint type ${endpointType} status: ${result.origResponse.status}, ${result.origResponse.statusText}`);
144
191
  }
145
192
  return result;
146
193
  }
@@ -9,6 +9,7 @@ import {
9
9
  CredentialResponse,
10
10
  CredentialSupported,
11
11
  EndpointMetadata,
12
+ EndpointMetadataResult,
12
13
  OID4VCICredentialFormat,
13
14
  OpenId4VCIVersion,
14
15
  OpenIDResponse,
@@ -53,7 +54,7 @@ export class OpenID4VCIClient {
53
54
  private _clientId?: string;
54
55
  private _kid: string | undefined;
55
56
  private _alg: Alg | string | undefined;
56
- private _endpointMetadata: EndpointMetadata | undefined;
57
+ private _endpointMetadata: EndpointMetadataResult | undefined;
57
58
  private _accessTokenResponse: AccessTokenResponse | undefined;
58
59
 
59
60
  private constructor(
@@ -119,9 +120,14 @@ export class OpenID4VCIClient {
119
120
  if (!scope && !authorizationDetails) {
120
121
  throw Error('Please provide a scope or authorization_details');
121
122
  }
122
- // todo: handling this because of the support for v1_0-08
123
- if (this._endpointMetadata && this._endpointMetadata.issuerMetadata && 'authorization_endpoint' in this._endpointMetadata.issuerMetadata) {
124
- this._endpointMetadata.authorization_endpoint = this._endpointMetadata.issuerMetadata.authorization_endpoint as string;
123
+ // todo: Probably can go with current logic in MetadataClient who will always set the authorization_endpoint when found
124
+ // handling this because of the support for v1_0-08
125
+ if (
126
+ this._endpointMetadata &&
127
+ this._endpointMetadata.credentialIssuerMetadata &&
128
+ 'authorization_endpoint' in this._endpointMetadata.credentialIssuerMetadata
129
+ ) {
130
+ this._endpointMetadata.authorization_endpoint = this._endpointMetadata.credentialIssuerMetadata.authorization_endpoint as string;
125
131
  }
126
132
  if (!this._endpointMetadata?.authorization_endpoint) {
127
133
  throw Error('Server metadata does not contain authorization endpoint');
@@ -169,13 +175,13 @@ export class OpenID4VCIClient {
169
175
  // What happens if it doesn't ???
170
176
  // let parEndpoint: string
171
177
  if (
172
- !this._endpointMetadata?.issuerMetadata ||
173
- !('pushed_authorization_request_endpoint' in this._endpointMetadata.issuerMetadata) ||
174
- typeof this._endpointMetadata.issuerMetadata.pushed_authorization_request_endpoint !== 'string'
178
+ !this._endpointMetadata?.credentialIssuerMetadata ||
179
+ !('pushed_authorization_request_endpoint' in this._endpointMetadata.credentialIssuerMetadata) ||
180
+ typeof this._endpointMetadata.credentialIssuerMetadata.pushed_authorization_request_endpoint !== 'string'
175
181
  ) {
176
182
  throw Error('Server metadata does not contain pushed authorization request endpoint');
177
183
  }
178
- const parEndpoint: string = this._endpointMetadata.issuerMetadata.pushed_authorization_request_endpoint;
184
+ const parEndpoint: string = this._endpointMetadata.credentialIssuerMetadata.pushed_authorization_request_endpoint;
179
185
 
180
186
  // add 'openid' scope if not present
181
187
  if (scope && !scope.includes('openid')) {
@@ -207,7 +213,10 @@ export class OpenID4VCIClient {
207
213
  }
208
214
 
209
215
  private handleLocations(authorizationDetails: AuthDetails) {
210
- if (authorizationDetails && (this.endpointMetadata.issuerMetadata?.authorization_server || this.endpointMetadata.authorization_endpoint)) {
216
+ if (
217
+ authorizationDetails &&
218
+ (this.endpointMetadata.credentialIssuerMetadata?.authorization_server || this.endpointMetadata.authorization_endpoint)
219
+ ) {
211
220
  if (authorizationDetails.locations) {
212
221
  if (Array.isArray(authorizationDetails.locations)) {
213
222
  (authorizationDetails.locations as string[]).push(this.endpointMetadata.issuer);
@@ -293,8 +302,8 @@ export class OpenID4VCIClient {
293
302
  metadata: this.endpointMetadata,
294
303
  });
295
304
  requestBuilder.withTokenFromResponse(this.accessTokenResponse);
296
- if (this.endpointMetadata?.issuerMetadata) {
297
- const metadata = this.endpointMetadata.issuerMetadata;
305
+ if (this.endpointMetadata?.credentialIssuerMetadata) {
306
+ const metadata = this.endpointMetadata.credentialIssuerMetadata;
298
307
  const types = Array.isArray(credentialTypes) ? credentialTypes : [credentialTypes];
299
308
  if (metadata.credentials_supported && Array.isArray(metadata.credentials_supported)) {
300
309
  for (const type of types) {
@@ -359,7 +368,7 @@ export class OpenID4VCIClient {
359
368
 
360
369
  getCredentialsSupported(restrictToInitiationTypes: boolean, supportedType?: string): CredentialSupported[] {
361
370
  return getSupportedCredentials({
362
- issuerMetadata: this.endpointMetadata.issuerMetadata,
371
+ issuerMetadata: this.endpointMetadata.credentialIssuerMetadata,
363
372
  version: this.version(),
364
373
  supportedType,
365
374
  credentialTypes: restrictToInitiationTypes ? this.getCredentialTypes() : undefined,
@@ -449,7 +458,7 @@ export class OpenID4VCIClient {
449
458
  return this.credentialOffer.version;
450
459
  }
451
460
 
452
- public get endpointMetadata(): EndpointMetadata {
461
+ public get endpointMetadata(): EndpointMetadataResult {
453
462
  this.assertServerMetadata();
454
463
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
455
464
  return this._endpointMetadata!;
@@ -1,4 +1,11 @@
1
- import { AccessTokenRequest, AccessTokenRequestOpts, AccessTokenResponse, GrantTypes, OpenIDResponse } from '@sphereon/oid4vci-common';
1
+ import {
2
+ AccessTokenRequest,
3
+ AccessTokenRequestOpts,
4
+ AccessTokenResponse,
5
+ GrantTypes,
6
+ OpenIDResponse,
7
+ WellKnownEndpoints
8
+ } from '@sphereon/oid4vci-common'
2
9
  import nock from 'nock';
3
10
 
4
11
  import { AccessTokenClient } from '../AccessTokenClient';
@@ -11,6 +18,8 @@ const MOCK_URL = 'https://sphereonjunit20221013.com/';
11
18
  describe('AccessTokenClient should', () => {
12
19
  beforeEach(() => {
13
20
  nock.cleanAll();
21
+ nock(MOCK_URL).get(WellKnownEndpoints.OAUTH_AS).reply(404, {});
22
+ nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {});
14
23
  });
15
24
 
16
25
  afterEach(() => {
@@ -5,8 +5,8 @@ import {
5
5
  CredentialOfferRequestWithBaseUrl,
6
6
  Jwt,
7
7
  OpenId4VCIVersion,
8
- ProofOfPossession,
9
- } from '@sphereon/oid4vci-common';
8
+ ProofOfPossession, WellKnownEndpoints
9
+ } from '@sphereon/oid4vci-common'
10
10
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
11
11
  // @ts-ignore
12
12
  import nock from 'nock';
@@ -55,6 +55,7 @@ describe('OID4VCI-Client should', () => {
55
55
  function succeedWithAFullFlowWithClientSetup() {
56
56
  nock(IDENTIPROOF_ISSUER_URL).get('/.well-known/openid-credential-issuer').reply(200, JSON.stringify(IDENTIPROOF_OID4VCI_METADATA));
57
57
  nock(IDENTIPROOF_AS_URL).get('/.well-known/oauth-authorization-server').reply(200, JSON.stringify(IDENTIPROOF_AS_METADATA));
58
+ nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {});
58
59
  nock(IDENTIPROOF_AS_URL)
59
60
  .post(/oauth2\/token.*/)
60
61
  .reply(200, JSON.stringify(mockedAccessTokenResponse));
@@ -1,3 +1,5 @@
1
+ import { OpenId4VCIVersion } from '@sphereon/oid4vci-common';
2
+
1
3
  import { CredentialOfferClient } from '../CredentialOfferClient';
2
4
 
3
5
  import { INITIATION_TEST, INITIATION_TEST_HTTPS_URI, INITIATION_TEST_URI } from './MetadataMocks';
@@ -45,4 +47,15 @@ describe('Issuance Initiation', () => {
45
47
  const issuanceInitiationURI = INITIATION_TEST_HTTPS_URI.replace('?', '');
46
48
  await expect(async () => CredentialOfferClient.fromURI(issuanceInitiationURI)).rejects.toThrowError('Invalid Credential Offer Request');
47
49
  });
50
+
51
+ it('Should return Credential Offer', async () => {
52
+ const client = await CredentialOfferClient.fromURI(
53
+ 'openid-credential-offer://?credential_offer=%7B%22credential_issuer%22%3A%22https%3A%2F%2Flaunchpad.vii.electron.mattrlabs.io%22%2C%22credentials%22%3A%5B%7B%22format%22%3A%22ldp_vc%22%2C%22types%22%3A%5B%22OpenBadgeCredential%22%5D%7D%5D%2C%22grants%22%3A%7B%22urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code%22%3A%7B%22pre-authorized_code%22%3A%22UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X%22%7D%7D%7D',
54
+ );
55
+ expect(client.version).toEqual(OpenId4VCIVersion.VER_1_0_11);
56
+ expect(client.baseUrl).toEqual('openid-credential-offer://');
57
+ expect(client.scheme).toEqual('openid-credential-offer');
58
+ expect(client.credential_offer.credential_issuer).toEqual('https://launchpad.vii.electron.mattrlabs.io');
59
+ expect(client.preAuthorizedCode).toEqual('UPZohaodPlLBnGsqB02n2tIupCIg8nKRRUEUHWA665X');
60
+ });
48
61
  });
@@ -0,0 +1,105 @@
1
+ import { fetch } from 'cross-fetch';
2
+ import { Alg, AuthzFlowType, Jwt } from '@sphereon/oid4vci-common';
3
+ import { importJWK, JWK, SignJWT } from 'jose';
4
+
5
+ import { OpenID4VCIClient } from '..';
6
+
7
+ export const UNIT_TEST_TIMEOUT = 30000;
8
+
9
+ const ISSUER_URL = 'https://launchpad.vii.electron.mattrlabs.io';
10
+
11
+ const jwk: JWK = {
12
+ crv: 'Ed25519',
13
+ d: 'kTRm0aONHYwNPA-w_DtjMHUIWjE3K70qgCIhWojZ0eU',
14
+ x: 'NeA0d8sp86xRh3DczU4m5wPNIbl0HCSwOBcMN3sNmdk',
15
+ kty: 'OKP',
16
+ };
17
+
18
+ // pub hex: 35e03477cb29f3ac518770dccd4e26e703cd21b9741c24b038170c377b0d99d9
19
+ // priv hex: 913466d1a38d1d8c0d3c0fb0fc3b633075085a31372bbd2a8022215a88d9d1e5
20
+ const did = `did:key:z6Mki5ZwZKN1dBQprfJTikUvkDxrHijiiQngkWviMF5gw2Hv`;
21
+ const kid = `${did}#z6Mki5ZwZKN1dBQprfJTikUvkDxrHijiiQngkWviMF5gw2Hv`;
22
+ describe('OID4VCI-Client using Mattr issuer should', () => {
23
+ async function test(format: 'ldp_vc' | 'jwt_vc_json') {
24
+ const offer = await getCredentialOffer(format)
25
+ const client = await OpenID4VCIClient.fromURI({
26
+ uri: offer.offerUrl,
27
+ flowType: AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW,
28
+ kid,
29
+ alg: Alg.EdDSA
30
+ })
31
+ expect(client.flowType).toEqual(AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW)
32
+ expect(client.credentialOffer).toBeDefined()
33
+ expect(client.endpointMetadata).toBeDefined()
34
+ expect(client.getCredentialEndpoint()).toEqual(`${ISSUER_URL}/oidc/v1/auth/credential`)
35
+ expect(client.getAccessTokenEndpoint()).toEqual('https://launchpad.vii.electron.mattrlabs.io/oidc/v1/auth/token')
36
+
37
+ const accessToken = await client.acquireAccessToken()
38
+ console.log(accessToken)
39
+ expect(accessToken).toMatchObject({
40
+ expires_in: 3600,
41
+ scope: 'OpenBadgeCredential',
42
+ token_type: 'Bearer'
43
+ })
44
+
45
+ const credentialResponse = await client.acquireCredentials({
46
+ credentialTypes: 'OpenBadgeCredential',
47
+ format,
48
+ proofCallbacks: {
49
+ signCallback: proofOfPossessionCallbackFunction
50
+ }
51
+ })
52
+ expect(credentialResponse.credential).toBeDefined()
53
+ }
54
+
55
+ it(
56
+ 'succeed in a full flow with the client using OpenID4VCI version 11 and ldp_vc',
57
+ async () => {
58
+
59
+ await test('ldp_vc')
60
+ },
61
+ UNIT_TEST_TIMEOUT,
62
+ );
63
+ it(
64
+ 'succeed in a full flow with the client using OpenID4VCI version 11 and jwt_vc_json',
65
+ async () => {
66
+
67
+ await test('jwt_vc_json')
68
+ },
69
+ UNIT_TEST_TIMEOUT,
70
+ );
71
+ });
72
+
73
+ interface CreateCredentialOfferResponse {
74
+ id: string;
75
+ offerUrl: string;
76
+ }
77
+
78
+ async function getCredentialOffer(format: 'ldp_vc' | 'jwt_vc_json'): Promise<CreateCredentialOfferResponse> {
79
+ const credentialOffer = await fetch('https://launchpad.mattrlabs.com/api/credential-offer', {
80
+ method: 'post',
81
+ headers: {
82
+ Accept: 'application/json',
83
+ 'Content-Type': 'application/json',
84
+ },
85
+
86
+ //make sure to serialize your JSON body
87
+ body: JSON.stringify({
88
+ format,
89
+ type: 'OpenBadgeCredential',
90
+ userId: '622a9f65-21c0-4c0b-9a6a-f7574c2a1549',
91
+ userAuthenticationRequired: false,
92
+ }),
93
+ });
94
+
95
+ return (await credentialOffer.json()) as CreateCredentialOfferResponse;
96
+ }
97
+
98
+ async function proofOfPossessionCallbackFunction(args: Jwt, kid?: string): Promise<string> {
99
+ const importedJwk = await importJWK(jwk, 'EdDSA');
100
+ return await new SignJWT({ ...args.payload })
101
+ .setProtectedHeader({ ...args.header })
102
+ .setIssuedAt()
103
+ .setExpirationTime('2h')
104
+ .sign(importedJwk);
105
+ }
@@ -30,16 +30,18 @@ describe('MetadataClient with IdentiProof Issuer should', () => {
30
30
  nock(IDENTIPROOF_ISSUER_URL).get(WellKnownEndpoints.OPENID4VCI_ISSUER).reply(200, JSON.stringify(IDENTIPROOF_OID4VCI_METADATA));
31
31
 
32
32
  nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OAUTH_AS).reply(200, JSON.stringify(IDENTIPROOF_AS_METADATA));
33
+ nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404);
33
34
 
34
35
  const metadata = await MetadataClient.retrieveAllMetadata(IDENTIPROOF_ISSUER_URL);
35
36
  expect(metadata.credential_endpoint).toEqual('https://issuer.research.identiproof.io/credential');
36
37
  expect(metadata.token_endpoint).toEqual('https://auth.research.identiproof.io/oauth2/token');
37
- expect(metadata.issuerMetadata).toEqual(IDENTIPROOF_OID4VCI_METADATA);
38
+ expect(metadata.credentialIssuerMetadata).toMatchObject(IDENTIPROOF_OID4VCI_METADATA);
38
39
  });
39
40
 
40
41
  it('succeed with OID4VCI and separate AS metadata from Initiation', async () => {
41
42
  nock(IDENTIPROOF_ISSUER_URL).get(WellKnownEndpoints.OPENID4VCI_ISSUER).reply(200, JSON.stringify(IDENTIPROOF_OID4VCI_METADATA));
42
43
  nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OAUTH_AS).reply(200, JSON.stringify(IDENTIPROOF_AS_METADATA));
44
+ nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404);
43
45
 
44
46
  const INITIATE_URI =
45
47
  'openid-initiate-issuance://?issuer=https%3A%2F%2Fissuer.research.identiproof.io&credential_type=OpenBadgeCredential&pre-authorized_code=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhOTUyZjUxNi1jYWVmLTQ4YjMtODIxYy00OTRkYzgyNjljZjAiLCJwcmUtYXV0aG9yaXplZCI6dHJ1ZX0.YE5DlalcLC2ChGEg47CQDaN1gTxbaQqSclIVqsSAUHE&user_pin_required=false';
@@ -47,7 +49,7 @@ describe('MetadataClient with IdentiProof Issuer should', () => {
47
49
  const metadata = await MetadataClient.retrieveAllMetadata(getIssuerFromCredentialOfferPayload(initiation.credential_offer) as string);
48
50
  expect(metadata.credential_endpoint).toEqual('https://issuer.research.identiproof.io/credential');
49
51
  expect(metadata.token_endpoint).toEqual('https://auth.research.identiproof.io/oauth2/token');
50
- expect(metadata.issuerMetadata).toEqual(IDENTIPROOF_OID4VCI_METADATA);
52
+ expect(metadata.credentialIssuerMetadata).toEqual(IDENTIPROOF_OID4VCI_METADATA);
51
53
  });
52
54
 
53
55
  it('Fail without OID4VCI and only AS metadata (no credential endpoint)', async () => {
@@ -64,18 +66,20 @@ describe('MetadataClient with IdentiProof Issuer should', () => {
64
66
  .reply(404, JSON.stringify({ error: 'does not exist' }));
65
67
 
66
68
  await expect(() => MetadataClient.retrieveAllMetadata(IDENTIPROOF_ISSUER_URL, { errorOnNotFound: true })).rejects.toThrowError(
67
- 'Could not deduce the token endpoint for https://issuer.research.identiproof.io',
69
+ 'Could not deduce the token_endpoint for https://issuer.research.identiproof.io',
68
70
  );
69
71
  });
70
72
 
71
73
  it('Fail with OID4VCI and no AS metadata', async () => {
72
74
  nock(IDENTIPROOF_ISSUER_URL).get(WellKnownEndpoints.OPENID4VCI_ISSUER).reply(200, JSON.stringify(IDENTIPROOF_OID4VCI_METADATA));
73
- nock(IDENTIPROOF_ISSUER_URL)
75
+ nock(IDENTIPROOF_AS_URL)
74
76
  .get(WellKnownEndpoints.OPENID_CONFIGURATION)
75
77
  .reply(404, JSON.stringify({ error: 'does not exist' }));
76
78
 
77
79
  nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OAUTH_AS).reply(404, JSON.stringify({}));
78
- await expect(() => MetadataClient.retrieveAllMetadata(IDENTIPROOF_ISSUER_URL)).rejects.toThrowError('{"error": "not found"}');
80
+ await expect(() => MetadataClient.retrieveAllMetadata(IDENTIPROOF_ISSUER_URL)).rejects.toThrowError(
81
+ 'Issuer https://issuer.research.identiproof.io provided a separate authorization server https://auth.research.identiproof.io, but that server did not provide metadata',
82
+ );
79
83
  });
80
84
 
81
85
  it('Fail if there is no token endpoint with errors enabled', async () => {
@@ -83,9 +87,10 @@ describe('MetadataClient with IdentiProof Issuer should', () => {
83
87
  const meta = JSON.parse(JSON.stringify(IDENTIPROOF_AS_METADATA));
84
88
  delete meta.token_endpoint;
85
89
  nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OAUTH_AS).reply(200, JSON.stringify(meta));
90
+ nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404);
86
91
 
87
92
  await expect(() => MetadataClient.retrieveAllMetadata(IDENTIPROOF_ISSUER_URL, { errorOnNotFound: true })).rejects.toThrowError(
88
- 'Could not deduce the token endpoint for https://issuer.research.identiproof.io',
93
+ 'Authorization Sever https://auth.research.identiproof.io did not provide a token_endpoint',
89
94
  );
90
95
  });
91
96
 
@@ -94,6 +99,7 @@ describe('MetadataClient with IdentiProof Issuer should', () => {
94
99
  delete meta.credential_endpoint;
95
100
  nock(IDENTIPROOF_ISSUER_URL).get(WellKnownEndpoints.OPENID4VCI_ISSUER).reply(200, JSON.stringify(meta));
96
101
  nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OAUTH_AS).reply(200, JSON.stringify(IDENTIPROOF_AS_METADATA));
102
+ nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404);
97
103
 
98
104
  await expect(() => MetadataClient.retrieveAllMetadata(IDENTIPROOF_ISSUER_URL, { errorOnNotFound: true })).rejects.toThrowError(
99
105
  'Could not deduce the credential endpoint for https://issuer.research.identiproof.io',
@@ -103,6 +109,7 @@ describe('MetadataClient with IdentiProof Issuer should', () => {
103
109
  it('Succeed with default value if there is no credential endpoint with errors disabled', async () => {
104
110
  nock(IDENTIPROOF_ISSUER_URL).get(WellKnownEndpoints.OPENID4VCI_ISSUER).reply(200, JSON.stringify(IDENTIPROOF_OID4VCI_METADATA));
105
111
  nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OAUTH_AS).reply(200, JSON.stringify(IDENTIPROOF_AS_METADATA));
112
+ nock(IDENTIPROOF_AS_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404);
106
113
 
107
114
  const metadata = await MetadataClient.retrieveAllMetadata(IDENTIPROOF_ISSUER_URL);
108
115
  expect(metadata.credential_endpoint).toEqual('https://issuer.research.identiproof.io/credential');
@@ -130,11 +137,13 @@ describe('MetadataClient with IdentiProof Issuer should', () => {
130
137
  describe('Metadataclient with Spruce Issuer should', () => {
131
138
  it('succeed with OID4VCI and separate AS metadata', async () => {
132
139
  nock(SPRUCE_ISSUER_URL).get(WellKnownEndpoints.OPENID4VCI_ISSUER).reply(200, JSON.stringify(SPRUCE_OID4VCI_METADATA));
140
+ nock(SPRUCE_ISSUER_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404);
141
+ nock(SPRUCE_ISSUER_URL).get(WellKnownEndpoints.OAUTH_AS).reply(404);
133
142
 
134
143
  const metadata = await MetadataClient.retrieveAllMetadata(SPRUCE_ISSUER_URL);
135
144
  expect(metadata.credential_endpoint).toEqual('https://ngi-oidc4vci-test.spruceid.xyz/credential');
136
145
  expect(metadata.token_endpoint).toEqual('https://ngi-oidc4vci-test.spruceid.xyz/token');
137
- expect(metadata.issuerMetadata).toEqual(SPRUCE_OID4VCI_METADATA);
146
+ expect(metadata.credentialIssuerMetadata).toEqual(SPRUCE_OID4VCI_METADATA);
138
147
  });
139
148
 
140
149
  it('Fail without OID4VCI', async () => {
@@ -144,7 +153,7 @@ describe('Metadataclient with Spruce Issuer should', () => {
144
153
  .reply(404, JSON.stringify({ error: 'does not exist' }));
145
154
 
146
155
  await expect(() => MetadataClient.retrieveAllMetadata(SPRUCE_ISSUER_URL, { errorOnNotFound: true })).rejects.toThrowError(
147
- 'Could not deduce the token endpoint for https://ngi-oidc4vci-test.spruceid.xyz',
156
+ 'Could not deduce the token_endpoint for https://ngi-oidc4vci-test.spruceid.xyz',
148
157
  );
149
158
  });
150
159
  });
@@ -160,7 +169,7 @@ describe('Metadataclient with Danubetech should', () => {
160
169
  const metadata = await MetadataClient.retrieveAllMetadata(DANUBE_ISSUER_URL);
161
170
  expect(metadata.credential_endpoint).toEqual('https://oidc4vc.uniissuer.io/credential');
162
171
  expect(metadata.token_endpoint).toEqual('https://oidc4vc.uniissuer.io/token');
163
- expect(metadata.issuerMetadata).toEqual(DANUBE_OIDC_METADATA);
172
+ expect(metadata.credentialIssuerMetadata).toEqual(DANUBE_OIDC_METADATA);
164
173
  });
165
174
 
166
175
  it('Fail without OID4VCI', async () => {
@@ -170,7 +179,7 @@ describe('Metadataclient with Danubetech should', () => {
170
179
  .reply(404, JSON.stringify({ error: 'does not exist' }));
171
180
 
172
181
  await expect(() => MetadataClient.retrieveAllMetadata(SPRUCE_ISSUER_URL, { errorOnNotFound: true })).rejects.toThrowError(
173
- 'Could not deduce the token endpoint for https://ngi-oidc4vci-test.spruceid.xyz',
182
+ 'Could not deduce the token_endpoint for https://ngi-oidc4vci-test.spruceid.xyz',
174
183
  );
175
184
  });
176
185
  });
@@ -187,7 +196,7 @@ describe('Metadataclient with Walt-id should', () => {
187
196
  const metadata = await MetadataClient.retrieveAllMetadata(WALT_ISSUER_URL);
188
197
  expect(metadata.credential_endpoint).toEqual('https://jff.walt.id/issuer-api/oidc/credential');
189
198
  expect(metadata.token_endpoint).toEqual('https://jff.walt.id/issuer-api/oidc/token');
190
- expect(metadata.issuerMetadata).toEqual(WALT_OID4VCI_METADATA);
199
+ expect(metadata.credentialIssuerMetadata).toEqual(WALT_OID4VCI_METADATA);
191
200
  });
192
201
 
193
202
  it('Fail without OID4VCI', async () => {
@@ -197,7 +206,7 @@ describe('Metadataclient with Walt-id should', () => {
197
206
  .reply(404, JSON.stringify({ error: 'does not exist' }));
198
207
 
199
208
  await expect(() => MetadataClient.retrieveAllMetadata(WALT_ISSUER_URL, { errorOnNotFound: true })).rejects.toThrowError(
200
- 'Could not deduce the token endpoint for https://jff.walt.id/issuer-api/oidc',
209
+ 'Could not deduce the token_endpoint for https://jff.walt.id/issuer-api/oidc',
201
210
  );
202
211
  });
203
212
  });
@@ -1,4 +1,4 @@
1
- import { AuthzFlowType, CodeChallengeMethod } from '@sphereon/oid4vci-common';
1
+ import { AuthzFlowType, CodeChallengeMethod, WellKnownEndpoints } from '@sphereon/oid4vci-common'
2
2
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
3
  // @ts-ignore
4
4
  import nock from 'nock';
@@ -12,6 +12,8 @@ describe('OpenID4VCIClient should', () => {
12
12
 
13
13
  beforeEach(async () => {
14
14
  nock(MOCK_URL).get(/.*/).reply(200, {});
15
+ nock(MOCK_URL).get(WellKnownEndpoints.OAUTH_AS).reply(404, {});
16
+ nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {});
15
17
  client = await OpenID4VCIClient.fromURI({
16
18
  uri: 'openid-initiate-issuance://?issuer=https://server.example.com&credential_type=TestCredential',
17
19
  flowType: AuthzFlowType.AUTHORIZATION_CODE_FLOW,
@@ -25,7 +27,7 @@ describe('OpenID4VCIClient should', () => {
25
27
  it('should create successfully construct an authorization request url', async () => {
26
28
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
27
29
  // @ts-ignore
28
- client._endpointMetadata?.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
30
+ client._endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
29
31
  const url = client.createAuthorizationRequestUrl({
30
32
  clientId: 'test-client',
31
33
  codeChallengeMethod: CodeChallengeMethod.SHA256,
@@ -53,7 +55,7 @@ describe('OpenID4VCIClient should', () => {
53
55
  it("injects 'openid' as the first scope if not provided", async () => {
54
56
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
55
57
  // @ts-ignore
56
- client._endpointMetadata?.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
58
+ client._endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
57
59
 
58
60
  const url = client.createAuthorizationRequestUrl({
59
61
  clientId: 'test-client',
@@ -71,7 +73,7 @@ describe('OpenID4VCIClient should', () => {
71
73
  it('throw an error if no scope and no authorization_details is provided', async () => {
72
74
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
73
75
  // @ts-ignore
74
- client._endpointMetadata?.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
76
+ client._endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
75
77
 
76
78
  expect(() => {
77
79
  client.createAuthorizationRequestUrl({
@@ -85,7 +87,7 @@ describe('OpenID4VCIClient should', () => {
85
87
  it('create an authorization request url with authorization_details array property', async () => {
86
88
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
87
89
  // @ts-ignore
88
- client._endpointMetadata.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
90
+ client._endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
89
91
 
90
92
  expect(
91
93
  client.createAuthorizationRequestUrl({
@@ -116,7 +118,7 @@ describe('OpenID4VCIClient should', () => {
116
118
  it('create an authorization request url with authorization_details object property', async () => {
117
119
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
118
120
  // @ts-ignore
119
- client._endpointMetadata.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
121
+ client._endpointMetadata?.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
120
122
 
121
123
  expect(
122
124
  client.createAuthorizationRequestUrl({
@@ -140,7 +142,7 @@ describe('OpenID4VCIClient should', () => {
140
142
  it('create an authorization request url with authorization_details and scope', async () => {
141
143
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
142
144
  // @ts-ignore
143
- client._endpointMetadata.issuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
145
+ client._endpointMetadata.credentialIssuerMetadata.authorization_endpoint = `${MOCK_URL}v1/auth/authorize`;
144
146
 
145
147
  expect(
146
148
  client.createAuthorizationRequestUrl({
@@ -1,4 +1,4 @@
1
- import { AuthzFlowType, CodeChallengeMethod, Oauth2ASWithOID4VCIMetadata } from '@sphereon/oid4vci-common';
1
+ import { AuthzFlowType, CodeChallengeMethod, WellKnownEndpoints } from '@sphereon/oid4vci-common'
2
2
  import nock from 'nock';
3
3
 
4
4
  import { OpenID4VCIClient } from '../OpenID4VCIClient';
@@ -9,6 +9,8 @@ describe('OpenID4VCIClient', () => {
9
9
 
10
10
  beforeEach(async () => {
11
11
  nock(MOCK_URL).get(/.*/).reply(200, {});
12
+ nock(MOCK_URL).get(WellKnownEndpoints.OAUTH_AS).reply(404, {});
13
+ nock(MOCK_URL).get(WellKnownEndpoints.OPENID_CONFIGURATION).reply(404, {});
12
14
  nock(`${MOCK_URL}`).post('/v1/auth/par').reply(201, { request_uri: 'test_uri', expires_in: 90 });
13
15
  client = await OpenID4VCIClient.fromURI({
14
16
  uri: 'openid-initiate-issuance://?issuer=https://server.example.com&credential_type=TestCredential',
@@ -21,7 +23,9 @@ describe('OpenID4VCIClient', () => {
21
23
  });
22
24
 
23
25
  it('should successfully retrieve the authorization code using PAR', async () => {
24
- (client.endpointMetadata.issuerMetadata! as Oauth2ASWithOID4VCIMetadata).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`;
26
+ (
27
+ client.endpointMetadata.credentialIssuerMetadata!
28
+ ).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`;
25
29
  const actual = await client.acquirePushedAuthorizationRequestURI({
26
30
  clientId: 'test-client',
27
31
  codeChallengeMethod: CodeChallengeMethod.SHA256,
@@ -56,7 +60,9 @@ describe('OpenID4VCIClient', () => {
56
60
  });
57
61
 
58
62
  it('should not fail when only authorization_details is present', async () => {
59
- (client.endpointMetadata.issuerMetadata! as Oauth2ASWithOID4VCIMetadata).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`;
63
+ (
64
+ client.endpointMetadata.credentialIssuerMetadata!
65
+ ).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`;
60
66
  const actual = await client.acquirePushedAuthorizationRequestURI({
61
67
  clientId: 'test-client',
62
68
  codeChallengeMethod: CodeChallengeMethod.SHA256,
@@ -77,7 +83,9 @@ describe('OpenID4VCIClient', () => {
77
83
  });
78
84
 
79
85
  it('should not fail when only scope is present', async () => {
80
- (client.endpointMetadata.issuerMetadata! as Oauth2ASWithOID4VCIMetadata).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`;
86
+ (
87
+ client.endpointMetadata.credentialIssuerMetadata!
88
+ ).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`;
81
89
  const actual = await client.acquirePushedAuthorizationRequestURI({
82
90
  clientId: 'test-client',
83
91
  codeChallengeMethod: CodeChallengeMethod.SHA256,
@@ -89,7 +97,9 @@ describe('OpenID4VCIClient', () => {
89
97
  });
90
98
 
91
99
  it('should not fail when both authorization_details and scope are present', async () => {
92
- (client.endpointMetadata.issuerMetadata! as Oauth2ASWithOID4VCIMetadata).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`;
100
+ (
101
+ client.endpointMetadata.credentialIssuerMetadata!
102
+ ).pushed_authorization_request_endpoint = `${MOCK_URL}v1/auth/par`;
93
103
  const actual = await client.acquirePushedAuthorizationRequestURI({
94
104
  clientId: 'test-client',
95
105
  codeChallengeMethod: CodeChallengeMethod.SHA256,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/oid4vci-client",
3
- "version": "0.6.1-next.8+02c84d3",
3
+ "version": "0.7.1-next.7+5b8552f",
4
4
  "description": "OpenID for Verifiable Credential Issuance (OpenID4VCI) client",
5
5
  "source": "lib/index.ts",
6
6
  "main": "dist/index.js",
@@ -15,15 +15,14 @@
15
15
  "build": "tsc"
16
16
  },
17
17
  "dependencies": {
18
- "@sphereon/oid4vci-common": "0.6.1-next.8+02c84d3",
18
+ "@sphereon/oid4vci-common": "0.7.1-next.7+5b8552f",
19
19
  "@sphereon/ssi-types": "^0.15.1",
20
20
  "cross-fetch": "^3.1.8",
21
- "debug": "^4.3.4",
22
- "uint8arrays": "^4.0.6"
21
+ "debug": "^4.3.4"
23
22
  },
24
23
  "devDependencies": {
25
24
  "@types/jest": "^29.5.3",
26
- "@types/node": "^18.17.3",
25
+ "@types/node": "^18.17.4",
27
26
  "@typescript-eslint/eslint-plugin": "^5.62.0",
28
27
  "@typescript-eslint/parser": "^5.62.0",
29
28
  "codecov": "^3.8.3",
@@ -40,7 +39,8 @@
40
39
  "open-cli": "^7.2.0",
41
40
  "ts-jest": "^29.1.1",
42
41
  "ts-node": "^10.9.1",
43
- "typescript": "4.9.5"
42
+ "typescript": "4.9.5",
43
+ "uint8arrays": "3.1.1"
44
44
  },
45
45
  "engines": {
46
46
  "node": ">=16"
@@ -64,5 +64,5 @@
64
64
  "OIDC4VCI",
65
65
  "OID4VCI"
66
66
  ],
67
- "gitHead": "02c84d30ec5fd81b1ecbec0d676e9a8c9b731823"
67
+ "gitHead": "5b8552f1844e4b97156c49e464693952fd0b63f0"
68
68
  }