@sphereon/oid4vci-client 0.10.3-next.8 → 0.10.4-next.119
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 +24 -5
- package/dist/AccessTokenClient.d.ts +5 -5
- package/dist/AccessTokenClient.d.ts.map +1 -1
- package/dist/AccessTokenClient.js +51 -37
- package/dist/AccessTokenClient.js.map +1 -1
- package/dist/AccessTokenClientV1_0_11.d.ts +29 -0
- package/dist/AccessTokenClientV1_0_11.d.ts.map +1 -0
- package/dist/AccessTokenClientV1_0_11.js +209 -0
- package/dist/AccessTokenClientV1_0_11.js.map +1 -0
- package/dist/AuthorizationCodeClient.d.ts +9 -4
- package/dist/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/AuthorizationCodeClient.js +102 -18
- package/dist/AuthorizationCodeClient.js.map +1 -1
- package/dist/AuthorizationCodeClientV1_0_11.d.ts +9 -0
- package/dist/AuthorizationCodeClientV1_0_11.d.ts.map +1 -0
- package/dist/AuthorizationCodeClientV1_0_11.js +134 -0
- package/dist/AuthorizationCodeClientV1_0_11.js.map +1 -0
- package/dist/CredentialOfferClient.d.ts.map +1 -1
- package/dist/CredentialOfferClient.js +18 -13
- package/dist/CredentialOfferClient.js.map +1 -1
- package/dist/CredentialOfferClientV1_0_11.d.ts +10 -0
- package/dist/CredentialOfferClientV1_0_11.d.ts.map +1 -0
- package/dist/CredentialOfferClientV1_0_11.js +101 -0
- package/dist/CredentialOfferClientV1_0_11.js.map +1 -0
- 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.d.ts +20 -7
- package/dist/CredentialRequestClient.d.ts.map +1 -1
- package/dist/CredentialRequestClient.js +46 -30
- package/dist/CredentialRequestClient.js.map +1 -1
- package/dist/CredentialRequestClientBuilder.d.ts +11 -6
- package/dist/CredentialRequestClientBuilder.d.ts.map +1 -1
- package/dist/CredentialRequestClientBuilder.js +22 -9
- package/dist/CredentialRequestClientBuilder.js.map +1 -1
- package/dist/CredentialRequestClientBuilderV1_0_11.d.ts +48 -0
- package/dist/CredentialRequestClientBuilderV1_0_11.d.ts.map +1 -0
- package/dist/CredentialRequestClientBuilderV1_0_11.js +121 -0
- package/dist/CredentialRequestClientBuilderV1_0_11.js.map +1 -0
- package/dist/CredentialRequestClientV1_0_11.d.ts +50 -0
- package/dist/CredentialRequestClientV1_0_11.d.ts.map +1 -0
- package/dist/CredentialRequestClientV1_0_11.js +151 -0
- package/dist/CredentialRequestClientV1_0_11.js.map +1 -0
- package/dist/MetadataClient.d.ts +5 -15
- package/dist/MetadataClient.d.ts.map +1 -1
- package/dist/MetadataClient.js +41 -44
- package/dist/MetadataClient.js.map +1 -1
- package/dist/MetadataClientV1_0_11.d.ts +31 -0
- package/dist/MetadataClientV1_0_11.d.ts.map +1 -0
- package/dist/MetadataClientV1_0_11.js +182 -0
- package/dist/MetadataClientV1_0_11.js.map +1 -0
- 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 +14 -19
- package/dist/OpenID4VCIClient.d.ts.map +1 -1
- package/dist/OpenID4VCIClient.js +111 -61
- package/dist/OpenID4VCIClient.js.map +1 -1
- package/dist/OpenID4VCIClientV1_0_11.d.ts +108 -0
- package/dist/OpenID4VCIClientV1_0_11.d.ts.map +1 -0
- package/dist/OpenID4VCIClientV1_0_11.js +449 -0
- package/dist/OpenID4VCIClientV1_0_11.js.map +1 -0
- 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 -21
- package/dist/ProofOfPossessionBuilder.js.map +1 -1
- package/dist/functions/OpenIDUtils.d.ts +12 -0
- package/dist/functions/OpenIDUtils.d.ts.map +1 -0
- package/dist/functions/OpenIDUtils.js +37 -0
- package/dist/functions/OpenIDUtils.js.map +1 -0
- package/dist/functions/index.d.ts +2 -3
- package/dist/functions/index.d.ts.map +1 -1
- package/dist/functions/index.js +2 -3
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/notifications.d.ts +4 -0
- package/dist/functions/notifications.d.ts.map +1 -0
- package/dist/functions/notifications.js +39 -0
- package/dist/functions/notifications.js.map +1 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -1
- package/lib/AccessTokenClient.ts +59 -34
- package/lib/AccessTokenClientV1_0_11.ts +250 -0
- package/lib/AuthorizationCodeClient.ts +131 -28
- package/lib/AuthorizationCodeClientV1_0_11.ts +170 -0
- package/lib/CredentialOfferClient.ts +21 -8
- package/lib/CredentialOfferClientV1_0_11.ts +112 -0
- package/lib/CredentialOfferClientV1_0_13.ts +103 -0
- package/lib/CredentialRequestClient.ts +65 -26
- package/lib/CredentialRequestClientBuilder.ts +34 -16
- package/lib/CredentialRequestClientBuilderV1_0_11.ts +163 -0
- package/lib/CredentialRequestClientV1_0_11.ts +197 -0
- package/lib/MetadataClient.ts +64 -49
- package/lib/MetadataClientV1_0_11.ts +189 -0
- package/lib/MetadataClientV1_0_13.ts +188 -0
- package/lib/OpenID4VCIClient.ts +132 -68
- package/lib/OpenID4VCIClientV1_0_11.ts +635 -0
- package/lib/OpenID4VCIClientV1_0_13.ts +677 -0
- package/lib/ProofOfPossessionBuilder.ts +41 -11
- package/lib/__tests__/AccessTokenClient.spec.ts +40 -12
- package/lib/__tests__/AuthorizationDetailsBuilder.spec.ts +0 -12
- package/lib/__tests__/CredentialRequestClient.spec.ts +87 -50
- package/lib/__tests__/CredentialRequestClientBuilder.spec.ts +18 -12
- package/lib/__tests__/CredentialRequestClientV1_0_11.spec.ts +317 -0
- package/lib/__tests__/EBSIE2E.spec.test.ts +2 -2
- package/lib/__tests__/HttpUtils.spec.ts +1 -1
- package/lib/__tests__/IT.spec.ts +264 -14
- package/lib/__tests__/IssuanceInitiation.spec.ts +59 -4
- package/lib/__tests__/IssuanceInitiationV1_0_11.spec.ts +62 -0
- package/lib/__tests__/MattrE2E.spec.test.ts +2 -2
- package/lib/__tests__/MetadataClient.spec.ts +53 -3
- package/lib/__tests__/MetadataMocks.ts +42 -2
- package/lib/__tests__/OpenID4VCIClient.spec.ts +58 -2
- package/lib/__tests__/{OpenID4VCIClientPAR.spec.ts → OpenID4VCIClientPARV1_0_11.spec.ts} +5 -5
- package/lib/__tests__/OpenID4VCIClientV1_0_11.spec.ts +226 -0
- package/lib/__tests__/OpenID4VCIClientV1_0_13.spec.ts +204 -0
- package/lib/__tests__/ProofOfPossessionBuilder.spec.ts +1 -1
- package/lib/__tests__/SdJwt.spec.ts +36 -30
- package/lib/__tests__/SphereonE2E.spec.test.ts +10 -7
- package/lib/__tests__/data/VciDataFixtures.ts +712 -27
- package/lib/functions/OpenIDUtils.ts +25 -0
- package/lib/functions/index.ts +2 -3
- package/lib/functions/notifications.ts +32 -0
- package/lib/index.ts +16 -1
- package/lib/types/index.ts +6 -0
- package/package.json +4 -4
- package/dist/functions/ProofUtil.d.ts +0 -30
- package/dist/functions/ProofUtil.d.ts.map +0 -1
- package/dist/functions/ProofUtil.js +0 -106
- package/dist/functions/ProofUtil.js.map +0 -1
- package/lib/functions/ProofUtil.ts +0 -128
|
@@ -12,35 +12,118 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.createAuthorizationRequestUrl = void 0;
|
|
15
|
+
exports.createAuthorizationRequestUrl = exports.createSignedAuthRequestWhenNeeded = void 0;
|
|
16
16
|
const oid4vci_common_1 = require("@sphereon/oid4vci-common");
|
|
17
17
|
const debug_1 = __importDefault(require("debug"));
|
|
18
|
+
const ProofOfPossessionBuilder_1 = require("./ProofOfPossessionBuilder");
|
|
18
19
|
const debug = (0, debug_1.default)('sphereon:oid4vci');
|
|
19
|
-
|
|
20
|
+
function createSignedAuthRequestWhenNeeded(requestObject, opts) {
|
|
20
21
|
var _a, _b, _c, _d;
|
|
21
|
-
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
if (opts.requestObjectMode === oid4vci_common_1.CreateRequestObjectMode.REQUEST_URI) {
|
|
24
|
+
throw Error(`Request Object Mode ${opts.requestObjectMode} is not supported yet`);
|
|
25
|
+
}
|
|
26
|
+
else if (opts.requestObjectMode === oid4vci_common_1.CreateRequestObjectMode.REQUEST_OBJECT) {
|
|
27
|
+
if (typeof ((_a = opts.signCallbacks) === null || _a === void 0 ? void 0 : _a.signCallback) !== 'function') {
|
|
28
|
+
throw Error(`No request object sign callback found, whilst request object mode was set to ${opts.requestObjectMode}`);
|
|
29
|
+
}
|
|
30
|
+
else if (!opts.kid) {
|
|
31
|
+
throw Error(`No kid found, whilst request object mode was set to ${opts.requestObjectMode}`);
|
|
32
|
+
}
|
|
33
|
+
let client_metadata;
|
|
34
|
+
if (opts.clientMetadata || opts.jwksUri) {
|
|
35
|
+
client_metadata = (_b = opts.clientMetadata) !== null && _b !== void 0 ? _b : {};
|
|
36
|
+
if (opts.jwksUri) {
|
|
37
|
+
client_metadata['jwks_uri'] = opts.jwksUri;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
let authorization_details = requestObject['authorization_details'];
|
|
41
|
+
if (typeof authorization_details === 'string') {
|
|
42
|
+
authorization_details = JSON.parse(requestObject.authorization_details);
|
|
43
|
+
}
|
|
44
|
+
if (!requestObject.aud && opts.aud) {
|
|
45
|
+
requestObject.aud = opts.aud;
|
|
46
|
+
}
|
|
47
|
+
const iss = (_d = (_c = requestObject.iss) !== null && _c !== void 0 ? _c : opts.iss) !== null && _d !== void 0 ? _d : requestObject.client_id;
|
|
48
|
+
const jwt = { header: { alg: 'ES256', kid: opts.kid, typ: 'jwt' }, payload: Object.assign(Object.assign(Object.assign({}, requestObject), { iss, authorization_details }), (client_metadata && { client_metadata })) };
|
|
49
|
+
const pop = yield ProofOfPossessionBuilder_1.ProofOfPossessionBuilder.fromJwt({
|
|
50
|
+
jwt,
|
|
51
|
+
callbacks: opts.signCallbacks,
|
|
52
|
+
version: oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11,
|
|
53
|
+
mode: 'jwt',
|
|
54
|
+
}).build();
|
|
55
|
+
requestObject['request'] = pop.jwt;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.createSignedAuthRequestWhenNeeded = createSignedAuthRequestWhenNeeded;
|
|
60
|
+
function filterSupportedCredentials(credentialOffer, credentialsSupported) {
|
|
61
|
+
if (!credentialOffer.credential_configuration_ids || !credentialsSupported) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
return Object.entries(credentialsSupported)
|
|
65
|
+
.filter((entry) => { var _a; return (_a = credentialOffer.credential_configuration_ids) === null || _a === void 0 ? void 0 : _a.includes(entry[0]); })
|
|
66
|
+
.map((entry) => {
|
|
67
|
+
return Object.assign(Object.assign({}, entry[1]), { configuration_id: entry[0] });
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const createAuthorizationRequestUrl = ({ pkce, endpointMetadata, authorizationRequest, credentialOffer, credentialConfigurationSupported, clientId, version, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
var _a, _b, _c, _d, _e;
|
|
72
|
+
function removeDisplayAndValueTypes(obj) {
|
|
73
|
+
for (const prop in obj) {
|
|
74
|
+
if (['display', 'value_type'].includes(prop)) {
|
|
75
|
+
delete obj[prop];
|
|
76
|
+
}
|
|
77
|
+
else if (typeof obj[prop] === 'object') {
|
|
78
|
+
removeDisplayAndValueTypes(obj[prop]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const { redirectUri, requestObjectOpts = { requestObjectMode: oid4vci_common_1.CreateRequestObjectMode.NONE } } = authorizationRequest;
|
|
83
|
+
const client_id = clientId !== null && clientId !== void 0 ? clientId : authorizationRequest.clientId;
|
|
22
84
|
let { scope, authorizationDetails } = authorizationRequest;
|
|
23
85
|
const parMode = ((_a = endpointMetadata === null || endpointMetadata === void 0 ? void 0 : endpointMetadata.credentialIssuerMetadata) === null || _a === void 0 ? void 0 : _a.require_pushed_authorization_requests)
|
|
24
86
|
? oid4vci_common_1.PARMode.REQUIRE
|
|
25
|
-
: (_b = authorizationRequest.parMode) !== null && _b !== void 0 ? _b : oid4vci_common_1.PARMode.AUTO;
|
|
87
|
+
: (_b = authorizationRequest.parMode) !== null && _b !== void 0 ? _b : (client_id ? oid4vci_common_1.PARMode.AUTO : oid4vci_common_1.PARMode.NEVER);
|
|
26
88
|
// Scope and authorization_details can be used in the same authorization request
|
|
27
89
|
// https://datatracker.ietf.org/doc/html/draft-ietf-oauth-rar-23#name-relationship-to-scope-param
|
|
28
90
|
if (!scope && !authorizationDetails) {
|
|
29
91
|
if (!credentialOffer) {
|
|
30
92
|
throw Error('Please provide a scope or authorization_details if no credential offer is present');
|
|
31
93
|
}
|
|
32
|
-
|
|
94
|
+
if ('credentials' in credentialOffer.credential_offer) {
|
|
95
|
+
throw new Error('CredentialOffer format is wrong.');
|
|
96
|
+
}
|
|
97
|
+
const ver = (_c = version !== null && version !== void 0 ? version : (0, oid4vci_common_1.determineSpecVersionFromOffer)(credentialOffer.credential_offer)) !== null && _c !== void 0 ? _c : oid4vci_common_1.OpenId4VCIVersion.VER_1_0_13;
|
|
98
|
+
const creds = ver === oid4vci_common_1.OpenId4VCIVersion.VER_1_0_13
|
|
99
|
+
? filterSupportedCredentials(credentialOffer.credential_offer, credentialConfigurationSupported)
|
|
100
|
+
: [];
|
|
33
101
|
// FIXME: complains about VCT for sd-jwt
|
|
34
102
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
35
103
|
// @ts-ignore
|
|
36
|
-
authorizationDetails = creds
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
format
|
|
104
|
+
authorizationDetails = creds.flatMap((cred) => {
|
|
105
|
+
var _a;
|
|
106
|
+
const locations = [(_a = credentialOffer === null || credentialOffer === void 0 ? void 0 : credentialOffer.credential_offer.credential_issuer) !== null && _a !== void 0 ? _a : endpointMetadata.issuer];
|
|
107
|
+
const credential_configuration_id = cred.configuration_id;
|
|
108
|
+
const vct = cred.vct;
|
|
109
|
+
let format;
|
|
110
|
+
if (!credential_configuration_id) {
|
|
111
|
+
format = cred.format;
|
|
112
|
+
}
|
|
113
|
+
if (!credential_configuration_id && !cred.format) {
|
|
114
|
+
throw Error('format is required in authorization details');
|
|
115
|
+
}
|
|
116
|
+
const meta = {};
|
|
117
|
+
const credential_definition = cred.credential_definition;
|
|
118
|
+
if ((credential_definition === null || credential_definition === void 0 ? void 0 : credential_definition.type) && !format) {
|
|
119
|
+
// ype: OPTIONAL. Array as defined in Appendix A.1.1.2. This claim contains the type values the Wallet requests authorization for at the Credential Issuer. It MUST be present if the claim format is present in the root of the authorization details object. It MUST not be present otherwise.
|
|
120
|
+
// It meens we have a config_id, already mapping it to an explicit format and types
|
|
121
|
+
delete credential_definition.type;
|
|
122
|
+
}
|
|
123
|
+
if (credential_definition.credentialSubject) {
|
|
124
|
+
removeDisplayAndValueTypes(credential_definition.credentialSubject);
|
|
125
|
+
}
|
|
126
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ type: 'openid_credential' }, meta), { locations }), (credential_definition && { credential_definition })), (credential_configuration_id && { credential_configuration_id })), (format && { format })), (vct && { vct })), (cred.claims && { claims: removeDisplayAndValueTypes(JSON.parse(JSON.stringify(cred.claims))) }));
|
|
44
127
|
});
|
|
45
128
|
if (!authorizationDetails || authorizationDetails.length === 0) {
|
|
46
129
|
throw Error(`Could not create authorization details from credential offer. Please pass in explicit details`);
|
|
@@ -49,15 +132,15 @@ const createAuthorizationRequestUrl = ({ pkce, endpointMetadata, authorizationRe
|
|
|
49
132
|
if (!(endpointMetadata === null || endpointMetadata === void 0 ? void 0 : endpointMetadata.authorization_endpoint)) {
|
|
50
133
|
throw Error('Server metadata does not contain authorization endpoint');
|
|
51
134
|
}
|
|
52
|
-
const parEndpoint = (
|
|
135
|
+
const parEndpoint = (_d = endpointMetadata.credentialIssuerMetadata) === null || _d === void 0 ? void 0 : _d.pushed_authorization_request_endpoint;
|
|
53
136
|
// add 'openid' scope if not present
|
|
54
137
|
if (!(scope === null || scope === void 0 ? void 0 : scope.includes('openid'))) {
|
|
55
138
|
scope = ['openid', scope].filter((s) => !!s).join(' ');
|
|
56
139
|
}
|
|
57
140
|
let queryObj = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ response_type: oid4vci_common_1.ResponseType.AUTH_CODE }, (!pkce.disabled && {
|
|
58
|
-
code_challenge_method: (
|
|
141
|
+
code_challenge_method: (_e = pkce.codeChallengeMethod) !== null && _e !== void 0 ? _e : oid4vci_common_1.CodeChallengeMethod.S256,
|
|
59
142
|
code_challenge: pkce.codeChallenge,
|
|
60
|
-
})), { authorization_details: JSON.stringify(handleAuthorizationDetails(endpointMetadata, authorizationDetails)) }), (redirectUri && { redirect_uri: redirectUri })), (
|
|
143
|
+
})), { authorization_details: JSON.stringify(handleAuthorizationDetails(endpointMetadata, authorizationDetails)) }), (redirectUri && { redirect_uri: redirectUri })), (client_id && { client_id })), ((credentialOffer === null || credentialOffer === void 0 ? void 0 : credentialOffer.issuerState) && { issuer_state: credentialOffer.issuerState })), { scope });
|
|
61
144
|
if (!parEndpoint && parMode === oid4vci_common_1.PARMode.REQUIRE) {
|
|
62
145
|
throw Error(`PAR mode is set to required by Authorization Server does not support PAR!`);
|
|
63
146
|
}
|
|
@@ -75,10 +158,11 @@ const createAuthorizationRequestUrl = ({ pkce, endpointMetadata, authorizationRe
|
|
|
75
158
|
}
|
|
76
159
|
}
|
|
77
160
|
else {
|
|
78
|
-
debug(`PAR response: ${(parResponse.successBody, null, 2)}`);
|
|
79
|
-
queryObj = { request_uri: parResponse.successBody.request_uri };
|
|
161
|
+
debug(`PAR response: ${JSON.stringify(parResponse.successBody, null, 2)}`);
|
|
162
|
+
queryObj = { /*response_type: ResponseType.AUTH_CODE,*/ client_id, request_uri: parResponse.successBody.request_uri };
|
|
80
163
|
}
|
|
81
164
|
}
|
|
165
|
+
yield createSignedAuthRequestWhenNeeded(queryObj, Object.assign(Object.assign({}, requestObjectOpts), { aud: endpointMetadata.authorization_server }));
|
|
82
166
|
debug(`Object that will become query params: ` + JSON.stringify(queryObj, null, 2));
|
|
83
167
|
const url = (0, oid4vci_common_1.convertJsonToURI)(queryObj, {
|
|
84
168
|
baseUrl: endpointMetadata.authorization_endpoint,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorizationCodeClient.js","sourceRoot":"","sources":["../lib/AuthorizationCodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"AuthorizationCodeClient.js","sourceRoot":"","sources":["../lib/AuthorizationCodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAqBkC;AAClC,kDAA0B;AAE1B,yEAAsE;AAEtE,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,kBAAkB,CAAC,CAAC;AAExC,SAA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oB,CAAC,SAAmB,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;YACvG,CAAC;QACH,CAAC;aAAM,CAAC;YACN,oBAAoB,CAAC,SAAS,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthorizationRequestOpts, CredentialOfferRequestWithBaseUrl, CredentialsSupportedLegacy, EndpointMetadataResultV1_0_11, PKCEOpts } from '@sphereon/oid4vci-common';
|
|
2
|
+
export declare const createAuthorizationRequestUrlV1_0_11: ({ pkce, endpointMetadata, authorizationRequest, credentialOffer, credentialsSupported, }: {
|
|
3
|
+
pkce: PKCEOpts;
|
|
4
|
+
endpointMetadata: EndpointMetadataResultV1_0_11;
|
|
5
|
+
authorizationRequest: AuthorizationRequestOpts;
|
|
6
|
+
credentialOffer?: CredentialOfferRequestWithBaseUrl | undefined;
|
|
7
|
+
credentialsSupported?: CredentialsSupportedLegacy[] | undefined;
|
|
8
|
+
}) => Promise<string>;
|
|
9
|
+
//# sourceMappingURL=AuthorizationCodeClientV1_0_11.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthorizationCodeClientV1_0_11.d.ts","sourceRoot":"","sources":["../lib/AuthorizationCodeClientV1_0_11.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,EAMxB,iCAAiC,EACjC,0BAA0B,EAC1B,6BAA6B,EAI7B,QAAQ,EAGT,MAAM,0BAA0B,CAAC;AAOlC,eAAO,MAAM,oCAAoC;UAOzC,QAAQ;sBACI,6BAA6B;0BACzB,wBAAwB;;;MAG5C,QAAQ,MAAM,CA8FjB,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
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.createAuthorizationRequestUrlV1_0_11 = void 0;
|
|
16
|
+
const oid4vci_common_1 = require("@sphereon/oid4vci-common");
|
|
17
|
+
const debug_1 = __importDefault(require("debug"));
|
|
18
|
+
const AuthorizationCodeClient_1 = require("./AuthorizationCodeClient");
|
|
19
|
+
const debug = (0, debug_1.default)('sphereon:oid4vci');
|
|
20
|
+
const createAuthorizationRequestUrlV1_0_11 = ({ pkce, endpointMetadata, authorizationRequest, credentialOffer, credentialsSupported, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
var _a, _b, _c, _d;
|
|
22
|
+
const { redirectUri, clientId, requestObjectOpts = { requestObjectMode: oid4vci_common_1.CreateRequestObjectMode.NONE } } = authorizationRequest;
|
|
23
|
+
let { scope, authorizationDetails } = authorizationRequest;
|
|
24
|
+
const parMode = ((_a = endpointMetadata === null || endpointMetadata === void 0 ? void 0 : endpointMetadata.credentialIssuerMetadata) === null || _a === void 0 ? void 0 : _a.require_pushed_authorization_requests)
|
|
25
|
+
? oid4vci_common_1.PARMode.REQUIRE
|
|
26
|
+
: (_b = authorizationRequest.parMode) !== null && _b !== void 0 ? _b : oid4vci_common_1.PARMode.AUTO;
|
|
27
|
+
// Scope and authorization_details can be used in the same authorization request
|
|
28
|
+
// https://datatracker.ietf.org/doc/html/draft-ietf-oauth-rar-23#name-relationship-to-scope-param
|
|
29
|
+
if (!scope && !authorizationDetails) {
|
|
30
|
+
if (!credentialOffer) {
|
|
31
|
+
throw Error('Please provide a scope or authorization_details if no credential offer is present');
|
|
32
|
+
}
|
|
33
|
+
const creds = credentialOffer.credential_offer.credentials;
|
|
34
|
+
// FIXME: complains about VCT for sd-jwt
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
authorizationDetails = creds
|
|
38
|
+
.flatMap((cred) => (typeof cred === 'string' ? credentialsSupported : cred))
|
|
39
|
+
.filter((cred) => !!cred)
|
|
40
|
+
.map((cred) => {
|
|
41
|
+
return Object.assign(Object.assign({}, cred), { type: 'openid_credential', locations: [endpointMetadata.issuer],
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
format: cred.format });
|
|
45
|
+
});
|
|
46
|
+
if (!authorizationDetails || (Array.isArray(authorizationDetails) && authorizationDetails.length === 0)) {
|
|
47
|
+
throw Error(`Could not create authorization details from credential offer. Please pass in explicit details`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!(endpointMetadata === null || endpointMetadata === void 0 ? void 0 : endpointMetadata.authorization_endpoint)) {
|
|
51
|
+
throw Error('Server metadata does not contain authorization endpoint');
|
|
52
|
+
}
|
|
53
|
+
const parEndpoint = (_c = endpointMetadata.credentialIssuerMetadata) === null || _c === void 0 ? void 0 : _c.pushed_authorization_request_endpoint;
|
|
54
|
+
// add 'openid' scope if not present
|
|
55
|
+
if (!(scope === null || scope === void 0 ? void 0 : scope.includes('openid'))) {
|
|
56
|
+
scope = ['openid', scope].filter((s) => !!s).join(' ');
|
|
57
|
+
}
|
|
58
|
+
let queryObj = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ response_type: oid4vci_common_1.ResponseType.AUTH_CODE }, (!pkce.disabled && {
|
|
59
|
+
code_challenge_method: (_d = pkce.codeChallengeMethod) !== null && _d !== void 0 ? _d : oid4vci_common_1.CodeChallengeMethod.S256,
|
|
60
|
+
code_challenge: pkce.codeChallenge,
|
|
61
|
+
})), { authorization_details: JSON.stringify(handleAuthorizationDetailsV1_0_11(endpointMetadata, authorizationDetails)) }), (redirectUri && { redirect_uri: redirectUri })), (clientId && { client_id: clientId })), ((credentialOffer === null || credentialOffer === void 0 ? void 0 : credentialOffer.issuerState) && { issuer_state: credentialOffer.issuerState })), { scope });
|
|
62
|
+
if (!parEndpoint && parMode === oid4vci_common_1.PARMode.REQUIRE) {
|
|
63
|
+
throw Error(`PAR mode is set to required by Authorization Server does not support PAR!`);
|
|
64
|
+
}
|
|
65
|
+
else if (parEndpoint && parMode !== oid4vci_common_1.PARMode.NEVER) {
|
|
66
|
+
debug(`USING PAR with endpoint ${parEndpoint}`);
|
|
67
|
+
const parResponse = yield (0, oid4vci_common_1.formPost)(parEndpoint, (0, oid4vci_common_1.convertJsonToURI)(queryObj, {
|
|
68
|
+
mode: oid4vci_common_1.JsonURIMode.X_FORM_WWW_URLENCODED,
|
|
69
|
+
uriTypeProperties: ['client_id', 'request_uri', 'redirect_uri', 'scope', 'authorization_details', 'issuer_state'],
|
|
70
|
+
}), { contentType: 'application/x-www-form-urlencoded', accept: 'application/json' });
|
|
71
|
+
if (parResponse.errorBody || !parResponse.successBody) {
|
|
72
|
+
console.log(JSON.stringify(parResponse.errorBody));
|
|
73
|
+
console.log('Falling back to regular request URI, since PAR failed');
|
|
74
|
+
if (parMode === oid4vci_common_1.PARMode.REQUIRE) {
|
|
75
|
+
throw Error(`PAR error: ${parResponse.origResponse.statusText}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
debug(`PAR response: ${JSON.stringify(parResponse.successBody, null, 2)}`);
|
|
80
|
+
queryObj = { request_uri: parResponse.successBody.request_uri };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
yield (0, AuthorizationCodeClient_1.createSignedAuthRequestWhenNeeded)(queryObj, Object.assign(Object.assign({}, requestObjectOpts), { aud: endpointMetadata.authorization_server }));
|
|
84
|
+
debug(`Object that will become query params: ` + JSON.stringify(queryObj, null, 2));
|
|
85
|
+
const url = (0, oid4vci_common_1.convertJsonToURI)(queryObj, {
|
|
86
|
+
baseUrl: endpointMetadata.authorization_endpoint,
|
|
87
|
+
uriTypeProperties: ['client_id', 'request_uri', 'redirect_uri', 'scope', 'authorization_details', 'issuer_state'],
|
|
88
|
+
// arrayTypeProperties: ['authorization_details'],
|
|
89
|
+
mode: oid4vci_common_1.JsonURIMode.X_FORM_WWW_URLENCODED,
|
|
90
|
+
// We do not add the version here, as this always needs to be form encoded
|
|
91
|
+
});
|
|
92
|
+
debug(`Authorization Request URL: ${url}`);
|
|
93
|
+
return url;
|
|
94
|
+
});
|
|
95
|
+
exports.createAuthorizationRequestUrlV1_0_11 = createAuthorizationRequestUrlV1_0_11;
|
|
96
|
+
const handleAuthorizationDetailsV1_0_11 = (endpointMetadata, authorizationDetails) => {
|
|
97
|
+
if (authorizationDetails) {
|
|
98
|
+
if (typeof authorizationDetails === 'string') {
|
|
99
|
+
// backwards compat for older versions of the lib
|
|
100
|
+
return authorizationDetails;
|
|
101
|
+
}
|
|
102
|
+
if (Array.isArray(authorizationDetails)) {
|
|
103
|
+
return authorizationDetails
|
|
104
|
+
.filter((value) => typeof value !== 'string')
|
|
105
|
+
.map((value) => handleLocations(endpointMetadata, typeof value === 'string' ? value : Object.assign({}, value)));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
return handleLocations(endpointMetadata, Object.assign({}, authorizationDetails));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return authorizationDetails;
|
|
112
|
+
};
|
|
113
|
+
const handleLocations = (endpointMetadata, authorizationDetails) => {
|
|
114
|
+
var _a;
|
|
115
|
+
if (typeof authorizationDetails === 'string') {
|
|
116
|
+
// backwards compat for older versions of the lib
|
|
117
|
+
return authorizationDetails;
|
|
118
|
+
}
|
|
119
|
+
if (authorizationDetails && (((_a = endpointMetadata.credentialIssuerMetadata) === null || _a === void 0 ? void 0 : _a.authorization_server) || endpointMetadata.authorization_endpoint)) {
|
|
120
|
+
if (authorizationDetails.locations) {
|
|
121
|
+
if (Array.isArray(authorizationDetails.locations)) {
|
|
122
|
+
authorizationDetails.locations.push(endpointMetadata.issuer);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
authorizationDetails.locations = [authorizationDetails.locations, endpointMetadata.issuer];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
authorizationDetails.locations = [endpointMetadata.issuer];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return authorizationDetails;
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=AuthorizationCodeClientV1_0_11.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthorizationCodeClientV1_0_11.js","sourceRoot":"","sources":["../lib/AuthorizationCodeClientV1_0_11.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAiBkC;AAClC,kDAA0B;AAE1B,uEAA8E;AAE9E,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,kBAAkB,CAAC,CAAC;AAEjC,MAAM,oCAAoC,GAAG,CAAO,EACzD,IAAI,EACJ,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,GAOrB,EAAmB,EAAE;;IACpB,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,GAAG,EAAE,iBAAiB,EAAE,wCAAuB,CAAC,IAAI,EAAE,EAAE,GAAG,oBAAoB,CAAC;IAChI,IAAI,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,oBAAoB,CAAC;IAE3D,MAAM,OAAO,GAAG,CAAA,MAAA,gBA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AAI,oBAAoB,IAAI,CAAC,CAAA,MAAA,gBAAgB,CAAC,wBAAwB,0CAAE,oBAAoB,KAAI,gBAAgB,CAAC,sBAAsB,CAAC,EAAE,CAAC;QACzI,IAAI,oBAAoB,CAAC,SAAS,EAAE,CAAC;YACnC,IAAI,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAE,CAAC;gBAClD,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACN,oBAAoB,CAAC,SAAS,GAAG,CAAC,oBAAoB,CAAC,SAAmB,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;YACvG,CAAC;QACH,CAAC;aAAM,CAAC;YACN,oBAAoB,CAAC,SAAS,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialOfferClient.d.ts","sourceRoot":"","sources":["../lib/CredentialOfferClient.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CredentialOfferClient.d.ts","sourceRoot":"","sources":["../lib/CredentialOfferClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iCAAiC,EAKjC,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;WA2DpG,KAAK,CACjB,kBAAkB,EAAE,iCAAiC,EACrD,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,iBAAiB,CAAC;KAC7B,GACA,MAAM;CAsCV"}
|
|
@@ -15,11 +15,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.CredentialOfferClient = void 0;
|
|
16
16
|
const oid4vci_common_1 = require("@sphereon/oid4vci-common");
|
|
17
17
|
const debug_1 = __importDefault(require("debug"));
|
|
18
|
-
const
|
|
18
|
+
const types_1 = require("./types");
|
|
19
19
|
const debug = (0, debug_1.default)('sphereon:oid4vci:offer');
|
|
20
20
|
class CredentialOfferClient {
|
|
21
21
|
static fromURI(uri, opts) {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
debug(`Credential Offer URI: ${uri}`);
|
|
25
25
|
if (!uri.includes('?') || !uri.includes('://')) {
|
|
@@ -29,21 +29,24 @@ class CredentialOfferClient {
|
|
|
29
29
|
const scheme = uri.split('://')[0];
|
|
30
30
|
const baseUrl = uri.split('?')[0];
|
|
31
31
|
const version = (0, oid4vci_common_1.determineSpecVersionFromURI)(uri);
|
|
32
|
+
types_1.LOG.log(`Offer URL determined to be of version ${version}`);
|
|
32
33
|
let credentialOffer;
|
|
33
34
|
let credentialOfferPayload;
|
|
35
|
+
// credential offer was introduced in draft 9 and credential_offer_uri in draft 11
|
|
34
36
|
if (version < oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11) {
|
|
35
|
-
credentialOfferPayload = (0,
|
|
37
|
+
credentialOfferPayload = (0, oid4vci_common_1.convertURIToJsonObject)(uri, {
|
|
36
38
|
arrayTypeProperties: ['credential_type'],
|
|
37
|
-
requiredProperties: uri.includes('
|
|
39
|
+
requiredProperties: uri.includes('credential_offer=') ? ['credential_offer'] : ['issuer', 'credential_type'],
|
|
38
40
|
});
|
|
39
41
|
credentialOffer = {
|
|
40
42
|
credential_offer: credentialOfferPayload,
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
45
|
else {
|
|
44
|
-
credentialOffer = (0,
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
credentialOffer = (0, oid4vci_common_1.convertURIToJsonObject)(uri, {
|
|
47
|
+
// It must have the '=' sign after credential_offer otherwise the uri will get split at openid_credential_offer
|
|
48
|
+
arrayTypeProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri='] : ['credential_offer='],
|
|
49
|
+
requiredProperties: uri.includes('credential_offer_uri=') ? ['credential_offer_uri='] : ['credential_offer='],
|
|
47
50
|
});
|
|
48
51
|
if ((credentialOffer === null || credentialOffer === void 0 ? void 0 : credentialOffer.credential_offer_uri) === undefined && !(credentialOffer === null || credentialOffer === void 0 ? void 0 : credentialOffer.credential_offer)) {
|
|
49
52
|
throw Error('Either a credential_offer or credential_offer_uri should be present in ' + uri);
|
|
@@ -52,11 +55,13 @@ class CredentialOfferClient {
|
|
|
52
55
|
const request = yield (0, oid4vci_common_1.toUniformCredentialOfferRequest)(credentialOffer, Object.assign(Object.assign({}, opts), { version }));
|
|
53
56
|
const clientId = (0, oid4vci_common_1.getClientIdFromCredentialOfferPayload)(request.credential_offer);
|
|
54
57
|
const grants = (_a = request.credential_offer) === null || _a === void 0 ? void 0 : _a.grants;
|
|
55
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({ scheme,
|
|
56
|
-
baseUrl,
|
|
57
|
-
clientId }, request), (((_b = grants === null || grants === void 0 ? void 0 : grants.authorization_code) === null || _b === void 0 ? void 0 : _b.issuer_state) && { issuerState: grants.authorization_code.issuer_state })), (((_c = grants === null || grants === void 0 ? void 0 : grants['urn:ietf:params:oauth:grant-type:pre-authorized_code']) === null || _c === void 0 ? void 0 : _c['pre-authorized_code']) && {
|
|
58
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ scheme,
|
|
59
|
+
baseUrl }, (clientId && { clientId })), request), (((_b = grants === null || grants === void 0 ? void 0 : grants.authorization_code) === null || _b === void 0 ? void 0 : _b.issuer_state) && { issuerState: grants.authorization_code.issuer_state })), (((_c = grants === null || grants === void 0 ? void 0 : grants['urn:ietf:params:oauth:grant-type:pre-authorized_code']) === null || _c === void 0 ? void 0 : _c['pre-authorized_code']) && {
|
|
58
60
|
preAuthorizedCode: grants['urn:ietf:params:oauth:grant-type:pre-authorized_code']['pre-authorized_code'],
|
|
59
|
-
})), { userPinRequired: (_g = (_f = (_e = (_d = request.credential_offer) === null || _d === void 0 ? void 0 : _d.grants) === null || _e === void 0 ? void 0 : _e['urn:ietf:params:oauth:grant-type:pre-authorized_code']) === null || _f === void 0 ? void 0 : _f.user_pin_required) !== null && _g !== void 0 ? _g : false })
|
|
61
|
+
})), { userPinRequired: (_l = (_g = (_f = (_e = (_d = request.credential_offer) === null || _d === void 0 ? void 0 : _d.grants) === null || _e === void 0 ? void 0 : _e['urn:ietf:params:oauth:grant-type:pre-authorized_code']) === null || _f === void 0 ? void 0 : _f.user_pin_required) !== null && _g !== void 0 ? _g : !!((_k = (_j = (_h = request.credential_offer) === null || _h === void 0 ? void 0 : _h.grants) === null || _j === void 0 ? void 0 : _j['urn:ietf:params:oauth:grant-type:pre-authorized_code']) === null || _k === void 0 ? void 0 : _k.tx_code)) !== null && _l !== void 0 ? _l : false }), (((_p = (_o = (_m = request.credential_offer) === null || _m === void 0 ? void 0 : _m.grants) === null || _o === void 0 ? void 0 : _o['urn:ietf:params:oauth:grant-type:pre-authorized_code']) === null || _p === void 0 ? void 0 : _p.tx_code) &&
|
|
62
|
+
{
|
|
63
|
+
// txCode: request.credential_offer?.grants?.['urn:ietf:params:oauth:grant-type:pre-authorized_code']?.tx_code,
|
|
64
|
+
}));
|
|
60
65
|
});
|
|
61
66
|
}
|
|
62
67
|
static toURI(requestWithBaseUrl, opts) {
|
|
@@ -86,12 +91,12 @@ class CredentialOfferClient {
|
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
|
-
return (0,
|
|
94
|
+
return (0, oid4vci_common_1.convertJsonToURI)((_b = requestWithBaseUrl.credential_offer_uri) !== null && _b !== void 0 ? _b : requestWithBaseUrl.original_credential_offer, {
|
|
90
95
|
baseUrl,
|
|
91
96
|
arrayTypeProperties: isUri ? [] : ['credential_type'],
|
|
92
97
|
uriTypeProperties: isUri
|
|
93
98
|
? ['credential_offer_uri']
|
|
94
|
-
: version >= oid4vci_common_1.OpenId4VCIVersion.
|
|
99
|
+
: version >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_13
|
|
95
100
|
? ['credential_issuer', 'credential_type']
|
|
96
101
|
: ['issuer', 'credential_type'],
|
|
97
102
|
param,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialOfferClient.js","sourceRoot":"","sources":["../lib/CredentialOfferClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"CredentialOfferClient.js","sourceRoot":"","sources":["../lib/CredentialOfferClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAakC;AAClC,kDAA0B;AAE1B,mCAA8B;AAE9B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,wBAAwB,CAAC,CAAC;AAE9C,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,CAAC;gBAC/C,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;gBAC9C,MAAM,KAAK,CAAC,kCAAkC,CAAC,CAAC;YAClD,CAAC;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,EA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AA,iCAAgB,EAAC,MAAA,kBAAkB,CAAC,oBAAoB,mCAAI,kBAAkB,CAAC,yBAAyB,EAAE;YAC/G,OAAO;YACP,mBAAmB,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;YACrD,iBAAiB,EAAE,KAAK;gBACtB,CAAC,CAAC,CAAC,sBAAsB,CAAC;gBAC1B,CAAC,CAAC,OAAO,IAAI,kCAAiB,CAAC,UAAU;oBACvC,CAAC,CAAC,CAAC,mBAAmB,EAAE,iBAAiB,CAAC;oBAC1C,CAAC,CAAC,CAAC,QAAQ,EAAE,iBAAiB,CAAC;YACnC,KAAK;YACL,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF;AAvGD,sDAuGC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CredentialOfferRequestWithBaseUrl, CredentialOfferRequestWithBaseUrlV1_0_11, OpenId4VCIVersion } from '@sphereon/oid4vci-common';
|
|
2
|
+
export declare class CredentialOfferClientV1_0_11 {
|
|
3
|
+
static fromURI(uri: string, opts?: {
|
|
4
|
+
resolve?: boolean;
|
|
5
|
+
}): Promise<CredentialOfferRequestWithBaseUrlV1_0_11>;
|
|
6
|
+
static toURI(requestWithBaseUrl: CredentialOfferRequestWithBaseUrl, opts?: {
|
|
7
|
+
version?: OpenId4VCIVersion;
|
|
8
|
+
}): string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=CredentialOfferClientV1_0_11.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialOfferClientV1_0_11.d.ts","sourceRoot":"","sources":["../lib/CredentialOfferClientV1_0_11.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iCAAiC,EACjC,wCAAwC,EAIxC,iBAAiB,EAElB,MAAM,0BAA0B,CAAC;AAKlC,qBAAa,4BAA4B;WACnB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC;WAiD3G,KAAK,CACjB,kBAAkB,EAAE,iCAAiC,EACrD,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,iBAAiB,CAAC;KAC7B,GACA,MAAM;CAsCV"}
|
|
@@ -0,0 +1,101 @@
|
|
|
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.CredentialOfferClientV1_0_11 = void 0;
|
|
16
|
+
const oid4vci_common_1 = require("@sphereon/oid4vci-common");
|
|
17
|
+
const debug_1 = __importDefault(require("debug"));
|
|
18
|
+
const debug = (0, debug_1.default)('sphereon:oid4vci:offer');
|
|
19
|
+
class CredentialOfferClientV1_0_11 {
|
|
20
|
+
static fromURI(uri, opts) {
|
|
21
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
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, oid4vci_common_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, oid4vci_common_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
|
+
const clientId = (0, oid4vci_common_1.getClientIdFromCredentialOfferPayload)(request.credential_offer);
|
|
53
|
+
const grants = (_a = request.credential_offer) === null || _a === void 0 ? void 0 : _a.grants;
|
|
54
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ scheme,
|
|
55
|
+
baseUrl }, (clientId && { clientId })), request), (((_b = grants === null || grants === void 0 ? void 0 : grants.authorization_code) === null || _b === void 0 ? void 0 : _b.issuer_state) && { issuerState: grants.authorization_code.issuer_state })), (((_c = grants === null || grants === void 0 ? void 0 : grants['urn:ietf:params:oauth:grant-type:pre-authorized_code']) === null || _c === void 0 ? void 0 : _c['pre-authorized_code']) && {
|
|
56
|
+
preAuthorizedCode: grants['urn:ietf:params:oauth:grant-type:pre-authorized_code']['pre-authorized_code'],
|
|
57
|
+
})), { userPinRequired: (_g = !!((_f = (_e = (_d = request.credential_offer) === null || _d === void 0 ? void 0 : _d.grants) === null || _e === void 0 ? void 0 : _e['urn:ietf:params:oauth:grant-type:pre-authorized_code']) === null || _f === void 0 ? void 0 : _f.user_pin_required)) !== null && _g !== void 0 ? _g : false });
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
static toURI(requestWithBaseUrl, opts) {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
debug(`Credential Offer Request with base URL: ${JSON.stringify(requestWithBaseUrl)}`);
|
|
63
|
+
const version = (_a = opts === null || opts === void 0 ? void 0 : opts.version) !== null && _a !== void 0 ? _a : requestWithBaseUrl.version;
|
|
64
|
+
let baseUrl = requestWithBaseUrl.baseUrl.includes(requestWithBaseUrl.scheme)
|
|
65
|
+
? requestWithBaseUrl.baseUrl
|
|
66
|
+
: `${requestWithBaseUrl.scheme.replace('://', '')}://${requestWithBaseUrl.baseUrl}`;
|
|
67
|
+
let param;
|
|
68
|
+
const isUri = requestWithBaseUrl.credential_offer_uri !== undefined;
|
|
69
|
+
if (version.valueOf() >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11.valueOf()) {
|
|
70
|
+
// v11 changed from encoding every param to a encoded json object with a credential_offer param key
|
|
71
|
+
if (!baseUrl.includes('?')) {
|
|
72
|
+
param = isUri ? 'credential_offer_uri' : 'credential_offer';
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const split = baseUrl.split('?');
|
|
76
|
+
if (split.length > 1 && split[1] !== '') {
|
|
77
|
+
if (baseUrl.endsWith('&')) {
|
|
78
|
+
param = isUri ? 'credential_offer_uri' : 'credential_offer';
|
|
79
|
+
}
|
|
80
|
+
else if (!baseUrl.endsWith('=')) {
|
|
81
|
+
baseUrl += `&`;
|
|
82
|
+
param = isUri ? 'credential_offer_uri' : 'credential_offer';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return (0, oid4vci_common_1.convertJsonToURI)((_b = requestWithBaseUrl.credential_offer_uri) !== null && _b !== void 0 ? _b : requestWithBaseUrl.original_credential_offer, {
|
|
88
|
+
baseUrl,
|
|
89
|
+
arrayTypeProperties: isUri ? [] : ['credential_type'],
|
|
90
|
+
uriTypeProperties: isUri
|
|
91
|
+
? ['credential_offer_uri']
|
|
92
|
+
: version >= oid4vci_common_1.OpenId4VCIVersion.VER_1_0_11
|
|
93
|
+
? ['credential_issuer', 'credential_type']
|
|
94
|
+
: ['issuer', 'credential_type'],
|
|
95
|
+
param,
|
|
96
|
+
version,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.CredentialOfferClientV1_0_11 = CredentialOfferClientV1_0_11;
|
|
101
|
+
//# sourceMappingURL=CredentialOfferClientV1_0_11.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialOfferClientV1_0_11.js","sourceRoot":"","sources":["../lib/CredentialOfferClientV1_0_11.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAakC;AAClC,kDAA0B;AAE1B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,wBAAwB,CAAC,CAAC;AAE9C,MAAa,4BAA4B;IAChC,MAAM,CAAO,OAAO,CAAC,GAAW,EAAE,IAA4B;;;YACnE,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;YACtC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,G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AoB,mCAAI,kBAAkB,CAAC,yBAAyB,EAAE;YAC/G,OAAO;YACP,mBAAmB,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;YACrD,iBAAiB,EAAE,KAAK;gBACtB,CAAC,CAAC,CAAC,sBAAsB,CAAC;gBAC1B,CAAC,CAAC,OAAO,IAAI,kCAAiB,CAAC,UAAU;oBACvC,CAAC,CAAC,CAAC,mBAAmB,EAAE,iBAAiB,CAAC;oBAC1C,CAAC,CAAC,CAAC,QAAQ,EAAE,iBAAiB,CAAC;YACnC,KAAK;YACL,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF;AA7FD,oEA6FC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CredentialOfferRequestWithBaseUrl, OpenId4VCIVersion } from '@sphereon/oid4vci-common';
|
|
2
|
+
export declare class CredentialOfferClientV1_0_13 {
|
|
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=CredentialOfferClientV1_0_13.d.ts.map
|