@openid4vc/openid4vci 0.3.0-alpha-20250320203319 → 0.3.0-alpha-20250320210854

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { getGlobalConfig as getGlobalConfig2, setGlobalConfig } from "@openid4vc/utils";
2
+ import { getGlobalConfig, setGlobalConfig } from "@openid4vc/utils";
3
3
 
4
4
  // src/credential-request/credential-request-configurations.ts
5
5
  import { arrayEqualsIgnoreOrder } from "@openid4vc/utils";
@@ -697,65 +697,42 @@ import {
697
697
  import {
698
698
  preAuthorizedCodeGrantIdentifier
699
699
  } from "@openid4vc/oauth2";
700
- import z11 from "zod";
701
-
702
- // ../utils/src/validation.ts
700
+ import { zHttpsUrl as zHttpsUrl2 } from "@openid4vc/utils";
703
701
  import z10 from "zod";
704
-
705
- // ../utils/src/config.ts
706
- var GLOBAL_CONFIG = {
707
- allowInsecureUrls: false
708
- };
709
- function getGlobalConfig() {
710
- return GLOBAL_CONFIG;
711
- }
712
-
713
- // ../utils/src/validation.ts
714
- var zHttpsUrl2 = z10.string().url().refine(
715
- (url) => {
716
- const { allowInsecureUrls } = getGlobalConfig();
717
- return allowInsecureUrls ? url.startsWith("http://") || url.startsWith("https://") : url.startsWith("https://");
718
- },
719
- { message: "url must be an https:// url" }
720
- );
721
- var zInteger2 = z10.number().int();
722
- var zHttpMethod = z10.enum(["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE", "CONNECT", "PATCH"]);
723
-
724
- // src/credential-offer/z-credential-offer.ts
725
- var zTxCode = z11.object({
726
- input_mode: z11.union([z11.literal("numeric"), z11.literal("text")]).optional(),
727
- length: z11.number().int().optional(),
728
- description: z11.string().max(300).optional()
702
+ var zTxCode = z10.object({
703
+ input_mode: z10.union([z10.literal("numeric"), z10.literal("text")]).optional(),
704
+ length: z10.number().int().optional(),
705
+ description: z10.string().max(300).optional()
729
706
  }).passthrough();
730
- var zCredentialOfferGrants = z11.object({
731
- authorization_code: z11.object({
732
- issuer_state: z11.string().optional(),
707
+ var zCredentialOfferGrants = z10.object({
708
+ authorization_code: z10.object({
709
+ issuer_state: z10.string().optional(),
733
710
  authorization_server: zHttpsUrl2.optional()
734
711
  }).passthrough().optional(),
735
- [preAuthorizedCodeGrantIdentifier]: z11.object({
736
- "pre-authorized_code": z11.string(),
712
+ [preAuthorizedCodeGrantIdentifier]: z10.object({
713
+ "pre-authorized_code": z10.string(),
737
714
  tx_code: zTxCode.optional(),
738
715
  authorization_server: zHttpsUrl2.optional()
739
716
  }).passthrough().optional()
740
717
  }).passthrough();
741
- var zCredentialOfferObjectDraft14 = z11.object({
718
+ var zCredentialOfferObjectDraft14 = z10.object({
742
719
  credential_issuer: zHttpsUrl2,
743
- credential_configuration_ids: z11.array(z11.string()),
744
- grants: z11.optional(zCredentialOfferGrants)
720
+ credential_configuration_ids: z10.array(z10.string()),
721
+ grants: z10.optional(zCredentialOfferGrants)
745
722
  }).passthrough();
746
- var zCredentialOfferObjectDraft11To14 = z11.object({
723
+ var zCredentialOfferObjectDraft11To14 = z10.object({
747
724
  credential_issuer: zHttpsUrl2,
748
725
  // We don't support the inline offer objects from draft 11
749
- credentials: z11.array(
750
- z11.string({ message: "Only string credential identifiers are supported for draft 11 credential offers" })
726
+ credentials: z10.array(
727
+ z10.string({ message: "Only string credential identifiers are supported for draft 11 credential offers" })
751
728
  ),
752
- grants: z11.optional(
753
- z11.object({
729
+ grants: z10.optional(
730
+ z10.object({
754
731
  // Has extra param in draft 14, but doesn't matter for transform purposes
755
732
  authorization_code: zCredentialOfferGrants.shape.authorization_code,
756
- [preAuthorizedCodeGrantIdentifier]: z11.object({
757
- "pre-authorized_code": z11.string(),
758
- user_pin_required: z11.optional(z11.boolean())
733
+ [preAuthorizedCodeGrantIdentifier]: z10.object({
734
+ "pre-authorized_code": z10.string(),
735
+ user_pin_required: z10.optional(z10.boolean())
759
736
  }).passthrough().optional()
760
737
  })
761
738
  )
@@ -780,7 +757,7 @@ var zCredentialOfferObjectDraft11To14 = z11.object({
780
757
  }
781
758
  return v14;
782
759
  }).pipe(zCredentialOfferObjectDraft14);
783
- var zCredentialOfferObject = z11.union([
760
+ var zCredentialOfferObject = z10.union([
784
761
  // First prioritize draft 14 (and 13)
785
762
  zCredentialOfferObjectDraft14,
786
763
  // Then try parsing draft 11 and transform into draft 14
@@ -976,74 +953,74 @@ import {
976
953
  import { ContentType as ContentType2, isResponseContentType, parseWithErrorHandling as parseWithErrorHandling2 } from "@openid4vc/utils";
977
954
 
978
955
  // src/credential-request/z-credential-request.ts
979
- import z15 from "zod";
956
+ import z14 from "zod";
980
957
 
981
958
  // src/credential-request/z-credential-request-common.ts
982
959
  import { zJwk as zJwk2 } from "@openid4vc/oauth2";
983
- import z14 from "zod";
960
+ import z13 from "zod";
984
961
 
985
962
  // src/formats/proof-type/jwt/z-jwt-proof-type.ts
986
963
  import { zCompactJwt as zCompactJwt2, zJwtHeader as zJwtHeader2, zJwtPayload as zJwtPayload2 } from "@openid4vc/oauth2";
987
- import { zHttpsUrl as zHttpsUrl3, zInteger as zInteger3 } from "@openid4vc/utils";
988
- import z12 from "zod";
989
- var zJwtProofTypeIdentifier = z12.literal("jwt");
964
+ import { zHttpsUrl as zHttpsUrl3, zInteger as zInteger2 } from "@openid4vc/utils";
965
+ import z11 from "zod";
966
+ var zJwtProofTypeIdentifier = z11.literal("jwt");
990
967
  var jwtProofTypeIdentifier = zJwtProofTypeIdentifier.value;
991
- var zCredentialRequestProofJwt = z12.object({
968
+ var zCredentialRequestProofJwt = z11.object({
992
969
  proof_type: zJwtProofTypeIdentifier,
993
970
  jwt: zCompactJwt2
994
971
  });
995
972
  var zCredentialRequestJwtProofTypeHeader = zJwtHeader2.merge(
996
- z12.object({
997
- key_attestation: z12.optional(zCompactJwt2),
998
- typ: z12.literal("openid4vci-proof+jwt")
973
+ z11.object({
974
+ key_attestation: z11.optional(zCompactJwt2),
975
+ typ: z11.literal("openid4vci-proof+jwt")
999
976
  })
1000
977
  ).passthrough().refine(({ kid, jwk }) => jwk === void 0 || kid === void 0, {
1001
978
  message: `Both 'jwk' and 'kid' are defined. Only one is allowed`
1002
979
  }).refine(({ trust_chain, kid }) => !trust_chain || !kid, {
1003
980
  message: `When 'trust_chain' is provided, 'kid' is required`
1004
981
  });
1005
- var zCredentialRequestJwtProofTypePayload = z12.object({
982
+ var zCredentialRequestJwtProofTypePayload = z11.object({
1006
983
  ...zJwtPayload2.shape,
1007
984
  aud: zHttpsUrl3,
1008
- iat: zInteger3
985
+ iat: zInteger2
1009
986
  }).passthrough();
1010
987
 
1011
988
  // src/formats/proof-type/attestation/z-attestation-proof-type.ts
1012
989
  import { zCompactJwt as zCompactJwt3 } from "@openid4vc/oauth2";
1013
- import z13 from "zod";
1014
- var zAttestationProofTypeIdentifier = z13.literal("attestation");
990
+ import z12 from "zod";
991
+ var zAttestationProofTypeIdentifier = z12.literal("attestation");
1015
992
  var attestationProofTypeIdentifier = zAttestationProofTypeIdentifier.value;
1016
- var zCredentialRequestProofAttestation = z13.object({
993
+ var zCredentialRequestProofAttestation = z12.object({
1017
994
  proof_type: zAttestationProofTypeIdentifier,
1018
995
  attestation: zCompactJwt3
1019
996
  });
1020
997
  var zCredentialRequestAttestationProofTypePayload = zKeyAttestationJwtPayloadForUse("proof_type.attestation");
1021
998
 
1022
999
  // src/credential-request/z-credential-request-common.ts
1023
- var zCredentialRequestProofCommon = z14.object({
1024
- proof_type: z14.string()
1000
+ var zCredentialRequestProofCommon = z13.object({
1001
+ proof_type: z13.string()
1025
1002
  }).passthrough();
1026
1003
  var allCredentialRequestProofs = [zCredentialRequestProofJwt, zCredentialRequestProofAttestation];
1027
- var zCredentialRequestProof = z14.union([
1004
+ var zCredentialRequestProof = z13.union([
1028
1005
  zCredentialRequestProofCommon,
1029
- z14.discriminatedUnion("proof_type", allCredentialRequestProofs)
1006
+ z13.discriminatedUnion("proof_type", allCredentialRequestProofs)
1030
1007
  ]);
1031
- var zCredentialRequestProofsCommon = z14.record(z14.string(), z14.array(z14.unknown()));
1032
- var zCredentialRequestProofs = z14.object({
1033
- [zJwtProofTypeIdentifier.value]: z14.optional(z14.array(zCredentialRequestProofJwt.shape.jwt)),
1034
- [zAttestationProofTypeIdentifier.value]: z14.optional(z14.array(zCredentialRequestProofAttestation.shape.attestation))
1008
+ var zCredentialRequestProofsCommon = z13.record(z13.string(), z13.array(z13.unknown()));
1009
+ var zCredentialRequestProofs = z13.object({
1010
+ [zJwtProofTypeIdentifier.value]: z13.optional(z13.array(zCredentialRequestProofJwt.shape.jwt)),
1011
+ [zAttestationProofTypeIdentifier.value]: z13.optional(z13.array(zCredentialRequestProofAttestation.shape.attestation))
1035
1012
  });
1036
- var zCredentialRequestCommon = z14.object({
1013
+ var zCredentialRequestCommon = z13.object({
1037
1014
  proof: zCredentialRequestProof.optional(),
1038
- proofs: z14.optional(
1039
- z14.intersection(zCredentialRequestProofsCommon, zCredentialRequestProofs).refine((proofs) => Object.values(proofs).length === 1, {
1015
+ proofs: z13.optional(
1016
+ z13.intersection(zCredentialRequestProofsCommon, zCredentialRequestProofs).refine((proofs) => Object.values(proofs).length === 1, {
1040
1017
  message: `The 'proofs' object in a credential request should contain exactly one attribute`
1041
1018
  })
1042
1019
  ),
1043
- credential_response_encryption: z14.object({
1020
+ credential_response_encryption: z13.object({
1044
1021
  jwk: zJwk2,
1045
- alg: z14.string(),
1046
- enc: z14.string()
1022
+ alg: z13.string(),
1023
+ enc: z13.string()
1047
1024
  }).passthrough().optional()
1048
1025
  }).passthrough().refine(({ proof, proofs }) => !(proof !== void 0 && proofs !== void 0), {
1049
1026
  message: `Both 'proof' and 'proofs' are defined. Only one is allowed`
@@ -1060,27 +1037,27 @@ var allCredentialRequestFormats = [
1060
1037
  var allCredentialRequestFormatIdentifiers = allCredentialRequestFormats.map(
1061
1038
  (format) => format.shape.format.value
1062
1039
  );
1063
- var zAuthorizationDetailsCredentialRequest = z15.object({
1064
- credential_identifier: z15.string(),
1040
+ var zAuthorizationDetailsCredentialRequest = z14.object({
1041
+ credential_identifier: z14.string(),
1065
1042
  // Cannot be present if credential identifier is present
1066
- format: z15.never({ message: "'format' cannot be defined when 'credential_identifier' is set." }).optional()
1043
+ format: z14.never({ message: "'format' cannot be defined when 'credential_identifier' is set." }).optional()
1067
1044
  });
1068
- var zCredentialRequestFormatNoCredentialIdentifier = z15.object({
1069
- format: z15.string(),
1070
- credential_identifier: z15.never({ message: "'credential_identifier' cannot be defined when 'format' is set." }).optional()
1045
+ var zCredentialRequestFormatNoCredentialIdentifier = z14.object({
1046
+ format: z14.string(),
1047
+ credential_identifier: z14.never({ message: "'credential_identifier' cannot be defined when 'format' is set." }).optional()
1071
1048
  }).passthrough();
1072
1049
  var zCredenialRequestDraft14WithFormat = zCredentialRequestCommon.and(zCredentialRequestFormatNoCredentialIdentifier).transform((data, ctx) => {
1073
1050
  if (!allCredentialRequestFormatIdentifiers.includes(data.format)) return data;
1074
- const result = z15.object({}).passthrough().and(z15.discriminatedUnion("format", allCredentialRequestFormats)).safeParse(data);
1051
+ const result = z14.object({}).passthrough().and(z14.discriminatedUnion("format", allCredentialRequestFormats)).safeParse(data);
1075
1052
  if (result.success) {
1076
1053
  return result.data;
1077
1054
  }
1078
1055
  for (const issue of result.error.issues) {
1079
1056
  ctx.addIssue(issue);
1080
1057
  }
1081
- return z15.NEVER;
1058
+ return z14.NEVER;
1082
1059
  });
1083
- var zCredentialRequestDraft14 = z15.union([
1060
+ var zCredentialRequestDraft14 = z14.union([
1084
1061
  zCredenialRequestDraft14WithFormat,
1085
1062
  zCredentialRequestCommon.and(zAuthorizationDetailsCredentialRequest)
1086
1063
  ]);
@@ -1097,7 +1074,7 @@ var zCredentialRequestDraft11To14 = zCredentialRequestCommon.and(zCredentialRequ
1097
1074
  for (const issue of result.error.issues) {
1098
1075
  ctx.addIssue(issue);
1099
1076
  }
1100
- return z15.NEVER;
1077
+ return z14.NEVER;
1101
1078
  }).pipe(zCredentialRequestDraft14);
1102
1079
  var zCredentialRequestDraft14To11 = zCredentialRequestDraft14.refine(
1103
1080
  (data) => data.credential_identifier === void 0,
@@ -1115,15 +1092,15 @@ var zCredentialRequestDraft14To11 = zCredentialRequestDraft14.refine(
1115
1092
  for (const issue of result.error.issues) {
1116
1093
  ctx.addIssue(issue);
1117
1094
  }
1118
- return z15.NEVER;
1095
+ return z14.NEVER;
1119
1096
  });
1120
- var zCredentialRequest = z15.union([zCredentialRequestDraft14, zCredentialRequestDraft11To14]);
1097
+ var zCredentialRequest = z14.union([zCredentialRequestDraft14, zCredentialRequestDraft11To14]);
1121
1098
 
1122
1099
  // src/credential-request/z-credential-response.ts
1123
- import z17 from "zod";
1100
+ import z16 from "zod";
1124
1101
 
1125
1102
  // ../oauth2/src/common/z-oauth2-error.ts
1126
- import z16 from "zod";
1103
+ import z15 from "zod";
1127
1104
  var Oauth2ErrorCodes = /* @__PURE__ */ ((Oauth2ErrorCodes4) => {
1128
1105
  Oauth2ErrorCodes4["ServerError"] = "server_error";
1129
1106
  Oauth2ErrorCodes4["InvalidTarget"] = "invalid_target";
@@ -1160,21 +1137,21 @@ var Oauth2ErrorCodes = /* @__PURE__ */ ((Oauth2ErrorCodes4) => {
1160
1137
  Oauth2ErrorCodes4["WalletUnavailable"] = "wallet_unavailable";
1161
1138
  return Oauth2ErrorCodes4;
1162
1139
  })(Oauth2ErrorCodes || {});
1163
- var zOauth2ErrorResponse = z16.object({
1164
- error: z16.union([z16.nativeEnum(Oauth2ErrorCodes), z16.string()]),
1165
- error_description: z16.string().optional(),
1166
- error_uri: z16.string().optional()
1140
+ var zOauth2ErrorResponse = z15.object({
1141
+ error: z15.union([z15.nativeEnum(Oauth2ErrorCodes), z15.string()]),
1142
+ error_description: z15.string().optional(),
1143
+ error_uri: z15.string().optional()
1167
1144
  }).passthrough();
1168
1145
 
1169
1146
  // src/credential-request/z-credential-response.ts
1170
- var zCredentialEncoding = z17.union([z17.string(), z17.record(z17.string(), z17.any())]);
1171
- var zCredentialResponse = z17.object({
1172
- credential: z17.optional(zCredentialEncoding),
1173
- credentials: z17.optional(z17.array(zCredentialEncoding)),
1174
- transaction_id: z17.string().optional(),
1175
- c_nonce: z17.string().optional(),
1176
- c_nonce_expires_in: z17.number().int().optional(),
1177
- notification_id: z17.string().optional()
1147
+ var zCredentialEncoding = z16.union([z16.string(), z16.record(z16.string(), z16.any())]);
1148
+ var zCredentialResponse = z16.object({
1149
+ credential: z16.optional(zCredentialEncoding),
1150
+ credentials: z16.optional(z16.array(zCredentialEncoding)),
1151
+ transaction_id: z16.string().optional(),
1152
+ c_nonce: z16.string().optional(),
1153
+ c_nonce_expires_in: z16.number().int().optional(),
1154
+ notification_id: z16.string().optional()
1178
1155
  }).passthrough().refine(
1179
1156
  (value) => {
1180
1157
  const { credential, credentials, transaction_id } = value;
@@ -1184,10 +1161,10 @@ var zCredentialResponse = z17.object({
1184
1161
  message: `Exactly one of 'credential', 'credentials', or 'transaction_id' MUST be defined.`
1185
1162
  }
1186
1163
  );
1187
- var zCredentialErrorResponse = z17.object({
1164
+ var zCredentialErrorResponse = z16.object({
1188
1165
  ...zOauth2ErrorResponse.shape,
1189
- c_nonce: z17.string().optional(),
1190
- c_nonce_expires_in: z17.number().int().optional()
1166
+ c_nonce: z16.string().optional(),
1167
+ c_nonce_expires_in: z16.number().int().optional()
1191
1168
  }).passthrough();
1192
1169
 
1193
1170
  // src/credential-request/retrieve-credentials.ts
@@ -1435,11 +1412,11 @@ import { InvalidFetchResponseError as InvalidFetchResponseError2 } from "@openid
1435
1412
  import { ContentType as ContentType3, ValidationError as ValidationError3, createZodFetcher as createZodFetcher2, parseWithErrorHandling as parseWithErrorHandling6 } from "@openid4vc/utils";
1436
1413
 
1437
1414
  // src/nonce/z-nonce.ts
1438
- import { zInteger as zInteger4 } from "@openid4vc/utils";
1439
- import z18 from "zod";
1440
- var zNonceResponse = z18.object({
1441
- c_nonce: z18.string(),
1442
- c_nonce_expires_in: z18.optional(zInteger4)
1415
+ import { zInteger as zInteger3 } from "@openid4vc/utils";
1416
+ import z17 from "zod";
1417
+ var zNonceResponse = z17.object({
1418
+ c_nonce: z17.string(),
1419
+ c_nonce_expires_in: z17.optional(zInteger3)
1443
1420
  }).passthrough();
1444
1421
 
1445
1422
  // src/nonce/nonce-request.ts
@@ -1482,15 +1459,15 @@ import {
1482
1459
  import { ContentType as ContentType4, isResponseContentType as isResponseContentType2, parseWithErrorHandling as parseWithErrorHandling7 } from "@openid4vc/utils";
1483
1460
 
1484
1461
  // src/notification/z-notification.ts
1485
- import z19 from "zod";
1486
- var zNotificationEvent = z19.enum(["credential_accepted", "credential_failure", "credential_deleted"]);
1487
- var zNotificationRequest = z19.object({
1488
- notification_id: z19.string(),
1462
+ import z18 from "zod";
1463
+ var zNotificationEvent = z18.enum(["credential_accepted", "credential_failure", "credential_deleted"]);
1464
+ var zNotificationRequest = z18.object({
1465
+ notification_id: z18.string(),
1489
1466
  event: zNotificationEvent,
1490
- event_description: z19.optional(z19.string())
1467
+ event_description: z18.optional(z18.string())
1491
1468
  }).passthrough();
1492
- var zNotificationErrorResponse = z19.object({
1493
- error: z19.enum(["invalid_notification_id", "invalid_notification_request"])
1469
+ var zNotificationErrorResponse = z18.object({
1470
+ error: z18.enum(["invalid_notification_id", "invalid_notification_request"])
1494
1471
  }).passthrough();
1495
1472
 
1496
1473
  // src/notification/notification.ts
@@ -1925,7 +1902,7 @@ function createCredentialResponse(options) {
1925
1902
 
1926
1903
  // src/credential-request/parse-credential-request.ts
1927
1904
  import { parseWithErrorHandling as parseWithErrorHandling9 } from "@openid4vc/utils";
1928
- import z20 from "zod";
1905
+ import z19 from "zod";
1929
1906
  function parseCredentialRequest(options) {
1930
1907
  const credentialRequest = parseWithErrorHandling9(
1931
1908
  zCredentialRequest,
@@ -1937,7 +1914,7 @@ function parseCredentialRequest(options) {
1937
1914
  if (knownProofs.success) {
1938
1915
  proofs = knownProofs.data;
1939
1916
  }
1940
- const knownProof = z20.union(allCredentialRequestProofs).safeParse(credentialRequest.proof);
1917
+ const knownProof = z19.union(allCredentialRequestProofs).safeParse(credentialRequest.proof);
1941
1918
  if (knownProof.success && knownProof.data.proof_type === jwtProofTypeIdentifier) {
1942
1919
  proofs = { [jwtProofTypeIdentifier]: [knownProof.data.jwt] };
1943
1920
  } else if (knownProof.success && knownProof.data.proof_type === attestationProofTypeIdentifier) {
@@ -1954,7 +1931,7 @@ function parseCredentialRequest(options) {
1954
1931
  return {
1955
1932
  // Removes all claims that are not specific to this format
1956
1933
  format: parseWithErrorHandling9(
1957
- z20.union(allCredentialRequestFormats),
1934
+ z19.union(allCredentialRequestFormats),
1958
1935
  credentialRequest,
1959
1936
  "Unable to validate format specific properties from credential request"
1960
1937
  ),
@@ -2118,7 +2095,7 @@ export {
2118
2095
  credentialsSupportedToCredentialConfigurationsSupported,
2119
2096
  extractScopesForCredentialConfigurationIds,
2120
2097
  getCredentialConfigurationsMatchingRequestFormat,
2121
- getGlobalConfig2 as getGlobalConfig,
2098
+ getGlobalConfig,
2122
2099
  setGlobalConfig
2123
2100
  };
2124
2101
  //# sourceMappingURL=index.mjs.map