hono 4.10.5 → 4.10.6
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/adapter/aws-lambda/handler.js +63 -2
- package/dist/cjs/adapter/aws-lambda/handler.js +64 -2
- package/dist/cjs/middleware/bearer-auth/index.js +8 -7
- package/dist/middleware/bearer-auth/index.js +8 -7
- package/dist/types/adapter/aws-lambda/handler.d.ts +27 -7
- package/dist/types/adapter/aws-lambda/types.d.ts +19 -0
- package/dist/types/middleware/bearer-auth/index.d.ts +34 -3
- package/dist/types/middleware/secure-headers/secure-headers.d.ts +2 -0
- package/package.json +1 -1
|
@@ -73,9 +73,25 @@ var handle = (app, { isContentTypeBinary } = { isContentTypeBinary: void 0 }) =>
|
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
var EventProcessor = class {
|
|
76
|
+
getHeaderValue(headers, key) {
|
|
77
|
+
const value = headers ? Array.isArray(headers[key]) ? headers[key][0] : headers[key] : void 0;
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
getDomainName(event) {
|
|
81
|
+
if (event.requestContext && "domainName" in event.requestContext) {
|
|
82
|
+
return event.requestContext.domainName;
|
|
83
|
+
}
|
|
84
|
+
const hostFromHeaders = this.getHeaderValue(event.headers, "host");
|
|
85
|
+
if (hostFromHeaders) {
|
|
86
|
+
return hostFromHeaders;
|
|
87
|
+
}
|
|
88
|
+
const multiValueHeaders = "multiValueHeaders" in event ? event.multiValueHeaders : {};
|
|
89
|
+
const hostFromMultiValueHeaders = this.getHeaderValue(multiValueHeaders, "host");
|
|
90
|
+
return hostFromMultiValueHeaders;
|
|
91
|
+
}
|
|
76
92
|
createRequest(event) {
|
|
77
93
|
const queryString = this.getQueryString(event);
|
|
78
|
-
const domainName =
|
|
94
|
+
const domainName = this.getDomainName(event);
|
|
79
95
|
const path = this.getPath(event);
|
|
80
96
|
const urlPath = `https://${domainName}${path}`;
|
|
81
97
|
const url = queryString ? `${urlPath}?${queryString}` : urlPath;
|
|
@@ -103,7 +119,7 @@ var EventProcessor = class {
|
|
|
103
119
|
body,
|
|
104
120
|
statusCode: res.status,
|
|
105
121
|
isBase64Encoded,
|
|
106
|
-
...event.multiValueHeaders ? {
|
|
122
|
+
..."multiValueHeaders" in event && event.multiValueHeaders ? {
|
|
107
123
|
multiValueHeaders: {}
|
|
108
124
|
} : {
|
|
109
125
|
headers: {}
|
|
@@ -263,6 +279,41 @@ var ALBProcessor = class extends EventProcessor {
|
|
|
263
279
|
}
|
|
264
280
|
};
|
|
265
281
|
var albProcessor = new ALBProcessor();
|
|
282
|
+
var LatticeV2Processor = class extends EventProcessor {
|
|
283
|
+
getPath(event) {
|
|
284
|
+
return event.path;
|
|
285
|
+
}
|
|
286
|
+
getMethod(event) {
|
|
287
|
+
return event.method;
|
|
288
|
+
}
|
|
289
|
+
getQueryString() {
|
|
290
|
+
return "";
|
|
291
|
+
}
|
|
292
|
+
getHeaders(event) {
|
|
293
|
+
const headers = new Headers();
|
|
294
|
+
if (event.headers) {
|
|
295
|
+
for (const [k, values] of Object.entries(event.headers)) {
|
|
296
|
+
if (values) {
|
|
297
|
+
const foundK = headers.get(k);
|
|
298
|
+
values.forEach((v) => {
|
|
299
|
+
const sanitizedValue = sanitizeHeaderValue(v);
|
|
300
|
+
return (!foundK || !foundK.includes(sanitizedValue)) && headers.append(k, sanitizedValue);
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return headers;
|
|
306
|
+
}
|
|
307
|
+
getCookies() {
|
|
308
|
+
}
|
|
309
|
+
setCookiesToResult(result, cookies) {
|
|
310
|
+
result.headers = {
|
|
311
|
+
...result.headers,
|
|
312
|
+
"set-cookie": cookies.join(", ")
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
var latticeV2Processor = new LatticeV2Processor();
|
|
266
317
|
var getProcessor = (event) => {
|
|
267
318
|
if (isProxyEventALB(event)) {
|
|
268
319
|
return albProcessor;
|
|
@@ -270,6 +321,9 @@ var getProcessor = (event) => {
|
|
|
270
321
|
if (isProxyEventV2(event)) {
|
|
271
322
|
return v2Processor;
|
|
272
323
|
}
|
|
324
|
+
if (isLatticeEventV2(event)) {
|
|
325
|
+
return latticeV2Processor;
|
|
326
|
+
}
|
|
273
327
|
return v1Processor;
|
|
274
328
|
};
|
|
275
329
|
var isProxyEventALB = (event) => {
|
|
@@ -281,6 +335,12 @@ var isProxyEventALB = (event) => {
|
|
|
281
335
|
var isProxyEventV2 = (event) => {
|
|
282
336
|
return Object.hasOwn(event, "rawPath");
|
|
283
337
|
};
|
|
338
|
+
var isLatticeEventV2 = (event) => {
|
|
339
|
+
if (event.requestContext) {
|
|
340
|
+
return Object.hasOwn(event.requestContext, "serviceArn");
|
|
341
|
+
}
|
|
342
|
+
return false;
|
|
343
|
+
};
|
|
284
344
|
var defaultIsContentTypeBinary = (contentType) => {
|
|
285
345
|
return !/^text\/(?:plain|html|css|javascript|csv)|(?:\/|\+)(?:json|xml)\s*(?:;|$)/.test(
|
|
286
346
|
contentType
|
|
@@ -297,6 +357,7 @@ export {
|
|
|
297
357
|
EventProcessor,
|
|
298
358
|
EventV1Processor,
|
|
299
359
|
EventV2Processor,
|
|
360
|
+
LatticeV2Processor,
|
|
300
361
|
defaultIsContentTypeBinary,
|
|
301
362
|
getProcessor,
|
|
302
363
|
handle,
|
|
@@ -22,6 +22,7 @@ __export(handler_exports, {
|
|
|
22
22
|
EventProcessor: () => EventProcessor,
|
|
23
23
|
EventV1Processor: () => EventV1Processor,
|
|
24
24
|
EventV2Processor: () => EventV2Processor,
|
|
25
|
+
LatticeV2Processor: () => LatticeV2Processor,
|
|
25
26
|
defaultIsContentTypeBinary: () => defaultIsContentTypeBinary,
|
|
26
27
|
getProcessor: () => getProcessor,
|
|
27
28
|
handle: () => handle,
|
|
@@ -103,9 +104,25 @@ const handle = (app, { isContentTypeBinary } = { isContentTypeBinary: void 0 })
|
|
|
103
104
|
};
|
|
104
105
|
};
|
|
105
106
|
class EventProcessor {
|
|
107
|
+
getHeaderValue(headers, key) {
|
|
108
|
+
const value = headers ? Array.isArray(headers[key]) ? headers[key][0] : headers[key] : void 0;
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
getDomainName(event) {
|
|
112
|
+
if (event.requestContext && "domainName" in event.requestContext) {
|
|
113
|
+
return event.requestContext.domainName;
|
|
114
|
+
}
|
|
115
|
+
const hostFromHeaders = this.getHeaderValue(event.headers, "host");
|
|
116
|
+
if (hostFromHeaders) {
|
|
117
|
+
return hostFromHeaders;
|
|
118
|
+
}
|
|
119
|
+
const multiValueHeaders = "multiValueHeaders" in event ? event.multiValueHeaders : {};
|
|
120
|
+
const hostFromMultiValueHeaders = this.getHeaderValue(multiValueHeaders, "host");
|
|
121
|
+
return hostFromMultiValueHeaders;
|
|
122
|
+
}
|
|
106
123
|
createRequest(event) {
|
|
107
124
|
const queryString = this.getQueryString(event);
|
|
108
|
-
const domainName =
|
|
125
|
+
const domainName = this.getDomainName(event);
|
|
109
126
|
const path = this.getPath(event);
|
|
110
127
|
const urlPath = `https://${domainName}${path}`;
|
|
111
128
|
const url = queryString ? `${urlPath}?${queryString}` : urlPath;
|
|
@@ -133,7 +150,7 @@ class EventProcessor {
|
|
|
133
150
|
body,
|
|
134
151
|
statusCode: res.status,
|
|
135
152
|
isBase64Encoded,
|
|
136
|
-
...event.multiValueHeaders ? {
|
|
153
|
+
..."multiValueHeaders" in event && event.multiValueHeaders ? {
|
|
137
154
|
multiValueHeaders: {}
|
|
138
155
|
} : {
|
|
139
156
|
headers: {}
|
|
@@ -293,6 +310,41 @@ class ALBProcessor extends EventProcessor {
|
|
|
293
310
|
}
|
|
294
311
|
}
|
|
295
312
|
const albProcessor = new ALBProcessor();
|
|
313
|
+
class LatticeV2Processor extends EventProcessor {
|
|
314
|
+
getPath(event) {
|
|
315
|
+
return event.path;
|
|
316
|
+
}
|
|
317
|
+
getMethod(event) {
|
|
318
|
+
return event.method;
|
|
319
|
+
}
|
|
320
|
+
getQueryString() {
|
|
321
|
+
return "";
|
|
322
|
+
}
|
|
323
|
+
getHeaders(event) {
|
|
324
|
+
const headers = new Headers();
|
|
325
|
+
if (event.headers) {
|
|
326
|
+
for (const [k, values] of Object.entries(event.headers)) {
|
|
327
|
+
if (values) {
|
|
328
|
+
const foundK = headers.get(k);
|
|
329
|
+
values.forEach((v) => {
|
|
330
|
+
const sanitizedValue = sanitizeHeaderValue(v);
|
|
331
|
+
return (!foundK || !foundK.includes(sanitizedValue)) && headers.append(k, sanitizedValue);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return headers;
|
|
337
|
+
}
|
|
338
|
+
getCookies() {
|
|
339
|
+
}
|
|
340
|
+
setCookiesToResult(result, cookies) {
|
|
341
|
+
result.headers = {
|
|
342
|
+
...result.headers,
|
|
343
|
+
"set-cookie": cookies.join(", ")
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
const latticeV2Processor = new LatticeV2Processor();
|
|
296
348
|
const getProcessor = (event) => {
|
|
297
349
|
if (isProxyEventALB(event)) {
|
|
298
350
|
return albProcessor;
|
|
@@ -300,6 +352,9 @@ const getProcessor = (event) => {
|
|
|
300
352
|
if (isProxyEventV2(event)) {
|
|
301
353
|
return v2Processor;
|
|
302
354
|
}
|
|
355
|
+
if (isLatticeEventV2(event)) {
|
|
356
|
+
return latticeV2Processor;
|
|
357
|
+
}
|
|
303
358
|
return v1Processor;
|
|
304
359
|
};
|
|
305
360
|
const isProxyEventALB = (event) => {
|
|
@@ -311,6 +366,12 @@ const isProxyEventALB = (event) => {
|
|
|
311
366
|
const isProxyEventV2 = (event) => {
|
|
312
367
|
return Object.hasOwn(event, "rawPath");
|
|
313
368
|
};
|
|
369
|
+
const isLatticeEventV2 = (event) => {
|
|
370
|
+
if (event.requestContext) {
|
|
371
|
+
return Object.hasOwn(event.requestContext, "serviceArn");
|
|
372
|
+
}
|
|
373
|
+
return false;
|
|
374
|
+
};
|
|
314
375
|
const defaultIsContentTypeBinary = (contentType) => {
|
|
315
376
|
return !/^text\/(?:plain|html|css|javascript|csv)|(?:\/|\+)(?:json|xml)\s*(?:;|$)/.test(
|
|
316
377
|
contentType
|
|
@@ -328,6 +389,7 @@ const isContentEncodingBinary = (contentEncoding) => {
|
|
|
328
389
|
EventProcessor,
|
|
329
390
|
EventV1Processor,
|
|
330
391
|
EventV2Processor,
|
|
392
|
+
LatticeV2Processor,
|
|
331
393
|
defaultIsContentTypeBinary,
|
|
332
394
|
getProcessor,
|
|
333
395
|
handle,
|
|
@@ -41,8 +41,9 @@ const bearerAuth = (options) => {
|
|
|
41
41
|
const regexp = new RegExp(`^${prefixRegexStr}(${TOKEN_STRINGS}) *$`);
|
|
42
42
|
const wwwAuthenticatePrefix = options.prefix === "" ? "" : `${options.prefix} `;
|
|
43
43
|
const throwHTTPException = async (c, status, wwwAuthenticateHeader, messageOption) => {
|
|
44
|
+
const wwwAuthenticateHeaderValue = typeof wwwAuthenticateHeader === "function" ? await wwwAuthenticateHeader(c) : wwwAuthenticateHeader;
|
|
44
45
|
const headers = {
|
|
45
|
-
"WWW-Authenticate":
|
|
46
|
+
"WWW-Authenticate": typeof wwwAuthenticateHeaderValue === "string" ? wwwAuthenticateHeaderValue : `${wwwAuthenticatePrefix}${Object.entries(wwwAuthenticateHeaderValue).map(([key, value]) => `${key}="${value}"`).join(",")}`
|
|
46
47
|
};
|
|
47
48
|
const responseMessage = typeof messageOption === "function" ? await messageOption(c) : messageOption;
|
|
48
49
|
const res = typeof responseMessage === "string" ? new Response(responseMessage, { status, headers }) : new Response(JSON.stringify(responseMessage), {
|
|
@@ -60,8 +61,8 @@ const bearerAuth = (options) => {
|
|
|
60
61
|
await throwHTTPException(
|
|
61
62
|
c,
|
|
62
63
|
401,
|
|
63
|
-
`${wwwAuthenticatePrefix}realm="${realm}"`,
|
|
64
|
-
options.noAuthenticationHeaderMessage || "Unauthorized"
|
|
64
|
+
options.noAuthenticationHeader?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}realm="${realm}"`,
|
|
65
|
+
options.noAuthenticationHeader?.message || options.noAuthenticationHeaderMessage || "Unauthorized"
|
|
65
66
|
);
|
|
66
67
|
} else {
|
|
67
68
|
const match = regexp.exec(headerToken);
|
|
@@ -69,8 +70,8 @@ const bearerAuth = (options) => {
|
|
|
69
70
|
await throwHTTPException(
|
|
70
71
|
c,
|
|
71
72
|
400,
|
|
72
|
-
`${wwwAuthenticatePrefix}error="invalid_request"`,
|
|
73
|
-
options.invalidAuthenticationHeaderMessage || "Bad Request"
|
|
73
|
+
options.invalidAuthenticationHeader?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}error="invalid_request"`,
|
|
74
|
+
options.invalidAuthenticationHeader?.message || options.invalidAuthenticationHeaderMessage || "Bad Request"
|
|
74
75
|
);
|
|
75
76
|
} else {
|
|
76
77
|
let equal = false;
|
|
@@ -90,8 +91,8 @@ const bearerAuth = (options) => {
|
|
|
90
91
|
await throwHTTPException(
|
|
91
92
|
c,
|
|
92
93
|
401,
|
|
93
|
-
`${wwwAuthenticatePrefix}error="invalid_token"`,
|
|
94
|
-
options.invalidTokenMessage || "Unauthorized"
|
|
94
|
+
options.invalidToken?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}error="invalid_token"`,
|
|
95
|
+
options.invalidToken?.message || options.invalidTokenMessage || "Unauthorized"
|
|
95
96
|
);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
@@ -19,8 +19,9 @@ var bearerAuth = (options) => {
|
|
|
19
19
|
const regexp = new RegExp(`^${prefixRegexStr}(${TOKEN_STRINGS}) *$`);
|
|
20
20
|
const wwwAuthenticatePrefix = options.prefix === "" ? "" : `${options.prefix} `;
|
|
21
21
|
const throwHTTPException = async (c, status, wwwAuthenticateHeader, messageOption) => {
|
|
22
|
+
const wwwAuthenticateHeaderValue = typeof wwwAuthenticateHeader === "function" ? await wwwAuthenticateHeader(c) : wwwAuthenticateHeader;
|
|
22
23
|
const headers = {
|
|
23
|
-
"WWW-Authenticate":
|
|
24
|
+
"WWW-Authenticate": typeof wwwAuthenticateHeaderValue === "string" ? wwwAuthenticateHeaderValue : `${wwwAuthenticatePrefix}${Object.entries(wwwAuthenticateHeaderValue).map(([key, value]) => `${key}="${value}"`).join(",")}`
|
|
24
25
|
};
|
|
25
26
|
const responseMessage = typeof messageOption === "function" ? await messageOption(c) : messageOption;
|
|
26
27
|
const res = typeof responseMessage === "string" ? new Response(responseMessage, { status, headers }) : new Response(JSON.stringify(responseMessage), {
|
|
@@ -38,8 +39,8 @@ var bearerAuth = (options) => {
|
|
|
38
39
|
await throwHTTPException(
|
|
39
40
|
c,
|
|
40
41
|
401,
|
|
41
|
-
`${wwwAuthenticatePrefix}realm="${realm}"`,
|
|
42
|
-
options.noAuthenticationHeaderMessage || "Unauthorized"
|
|
42
|
+
options.noAuthenticationHeader?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}realm="${realm}"`,
|
|
43
|
+
options.noAuthenticationHeader?.message || options.noAuthenticationHeaderMessage || "Unauthorized"
|
|
43
44
|
);
|
|
44
45
|
} else {
|
|
45
46
|
const match = regexp.exec(headerToken);
|
|
@@ -47,8 +48,8 @@ var bearerAuth = (options) => {
|
|
|
47
48
|
await throwHTTPException(
|
|
48
49
|
c,
|
|
49
50
|
400,
|
|
50
|
-
`${wwwAuthenticatePrefix}error="invalid_request"`,
|
|
51
|
-
options.invalidAuthenticationHeaderMessage || "Bad Request"
|
|
51
|
+
options.invalidAuthenticationHeader?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}error="invalid_request"`,
|
|
52
|
+
options.invalidAuthenticationHeader?.message || options.invalidAuthenticationHeaderMessage || "Bad Request"
|
|
52
53
|
);
|
|
53
54
|
} else {
|
|
54
55
|
let equal = false;
|
|
@@ -68,8 +69,8 @@ var bearerAuth = (options) => {
|
|
|
68
69
|
await throwHTTPException(
|
|
69
70
|
c,
|
|
70
71
|
401,
|
|
71
|
-
`${wwwAuthenticatePrefix}error="invalid_token"`,
|
|
72
|
-
options.invalidTokenMessage || "Unauthorized"
|
|
72
|
+
options.invalidToken?.wwwAuthenticateHeader || `${wwwAuthenticatePrefix}error="invalid_token"`,
|
|
73
|
+
options.invalidToken?.message || options.invalidTokenMessage || "Unauthorized"
|
|
73
74
|
);
|
|
74
75
|
}
|
|
75
76
|
}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import type { Hono } from '../../hono';
|
|
2
2
|
import type { Env, Schema } from '../../types';
|
|
3
|
-
import type { ALBRequestContext, ApiGatewayRequestContext, ApiGatewayRequestContextV2, Handler, LambdaContext } from './types';
|
|
4
|
-
export type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent;
|
|
3
|
+
import type { ALBRequestContext, ApiGatewayRequestContext, ApiGatewayRequestContextV2, Handler, LambdaContext, LatticeRequestContextV2 } from './types';
|
|
4
|
+
export type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent | LatticeProxyEventV2;
|
|
5
|
+
export interface LatticeProxyEventV2 {
|
|
6
|
+
version: string;
|
|
7
|
+
path: string;
|
|
8
|
+
method: string;
|
|
9
|
+
headers: Record<string, string[] | undefined>;
|
|
10
|
+
queryStringParameters: Record<string, string[] | undefined>;
|
|
11
|
+
body: string | null;
|
|
12
|
+
isBase64Encoded: boolean;
|
|
13
|
+
requestContext: LatticeRequestContextV2;
|
|
14
|
+
}
|
|
5
15
|
export interface APIGatewayProxyEventV2 {
|
|
6
16
|
version: string;
|
|
7
17
|
routeKey: string;
|
|
@@ -124,6 +134,8 @@ export declare abstract class EventProcessor<E extends LambdaEvent> {
|
|
|
124
134
|
protected abstract getHeaders(event: E): Headers;
|
|
125
135
|
protected abstract getCookies(event: E, headers: Headers): void;
|
|
126
136
|
protected abstract setCookiesToResult(result: APIGatewayProxyResult, cookies: string[]): void;
|
|
137
|
+
protected getHeaderValue(headers: E['headers'], key: string): string | undefined;
|
|
138
|
+
protected getDomainName(event: E): string | undefined;
|
|
127
139
|
createRequest(event: E): Request;
|
|
128
140
|
createResult(event: E, res: Response, options: Pick<HandleOptions, 'isContentTypeBinary'>): Promise<APIGatewayProxyResult>;
|
|
129
141
|
setCookies(event: E, res: Response, result: APIGatewayProxyResult): void;
|
|
@@ -136,11 +148,11 @@ export declare class EventV2Processor extends EventProcessor<APIGatewayProxyEven
|
|
|
136
148
|
protected setCookiesToResult(result: APIGatewayProxyResult, cookies: string[]): void;
|
|
137
149
|
protected getHeaders(event: APIGatewayProxyEventV2): Headers;
|
|
138
150
|
}
|
|
139
|
-
export declare class EventV1Processor extends EventProcessor<
|
|
140
|
-
protected getPath(event:
|
|
141
|
-
protected getMethod(event:
|
|
142
|
-
protected getQueryString(event:
|
|
143
|
-
protected getCookies(event:
|
|
151
|
+
export declare class EventV1Processor extends EventProcessor<APIGatewayProxyEvent> {
|
|
152
|
+
protected getPath(event: APIGatewayProxyEvent): string;
|
|
153
|
+
protected getMethod(event: APIGatewayProxyEvent): string;
|
|
154
|
+
protected getQueryString(event: APIGatewayProxyEvent): string;
|
|
155
|
+
protected getCookies(event: APIGatewayProxyEvent, headers: Headers): void;
|
|
144
156
|
protected getHeaders(event: APIGatewayProxyEvent): Headers;
|
|
145
157
|
protected setCookiesToResult(result: APIGatewayProxyResult, cookies: string[]): void;
|
|
146
158
|
}
|
|
@@ -152,6 +164,14 @@ export declare class ALBProcessor extends EventProcessor<ALBProxyEvent> {
|
|
|
152
164
|
protected getCookies(event: ALBProxyEvent, headers: Headers): void;
|
|
153
165
|
protected setCookiesToResult(result: APIGatewayProxyResult, cookies: string[]): void;
|
|
154
166
|
}
|
|
167
|
+
export declare class LatticeV2Processor extends EventProcessor<LatticeProxyEventV2> {
|
|
168
|
+
protected getPath(event: LatticeProxyEventV2): string;
|
|
169
|
+
protected getMethod(event: LatticeProxyEventV2): string;
|
|
170
|
+
protected getQueryString(): string;
|
|
171
|
+
protected getHeaders(event: LatticeProxyEventV2): Headers;
|
|
172
|
+
protected getCookies(): void;
|
|
173
|
+
protected setCookiesToResult(result: APIGatewayProxyResult, cookies: string[]): void;
|
|
174
|
+
}
|
|
155
175
|
export declare const getProcessor: (event: LambdaEvent) => EventProcessor<LambdaEvent>;
|
|
156
176
|
/**
|
|
157
177
|
* Check if the given content type is binary.
|
|
@@ -122,4 +122,23 @@ export interface ALBRequestContext {
|
|
|
122
122
|
targetGroupArn: string;
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
+
export interface LatticeRequestContextV2 {
|
|
126
|
+
serviceNetworkArn: string;
|
|
127
|
+
serviceArn: string;
|
|
128
|
+
targetGroupArn: string;
|
|
129
|
+
region: string;
|
|
130
|
+
timeEpoch: string;
|
|
131
|
+
identity: {
|
|
132
|
+
sourceVpcArn?: string;
|
|
133
|
+
type?: string;
|
|
134
|
+
principal?: string;
|
|
135
|
+
principalOrgID?: string;
|
|
136
|
+
sessionName?: string;
|
|
137
|
+
x509IssuerOu?: string;
|
|
138
|
+
x509SanDns?: string;
|
|
139
|
+
x509SanNameCn?: string;
|
|
140
|
+
x509SanUri?: string;
|
|
141
|
+
x509SubjectCn?: string;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
125
144
|
export {};
|
|
@@ -5,24 +5,52 @@
|
|
|
5
5
|
import type { Context } from '../../context';
|
|
6
6
|
import type { MiddlewareHandler } from '../../types';
|
|
7
7
|
type MessageFunction = (c: Context) => string | object | Promise<string | object>;
|
|
8
|
+
type CustomizedErrorResponseOptions = {
|
|
9
|
+
wwwAuthenticateHeader?: string | object | MessageFunction;
|
|
10
|
+
message?: string | object | MessageFunction;
|
|
11
|
+
};
|
|
8
12
|
type BearerAuthOptions = {
|
|
9
13
|
token: string | string[];
|
|
10
14
|
realm?: string;
|
|
11
15
|
prefix?: string;
|
|
12
16
|
headerName?: string;
|
|
13
17
|
hashFunction?: Function;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use noAuthenticationHeader.message instead
|
|
20
|
+
*/
|
|
14
21
|
noAuthenticationHeaderMessage?: string | object | MessageFunction;
|
|
22
|
+
noAuthenticationHeader?: CustomizedErrorResponseOptions;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use invalidAuthenticationHeader.message instead
|
|
25
|
+
*/
|
|
15
26
|
invalidAuthenticationHeaderMessage?: string | object | MessageFunction;
|
|
27
|
+
invalidAuthenticationHeader?: CustomizedErrorResponseOptions;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use invalidToken.message instead
|
|
30
|
+
*/
|
|
16
31
|
invalidTokenMessage?: string | object | MessageFunction;
|
|
32
|
+
invalidToken?: CustomizedErrorResponseOptions;
|
|
17
33
|
} | {
|
|
18
34
|
realm?: string;
|
|
19
35
|
prefix?: string;
|
|
20
36
|
headerName?: string;
|
|
21
37
|
verifyToken: (token: string, c: Context) => boolean | Promise<boolean>;
|
|
22
38
|
hashFunction?: Function;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use noAuthenticationHeader.message instead
|
|
41
|
+
*/
|
|
23
42
|
noAuthenticationHeaderMessage?: string | object | MessageFunction;
|
|
43
|
+
noAuthenticationHeader?: CustomizedErrorResponseOptions;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use invalidAuthenticationHeader.message instead
|
|
46
|
+
*/
|
|
24
47
|
invalidAuthenticationHeaderMessage?: string | object | MessageFunction;
|
|
48
|
+
invalidAuthenticationHeader?: CustomizedErrorResponseOptions;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Use invalidToken.message instead
|
|
51
|
+
*/
|
|
25
52
|
invalidTokenMessage?: string | object | MessageFunction;
|
|
53
|
+
invalidToken?: CustomizedErrorResponseOptions;
|
|
26
54
|
};
|
|
27
55
|
/**
|
|
28
56
|
* Bearer Auth Middleware for Hono.
|
|
@@ -36,9 +64,12 @@ type BearerAuthOptions = {
|
|
|
36
64
|
* @param {string} [options.prefix="Bearer"] - The prefix (or known as `schema`) for the Authorization header value. If set to the empty string, no prefix is expected.
|
|
37
65
|
* @param {string} [options.headerName=Authorization] - The header name.
|
|
38
66
|
* @param {Function} [options.hashFunction] - A function to handle hashing for safe comparison of authentication tokens.
|
|
39
|
-
* @param {string | object | MessageFunction} [options.
|
|
40
|
-
* @param {string | object | MessageFunction} [options.
|
|
41
|
-
* @param {string | object | MessageFunction} [options.
|
|
67
|
+
* @param {string | object | MessageFunction} [options.noAuthenticationHeader.message="Unauthorized"] - The no authentication header message.
|
|
68
|
+
* @param {string | object | MessageFunction} [options.noAuthenticationHeader.wwwAuthenticateHeader="Bearer realm=\"\""] - The response header value for the WWW-Authenticate header when no authentication header is provided.
|
|
69
|
+
* @param {string | object | MessageFunction} [options.invalidAuthenticationHeader.message="Bad Request"] - The invalid authentication header message.
|
|
70
|
+
* @param {string | object | MessageFunction} [options.invalidAuthenticationHeader.wwwAuthenticateHeader="Bearer error=\"invalid_request\""] - The response header value for the WWW-Authenticate header when authentication header is invalid.
|
|
71
|
+
* @param {string | object | MessageFunction} [options.invalidToken.message="Unauthorized"] - The invalid token message.
|
|
72
|
+
* @param {string | object | MessageFunction} [options.invalidToken.wwwAuthenticateHeader="Bearer error=\"invalid_token\""] - The response header value for the WWW-Authenticate header when token is invalid.
|
|
42
73
|
* @returns {MiddlewareHandler} The middleware handler function.
|
|
43
74
|
* @throws {Error} If neither "token" nor "verifyToken" options are provided.
|
|
44
75
|
* @throws {HTTPException} If authentication fails, with 401 status code for missing or invalid token, or 400 status code for invalid request.
|
|
@@ -33,6 +33,8 @@ interface ContentSecurityPolicyOptions {
|
|
|
33
33
|
styleSrcElem?: ContentSecurityPolicyOptionValue;
|
|
34
34
|
upgradeInsecureRequests?: ContentSecurityPolicyOptionValue;
|
|
35
35
|
workerSrc?: ContentSecurityPolicyOptionValue;
|
|
36
|
+
requireTrustedTypesFor?: ContentSecurityPolicyOptionValue;
|
|
37
|
+
trustedTypes?: ContentSecurityPolicyOptionValue;
|
|
36
38
|
}
|
|
37
39
|
interface ReportToOptions {
|
|
38
40
|
group: string;
|