@openid4vc/openid4vp 0.3.0-alpha-20250321202313 → 0.3.0-alpha-20250321205459
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +54 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -62
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -832,7 +832,7 @@ function parseOpenid4vpAuthorizationRequest(options) {
|
|
|
832
832
|
// src/authorization-request/resolve-authorization-request.ts
|
|
833
833
|
import { Oauth2ErrorCodes as Oauth2ErrorCodes9, Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError10 } from "@openid4vc/oauth2";
|
|
834
834
|
import { parseWithErrorHandling as parseWithErrorHandling4 } from "@openid4vc/utils";
|
|
835
|
-
import
|
|
835
|
+
import z13 from "zod";
|
|
836
836
|
|
|
837
837
|
// src/fetch-client-metadata.ts
|
|
838
838
|
import { Oauth2ErrorCodes as Oauth2ErrorCodes4, Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError5 } from "@openid4vc/oauth2";
|
|
@@ -936,23 +936,26 @@ function parseAuthorizationRequestVersion(request) {
|
|
|
936
936
|
|
|
937
937
|
// src/jar/jar-request-object/fetch-jar-request-object.ts
|
|
938
938
|
import { Oauth2ErrorCodes as Oauth2ErrorCodes6, Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError7 } from "@openid4vc/oauth2";
|
|
939
|
-
import { ContentType as ContentType2,
|
|
940
|
-
import { z as z11 } from "zod";
|
|
939
|
+
import { ContentType as ContentType2, defaultFetcher, objectToQueryParams as objectToQueryParams2 } from "@openid4vc/utils";
|
|
941
940
|
async function fetchJarRequestObject(options) {
|
|
942
|
-
const { requestUri, clientIdentifierScheme, method, wallet, fetch } = options;
|
|
943
|
-
const fetcher = createZodFetcher2(fetch);
|
|
941
|
+
const { requestUri, clientIdentifierScheme, method, wallet, fetch = defaultFetcher } = options;
|
|
944
942
|
let requestBody = wallet.metadata ? { wallet_metadata: wallet.metadata, wallet_nonce: wallet.nonce } : void 0;
|
|
945
943
|
if (requestBody?.wallet_metadata?.request_object_signing_alg_values_supported && clientIdentifierScheme === "redirect_uri") {
|
|
946
944
|
const { request_object_signing_alg_values_supported, ...rest } = requestBody.wallet_metadata;
|
|
947
945
|
requestBody = { ...requestBody, wallet_metadata: { ...rest } };
|
|
948
946
|
}
|
|
949
|
-
const
|
|
947
|
+
const response = await fetch(requestUri, {
|
|
950
948
|
method,
|
|
949
|
+
body: method === "POST" ? objectToQueryParams2(wallet.metadata ?? {}) : void 0,
|
|
951
950
|
headers: {
|
|
952
|
-
Accept: `${ContentType2.OAuthAuthorizationRequestJwt}, ${ContentType2.Jwt};q=0.9`,
|
|
951
|
+
Accept: `${ContentType2.OAuthAuthorizationRequestJwt}, ${ContentType2.Jwt};q=0.9, text/plain`,
|
|
953
952
|
"Content-Type": ContentType2.XWwwFormUrlencoded
|
|
954
|
-
}
|
|
955
|
-
|
|
953
|
+
}
|
|
954
|
+
}).catch(() => {
|
|
955
|
+
throw new Oauth2ServerErrorResponseError7({
|
|
956
|
+
error_description: `Fetching request_object from request_uri '${requestUri}' failed`,
|
|
957
|
+
error: Oauth2ErrorCodes6.InvalidRequestUri
|
|
958
|
+
});
|
|
956
959
|
});
|
|
957
960
|
if (!response.ok) {
|
|
958
961
|
throw new Oauth2ServerErrorResponseError7({
|
|
@@ -960,21 +963,15 @@ async function fetchJarRequestObject(options) {
|
|
|
960
963
|
error: Oauth2ErrorCodes6.InvalidRequestUri
|
|
961
964
|
});
|
|
962
965
|
}
|
|
963
|
-
|
|
964
|
-
throw new Oauth2ServerErrorResponseError7({
|
|
965
|
-
error_description: `Parsing request_object from request_uri '${requestUri}' failed.`,
|
|
966
|
-
error: Oauth2ErrorCodes6.InvalidRequestObject
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
return result.data;
|
|
966
|
+
return await response.text();
|
|
970
967
|
}
|
|
971
968
|
|
|
972
969
|
// src/jar/jar-request-object/z-jar-request-object.ts
|
|
973
970
|
import { zJwtPayload as zJwtPayload2 } from "@openid4vc/oauth2";
|
|
974
|
-
import { z as
|
|
975
|
-
var zJarRequestObjectPayload =
|
|
971
|
+
import { z as z11 } from "zod";
|
|
972
|
+
var zJarRequestObjectPayload = z11.object({
|
|
976
973
|
...zJwtPayload2.shape,
|
|
977
|
-
client_id:
|
|
974
|
+
client_id: z11.string()
|
|
978
975
|
}).passthrough();
|
|
979
976
|
|
|
980
977
|
// src/jar/handle-jar-request/verify-jar-request.ts
|
|
@@ -1078,13 +1075,13 @@ import { Oauth2ErrorCodes as Oauth2ErrorCodes8, Oauth2ServerErrorResponseError a
|
|
|
1078
1075
|
import { decodeBase64, encodeToUtf8String, parseIfJson } from "@openid4vc/utils";
|
|
1079
1076
|
|
|
1080
1077
|
// src/transaction-data/z-transaction-data.ts
|
|
1081
|
-
import { z as
|
|
1082
|
-
var zTransactionEntry =
|
|
1083
|
-
type:
|
|
1084
|
-
credential_ids:
|
|
1085
|
-
transaction_data_hashes_alg:
|
|
1078
|
+
import { z as z12 } from "zod";
|
|
1079
|
+
var zTransactionEntry = z12.object({
|
|
1080
|
+
type: z12.string(),
|
|
1081
|
+
credential_ids: z12.array(z12.string()).nonempty(),
|
|
1082
|
+
transaction_data_hashes_alg: z12.array(z12.string()).optional()
|
|
1086
1083
|
});
|
|
1087
|
-
var zTransactionData =
|
|
1084
|
+
var zTransactionData = z12.array(zTransactionEntry);
|
|
1088
1085
|
|
|
1089
1086
|
// src/transaction-data/parse-transaction-data.ts
|
|
1090
1087
|
function parseTransactionData(options) {
|
|
@@ -1109,7 +1106,7 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
|
|
|
1109
1106
|
const { wallet, callbacks, origin, disableOriginValidation } = options;
|
|
1110
1107
|
let authorizationRequestPayload;
|
|
1111
1108
|
const parsed = parseWithErrorHandling4(
|
|
1112
|
-
|
|
1109
|
+
z13.union([zOpenid4vpAuthorizationRequestDcApi, zOpenid4vpAuthorizationRequest, zJarAuthorizationRequest]),
|
|
1113
1110
|
options.authorizationRequestPayload,
|
|
1114
1111
|
"Invalid authorization request. Could not parse openid4vp authorization request as openid4vp or jar auth request."
|
|
1115
1112
|
);
|
|
@@ -1117,7 +1114,7 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
|
|
|
1117
1114
|
if (isJarAuthorizationRequest(parsed)) {
|
|
1118
1115
|
jar = await verifyJarRequest({ jarRequestParams: parsed, callbacks, wallet });
|
|
1119
1116
|
const parsedJarAuthorizationRequestPayload = parseWithErrorHandling4(
|
|
1120
|
-
|
|
1117
|
+
z13.union([zOpenid4vpAuthorizationRequestDcApi, zOpenid4vpAuthorizationRequest]),
|
|
1121
1118
|
jar.authorizationRequestPayload,
|
|
1122
1119
|
"Invalid authorization request. Could not parse jar request payload as openid4vp auth request."
|
|
1123
1120
|
);
|
|
@@ -1238,7 +1235,7 @@ async function createJarmAuthorizationResponse(options) {
|
|
|
1238
1235
|
}
|
|
1239
1236
|
|
|
1240
1237
|
// src/jarm/jarm-response-mode.ts
|
|
1241
|
-
import { z as
|
|
1238
|
+
import { z as z14 } from "zod";
|
|
1242
1239
|
var jarmResponseMode = [
|
|
1243
1240
|
"jwt",
|
|
1244
1241
|
"query.jwt",
|
|
@@ -1247,7 +1244,7 @@ var jarmResponseMode = [
|
|
|
1247
1244
|
"direct_post.jwt",
|
|
1248
1245
|
"dc_api.jwt"
|
|
1249
1246
|
];
|
|
1250
|
-
var zJarmResponseMode =
|
|
1247
|
+
var zJarmResponseMode = z14.enum(jarmResponseMode);
|
|
1251
1248
|
var isJarmResponseMode = (responseMode) => {
|
|
1252
1249
|
return jarmResponseMode.includes(responseMode);
|
|
1253
1250
|
};
|
|
@@ -1380,12 +1377,12 @@ async function createOpenid4vpAuthorizationResponse(options) {
|
|
|
1380
1377
|
|
|
1381
1378
|
// src/authorization-response/submit-authorization-response.ts
|
|
1382
1379
|
import { Oauth2Error as Oauth2Error9 } from "@openid4vc/oauth2";
|
|
1383
|
-
import { ContentType as ContentType4, defaultFetcher as
|
|
1380
|
+
import { ContentType as ContentType4, defaultFetcher as defaultFetcher3 } from "@openid4vc/utils";
|
|
1384
1381
|
import { objectToQueryParams as objectToQueryParams3 } from "@openid4vc/utils";
|
|
1385
1382
|
|
|
1386
1383
|
// src/jarm/jarm-authorizatino-response-send.ts
|
|
1387
1384
|
import { Oauth2Error as Oauth2Error8 } from "@openid4vc/oauth2";
|
|
1388
|
-
import { ContentType as ContentType3, URL as URL4, defaultFetcher } from "@openid4vc/utils";
|
|
1385
|
+
import { ContentType as ContentType3, URL as URL4, defaultFetcher as defaultFetcher2 } from "@openid4vc/utils";
|
|
1389
1386
|
var jarmAuthorizationResponseSend = (options) => {
|
|
1390
1387
|
const { authorizationRequestPayload, jarmAuthorizationResponseJwt, callbacks } = options;
|
|
1391
1388
|
const responseEndpoint = authorizationRequestPayload.response_uri ?? authorizationRequestPayload.redirect_uri;
|
|
@@ -1396,7 +1393,7 @@ var jarmAuthorizationResponseSend = (options) => {
|
|
|
1396
1393
|
return handleDirectPostJwt(responseEndpointUrl, jarmAuthorizationResponseJwt, callbacks);
|
|
1397
1394
|
};
|
|
1398
1395
|
async function handleDirectPostJwt(responseEndpoint, responseJwt, callbacks) {
|
|
1399
|
-
const response = await (callbacks.fetch ??
|
|
1396
|
+
const response = await (callbacks.fetch ?? defaultFetcher2)(responseEndpoint, {
|
|
1400
1397
|
method: "POST",
|
|
1401
1398
|
headers: { "Content-Type": ContentType3.XWwwFormUrlencoded },
|
|
1402
1399
|
body: `response=${responseJwt}`
|
|
@@ -1423,7 +1420,7 @@ async function submitOpenid4vpAuthorizationResponse(options) {
|
|
|
1423
1420
|
"Failed to submit OpenId4Vp Authorization Response. No redirect_uri or response_uri provided."
|
|
1424
1421
|
);
|
|
1425
1422
|
}
|
|
1426
|
-
const fetch = callbacks.fetch ??
|
|
1423
|
+
const fetch = callbacks.fetch ?? defaultFetcher3;
|
|
1427
1424
|
const encodedResponse = objectToQueryParams3(authorizationResponsePayload);
|
|
1428
1425
|
const submissionResponse = await fetch(url, {
|
|
1429
1426
|
method: "POST",
|
|
@@ -1445,17 +1442,17 @@ import { Oauth2Error as Oauth2Error10 } from "@openid4vc/oauth2";
|
|
|
1445
1442
|
import { parseIfJson as parseIfJson2, parseWithErrorHandling as parseWithErrorHandling5 } from "@openid4vc/utils";
|
|
1446
1443
|
|
|
1447
1444
|
// src/vp-token/z-vp-token.ts
|
|
1448
|
-
import { z as
|
|
1449
|
-
var zVpTokenPexEntry =
|
|
1445
|
+
import { z as z15 } from "zod";
|
|
1446
|
+
var zVpTokenPexEntry = z15.union([z15.string(), z15.record(z15.any())], {
|
|
1450
1447
|
message: "pex vp_token entry must be a string or object"
|
|
1451
1448
|
});
|
|
1452
|
-
var zVpTokenPex =
|
|
1453
|
-
[zVpTokenPexEntry,
|
|
1449
|
+
var zVpTokenPex = z15.union(
|
|
1450
|
+
[zVpTokenPexEntry, z15.array(zVpTokenPexEntry).nonempty("Must have at least entry in vp_token array")],
|
|
1454
1451
|
{
|
|
1455
1452
|
message: "pex vp_token must be a string, object or array of strings and objects"
|
|
1456
1453
|
}
|
|
1457
1454
|
);
|
|
1458
|
-
var zVpTokenDcql =
|
|
1455
|
+
var zVpTokenDcql = z15.record(z15.union([z15.string(), z15.record(z15.any())]), {
|
|
1459
1456
|
message: "dcql vp_token must be an object with keys referencing the dcql credential query id, and values the encoded (string or object) presentation"
|
|
1460
1457
|
});
|
|
1461
1458
|
var zVpToken = zVpTokenDcql.or(zVpTokenPex);
|
|
@@ -1529,23 +1526,23 @@ import { parseWithErrorHandling as parseWithErrorHandling6 } from "@openid4vc/ut
|
|
|
1529
1526
|
|
|
1530
1527
|
// src/authorization-response/z-authorization-response.ts
|
|
1531
1528
|
import { zStringToJson as zStringToJson2 } from "@openid4vc/utils";
|
|
1532
|
-
import { z as
|
|
1529
|
+
import { z as z17 } from "zod";
|
|
1533
1530
|
|
|
1534
1531
|
// src/models/z-pex.ts
|
|
1535
|
-
import { z as
|
|
1536
|
-
var zPexPresentationDefinition =
|
|
1537
|
-
var zPexPresentationSubmission =
|
|
1532
|
+
import { z as z16 } from "zod";
|
|
1533
|
+
var zPexPresentationDefinition = z16.record(z16.any());
|
|
1534
|
+
var zPexPresentationSubmission = z16.record(z16.any());
|
|
1538
1535
|
|
|
1539
1536
|
// src/authorization-response/z-authorization-response.ts
|
|
1540
|
-
var zOpenid4vpAuthorizationResponse =
|
|
1541
|
-
state:
|
|
1542
|
-
id_token:
|
|
1537
|
+
var zOpenid4vpAuthorizationResponse = z17.object({
|
|
1538
|
+
state: z17.string().optional(),
|
|
1539
|
+
id_token: z17.string().optional(),
|
|
1543
1540
|
vp_token: zVpToken,
|
|
1544
1541
|
presentation_submission: zPexPresentationSubmission.or(zStringToJson2).optional(),
|
|
1545
|
-
refresh_token:
|
|
1546
|
-
token_type:
|
|
1547
|
-
access_token:
|
|
1548
|
-
expires_in:
|
|
1542
|
+
refresh_token: z17.string().optional(),
|
|
1543
|
+
token_type: z17.string().optional(),
|
|
1544
|
+
access_token: z17.string().optional(),
|
|
1545
|
+
expires_in: z17.number().optional()
|
|
1549
1546
|
}).passthrough();
|
|
1550
1547
|
|
|
1551
1548
|
// src/authorization-response/parse-authorization-response-payload.ts
|
|
@@ -1560,11 +1557,11 @@ function parseOpenid4VpAuthorizationResponsePayload(payload) {
|
|
|
1560
1557
|
// src/authorization-response/parse-jarm-authorization-response.ts
|
|
1561
1558
|
import { Oauth2Error as Oauth2Error11, decodeJwtHeader, zCompactJwe as zCompactJwe3, zCompactJwt as zCompactJwt3 } from "@openid4vc/oauth2";
|
|
1562
1559
|
import { parseWithErrorHandling as parseWithErrorHandling7 } from "@openid4vc/utils";
|
|
1563
|
-
import
|
|
1560
|
+
import z18 from "zod";
|
|
1564
1561
|
async function parseJarmAuthorizationResponse(options) {
|
|
1565
1562
|
const { jarmResponseJwt, callbacks, authorizationRequestPayload, expectedClientId } = options;
|
|
1566
1563
|
const jarmAuthorizationResponseJwt = parseWithErrorHandling7(
|
|
1567
|
-
|
|
1564
|
+
z18.union([zCompactJwt3, zCompactJwe3]),
|
|
1568
1565
|
jarmResponseJwt,
|
|
1569
1566
|
"Invalid jarm authorization response jwt."
|
|
1570
1567
|
);
|
|
@@ -1762,22 +1759,22 @@ var Openid4vpVerifier = class {
|
|
|
1762
1759
|
};
|
|
1763
1760
|
|
|
1764
1761
|
// src/models/z-credential-formats.ts
|
|
1765
|
-
import { z as
|
|
1766
|
-
var zCredentialFormat =
|
|
1762
|
+
import { z as z19 } from "zod";
|
|
1763
|
+
var zCredentialFormat = z19.enum(["jwt_vc_json", "ldp_vc", "ac_vc", "mso_mdoc", "dc+sd-jwt", "vc+sd-jwt"]);
|
|
1767
1764
|
|
|
1768
1765
|
// src/models/z-proof-formats.ts
|
|
1769
|
-
import { z as
|
|
1770
|
-
var zProofFormat =
|
|
1766
|
+
import { z as z20 } from "zod";
|
|
1767
|
+
var zProofFormat = z20.enum(["jwt_vp_json", "ldc_vp", "ac_vp", "dc+sd-jwt", "vc+sd-jwt", "mso_mdoc"]);
|
|
1771
1768
|
|
|
1772
1769
|
// src/models/z-wallet-metadata.ts
|
|
1773
|
-
import { z as
|
|
1774
|
-
var zWalletMetadata =
|
|
1775
|
-
presentation_definition_uri_supported:
|
|
1770
|
+
import { z as z21 } from "zod";
|
|
1771
|
+
var zWalletMetadata = z21.object({
|
|
1772
|
+
presentation_definition_uri_supported: z21.optional(z21.boolean()),
|
|
1776
1773
|
vp_formats_supported: zVpFormatsSupported,
|
|
1777
|
-
client_id_schemes_supported:
|
|
1778
|
-
request_object_signing_alg_values_supported:
|
|
1779
|
-
authorization_encryption_alg_values_supported:
|
|
1780
|
-
authorization_encryption_enc_values_supported:
|
|
1774
|
+
client_id_schemes_supported: z21.optional(z21.array(zClientIdScheme)),
|
|
1775
|
+
request_object_signing_alg_values_supported: z21.optional(z21.array(z21.string())),
|
|
1776
|
+
authorization_encryption_alg_values_supported: z21.optional(z21.array(z21.string())),
|
|
1777
|
+
authorization_encryption_enc_values_supported: z21.optional(z21.array(z21.string()))
|
|
1781
1778
|
});
|
|
1782
1779
|
export {
|
|
1783
1780
|
JarmMode,
|