@openid4vc/openid4vp 0.3.0-alpha-20251107130226 → 0.3.0-alpha-20251110114129

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.d.cts CHANGED
@@ -1,28 +1,8 @@
1
1
  import * as _openid4vc_oauth20 from "@openid4vc/oauth2";
2
- import { CallbackContext, DecodeJwtResult, HashAlgorithm, JweEncryptor, Jwk, JwkSet, JwtPayload, JwtSigner, JwtSignerWithJwk } from "@openid4vc/oauth2";
2
+ import { CallbackContext, CreateJarAuthorizationRequestOptions, DecodeJwtResult, HashAlgorithm, JarRequestObjectPayload, Jwk, JwkSet, JwtSigner, JwtSignerWithJwk, zJarRequestObjectPayload } from "@openid4vc/oauth2";
3
3
  import z$1, { z } from "zod";
4
4
  import { NonEmptyArray } from "@openid4vc/utils";
5
5
 
6
- //#region src/jar/create-jar-authorization-request.d.ts
7
- interface CreateJarAuthorizationRequestOptions {
8
- authorizationRequestPayload: JwtPayload & {
9
- client_id?: string;
10
- };
11
- requestUri?: string;
12
- jwtSigner: JwtSigner;
13
- jweEncryptor?: JweEncryptor;
14
- callbacks: Pick<CallbackContext, 'signJwt' | 'encryptJwe'>;
15
- /**
16
- * Number of seconds after which the signed authorization request will expire
17
- */
18
- expiresInSeconds: number;
19
- /**
20
- * Date that should be used as now. If not provided current date will be used.
21
- */
22
- now?: Date;
23
- additionalJwtPayload?: Record<string, unknown>;
24
- }
25
- //#endregion
26
6
  //#region src/models/z-wallet-metadata.d.ts
