@pagopa/io-wallet-oid4vp 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.mts +69 -4
- package/dist/index.d.ts +69 -4
- package/dist/index.js +82 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -115,7 +115,7 @@ const resp = createAuthorizationResponse({
|
|
|
115
115
|
|
|
116
116
|
### AuthorizationRequestObject type and Zod parser
|
|
117
117
|
```typescript
|
|
118
|
-
export const
|
|
118
|
+
export const zOpenid4vpAuthorizationRequestPayload = z
|
|
119
119
|
.object({
|
|
120
120
|
response_type: z.literal('vp_token'),
|
|
121
121
|
client_id: z.string(),
|
|
@@ -131,7 +131,7 @@ export const zOpenid4vpAuthorizationRequest = z
|
|
|
131
131
|
})
|
|
132
132
|
.passthrough().and(zJwtPayload)
|
|
133
133
|
|
|
134
|
-
export type AuthorizationRequestObject = z.infer<typeof
|
|
134
|
+
export type AuthorizationRequestObject = z.infer<typeof zOpenid4vpAuthorizationRequestPayload>
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
### parseAuthorizeRequest
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CallbackContext, RequestDpopOptions, JwtSigner } from '@openid4vc/oauth2';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import z$1, { z } from 'zod';
|
|
3
3
|
import * as _openid4vc_openid4vp from '@openid4vc/openid4vp';
|
|
4
4
|
import { VpToken } from '@openid4vc/openid4vp';
|
|
5
5
|
export { CreateOpenid4vpAuthorizationResponseOptions, CreateOpenid4vpAuthorizationResponseResult, VpToken, createOpenid4vpAuthorizationResponse } from '@openid4vc/openid4vp';
|
|
@@ -9,7 +9,7 @@ import { ItWalletCredentialVerifierMetadata } from '@pagopa/io-wallet-oid-federa
|
|
|
9
9
|
* Zod parser that describes a JWT payload
|
|
10
10
|
* containing an OID4VP Request Object
|
|
11
11
|
*/
|
|
12
|
-
declare const
|
|
12
|
+
declare const zOpenid4vpAuthorizationRequestPayload: z.ZodIntersection<z.ZodObject<{
|
|
13
13
|
client_id: z.ZodString;
|
|
14
14
|
dcql_query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
15
15
|
nonce: z.ZodString;
|
|
@@ -1078,7 +1078,26 @@ declare const zOpenid4vpAuthorizationRequest: z.ZodIntersection<z.ZodObject<{
|
|
|
1078
1078
|
status: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
1079
1079
|
trust_chain: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
1080
1080
|
}, z.ZodTypeAny, "passthrough">>>;
|
|
1081
|
-
type AuthorizationRequestObject = z.infer<typeof
|
|
1081
|
+
type AuthorizationRequestObject = z.infer<typeof zOpenid4vpAuthorizationRequestPayload>;
|
|
1082
|
+
declare const zOpenid4vpAuthorizationRequestHeader: z.ZodObject<{
|
|
1083
|
+
alg: z.ZodString;
|
|
1084
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
1085
|
+
trust_chain: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
1086
|
+
typ: z.ZodLiteral<"oauth-authz-req+jwt">;
|
|
1087
|
+
x5c: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1088
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1089
|
+
alg: z.ZodString;
|
|
1090
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
1091
|
+
trust_chain: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
1092
|
+
typ: z.ZodLiteral<"oauth-authz-req+jwt">;
|
|
1093
|
+
x5c: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1094
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1095
|
+
alg: z.ZodString;
|
|
1096
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
1097
|
+
trust_chain: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
1098
|
+
typ: z.ZodLiteral<"oauth-authz-req+jwt">;
|
|
1099
|
+
x5c: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1100
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
1082
1101
|
|
|
1083
1102
|
interface ParseAuthorizeRequestOptions {
|
|
1084
1103
|
/**
|
|
@@ -1148,6 +1167,45 @@ interface CreateAuthorizationResponseOptions {
|
|
|
1148
1167
|
*/
|
|
1149
1168
|
declare function createAuthorizationResponse(options: CreateAuthorizationResponseOptions): Promise<_openid4vc_openid4vp.CreateOpenid4vpAuthorizationResponseResult>;
|
|
1150
1169
|
|
|
1170
|
+
declare const zOid4vpAuthorizationResponseResult: z$1.ZodObject<{
|
|
1171
|
+
redirect_uri: z$1.ZodString;
|
|
1172
|
+
}, "strip", z$1.ZodTypeAny, {
|
|
1173
|
+
redirect_uri: string;
|
|
1174
|
+
}, {
|
|
1175
|
+
redirect_uri: string;
|
|
1176
|
+
}>;
|
|
1177
|
+
type Oid4vpAuthorizationResponseResult = z$1.infer<typeof zOid4vpAuthorizationResponseResult>;
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* Configuration options for fetching OID4VP Presentation Result
|
|
1181
|
+
*/
|
|
1182
|
+
interface FetchAuthorizationResponseOptions {
|
|
1183
|
+
/**
|
|
1184
|
+
* The signed and encrypted {@link Openid4vpAuthorizationResponse} in base64 format
|
|
1185
|
+
*/
|
|
1186
|
+
authorizationResponseJarm: string;
|
|
1187
|
+
/**
|
|
1188
|
+
* Callback functions for making HTTP requests
|
|
1189
|
+
* Allows for custom fetch implementations
|
|
1190
|
+
*/
|
|
1191
|
+
callbacks: Pick<CallbackContext, "fetch">;
|
|
1192
|
+
/**
|
|
1193
|
+
* The response_uri field contained in the {@link AuthorizationRequestObject}
|
|
1194
|
+
*/
|
|
1195
|
+
presentationResponseUri: string;
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Sends the {@link Openid4vpAuthorizationResponse} to the response uri provided by the session's
|
|
1199
|
+
* {@link AuthorizationRequestObject} and returns the {@link Oid4vpAuthorizationResponseResult} object
|
|
1200
|
+
* containing the redirect_uri at which to continue the presentation
|
|
1201
|
+
*
|
|
1202
|
+
* @param options {@link FetchAuthorizationResponseOptions}
|
|
1203
|
+
* @returns Promise that resolves to the parsed {@link Oid4vpAuthorizationResponseResult}
|
|
1204
|
+
* @throws {UnexpectedStatusCodeError} When the server returns a non-200 status code
|
|
1205
|
+
* @throws {ValidationError} When the response cannot be parsed or is invalid
|
|
1206
|
+
*/
|
|
1207
|
+
declare function fetchAuthorizationResponse(options: FetchAuthorizationResponseOptions): Promise<Oid4vpAuthorizationResponseResult>;
|
|
1208
|
+
|
|
1151
1209
|
/**
|
|
1152
1210
|
* Generic error thrown during Oid4vp operations
|
|
1153
1211
|
*/
|
|
@@ -1164,6 +1222,13 @@ declare class ParseAuthorizeRequestError extends Oid4vpError {
|
|
|
1164
1222
|
readonly statusCode?: number | undefined;
|
|
1165
1223
|
constructor(message: string, statusCode?: number | undefined);
|
|
1166
1224
|
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Error thrown by {@link fetchAuthorizationResponse}
|
|
1227
|
+
*/
|
|
1228
|
+
declare class FetchAuthorizationResponseError extends Oid4vpError {
|
|
1229
|
+
readonly statusCode?: number | undefined;
|
|
1230
|
+
constructor(message: string, statusCode?: number | undefined);
|
|
1231
|
+
}
|
|
1167
1232
|
/**
|
|
1168
1233
|
* Error thrown by {@link createAuthorizationResponse} in case there
|
|
1169
1234
|
* are unexpected errors.
|
|
@@ -1173,4 +1238,4 @@ declare class CreateAuthorizationResponseError extends Oid4vpError {
|
|
|
1173
1238
|
constructor(message: string, statusCode?: number | undefined);
|
|
1174
1239
|
}
|
|
1175
1240
|
|
|
1176
|
-
export { type AuthorizationRequestObject, CreateAuthorizationResponseError, type CreateAuthorizationResponseOptions, Oid4vpError, ParseAuthorizeRequestError, type ParseAuthorizeRequestOptions, createAuthorizationResponse, parseAuthorizeRequest,
|
|
1241
|
+
export { type AuthorizationRequestObject, CreateAuthorizationResponseError, type CreateAuthorizationResponseOptions, FetchAuthorizationResponseError, type FetchAuthorizationResponseOptions, type Oid4vpAuthorizationResponseResult, Oid4vpError, ParseAuthorizeRequestError, type ParseAuthorizeRequestOptions, createAuthorizationResponse, fetchAuthorizationResponse, parseAuthorizeRequest, zOid4vpAuthorizationResponseResult, zOpenid4vpAuthorizationRequestHeader, zOpenid4vpAuthorizationRequestPayload };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CallbackContext, RequestDpopOptions, JwtSigner } from '@openid4vc/oauth2';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import z$1, { z } from 'zod';
|
|
3
3
|
import * as _openid4vc_openid4vp from '@openid4vc/openid4vp';
|
|
4
4
|
import { VpToken } from '@openid4vc/openid4vp';
|
|
5
5
|
export { CreateOpenid4vpAuthorizationResponseOptions, CreateOpenid4vpAuthorizationResponseResult, VpToken, createOpenid4vpAuthorizationResponse } from '@openid4vc/openid4vp';
|
|
@@ -9,7 +9,7 @@ import { ItWalletCredentialVerifierMetadata } from '@pagopa/io-wallet-oid-federa
|
|
|
9
9
|
* Zod parser that describes a JWT payload
|
|
10
10
|
* containing an OID4VP Request Object
|
|
11
11
|
*/
|
|
12
|
-
declare const
|
|
12
|
+
declare const zOpenid4vpAuthorizationRequestPayload: z.ZodIntersection<z.ZodObject<{
|
|
13
13
|
client_id: z.ZodString;
|
|
14
14
|
dcql_query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
15
15
|
nonce: z.ZodString;
|
|
@@ -1078,7 +1078,26 @@ declare const zOpenid4vpAuthorizationRequest: z.ZodIntersection<z.ZodObject<{
|
|
|
1078
1078
|
status: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
1079
1079
|
trust_chain: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
1080
1080
|
}, z.ZodTypeAny, "passthrough">>>;
|
|
1081
|
-
type AuthorizationRequestObject = z.infer<typeof
|
|
1081
|
+
type AuthorizationRequestObject = z.infer<typeof zOpenid4vpAuthorizationRequestPayload>;
|
|
1082
|
+
declare const zOpenid4vpAuthorizationRequestHeader: z.ZodObject<{
|
|
1083
|
+
alg: z.ZodString;
|
|
1084
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
1085
|
+
trust_chain: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
1086
|
+
typ: z.ZodLiteral<"oauth-authz-req+jwt">;
|
|
1087
|
+
x5c: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1088
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1089
|
+
alg: z.ZodString;
|
|
1090
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
1091
|
+
trust_chain: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
1092
|
+
typ: z.ZodLiteral<"oauth-authz-req+jwt">;
|
|
1093
|
+
x5c: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1094
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1095
|
+
alg: z.ZodString;
|
|
1096
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
1097
|
+
trust_chain: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
1098
|
+
typ: z.ZodLiteral<"oauth-authz-req+jwt">;
|
|
1099
|
+
x5c: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1100
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
1082
1101
|
|
|
1083
1102
|
interface ParseAuthorizeRequestOptions {
|
|
1084
1103
|
/**
|
|
@@ -1148,6 +1167,45 @@ interface CreateAuthorizationResponseOptions {
|
|
|
1148
1167
|
*/
|
|
1149
1168
|
declare function createAuthorizationResponse(options: CreateAuthorizationResponseOptions): Promise<_openid4vc_openid4vp.CreateOpenid4vpAuthorizationResponseResult>;
|
|
1150
1169
|
|
|
1170
|
+
declare const zOid4vpAuthorizationResponseResult: z$1.ZodObject<{
|
|
1171
|
+
redirect_uri: z$1.ZodString;
|
|
1172
|
+
}, "strip", z$1.ZodTypeAny, {
|
|
1173
|
+
redirect_uri: string;
|
|
1174
|
+
}, {
|
|
1175
|
+
redirect_uri: string;
|
|
1176
|
+
}>;
|
|
1177
|
+
type Oid4vpAuthorizationResponseResult = z$1.infer<typeof zOid4vpAuthorizationResponseResult>;
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* Configuration options for fetching OID4VP Presentation Result
|
|
1181
|
+
*/
|
|
1182
|
+
interface FetchAuthorizationResponseOptions {
|
|
1183
|
+
/**
|
|
1184
|
+
* The signed and encrypted {@link Openid4vpAuthorizationResponse} in base64 format
|
|
1185
|
+
*/
|
|
1186
|
+
authorizationResponseJarm: string;
|
|
1187
|
+
/**
|
|
1188
|
+
* Callback functions for making HTTP requests
|
|
1189
|
+
* Allows for custom fetch implementations
|
|
1190
|
+
*/
|
|
1191
|
+
callbacks: Pick<CallbackContext, "fetch">;
|
|
1192
|
+
/**
|
|
1193
|
+
* The response_uri field contained in the {@link AuthorizationRequestObject}
|
|
1194
|
+
*/
|
|
1195
|
+
presentationResponseUri: string;
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Sends the {@link Openid4vpAuthorizationResponse} to the response uri provided by the session's
|
|
1199
|
+
* {@link AuthorizationRequestObject} and returns the {@link Oid4vpAuthorizationResponseResult} object
|
|
1200
|
+
* containing the redirect_uri at which to continue the presentation
|
|
1201
|
+
*
|
|
1202
|
+
* @param options {@link FetchAuthorizationResponseOptions}
|
|
1203
|
+
* @returns Promise that resolves to the parsed {@link Oid4vpAuthorizationResponseResult}
|
|
1204
|
+
* @throws {UnexpectedStatusCodeError} When the server returns a non-200 status code
|
|
1205
|
+
* @throws {ValidationError} When the response cannot be parsed or is invalid
|
|
1206
|
+
*/
|
|
1207
|
+
declare function fetchAuthorizationResponse(options: FetchAuthorizationResponseOptions): Promise<Oid4vpAuthorizationResponseResult>;
|
|
1208
|
+
|
|
1151
1209
|
/**
|
|
1152
1210
|
* Generic error thrown during Oid4vp operations
|
|
1153
1211
|
*/
|
|
@@ -1164,6 +1222,13 @@ declare class ParseAuthorizeRequestError extends Oid4vpError {
|
|
|
1164
1222
|
readonly statusCode?: number | undefined;
|
|
1165
1223
|
constructor(message: string, statusCode?: number | undefined);
|
|
1166
1224
|
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Error thrown by {@link fetchAuthorizationResponse}
|
|
1227
|
+
*/
|
|
1228
|
+
declare class FetchAuthorizationResponseError extends Oid4vpError {
|
|
1229
|
+
readonly statusCode?: number | undefined;
|
|
1230
|
+
constructor(message: string, statusCode?: number | undefined);
|
|
1231
|
+
}
|
|
1167
1232
|
/**
|
|
1168
1233
|
* Error thrown by {@link createAuthorizationResponse} in case there
|
|
1169
1234
|
* are unexpected errors.
|
|
@@ -1173,4 +1238,4 @@ declare class CreateAuthorizationResponseError extends Oid4vpError {
|
|
|
1173
1238
|
constructor(message: string, statusCode?: number | undefined);
|
|
1174
1239
|
}
|
|
1175
1240
|
|
|
1176
|
-
export { type AuthorizationRequestObject, CreateAuthorizationResponseError, type CreateAuthorizationResponseOptions, Oid4vpError, ParseAuthorizeRequestError, type ParseAuthorizeRequestOptions, createAuthorizationResponse, parseAuthorizeRequest,
|
|
1241
|
+
export { type AuthorizationRequestObject, CreateAuthorizationResponseError, type CreateAuthorizationResponseOptions, FetchAuthorizationResponseError, type FetchAuthorizationResponseOptions, type Oid4vpAuthorizationResponseResult, Oid4vpError, ParseAuthorizeRequestError, type ParseAuthorizeRequestOptions, createAuthorizationResponse, fetchAuthorizationResponse, parseAuthorizeRequest, zOid4vpAuthorizationResponseResult, zOpenid4vpAuthorizationRequestHeader, zOpenid4vpAuthorizationRequestPayload };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,18 +17,30 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var index_exports = {};
|
|
22
32
|
__export(index_exports, {
|
|
23
33
|
CreateAuthorizationResponseError: () => CreateAuthorizationResponseError,
|
|
34
|
+
FetchAuthorizationResponseError: () => FetchAuthorizationResponseError,
|
|
24
35
|
Oid4vpError: () => Oid4vpError,
|
|
25
36
|
ParseAuthorizeRequestError: () => ParseAuthorizeRequestError,
|
|
26
37
|
createAuthorizationResponse: () => createAuthorizationResponse,
|
|
27
38
|
createOpenid4vpAuthorizationResponse: () => import_openid4vp2.createOpenid4vpAuthorizationResponse,
|
|
39
|
+
fetchAuthorizationResponse: () => fetchAuthorizationResponse,
|
|
28
40
|
parseAuthorizeRequest: () => parseAuthorizeRequest,
|
|
29
|
-
|
|
41
|
+
zOid4vpAuthorizationResponseResult: () => zOid4vpAuthorizationResponseResult,
|
|
42
|
+
zOpenid4vpAuthorizationRequestHeader: () => zOpenid4vpAuthorizationRequestHeader,
|
|
43
|
+
zOpenid4vpAuthorizationRequestPayload: () => zOpenid4vpAuthorizationRequestPayload
|
|
30
44
|
});
|
|
31
45
|
module.exports = __toCommonJS(index_exports);
|
|
32
46
|
|
|
@@ -49,6 +63,13 @@ var ParseAuthorizeRequestError = class extends Oid4vpError {
|
|
|
49
63
|
this.name = "ParseAuthorizeRequestError";
|
|
50
64
|
}
|
|
51
65
|
};
|
|
66
|
+
var FetchAuthorizationResponseError = class extends Oid4vpError {
|
|
67
|
+
constructor(message, statusCode) {
|
|
68
|
+
super(message);
|
|
69
|
+
this.statusCode = statusCode;
|
|
70
|
+
this.name = "FetchAuthorizationResponseError";
|
|
71
|
+
}
|
|
72
|
+
};
|
|
52
73
|
var CreateAuthorizationResponseError = class extends Oid4vpError {
|
|
53
74
|
constructor(message, statusCode) {
|
|
54
75
|
super(message);
|
|
@@ -60,7 +81,7 @@ var CreateAuthorizationResponseError = class extends Oid4vpError {
|
|
|
60
81
|
// src/authorization-request/z-request-object.ts
|
|
61
82
|
var import_oauth2 = require("@openid4vc/oauth2");
|
|
62
83
|
var import_zod = require("zod");
|
|
63
|
-
var
|
|
84
|
+
var zOpenid4vpAuthorizationRequestPayload = import_zod.z.object({
|
|
64
85
|
client_id: import_zod.z.string(),
|
|
65
86
|
dcql_query: import_zod.z.record(import_zod.z.string(), import_zod.z.any()).optional(),
|
|
66
87
|
nonce: import_zod.z.string(),
|
|
@@ -73,13 +94,21 @@ var zOpenid4vpAuthorizationRequest = import_zod.z.object({
|
|
|
73
94
|
state: import_zod.z.string(),
|
|
74
95
|
wallet_nonce: import_zod.z.string().optional()
|
|
75
96
|
}).passthrough().and(import_oauth2.zJwtPayload);
|
|
97
|
+
var zOpenid4vpAuthorizationRequestHeader = import_zod.z.object({
|
|
98
|
+
alg: import_zod.z.string(),
|
|
99
|
+
kid: import_zod.z.string().optional(),
|
|
100
|
+
trust_chain: import_zod.z.array(import_zod.z.string()).nonempty().optional(),
|
|
101
|
+
typ: import_zod.z.literal("oauth-authz-req+jwt"),
|
|
102
|
+
x5c: import_zod.z.array(import_zod.z.string()).optional()
|
|
103
|
+
}).passthrough();
|
|
76
104
|
|
|
77
105
|
// src/authorization-request/parse-authorization-request.ts
|
|
78
106
|
async function parseAuthorizeRequest(options) {
|
|
79
107
|
try {
|
|
80
108
|
const decoded = (0, import_oauth22.decodeJwt)({
|
|
109
|
+
headerSchema: zOpenid4vpAuthorizationRequestHeader,
|
|
81
110
|
jwt: options.requestObjectJwt,
|
|
82
|
-
payloadSchema:
|
|
111
|
+
payloadSchema: zOpenid4vpAuthorizationRequestPayload
|
|
83
112
|
});
|
|
84
113
|
const verificationResult = await options.callbacks.verifyJwt(
|
|
85
114
|
options.dpop.signer,
|
|
@@ -148,16 +177,65 @@ async function createAuthorizationResponse(options) {
|
|
|
148
177
|
}
|
|
149
178
|
}
|
|
150
179
|
|
|
180
|
+
// src/authorization-response/fetch-authorization-response.ts
|
|
181
|
+
var import_utils3 = require("@openid4vc/utils");
|
|
182
|
+
var import_io_wallet_utils = require("@pagopa/io-wallet-utils");
|
|
183
|
+
|
|
184
|
+
// src/authorization-response/z-authorization-response.ts
|
|
185
|
+
var import_zod2 = __toESM(require("zod"));
|
|
186
|
+
var zOid4vpAuthorizationResponseResult = import_zod2.default.object({
|
|
187
|
+
redirect_uri: import_zod2.default.string()
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// src/authorization-response/fetch-authorization-response.ts
|
|
191
|
+
async function fetchAuthorizationResponse(options) {
|
|
192
|
+
try {
|
|
193
|
+
const fetch = (0, import_utils3.createFetcher)(options.callbacks.fetch);
|
|
194
|
+
const authorizationResponseResult = await fetch(
|
|
195
|
+
options.presentationResponseUri,
|
|
196
|
+
{
|
|
197
|
+
body: new URLSearchParams({
|
|
198
|
+
response: options.authorizationResponseJarm
|
|
199
|
+
}),
|
|
200
|
+
headers: {
|
|
201
|
+
[import_io_wallet_utils.HEADERS.CONTENT_TYPE]: import_io_wallet_utils.CONTENT_TYPES.FORM_URLENCODED
|
|
202
|
+
},
|
|
203
|
+
method: "POST"
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
await (0, import_io_wallet_utils.hasStatusOrThrow)(
|
|
207
|
+
200,
|
|
208
|
+
import_io_wallet_utils.UnexpectedStatusCodeError
|
|
209
|
+
)(authorizationResponseResult);
|
|
210
|
+
const authorizationResponseResultJson = await authorizationResponseResult.json();
|
|
211
|
+
return (0, import_utils3.parseWithErrorHandling)(
|
|
212
|
+
zOid4vpAuthorizationResponseResult,
|
|
213
|
+
authorizationResponseResultJson
|
|
214
|
+
);
|
|
215
|
+
} catch (error) {
|
|
216
|
+
if (error instanceof import_io_wallet_utils.UnexpectedStatusCodeError || error instanceof import_utils3.ValidationError) {
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
throw new FetchAuthorizationResponseError(
|
|
220
|
+
`Unexpected error sending authorization response: ${error instanceof Error ? error.message : String(error)}`
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
151
225
|
// src/index.ts
|
|
152
226
|
var import_openid4vp2 = require("@openid4vc/openid4vp");
|
|
153
227
|
// Annotate the CommonJS export names for ESM import in node:
|
|
154
228
|
0 && (module.exports = {
|
|
155
229
|
CreateAuthorizationResponseError,
|
|
230
|
+
FetchAuthorizationResponseError,
|
|
156
231
|
Oid4vpError,
|
|
157
232
|
ParseAuthorizeRequestError,
|
|
158
233
|
createAuthorizationResponse,
|
|
159
234
|
createOpenid4vpAuthorizationResponse,
|
|
235
|
+
fetchAuthorizationResponse,
|
|
160
236
|
parseAuthorizeRequest,
|
|
161
|
-
|
|
237
|
+
zOid4vpAuthorizationResponseResult,
|
|
238
|
+
zOpenid4vpAuthorizationRequestHeader,
|
|
239
|
+
zOpenid4vpAuthorizationRequestPayload
|
|
162
240
|
});
|
|
163
241
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/authorization-request/parse-authorization-request.ts","../src/errors.ts","../src/authorization-request/z-request-object.ts","../src/authorization-response/create-authorization-response.ts"],"sourcesContent":["export * from \"./authorization-request\";\nexport * from \"./authorization-response\";\nexport * from \"./errors\";\n\nexport {\n type CreateOpenid4vpAuthorizationResponseOptions,\n type CreateOpenid4vpAuthorizationResponseResult,\n type VpToken,\n createOpenid4vpAuthorizationResponse,\n} from \"@openid4vc/openid4vp\";\n","import {\n CallbackContext,\n Oauth2JwtParseError,\n RequestDpopOptions,\n decodeJwt,\n} from \"@openid4vc/oauth2\";\nimport { ValidationError } from \"@openid4vc/utils\";\n\nimport { ParseAuthorizeRequestError } from \"../errors\";\nimport {\n AuthorizationRequestObject,\n zOpenid4vpAuthorizationRequest,\n} from \"./z-request-object\";\n\nexport interface ParseAuthorizeRequestOptions {\n /**\n * Callback context for signature verification.\n */\n callbacks: Pick<CallbackContext, \"verifyJwt\">;\n\n /**\n * DPoP options\n */\n dpop: RequestDpopOptions;\n\n /**\n * The Authorization Request Object JWT.\n */\n requestObjectJwt: string;\n}\n\n/**\n * This method verifies a JWT containing a Request Object and returns its\n * decoded value for further processing\n * @param options {@link ParseAuthorizeRequestOptions}\n * @returns An {@link AuthorizationRequestObject} containing the RP required\n * credentials\n * @throws {@link ValidationError} in case there are errors validating the Request Object structure\n * @throws {@link Oauth2JwtParseError} in case the request object jwt is malformed (e.g missing header, bad encoding)\n * @throws {@link ParseAuthorizeRequestError} in case the JWT signature is invalid or there are unexpected errors\n */\nexport async function parseAuthorizeRequest(\n options: ParseAuthorizeRequestOptions,\n): Promise<AuthorizationRequestObject> {\n try {\n const decoded = decodeJwt({\n jwt: options.requestObjectJwt,\n payloadSchema: zOpenid4vpAuthorizationRequest,\n });\n const verificationResult = await options.callbacks.verifyJwt(\n options.dpop.signer,\n {\n compact: options.requestObjectJwt,\n header: decoded.header,\n payload: decoded.payload,\n },\n );\n\n if (!verificationResult.verified)\n throw new ParseAuthorizeRequestError(\n \"Error verifying Request Object signature\",\n );\n\n return decoded.payload;\n } catch (error) {\n if (\n error instanceof ValidationError ||\n error instanceof Oauth2JwtParseError\n )\n throw error;\n throw new ParseAuthorizeRequestError(\n `Unexpected error during Request Object parsing: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n","/**\n * Generic error thrown during Oid4vp operations\n */\nexport class Oid4vpError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"Oid4vpError\";\n }\n}\n\n/**\n * Error thrown by {@link parseAuthorizeRequest} when the passed\n * request object has an invalid signature or unexpected errors\n * are thrown\n */\nexport class ParseAuthorizeRequestError extends Oid4vpError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"ParseAuthorizeRequestError\";\n }\n}\n\n/**\n * Error thrown by {@link createAuthorizationResponse} in case there\n * are unexpected errors.\n */\nexport class CreateAuthorizationResponseError extends Oid4vpError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"CreateAuthorizationResponseError\";\n }\n}\n","import { zJwtPayload } from \"@openid4vc/oauth2\";\nimport { z } from \"zod\";\n\n/**\n * Zod parser that describes a JWT payload\n * containing an OID4VP Request Object\n */\nexport const zOpenid4vpAuthorizationRequest = z\n .object({\n client_id: z.string(),\n dcql_query: z.record(z.string(), z.any()).optional(),\n nonce: z.string(),\n request_uri: z.string().url().optional(),\n request_uri_method: z.optional(z.string()),\n response_mode: z.literal(\"direct_post.jwt\"),\n response_type: z.literal(\"vp_token\"),\n response_uri: z.string().url().optional(),\n scope: z.string().optional(),\n state: z.string(),\n wallet_nonce: z.string().optional(),\n })\n .passthrough()\n .and(zJwtPayload);\n\nexport type AuthorizationRequestObject = z.infer<\n typeof zOpenid4vpAuthorizationRequest\n>;\n","import { CallbackContext, JwtSigner } from \"@openid4vc/oauth2\";\nimport {\n CreateOpenid4vpAuthorizationResponseOptions,\n VpToken,\n createOpenid4vpAuthorizationResponse,\n} from \"@openid4vc/openid4vp\";\nimport { addSecondsToDate, dateToSeconds } from \"@openid4vc/utils\";\nimport { ItWalletCredentialVerifierMetadata } from \"@pagopa/io-wallet-oid-federation\";\n\nimport { AuthorizationRequestObject } from \"../authorization-request\";\nimport { CreateAuthorizationResponseError } from \"../errors\";\n\ntype JarmServerMetadata = NonNullable<\n CreateOpenid4vpAuthorizationResponseOptions[\"jarm\"]\n>[\"serverMetadata\"];\n\nexport interface CreateAuthorizationResponseOptions {\n /**\n * Callbacks for authorization response generation\n */\n callbacks: Pick<\n CallbackContext,\n \"encryptJwe\" | \"fetch\" | \"generateRandom\" | \"signJwt\"\n >;\n\n /**\n * Thumbprint of the JWK in the cnf Wallet Attestation\n */\n client_id: string;\n\n /**\n * Optional expiration of the Authorization Response JWT, defaults to 10 minutes\n */\n exp?: number;\n\n /**\n * Presentation's Request Object\n */\n requestObject: AuthorizationRequestObject;\n\n /**\n * OpenID Federation Relying Party metadata\n */\n rpMetadata: ItWalletCredentialVerifierMetadata;\n\n /**\n * Signer created from the Wallet Instance's private key\n */\n signer: JwtSigner;\n\n /**\n * Array containing the vp_tokens of the credentials\n * to present\n */\n vp_token: VpToken;\n}\n\n/**\n * This method receives the RequestObject, its resolved VP Tokens and other necessary cryptographic and configuration data\n * and returns a signed and encrypted Presentation Response\n * @param options {@link CreateAuthorizationResponseOptions}\n * @returns An {@link CreateOpenid4vpAuthorizationResponseResult} representing\n * the encrypted and signed Presentation Response to the corresponding {@link AuthorizationRequestObject}\n * @throws An {@link CreateAuthorizationResponseError} in case of unexpected errors during response generation,\n * encryption, or signing\n */\nexport async function createAuthorizationResponse(\n options: CreateAuthorizationResponseOptions,\n) {\n try {\n const openid_credential_verifier = options.rpMetadata;\n\n const serverMetadata: JarmServerMetadata = {\n authorization_encryption_alg_values_supported: [\n openid_credential_verifier.authorization_encrypted_response_alg,\n ],\n authorization_encryption_enc_values_supported: [\n openid_credential_verifier.authorization_encrypted_response_enc,\n ],\n authorization_signing_alg_values_supported: [\n openid_credential_verifier.authorization_signed_response_alg,\n ],\n };\n\n // NOTE: This method sets the state in the Authorization Response\n // using the corresponding value in the Request Object\n return await createOpenid4vpAuthorizationResponse({\n authorizationRequestPayload: options.requestObject,\n authorizationResponsePayload: {\n vp_token: options.vp_token,\n },\n callbacks: options.callbacks,\n clientMetadata: openid_credential_verifier,\n jarm: {\n audience: options.requestObject.client_id,\n authorizationServer: options.client_id,\n encryption: {\n nonce: new TextDecoder().decode(\n await options.callbacks.generateRandom(32),\n ),\n },\n expiresInSeconds:\n options.exp ?? dateToSeconds(addSecondsToDate(new Date(), 60 * 10)), // default: 10 minutes\n jwtSigner: options.signer,\n serverMetadata,\n },\n });\n } catch (error) {\n throw new CreateAuthorizationResponseError(\n `Unexpected error during Request Object parsing: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAKO;AACP,mBAAgC;;;ACHzB,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAOO,IAAM,6BAAN,cAAyC,YAAY;AAAA,EAC1D,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,mCAAN,cAA+C,YAAY;AA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3G;AAAA,EACF;AACF;;;AGzEA,uBAIO;AACP,IAAAC,gBAAgD;AA4DhD,eAAsB,4BACpB,SACA;AACA,MAAI;AACF,UAAM,6BAA6B,QAAQ;AAE3C,UAAM,iBAAqC;AAAA,MACzC,+CAA+C;AAAA,QAC7C,2BAA2B;AAAA,MAC7B;AAAA,MACA,+CAA+C;AAAA,QAC7C,2BAA2B;AAAA,MAC7B;AAAA,MACA,4CAA4C;AAAA,QAC1C,2BAA2B;AAAA,MAC7B;AAAA,IACF;AAIA,WAAO,UAAM,uDAAqC;AAAA,MAChD,6BAA6B,QAAQ;AAAA,MACrC,8BAA8B;AAAA,QAC5B,UAAU,QAAQ;AAAA,MACpB;AAAA,MACA,WAAW,QAAQ;AAAA,MACnB,gBAAgB;AAAA,MAChB,MAAM;AAAA,QACJ,UAAU,QAAQ,cAAc;AAAA,QAChC,qBAAqB,QAAQ;AAAA,QAC7B,YAAY;AAAA,UACV,OAAO,IAAI,YAAY,EAAE;AAAA,YACvB,MAAM,QAAQ,UAAU,eAAe,EAAE;AAAA,UAC3C;AAAA,QACF;AAAA,QACA,kBACE,QAAQ,WAAO,iCAAc,gCAAiB,oBAAI,KAAK,GAAG,KAAK,EAAE,CAAC;AAAA;AAAA,QACpE,WAAW,QAAQ;AAAA,QACnB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,mDAAmD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IAC3G;AAAA,EACF;AACF;;;AJ5GA,IAAAC,oBAKO;","names":["import_oauth2","import_utils","import_openid4vp"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/authorization-request/parse-authorization-request.ts","../src/errors.ts","../src/authorization-request/z-request-object.ts","../src/authorization-response/create-authorization-response.ts","../src/authorization-response/fetch-authorization-response.ts","../src/authorization-response/z-authorization-response.ts"],"sourcesContent":["export * from \"./authorization-request\";\nexport * from \"./authorization-response\";\nexport * from \"./errors\";\n\nexport {\n type CreateOpenid4vpAuthorizationResponseOptions,\n type CreateOpenid4vpAuthorizationResponseResult,\n type VpToken,\n createOpenid4vpAuthorizationResponse,\n} from \"@openid4vc/openid4vp\";\n","import {\n CallbackContext,\n Oauth2JwtParseError,\n RequestDpopOptions,\n decodeJwt,\n} from \"@openid4vc/oauth2\";\nimport { ValidationError } from \"@openid4vc/utils\";\n\nimport { ParseAuthorizeRequestError } from \"../errors\";\nimport {\n AuthorizationRequestObject,\n zOpenid4vpAuthorizationRequestHeader,\n zOpenid4vpAuthorizationRequestPayload,\n} from \"./z-request-object\";\n\nexport interface ParseAuthorizeRequestOptions {\n /**\n * Callback context for signature verification.\n */\n callbacks: Pick<CallbackContext, \"verifyJwt\">;\n\n /**\n * DPoP options\n */\n dpop: RequestDpopOptions;\n\n /**\n * The Authorization Request Object JWT.\n */\n requestObjectJwt: string;\n}\n\n/**\n * This method verifies a JWT containing a Request Object and returns its\n * decoded value for further processing\n * @param options {@link ParseAuthorizeRequestOptions}\n * @returns An {@link AuthorizationRequestObject} containing the RP required\n * credentials\n * @throws {@link ValidationError} in case there are errors validating the Request Object structure\n * @throws {@link Oauth2JwtParseError} in case the request object jwt is malformed (e.g missing header, bad encoding)\n * @throws {@link ParseAuthorizeRequestError} in case the JWT signature is invalid or there are unexpected errors\n */\nexport async function parseAuthorizeRequest(\n options: ParseAuthorizeRequestOptions,\n): Promise<AuthorizationRequestObject> {\n try {\n const decoded = decodeJwt({\n headerSchema: zOpenid4vpAuthorizationRequestHeader,\n jwt: options.requestObjectJwt,\n payloadSchema: zOpenid4vpAuthorizationRequestPayload,\n });\n const verificationResult = await options.callbacks.verifyJwt(\n options.dpop.signer,\n {\n compact: options.requestObjectJwt,\n header: decoded.header,\n payload: decoded.payload,\n },\n );\n\n if (!verificationResult.verified)\n throw new ParseAuthorizeRequestError(\n \"Error verifying Request Object signature\",\n );\n\n return decoded.payload;\n } catch (error) {\n if (\n error instanceof ValidationError ||\n error instanceof Oauth2JwtParseError\n )\n throw error;\n throw new ParseAuthorizeRequestError(\n `Unexpected error during Request Object parsing: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n","/**\n * Generic error thrown during Oid4vp operations\n */\nexport class Oid4vpError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"Oid4vpError\";\n }\n}\n\n/**\n * Error thrown by {@link parseAuthorizeRequest} when the passed\n * request object has an invalid signature or unexpected errors\n * are thrown\n */\nexport class ParseAuthorizeRequestError extends Oid4vpError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"ParseAuthorizeRequestError\";\n }\n}\n\n/**\n * Error thrown by {@link fetchAuthorizationResponse}\n */\nexport class FetchAuthorizationResponseError extends Oid4vpError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"FetchAuthorizationResponseError\";\n }\n}\n\n/**\n * Error thrown by {@link createAuthorizationResponse} in case there\n * are unexpected errors.\n */\nexport class CreateAuthorizationResponseError extends Oid4vpError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"CreateAuthorizationResponseError\";\n }\n}\n","import { zJwtPayload } from \"@openid4vc/oauth2\";\nimport { z } from \"zod\";\n\n/**\n * Zod parser that describes a JWT payload\n * containing an OID4VP Request Object\n */\nexport const zOpenid4vpAuthorizationRequestPayload = z\n .object({\n client_id: z.string(),\n dcql_query: z.record(z.string(), z.any()).optional(),\n nonce: z.string(),\n request_uri: z.string().url().optional(),\n request_uri_method: z.optional(z.string()),\n response_mode: z.literal(\"direct_post.jwt\"),\n response_type: z.literal(\"vp_token\"),\n response_uri: z.string().url().optional(),\n scope: z.string().optional(),\n state: z.string(),\n wallet_nonce: z.string().optional(),\n })\n .passthrough()\n .and(zJwtPayload);\n\nexport type AuthorizationRequestObject = z.infer<\n typeof zOpenid4vpAuthorizationRequestPayload\n>;\n\nexport const zOpenid4vpAuthorizationRequestHeader = z\n .object({\n alg: z.string(),\n kid: z.string().optional(),\n trust_chain: z.array(z.string()).nonempty().optional(),\n typ: z.literal(\"oauth-authz-req+jwt\"),\n x5c: z.array(z.string()).optional(),\n })\n .passthrough();\n","import { CallbackContext, JwtSigner } from \"@openid4vc/oauth2\";\nimport {\n CreateOpenid4vpAuthorizationResponseOptions,\n VpToken,\n createOpenid4vpAuthorizationResponse,\n} from \"@openid4vc/openid4vp\";\nimport { addSecondsToDate, dateToSeconds } from \"@openid4vc/utils\";\nimport { ItWalletCredentialVerifierMetadata } from \"@pagopa/io-wallet-oid-federation\";\n\nimport { AuthorizationRequestObject } from \"../authorization-request\";\nimport { CreateAuthorizationResponseError } from \"../errors\";\n\ntype JarmServerMetadata = NonNullable<\n CreateOpenid4vpAuthorizationResponseOptions[\"jarm\"]\n>[\"serverMetadata\"];\n\nexport interface CreateAuthorizationResponseOptions {\n /**\n * Callbacks for authorization response generation\n */\n callbacks: Pick<\n CallbackContext,\n \"encryptJwe\" | \"fetch\" | \"generateRandom\" | \"signJwt\"\n >;\n\n /**\n * Thumbprint of the JWK in the cnf Wallet Attestation\n */\n client_id: string;\n\n /**\n * Optional expiration of the Authorization Response JWT, defaults to 10 minutes\n */\n exp?: number;\n\n /**\n * Presentation's Request Object\n */\n requestObject: AuthorizationRequestObject;\n\n /**\n * OpenID Federation Relying Party metadata\n */\n rpMetadata: ItWalletCredentialVerifierMetadata;\n\n /**\n * Signer created from the Wallet Instance's private key\n */\n signer: JwtSigner;\n\n /**\n * Array containing the vp_tokens of the credentials\n * to present\n */\n vp_token: VpToken;\n}\n\n/**\n * This method receives the RequestObject, its resolved VP Tokens and other necessary cryptographic and configuration data\n * and returns a signed and encrypted Presentation Response\n * @param options {@link CreateAuthorizationResponseOptions}\n * @returns An {@link CreateOpenid4vpAuthorizationResponseResult} representing\n * the encrypted and signed Presentation Response to the corresponding {@link AuthorizationRequestObject}\n * @throws An {@link CreateAuthorizationResponseError} in case of unexpected errors during response generation,\n * encryption, or signing\n */\nexport async function createAuthorizationResponse(\n options: CreateAuthorizationResponseOptions,\n) {\n try {\n const openid_credential_verifier = options.rpMetadata;\n\n const serverMetadata: JarmServerMetadata = {\n authorization_encryption_alg_values_supported: [\n openid_credential_verifier.authorization_encrypted_response_alg,\n ],\n authorization_encryption_enc_values_supported: [\n openid_credential_verifier.authorization_encrypted_response_enc,\n ],\n authorization_signing_alg_values_supported: [\n openid_credential_verifier.authorization_signed_response_alg,\n ],\n };\n\n // NOTE: This method sets the state in the Authorization Response\n // using the corresponding value in the Request Object\n return await createOpenid4vpAuthorizationResponse({\n authorizationRequestPayload: options.requestObject,\n authorizationResponsePayload: {\n vp_token: options.vp_token,\n },\n callbacks: options.callbacks,\n clientMetadata: openid_credential_verifier,\n jarm: {\n audience: options.requestObject.client_id,\n authorizationServer: options.client_id,\n encryption: {\n nonce: new TextDecoder().decode(\n await options.callbacks.generateRandom(32),\n ),\n },\n expiresInSeconds:\n options.exp ?? dateToSeconds(addSecondsToDate(new Date(), 60 * 10)), // default: 10 minutes\n jwtSigner: options.signer,\n serverMetadata,\n },\n });\n } catch (error) {\n throw new CreateAuthorizationResponseError(\n `Unexpected error during Request Object parsing: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n","import { CallbackContext } from \"@openid4vc/oauth2\";\nimport {\n ValidationError,\n createFetcher,\n parseWithErrorHandling,\n} from \"@openid4vc/utils\";\nimport {\n CONTENT_TYPES,\n HEADERS,\n UnexpectedStatusCodeError,\n hasStatusOrThrow,\n} from \"@pagopa/io-wallet-utils\";\n\nimport { FetchAuthorizationResponseError } from \"../errors\";\nimport {\n Oid4vpAuthorizationResponseResult,\n zOid4vpAuthorizationResponseResult,\n} from \"./z-authorization-response\";\n\n/**\n * Configuration options for fetching OID4VP Presentation Result\n */\nexport interface FetchAuthorizationResponseOptions {\n /**\n * The signed and encrypted {@link Openid4vpAuthorizationResponse} in base64 format\n */\n authorizationResponseJarm: string;\n\n /**\n * Callback functions for making HTTP requests\n * Allows for custom fetch implementations\n */\n callbacks: Pick<CallbackContext, \"fetch\">;\n\n /**\n * The response_uri field contained in the {@link AuthorizationRequestObject}\n */\n presentationResponseUri: string;\n}\n\n/**\n * Sends the {@link Openid4vpAuthorizationResponse} to the response uri provided by the session's\n * {@link AuthorizationRequestObject} and returns the {@link Oid4vpAuthorizationResponseResult} object\n * containing the redirect_uri at which to continue the presentation\n *\n * @param options {@link FetchAuthorizationResponseOptions}\n * @returns Promise that resolves to the parsed {@link Oid4vpAuthorizationResponseResult}\n * @throws {UnexpectedStatusCodeError} When the server returns a non-200 status code\n * @throws {ValidationError} When the response cannot be parsed or is invalid\n */\nexport async function fetchAuthorizationResponse(\n options: FetchAuthorizationResponseOptions,\n): Promise<Oid4vpAuthorizationResponseResult> {\n try {\n const fetch = createFetcher(options.callbacks.fetch);\n const authorizationResponseResult = await fetch(\n options.presentationResponseUri,\n {\n body: new URLSearchParams({\n response: options.authorizationResponseJarm,\n }),\n headers: {\n [HEADERS.CONTENT_TYPE]: CONTENT_TYPES.FORM_URLENCODED,\n },\n method: \"POST\",\n },\n );\n\n await hasStatusOrThrow(\n 200,\n UnexpectedStatusCodeError,\n )(authorizationResponseResult);\n\n const authorizationResponseResultJson =\n await authorizationResponseResult.json();\n\n //Response could be anything, so it's returned as is for further processing\n return parseWithErrorHandling(\n zOid4vpAuthorizationResponseResult,\n authorizationResponseResultJson,\n );\n } catch (error) {\n if (\n error instanceof UnexpectedStatusCodeError ||\n error instanceof ValidationError\n ) {\n throw error;\n }\n throw new FetchAuthorizationResponseError(\n `Unexpected error sending authorization response: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n","import z from \"zod\";\n\nexport const zOid4vpAuthorizationResponseResult = z.object({\n redirect_uri: z.string(),\n});\n\nexport type Oid4vpAuthorizationResponseResult = z.infer<\n typeof zOid4vpAuthorizationResponseResult\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAA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AAM;AAAA,IACR;AACA,UAAM,IAAI;AAAA,MACR,oDAAoD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IAC5G;AAAA,EACF;AACF;;;ALxFA,IAAAC,oBAKO;","names":["import_oauth2","import_utils","import_utils","import_zod","z","import_openid4vp"]}
|
package/dist/index.mjs
CHANGED
|
@@ -20,6 +20,13 @@ var ParseAuthorizeRequestError = class extends Oid4vpError {
|
|
|
20
20
|
this.name = "ParseAuthorizeRequestError";
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
+
var FetchAuthorizationResponseError = class extends Oid4vpError {
|
|
24
|
+
constructor(message, statusCode) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.statusCode = statusCode;
|
|
27
|
+
this.name = "FetchAuthorizationResponseError";
|
|
28
|
+
}
|
|
29
|
+
};
|
|
23
30
|
var CreateAuthorizationResponseError = class extends Oid4vpError {
|
|
24
31
|
constructor(message, statusCode) {
|
|
25
32
|
super(message);
|
|
@@ -31,7 +38,7 @@ var CreateAuthorizationResponseError = class extends Oid4vpError {
|
|
|
31
38
|
// src/authorization-request/z-request-object.ts
|
|
32
39
|
import { zJwtPayload } from "@openid4vc/oauth2";
|
|
33
40
|
import { z } from "zod";
|
|
34
|
-
var
|
|
41
|
+
var zOpenid4vpAuthorizationRequestPayload = z.object({
|
|
35
42
|
client_id: z.string(),
|
|
36
43
|
dcql_query: z.record(z.string(), z.any()).optional(),
|
|
37
44
|
nonce: z.string(),
|
|
@@ -44,13 +51,21 @@ var zOpenid4vpAuthorizationRequest = z.object({
|
|
|
44
51
|
state: z.string(),
|
|
45
52
|
wallet_nonce: z.string().optional()
|
|
46
53
|
}).passthrough().and(zJwtPayload);
|
|
54
|
+
var zOpenid4vpAuthorizationRequestHeader = z.object({
|
|
55
|
+
alg: z.string(),
|
|
56
|
+
kid: z.string().optional(),
|
|
57
|
+
trust_chain: z.array(z.string()).nonempty().optional(),
|
|
58
|
+
typ: z.literal("oauth-authz-req+jwt"),
|
|
59
|
+
x5c: z.array(z.string()).optional()
|
|
60
|
+
}).passthrough();
|
|
47
61
|
|
|
48
62
|
// src/authorization-request/parse-authorization-request.ts
|
|
49
63
|
async function parseAuthorizeRequest(options) {
|
|
50
64
|
try {
|
|
51
65
|
const decoded = decodeJwt({
|
|
66
|
+
headerSchema: zOpenid4vpAuthorizationRequestHeader,
|
|
52
67
|
jwt: options.requestObjectJwt,
|
|
53
|
-
payloadSchema:
|
|
68
|
+
payloadSchema: zOpenid4vpAuthorizationRequestPayload
|
|
54
69
|
});
|
|
55
70
|
const verificationResult = await options.callbacks.verifyJwt(
|
|
56
71
|
options.dpop.signer,
|
|
@@ -121,17 +136,75 @@ async function createAuthorizationResponse(options) {
|
|
|
121
136
|
}
|
|
122
137
|
}
|
|
123
138
|
|
|
139
|
+
// src/authorization-response/fetch-authorization-response.ts
|
|
140
|
+
import {
|
|
141
|
+
ValidationError as ValidationError2,
|
|
142
|
+
createFetcher,
|
|
143
|
+
parseWithErrorHandling
|
|
144
|
+
} from "@openid4vc/utils";
|
|
145
|
+
import {
|
|
146
|
+
CONTENT_TYPES,
|
|
147
|
+
HEADERS,
|
|
148
|
+
UnexpectedStatusCodeError,
|
|
149
|
+
hasStatusOrThrow
|
|
150
|
+
} from "@pagopa/io-wallet-utils";
|
|
151
|
+
|
|
152
|
+
// src/authorization-response/z-authorization-response.ts
|
|
153
|
+
import z2 from "zod";
|
|
154
|
+
var zOid4vpAuthorizationResponseResult = z2.object({
|
|
155
|
+
redirect_uri: z2.string()
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// src/authorization-response/fetch-authorization-response.ts
|
|
159
|
+
async function fetchAuthorizationResponse(options) {
|
|
160
|
+
try {
|
|
161
|
+
const fetch = createFetcher(options.callbacks.fetch);
|
|
162
|
+
const authorizationResponseResult = await fetch(
|
|
163
|
+
options.presentationResponseUri,
|
|
164
|
+
{
|
|
165
|
+
body: new URLSearchParams({
|
|
166
|
+
response: options.authorizationResponseJarm
|
|
167
|
+
}),
|
|
168
|
+
headers: {
|
|
169
|
+
[HEADERS.CONTENT_TYPE]: CONTENT_TYPES.FORM_URLENCODED
|
|
170
|
+
},
|
|
171
|
+
method: "POST"
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
await hasStatusOrThrow(
|
|
175
|
+
200,
|
|
176
|
+
UnexpectedStatusCodeError
|
|
177
|
+
)(authorizationResponseResult);
|
|
178
|
+
const authorizationResponseResultJson = await authorizationResponseResult.json();
|
|
179
|
+
return parseWithErrorHandling(
|
|
180
|
+
zOid4vpAuthorizationResponseResult,
|
|
181
|
+
authorizationResponseResultJson
|
|
182
|
+
);
|
|
183
|
+
} catch (error) {
|
|
184
|
+
if (error instanceof UnexpectedStatusCodeError || error instanceof ValidationError2) {
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
throw new FetchAuthorizationResponseError(
|
|
188
|
+
`Unexpected error sending authorization response: ${error instanceof Error ? error.message : String(error)}`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
124
193
|
// src/index.ts
|
|
125
194
|
import {
|
|
126
195
|
createOpenid4vpAuthorizationResponse as createOpenid4vpAuthorizationResponse2
|
|
127
196
|
} from "@openid4vc/openid4vp";
|
|
128
197
|
export {
|
|
129
198
|
CreateAuthorizationResponseError,
|
|
199
|
+
FetchAuthorizationResponseError,
|
|
130
200
|
Oid4vpError,
|
|
131
201
|
ParseAuthorizeRequestError,
|
|
132
202
|
createAuthorizationResponse,
|
|
133
203
|
createOpenid4vpAuthorizationResponse2 as createOpenid4vpAuthorizationResponse,
|
|
204
|
+
fetchAuthorizationResponse,
|
|
134
205
|
parseAuthorizeRequest,
|
|
135
|
-
|
|
206
|
+
zOid4vpAuthorizationResponseResult,
|
|
207
|
+
zOpenid4vpAuthorizationRequestHeader,
|
|
208
|
+
zOpenid4vpAuthorizationRequestPayload
|
|
136
209
|
};
|
|
137
210
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/authorization-request/parse-authorization-request.ts","../src/errors.ts","../src/authorization-request/z-request-object.ts","../src/authorization-response/create-authorization-response.ts","../src/index.ts"],"sourcesContent":["import {\n CallbackContext,\n Oauth2JwtParseError,\n RequestDpopOptions,\n decodeJwt,\n} from \"@openid4vc/oauth2\";\nimport { ValidationError } from \"@openid4vc/utils\";\n\nimport { ParseAuthorizeRequestError } from \"../errors\";\nimport {\n AuthorizationRequestObject,\n zOpenid4vpAuthorizationRequest,\n} from \"./z-request-object\";\n\nexport interface ParseAuthorizeRequestOptions {\n /**\n * Callback context for signature verification.\n */\n callbacks: Pick<CallbackContext, \"verifyJwt\">;\n\n /**\n * DPoP options\n */\n dpop: RequestDpopOptions;\n\n /**\n * The Authorization Request Object JWT.\n */\n requestObjectJwt: string;\n}\n\n/**\n * This method verifies a JWT containing a Request Object and returns its\n * decoded value for further processing\n * @param options {@link ParseAuthorizeRequestOptions}\n * @returns An {@link AuthorizationRequestObject} containing the RP required\n * credentials\n * @throws {@link ValidationError} in case there are errors validating the Request Object structure\n * @throws {@link Oauth2JwtParseError} in case the request object jwt is malformed (e.g missing header, bad encoding)\n * @throws {@link ParseAuthorizeRequestError} in case the JWT signature is invalid or there are unexpected errors\n */\nexport async function parseAuthorizeRequest(\n options: ParseAuthorizeRequestOptions,\n): Promise<AuthorizationRequestObject> {\n try {\n const decoded = decodeJwt({\n jwt: options.requestObjectJwt,\n payloadSchema: zOpenid4vpAuthorizationRequest,\n });\n const verificationResult = await options.callbacks.verifyJwt(\n options.dpop.signer,\n {\n compact: options.requestObjectJwt,\n header: decoded.header,\n payload: decoded.payload,\n },\n );\n\n if (!verificationResult.verified)\n throw new ParseAuthorizeRequestError(\n \"Error verifying Request Object signature\",\n );\n\n return decoded.payload;\n } catch (error) {\n if (\n error instanceof ValidationError ||\n error instanceof Oauth2JwtParseError\n )\n throw error;\n throw new ParseAuthorizeRequestError(\n `Unexpected error during Request Object parsing: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n","/**\n * Generic error thrown during Oid4vp operations\n */\nexport class Oid4vpError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"Oid4vpError\";\n }\n}\n\n/**\n * Error thrown by {@link parseAuthorizeRequest} when the passed\n * request object has an invalid signature or unexpected errors\n * are thrown\n */\nexport class ParseAuthorizeRequestError extends Oid4vpError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"ParseAuthorizeRequestError\";\n }\n}\n\n/**\n * Error thrown by {@link createAuthorizationResponse} in case there\n * are unexpected errors.\n */\nexport class CreateAuthorizationResponseError extends Oid4vpError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"CreateAuthorizationResponseError\";\n }\n}\n","import { zJwtPayload } from \"@openid4vc/oauth2\";\nimport { z } from \"zod\";\n\n/**\n * Zod parser that describes a JWT payload\n * containing an OID4VP Request Object\n */\nexport const zOpenid4vpAuthorizationRequest = z\n .object({\n client_id: z.string(),\n dcql_query: z.record(z.string(), z.any()).optional(),\n nonce: z.string(),\n request_uri: z.string().url().optional(),\n request_uri_method: z.optional(z.string()),\n response_mode: z.literal(\"direct_post.jwt\"),\n response_type: z.literal(\"vp_token\"),\n response_uri: z.string().url().optional(),\n scope: z.string().optional(),\n state: z.string(),\n wallet_nonce: z.string().optional(),\n })\n .passthrough()\n .and(zJwtPayload);\n\nexport type AuthorizationRequestObject = z.infer<\n typeof zOpenid4vpAuthorizationRequest\n>;\n","import { CallbackContext, JwtSigner } from \"@openid4vc/oauth2\";\nimport {\n CreateOpenid4vpAuthorizationResponseOptions,\n VpToken,\n createOpenid4vpAuthorizationResponse,\n} from \"@openid4vc/openid4vp\";\nimport { addSecondsToDate, dateToSeconds } from \"@openid4vc/utils\";\nimport { ItWalletCredentialVerifierMetadata } from \"@pagopa/io-wallet-oid-federation\";\n\nimport { AuthorizationRequestObject } from \"../authorization-request\";\nimport { CreateAuthorizationResponseError } from \"../errors\";\n\ntype JarmServerMetadata = NonNullable<\n CreateOpenid4vpAuthorizationResponseOptions[\"jarm\"]\n>[\"serverMetadata\"];\n\nexport interface CreateAuthorizationResponseOptions {\n /**\n * Callbacks for authorization response generation\n */\n callbacks: Pick<\n CallbackContext,\n \"encryptJwe\" | \"fetch\" | \"generateRandom\" | \"signJwt\"\n >;\n\n /**\n * Thumbprint of the JWK in the cnf Wallet Attestation\n */\n client_id: string;\n\n /**\n * Optional expiration of the Authorization Response JWT, defaults to 10 minutes\n */\n exp?: number;\n\n /**\n * Presentation's Request Object\n */\n requestObject: AuthorizationRequestObject;\n\n /**\n * OpenID Federation Relying Party metadata\n */\n rpMetadata: ItWalletCredentialVerifierMetadata;\n\n /**\n * Signer created from the Wallet Instance's private key\n */\n signer: JwtSigner;\n\n /**\n * Array containing the vp_tokens of the credentials\n * to present\n */\n vp_token: VpToken;\n}\n\n/**\n * This method receives the RequestObject, its resolved VP Tokens and other necessary cryptographic and configuration data\n * and returns a signed and encrypted Presentation Response\n * @param options {@link CreateAuthorizationResponseOptions}\n * @returns An {@link CreateOpenid4vpAuthorizationResponseResult} representing\n * the encrypted and signed Presentation Response to the corresponding {@link AuthorizationRequestObject}\n * @throws An {@link CreateAuthorizationResponseError} in case of unexpected errors during response generation,\n * encryption, or signing\n */\nexport async function createAuthorizationResponse(\n options: CreateAuthorizationResponseOptions,\n) {\n try {\n const openid_credential_verifier = options.rpMetadata;\n\n const serverMetadata: JarmServerMetadata = {\n authorization_encryption_alg_values_supported: [\n openid_credential_verifier.authorization_encrypted_response_alg,\n ],\n authorization_encryption_enc_values_supported: [\n openid_credential_verifier.authorization_encrypted_response_enc,\n ],\n authorization_signing_alg_values_supported: [\n openid_credential_verifier.authorization_signed_response_alg,\n ],\n };\n\n // NOTE: This method sets the state in the Authorization Response\n // using the corresponding value in the Request Object\n return await createOpenid4vpAuthorizationResponse({\n authorizationRequestPayload: options.requestObject,\n authorizationResponsePayload: {\n vp_token: options.vp_token,\n },\n callbacks: options.callbacks,\n clientMetadata: openid_credential_verifier,\n jarm: {\n audience: options.requestObject.client_id,\n authorizationServer: options.client_id,\n encryption: {\n nonce: new TextDecoder().decode(\n await options.callbacks.generateRandom(32),\n ),\n },\n expiresInSeconds:\n options.exp ?? dateToSeconds(addSecondsToDate(new Date(), 60 * 10)), // default: 10 minutes\n jwtSigner: options.signer,\n serverMetadata,\n },\n });\n } catch (error) {\n throw new CreateAuthorizationResponseError(\n `Unexpected error during Request Object parsing: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n","export * from \"./authorization-request\";\nexport * from \"./authorization-response\";\nexport * from \"./errors\";\n\nexport {\n type CreateOpenid4vpAuthorizationResponseOptions,\n type CreateOpenid4vpAuthorizationResponseResult,\n type VpToken,\n createOpenid4vpAuthorizationResponse,\n} from \"@openid4vc/openid4vp\";\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,uBAAuB;;;ACHzB,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAOO,IAAM,6BAAN,cAAyC,YAAY;AAAA,EAC1D,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAMO,IAAM,mCAAN,cAA+C,YAAY;AAAA,EAChE,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACxCA,SAAS,mBAAmB;AAC5B,SAAS,SAAS;AAMX,IAAM,iCAAiC,EAC3C,OAAO;AAAA,EACN,WAAW,EAAE,OAAO;AAAA,EACpB,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACnD,OAAO,EAAE,OAAO;A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C;AAAA,QAC1C,2BAA2B;AAAA,MAC7B;AAAA,IACF;AAIA,WAAO,MAAM,qCAAqC;AAAA,MAChD,6BAA6B,QAAQ;AAAA,MACrC,8BAA8B;AAAA,QAC5B,UAAU,QAAQ;AAAA,MACpB;AAAA,MACA,WAAW,QAAQ;AAAA,MACnB,gBAAgB;AAAA,MAChB,MAAM;AAAA,QACJ,UAAU,QAAQ,cAAc;AAAA,QAChC,qBAAqB,QAAQ;AAAA,QAC7B,YAAY;AAAA,UACV,OAAO,IAAI,YAAY,EAAE;AAAA,YACvB,MAAM,QAAQ,UAAU,eAAe,EAAE;AAAA,UAC3C;AAAA,QACF;AAAA,QACA,kBACE,QAAQ,OAAO,cAAc,iBAAiB,oBAAI,KAAK,GAAG,KAAK,EAAE,CAAC;AAAA;AAAA,QACpE,WAAW,QAAQ;AAAA,QACnB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,mDAAmD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IAC3G;AAAA,EACF;AACF;;;AC5GA;AAAA,EAIE,wCAAAA;AAAA,OACK;","names":["createOpenid4vpAuthorizationResponse"]}
|
|
1
|
+
{"version":3,"sources":["../src/authorization-request/parse-authorization-request.ts","../src/errors.ts","../src/authorization-request/z-request-object.ts","../src/authorization-response/create-authorization-response.ts","../src/authorization-response/fetch-authorization-response.ts","../src/authorization-response/z-authorization-response.ts","../src/index.ts"],"sourcesContent":["import {\n CallbackContext,\n Oauth2JwtParseError,\n RequestDpopOptions,\n decodeJwt,\n} from \"@openid4vc/oauth2\";\nimport { ValidationError } from \"@openid4vc/utils\";\n\nimport { ParseAuthorizeRequestError } from \"../errors\";\nimport {\n AuthorizationRequestObject,\n zOpenid4vpAuthorizationRequestHeader,\n zOpenid4vpAuthorizationRequestPayload,\n} from \"./z-request-object\";\n\nexport interface ParseAuthorizeRequestOptions {\n /**\n * Callback context for signature verification.\n */\n callbacks: Pick<CallbackContext, \"verifyJwt\">;\n\n /**\n * DPoP options\n */\n dpop: RequestDpopOptions;\n\n /**\n * The Authorization Request Object JWT.\n */\n requestObjectJwt: string;\n}\n\n/**\n * This method verifies a JWT containing a Request Object and returns its\n * decoded value for further processing\n * @param options {@link ParseAuthorizeRequestOptions}\n * @returns An {@link AuthorizationRequestObject} containing the RP required\n * credentials\n * @throws {@link ValidationError} in case there are errors validating the Request Object structure\n * @throws {@link Oauth2JwtParseError} in case the request object jwt is malformed (e.g missing header, bad encoding)\n * @throws {@link ParseAuthorizeRequestError} in case the JWT signature is invalid or there are unexpected errors\n */\nexport async function parseAuthorizeRequest(\n options: ParseAuthorizeRequestOptions,\n): Promise<AuthorizationRequestObject> {\n try {\n const decoded = decodeJwt({\n headerSchema: zOpenid4vpAuthorizationRequestHeader,\n jwt: options.requestObjectJwt,\n payloadSchema: zOpenid4vpAuthorizationRequestPayload,\n });\n const verificationResult = await options.callbacks.verifyJwt(\n options.dpop.signer,\n {\n compact: options.requestObjectJwt,\n header: decoded.header,\n payload: decoded.payload,\n },\n );\n\n if (!verificationResult.verified)\n throw new ParseAuthorizeRequestError(\n \"Error verifying Request Object signature\",\n );\n\n return decoded.payload;\n } catch (error) {\n if (\n error instanceof ValidationError ||\n error instanceof Oauth2JwtParseError\n )\n throw error;\n throw new ParseAuthorizeRequestError(\n `Unexpected error during Request Object parsing: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n","/**\n * Generic error thrown during Oid4vp operations\n */\nexport class Oid4vpError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"Oid4vpError\";\n }\n}\n\n/**\n * Error thrown by {@link parseAuthorizeRequest} when the passed\n * request object has an invalid signature or unexpected errors\n * are thrown\n */\nexport class ParseAuthorizeRequestError extends Oid4vpError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"ParseAuthorizeRequestError\";\n }\n}\n\n/**\n * Error thrown by {@link fetchAuthorizationResponse}\n */\nexport class FetchAuthorizationResponseError extends Oid4vpError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"FetchAuthorizationResponseError\";\n }\n}\n\n/**\n * Error thrown by {@link createAuthorizationResponse} in case there\n * are unexpected errors.\n */\nexport class CreateAuthorizationResponseError extends Oid4vpError {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"CreateAuthorizationResponseError\";\n }\n}\n","import { zJwtPayload } from \"@openid4vc/oauth2\";\nimport { z } from \"zod\";\n\n/**\n * Zod parser that describes a JWT payload\n * containing an OID4VP Request Object\n */\nexport const zOpenid4vpAuthorizationRequestPayload = z\n .object({\n client_id: z.string(),\n dcql_query: z.record(z.string(), z.any()).optional(),\n nonce: z.string(),\n request_uri: z.string().url().optional(),\n request_uri_method: z.optional(z.string()),\n response_mode: z.literal(\"direct_post.jwt\"),\n response_type: z.literal(\"vp_token\"),\n response_uri: z.string().url().optional(),\n scope: z.string().optional(),\n state: z.string(),\n wallet_nonce: z.string().optional(),\n })\n .passthrough()\n .and(zJwtPayload);\n\nexport type AuthorizationRequestObject = z.infer<\n typeof zOpenid4vpAuthorizationRequestPayload\n>;\n\nexport const zOpenid4vpAuthorizationRequestHeader = z\n .object({\n alg: z.string(),\n kid: z.string().optional(),\n trust_chain: z.array(z.string()).nonempty().optional(),\n typ: z.literal(\"oauth-authz-req+jwt\"),\n x5c: z.array(z.string()).optional(),\n })\n .passthrough();\n","import { CallbackContext, JwtSigner } from \"@openid4vc/oauth2\";\nimport {\n CreateOpenid4vpAuthorizationResponseOptions,\n VpToken,\n createOpenid4vpAuthorizationResponse,\n} from \"@openid4vc/openid4vp\";\nimport { addSecondsToDate, dateToSeconds } from \"@openid4vc/utils\";\nimport { ItWalletCredentialVerifierMetadata } from \"@pagopa/io-wallet-oid-federation\";\n\nimport { AuthorizationRequestObject } from \"../authorization-request\";\nimport { CreateAuthorizationResponseError } from \"../errors\";\n\ntype JarmServerMetadata = NonNullable<\n CreateOpenid4vpAuthorizationResponseOptions[\"jarm\"]\n>[\"serverMetadata\"];\n\nexport interface CreateAuthorizationResponseOptions {\n /**\n * Callbacks for authorization response generation\n */\n callbacks: Pick<\n CallbackContext,\n \"encryptJwe\" | \"fetch\" | \"generateRandom\" | \"signJwt\"\n >;\n\n /**\n * Thumbprint of the JWK in the cnf Wallet Attestation\n */\n client_id: string;\n\n /**\n * Optional expiration of the Authorization Response JWT, defaults to 10 minutes\n */\n exp?: number;\n\n /**\n * Presentation's Request Object\n */\n requestObject: AuthorizationRequestObject;\n\n /**\n * OpenID Federation Relying Party metadata\n */\n rpMetadata: ItWalletCredentialVerifierMetadata;\n\n /**\n * Signer created from the Wallet Instance's private key\n */\n signer: JwtSigner;\n\n /**\n * Array containing the vp_tokens of the credentials\n * to present\n */\n vp_token: VpToken;\n}\n\n/**\n * This method receives the RequestObject, its resolved VP Tokens and other necessary cryptographic and configuration data\n * and returns a signed and encrypted Presentation Response\n * @param options {@link CreateAuthorizationResponseOptions}\n * @returns An {@link CreateOpenid4vpAuthorizationResponseResult} representing\n * the encrypted and signed Presentation Response to the corresponding {@link AuthorizationRequestObject}\n * @throws An {@link CreateAuthorizationResponseError} in case of unexpected errors during response generation,\n * encryption, or signing\n */\nexport async function createAuthorizationResponse(\n options: CreateAuthorizationResponseOptions,\n) {\n try {\n const openid_credential_verifier = options.rpMetadata;\n\n const serverMetadata: JarmServerMetadata = {\n authorization_encryption_alg_values_supported: [\n openid_credential_verifier.authorization_encrypted_response_alg,\n ],\n authorization_encryption_enc_values_supported: [\n openid_credential_verifier.authorization_encrypted_response_enc,\n ],\n authorization_signing_alg_values_supported: [\n openid_credential_verifier.authorization_signed_response_alg,\n ],\n };\n\n // NOTE: This method sets the state in the Authorization Response\n // using the corresponding value in the Request Object\n return await createOpenid4vpAuthorizationResponse({\n authorizationRequestPayload: options.requestObject,\n authorizationResponsePayload: {\n vp_token: options.vp_token,\n },\n callbacks: options.callbacks,\n clientMetadata: openid_credential_verifier,\n jarm: {\n audience: options.requestObject.client_id,\n authorizationServer: options.client_id,\n encryption: {\n nonce: new TextDecoder().decode(\n await options.callbacks.generateRandom(32),\n ),\n },\n expiresInSeconds:\n options.exp ?? dateToSeconds(addSecondsToDate(new Date(), 60 * 10)), // default: 10 minutes\n jwtSigner: options.signer,\n serverMetadata,\n },\n });\n } catch (error) {\n throw new CreateAuthorizationResponseError(\n `Unexpected error during Request Object parsing: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n","import { CallbackContext } from \"@openid4vc/oauth2\";\nimport {\n ValidationError,\n createFetcher,\n parseWithErrorHandling,\n} from \"@openid4vc/utils\";\nimport {\n CONTENT_TYPES,\n HEADERS,\n UnexpectedStatusCodeError,\n hasStatusOrThrow,\n} from \"@pagopa/io-wallet-utils\";\n\nimport { FetchAuthorizationResponseError } from \"../errors\";\nimport {\n Oid4vpAuthorizationResponseResult,\n zOid4vpAuthorizationResponseResult,\n} from \"./z-authorization-response\";\n\n/**\n * Configuration options for fetching OID4VP Presentation Result\n */\nexport interface FetchAuthorizationResponseOptions {\n /**\n * The signed and encrypted {@link Openid4vpAuthorizationResponse} in base64 format\n */\n authorizationResponseJarm: string;\n\n /**\n * Callback functions for making HTTP requests\n * Allows for custom fetch implementations\n */\n callbacks: Pick<CallbackContext, \"fetch\">;\n\n /**\n * The response_uri field contained in the {@link AuthorizationRequestObject}\n */\n presentationResponseUri: string;\n}\n\n/**\n * Sends the {@link Openid4vpAuthorizationResponse} to the response uri provided by the session's\n * {@link AuthorizationRequestObject} and returns the {@link Oid4vpAuthorizationResponseResult} object\n * containing the redirect_uri at which to continue the presentation\n *\n * @param options {@link FetchAuthorizationResponseOptions}\n * @returns Promise that resolves to the parsed {@link Oid4vpAuthorizationResponseResult}\n * @throws {UnexpectedStatusCodeError} When the server returns a non-200 status code\n * @throws {ValidationError} When the response cannot be parsed or is invalid\n */\nexport async function fetchAuthorizationResponse(\n options: FetchAuthorizationResponseOptions,\n): Promise<Oid4vpAuthorizationResponseResult> {\n try {\n const fetch = createFetcher(options.callbacks.fetch);\n const authorizationResponseResult = await fetch(\n options.presentationResponseUri,\n {\n body: new URLSearchParams({\n response: options.authorizationResponseJarm,\n }),\n headers: {\n [HEADERS.CONTENT_TYPE]: CONTENT_TYPES.FORM_URLENCODED,\n },\n method: \"POST\",\n },\n );\n\n await hasStatusOrThrow(\n 200,\n UnexpectedStatusCodeError,\n )(authorizationResponseResult);\n\n const authorizationResponseResultJson =\n await authorizationResponseResult.json();\n\n //Response could be anything, so it's returned as is for further processing\n return parseWithErrorHandling(\n zOid4vpAuthorizationResponseResult,\n authorizationResponseResultJson,\n );\n } catch (error) {\n if (\n error instanceof UnexpectedStatusCodeError ||\n error instanceof ValidationError\n ) {\n throw error;\n }\n throw new FetchAuthorizationResponseError(\n `Unexpected error sending authorization response: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n}\n","import z from \"zod\";\n\nexport const zOid4vpAuthorizationResponseResult = z.object({\n redirect_uri: z.string(),\n});\n\nexport type Oid4vpAuthorizationResponseResult = z.infer<\n typeof zOid4vpAuthorizationResponseResult\n>;\n","export * from \"./authorization-request\";\nexport * from \"./authorization-response\";\nexport * from \"./errors\";\n\nexport {\n type CreateOpenid4vpAuthorizationResponseOptions,\n type CreateOpenid4vpAuthorizationResponseResult,\n type VpToken,\n createOpenid4vpAuthorizationResponse,\n} from \"@openid4vc/openid4vp\";\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,uBAAuB;;;ACHzB,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAOO,IAAM,6BAAN,cAAyC,YAAY;AAAA,EAC1D,YACE,SACgB,YAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,kCAAN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;AAAA;AAAA,QACpE,WAAW,QAAQ;AAAA,QACnB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,mDAAmD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IAC3G;AAAA,EACF;AACF;;;AC/GA;AAAA,EACE,mBAAAA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACXP,OAAOC,QAAO;AAEP,IAAM,qCAAqCA,GAAE,OAAO;AAAA,EACzD,cAAcA,GAAE,OAAO;AACzB,CAAC;;;AD8CD,eAAsB,2BACpB,SAC4C;AAC5C,MAAI;AACF,UAAM,QAAQ,cAAc,QAAQ,UAAU,KAAK;AACnD,UAAM,8BAA8B,MAAM;AAAA,MACxC,QAAQ;AAAA,MACR;AAAA,QACE,MAAM,IAAI,gBAAgB;AAAA,UACxB,UAAU,QAAQ;AAAA,QACpB,CAAC;AAAA,QACD,SAAS;AAAA,UACP,CAAC,QAAQ,YAAY,GAAG,cAAc;AAAA,QACxC;AAAA,QACA,QAAQ;AAAA,MACV;AAAA,IACF;AAEA,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,IACF,EAAE,2BAA2B;AAE7B,UAAM,kCACJ,MAAM,4BAA4B,KAAK;AAGzC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,QACE,iBAAiB,6BACjB,iBAAiBC,kBACjB;AACA,YAAM;AAAA,IACR;AACA,UAAM,IAAI;AAAA,MACR,oDAAoD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IAC5G;AAAA,EACF;AACF;;;AExFA;AAAA,EAIE,wCAAAC;AAAA,OACK;","names":["ValidationError","z","ValidationError","createOpenid4vpAuthorizationResponse"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/io-wallet-oid4vp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"@openid4vc/utils": "0.3.0-alpha-20250714110838",
|
|
31
31
|
"@openid4vc/openid4vp": "0.3.0-alpha-20250714110838",
|
|
32
32
|
"zod": "^3.24.2",
|
|
33
|
+
"@pagopa/io-wallet-utils": "",
|
|
33
34
|
"@pagopa/io-wallet-oid-federation": ""
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|