@sphereon/oid4vci-client 0.10.4-unstable.98 → 0.12.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/README.md +7 -7
- package/dist/AccessTokenClient.d.ts.map +1 -1
- package/dist/AccessTokenClient.js +5 -6
- package/dist/AccessTokenClient.js.map +1 -1
- package/dist/AccessTokenClientV1_0_11.d.ts.map +1 -1
- package/dist/AccessTokenClientV1_0_11.js +3 -5
- package/dist/AccessTokenClientV1_0_11.js.map +1 -1
- package/dist/AuthorizationCodeClient.d.ts +4 -1
- package/dist/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/AuthorizationCodeClient.js +47 -8
- package/dist/AuthorizationCodeClient.js.map +1 -1
- package/dist/AuthorizationCodeClientV1_0_11.d.ts.map +1 -1
- package/dist/AuthorizationCodeClientV1_0_11.js +5 -3
- package/dist/AuthorizationCodeClientV1_0_11.js.map +1 -1
- package/dist/CredentialOfferClient.d.ts.map +1 -1
- package/dist/CredentialOfferClient.js +26 -12
- package/dist/CredentialOfferClient.js.map +1 -1
- package/dist/CredentialOfferClientV1_0_11.js +6 -7
- package/dist/CredentialOfferClientV1_0_11.js.map +1 -1
- package/dist/CredentialOfferClientV1_0_13.d.ts +10 -0
- package/dist/CredentialOfferClientV1_0_13.d.ts.map +1 -0
- package/dist/CredentialOfferClientV1_0_13.js +94 -0
- package/dist/CredentialOfferClientV1_0_13.js.map +1 -0
- package/dist/CredentialRequestClient.js +1 -1
- package/dist/CredentialRequestClient.js.map +1 -1
- package/dist/CredentialRequestClientBuilderV1_0_11.d.ts +3 -1
- package/dist/CredentialRequestClientBuilderV1_0_11.d.ts.map +1 -1
- package/dist/CredentialRequestClientBuilderV1_0_11.js +4 -0
- package/dist/CredentialRequestClientBuilderV1_0_11.js.map +1 -1
- package/dist/CredentialRequestClientV1_0_11.d.ts +9 -3
- package/dist/CredentialRequestClientV1_0_11.d.ts.map +1 -1
- package/dist/CredentialRequestClientV1_0_11.js +2 -1
- package/dist/CredentialRequestClientV1_0_11.js.map +1 -1
- package/dist/MetadataClient.d.ts +5 -5
- package/dist/MetadataClient.d.ts.map +1 -1
- package/dist/MetadataClient.js +30 -13
- package/dist/MetadataClient.js.map +1 -1
- package/dist/MetadataClientV1_0_13.d.ts +31 -0
- package/dist/MetadataClientV1_0_13.d.ts.map +1 -0
- package/dist/MetadataClientV1_0_13.js +181 -0
- package/dist/MetadataClientV1_0_13.js.map +1 -0
- package/dist/OpenID4VCIClient.d.ts +13 -24
- package/dist/OpenID4VCIClient.d.ts.map +1 -1
- package/dist/OpenID4VCIClient.js +126 -103
- package/dist/OpenID4VCIClient.js.map +1 -1
- package/dist/OpenID4VCIClientV1_0_11.d.ts +3 -2
- package/dist/OpenID4VCIClientV1_0_11.d.ts.map +1 -1
- package/dist/OpenID4VCIClientV1_0_11.js +5 -18
- package/dist/OpenID4VCIClientV1_0_11.js.map +1 -1
- package/dist/OpenID4VCIClientV1_0_13.d.ts +112 -0
- package/dist/OpenID4VCIClientV1_0_13.d.ts.map +1 -0
- package/dist/OpenID4VCIClientV1_0_13.js +478 -0
- package/dist/OpenID4VCIClientV1_0_13.js.map +1 -0
- package/dist/ProofOfPossessionBuilder.d.ts +14 -3
- package/dist/ProofOfPossessionBuilder.d.ts.map +1 -1
- package/dist/ProofOfPossessionBuilder.js +20 -20
- package/dist/ProofOfPossessionBuilder.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/lib/AccessTokenClient.ts +5 -11
- package/lib/AccessTokenClientV1_0_11.ts +3 -9
- package/lib/AuthorizationCodeClient.ts +47 -8
- package/lib/AuthorizationCodeClientV1_0_11.ts +8 -6
- package/lib/CredentialOfferClient.ts +31 -9
- package/lib/CredentialOfferClientV1_0_11.ts +6 -6
- package/lib/CredentialOfferClientV1_0_13.ts +103 -0
- package/lib/CredentialRequestClient.ts +1 -1
- package/lib/CredentialRequestClientBuilderV1_0_11.ts +7 -0
- package/lib/CredentialRequestClientV1_0_11.ts +9 -4
- package/lib/MetadataClient.ts +49 -14
- package/lib/MetadataClientV1_0_13.ts +188 -0
- package/lib/OpenID4VCIClient.ts +131 -115
- package/lib/OpenID4VCIClientV1_0_11.ts +9 -19
- package/lib/OpenID4VCIClientV1_0_13.ts +677 -0
- package/lib/ProofOfPossessionBuilder.ts +40 -9
- package/lib/__tests__/CredentialRequestClientV1_0_11.spec.ts +2 -2
- package/lib/__tests__/MetadataClient.spec.ts +3 -4
- package/lib/__tests__/MetadataMocks.ts +1 -0
- package/lib/__tests__/OpenID4VCIClient.spec.ts +42 -9
- package/lib/__tests__/OpenID4VCIClientV1_0_11.spec.ts +24 -0
- package/lib/__tests__/OpenID4VCIClientV1_0_13.spec.ts +204 -0
- package/lib/__tests__/SdJwt.spec.ts +2 -2
- package/lib/__tests__/SphereonE2E.spec.test.ts +4 -3
- package/lib/index.ts +8 -0
- package/package.json +4 -4
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MetadataClientV1_0_13 = void 0;
|
|
16
|
+
const oid4vci_common_1 = require("@sphereon/oid4vci-common");
|
|
17
|
+
const debug_1 = __importDefault(require("debug"));
|
|
18
|
+
const OpenIDUtils_1 = require("./functions/OpenIDUtils");
|
|
19
|
+
const debug = (0, debug_1.default)('sphereon:oid4vci:metadata');
|
|
20
|
+
class MetadataClientV1_0_13 {
|
|
21
|
+
/**
|
|
22
|
+
* Retrieve metadata using the Initiation obtained from a previous step
|
|
23
|
+
*
|
|
24
|
+
* @param credentialOffer
|
|
25
|
+
*/
|
|
26
|
+
static retrieveAllMetadataFromCredentialOffer(credentialOffer) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return MetadataClientV1_0_13.retrieveAllMetadataFromCredentialOfferRequest(credentialOffer.credential_offer);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Retrieve the metada using the initiation request obtained from a previous step
|
|
33
|
+
* @param request
|
|
34
|
+
*/
|
|
35
|
+
static retrieveAllMetadataFromCredentialOfferRequest(request) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const issuer = (0, oid4vci_common_1.getIssuerFromCredentialOfferPayload)(request);
|
|
38
|
+
if (issuer) {
|
|
39
|
+
return MetadataClientV1_0_13.retrieveAllMetadata(issuer);
|
|
40
|
+
}
|
|
41
|
+
throw new Error("can't retrieve metadata from CredentialOfferRequest. No issuer field is present");
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Retrieve all metadata from an issuer
|
|
46
|
+
* @param issuer The issuer URL
|
|
47
|
+
* @param opts
|
|
48
|
+
*/
|
|
49
|
+
static retrieveAllMetadata(issuer, opts) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
let token_endpoint;
|
|
52
|
+
let credential_endpoint;
|
|
53
|
+
let deferred_credential_endpoint;
|
|
54
|
+
let authorization_endpoint;
|
|
55
|
+
let authorizationServerType = 'OID4VCI';
|
|
56
|
+
let authorization_servers = [issuer];
|
|
57
|
+
const oid4vciResponse = yield MetadataClientV1_0_13.retrieveOpenID4VCIServerMetadata(issuer, { errorOnNotFound: false }); // We will handle errors later, given we will also try other metadata locations
|
|
58
|
+
let credentialIssuerMetadata = oid4vciResponse === null || oid4vciResponse === void 0 ? void 0 : oid4vciResponse.successBody;
|
|
59
|
+
if (credentialIssuerMetadata) {
|
|
60
|
+
debug(`Issuer ${issuer} OID4VCI well-known server metadata\r\n${JSON.stringify(credentialIssuerMetadata)}`);
|
|
61
|
+
credential_endpoint = credentialIssuerMetadata.credential_endpoint;
|
|
62
|
+
deferred_credential_endpoint = credentialIssuerMetadata.deferred_credential_endpoint;
|
|
63
|
+
if (credentialIssuerMetadata.token_endpoint) {
|
|
64
|
+
token_endpoint = credentialIssuerMetadata.token_endpoint;
|
|
65
|
+
}
|
|
66
|
+
if (credentialIssuerMetadata.authorization_servers) {
|
|
67
|
+
authorization_servers = credentialIssuerMetadata.authorization_servers;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// No specific OID4VCI endpoint. Either can be an OAuth2 AS or an OIDC IDP. Let's start with OIDC first
|
|
71
|
+
// TODO: for now we're taking just the first one
|
|
72
|
+
let response = yield (0, OpenIDUtils_1.retrieveWellknown)(authorization_servers[0], 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';
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// Now let's do OAuth2
|
|
82
|
+
// TODO: for now we're taking just the first one
|
|
83
|
+
response = yield (0, OpenIDUtils_1.retrieveWellknown)(authorization_servers[0], oid4vci_common_1.WellKnownEndpoints.OAUTH_AS, { errorOnNotFound: false });
|
|
84
|
+
authMetadata = response.successBody;
|
|
85
|
+
}
|
|
86
|
+
if (!authMetadata) {
|
|
87
|
+
// We will always throw an error, no matter whether the user provided the option not to, because this is bad.
|
|
88
|
+
if (!authorization_servers.includes(issuer)) {
|
|
89
|
+
throw Error(`Issuer ${issuer} provided a separate authorization server ${authorization_servers}, but that server did not provide metadata`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (!authorizationServerType) {
|
|
94
|
+
authorizationServerType = 'OAuth 2.0';
|
|
95
|
+
}
|
|
96
|
+
debug(`Issuer ${issuer} has ${authorizationServerType} Server metadata in well-known location`);
|
|
97
|
+
if (!authMetadata.authorization_endpoint) {
|
|
98
|
+
console.warn(`Issuer ${issuer} of type ${authorizationServerType} has no authorization_endpoint! Will use ${authorization_endpoint}. This only works for pre-authorized flows`);
|
|
99
|
+
}
|
|
100
|
+
else if (authorization_endpoint && authMetadata.authorization_endpoint !== authorization_endpoint) {
|
|
101
|
+
throw Error(`Credential issuer has a different authorization_endpoint (${authorization_endpoint}) from the Authorization Server (${authMetadata.authorization_endpoint})`);
|
|
102
|
+
}
|
|
103
|
+
authorization_endpoint = authMetadata.authorization_endpoint;
|
|
104
|
+
if (!authMetadata.token_endpoint) {
|
|
105
|
+
throw Error(`Authorization Sever ${authorization_servers} did not provide a token_endpoint`);
|
|
106
|
+
}
|
|
107
|
+
else if (token_endpoint && authMetadata.token_endpoint !== token_endpoint) {
|
|
108
|
+
throw Error(`Credential issuer has a different token_endpoint (${token_endpoint}) from the Authorization Server (${authMetadata.token_endpoint})`);
|
|
109
|
+
}
|
|
110
|
+
token_endpoint = authMetadata.token_endpoint;
|
|
111
|
+
if (authMetadata.credential_endpoint) {
|
|
112
|
+
if (credential_endpoint && authMetadata.credential_endpoint !== credential_endpoint) {
|
|
113
|
+
debug(`Credential issuer has a different credential_endpoint (${credential_endpoint}) from the Authorization Server (${authMetadata.credential_endpoint}). Will use the issuer value`);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
credential_endpoint = authMetadata.credential_endpoint;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (authMetadata.deferred_credential_endpoint) {
|
|
120
|
+
if (deferred_credential_endpoint && authMetadata.deferred_credential_endpoint !== deferred_credential_endpoint) {
|
|
121
|
+
debug(`Credential issuer has a different deferred_credential_endpoint (${deferred_credential_endpoint}) from the Authorization Server (${authMetadata.deferred_credential_endpoint}). Will use the issuer value`);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
deferred_credential_endpoint = authMetadata.deferred_credential_endpoint;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (!authorization_endpoint) {
|
|
129
|
+
debug(`Issuer ${issuer} does not expose authorization_endpoint, so only pre-auth will be supported`);
|
|
130
|
+
}
|
|
131
|
+
if (!token_endpoint) {
|
|
132
|
+
debug(`Issuer ${issuer} does not have a token_endpoint listed in well-known locations!`);
|
|
133
|
+
if (opts === null || opts === void 0 ? void 0 : opts.errorOnNotFound) {
|
|
134
|
+
throw Error(`Could not deduce the token_endpoint for ${issuer}`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
token_endpoint = `${issuer}${issuer.endsWith('/') ? 'token' : '/token'}`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (!credential_endpoint) {
|
|
141
|
+
debug(`Issuer ${issuer} does not have a credential_endpoint listed in well-known locations!`);
|
|
142
|
+
if (opts === null || opts === void 0 ? void 0 : opts.errorOnNotFound) {
|
|
143
|
+
throw Error(`Could not deduce the credential endpoint for ${issuer}`);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
credential_endpoint = `${issuer}${issuer.endsWith('/') ? 'credential' : '/credential'}`;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (!credentialIssuerMetadata && authMetadata) {
|
|
150
|
+
// 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
|
|
151
|
+
credentialIssuerMetadata = authMetadata;
|
|
152
|
+
}
|
|
153
|
+
debug(`Issuer ${issuer} token endpoint ${token_endpoint}, credential endpoint ${credential_endpoint}`);
|
|
154
|
+
return {
|
|
155
|
+
issuer,
|
|
156
|
+
token_endpoint,
|
|
157
|
+
credential_endpoint,
|
|
158
|
+
deferred_credential_endpoint,
|
|
159
|
+
authorization_server: authorization_servers[0],
|
|
160
|
+
authorization_endpoint,
|
|
161
|
+
authorizationServerType,
|
|
162
|
+
credentialIssuerMetadata: credentialIssuerMetadata,
|
|
163
|
+
authorizationServerMetadata: authMetadata,
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Retrieve only the OID4VCI metadata for the issuer. So no OIDC/OAuth2 metadata
|
|
169
|
+
*
|
|
170
|
+
* @param issuerHost The issuer hostname
|
|
171
|
+
*/
|
|
172
|
+
static retrieveOpenID4VCIServerMetadata(issuerHost, opts) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
return (0, OpenIDUtils_1.retrieveWellknown)(issuerHost, oid4vci_common_1.WellKnownEndpoints.OPENID4VCI_ISSUER, {
|
|
175
|
+
errorOnNotFound: (opts === null || opts === void 0 ? void 0 : opts.errorOnNotFound) === undefined ? true : opts.errorOnNotFound,
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.MetadataClientV1_0_13 = MetadataClientV1_0_13;
|
|
181
|
+
//# sourceMappingURL=MetadataClientV1_0_13.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetadataClientV1_0_13.js","sourceRoot":"","sources":["../lib/MetadataClientV1_0_13.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAWkC;AAClC,kDAA0B;AAE1B,yDAA4D;AAE5D,MAAM,KAAK,GAAG,IAAA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;gBAC5B,oBAAoB,EAAE,qBAAqB,CAAC,CAAC,CAAC;gBAC9C,sBAAsB;gBACtB,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,IAAA,+BAAiB,EAAC,UAAU,EAAE,mCAAkB,CAAC,iBAAiB,EAAE;gBACzE,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;CACF;AAzKD,sDAyKC"}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
import { AccessTokenResponse, Alg, AuthorizationRequestOpts, AuthorizationResponse, AuthzFlowType, CredentialConfigurationSupportedV1_0_13, CredentialOfferRequestWithBaseUrl, CredentialResponse, EndpointMetadataResultV1_0_13, JWK, NotificationRequest, NotificationResult, OID4VCICredentialFormat, OpenId4VCIVersion, PKCEOpts, ProofOfPossessionCallbacks } from '@sphereon/oid4vci-common';
|
|
1
|
+
import { AccessTokenResponse, Alg, AuthorizationRequestOpts, AuthorizationResponse, AuthzFlowType, CredentialConfigurationSupported, CredentialConfigurationSupportedV1_0_13, CredentialOfferRequestWithBaseUrl, CredentialResponse, EndpointMetadataResultV1_0_11, EndpointMetadataResultV1_0_13, JWK, NotificationRequest, NotificationResult, OID4VCICredentialFormat, OpenId4VCIVersion, PKCEOpts, ProofOfPossessionCallbacks } from '@sphereon/oid4vci-common';
|
|
2
2
|
import { CredentialFormat } from '@sphereon/ssi-types';
|
|
3
3
|
import { CredentialRequestOpts } from './CredentialRequestClient';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
kid?: string;
|
|
9
|
-
jwk?: JWK;
|
|
10
|
-
alg?: Alg | string;
|
|
11
|
-
endpointMetadata?: EndpointMetadataResultV1_0_13;
|
|
12
|
-
accessTokenResponse?: AccessTokenResponse;
|
|
13
|
-
authorizationRequestOpts?: AuthorizationRequestOpts;
|
|
14
|
-
authorizationCodeResponse?: AuthorizationResponse;
|
|
15
|
-
pkce: PKCEOpts;
|
|
16
|
-
accessToken?: string;
|
|
17
|
-
authorizationURL?: string;
|
|
18
|
-
}
|
|
4
|
+
import { OpenID4VCIClientStateV1_0_11 } from './OpenID4VCIClientV1_0_11';
|
|
5
|
+
import { OpenID4VCIClientStateV1_0_13 } from './OpenID4VCIClientV1_0_13';
|
|
6
|
+
export type OpenID4VCIClientState = OpenID4VCIClientStateV1_0_11 | OpenID4VCIClientStateV1_0_13;
|
|
7
|
+
export type EndpointMetadataResult = EndpointMetadataResultV1_0_11 | EndpointMetadataResultV1_0_13;
|
|
19
8
|
export declare class OpenID4VCIClient {
|
|
20
9
|
private readonly _state;
|
|
21
10
|
private constructor();
|
|
@@ -53,7 +42,7 @@ export declare class OpenID4VCIClient {
|
|
|
53
42
|
authorizationRequest?: AuthorizationRequestOpts;
|
|
54
43
|
pkce?: PKCEOpts;
|
|
55
44
|
}): Promise<string>;
|
|
56
|
-
retrieveServerMetadata(): Promise<
|
|
45
|
+
retrieveServerMetadata(): Promise<EndpointMetadataResult>;
|
|
57
46
|
private calculatePKCEOpts;
|
|
58
47
|
acquireAccessToken(opts?: {
|
|
59
48
|
pin?: string;
|
|
@@ -63,9 +52,8 @@ export declare class OpenID4VCIClient {
|
|
|
63
52
|
code?: string;
|
|
64
53
|
redirectUri?: string;
|
|
65
54
|
}): Promise<AccessTokenResponse>;
|
|
66
|
-
acquireCredentials({
|
|
67
|
-
|
|
68
|
-
credentialTypes?: string | string[];
|
|
55
|
+
acquireCredentials({ credentialTypes, context, proofCallbacks, format, kid, jwk, alg, jti, deferredCredentialAwait, deferredCredentialIntervalInMS, }: {
|
|
56
|
+
credentialTypes: string | string[];
|
|
69
57
|
context?: string[];
|
|
70
58
|
proofCallbacks: ProofOfPossessionCallbacks<any>;
|
|
71
59
|
format?: CredentialFormat | OID4VCICredentialFormat;
|
|
@@ -80,15 +68,16 @@ export declare class OpenID4VCIClient {
|
|
|
80
68
|
access_token: string;
|
|
81
69
|
}>;
|
|
82
70
|
exportState(): Promise<string>;
|
|
83
|
-
getCredentialsSupported(format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[]): Record<string, CredentialConfigurationSupportedV1_0_13>;
|
|
71
|
+
getCredentialsSupported(restrictToInitiationTypes?: boolean, format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[]): Record<string, CredentialConfigurationSupportedV1_0_13> | Array<CredentialConfigurationSupported>;
|
|
84
72
|
sendNotification(credentialRequestOpts: Partial<CredentialRequestOpts>, request: NotificationRequest, accessToken?: string): Promise<NotificationResult>;
|
|
73
|
+
getCredentialOfferTypes(): string[][] | undefined;
|
|
85
74
|
issuerSupportedFlowTypes(): AuthzFlowType[];
|
|
86
75
|
isFlowTypeSupported(flowType: AuthzFlowType): boolean;
|
|
87
|
-
hasAuthorizationURL(): boolean;
|
|
88
76
|
get authorizationURL(): string | undefined;
|
|
77
|
+
hasAuthorizationURL(): boolean;
|
|
89
78
|
get credentialOffer(): CredentialOfferRequestWithBaseUrl | undefined;
|
|
90
79
|
version(): OpenId4VCIVersion;
|
|
91
|
-
get endpointMetadata():
|
|
80
|
+
get endpointMetadata(): EndpointMetadataResult;
|
|
92
81
|
get kid(): string;
|
|
93
82
|
get alg(): string;
|
|
94
83
|
set clientId(value: string | undefined);
|
|
@@ -103,7 +92,7 @@ export declare class OpenID4VCIClient {
|
|
|
103
92
|
/**
|
|
104
93
|
* Too bad we need a method like this, but EBSI is not exposing metadata
|
|
105
94
|
*/
|
|
106
|
-
isEBSI():
|
|
95
|
+
isEBSI(): any;
|
|
107
96
|
private assertIssuerData;
|
|
108
97
|
private assertServerMetadata;
|
|
109
98
|
private assertAccessToken;
|
|
@@ -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,EAEb,uCAAuC,
|
|
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,EAEb,gCAAgC,EAChC,uCAAuC,EAGvC,iCAAiC,EACjC,kBAAkB,EAIlB,6BAA6B,EAC7B,6BAA6B,EAO7B,GAAG,EAEH,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,QAAQ,EACR,0BAA0B,EAE3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAQvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIlE,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAMzE,MAAM,MAAM,qBAAqB,GAAG,4BAA4B,GAAG,4BAA4B,CAAC;AAEhG,MAAM,MAAM,sBAAsB,GAAG,6BAA6B,GAAG,6BAA6B,CAAC;AAEnG,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAE/C,OAAO;WA2Da,oBAAoB,CAAC,EACvC,GAAG,EACH,GAAG,EACH,sBAAsB,EACtB,QAAQ,EACR,gBAAgB,EAChB,IAAI,EACJ,oBAAoB,EACpB,6BAA6B,GAC9B,EAAE;QACD,gBAAgB,EAAE,MAAM,CAAC;QACzB,GAAG,CAAC,EAAE,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