27
7
  declare const zWalletMetadata: z.ZodObject<{
28
8
  presentation_definition_uri_supported: z.ZodOptional<z.ZodBoolean>;
@@ -55,8 +35,8 @@ declare const zWalletMetadata: z.ZodObject<{
55
35
  x509_san_dns: "x509_san_dns";
56
36
  x509_san_uri: "x509_san_uri";
57
37
  x509_hash: "x509_hash";
58
- origin: "origin";
59
38
  https: "https";
39
+ origin: "origin";
60
40
  "web-origin": "web-origin";
61
41
  }>>>;
62
42
  client_id_prefixes_supported: z.ZodOptional<z.ZodArray<z.ZodEnum<{
@@ -66,9 +46,9 @@ declare const zWalletMetadata: z.ZodObject<{
66
46
  x509_san_dns: "x509_san_dns";
67
47
  x509_san_uri: "x509_san_uri";
68
48
  x509_hash: "x509_hash";
69
- origin: "origin";
70
49
  openid_federation: "openid_federation";
71
50
  decentralized_identifier: "decentralized_identifier";
51
+ origin: "origin";
72
52
  }>>>;
73
53
  request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
74
54
  authorization_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -198,13 +178,13 @@ interface ValidateOpenid4vpAuthorizationRequestPayloadOptions {
198
178
  declare const validateOpenid4vpAuthorizationRequestPayload: (options: ValidateOpenid4vpAuthorizationRequestPayloadOptions) => void;
199
179
  //#endregion
200
180
  //#region src/jar/z-jar-authorization-request.d.ts
201
- declare const zJarAuthorizationRequest: z.ZodObject<{
181
+ declare const zOpenid4vpJarAuthorizationRequest: z.ZodObject<{
202
182
  request: z.ZodOptional<z.ZodString>;
203
183
  request_uri: z.ZodOptional<z.ZodString>;
204
- request_uri_method: z.ZodOptional<z.ZodString>;
205
184
  client_id: z.ZodOptional<z.ZodString>;
185
+ request_uri_method: z.ZodOptional<z.ZodString>;
206
186
  }, z.core.$loose>;
207
- type JarAuthorizationRequest = z.infer<typeof zJarAuthorizationRequest>;
187
+ type Openid4vpJarAuthorizationRequest = z.infer<typeof zOpenid4vpJarAuthorizationRequest>;
208
188
  //#endregion
209
189
  //#region src/authorization-request/z-authorization-request-dc-api.d.ts
210
190
  declare const zOpenid4vpAuthorizationRequestDcApi: z.ZodObject<{
@@ -299,7 +279,7 @@ declare const zOpenid4vpAuthorizationRequestDcApi: z.ZodObject<{
299
279
  scope: z.ZodOptional<z.ZodNever>;
300
280
  }, z.core.$loose>;
301
281
  type Openid4vpAuthorizationRequestDcApi = z.infer<typeof zOpenid4vpAuthorizationRequestDcApi>;
302
- declare function isOpenid4vpAuthorizationRequestDcApi(request: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi | JarAuthorizationRequest): request is Openid4vpAuthorizationRequestDcApi;
282
+ declare function isOpenid4vpAuthorizationRequestDcApi(request: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi | Openid4vpJarAuthorizationRequest): request is Openid4vpAuthorizationRequestDcApi;
303
283
  //#endregion
304
284
  //#region src/authorization-request/create-authorization-request.d.ts
305
285
  interface CreateOpenid4vpAuthorizationRequestOptions {
@@ -538,7 +518,6 @@ declare function createOpenid4vpAuthorizationRequest(options: CreateOpenid4vpAut
538
518
  [x: string]: unknown;
539
519
  request?: string | undefined;
540
520
  request_uri?: string | undefined;
541
- request_uri_method?: string | undefined;
542
521
  client_id?: string | undefined;
543
522
  };
544
523
  authorizationRequest: string;
@@ -547,7 +526,6 @@ declare function createOpenid4vpAuthorizationRequest(options: CreateOpenid4vpAut
547
526
  [x: string]: unknown;
548
527
  request?: string | undefined;
549
528
  request_uri?: string | undefined;
550
- request_uri_method?: string | undefined;
551
529
  client_id?: string | undefined;
552
530
  };
553
531
  signerJwk: {
@@ -1033,7 +1011,7 @@ declare function createOpenid4vpAuthorizationRequest(options: CreateOpenid4vpAut
1033
1011
  interface ParsedJarRequest {
1034
1012
  type: 'jar';
1035
1013
  provided: 'uri' | 'jwt' | 'params';
1036
- params: JarAuthorizationRequest;
1014
+ params: Openid4vpJarAuthorizationRequest;
1037
1015
  }
1038
1016
  interface ParsedOpenid4vpAuthorizationRequest {
1039
1017
  type: 'openid4vp';
@@ -1050,54 +1028,6 @@ interface ParseOpenid4vpAuthorizationRequestOptions {
1050
1028
  }
1051
1029
  declare function parseOpenid4vpAuthorizationRequest(options: ParseOpenid4vpAuthorizationRequestOptions): ParsedOpenid4vpAuthorizationRequest | ParsedJarRequest | ParsedOpenid4vpDcApiAuthorizationRequest;
1052
1030
  //#endregion
1053
- //#region src/jar/jar-request-object/z-jar-request-object.d.ts
1054
- declare const zJarRequestObjectPayload: z.ZodObject<{
1055
- client_id: z.ZodString;
1056
- iss: z.ZodOptional<z.ZodString>;
1057
- aud: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1058
- iat: z.ZodOptional<z.ZodNumber>;
1059
- exp: z.ZodOptional<z.ZodNumber>;
1060
- nbf: z.ZodOptional<z.ZodNumber>;
1061
- nonce: z.ZodOptional<z.ZodString>;
1062
- jti: z.ZodOptional<z.ZodString>;
1063
- sub: z.ZodOptional<z.ZodString>;
1064
- cnf: z.ZodOptional<z.ZodObject<{
1065
- jwk: z.ZodOptional<z.ZodObject<{
1066
- kty: z.ZodString;
1067
- crv: z.ZodOptional<z.ZodString>;
1068
- x: z.ZodOptional<z.ZodString>;
1069
- y: z.ZodOptional<z.ZodString>;
1070
- e: z.ZodOptional<z.ZodString>;
1071
- n: z.ZodOptional<z.ZodString>;
1072
- alg: z.ZodOptional<z.ZodString>;
1073
- d: z.ZodOptional<z.ZodString>;
1074
- dp: z.ZodOptional<z.ZodString>;
1075
- dq: z.ZodOptional<z.ZodString>;
1076
- ext: z.ZodOptional<z.ZodBoolean>;
1077
- k: z.ZodOptional<z.ZodString>;
1078
- key_ops: z.ZodOptional<z.ZodArray<z.ZodString>>;
1079
- kid: z.ZodOptional<z.ZodString>;
1080
- oth: z.ZodOptional<z.ZodArray<z.ZodObject<{
1081
- d: z.ZodOptional<z.ZodString>;
1082
- r: z.ZodOptional<z.ZodString>;
1083
- t: z.ZodOptional<z.ZodString>;
1084
- }, z.core.$loose>>>;
1085
- p: z.ZodOptional<z.ZodString>;
1086
- q: z.ZodOptional<z.ZodString>;
1087
- qi: z.ZodOptional<z.ZodString>;
1088
- use: z.ZodOptional<z.ZodString>;
1089
- x5c: z.ZodOptional<z.ZodArray<z.ZodString>>;
1090
- x5t: z.ZodOptional<z.ZodString>;
1091
- 'x5t#S256': z.ZodOptional<z.ZodString>;
1092
- x5u: z.ZodOptional<z.ZodString>;
1093
- }, z.core.$loose>>;
1094
- jkt: z.ZodOptional<z.ZodString>;
1095
- }, z.core.$loose>>;
1096
- status: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1097
- trust_chain: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodString>>;
1098
- }, z.core.$loose>;
1099
- type JarRequestObjectPayload = z.infer<typeof zJarRequestObjectPayload>;
1100
- //#endregion
1101
1031
  //#region src/jar/handle-jar-request/verify-jar-request.d.ts
1102
1032
  interface VerifiedJarRequest {
1103
1033
  authorizationRequestPayload: JarRequestObjectPayload;
@@ -1190,10 +1120,10 @@ declare const zClientIdPrefix: z.ZodEnum<{
1190
1120
  x509_san_dns: "x509_san_dns";
1191
1121
  x509_san_uri: "x509_san_uri";
1192
1122
  x509_hash: "x509_hash";
1193
- origin: "origin";
1194
1123
  https: "https";
1195
1124
  openid_federation: "openid_federation";
1196
1125
  decentralized_identifier: "decentralized_identifier";
1126
+ origin: "origin";
1197
1127
  "web-origin": "web-origin";
1198
1128
  }>;
1199
1129
  declare const zUniformClientIdPrefix: z.ZodEnum<{
@@ -1203,9 +1133,9 @@ declare const zUniformClientIdPrefix: z.ZodEnum<{
1203
1133
  x509_san_dns: "x509_san_dns";
1204
1134
  x509_san_uri: "x509_san_uri";
1205
1135
  x509_hash: "x509_hash";
1206
- origin: "origin";
1207
1136
  openid_federation: "openid_federation";
1208
1137
  decentralized_identifier: "decentralized_identifier";
1138
+ origin: "origin";
1209
1139
  }>;
1210
1140
  type ClientIdPrefix = z.infer<typeof zClientIdPrefix>;
1211
1141
  type UniformClientIdPrefix = z.infer<typeof zUniformClientIdPrefix>;
@@ -1363,7 +1293,7 @@ declare function parseTransactionData(options: ParseTransactionDataOptions): Par
1363
1293
  //#endregion
1364
1294
  //#region src/authorization-request/resolve-authorization-request.d.ts
1365
1295
  interface ResolveOpenid4vpAuthorizationRequestOptions {
1366
- authorizationRequestPayload: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi | JarAuthorizationRequest;
1296
+ authorizationRequestPayload: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi | Openid4vpJarAuthorizationRequest;
1367
1297
  wallet?: WalletVerificationOptions;
1368
1298
  origin?: string;
1369
1299
  disableOriginValidation?: boolean;
@@ -2130,7 +2060,6 @@ declare class Openid4vpVerifier {
2130
2060
  [x: string]: unknown;
2131
2061
  request?: string | undefined;
2132
2062
  request_uri?: string | undefined;
2133
- request_uri_method?: string | undefined;
2134
2063
  client_id?: string | undefined;
2135
2064
  };
2136
2065
  authorizationRequest: string;
@@ -2139,7 +2068,6 @@ declare class Openid4vpVerifier {
2139
2068
  [x: string]: unknown;
2140
2069
  request?: string | undefined;
2141
2070
  request_uri?: string | undefined;
2142
- request_uri_method?: string | undefined;
2143
2071
  client_id?: string | undefined;
2144
2072
  };
2145
2073
  signerJwk: {
package/dist/index.d.mts CHANGED
@@ -1,28 +1,8 @@
1
1
  import * as _openid4vc_oauth20 from "@openid4vc/oauth2";
2
- import { CallbackContext, DecodeJwtResult, HashAlgorithm, JweEncryptor, Jwk, JwkSet, JwtPayload, JwtSigner, JwtSignerWithJwk } from "@openid4vc/oauth2";
2
+ import { CallbackContext, CreateJarAuthorizationRequestOptions, DecodeJwtResult, HashAlgorithm, JarRequestObjectPayload, Jwk, JwkSet, JwtSigner, JwtSignerWithJwk, zJarRequestObjectPayload } from "@openid4vc/oauth2";
3
3
  import { NonEmptyArray } from "@openid4vc/utils";
4
4
  import z$1, { z } from "zod";
5
5
 
6
- //#region src/jar/create-jar-authorization-request.d.ts
7
- interface CreateJarAuthorizationRequestOptions {
8
- authorizationRequestPayload: JwtPayload & {
9
- client_id?: string;
10
- };
11
- requestUri?: string;
12
- jwtSigner: JwtSigner;
13
- jweEncryptor?: JweEncryptor;
14
- callbacks: Pick<CallbackContext, 'signJwt' | 'encryptJwe'>;
15
- /**
16
- * Number of seconds after which the signed authorization request will expire
17
- */
18
- expiresInSeconds: number;
19
- /**
20
- * Date that should be used as now. If not provided current date will be used.
21
- */
22
- now?: Date;
23
- additionalJwtPayload?: Record<string, unknown>;
24
- }
25
- //#endregion
26
6
  //#region src/models/z-wallet-metadata.d.ts
27
7
  declare const zWalletMetadata: z.ZodObject<{
28
8
  presentation_definition_uri_supported: z.ZodOptional<z.ZodBoolean>;
@@ -55,8 +35,8 @@ declare const zWalletMetadata: z.ZodObject<{
55
35
  x509_san_dns: "x509_san_dns";
56
36
  x509_san_uri: "x509_san_uri";
57
37
  x509_hash: "x509_hash";
58
- origin: "origin";
59
38
  https: "https";
39
+ origin: "origin";
60
40
  "web-origin": "web-origin";
61
41
  }>>>;
62
42
  client_id_prefixes_supported: z.ZodOptional<z.ZodArray<z.ZodEnum<{
@@ -66,9 +46,9 @@ declare const zWalletMetadata: z.ZodObject<{
66
46
  x509_san_dns: "x509_san_dns";
67
47
  x509_san_uri: "x509_san_uri";
68
48
  x509_hash: "x509_hash";
69
- origin: "origin";
70
49
  openid_federation: "openid_federation";
71
50
  decentralized_identifier: "decentralized_identifier";
51
+ origin: "origin";
72
52
  }>>>;
73
53
  request_object_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
74
54
  authorization_encryption_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -198,13 +178,13 @@ interface ValidateOpenid4vpAuthorizationRequestPayloadOptions {
198
178
  declare const validateOpenid4vpAuthorizationRequestPayload: (options: ValidateOpenid4vpAuthorizationRequestPayloadOptions) => void;
199
179
  //#endregion
200
180
  //#region src/jar/z-jar-authorization-request.d.ts
201
- declare const zJarAuthorizationRequest: z.ZodObject<{
181
+ declare const zOpenid4vpJarAuthorizationRequest: z.ZodObject<{
202
182
  request: z.ZodOptional<z.ZodString>;
203
183
  request_uri: z.ZodOptional<z.ZodString>;
204
- request_uri_method: z.ZodOptional<z.ZodString>;
205
184
  client_id: z.ZodOptional<z.ZodString>;
185
+ request_uri_method: z.ZodOptional<z.ZodString>;
206
186
  }, z.core.$loose>;
207
- type JarAuthorizationRequest = z.infer<typeof zJarAuthorizationRequest>;
187
+ type Openid4vpJarAuthorizationRequest = z.infer<typeof zOpenid4vpJarAuthorizationRequest>;
208
188
  //#endregion
209
189
  //#region src/authorization-request/z-authorization-request-dc-api.d.ts
210
190
  declare const zOpenid4vpAuthorizationRequestDcApi: z.ZodObject<{
@@ -299,7 +279,7 @@ declare const zOpenid4vpAuthorizationRequestDcApi: z.ZodObject<{
299
279
  scope: z.ZodOptional<z.ZodNever>;
300
280
  }, z.core.$loose>;
301
281
  type Openid4vpAuthorizationRequestDcApi = z.infer<typeof zOpenid4vpAuthorizationRequestDcApi>;
302
- declare function isOpenid4vpAuthorizationRequestDcApi(request: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi | JarAuthorizationRequest): request is Openid4vpAuthorizationRequestDcApi;
282
+ declare function isOpenid4vpAuthorizationRequestDcApi(request: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi | Openid4vpJarAuthorizationRequest): request is Openid4vpAuthorizationRequestDcApi;
303
283
  //#endregion
304
284
  //#region src/authorization-request/create-authorization-request.d.ts
305
285
  interface CreateOpenid4vpAuthorizationRequestOptions {
@@ -538,7 +518,6 @@ declare function createOpenid4vpAuthorizationRequest(options: CreateOpenid4vpAut
538
518
  [x: string]: unknown;
539
519
  request?: string | undefined;
540
520
  request_uri?: string | undefined;
541
- request_uri_method?: string | undefined;
542
521
  client_id?: string | undefined;
543
522
  };
544
523
  authorizationRequest: string;
@@ -547,7 +526,6 @@ declare function createOpenid4vpAuthorizationRequest(options: CreateOpenid4vpAut
547
526
  [x: string]: unknown;
548
527
  request?: string | undefined;
549
528
  request_uri?: string | undefined;
550
- request_uri_method?: string | undefined;
551
529
  client_id?: string | undefined;
552
530
  };
553
531
  signerJwk: {
@@ -1033,7 +1011,7 @@ declare function createOpenid4vpAuthorizationRequest(options: CreateOpenid4vpAut
1033
1011
  interface ParsedJarRequest {
1034
1012
  type: 'jar';
1035
1013
  provided: 'uri' | 'jwt' | 'params';
1036
- params: JarAuthorizationRequest;
1014
+ params: Openid4vpJarAuthorizationRequest;
1037
1015
  }
1038
1016
  interface ParsedOpenid4vpAuthorizationRequest {
1039
1017
  type: 'openid4vp';
@@ -1050,54 +1028,6 @@ interface ParseOpenid4vpAuthorizationRequestOptions {
1050
1028
  }
1051
1029
  declare function parseOpenid4vpAuthorizationRequest(options: ParseOpenid4vpAuthorizationRequestOptions): ParsedOpenid4vpAuthorizationRequest | ParsedJarRequest | ParsedOpenid4vpDcApiAuthorizationRequest;
1052
1030
  //#endregion
1053
- //#region src/jar/jar-request-object/z-jar-request-object.d.ts
1054
- declare const zJarRequestObjectPayload: z.ZodObject<{
1055
- client_id: z.ZodString;
1056
- iss: z.ZodOptional<z.ZodString>;
1057
- aud: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1058
- iat: z.ZodOptional<z.ZodNumber>;
1059
- exp: z.ZodOptional<z.ZodNumber>;
1060
- nbf: z.ZodOptional<z.ZodNumber>;
1061
- nonce: z.ZodOptional<z.ZodString>;
1062
- jti: z.ZodOptional<z.ZodString>;
1063
- sub: z.ZodOptional<z.ZodString>;
1064
- cnf: z.ZodOptional<z.ZodObject<{
1065
- jwk: z.ZodOptional<z.ZodObject<{
1066
- kty: z.ZodString;
1067
- crv: z.ZodOptional<z.ZodString>;
1068
- x: z.ZodOptional<z.ZodString>;
1069
- y: z.ZodOptional<z.ZodString>;
1070
- e: z.ZodOptional<z.ZodString>;
1071
- n: z.ZodOptional<z.ZodString>;
1072
- alg: z.ZodOptional<z.ZodString>;
1073
- d: z.ZodOptional<z.ZodString>;
1074
- dp: z.ZodOptional<z.ZodString>;
1075
- dq: z.ZodOptional<z.ZodString>;
1076
- ext: z.ZodOptional<z.ZodBoolean>;
1077
- k: z.ZodOptional<z.ZodString>;
1078
- key_ops: z.ZodOptional<z.ZodArray<z.ZodString>>;
1079
- kid: z.ZodOptional<z.ZodString>;
1080
- oth: z.ZodOptional<z.ZodArray<z.ZodObject<{
1081
- d: z.ZodOptional<z.ZodString>;
1082
- r: z.ZodOptional<z.ZodString>;
1083
- t: z.ZodOptional<z.ZodString>;
1084
- }, z.core.$loose>>>;
1085
- p: z.ZodOptional<z.ZodString>;
1086
- q: z.ZodOptional<z.ZodString>;
1087
- qi: z.ZodOptional<z.ZodString>;
1088
- use: z.ZodOptional<z.ZodString>;
1089
- x5c: z.ZodOptional<z.ZodArray<z.ZodString>>;
1090
- x5t: z.ZodOptional<z.ZodString>;
1091
- 'x5t#S256': z.ZodOptional<z.ZodString>;
1092
- x5u: z.ZodOptional<z.ZodString>;
1093
- }, z.core.$loose>>;
1094
- jkt: z.ZodOptional<z.ZodString>;
1095
- }, z.core.$loose>>;
1096
- status: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1097
- trust_chain: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodString>>;
1098
- }, z.core.$loose>;
1099
- type JarRequestObjectPayload = z.infer<typeof zJarRequestObjectPayload>;
1100
- //#endregion
1101
1031
  //#region src/jar/handle-jar-request/verify-jar-request.d.ts
1102
1032
  interface VerifiedJarRequest {
1103
1033
  authorizationRequestPayload: JarRequestObjectPayload;
@@ -1190,10 +1120,10 @@ declare const zClientIdPrefix: z.ZodEnum<{
1190
1120
  x509_san_dns: "x509_san_dns";
1191
1121
  x509_san_uri: "x509_san_uri";
1192
1122
  x509_hash: "x509_hash";
1193
- origin: "origin";
1194
1123
  https: "https";
1195
1124
  openid_federation: "openid_federation";
1196
1125
  decentralized_identifier: "decentralized_identifier";
1126
+ origin: "origin";
1197
1127
  "web-origin": "web-origin";
1198
1128
  }>;
1199
1129
  declare const zUniformClientIdPrefix: z.ZodEnum<{
@@ -1203,9 +1133,9 @@ declare const zUniformClientIdPrefix: z.ZodEnum<{
1203
1133
  x509_san_dns: "x509_san_dns";
1204
1134
  x509_san_uri: "x509_san_uri";
1205
1135
  x509_hash: "x509_hash";
1206
- origin: "origin";
1207
1136
  openid_federation: "openid_federation";
1208
1137
  decentralized_identifier: "decentralized_identifier";
1138
+ origin: "origin";
1209
1139
  }>;
1210
1140
  type ClientIdPrefix = z.infer<typeof zClientIdPrefix>;
1211
1141
  type UniformClientIdPrefix = z.infer<typeof zUniformClientIdPrefix>;
@@ -1363,7 +1293,7 @@ declare function parseTransactionData(options: ParseTransactionDataOptions): Par
1363
1293
  //#endregion
1364
1294
  //#region src/authorization-request/resolve-authorization-request.d.ts
1365
1295
  interface ResolveOpenid4vpAuthorizationRequestOptions {
1366
- authorizationRequestPayload: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi | JarAuthorizationRequest;
1296
+ authorizationRequestPayload: Openid4vpAuthorizationRequest | Openid4vpAuthorizationRequestDcApi | Openid4vpJarAuthorizationRequest;
1367
1297
  wallet?: WalletVerificationOptions;
1368
1298
  origin?: string;
1369
1299
  disableOriginValidation?: boolean;
@@ -2130,7 +2060,6 @@ declare class Openid4vpVerifier {
2130
2060
  [x: string]: unknown;
2131
2061
  request?: string | undefined;
2132
2062
  request_uri?: string | undefined;
2133
- request_uri_method?: string | undefined;
2134
2063
  client_id?: string | undefined;
2135
2064
  };
2136
2065
  authorizationRequest: string;
@@ -2139,7 +2068,6 @@ declare class Openid4vpVerifier {
2139
2068
  [x: string]: unknown;
2140
2069
  request?: string | undefined;
2141
2070
  request_uri?: string | undefined;
2142
- request_uri_method?: string | undefined;
2143
2071
  client_id?: string | undefined;
2144
2072
  };
2145
2073
  signerJwk: {
package/dist/index.mjs CHANGED
@@ -1,58 +1,7 @@
1
- import { HashAlgorithm, Oauth2Error, Oauth2ErrorCodes, Oauth2ServerErrorResponseError, decodeJwt, decodeJwtHeader, fetchJwks, jwtHeaderFromJwtSigner, jwtSignerFromJwt, verifyJwt, zAlgValueNotNone, zCompactJwe, zCompactJwt, zJwkSet, zJwtHeader, zJwtPayload } from "@openid4vc/oauth2";
2
- import { ContentType, URL, URLSearchParams, addSecondsToDate, createFetcher, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, encodeToBase64Url, encodeToUtf8String, getGlobalConfig, objectToQueryParams, parseIfJson, parseWithErrorHandling, stringToJsonWithErrorHandling, zHttpsUrl, zStringToJson } from "@openid4vc/utils";
1
+ import { HashAlgorithm, Oauth2Error, Oauth2ErrorCodes, Oauth2ServerErrorResponseError, createJarAuthorizationRequest, decodeJwt, decodeJwtHeader, fetchJwks, jwtHeaderFromJwtSigner, jwtSignerFromJwt, signedAuthorizationRequestJwtHeaderTyp, validateJarRequestParams, verifyJwt, zAlgValueNotNone, zCompactJwe, zCompactJwt, zJarAuthorizationRequest, zJarRequestObjectPayload, zJwkSet, zJwtHeader, zJwtPayload } from "@openid4vc/oauth2";
2
+ import { ContentType, URL, URLSearchParams, createFetcher, createZodFetcher, dateToSeconds, decodeBase64, decodeUtf8String, encodeToBase64Url, encodeToUtf8String, getGlobalConfig, objectToQueryParams, parseIfJson, parseWithErrorHandling, stringToJsonWithErrorHandling, zHttpsUrl, zStringToJson } from "@openid4vc/utils";
3
3
  import z$1, { z } from "zod";
4
4
 
5
- //#region src/jar/create-jar-authorization-request.ts
6
- /**
7
- * Creates a JAR (JWT Authorization Request) request object.
8
- *
9
- * @param options - The input parameters
10
- * @param options.authorizationRequestPayload - The authorization request parameters
11
- * @param options.jwtSigner - The JWT signer
12
- * @param options.jweEncryptor - The JWE encryptor (optional) if provided, the request object will be encrypted
13
- * @param options.requestUri - The request URI (optional) if provided, the request object needs to be fetched from the URI
14
- * @param options.callbacks - The callback context
15
- * @returns the requestParams, signerJwk, encryptionJwk, and requestObjectJwt
16
- */
17
- async function createJarAuthorizationRequest(options) {
18
- const { jwtSigner, jweEncryptor, authorizationRequestPayload, requestUri, callbacks } = options;
19
- let authorizationRequestJwt;
20
- let encryptionJwk;
21
- const now = options.now ?? /* @__PURE__ */ new Date();
22
- const { jwt, signerJwk } = await callbacks.signJwt(jwtSigner, {
23
- header: {
24
- ...jwtHeaderFromJwtSigner(jwtSigner),
25
- typ: "oauth-authz-req+jwt"
26
- },
27
- payload: {
28
- iat: dateToSeconds(now),
29
- exp: dateToSeconds(addSecondsToDate(now, options.expiresInSeconds)),
30
- ...options.additionalJwtPayload,
31
- ...authorizationRequestPayload
32
- }
33
- });
34
- authorizationRequestJwt = jwt;
35
- if (jweEncryptor) {
36
- const encryptionResult = await callbacks.encryptJwe(jweEncryptor, authorizationRequestJwt);
37
- authorizationRequestJwt = encryptionResult.jwe;
38
- encryptionJwk = encryptionResult.encryptionJwk;
39
- }
40
- const client_id = authorizationRequestPayload.client_id;
41
- return {
42
- jarAuthorizationRequest: requestUri ? {
43
- client_id,
44
- request_uri: requestUri
45
- } : {
46
- client_id,
47
- request: authorizationRequestJwt
48
- },
49
- signerJwk,
50
- encryptionJwk,
51
- authorizationRequestJwt
52
- };
53
- }
54
-
55
- //#endregion
56
5
  //#region src/authorization-request/validate-authorization-request.ts
57
6
  /**
58
7
  * Validate the OpenId4Vp Authorization Request parameters
@@ -383,24 +332,7 @@ async function createOpenid4vpAuthorizationRequest(options) {
383
332
 
384
333
  //#endregion
385
334
  //#region src/jar/z-jar-authorization-request.ts
386
- const zJarAuthorizationRequest = z.object({
387
- request: z.optional(z.string()),
388
- request_uri: z.optional(zHttpsUrl),
389
- request_uri_method: z.optional(z.string()),
390
- client_id: z.optional(z.string())
391
- }).loose();
392
- function validateJarRequestParams(options) {
393
- const { jarRequestParams } = options;
394
- if (jarRequestParams.request && jarRequestParams.request_uri) throw new Oauth2ServerErrorResponseError({
395
- error: "invalid_request_object",
396
- error_description: "request and request_uri cannot both be present in a JAR request"
397
- });
398
- if (!jarRequestParams.request && !jarRequestParams.request_uri) throw new Oauth2ServerErrorResponseError({
399
- error: "invalid_request_object",
400
- error_description: "request or request_uri must be present"
401
- });
402
- return jarRequestParams;
403
- }
335
+ const zOpenid4vpJarAuthorizationRequest = zJarAuthorizationRequest.extend({ request_uri_method: z.optional(z.string()) });
404
336
  function isJarAuthorizationRequest(request) {
405
337
  return "request" in request || "request_uri" in request;
406
338
  }
@@ -421,7 +353,7 @@ function parseOpenid4vpAuthorizationRequest(options) {
421
353
  else params = authorizationRequest;
422
354
  const parsedRequest = parseWithErrorHandling(z$1.union([
423
355
  zOpenid4vpAuthorizationRequest,
424
- zJarAuthorizationRequest,
356
+ zOpenid4vpJarAuthorizationRequest,
425
357
  zOpenid4vpAuthorizationRequestDcApi
426
358
  ]), params);
427
359
  if (isJarAuthorizationRequest(parsedRequest)) return {
@@ -852,17 +784,8 @@ async function fetchJarRequestObject(options) {
852
784
  return await response.text();
853
785
  }
854
786
 
855
- //#endregion
856
- //#region src/jar/jar-request-object/z-jar-request-object.ts
857
- const zJarRequestObjectPayload = z.object({
858
- ...zJwtPayload.shape,
859
- client_id: z.string()
860
- }).loose();
861
-
862
787
  //#endregion
863
788
  //#region src/jar/handle-jar-request/verify-jar-request.ts
864
- const zSignedAuthorizationRequestJwtHeaderTyp = z$1.literal("oauth-authz-req+jwt");
865
- const signedAuthorizationRequestJwtHeaderTyp = zSignedAuthorizationRequestJwtHeaderTyp.value;
866
789
  /**
867
790
  * Verifies a JAR (JWT Secured Authorization Request) request by validating, decrypting, and verifying signatures.
868
791
  *
@@ -873,7 +796,10 @@ const signedAuthorizationRequestJwtHeaderTyp = zSignedAuthorizationRequestJwtHea
873
796
  */
874
797
  async function verifyJarRequest(options) {
875
798
  const { callbacks, wallet = {} } = options;
876
- const jarRequestParams = validateJarRequestParams(options);
799
+ const jarRequestParams = {
800
+ ...validateJarRequestParams(options),
801
+ ...options.jarRequestParams
802
+ };
877
803
  const sendBy = jarRequestParams.request ? "value" : "reference";
878
804
  const clientIdPrefix = jarRequestParams.client_id ? zClientIdPrefix.safeParse(jarRequestParams.client_id.split(":")[0]).data : "origin";
879
805
  const method = jarRequestParams.request_uri_method ?? "get";
@@ -932,7 +858,7 @@ async function decryptJarRequest(options) {
932
858
  });
933
859
  const decryptionResult = await callbacks.decryptJwe(jwe);
934
860
  if (!decryptionResult.decrypted) throw new Oauth2ServerErrorResponseError({
935
- error: "invalid_request_object",
861
+ error: Oauth2ErrorCodes.InvalidRequestObject,
936
862
  error_description: "Failed to decrypt jar request object."
937
863
  });
938
864
  return decryptionResult;
@@ -990,7 +916,7 @@ async function verifyJarRequestObject(options) {
990
916
  signer: jwtSigner
991
917
  });
992
918
  const version = parseAuthorizationRequestVersion(jwt.payload);
993
- if (jwt.header.typ !== "oauth-authz-req+jwt" && version >= 24) throw new Oauth2ServerErrorResponseError({
919
+ if (jwt.header.typ !== signedAuthorizationRequestJwtHeaderTyp && version >= 24) throw new Oauth2ServerErrorResponseError({
994
920
  error: Oauth2ErrorCodes.InvalidRequestObject,
995
921
  error_description: `Invalid Jar Request Object typ header. Expected "oauth-authz-req+jwt", received "${jwt.header.typ}".`
996
922
  });
@@ -1035,7 +961,7 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
1035
961
  const parsed = parseWithErrorHandling(z$1.union([
1036
962
  zOpenid4vpAuthorizationRequestDcApi,
1037
963
  zOpenid4vpAuthorizationRequest,
1038
- zJarAuthorizationRequest
964
+ zOpenid4vpJarAuthorizationRequest
1039
965
  ]), options.authorizationRequestPayload, "Invalid authorization request. Could not parse openid4vp authorization request as openid4vp or jar auth request.");
1040
966
  let jar;
1041
967
  if (isJarAuthorizationRequest(parsed)) {
@@ -1114,7 +1040,7 @@ function validateOpenId4vpAuthorizationRequestPayload(options) {
1114
1040
 
1115
1041
  //#endregion
1116
1042
  //#region ../utils/src/date.ts
1117
- function addSecondsToDate$1(date, seconds) {
1043
+ function addSecondsToDate(date, seconds) {
1118
1044
  return new Date(date.getTime() + seconds * 1e3);
1119
1045
  }
1120
1046
 
@@ -1257,7 +1183,7 @@ async function createOpenid4vpAuthorizationResponse(options) {
1257
1183
  additionalJwtPayload = {
1258
1184
  iss: jarm.authorizationServer,
1259
1185
  aud: jarm.audience,
1260
- exp: jarm.expiresInSeconds ?? dateToSeconds(addSecondsToDate$1(/* @__PURE__ */ new Date(), 600))
1186
+ exp: jarm.expiresInSeconds ?? dateToSeconds(addSecondsToDate(/* @__PURE__ */ new Date(), 600))
1261
1187
  };
1262
1188
  }
1263
1189
  const jarmResponsePayload = {