@sphereon/oid4vci-client 0.4.1-unstable.248 → 0.4.1-unstable.253
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/AccessTokenClient.d.ts +2 -2
- package/dist/AccessTokenClient.d.ts.map +1 -1
- package/dist/AccessTokenClient.js +27 -35
- package/dist/AccessTokenClient.js.map +1 -1
- package/dist/AuthorizationDetailsBuilder.d.ts +2 -2
- package/dist/AuthorizationDetailsBuilder.d.ts.map +1 -1
- package/dist/AuthorizationDetailsBuilder.js.map +1 -1
- package/dist/CredentialOfferClient.d.ts +10 -0
- package/dist/CredentialOfferClient.d.ts.map +1 -0
- package/dist/CredentialOfferClient.js +97 -0
- package/dist/CredentialOfferClient.js.map +1 -0
- package/dist/CredentialRequestClient.d.ts +15 -13
- package/dist/CredentialRequestClient.d.ts.map +1 -1
- package/dist/CredentialRequestClient.js +38 -6
- package/dist/CredentialRequestClient.js.map +1 -1
- package/dist/CredentialRequestClientBuilder.d.ts +34 -0
- package/dist/CredentialRequestClientBuilder.d.ts.map +1 -0
- package/dist/CredentialRequestClientBuilder.js +86 -0
- package/dist/CredentialRequestClientBuilder.js.map +1 -0
- package/dist/MetadataClient.js +1 -1
- package/dist/MetadataClient.js.map +1 -1
- package/dist/OpenID4VCIClient.d.ts +7 -5
- package/dist/OpenID4VCIClient.d.ts.map +1 -1
- package/dist/OpenID4VCIClient.js +31 -21
- package/dist/OpenID4VCIClient.js.map +1 -1
- package/dist/ProofOfPossessionBuilder.d.ts +2 -2
- package/dist/ProofOfPossessionBuilder.d.ts.map +1 -1
- package/dist/ProofOfPossessionBuilder.js.map +1 -1
- package/dist/functions/ProofUtil.d.ts +2 -2
- package/dist/functions/ProofUtil.d.ts.map +1 -1
- package/dist/functions/ProofUtil.js +2 -2
- package/dist/functions/ProofUtil.js.map +1 -1
- package/dist/functions/index.d.ts +2 -2
- package/dist/functions/index.d.ts.map +1 -1
- package/dist/functions/index.js +2 -2
- package/dist/functions/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/lib/AccessTokenClient.ts +29 -54
- package/lib/AuthorizationDetailsBuilder.ts +2 -2
- package/lib/CredentialOfferClient.ts +101 -0
- package/lib/CredentialRequestClient.ts +62 -25
- package/lib/CredentialRequestClientBuilder.ts +109 -0
- package/lib/MetadataClient.ts +1 -1
- package/lib/OpenID4VCIClient.ts +39 -23
- package/lib/ProofOfPossessionBuilder.ts +4 -3
- package/lib/__tests__/AccessTokenClient.spec.ts +4 -0
- package/lib/__tests__/AuthorizationDetailsBuilder.spec.ts +6 -6
- package/lib/__tests__/AuthzFlowType.spec.ts +5 -5
- package/lib/__tests__/CredentialRequestClient.spec.ts +71 -54
- package/lib/__tests__/CredentialRequestClientBuilder.spec.ts +21 -15
- package/lib/__tests__/IT.spec.ts +18 -9
- package/lib/__tests__/IssuanceInitiation.spec.ts +24 -16
- package/lib/__tests__/JsonURIConversions.spec.ts +5 -2
- package/lib/__tests__/MetadataClient.spec.ts +8 -3
- package/lib/__tests__/MetadataMocks.ts +17 -5
- package/lib/__tests__/ProofOfPossessionBuilder.spec.ts +2 -2
- package/lib/__tests__/data/VciDataFixtures.ts +10 -10
- package/lib/functions/ProofUtil.ts +5 -15
- package/lib/functions/index.ts +2 -2
- package/lib/index.ts +2 -2
- package/package.json +3 -3
- package/dist/CredentialOffer.d.ts +0 -6
- package/dist/CredentialOffer.d.ts.map +0 -1
- package/dist/CredentialOffer.js +0 -49
- package/dist/CredentialOffer.js.map +0 -1
- package/dist/CredentialRequestClientBuilderV1_0_09.d.ts +0 -29
- package/dist/CredentialRequestClientBuilderV1_0_09.d.ts.map +0 -1
- package/dist/CredentialRequestClientBuilderV1_0_09.js +0 -63
- package/dist/CredentialRequestClientBuilderV1_0_09.js.map +0 -1
- package/dist/functions/Encoding.d.ts +0 -20
- package/dist/functions/Encoding.d.ts.map +0 -1
- package/dist/functions/Encoding.js +0 -144
- package/dist/functions/Encoding.js.map +0 -1
- package/dist/functions/HttpUtils.d.ts +0 -24
- package/dist/functions/HttpUtils.d.ts.map +0 -1
- package/dist/functions/HttpUtils.js +0 -93
- package/dist/functions/HttpUtils.js.map +0 -1
- package/lib/CredentialOffer.ts +0 -55
- package/lib/CredentialRequestClientBuilderV1_0_09.ts +0 -99
- package/lib/functions/Encoding.ts +0 -138
- package/lib/functions/HttpUtils.ts +0 -106
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AccessTokenRequest, AccessTokenRequestOpts, AccessTokenResponse, AuthorizationServerOpts, EndpointMetadata, IssuerOpts, OpenIDResponse } from '@sphereon/oid4vci-common';
|
|
2
2
|
export declare class AccessTokenClient {
|
|
3
|
-
acquireAccessToken(
|
|
3
|
+
acquireAccessToken(opts: AccessTokenRequestOpts): Promise<OpenIDResponse<AccessTokenResponse>>;
|
|
4
4
|
acquireAccessTokenUsingRequest({ accessTokenRequest, isPinRequired, metadata, asOpts, issuerOpts, }: {
|
|
5
5
|
accessTokenRequest: AccessTokenRequest;
|
|
6
6
|
isPinRequired?: boolean;
|
|
@@ -8,7 +8,7 @@ export declare class AccessTokenClient {
|
|
|
8
8
|
asOpts?: AuthorizationServerOpts;
|
|
9
9
|
issuerOpts?: IssuerOpts;
|
|
10
10
|
}): Promise<OpenIDResponse<AccessTokenResponse>>;
|
|
11
|
-
createAccessTokenRequest(
|
|
11
|
+
createAccessTokenRequest(opts: AccessTokenRequestOpts): Promise<AccessTokenRequest>;
|
|
12
12
|
private assertPreAuthorizedGrantType;
|
|
13
13
|
private assertAuthorizationGrantType;
|
|
14
14
|
private isPinRequiredValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessTokenClient.d.ts","sourceRoot":"","sources":["../lib/AccessTokenClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,
|
|
1
|
+
{"version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;IAUnC,OAAO,CAAC,qBAAqB;CAI9B"}
|
|
@@ -18,14 +18,16 @@ const ssi_types_1 = require("@sphereon/ssi-types");
|
|
|
18
18
|
const debug_1 = __importDefault(require("debug"));
|
|
19
19
|
const MetadataClient_1 = require("./MetadataClient");
|
|
20
20
|
const functions_1 = require("./functions");
|
|
21
|
-
const debug = (0, debug_1.default)('sphereon:
|
|
21
|
+
const debug = (0, debug_1.default)('sphereon:oid4vci:token');
|
|
22
22
|
class AccessTokenClient {
|
|
23
|
-
acquireAccessToken(
|
|
23
|
+
acquireAccessToken(opts) {
|
|
24
|
+
var _a;
|
|
24
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const {
|
|
26
|
-
const
|
|
26
|
+
const { asOpts, pin, codeVerifier, code, redirectUri, metadata } = opts;
|
|
27
|
+
const credentialOffer = yield (0, oid4vci_common_1.assertedUniformCredentialOffer)(opts.credentialOffer);
|
|
28
|
+
const isPinRequired = this.isPinRequiredValue(credentialOffer.credential_offer);
|
|
27
29
|
const issuerOpts = {
|
|
28
|
-
issuer: (0, oid4vci_common_1.getIssuerFromCredentialOfferPayload)(
|
|
30
|
+
issuer: (_a = (0, oid4vci_common_1.getIssuerFromCredentialOfferPayload)(credentialOffer.credential_offer)) !== null && _a !== void 0 ? _a : metadata === null || metadata === void 0 ? void 0 : metadata.issuer,
|
|
29
31
|
};
|
|
30
32
|
return yield this.acquireAccessTokenUsingRequest({
|
|
31
33
|
accessTokenRequest: yield this.createAccessTokenRequest({
|
|
@@ -58,25 +60,29 @@ class AccessTokenClient {
|
|
|
58
60
|
return this.sendAuthCode(requestTokenURL, accessTokenRequest);
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
|
-
createAccessTokenRequest(
|
|
63
|
+
createAccessTokenRequest(opts) {
|
|
64
|
+
var _a, _b, _c, _d;
|
|
62
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const
|
|
66
|
+
const { asOpts, pin, codeVerifier, code, redirectUri } = opts;
|
|
67
|
+
const credentialOfferRequest = yield (0, oid4vci_common_1.toUniformCredentialOfferRequest)(opts.credentialOffer);
|
|
64
68
|
const request = {};
|
|
65
69
|
if (asOpts === null || asOpts === void 0 ? void 0 : asOpts.clientId) {
|
|
66
70
|
request.client_id = asOpts.clientId;
|
|
67
71
|
}
|
|
68
|
-
this.assertNumericPin(this.isPinRequiredValue(credentialOfferRequest), pin);
|
|
72
|
+
this.assertNumericPin(this.isPinRequiredValue(credentialOfferRequest.credential_offer), pin);
|
|
69
73
|
request.user_pin = pin;
|
|
70
|
-
|
|
74
|
+
const isPreAuth = (0, oid4vci_common_1.isPreAuthCode)(credentialOfferRequest);
|
|
75
|
+
if (isPreAuth) {
|
|
71
76
|
if (codeVerifier) {
|
|
72
77
|
throw new Error('Cannot pass a code_verifier when flow type is pre-authorized');
|
|
73
78
|
}
|
|
74
79
|
request.grant_type = oid4vci_common_1.GrantTypes.PRE_AUTHORIZED_CODE;
|
|
75
|
-
//
|
|
76
|
-
request[oid4vci_common_1.PRE_AUTH_CODE_LITERAL] =
|
|
80
|
+
// we actually know it is there because of the isPreAuthCode call
|
|
81
|
+
request[oid4vci_common_1.PRE_AUTH_CODE_LITERAL] =
|
|
82
|
+
(_b = (_a = credentialOfferRequest === null || credentialOfferRequest === void 0 ? void 0 : credentialOfferRequest.credential_offer.grants) === null || _a === void 0 ? void 0 : _a['urn:ietf:params:oauth:grant-type:pre-authorized_code']) === null || _b === void 0 ? void 0 : _b[oid4vci_common_1.PRE_AUTH_CODE_LITERAL];
|
|
77
83
|
}
|
|
78
|
-
if (
|
|
79
|
-
this.throwNotSupportedFlow();
|
|
84
|
+
if ((_d = (_c = credentialOfferRequest.credential_offer.grants) === null || _c === void 0 ? void 0 : _c.authorization_code) === null || _d === void 0 ? void 0 : _d.issuer_state) {
|
|
85
|
+
this.throwNotSupportedFlow(); // not supported yet
|
|
80
86
|
request.grant_type = oid4vci_common_1.GrantTypes.AUTHORIZATION_CODE;
|
|
81
87
|
}
|
|
82
88
|
if (codeVerifier) {
|
|
@@ -85,9 +91,8 @@ class AccessTokenClient {
|
|
|
85
91
|
request.redirect_uri = redirectUri;
|
|
86
92
|
request.grant_type = oid4vci_common_1.GrantTypes.AUTHORIZATION_CODE;
|
|
87
93
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
throw Error('A pre_authorized_code flow cannot have an op_state in the initiation request');
|
|
94
|
+
if (request.grant_type === oid4vci_common_1.GrantTypes.AUTHORIZATION_CODE && isPreAuth) {
|
|
95
|
+
throw Error('A pre_authorized_code flow cannot have an issuer state in the credential offer');
|
|
91
96
|
}
|
|
92
97
|
return request;
|
|
93
98
|
});
|
|
@@ -103,27 +108,14 @@ class AccessTokenClient {
|
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
110
|
isPinRequiredValue(requestPayload) {
|
|
111
|
+
var _a, _b, _c;
|
|
106
112
|
let isPinRequired = false;
|
|
107
113
|
if (!requestPayload) {
|
|
108
114
|
throw new Error(oid4vci_common_1.TokenErrorResponse.invalid_request);
|
|
109
115
|
}
|
|
110
116
|
const issuer = (0, oid4vci_common_1.getIssuerFromCredentialOfferPayload)(requestPayload);
|
|
111
|
-
if ((
|
|
112
|
-
|
|
113
|
-
if (typeof requestPayload.user_pin_required === 'string') {
|
|
114
|
-
isPinRequired = requestPayload.user_pin_required.toLowerCase() === 'true';
|
|
115
|
-
}
|
|
116
|
-
else if (typeof requestPayload.user_pin_required === 'boolean') {
|
|
117
|
-
isPinRequired = requestPayload.user_pin_required;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
else if ((0, oid4vci_common_1.isCredentialOfferV1_0_11)(requestPayload)) {
|
|
121
|
-
requestPayload = requestPayload;
|
|
122
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
123
|
-
if ('grants' in requestPayload && 'urn:ietf:params:oauth:grant-type:pre-authorized_code' in requestPayload.grants) {
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
125
|
-
isPinRequired = requestPayload.grants['urn:ietf:params:oauth:grant-type:pre-authorized_code'].user_pin_required;
|
|
126
|
-
}
|
|
117
|
+
if ((_a = requestPayload.grants) === null || _a === void 0 ? void 0 : _a['urn:ietf:params:oauth:grant-type:pre-authorized_code']) {
|
|
118
|
+
isPinRequired = (_c = (_b = requestPayload.grants['urn:ietf:params:oauth:grant-type:pre-authorized_code']) === null || _b === void 0 ? void 0 : _b.user_pin_required) !== null && _c !== void 0 ? _c : false;
|
|
127
119
|
}
|
|
128
120
|
debug(`Pin required for issuer ${issuer}: ${isPinRequired}`);
|
|
129
121
|
return isPinRequired;
|
|
@@ -210,12 +202,12 @@ class AccessTokenClient {
|
|
|
210
202
|
}
|
|
211
203
|
static creatTokenURLFromURL(url, allowInsecureEndpoints, tokenEndpoint) {
|
|
212
204
|
if (allowInsecureEndpoints !== true && url.startsWith('http://')) {
|
|
213
|
-
throw Error(`Unprotected token endpoints are not allowed ${url}`);
|
|
205
|
+
throw Error(`Unprotected token endpoints are not allowed ${url}. Adjust settings if you really need this (dev/test settings only!!)`);
|
|
214
206
|
}
|
|
215
207
|
const hostname = url.replace(/https?:\/\//, '').replace(/\/$/, '');
|
|
216
208
|
const endpoint = tokenEndpoint ? (tokenEndpoint.startsWith('/') ? tokenEndpoint : tokenEndpoint.substring(1)) : '/token';
|
|
217
|
-
|
|
218
|
-
return
|
|
209
|
+
const scheme = url.split('://')[0];
|
|
210
|
+
return `${scheme ? scheme + '://' : 'https://'}${hostname}${endpoint}`;
|
|
219
211
|
}
|
|
220
212
|
throwNotSupportedFlow() {
|
|
221
213
|
debug(`Only pre-authorized flow supported.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessTokenClient.js","sourceRoot":"","sources":["../lib/AccessTokenClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"AccessTokenClient.js","sourceRoot":"","sources":["../lib/AccessTokenClient.ts"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GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,UAAU,GAAG,QAAQ,GAAG,QAAQ,EAAE,CAAC;IACzE,CAAC;IAEO,qBAAqB;QAC3B,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;CACF;AA3ND,8CA2NC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AuthorizationDetailsJwtVcJson,
|
|
1
|
+
import { AuthorizationDetailsJwtVcJson, OID4VCICredentialFormat } from '@sphereon/oid4vci-common';
|
|
2
2
|
export declare class AuthorizationDetailsBuilder {
|
|
3
3
|
private readonly authorizationDetails;
|
|
4
4
|
constructor();
|
|
5
5
|
withType(type: string): AuthorizationDetailsBuilder;
|
|
6
|
-
withFormats(format:
|
|
6
|
+
withFormats(format: OID4VCICredentialFormat): AuthorizationDetailsBuilder;
|
|
7
7
|
withLocations(locations: string[]): AuthorizationDetailsBuilder;
|
|
8
8
|
addLocation(location: string): AuthorizationDetailsBuilder;
|
|
9
9
|
buildJwtVcJson(): AuthorizationDetailsJwtVcJson;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorizationDetailsBuilder.d.ts","sourceRoot":"","sources":["../lib/AuthorizationDetailsBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,
|
|
1
|
+
{"version":3,"file":"AuthorizationDetailsBuilder.d.ts","sourceRoot":"","sources":["../lib/AuthorizationDetailsBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAGlG,qBAAa,2BAA2B;IACtC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAyC;;IAM9E,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,2BAA2B;IAKnD,WAAW,CAAC,MAAM,EAAE,uBAAuB,GAAG,2BAA2B;IAKzE,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,2BAA2B;IAS/D,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,2BAA2B;IAU1D,cAAc,IAAI,6BAA6B;CAMhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorizationDetailsBuilder.js","sourceRoot":"","sources":["../lib/AuthorizationDetailsBuilder.ts"],"names":[],"mappings":";;;AAEA,sEAAsE;AACtE,MAAa,2BAA2B;IAGtC;QACE,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;IACjC,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,IAAI,CAAC,oBAAoB,CAAC,IAAI,GAAG,IAAI,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"AuthorizationDetailsBuilder.js","sourceRoot":"","sources":["../lib/AuthorizationDetailsBuilder.ts"],"names":[],"mappings":";;;AAEA,sEAAsE;AACtE,MAAa,2BAA2B;IAGtC;QACE,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;IACjC,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,IAAI,CAAC,oBAAoB,CAAC,IAAI,GAAG,IAAI,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,MAA+B;QACzC,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,MAAM,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,SAAmB;QAC/B,IAAI,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE;YACvC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;SACxD;aAAM;YACL,IAAI,CAAC,oBAAoB,CAAC,SAAS,GAAG,SAAS,CAAC;SACjD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,QAAgB;QAC1B,IAAI,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE;YACvC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACpD;aAAM;YACL,IAAI,CAAC,oBAAoB,CAAC,SAAS,GAAG,CAAC,QAAQ,CAAC,CAAC;SAClD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0JAA0J;IAC1J,cAAc;QACZ,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,IAAI,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE;YACtE,OAAO,IAAI,CAAC,oBAAqD,CAAC;SACnE;QACD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;CACF;AA1CD,kEA0CC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CredentialOfferRequestWithBaseUrl, OpenId4VCIVersion } from '@sphereon/oid4vci-common';
|
|
2
|
+
export declare class CredentialOfferClient {
|
|
3
|
+
static fromURI(uri: string, opts?: {
|
|
4
|
+
resolve?: boolean;
|
|
5
|
+
}): Promise<CredentialOfferRequestWithBaseUrl>;
|
|
6
|
+
static toURI(requestWithBaseUrl: CredentialOfferRequestWithBaseUrl, opts?: {
|
|
7
|
+
version?: OpenId4VCIVersion;
|
|
8
|
+
}): string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=CredentialOfferClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialOfferClient.d.ts","sourceRoot":"","sources":["../lib/CredentialOfferClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iCAAiC,EAGjC,iBAAiB,EAElB,MAAM,0BAA0B,CAAC;AAOlC,qBAAa,qBAAqB;WACZ,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,iCAAiC,CAAC;WAwCpG,KAAK,CACjB,kBAAkB,EAAE,iCAAiC,EACrD,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,iBAAiB,CAAC;KAC7B,GACA,MAAM;CAsCV"}
|
|
@@ -0,0 +1,97 @@
|
|
|
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.CredentialOfferClient = void 0;
|
|
16
|
+
const oid4vci_common_1 = require("@sphereon/oid4vci-common");
|
|
17
|
+
const debug_1 = __importDefault(require("debug"));
|
|
18
|
+
const functions_1 = require("./functions");
|
|
19
|
+
const debug = (0, debug_1.default)('sphereon:openid4vci:initiation');
|
|
20
|
+
class CredentialOfferClient {
|
|
21
|
+
static fromURI(uri, opts) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
debug(`Credential Offer URI: ${uri}`);
|
|
24
|
+
if (!uri.includes('?') || !uri.includes('://')) {
|
|
25
|
+
debug(`Invalid Credential Offer URI: ${uri}`);
|
|
26
|
+
throw Error(`Invalid Credential Offer Request`);
|
|
27
|
+
}
|
|
28
|
+
const scheme = uri.split('://')[0];
|
|
29
|
+
const baseUrl = uri.split('?')[0];
|
|
30
|
+
const version = (0, oid4vci_common_1.determineSpecVersionFromURI)(uri);
|
|
31
|
+
let credentialOffer;
|
|
32
|
+
let credentialOfferPayload;
|
|
33
|
+
if (version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11) {
|
|
34
|
+
credentialOfferPayload = (0, functions_1.convertURIToJsonObject)(uri, {
|
|
35
|
+
arrayTypeProperties: ['credential_type'],
|
|
36
|
+
requiredProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri'] : ['issuer', 'credential_type'],
|
|
37
|
+
});
|
|
38
|
+
credentialOffer = {
|
|
39
|
+
credential_offer: credentialOfferPayload,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
credentialOffer = (0, functions_1.convertURIToJsonObject)(uri, {
|
|
44
|
+
arrayTypeProperties: ['credentials'],
|
|
45
|
+
requiredProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri'] : ['credential_offer'],
|
|
46
|
+
});
|
|
47
|
+
if ((credentialOffer === null || credentialOffer === void 0 ? void 0 : credentialOffer.credential_offer_uri) === undefined && !(credentialOffer === null || credentialOffer === void 0 ? void 0 : credentialOffer.credential_offer)) {
|
|
48
|
+
throw Error('Either a credential_offer or credential_offer_uri should be present in ' + uri);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const request = yield (0, oid4vci_common_1.toUniformCredentialOfferRequest)(credentialOffer, Object.assign(Object.assign({}, opts), { version }));
|
|
52
|
+
return Object.assign({ scheme,
|
|
53
|
+
baseUrl }, request);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
static toURI(requestWithBaseUrl, opts) {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
debug(`Credential Offer Request with base URL: ${JSON.stringify(requestWithBaseUrl)}`);
|
|
59
|
+
const version = (_a = opts === null || opts === void 0 ? void 0 : opts.version) !== null && _a !== void 0 ? _a : requestWithBaseUrl.version;
|
|
60
|
+
let baseUrl = requestWithBaseUrl.baseUrl.includes(requestWithBaseUrl.scheme)
|
|
61
|
+
? requestWithBaseUrl.baseUrl
|
|
62
|
+
: `${requestWithBaseUrl.scheme.replace('://', '')}://${requestWithBaseUrl.baseUrl}`;
|
|
63
|
+
let param;
|
|
64
|
+
const isUri = requestWithBaseUrl.credential_offer_uri !== undefined;
|
|
65
|
+
if (version.valueOf() >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11.valueOf()) {
|
|
66
|
+
// v11 changed from encoding every param to a encoded json object with a credential_offer param key
|
|
67
|
+
if (!baseUrl.includes('?')) {
|
|
68
|
+
param = isUri ? 'credential_offer_uri' : 'credential_offer';
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const split = baseUrl.split('?');
|
|
72
|
+
if (split.length > 1 && split[1] !== '') {
|
|
73
|
+
if (baseUrl.endsWith('&')) {
|
|
74
|
+
param = isUri ? 'credential_offer_uri' : 'credential_offer';
|
|
75
|
+
}
|
|
76
|
+
else if (!baseUrl.endsWith('=')) {
|
|
77
|
+
baseUrl += `&`;
|
|
78
|
+
param = isUri ? 'credential_offer_uri' : 'credential_offer';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return (0, functions_1.convertJsonToURI)((_b = requestWithBaseUrl.credential_offer_uri) !== null && _b !== void 0 ? _b : requestWithBaseUrl.original_credential_offer, {
|
|
84
|
+
baseUrl,
|
|
85
|
+
arrayTypeProperties: isUri ? [] : ['credential_type'],
|
|
86
|
+
uriTypeProperties: isUri
|
|
87
|
+
? ['credential_offer_uri']
|
|
88
|
+
: version >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11
|
|
89
|
+
? ['credential_issuer', 'credential_type']
|
|
90
|
+
: ['issuer', 'credential_type'],
|
|
91
|
+
param,
|
|
92
|
+
version,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.CredentialOfferClient = CredentialOfferClient;
|
|
97
|
+
//# sourceMappingURL=CredentialOfferClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialOfferClient.js","sourceRoot":"","sources":["../lib/CredentialOfferClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DASkC;AAClC,kDAA0B;AAE1B,2CAAuE;AAEvE,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,gCAAgC,CAAC,CAAC;AAEtD,MAAa,qBAAqB;IACzB,MAAM,CAAO,OAAO,CAAC,GAAW,EAAE,IAA4B;;YACnE,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;YACtC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBAC9C,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;gBAC9C,MAAM,KAAK,CAAC,kCAAkC,CAAC,CAAC;aACjD;YACD,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACnC,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,OAAO,GAAG,IAAA,4CAA2B,EAAC,GAAG,CAAC,CAAC;YACjD,IAAI,eAAgC,CAAC;YACrC,IAAI,sBAA8C,CAAC;YACnD,IAAI,OAAO,GAAG,kCAAiB,CAAC,UAAU,EAAE;gBAC1C,sBAAsB,GAAG,IAAA,kCAAsB,EAAC,GAAG,EAAE;oBACnD,mBAAmB,EAAE,CAAC,iBAAiB,CAAC;oBACxC,kBAAkB,EAAE,GAAG,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,C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C,CAAC,CAAC,CAAC,mBAAmB,EAAE,iBAAiB,CAAC;oBAC1C,CAAC,CAAC,CAAC,QAAQ,EAAE,iBAAiB,CAAC;YACjC,KAAK;YACL,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF;AApFD,sDAoFC"}
|
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CredentialResponse, OID4VCICredentialFormat, OpenId4VCIVersion, OpenIDResponse, ProofOfPossession, UniformCredentialRequest } from '@sphereon/oid4vci-common';
|
|
2
2
|
import { CredentialFormat } from '@sphereon/ssi-types';
|
|
3
|
-
import {
|
|
3
|
+
import { CredentialRequestClientBuilder } from './CredentialRequestClientBuilder';
|
|
4
4
|
import { ProofOfPossessionBuilder } from './ProofOfPossessionBuilder';
|
|
5
5
|
export interface CredentialRequestOpts {
|
|
6
6
|
credentialEndpoint: string;
|
|
7
|
-
|
|
8
|
-
format
|
|
7
|
+
credentialTypes: string[];
|
|
8
|
+
format?: CredentialFormat | OID4VCICredentialFormat;
|
|
9
9
|
proof: ProofOfPossession;
|
|
10
10
|
token: string;
|
|
11
|
+
version?: OpenId4VCIVersion;
|
|
11
12
|
}
|
|
12
13
|
export declare class CredentialRequestClient {
|
|
13
14
|
private readonly _credentialRequestOpts;
|
|
14
15
|
get credentialRequestOpts(): CredentialRequestOpts;
|
|
15
16
|
getCredentialEndpoint(): string;
|
|
16
|
-
constructor(builder:
|
|
17
|
-
acquireCredentialsUsingProof(
|
|
17
|
+
constructor(builder: CredentialRequestClientBuilder);
|
|
18
|
+
acquireCredentialsUsingProof(opts: {
|
|
18
19
|
proofInput: ProofOfPossessionBuilder | ProofOfPossession;
|
|
19
|
-
|
|
20
|
-
format?: CredentialFormat |
|
|
20
|
+
credentialTypes?: string | string[];
|
|
21
|
+
format?: CredentialFormat | OID4VCICredentialFormat;
|
|
21
22
|
}): Promise<OpenIDResponse<CredentialResponse>>;
|
|
22
|
-
acquireCredentialsUsingRequest(
|
|
23
|
-
createCredentialRequest(
|
|
23
|
+
acquireCredentialsUsingRequest(uniformRequest: UniformCredentialRequest): Promise<OpenIDResponse<CredentialResponse>>;
|
|
24
|
+
createCredentialRequest(opts: {
|
|
24
25
|
proofInput: ProofOfPossessionBuilder | ProofOfPossession;
|
|
25
|
-
|
|
26
|
-
format?: CredentialFormat |
|
|
27
|
-
}): Promise<
|
|
26
|
+
credentialTypes?: string | string[];
|
|
27
|
+
format?: CredentialFormat | OID4VCICredentialFormat;
|
|
28
|
+
}): Promise<UniformCredentialRequest>;
|
|
29
|
+
private isV11OrHigher;
|
|
28
30
|
}
|
|
29
31
|
//# sourceMappingURL=CredentialRequestClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialRequestClient.d.ts","sourceRoot":"","sources":["../lib/CredentialRequestClient.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CredentialRequestClient.d.ts","sourceRoot":"","sources":["../lib/CredentialRequestClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,wBAAwB,EAEzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAKtE,MAAM,WAAW,qBAAqB;IACpC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,gBAAgB,GAAG,uBAAuB,CAAC;IACpD,KAAK,EAAE,iBAAiB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AAED,qBAAa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAiC;IAExE,IAAI,qBAAqB,IAAI,qBAAqB,CAEjD;IAEM,qBAAqB,IAAI,MAAM;gBAInB,OAAO,EAAE,8BAA8B;IAI7C,4BAA4B,CAAC,IAAI,EAAE;QAC9C,UAAU,EAAE,wBAAwB,GAAG,iBAAiB,CAAC;QACzD,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACpC,MAAM,CAAC,EAAE,gBAAgB,GAAG,uBAAuB,CAAC;KACrD,GAAG,OAAO,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAOlC,8BAA8B,CAAC,cAAc,EAAE,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAqBrH,uBAAuB,CAAC,IAAI,EAAE;QACzC,UAAU,EAAE,wBAAwB,GAAG,iBAAiB,CAAC;QACzD,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACpC,MAAM,CAAC,EAAE,gBAAgB,GAAG,uBAAuB,CAAC;KACrD,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA+BrC,OAAO,CAAC,aAAa;CAGtB"}
|
|
@@ -28,14 +28,23 @@ class CredentialRequestClient {
|
|
|
28
28
|
constructor(builder) {
|
|
29
29
|
this._credentialRequestOpts = Object.assign({}, builder);
|
|
30
30
|
}
|
|
31
|
-
acquireCredentialsUsingProof(
|
|
31
|
+
acquireCredentialsUsingProof(opts) {
|
|
32
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const
|
|
33
|
+
const { credentialTypes, proofInput, format } = opts;
|
|
34
|
+
const request = yield this.createCredentialRequest({ proofInput, credentialTypes, format });
|
|
34
35
|
return yield this.acquireCredentialsUsingRequest(request);
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
|
-
acquireCredentialsUsingRequest(
|
|
38
|
+
acquireCredentialsUsingRequest(uniformRequest) {
|
|
38
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
let request = uniformRequest;
|
|
41
|
+
if (!this.isV11OrHigher()) {
|
|
42
|
+
request = {
|
|
43
|
+
format: uniformRequest.format,
|
|
44
|
+
proof: uniformRequest.proof,
|
|
45
|
+
type: 'types' in uniformRequest ? uniformRequest.types[0] : uniformRequest.credential_definition.types[0],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
39
48
|
const credentialEndpoint = this.credentialRequestOpts.credentialEndpoint;
|
|
40
49
|
if (!(0, functions_1.isValidURL)(credentialEndpoint)) {
|
|
41
50
|
debug(`Invalid credential endpoint: ${credentialEndpoint}`);
|
|
@@ -48,16 +57,39 @@ class CredentialRequestClient {
|
|
|
48
57
|
return response;
|
|
49
58
|
});
|
|
50
59
|
}
|
|
51
|
-
createCredentialRequest(
|
|
60
|
+
createCredentialRequest(opts) {
|
|
61
|
+
var _a;
|
|
52
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const { proofInput } = opts;
|
|
64
|
+
const formatSelection = (_a = opts.format) !== null && _a !== void 0 ? _a : this.credentialRequestOpts.format;
|
|
65
|
+
const format = (formatSelection === 'jwt_vc' || formatSelection === 'jwt' ? 'jwt_vc_json_ld' : formatSelection);
|
|
66
|
+
if (!format) {
|
|
67
|
+
throw Error(`Format of credential to be issued is missing`);
|
|
68
|
+
}
|
|
69
|
+
else if (format !== 'jwt_vc_json_ld' && format !== 'jwt_vc_json' && format !== 'ldp_vc') {
|
|
70
|
+
throw Error(`Invalid format of credential to be issued: ${format}`);
|
|
71
|
+
}
|
|
72
|
+
const typesSelection = (opts === null || opts === void 0 ? void 0 : opts.credentialTypes) && (typeof opts.credentialTypes === 'string' || opts.credentialTypes.length > 0)
|
|
73
|
+
? opts.credentialTypes
|
|
74
|
+
: this.credentialRequestOpts.credentialTypes;
|
|
75
|
+
const types = Array.isArray(typesSelection) ? typesSelection : [typesSelection];
|
|
76
|
+
if (types.length === 0) {
|
|
77
|
+
throw Error(`Credential type(s) need to be provided`);
|
|
78
|
+
}
|
|
79
|
+
else if (!this.isV11OrHigher() && types.length !== 1) {
|
|
80
|
+
throw Error('Only a single credential type is supported for V8/V9');
|
|
81
|
+
}
|
|
53
82
|
const proof = 'proof_type' in proofInput ? yield ProofOfPossessionBuilder_1.ProofOfPossessionBuilder.fromProof(proofInput).build() : yield proofInput.build();
|
|
54
83
|
return {
|
|
55
|
-
|
|
56
|
-
format
|
|
84
|
+
types,
|
|
85
|
+
format,
|
|
57
86
|
proof,
|
|
58
87
|
};
|
|
59
88
|
});
|
|
60
89
|
}
|
|
90
|
+
isV11OrHigher() {
|
|
91
|
+
return !this.credentialRequestOpts.version || this.credentialRequestOpts.version >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11;
|
|
92
|
+
}
|
|
61
93
|
}
|
|
62
94
|
exports.CredentialRequestClient = CredentialRequestClient;
|
|
63
95
|
//# sourceMappingURL=CredentialRequestClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialRequestClient.js","sourceRoot":"","sources":["../lib/CredentialRequestClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"CredentialRequestClient.js","sourceRoot":"","sources":["../lib/CredentialRequestClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DASkC;AAElC,kDAA0B;AAG1B,yEAAsE;AACtE,2CAA+C;AAE/C,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,gCAAgC,CAAC,CAAC;AAWtD,MAAa,uBAAuB;IAGlC,IAAI,qBAAqB;QACvB,OAAO,IAAI,CAAC,sBAA+C,CAAC;IAC9D,CAAC;IAEM,qBAAqB;QAC1B,OAAO,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC;IACvD,CAAC;IAED,YAAmB,OAAuC;QACxD,IAAI,CAAC,sBAAsB,qBAAQ,OAAO,CAAE,CAAC;IAC/C,CAAC;IAEY,4BAA4B,CAAC,IAIzC;;YACC,MAAM,EAAE,eAAe,EAAE,UAAU,EA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AAC,CAAC,MAAM,mDAAwB,CAAC,SAAS,CAAC,UAA+B,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;YAC5I,OAAO;gBACL,KAAK;gBACL,MAAM;gBACN,KAAK;aACsB,CAAC;;KAC/B;IAEO,aAAa;QACnB,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,IAAI,kCAAiB,CAAC,UAAU,CAAC;IACnH,CAAC;CACF;AArFD,0DAqFC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AccessTokenResponse, CredentialIssuerMetadata, CredentialOfferRequestWithBaseUrl, EndpointMetadata, OID4VCICredentialFormat, OpenId4VCIVersion, UniformCredentialOfferRequest } from '@sphereon/oid4vci-common';
|
|
2
|
+
import { CredentialFormat } from '@sphereon/ssi-types';
|
|
3
|
+
import { CredentialRequestClient } from './CredentialRequestClient';
|
|
4
|
+
export declare class CredentialRequestClientBuilder {
|
|
5
|
+
credentialEndpoint?: string;
|
|
6
|
+
credentialTypes: string[];
|
|
7
|
+
format?: CredentialFormat | OID4VCICredentialFormat;
|
|
8
|
+
token?: string;
|
|
9
|
+
version?: OpenId4VCIVersion;
|
|
10
|
+
static fromURI({ uri, metadata }: {
|
|
11
|
+
uri: string;
|
|
12
|
+
metadata?: EndpointMetadata;
|
|
13
|
+
}): Promise<CredentialRequestClientBuilder>;
|
|
14
|
+
static fromCredentialOfferRequest(opts: {
|
|
15
|
+
request: UniformCredentialOfferRequest;
|
|
16
|
+
scheme?: string;
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
version?: OpenId4VCIVersion;
|
|
19
|
+
metadata?: EndpointMetadata;
|
|
20
|
+
}): CredentialRequestClientBuilder;
|
|
21
|
+
static fromCredentialOffer({ credentialOffer, metadata, }: {
|
|
22
|
+
credentialOffer: CredentialOfferRequestWithBaseUrl;
|
|
23
|
+
metadata?: EndpointMetadata;
|
|
24
|
+
}): CredentialRequestClientBuilder;
|
|
25
|
+
withCredentialEndpointFromMetadata(metadata: CredentialIssuerMetadata): CredentialRequestClientBuilder;
|
|
26
|
+
withCredentialEndpoint(credentialEndpoint: string): CredentialRequestClientBuilder;
|
|
27
|
+
withCredentialType(credentialTypes: string | string[]): CredentialRequestClientBuilder;
|
|
28
|
+
withFormat(format: CredentialFormat | OID4VCICredentialFormat): CredentialRequestClientBuilder;
|
|
29
|
+
withToken(accessToken: string): CredentialRequestClientBuilder;
|
|
30
|
+
withTokenFromResponse(response: AccessTokenResponse): CredentialRequestClientBuilder;
|
|
31
|
+
withVersion(version: OpenId4VCIVersion): CredentialRequestClientBuilder;
|
|
32
|
+
build(): CredentialRequestClient;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=CredentialRequestClientBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialRequestClientBuilder.d.ts","sourceRoot":"","sources":["../lib/CredentialRequestClientBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EAExB,iCAAiC,EAEjC,gBAAgB,EAEhB,uBAAuB,EACvB,iBAAiB,EACjB,6BAA6B,EAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,qBAAa,8BAA8B;IACzC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,EAAE,CAAM;IAC/B,MAAM,CAAC,EAAE,gBAAgB,GAAG,uBAAuB,CAAC;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,iBAAiB,CAAC;WAER,OAAO,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAA;KAAE,GAAG,OAAO,CAAC,8BAA8B,CAAC;WAKvH,0BAA0B,CAAC,IAAI,EAAE;QAC7C,OAAO,EAAE,6BAA6B,CAAC;QACvC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,iBAAiB,CAAC;QAC5B,QAAQ,CAAC,EAAE,gBAAgB,CAAC;KAC7B,GAAG,8BAA8B;WAmBpB,mBAAmB,CAAC,EAChC,eAAe,EACf,QAAQ,GACT,EAAE;QACD,eAAe,EAAE,iCAAiC,CAAC;QACnD,QAAQ,CAAC,EAAE,gBAAgB,CAAC;KAC7B,GAAG,8BAA8B;IAO3B,kCAAkC,CAAC,QAAQ,EAAE,wBAAwB,GAAG,8BAA8B;IAKtG,sBAAsB,CAAC,kBAAkB,EAAE,MAAM,GAAG,8BAA8B;IAKlF,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,8BAA8B;IAKtF,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,uBAAuB,GAAG,8BAA8B;IAK9F,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,8BAA8B;IAK9D,qBAAqB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,8BAA8B;IAKpF,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,8BAA8B;IAKvE,KAAK,IAAI,uBAAuB;CAMxC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CredentialRequestClientBuilder = void 0;
|
|
13
|
+
const oid4vci_common_1 = require("@sphereon/oid4vci-common");
|
|
14
|
+
const CredentialOfferClient_1 = require("./CredentialOfferClient");
|
|
15
|
+
const CredentialRequestClient_1 = require("./CredentialRequestClient");
|
|
16
|
+
class CredentialRequestClientBuilder {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.credentialTypes = [];
|
|
19
|
+
}
|
|
20
|
+
static fromURI({ uri, metadata }) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const offer = yield CredentialOfferClient_1.CredentialOfferClient.fromURI(uri);
|
|
23
|
+
return CredentialRequestClientBuilder.fromCredentialOfferRequest(Object.assign(Object.assign({ request: offer }, offer), { metadata }));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
static fromCredentialOfferRequest(opts) {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
const { request, metadata } = opts;
|
|
29
|
+
const version = (_a = opts.version) !== null && _a !== void 0 ? _a : (0, oid4vci_common_1.determineSpecVersionFromOffer)(request);
|
|
30
|
+
const builder = new CredentialRequestClientBuilder();
|
|
31
|
+
const issuer = (_b = (0, oid4vci_common_1.getIssuerFromCredentialOfferPayload)(request.credential_offer)) !== null && _b !== void 0 ? _b : metadata === null || metadata === void 0 ? void 0 : metadata.issuer;
|
|
32
|
+
builder.withVersion(version);
|
|
33
|
+
builder.withCredentialEndpoint((_c = metadata === null || metadata === void 0 ? void 0 : metadata.credential_endpoint) !== null && _c !== void 0 ? _c : (issuer.endsWith('/') ? `${issuer}credential` : `${issuer}/credential`));
|
|
34
|
+
if (version <= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_08) {
|
|
35
|
+
//todo: This basically sets all types available during initiation. Probably the user only wants a subset. So do we want to do this?
|
|
36
|
+
builder.withCredentialType(request.original_credential_offer.credential_type);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// todo: look whether this is correct
|
|
40
|
+
builder.withCredentialType(request.credential_offer.credentials.flatMap((c) => (typeof c === 'string' ? c : c.types)));
|
|
41
|
+
}
|
|
42
|
+
return builder;
|
|
43
|
+
}
|
|
44
|
+
static fromCredentialOffer({ credentialOffer, metadata, }) {
|
|
45
|
+
return CredentialRequestClientBuilder.fromCredentialOfferRequest({
|
|
46
|
+
request: credentialOffer,
|
|
47
|
+
metadata,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
withCredentialEndpointFromMetadata(metadata) {
|
|
51
|
+
this.credentialEndpoint = metadata.credential_endpoint;
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
withCredentialEndpoint(credentialEndpoint) {
|
|
55
|
+
this.credentialEndpoint = credentialEndpoint;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
withCredentialType(credentialTypes) {
|
|
59
|
+
this.credentialTypes = Array.isArray(credentialTypes) ? credentialTypes : [credentialTypes];
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
withFormat(format) {
|
|
63
|
+
this.format = format;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
withToken(accessToken) {
|
|
67
|
+
this.token = accessToken;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
withTokenFromResponse(response) {
|
|
71
|
+
this.token = response.access_token;
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
withVersion(version) {
|
|
75
|
+
this.version = version;
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
build() {
|
|
79
|
+
if (!this.version) {
|
|
80
|
+
this.withVersion(oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11);
|
|
81
|
+
}
|
|
82
|
+
return new CredentialRequestClient_1.CredentialRequestClient(this);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.CredentialRequestClientBuilder = CredentialRequestClientBuilder;
|
|
86
|
+
//# sourceMappingURL=CredentialRequestClientBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialRequestClientBuilder.js","sourceRoot":"","sources":["../lib/CredentialRequestClientBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAWkC;AAGlC,mEAAgE;AAChE,uEAAoE;AAEpE,MAAa,8BAA8B;IAA3C;QAEE,oBAAe,GAAa,EAAE,CAAC;IAyFjC,CAAC;IApFQ,MAAM,CAAO,OAAO,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAgD;;YACzF,MAAM,KAAK,GAAG,MAAM,6CAAqB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACvD,OAAO,8BAA8B,CAAC,0BAA0B,+BAAG,OAAO,EAAE,KAAK,IAAK,KAAK,KAAE,QAAQ,IAAG,CAAC;QAC3G,CAAC;KAAA;IAEM,MAAM,CAAC,0BAA0B,CAAC,IAMxC;;QACC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QACnC,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,OAAO,mCAAI,IAAA,8CAA6B,EAAC,OAAO,CAAC,CAAC;QACvE,MAAM,OAAO,GAAG,IAAI,8BAA8B,EAAE,CAAC;QACrD,MAAM,MAAM,GAAG,MAAA,IAAA,oDAAmC,EAAC,OAAO,CAAC,gBAAgB,CAAC,mCAAK,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAiB,CAAC;QAC7G,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC7B,OAAO,CAAC,sBAAsB,CAAC,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,mBAAmB,mCAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG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