@sphereon/oid4vci-common 0.18.2 → 0.19.1-feature.SSISDK.13.17
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/LICENSE +201 -201
- package/dist/index.cjs +346 -265
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +292 -79
- package/dist/index.d.ts +292 -79
- package/dist/index.js +305 -129
- package/dist/index.js.map +1 -1
- package/package.json +12 -13
package/dist/index.cjs
CHANGED
|
@@ -6,6 +6,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __esm = (fn, res) => function __init() {
|
|
10
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
+
};
|
|
12
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
13
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
|
+
};
|
|
9
15
|
var __export = (target, all) => {
|
|
10
16
|
for (var name in all)
|
|
11
17
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -28,6 +34,48 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
34
|
));
|
|
29
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
36
|
|
|
37
|
+
// ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.11.29_postcss@8.5.3_tsx@4.19.4_typescript@5.8.3_yaml@2.8.0/node_modules/tsup/assets/cjs_shims.js
|
|
38
|
+
var init_cjs_shims = __esm({
|
|
39
|
+
"../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.11.29_postcss@8.5.3_tsx@4.19.4_typescript@5.8.3_yaml@2.8.0/node_modules/tsup/assets/cjs_shims.js"() {
|
|
40
|
+
"use strict";
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// lib/functions/randomBytes.cjs
|
|
45
|
+
var require_randomBytes = __commonJS({
|
|
46
|
+
"lib/functions/randomBytes.cjs"(exports, module2) {
|
|
47
|
+
"use strict";
|
|
48
|
+
init_cjs_shims();
|
|
49
|
+
var MAX_BYTES = 65536;
|
|
50
|
+
var MAX_UINT32 = 4294967295;
|
|
51
|
+
var _global = typeof globalThis !== "undefined" ? globalThis : global;
|
|
52
|
+
var crypto = _global.crypto || _global.msCrypto;
|
|
53
|
+
if (!crypto) {
|
|
54
|
+
try {
|
|
55
|
+
crypto = require("crypto");
|
|
56
|
+
} catch (err) {
|
|
57
|
+
throw Error("crypto module is not available");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function randomBytes2(size) {
|
|
61
|
+
if (size > MAX_UINT32) throw new Error("requested too many random bytes");
|
|
62
|
+
const bytes = Buffer.allocUnsafe(size);
|
|
63
|
+
if (size > 0) {
|
|
64
|
+
if (size > MAX_BYTES) {
|
|
65
|
+
for (let generated = 0; generated < size; generated += MAX_BYTES) {
|
|
66
|
+
crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
crypto.getRandomValues(bytes);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return Uint8Array.from(bytes);
|
|
73
|
+
}
|
|
74
|
+
__name(randomBytes2, "randomBytes");
|
|
75
|
+
module2.exports = randomBytes2;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
31
79
|
// lib/index.ts
|
|
32
80
|
var index_exports = {};
|
|
33
81
|
__export(index_exports, {
|
|
@@ -104,6 +152,7 @@ __export(index_exports, {
|
|
|
104
152
|
createCodeChallenge: () => createCodeChallenge,
|
|
105
153
|
createProofOfPossession: () => createProofOfPossession,
|
|
106
154
|
credentialIssuerMetadataFieldNames: () => credentialIssuerMetadataFieldNames,
|
|
155
|
+
credentialIssuerMetadataFieldNamesV1_0_15: () => credentialIssuerMetadataFieldNamesV1_0_15,
|
|
107
156
|
credentialSupportedV8ToV13: () => credentialSupportedV8ToV13,
|
|
108
157
|
credentialsSupportedV8ToV13: () => credentialsSupportedV8ToV13,
|
|
109
158
|
decodeJsonProperties: () => decodeJsonProperties,
|
|
@@ -119,6 +168,7 @@ __export(index_exports, {
|
|
|
119
168
|
generateNonce: () => generateNonce,
|
|
120
169
|
generateRandomString: () => generateRandomString,
|
|
121
170
|
getClientIdFromCredentialOfferPayload: () => getClientIdFromCredentialOfferPayload,
|
|
171
|
+
getCredentialConfigurationIdsFromOfferV1_0_15: () => getCredentialConfigurationIdsFromOfferV1_0_15,
|
|
122
172
|
getCredentialOfferPayload: () => getCredentialOfferPayload,
|
|
123
173
|
getCredentialRequestForVersion: () => getCredentialRequestForVersion,
|
|
124
174
|
getFormatForVersion: () => getFormatForVersion,
|
|
@@ -150,9 +200,10 @@ __export(index_exports, {
|
|
|
150
200
|
isPreAuthCode: () => isPreAuthCode,
|
|
151
201
|
isValidURL: () => isValidURL,
|
|
152
202
|
isW3cCredentialSupported: () => isW3cCredentialSupported,
|
|
203
|
+
normalizeOfferInput: () => normalizeOfferInput,
|
|
153
204
|
post: () => post,
|
|
154
|
-
randomBytes: () => randomBytes,
|
|
155
205
|
resolveCredentialOfferURI: () => resolveCredentialOfferURI,
|
|
206
|
+
supportedOID4VCICredentialFormat: () => supportedOID4VCICredentialFormat,
|
|
156
207
|
toAuthorizationResponsePayload: () => toAuthorizationResponsePayload,
|
|
157
208
|
toUniformCredentialOfferPayload: () => toUniformCredentialOfferPayload,
|
|
158
209
|
toUniformCredentialOfferRequest: () => toUniformCredentialOfferRequest,
|
|
@@ -162,45 +213,35 @@ __export(index_exports, {
|
|
|
162
213
|
validateJWT: () => validateJWT
|
|
163
214
|
});
|
|
164
215
|
module.exports = __toCommonJS(index_exports);
|
|
165
|
-
|
|
216
|
+
init_cjs_shims();
|
|
217
|
+
var import_ssi_types5 = require("@sphereon/ssi-types");
|
|
166
218
|
|
|
167
|
-
// lib/functions/
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
var randomBytes = /* @__PURE__ */ __name((size) => {
|
|
184
|
-
if (size > MAX_UINT32) throw new Error("requested too many random bytes");
|
|
185
|
-
const bytes = Buffer.allocUnsafe(size);
|
|
186
|
-
if (size > 0) {
|
|
187
|
-
if (size > MAX_BYTES) {
|
|
188
|
-
for (let generated = 0; generated < size; generated += MAX_BYTES) {
|
|
189
|
-
crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
|
|
190
|
-
}
|
|
191
|
-
} else {
|
|
192
|
-
crypto.getRandomValues(bytes);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return Uint8Array.from(bytes);
|
|
196
|
-
}, "randomBytes");
|
|
197
|
-
if (crypto && crypto.getRandomValues) {
|
|
198
|
-
module.exports = randomBytes;
|
|
199
|
-
} else {
|
|
200
|
-
module.exports = oldBrowser;
|
|
201
|
-
}
|
|
219
|
+
// lib/functions/index.ts
|
|
220
|
+
init_cjs_shims();
|
|
221
|
+
|
|
222
|
+
// lib/functions/CredentialRequestUtil.ts
|
|
223
|
+
init_cjs_shims();
|
|
224
|
+
|
|
225
|
+
// lib/types/index.ts
|
|
226
|
+
init_cjs_shims();
|
|
227
|
+
|
|
228
|
+
// lib/types/OpenIDClient.ts
|
|
229
|
+
init_cjs_shims();
|
|
230
|
+
|
|
231
|
+
// lib/types/Authorization.types.ts
|
|
232
|
+
init_cjs_shims();
|
|
202
233
|
|
|
203
234
|
// lib/types/Generic.types.ts
|
|
235
|
+
init_cjs_shims();
|
|
236
|
+
var supportedOID4VCICredentialFormat = [
|
|
237
|
+
"jwt_vc_json",
|
|
238
|
+
"jwt_vc_json-ld",
|
|
239
|
+
"ldp_vc",
|
|
240
|
+
"dc+sd-jwt",
|
|
241
|
+
"vc+sd-jwt",
|
|
242
|
+
"jwt_vc",
|
|
243
|
+
"mso_mdoc"
|
|
244
|
+
];
|
|
204
245
|
var PRE_AUTH_CODE_LITERAL = "pre-authorized_code";
|
|
205
246
|
var PRE_AUTH_GRANT_LITERAL = "urn:ietf:params:oauth:grant-type:pre-authorized_code";
|
|
206
247
|
|
|
@@ -264,6 +305,7 @@ var AuthzFlowType = /* @__PURE__ */ function(AuthzFlowType2) {
|
|
|
264
305
|
})(AuthzFlowType || (AuthzFlowType = {}));
|
|
265
306
|
|
|
266
307
|
// lib/types/CredentialIssuance.types.ts
|
|
308
|
+
init_cjs_shims();
|
|
267
309
|
var JsonURIMode = /* @__PURE__ */ function(JsonURIMode2) {
|
|
268
310
|
JsonURIMode2[JsonURIMode2["JSON_STRINGIFY"] = 0] = "JSON_STRINGIFY";
|
|
269
311
|
JsonURIMode2[JsonURIMode2["X_FORM_WWW_URLENCODED"] = 1] = "X_FORM_WWW_URLENCODED";
|
|
@@ -282,19 +324,25 @@ var Alg = /* @__PURE__ */ function(Alg2) {
|
|
|
282
324
|
return Alg2;
|
|
283
325
|
}({});
|
|
284
326
|
|
|
327
|
+
// lib/types/v1_0_08.types.ts
|
|
328
|
+
init_cjs_shims();
|
|
329
|
+
|
|
285
330
|
// lib/types/v1_0_09.types.ts
|
|
331
|
+
init_cjs_shims();
|
|
286
332
|
function isAuthorizationRequestV1_0_09(request) {
|
|
287
333
|
return request && "op_state" in request;
|
|
288
334
|
}
|
|
289
335
|
__name(isAuthorizationRequestV1_0_09, "isAuthorizationRequestV1_0_09");
|
|
290
336
|
|
|
291
337
|
// lib/types/v1_0_11.types.ts
|
|
338
|
+
init_cjs_shims();
|
|
292
339
|
function isAuthorizationRequestV1_0_11(request) {
|
|
293
340
|
return request && "issuer_state" in request;
|
|
294
341
|
}
|
|
295
342
|
__name(isAuthorizationRequestV1_0_11, "isAuthorizationRequestV1_0_11");
|
|
296
343
|
|
|
297
344
|
// lib/types/v1_0_13.types.ts
|
|
345
|
+
init_cjs_shims();
|
|
298
346
|
var credentialIssuerMetadataFieldNames = [
|
|
299
347
|
// Required fields
|
|
300
348
|
"credential_issuer",
|
|
@@ -314,7 +362,28 @@ var credentialIssuerMetadataFieldNames = [
|
|
|
314
362
|
"signed_metadata"
|
|
315
363
|
];
|
|
316
364
|
|
|
365
|
+
// lib/types/v1_0_15.types.ts
|
|
366
|
+
init_cjs_shims();
|
|
367
|
+
var credentialIssuerMetadataFieldNamesV1_0_15 = [
|
|
368
|
+
"credential_issuer",
|
|
369
|
+
"credential_configurations_supported",
|
|
370
|
+
"credential_endpoint",
|
|
371
|
+
"nonce_endpoint",
|
|
372
|
+
"deferred_credential_endpoint",
|
|
373
|
+
"notification_endpoint",
|
|
374
|
+
"credential_response_encryption",
|
|
375
|
+
"batch_credential_issuance",
|
|
376
|
+
"authorization_servers",
|
|
377
|
+
"token_endpoint",
|
|
378
|
+
"display",
|
|
379
|
+
"credential_supplier_config",
|
|
380
|
+
"credential_identifiers_supported",
|
|
381
|
+
"signed_metadata",
|
|
382
|
+
"authorization_challenge_endpoint"
|
|
383
|
+
];
|
|
384
|
+
|
|
317
385
|
// lib/types/ServerMetadata.ts
|
|
386
|
+
init_cjs_shims();
|
|
318
387
|
var authorizationServerMetadataFieldNames = [
|
|
319
388
|
"issuer",
|
|
320
389
|
"authorization_endpoint",
|
|
@@ -349,6 +418,7 @@ var WellKnownEndpoints = /* @__PURE__ */ function(WellKnownEndpoints2) {
|
|
|
349
418
|
}({});
|
|
350
419
|
|
|
351
420
|
// lib/types/OpenID4VCIErrors.ts
|
|
421
|
+
init_cjs_shims();
|
|
352
422
|
var BAD_PARAMS = "Wrong parameters provided";
|
|
353
423
|
var URL_NOT_VALID = "Request url is not valid";
|
|
354
424
|
var JWS_NOT_VALID = "JWS is not valid";
|
|
@@ -387,12 +457,14 @@ var ACCESS_TOKEN_ISSUER_REQUIRED_ERROR = "access token issuer is required";
|
|
|
387
457
|
var WRONG_METADATA_FORMAT = "Wrong metadata format";
|
|
388
458
|
|
|
389
459
|
// lib/types/OpenID4VCIVersions.types.ts
|
|
460
|
+
init_cjs_shims();
|
|
390
461
|
var OpenId4VCIVersion = /* @__PURE__ */ function(OpenId4VCIVersion2) {
|
|
391
462
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_08"] = 1008] = "VER_1_0_08";
|
|
392
463
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_09"] = 1009] = "VER_1_0_09";
|
|
393
464
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_11"] = 1011] = "VER_1_0_11";
|
|
394
465
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_12"] = 1012] = "VER_1_0_12";
|
|
395
466
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_13"] = 1013] = "VER_1_0_13";
|
|
467
|
+
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_15"] = 1015] = "VER_1_0_15";
|
|
396
468
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_UNKNOWN"] = Number.MAX_VALUE] = "VER_UNKNOWN";
|
|
397
469
|
return OpenId4VCIVersion2;
|
|
398
470
|
}({});
|
|
@@ -403,6 +475,7 @@ var DefaultURISchemes = /* @__PURE__ */ function(DefaultURISchemes2) {
|
|
|
403
475
|
}({});
|
|
404
476
|
|
|
405
477
|
// lib/types/StateManager.types.ts
|
|
478
|
+
init_cjs_shims();
|
|
406
479
|
var IssueStatus = /* @__PURE__ */ function(IssueStatus2) {
|
|
407
480
|
IssueStatus2["OFFER_CREATED"] = "OFFER_CREATED";
|
|
408
481
|
IssueStatus2["ACCESS_TOKEN_REQUESTED"] = "ACCESS_TOKEN_REQUESTED";
|
|
@@ -417,6 +490,7 @@ var IssueStatus = /* @__PURE__ */ function(IssueStatus2) {
|
|
|
417
490
|
}({});
|
|
418
491
|
|
|
419
492
|
// lib/types/Token.types.ts
|
|
493
|
+
init_cjs_shims();
|
|
420
494
|
var TokenErrorResponse = /* @__PURE__ */ function(TokenErrorResponse2) {
|
|
421
495
|
TokenErrorResponse2["invalid_request"] = "invalid_request";
|
|
422
496
|
TokenErrorResponse2["invalid_grant"] = "invalid_grant";
|
|
@@ -448,56 +522,15 @@ var TokenError = class _TokenError extends Error {
|
|
|
448
522
|
}
|
|
449
523
|
};
|
|
450
524
|
|
|
451
|
-
// lib/
|
|
452
|
-
|
|
453
|
-
return formatObject.format === format;
|
|
454
|
-
}
|
|
455
|
-
__name(isFormat, "isFormat");
|
|
456
|
-
function isNotFormat(formatObject, format) {
|
|
457
|
-
return formatObject.format !== format;
|
|
458
|
-
}
|
|
459
|
-
__name(isNotFormat, "isNotFormat");
|
|
460
|
-
var isUniformFormat = /* @__PURE__ */ __name((format) => {
|
|
461
|
-
return [
|
|
462
|
-
"jwt_vc_json",
|
|
463
|
-
"jwt_vc_json-ld",
|
|
464
|
-
"ldp_vc",
|
|
465
|
-
"vc+sd-jwt",
|
|
466
|
-
"mso_mdoc"
|
|
467
|
-
].includes(format);
|
|
468
|
-
}, "isUniformFormat");
|
|
469
|
-
function getUniformFormat(format) {
|
|
470
|
-
if (isUniformFormat(format)) {
|
|
471
|
-
return format;
|
|
472
|
-
}
|
|
473
|
-
if (format.toLocaleLowerCase() === "jwt_vc" || format.toLocaleLowerCase() === "jwt") {
|
|
474
|
-
return "jwt_vc";
|
|
475
|
-
}
|
|
476
|
-
if (format === "ldp_vc" || format === "ldp") {
|
|
477
|
-
return "ldp_vc";
|
|
478
|
-
}
|
|
479
|
-
throw new Error(`Invalid format: ${format}`);
|
|
480
|
-
}
|
|
481
|
-
__name(getUniformFormat, "getUniformFormat");
|
|
482
|
-
function getFormatForVersion(format, version) {
|
|
483
|
-
const uniformFormat = isUniformFormat(format) ? format : getUniformFormat(format);
|
|
484
|
-
if (version === OpenId4VCIVersion.VER_1_0_08) {
|
|
485
|
-
if (uniformFormat === "jwt_vc_json") {
|
|
486
|
-
return "jwt_vc";
|
|
487
|
-
} else if (uniformFormat === "ldp_vc" || uniformFormat === "jwt_vc_json-ld") {
|
|
488
|
-
return "ldp_vc";
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
return uniformFormat;
|
|
492
|
-
}
|
|
493
|
-
__name(getFormatForVersion, "getFormatForVersion");
|
|
525
|
+
// lib/types/QRCode.types.ts
|
|
526
|
+
init_cjs_shims();
|
|
494
527
|
|
|
495
528
|
// lib/functions/CredentialRequestUtil.ts
|
|
496
|
-
function getTypesFromRequest(credentialRequest, opts) {
|
|
529
|
+
function getTypesFromRequest(credentialRequest, format, opts) {
|
|
497
530
|
let types = [];
|
|
498
531
|
if ("credential_identifier" in credentialRequest && credentialRequest.credential_identifier) {
|
|
499
532
|
throw Error(`Cannot get types from request when it contains a credential_identifier`);
|
|
500
|
-
} else if (
|
|
533
|
+
} else if (format === "jwt_vc_json-ld" || format === "ldp_vc" || format === "jwt_vc" || format === "jwt_vc_json") {
|
|
501
534
|
if ("credential_definition" in credentialRequest && credentialRequest.credential_definition) {
|
|
502
535
|
types = "types" in credentialRequest.credential_definition ? credentialRequest.credential_definition.types : credentialRequest.credential_definition.type;
|
|
503
536
|
}
|
|
@@ -507,11 +540,11 @@ function getTypesFromRequest(credentialRequest, opts) {
|
|
|
507
540
|
if ("types" in credentialRequest && Array.isArray(credentialRequest.types)) {
|
|
508
541
|
types = credentialRequest.types;
|
|
509
542
|
}
|
|
510
|
-
} else if (
|
|
543
|
+
} else if (format === "vc+sd-jwt" && "vct" in credentialRequest) {
|
|
511
544
|
types = [
|
|
512
545
|
credentialRequest.vct
|
|
513
546
|
];
|
|
514
|
-
} else if (
|
|
547
|
+
} else if (format === "mso_mdoc" && "doctype" in credentialRequest) {
|
|
515
548
|
types = [
|
|
516
549
|
credentialRequest.doctype
|
|
517
550
|
];
|
|
@@ -525,17 +558,16 @@ function getTypesFromRequest(credentialRequest, opts) {
|
|
|
525
558
|
return types;
|
|
526
559
|
}
|
|
527
560
|
__name(getTypesFromRequest, "getTypesFromRequest");
|
|
528
|
-
function getCredentialRequestForVersion(credentialRequest, version) {
|
|
561
|
+
function getCredentialRequestForVersion(credentialRequest, format, version) {
|
|
529
562
|
if (version === OpenId4VCIVersion.VER_1_0_08) {
|
|
530
|
-
const
|
|
531
|
-
const types = getTypesFromRequest(credentialRequest, {
|
|
563
|
+
const types = getTypesFromRequest(credentialRequest, format, {
|
|
532
564
|
filterVerifiableCredential: true
|
|
533
565
|
});
|
|
534
566
|
if (credentialRequest.credential_subject_issuance) {
|
|
535
567
|
throw Error("Experimental subject issuance is not supported for older versions of the spec");
|
|
536
568
|
}
|
|
537
569
|
return {
|
|
538
|
-
format
|
|
570
|
+
format,
|
|
539
571
|
proof: credentialRequest.proof,
|
|
540
572
|
type: types[0]
|
|
541
573
|
};
|
|
@@ -544,10 +576,14 @@ function getCredentialRequestForVersion(credentialRequest, version) {
|
|
|
544
576
|
}
|
|
545
577
|
__name(getCredentialRequestForVersion, "getCredentialRequestForVersion");
|
|
546
578
|
|
|
579
|
+
// lib/functions/CredentialResponseUtil.ts
|
|
580
|
+
init_cjs_shims();
|
|
581
|
+
|
|
547
582
|
// lib/functions/HttpUtils.ts
|
|
583
|
+
init_cjs_shims();
|
|
584
|
+
var import_ssi_types = require("@sphereon/ssi-types");
|
|
548
585
|
var import_cross_fetch = require("cross-fetch");
|
|
549
|
-
var
|
|
550
|
-
var debug = (0, import_debug.default)("sphereon:openid4vci:http");
|
|
586
|
+
var logger = import_ssi_types.Loggers.DEFAULT.get("sphereon:openid4vci:http");
|
|
551
587
|
var getJson = /* @__PURE__ */ __name(async (URL1, opts) => {
|
|
552
588
|
return await openIdFetch(URL1, void 0, {
|
|
553
589
|
method: "GET",
|
|
@@ -592,25 +628,25 @@ var openIdFetch = /* @__PURE__ */ __name(async (url, body, opts) => {
|
|
|
592
628
|
headers,
|
|
593
629
|
body
|
|
594
630
|
};
|
|
595
|
-
debug(`START fetching url: ${url}`);
|
|
631
|
+
logger.debug(`START fetching url: ${url}`);
|
|
596
632
|
if (body) {
|
|
597
|
-
debug(`Body:\r
|
|
633
|
+
logger.debug(`Body:\r
|
|
598
634
|
${typeof body == "string" ? body : JSON.stringify(body)}`);
|
|
599
635
|
}
|
|
600
|
-
debug(`Headers:\r
|
|
636
|
+
logger.debug(`Headers:\r
|
|
601
637
|
${JSON.stringify(payload.headers)}`);
|
|
602
638
|
const origResponse = await (0, import_cross_fetch.fetch)(url, payload);
|
|
603
639
|
const isJSONResponse = accept === "application/json" || origResponse.headers.get("Content-Type") === "application/json";
|
|
604
640
|
const success = origResponse && origResponse.status >= 200 && origResponse.status < 400;
|
|
605
641
|
const responseText = await origResponse.text();
|
|
606
642
|
const responseBody = isJSONResponse && responseText.includes("{") ? JSON.parse(responseText) : responseText;
|
|
607
|
-
debug(`${success ? "success" : "error"} status: ${origResponse.status}, body:\r
|
|
643
|
+
logger.debug(`${success ? "success" : "error"} status: ${origResponse.status}, body:\r
|
|
608
644
|
${JSON.stringify(responseBody)}`);
|
|
609
645
|
if (!success && opts?.exceptionOnHttpErrorStatus) {
|
|
610
646
|
const error = JSON.stringify(responseBody);
|
|
611
647
|
throw new Error(error === "{}" ? '{"error": "not found"}' : error);
|
|
612
648
|
}
|
|
613
|
-
debug(`END fetching url: ${url}`);
|
|
649
|
+
logger.debug(`END fetching url: ${url}`);
|
|
614
650
|
return {
|
|
615
651
|
origResponse,
|
|
616
652
|
successBody: success ? responseBody : void 0,
|
|
@@ -741,9 +777,11 @@ async function acquireDeferredCredentialImpl({ bearerToken, transactionId, defer
|
|
|
741
777
|
__name(acquireDeferredCredentialImpl, "acquireDeferredCredentialImpl");
|
|
742
778
|
|
|
743
779
|
// lib/functions/CredentialOfferUtil.ts
|
|
744
|
-
|
|
780
|
+
init_cjs_shims();
|
|
781
|
+
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
745
782
|
var import_jwt_decode = require("jwt-decode");
|
|
746
|
-
var
|
|
783
|
+
var import_oid4vc_common = require("@sphereon/oid4vc-common");
|
|
784
|
+
var logger2 = import_ssi_types2.Loggers.DEFAULT.get("sphereon:oid4vci:offer");
|
|
747
785
|
function determineSpecVersionFromURI(uri) {
|
|
748
786
|
let version = determineSpecVersionFromScheme(uri, OpenId4VCIVersion.VER_UNKNOWN) ?? OpenId4VCIVersion.VER_UNKNOWN;
|
|
749
787
|
version = getVersionFromURIParam(uri, version, [
|
|
@@ -762,42 +800,102 @@ function determineSpecVersionFromURI(uri) {
|
|
|
762
800
|
OpenId4VCIVersion.VER_1_0_11
|
|
763
801
|
], "grants.user_pin_required");
|
|
764
802
|
version = getVersionFromURIParam(uri, version, [
|
|
765
|
-
OpenId4VCIVersion.VER_1_0_13
|
|
803
|
+
OpenId4VCIVersion.VER_1_0_13,
|
|
804
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
766
805
|
], "credential_configuration_ids");
|
|
767
806
|
version = getVersionFromURIParam(uri, version, [
|
|
768
|
-
OpenId4VCIVersion.VER_1_0_13
|
|
807
|
+
OpenId4VCIVersion.VER_1_0_13,
|
|
808
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
769
809
|
], "tx_code");
|
|
810
|
+
version = getVersionFromURIParam(uri, version, [
|
|
811
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
812
|
+
], "credential_offer_uri ");
|
|
770
813
|
if (version === OpenId4VCIVersion.VER_UNKNOWN) {
|
|
771
|
-
version = OpenId4VCIVersion.
|
|
814
|
+
version = OpenId4VCIVersion.VER_1_0_15;
|
|
772
815
|
}
|
|
773
816
|
return version;
|
|
774
817
|
}
|
|
775
818
|
__name(determineSpecVersionFromURI, "determineSpecVersionFromURI");
|
|
776
819
|
function determineSpecVersionFromScheme(credentialOfferURI, openId4VCIVersion) {
|
|
777
820
|
const scheme = getScheme(credentialOfferURI);
|
|
778
|
-
|
|
821
|
+
const url = toUrlWithDummyBase(credentialOfferURI);
|
|
822
|
+
const qp = url.searchParams;
|
|
823
|
+
if (scheme === DefaultURISchemes.INITIATE_ISSUANCE) {
|
|
824
|
+
if (qp.has("credential_offer") || qp.has("credential_offer_uri")) {
|
|
825
|
+
return recordVersion(openId4VCIVersion, [
|
|
826
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
827
|
+
], scheme);
|
|
828
|
+
}
|
|
829
|
+
if (qp.has("credential_type") || qp.has("issuer")) {
|
|
830
|
+
return recordVersion(openId4VCIVersion, [
|
|
831
|
+
OpenId4VCIVersion.VER_1_0_08
|
|
832
|
+
], scheme);
|
|
833
|
+
}
|
|
779
834
|
return recordVersion(openId4VCIVersion, [
|
|
780
|
-
OpenId4VCIVersion.
|
|
835
|
+
OpenId4VCIVersion.VER_UNKNOWN
|
|
781
836
|
], scheme);
|
|
782
837
|
}
|
|
783
|
-
if (
|
|
784
|
-
|
|
785
|
-
} else if (credentialOfferURI.includes(DefaultURISchemes.CREDENTIAL_OFFER)) {
|
|
786
|
-
if (credentialOfferURI.includes("credentials:") || credentialOfferURI.includes("credentials%22")) {
|
|
838
|
+
if (scheme === DefaultURISchemes.CREDENTIAL_OFFER) {
|
|
839
|
+
if (qp.has("credential_offer_uri")) {
|
|
787
840
|
return recordVersion(openId4VCIVersion, [
|
|
788
|
-
OpenId4VCIVersion.
|
|
841
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
789
842
|
], scheme);
|
|
790
843
|
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
844
|
+
const rawParam = getParamValueLoose(qp, "credential_offer");
|
|
845
|
+
if (rawParam) {
|
|
846
|
+
const decoded = tryDecodeOffer(rawParam);
|
|
847
|
+
const version = sniffOfferVersion(decoded);
|
|
848
|
+
if (version !== OpenId4VCIVersion.VER_UNKNOWN) {
|
|
849
|
+
return recordVersion(openId4VCIVersion, [
|
|
850
|
+
version
|
|
851
|
+
], scheme);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
795
854
|
return recordVersion(openId4VCIVersion, [
|
|
796
855
|
OpenId4VCIVersion.VER_UNKNOWN
|
|
797
856
|
], scheme);
|
|
798
857
|
}
|
|
858
|
+
return recordVersion(openId4VCIVersion, [
|
|
859
|
+
OpenId4VCIVersion.VER_UNKNOWN
|
|
860
|
+
], scheme);
|
|
799
861
|
}
|
|
800
862
|
__name(determineSpecVersionFromScheme, "determineSpecVersionFromScheme");
|
|
863
|
+
function toUrlWithDummyBase(uri) {
|
|
864
|
+
const normalized = uri.replace(/^openid-[^?]+:\/\//, "https://dummy/?");
|
|
865
|
+
return new URL(normalized);
|
|
866
|
+
}
|
|
867
|
+
__name(toUrlWithDummyBase, "toUrlWithDummyBase");
|
|
868
|
+
function getParamValueLoose(qp, key) {
|
|
869
|
+
if (qp.has(key)) return qp.get(key);
|
|
870
|
+
if (qp.has(`?${key}`)) return qp.get(`?${key}`);
|
|
871
|
+
return null;
|
|
872
|
+
}
|
|
873
|
+
__name(getParamValueLoose, "getParamValueLoose");
|
|
874
|
+
function tryDecodeOffer(input) {
|
|
875
|
+
let candidate = input;
|
|
876
|
+
try {
|
|
877
|
+
candidate = decodeURIComponent(candidate);
|
|
878
|
+
} catch {
|
|
879
|
+
}
|
|
880
|
+
if (!/[{}]/.test(candidate) && /^[A-Za-z0-9\-_]+$/.test(candidate)) {
|
|
881
|
+
try {
|
|
882
|
+
const b64 = candidate.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(candidate.length / 4) * 4, "=");
|
|
883
|
+
candidate = atob(b64);
|
|
884
|
+
} catch {
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
return candidate;
|
|
888
|
+
}
|
|
889
|
+
__name(tryDecodeOffer, "tryDecodeOffer");
|
|
890
|
+
function sniffOfferVersion(jsonLike) {
|
|
891
|
+
if (!jsonLike) return OpenId4VCIVersion.VER_UNKNOWN;
|
|
892
|
+
const has = /* @__PURE__ */ __name((k) => new RegExp(`"${k}"\\s*:`, "i").test(jsonLike), "has");
|
|
893
|
+
if (has("credentials")) return OpenId4VCIVersion.VER_1_0_11;
|
|
894
|
+
if (has("credential_configuration_id")) return OpenId4VCIVersion.VER_1_0_13;
|
|
895
|
+
if (has("credential_configuration_ids")) return OpenId4VCIVersion.VER_1_0_15;
|
|
896
|
+
return OpenId4VCIVersion.VER_UNKNOWN;
|
|
897
|
+
}
|
|
898
|
+
__name(sniffOfferVersion, "sniffOfferVersion");
|
|
801
899
|
function getScheme(credentialOfferURI) {
|
|
802
900
|
if (!credentialOfferURI || !credentialOfferURI.includes("://")) {
|
|
803
901
|
throw Error("Invalid credential offer URI");
|
|
@@ -853,7 +951,9 @@ var getStateFromCredentialOfferPayload = /* @__PURE__ */ __name((credentialOffer
|
|
|
853
951
|
return;
|
|
854
952
|
}, "getStateFromCredentialOfferPayload");
|
|
855
953
|
function determineSpecVersionFromOffer(offer) {
|
|
856
|
-
if (
|
|
954
|
+
if (isCredentialOfferV1_0_15(offer)) {
|
|
955
|
+
return OpenId4VCIVersion.VER_1_0_15;
|
|
956
|
+
} else if (isCredentialOfferV1_0_13(offer)) {
|
|
857
957
|
return OpenId4VCIVersion.VER_1_0_13;
|
|
858
958
|
} else if (isCredentialOfferV1_0_11(offer)) {
|
|
859
959
|
return OpenId4VCIVersion.VER_1_0_11;
|
|
@@ -871,10 +971,10 @@ function isCredentialOfferVersion(offer, min, max) {
|
|
|
871
971
|
}
|
|
872
972
|
const version = determineSpecVersionFromOffer(offer);
|
|
873
973
|
if (version.valueOf() < min.valueOf()) {
|
|
874
|
-
|
|
974
|
+
logger2.debug(`Credential offer version (${version.valueOf()}) is lower than minimum required version (${min.valueOf()})`);
|
|
875
975
|
return false;
|
|
876
976
|
} else if (max && version.valueOf() > max.valueOf()) {
|
|
877
|
-
|
|
977
|
+
logger2.debug(`Credential offer version (${version.valueOf()}) is higher than maximum required version (${max.valueOf()})`);
|
|
878
978
|
return false;
|
|
879
979
|
}
|
|
880
980
|
return true;
|
|
@@ -934,6 +1034,20 @@ function isCredentialOfferV1_0_13(offer) {
|
|
|
934
1034
|
return "credential_offer_uri" in offer;
|
|
935
1035
|
}
|
|
936
1036
|
__name(isCredentialOfferV1_0_13, "isCredentialOfferV1_0_13");
|
|
1037
|
+
function isCredentialOfferV1_0_15(offer) {
|
|
1038
|
+
if (!offer) {
|
|
1039
|
+
return false;
|
|
1040
|
+
}
|
|
1041
|
+
offer = normalizeOfferInput(offer);
|
|
1042
|
+
if ("credential_issuer" in offer && "credential_configuration_ids" in offer) {
|
|
1043
|
+
return Array.isArray(offer.credential_configuration_ids);
|
|
1044
|
+
}
|
|
1045
|
+
if ("credential_offer" in offer && offer["credential_offer"]) {
|
|
1046
|
+
return isCredentialOfferV1_0_15(offer["credential_offer"]);
|
|
1047
|
+
}
|
|
1048
|
+
return "credential_offer_uri" in offer;
|
|
1049
|
+
}
|
|
1050
|
+
__name(isCredentialOfferV1_0_15, "isCredentialOfferV1_0_15");
|
|
937
1051
|
async function toUniformCredentialOfferRequest(offer, opts) {
|
|
938
1052
|
let version = opts?.version ?? determineSpecVersionFromOffer(offer);
|
|
939
1053
|
let originalCredentialOffer = offer.credential_offer;
|
|
@@ -969,6 +1083,7 @@ async function toUniformCredentialOfferRequest(offer, opts) {
|
|
|
969
1083
|
}
|
|
970
1084
|
__name(toUniformCredentialOfferRequest, "toUniformCredentialOfferRequest");
|
|
971
1085
|
function isPreAuthCode(request) {
|
|
1086
|
+
request = normalizeOfferInput(request);
|
|
972
1087
|
const payload = "credential_offer" in request ? request.credential_offer : request;
|
|
973
1088
|
return payload?.grants?.[PRE_AUTH_GRANT_LITERAL]?.[PRE_AUTH_CODE_LITERAL] !== void 0;
|
|
974
1089
|
}
|
|
@@ -1002,7 +1117,8 @@ async function resolveCredentialOfferURI(uri) {
|
|
|
1002
1117
|
return response.successBody;
|
|
1003
1118
|
}
|
|
1004
1119
|
__name(resolveCredentialOfferURI, "resolveCredentialOfferURI");
|
|
1005
|
-
function toUniformCredentialOfferPayload(
|
|
1120
|
+
function toUniformCredentialOfferPayload(rawOffer, opts) {
|
|
1121
|
+
const offer = normalizeOfferInput(rawOffer);
|
|
1006
1122
|
const version = opts?.version ?? determineSpecVersionFromOffer(offer);
|
|
1007
1123
|
if (version >= OpenId4VCIVersion.VER_1_0_11) {
|
|
1008
1124
|
const orig = offer;
|
|
@@ -1071,6 +1187,7 @@ function determineFlowType(suppliedOffer, version) {
|
|
|
1071
1187
|
}
|
|
1072
1188
|
__name(determineFlowType, "determineFlowType");
|
|
1073
1189
|
function getCredentialOfferPayload(offer) {
|
|
1190
|
+
offer = normalizeOfferInput(offer);
|
|
1074
1191
|
let payload;
|
|
1075
1192
|
if ("credential_offer" in offer && offer["credential_offer"]) {
|
|
1076
1193
|
payload = offer.credential_offer;
|
|
@@ -1081,6 +1198,7 @@ function getCredentialOfferPayload(offer) {
|
|
|
1081
1198
|
}
|
|
1082
1199
|
__name(getCredentialOfferPayload, "getCredentialOfferPayload");
|
|
1083
1200
|
function determineGrantTypes(offer) {
|
|
1201
|
+
offer = normalizeOfferInput(offer);
|
|
1084
1202
|
let grants;
|
|
1085
1203
|
if ("grants" in offer && offer.grants) {
|
|
1086
1204
|
grants = offer.grants;
|
|
@@ -1153,8 +1271,28 @@ function getTypesFromOfferV1_0_11(credentialOffer, opts) {
|
|
|
1153
1271
|
return types;
|
|
1154
1272
|
}
|
|
1155
1273
|
__name(getTypesFromOfferV1_0_11, "getTypesFromOfferV1_0_11");
|
|
1274
|
+
function getCredentialConfigurationIdsFromOfferV1_0_15(offer) {
|
|
1275
|
+
return offer.credential_configuration_ids ?? [];
|
|
1276
|
+
}
|
|
1277
|
+
__name(getCredentialConfigurationIdsFromOfferV1_0_15, "getCredentialConfigurationIdsFromOfferV1_0_15");
|
|
1278
|
+
function normalizeOfferInput(input) {
|
|
1279
|
+
if (typeof input !== "string") {
|
|
1280
|
+
return input;
|
|
1281
|
+
}
|
|
1282
|
+
if (import_ssi_types2.ObjectUtils.isString(input) && input.startsWith("ey")) {
|
|
1283
|
+
const payload = (0, import_oid4vc_common.base64urlToString)(input);
|
|
1284
|
+
return JSON.parse(payload);
|
|
1285
|
+
}
|
|
1286
|
+
try {
|
|
1287
|
+
return JSON.parse(input);
|
|
1288
|
+
} catch {
|
|
1289
|
+
}
|
|
1290
|
+
return input;
|
|
1291
|
+
}
|
|
1292
|
+
__name(normalizeOfferInput, "normalizeOfferInput");
|
|
1156
1293
|
|
|
1157
1294
|
// lib/functions/Encoding.ts
|
|
1295
|
+
init_cjs_shims();
|
|
1158
1296
|
function convertJsonToURI(json, opts) {
|
|
1159
1297
|
if (typeof json === "string") {
|
|
1160
1298
|
return convertJsonToURI(JSON.parse(json), opts);
|
|
@@ -1281,6 +1419,7 @@ function customEncodeURIComponent(uriComponent, searchValue) {
|
|
|
1281
1419
|
__name(customEncodeURIComponent, "customEncodeURIComponent");
|
|
1282
1420
|
|
|
1283
1421
|
// lib/functions/TypeConversionUtils.ts
|
|
1422
|
+
init_cjs_shims();
|
|
1284
1423
|
function isW3cCredentialSupported(supported) {
|
|
1285
1424
|
return [
|
|
1286
1425
|
"jwt_vc_json",
|
|
@@ -1394,8 +1533,9 @@ function getTypesFromCredentialSupported(credentialSupported, opts) {
|
|
|
1394
1533
|
__name(getTypesFromCredentialSupported, "getTypesFromCredentialSupported");
|
|
1395
1534
|
|
|
1396
1535
|
// lib/functions/IssuerMetadataUtils.ts
|
|
1536
|
+
init_cjs_shims();
|
|
1397
1537
|
function getSupportedCredentials(opts) {
|
|
1398
|
-
const { version = OpenId4VCIVersion.
|
|
1538
|
+
const { version = OpenId4VCIVersion.VER_1_0_15, types } = opts ?? {};
|
|
1399
1539
|
if (types && Array.isArray(types)) {
|
|
1400
1540
|
if (version < OpenId4VCIVersion.VER_1_0_13) {
|
|
1401
1541
|
return types.flatMap((typeSet) => getSupportedCredential({
|
|
@@ -1447,9 +1587,10 @@ function determineVersionsFromIssuerMetadata(issuerMetadata) {
|
|
|
1447
1587
|
}
|
|
1448
1588
|
__name(determineVersionsFromIssuerMetadata, "determineVersionsFromIssuerMetadata");
|
|
1449
1589
|
function getSupportedCredential(opts) {
|
|
1450
|
-
const { issuerMetadata, types, format, version = OpenId4VCIVersion.
|
|
1590
|
+
const { issuerMetadata, types, format, version = OpenId4VCIVersion.VER_1_0_15 } = opts ?? {};
|
|
1451
1591
|
let credentialConfigurationsV11 = void 0;
|
|
1452
1592
|
let credentialConfigurationsV13 = void 0;
|
|
1593
|
+
let credentialConfigurationsV15 = void 0;
|
|
1453
1594
|
if (version < OpenId4VCIVersion.VER_1_0_12 || issuerMetadata?.credential_configurations_supported === void 0 && issuerMetadata?.credentials_supported) {
|
|
1454
1595
|
if (issuerMetadata?.credentials_supported && !Array.isArray(issuerMetadata?.credentials_supported)) {
|
|
1455
1596
|
credentialConfigurationsV11 = [];
|
|
@@ -1459,15 +1600,25 @@ function getSupportedCredential(opts) {
|
|
|
1459
1600
|
}
|
|
1460
1601
|
credentialConfigurationsV11?.push(supported);
|
|
1461
1602
|
});
|
|
1603
|
+
} else if (version >= OpenId4VCIVersion.VER_1_0_15) {
|
|
1604
|
+
credentialConfigurationsV15 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1462
1605
|
} else {
|
|
1463
1606
|
credentialConfigurationsV11 = issuerMetadata?.credentials_supported ?? [];
|
|
1464
1607
|
}
|
|
1465
|
-
} else {
|
|
1608
|
+
} else if (version == OpenId4VCIVersion.VER_1_0_13) {
|
|
1466
1609
|
credentialConfigurationsV13 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1610
|
+
} else {
|
|
1611
|
+
credentialConfigurationsV15 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1467
1612
|
}
|
|
1468
1613
|
if (!issuerMetadata || !issuerMetadata.credential_configurations_supported && !issuerMetadata.credentials_supported) {
|
|
1469
1614
|
VCI_LOG_COMMON.warning(`No credential issuer metadata or supported credentials found for issuer}`);
|
|
1470
|
-
|
|
1615
|
+
if (version < OpenId4VCIVersion.VER_1_0_13) {
|
|
1616
|
+
return credentialConfigurationsV11;
|
|
1617
|
+
} else if (version >= OpenId4VCIVersion.VER_1_0_15) {
|
|
1618
|
+
return credentialConfigurationsV15;
|
|
1619
|
+
} else {
|
|
1620
|
+
return credentialConfigurationsV15;
|
|
1621
|
+
}
|
|
1471
1622
|
}
|
|
1472
1623
|
const normalizedTypes = Array.isArray(types) ? types : types ? [
|
|
1473
1624
|
types
|
|
@@ -1497,7 +1648,17 @@ function getSupportedCredential(opts) {
|
|
|
1497
1648
|
return isTypeMatch && isFormatMatch ? config : void 0;
|
|
1498
1649
|
}
|
|
1499
1650
|
__name(filterMatchingConfig, "filterMatchingConfig");
|
|
1500
|
-
if (
|
|
1651
|
+
if (credentialConfigurationsV15) {
|
|
1652
|
+
return Object.entries(credentialConfigurationsV15).reduce((filteredConfigs, [id, config]) => {
|
|
1653
|
+
if (filterMatchingConfig(config)) {
|
|
1654
|
+
filteredConfigs[id] = config;
|
|
1655
|
+
if (!config.id) {
|
|
1656
|
+
config.id = id;
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
return filteredConfigs;
|
|
1660
|
+
}, {});
|
|
1661
|
+
} else if (credentialConfigurationsV13) {
|
|
1501
1662
|
return Object.entries(credentialConfigurationsV13).reduce((filteredConfigs, [id, config]) => {
|
|
1502
1663
|
if (filterMatchingConfig(config)) {
|
|
1503
1664
|
filteredConfigs[id] = config;
|
|
@@ -1560,13 +1721,59 @@ function getIssuerName(url, credentialIssuerMetadata) {
|
|
|
1560
1721
|
}
|
|
1561
1722
|
__name(getIssuerName, "getIssuerName");
|
|
1562
1723
|
|
|
1724
|
+
// lib/functions/FormatUtils.ts
|
|
1725
|
+
init_cjs_shims();
|
|
1726
|
+
function isFormat(formatObject, format) {
|
|
1727
|
+
return formatObject.format === format;
|
|
1728
|
+
}
|
|
1729
|
+
__name(isFormat, "isFormat");
|
|
1730
|
+
function isNotFormat(formatObject, format) {
|
|
1731
|
+
return formatObject.format !== format;
|
|
1732
|
+
}
|
|
1733
|
+
__name(isNotFormat, "isNotFormat");
|
|
1734
|
+
var isUniformFormat = /* @__PURE__ */ __name((format) => {
|
|
1735
|
+
return [
|
|
1736
|
+
"jwt_vc_json",
|
|
1737
|
+
"jwt_vc_json-ld",
|
|
1738
|
+
"ldp_vc",
|
|
1739
|
+
"vc+sd-jwt",
|
|
1740
|
+
"mso_mdoc"
|
|
1741
|
+
].includes(format);
|
|
1742
|
+
}, "isUniformFormat");
|
|
1743
|
+
function getUniformFormat(format) {
|
|
1744
|
+
if (isUniformFormat(format)) {
|
|
1745
|
+
return format;
|
|
1746
|
+
}
|
|
1747
|
+
if (format.toLocaleLowerCase() === "jwt_vc" || format.toLocaleLowerCase() === "jwt") {
|
|
1748
|
+
return "jwt_vc";
|
|
1749
|
+
}
|
|
1750
|
+
if (format === "ldp_vc" || format === "ldp") {
|
|
1751
|
+
return "ldp_vc";
|
|
1752
|
+
}
|
|
1753
|
+
throw new Error(`Invalid format: ${format}`);
|
|
1754
|
+
}
|
|
1755
|
+
__name(getUniformFormat, "getUniformFormat");
|
|
1756
|
+
function getFormatForVersion(format, version) {
|
|
1757
|
+
const uniformFormat = isUniformFormat(format) ? format : getUniformFormat(format);
|
|
1758
|
+
if (version === OpenId4VCIVersion.VER_1_0_08) {
|
|
1759
|
+
if (uniformFormat === "jwt_vc_json") {
|
|
1760
|
+
return "jwt_vc";
|
|
1761
|
+
} else if (uniformFormat === "ldp_vc" || uniformFormat === "jwt_vc_json-ld") {
|
|
1762
|
+
return "ldp_vc";
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
return uniformFormat;
|
|
1766
|
+
}
|
|
1767
|
+
__name(getFormatForVersion, "getFormatForVersion");
|
|
1768
|
+
|
|
1563
1769
|
// lib/functions/ProofUtil.ts
|
|
1564
|
-
|
|
1770
|
+
init_cjs_shims();
|
|
1771
|
+
var import_ssi_types3 = require("@sphereon/ssi-types");
|
|
1565
1772
|
var import_jwt_decode2 = require("jwt-decode");
|
|
1566
|
-
var
|
|
1773
|
+
var logger3 = import_ssi_types3.Loggers.DEFAULT.get("sphereon:oid4vci:common");
|
|
1567
1774
|
var createProofOfPossession = /* @__PURE__ */ __name(async (popMode, callbacks, jwtProps, existingJwt) => {
|
|
1568
1775
|
if (!callbacks.signCallback) {
|
|
1569
|
-
|
|
1776
|
+
logger3.debug(`no jwt signer callback or arguments supplied!`);
|
|
1570
1777
|
throw new Error(BAD_PARAMS);
|
|
1571
1778
|
}
|
|
1572
1779
|
const jwtPayload = createJWT(popMode, jwtProps, existingJwt);
|
|
@@ -1578,18 +1785,18 @@ var createProofOfPossession = /* @__PURE__ */ __name(async (popMode, callbacks,
|
|
|
1578
1785
|
try {
|
|
1579
1786
|
partiallyValidateJWS(jwt);
|
|
1580
1787
|
if (callbacks.verifyCallback) {
|
|
1581
|
-
|
|
1788
|
+
logger3.debug(`Calling supplied verify callback....`);
|
|
1582
1789
|
await callbacks.verifyCallback({
|
|
1583
1790
|
jwt,
|
|
1584
1791
|
kid: jwtPayload.header.kid
|
|
1585
1792
|
});
|
|
1586
|
-
|
|
1793
|
+
logger3.debug(`Supplied verify callback return success result`);
|
|
1587
1794
|
}
|
|
1588
1795
|
} catch {
|
|
1589
|
-
|
|
1796
|
+
logger3.debug(`JWS was not valid`);
|
|
1590
1797
|
throw new Error(JWS_NOT_VALID);
|
|
1591
1798
|
}
|
|
1592
|
-
|
|
1799
|
+
logger3.debug(`Proof of Possession JWT:\r
|
|
1593
1800
|
${jwt}`);
|
|
1594
1801
|
return proof;
|
|
1595
1802
|
}, "createProofOfPossession");
|
|
@@ -1708,6 +1915,7 @@ var getJwtProperty = /* @__PURE__ */ __name((propertyName, required, option, jwt
|
|
|
1708
1915
|
}, "getJwtProperty");
|
|
1709
1916
|
|
|
1710
1917
|
// lib/functions/AuthorizationResponseUtil.ts
|
|
1918
|
+
init_cjs_shims();
|
|
1711
1919
|
var toAuthorizationResponsePayload = /* @__PURE__ */ __name((input) => {
|
|
1712
1920
|
let response = input;
|
|
1713
1921
|
if (typeof input === "string") {
|
|
@@ -1724,12 +1932,15 @@ var toAuthorizationResponsePayload = /* @__PURE__ */ __name((input) => {
|
|
|
1724
1932
|
}, "toAuthorizationResponsePayload");
|
|
1725
1933
|
|
|
1726
1934
|
// lib/functions/RandomUtils.ts
|
|
1727
|
-
|
|
1935
|
+
init_cjs_shims();
|
|
1936
|
+
var import_oid4vc_common2 = require("@sphereon/oid4vc-common");
|
|
1728
1937
|
var u8a = __toESM(require("uint8arrays"), 1);
|
|
1938
|
+
var import_randomBytes = __toESM(require_randomBytes(), 1);
|
|
1939
|
+
var { toString } = u8a;
|
|
1729
1940
|
var CODE_VERIFIER_DEFAULT_LENGTH = 128;
|
|
1730
1941
|
var NONCE_LENGTH = 32;
|
|
1731
1942
|
var generateRandomString = /* @__PURE__ */ __name((length, encoding) => {
|
|
1732
|
-
return
|
|
1943
|
+
return toString((0, import_randomBytes.default)(length), encoding).slice(0, length);
|
|
1733
1944
|
}, "generateRandomString");
|
|
1734
1945
|
var generateNonce = /* @__PURE__ */ __name((length) => {
|
|
1735
1946
|
return generateRandomString(length ?? NONCE_LENGTH);
|
|
@@ -1743,7 +1954,7 @@ var createCodeChallenge = /* @__PURE__ */ __name((codeVerifier, codeChallengeMet
|
|
|
1743
1954
|
if (codeChallengeMethod === CodeChallengeMethod.plain) {
|
|
1744
1955
|
return codeVerifier;
|
|
1745
1956
|
} else if (!codeChallengeMethod || codeChallengeMethod === CodeChallengeMethod.S256) {
|
|
1746
|
-
return
|
|
1957
|
+
return toString((0, import_oid4vc_common2.defaultHasher)(codeVerifier, "sha256"), "base64url");
|
|
1747
1958
|
} else {
|
|
1748
1959
|
throw Error(`code challenge method ${codeChallengeMethod} not implemented`);
|
|
1749
1960
|
}
|
|
@@ -1758,10 +1969,12 @@ var assertValidCodeVerifier = /* @__PURE__ */ __name((codeVerifier) => {
|
|
|
1758
1969
|
}, "assertValidCodeVerifier");
|
|
1759
1970
|
|
|
1760
1971
|
// lib/experimental/holder-vci.ts
|
|
1972
|
+
init_cjs_shims();
|
|
1761
1973
|
var EXPERIMENTAL_SUBJECT_PROOF_MODE_ENABLED = process.env.EXPERIMENTAL_SUBJECT_PROOF_MODE?.trim().toLowerCase() === "true";
|
|
1762
1974
|
|
|
1763
1975
|
// lib/events/index.ts
|
|
1764
|
-
|
|
1976
|
+
init_cjs_shims();
|
|
1977
|
+
var import_ssi_types4 = require("@sphereon/ssi-types");
|
|
1765
1978
|
var CredentialOfferEventNames = /* @__PURE__ */ function(CredentialOfferEventNames2) {
|
|
1766
1979
|
CredentialOfferEventNames2["OID4VCI_OFFER_CREATED"] = "OID4VCI_OFFER_CREATED";
|
|
1767
1980
|
CredentialOfferEventNames2["OID4VCI_OFFER_EXPIRED"] = "OID4VCI_OFFER_EXPIRED";
|
|
@@ -1778,141 +1991,9 @@ var NotificationStatusEventNames = /* @__PURE__ */ function(NotificationStatusEv
|
|
|
1778
1991
|
NotificationStatusEventNames2["OID4VCI_NOTIFICATION_ERROR"] = "OID4VCI_NOTIFICATION_ERROR";
|
|
1779
1992
|
return NotificationStatusEventNames2;
|
|
1780
1993
|
}({});
|
|
1781
|
-
var EVENTS =
|
|
1994
|
+
var EVENTS = import_ssi_types4.EventManager.instance();
|
|
1782
1995
|
|
|
1783
1996
|
// lib/index.ts
|
|
1784
|
-
var VCI_LOGGERS =
|
|
1997
|
+
var VCI_LOGGERS = import_ssi_types5.Loggers.DEFAULT;
|
|
1785
1998
|
var VCI_LOG_COMMON = VCI_LOGGERS.get("sphereon:oid4vci:common");
|
|
1786
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1787
|
-
0 && (module.exports = {
|
|
1788
|
-
ACCESS_TOKEN_ISSUER_REQUIRED_ERROR,
|
|
1789
|
-
ALG_ERROR,
|
|
1790
|
-
AUD_ERROR,
|
|
1791
|
-
Alg,
|
|
1792
|
-
AuthorizationChallengeError,
|
|
1793
|
-
AuthzFlowType,
|
|
1794
|
-
BAD_PARAMS,
|
|
1795
|
-
CODE_VERIFIER_DEFAULT_LENGTH,
|
|
1796
|
-
CREDENTIAL_MISSING_ERROR,
|
|
1797
|
-
CodeChallengeMethod,
|
|
1798
|
-
CreateRequestObjectMode,
|
|
1799
|
-
CredentialEventNames,
|
|
1800
|
-
CredentialOfferEventNames,
|
|
1801
|
-
DID_NO_DIDDOC_ERROR,
|
|
1802
|
-
DefaultURISchemes,
|
|
1803
|
-
EVENTS,
|
|
1804
|
-
EXPERIMENTAL_SUBJECT_PROOF_MODE_ENABLED,
|
|
1805
|
-
EXPIRED_PRE_AUTHORIZED_CODE,
|
|
1806
|
-
Encoding,
|
|
1807
|
-
GRANTS_MUST_NOT_BE_UNDEFINED,
|
|
1808
|
-
GrantTypes,
|
|
1809
|
-
IAT_ERROR,
|
|
1810
|
-
INVALID_PRE_AUTHORIZED_CODE,
|
|
1811
|
-
ISSUER_CONFIG_ERROR,
|
|
1812
|
-
ISS_MUST_BE_CLIENT_ID,
|
|
1813
|
-
ISS_PRESENT_IN_PRE_AUTHORIZED_CODE_CONTEXT,
|
|
1814
|
-
IssueStatus,
|
|
1815
|
-
JWS_NOT_VALID,
|
|
1816
|
-
JWT_SIGNER_CALLBACK_REQUIRED_ERROR,
|
|
1817
|
-
JWT_VERIFY_CONFIG_ERROR,
|
|
1818
|
-
JsonURIMode,
|
|
1819
|
-
KID_DID_NO_DID_ERROR,
|
|
1820
|
-
KID_JWK_X5C_ERROR,
|
|
1821
|
-
NONCE_ERROR,
|
|
1822
|
-
NONCE_LENGTH,
|
|
1823
|
-
NONCE_STATE_MANAGER_REQUIRED_ERROR,
|
|
1824
|
-
NO_ISS_IN_AUTHORIZATION_CODE_CONTEXT,
|
|
1825
|
-
NO_JWT_PROVIDED,
|
|
1826
|
-
NotificationStatusEventNames,
|
|
1827
|
-
OpenId4VCIVersion,
|
|
1828
|
-
PARMode,
|
|
1829
|
-
PIN_NOT_MATCH_ERROR,
|
|
1830
|
-
PIN_VALIDATION_ERROR,
|
|
1831
|
-
PRE_AUTHORIZED_CODE_REQUIRED_ERROR,
|
|
1832
|
-
PRE_AUTH_CODE_LITERAL,
|
|
1833
|
-
PRE_AUTH_GRANT_LITERAL,
|
|
1834
|
-
PROOF_CANT_BE_CONSTRUCTED,
|
|
1835
|
-
ResponseType,
|
|
1836
|
-
STATE_MANAGER_REQUIRED_ERROR,
|
|
1837
|
-
STATE_MISSING_ERROR,
|
|
1838
|
-
TYP_ERROR,
|
|
1839
|
-
TokenError,
|
|
1840
|
-
TokenErrorResponse,
|
|
1841
|
-
UNKNOWN_CLIENT_ERROR,
|
|
1842
|
-
UNSUPPORTED_GRANT_TYPE_ERROR,
|
|
1843
|
-
URL_NOT_VALID,
|
|
1844
|
-
USER_PIN_NOT_REQUIRED_ERROR,
|
|
1845
|
-
USER_PIN_REQUIRED_ERROR,
|
|
1846
|
-
USER_PIN_TX_CODE_SPEC_ERROR,
|
|
1847
|
-
VCI_LOGGERS,
|
|
1848
|
-
VCI_LOG_COMMON,
|
|
1849
|
-
WRONG_METADATA_FORMAT,
|
|
1850
|
-
WellKnownEndpoints,
|
|
1851
|
-
acquireDeferredCredential,
|
|
1852
|
-
adjustUrl,
|
|
1853
|
-
assertValidCodeVerifier,
|
|
1854
|
-
assertedUniformCredentialOffer,
|
|
1855
|
-
authorizationServerMetadataFieldNames,
|
|
1856
|
-
convertJsonToURI,
|
|
1857
|
-
convertURIToJsonObject,
|
|
1858
|
-
createCodeChallenge,
|
|
1859
|
-
createProofOfPossession,
|
|
1860
|
-
credentialIssuerMetadataFieldNames,
|
|
1861
|
-
credentialSupportedV8ToV13,
|
|
1862
|
-
credentialsSupportedV8ToV13,
|
|
1863
|
-
decodeJsonProperties,
|
|
1864
|
-
determineFlowType,
|
|
1865
|
-
determineGrantTypes,
|
|
1866
|
-
determineSpecVersionFromOffer,
|
|
1867
|
-
determineSpecVersionFromScheme,
|
|
1868
|
-
determineSpecVersionFromURI,
|
|
1869
|
-
determineVersionsFromIssuerMetadata,
|
|
1870
|
-
extractBearerToken,
|
|
1871
|
-
formPost,
|
|
1872
|
-
generateCodeVerifier,
|
|
1873
|
-
generateNonce,
|
|
1874
|
-
generateRandomString,
|
|
1875
|
-
getClientIdFromCredentialOfferPayload,
|
|
1876
|
-
getCredentialOfferPayload,
|
|
1877
|
-
getCredentialRequestForVersion,
|
|
1878
|
-
getFormatForVersion,
|
|
1879
|
-
getIssuerDisplays,
|
|
1880
|
-
getIssuerFromCredentialOfferPayload,
|
|
1881
|
-
getIssuerName,
|
|
1882
|
-
getJson,
|
|
1883
|
-
getNumberOrUndefined,
|
|
1884
|
-
getScheme,
|
|
1885
|
-
getStateFromCredentialOfferPayload,
|
|
1886
|
-
getSupportedCredential,
|
|
1887
|
-
getSupportedCredentials,
|
|
1888
|
-
getTypesFromAuthorizationDetails,
|
|
1889
|
-
getTypesFromCredentialOffer,
|
|
1890
|
-
getTypesFromCredentialSupported,
|
|
1891
|
-
getTypesFromObject,
|
|
1892
|
-
getTypesFromOfferV1_0_11,
|
|
1893
|
-
getTypesFromRequest,
|
|
1894
|
-
getURIComponentsAsArray,
|
|
1895
|
-
getUniformFormat,
|
|
1896
|
-
isAuthorizationRequestV1_0_09,
|
|
1897
|
-
isAuthorizationRequestV1_0_11,
|
|
1898
|
-
isCredentialOfferVersion,
|
|
1899
|
-
isDeferredCredentialIssuancePending,
|
|
1900
|
-
isDeferredCredentialResponse,
|
|
1901
|
-
isFormat,
|
|
1902
|
-
isJWS,
|
|
1903
|
-
isNotFormat,
|
|
1904
|
-
isPreAuthCode,
|
|
1905
|
-
isValidURL,
|
|
1906
|
-
isW3cCredentialSupported,
|
|
1907
|
-
post,
|
|
1908
|
-
randomBytes,
|
|
1909
|
-
resolveCredentialOfferURI,
|
|
1910
|
-
toAuthorizationResponsePayload,
|
|
1911
|
-
toUniformCredentialOfferPayload,
|
|
1912
|
-
toUniformCredentialOfferRequest,
|
|
1913
|
-
trimBoth,
|
|
1914
|
-
trimEnd,
|
|
1915
|
-
trimStart,
|
|
1916
|
-
validateJWT
|
|
1917
|
-
});
|
|
1918
1999
|
//# sourceMappingURL=index.cjs.map
|