sst-http 1.3.2 → 1.3.3-beta.2
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 +87 -28
- package/dist/bus/index.cjs +185 -0
- package/dist/bus/index.d.cts +7 -0
- package/dist/bus/index.d.ts +7 -0
- package/dist/bus/index.js +9 -0
- package/dist/{chunk-5MOJ3SW6.js → chunk-5OUNKYO5.js} +1 -1
- package/dist/chunk-LLR3DQ65.js +140 -0
- package/dist/chunk-SENBWWVV.js +499 -0
- package/dist/chunk-YMGEGOSD.js +117 -0
- package/dist/cli.cjs +49 -13
- package/dist/cli.js +49 -13
- package/dist/handler-DaM4Racx.d.cts +4 -0
- package/dist/handler-DaM4Racx.d.ts +4 -0
- package/dist/http/index.cjs +644 -0
- package/dist/http/index.d.cts +51 -0
- package/dist/http/index.d.ts +51 -0
- package/dist/http/index.js +53 -0
- package/dist/index.cjs +204 -14
- package/dist/index.d.cts +6 -45
- package/dist/index.d.ts +6 -45
- package/dist/index.js +33 -517
- package/dist/infra.cjs +273 -126
- package/dist/infra.d.cts +35 -18
- package/dist/infra.d.ts +35 -18
- package/dist/infra.js +268 -121
- package/dist/{types-BF3w-wTx.d.cts → types-w1A7o_rd.d.cts} +5 -1
- package/dist/{types-BF3w-wTx.d.ts → types-w1A7o_rd.d.ts} +5 -1
- package/package.json +16 -5
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyResultV2 } from 'aws-lambda';
|
|
2
|
+
import { R as ResponseLike, F as FirebaseAuthOptions, e as RouteOptions } from '../types-w1A7o_rd.js';
|
|
3
|
+
export { c as FirebaseAuthMetadata, d as FirebaseClaims, H as Handler, a as HandlerContext, b as HttpMethod } from '../types-w1A7o_rd.js';
|
|
4
|
+
import { ZodTypeAny } from 'zod/v4';
|
|
5
|
+
import { L as LegacyDecorator, a as LegacyParameterDecorator } from '../handler-DaM4Racx.js';
|
|
6
|
+
|
|
7
|
+
declare class HttpError extends Error {
|
|
8
|
+
readonly statusCode: number;
|
|
9
|
+
readonly headers?: Record<string, string>;
|
|
10
|
+
readonly details?: unknown;
|
|
11
|
+
constructor(statusCode: number, message: string, options?: {
|
|
12
|
+
cause?: unknown;
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
details?: unknown;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
declare function json(status: number, data: unknown, headers?: Record<string, string>): ResponseLike;
|
|
18
|
+
declare function text(status: number, body: string, headers?: Record<string, string>): ResponseLike;
|
|
19
|
+
declare function noContent(headers?: Record<string, string>): ResponseLike;
|
|
20
|
+
type EventBridgeEvent = {
|
|
21
|
+
"detail-type"?: string;
|
|
22
|
+
detailType?: string;
|
|
23
|
+
detail?: unknown;
|
|
24
|
+
eventBusName?: string;
|
|
25
|
+
};
|
|
26
|
+
type HttpLambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
27
|
+
type LambdaEvent = HttpLambdaEvent | EventBridgeEvent;
|
|
28
|
+
type LambdaResult = APIGatewayProxyResult | APIGatewayProxyResultV2;
|
|
29
|
+
declare function createHandler(): (event: LambdaEvent, lambdaContext: unknown) => Promise<LambdaResult>;
|
|
30
|
+
declare function handleError(error: unknown, preferV2: boolean): LambdaResult;
|
|
31
|
+
|
|
32
|
+
declare const Get: (path?: string) => LegacyDecorator;
|
|
33
|
+
declare const Post: (path?: string) => LegacyDecorator;
|
|
34
|
+
declare const Put: (path?: string) => LegacyDecorator;
|
|
35
|
+
declare const Patch: (path?: string) => LegacyDecorator;
|
|
36
|
+
declare const Delete: (path?: string) => LegacyDecorator;
|
|
37
|
+
declare const Head: (path?: string) => LegacyDecorator;
|
|
38
|
+
declare const Options: (path?: string) => LegacyDecorator;
|
|
39
|
+
declare function FirebaseAuth(options?: FirebaseAuthOptions): LegacyDecorator;
|
|
40
|
+
declare function Auth(): LegacyParameterDecorator;
|
|
41
|
+
declare function Body(schema?: ZodTypeAny): LegacyParameterDecorator;
|
|
42
|
+
declare function Query(name?: string): LegacyParameterDecorator;
|
|
43
|
+
declare function Param(name?: string): LegacyParameterDecorator;
|
|
44
|
+
declare function Headers(): LegacyParameterDecorator;
|
|
45
|
+
declare function Header(name: string): LegacyParameterDecorator;
|
|
46
|
+
declare function Req(): LegacyParameterDecorator;
|
|
47
|
+
declare function Res(): LegacyParameterDecorator;
|
|
48
|
+
|
|
49
|
+
declare function configureRoutes(next?: RouteOptions): void;
|
|
50
|
+
|
|
51
|
+
export { Auth, Body, Delete, FirebaseAuth, FirebaseAuthOptions, Get, Head, Header, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, ResponseLike, RouteOptions, configureRoutes, createHandler, handleError, json, noContent, text };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Auth,
|
|
3
|
+
Body,
|
|
4
|
+
Delete,
|
|
5
|
+
FirebaseAuth,
|
|
6
|
+
Get,
|
|
7
|
+
Head,
|
|
8
|
+
Header,
|
|
9
|
+
Headers,
|
|
10
|
+
HttpError,
|
|
11
|
+
Options,
|
|
12
|
+
Param,
|
|
13
|
+
Patch,
|
|
14
|
+
Post,
|
|
15
|
+
Put,
|
|
16
|
+
Query,
|
|
17
|
+
Req,
|
|
18
|
+
Res,
|
|
19
|
+
createHandler,
|
|
20
|
+
handleError,
|
|
21
|
+
json,
|
|
22
|
+
noContent,
|
|
23
|
+
text
|
|
24
|
+
} from "../chunk-SENBWWVV.js";
|
|
25
|
+
import "../chunk-5OUNKYO5.js";
|
|
26
|
+
import {
|
|
27
|
+
configureRoutes
|
|
28
|
+
} from "../chunk-YMGEGOSD.js";
|
|
29
|
+
export {
|
|
30
|
+
Auth,
|
|
31
|
+
Body,
|
|
32
|
+
Delete,
|
|
33
|
+
FirebaseAuth,
|
|
34
|
+
Get,
|
|
35
|
+
Head,
|
|
36
|
+
Header,
|
|
37
|
+
Headers,
|
|
38
|
+
HttpError,
|
|
39
|
+
Options,
|
|
40
|
+
Param,
|
|
41
|
+
Patch,
|
|
42
|
+
Post,
|
|
43
|
+
Put,
|
|
44
|
+
Query,
|
|
45
|
+
Req,
|
|
46
|
+
Res,
|
|
47
|
+
configureRoutes,
|
|
48
|
+
createHandler,
|
|
49
|
+
handleError,
|
|
50
|
+
json,
|
|
51
|
+
noContent,
|
|
52
|
+
text
|
|
53
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
Header: () => Header,
|
|
30
30
|
Headers: () => Headers,
|
|
31
31
|
HttpError: () => HttpError,
|
|
32
|
+
On: () => On,
|
|
32
33
|
Options: () => Options,
|
|
33
34
|
Param: () => Param,
|
|
34
35
|
Patch: () => Patch,
|
|
@@ -42,13 +43,15 @@ __export(index_exports, {
|
|
|
42
43
|
handleError: () => handleError,
|
|
43
44
|
json: () => json,
|
|
44
45
|
noContent: () => noContent,
|
|
46
|
+
publish: () => publish,
|
|
45
47
|
text: () => text
|
|
46
48
|
});
|
|
47
49
|
module.exports = __toCommonJS(index_exports);
|
|
48
50
|
|
|
49
|
-
// src/registry.ts
|
|
51
|
+
// src/core/registry.ts
|
|
50
52
|
var routeMeta = /* @__PURE__ */ new Map();
|
|
51
53
|
var parameterMeta = /* @__PURE__ */ new Map();
|
|
54
|
+
var eventMeta = /* @__PURE__ */ new Map();
|
|
52
55
|
var options = {
|
|
53
56
|
inferPathFromName: false
|
|
54
57
|
};
|
|
@@ -91,6 +94,12 @@ function registerParameter(target, meta) {
|
|
|
91
94
|
list.sort((a, b) => a.index - b.index);
|
|
92
95
|
parameterMeta.set(handler, list);
|
|
93
96
|
}
|
|
97
|
+
function registerEvent(target, event) {
|
|
98
|
+
const handler = target;
|
|
99
|
+
const list = eventMeta.get(handler) ?? [];
|
|
100
|
+
list.push({ event });
|
|
101
|
+
eventMeta.set(handler, list);
|
|
102
|
+
}
|
|
94
103
|
function getRegisteredRoutes() {
|
|
95
104
|
const routes = [];
|
|
96
105
|
for (const [handler, meta] of routeMeta.entries()) {
|
|
@@ -108,6 +117,18 @@ function getRegisteredRoutes() {
|
|
|
108
117
|
}
|
|
109
118
|
return routes;
|
|
110
119
|
}
|
|
120
|
+
function getRegisteredEvents() {
|
|
121
|
+
const events = [];
|
|
122
|
+
for (const [handler, list] of eventMeta.entries()) {
|
|
123
|
+
for (const entry of list) {
|
|
124
|
+
events.push({
|
|
125
|
+
handler,
|
|
126
|
+
event: entry.event
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return events;
|
|
131
|
+
}
|
|
111
132
|
function inferPath(handler) {
|
|
112
133
|
if (!options.inferPathFromName) {
|
|
113
134
|
return void 0;
|
|
@@ -120,15 +141,15 @@ function inferPath(handler) {
|
|
|
120
141
|
return slug ? `/${slug}` : void 0;
|
|
121
142
|
}
|
|
122
143
|
|
|
123
|
-
// src/router.ts
|
|
144
|
+
// src/http/router.ts
|
|
124
145
|
var import_path_to_regexp = require("path-to-regexp");
|
|
125
146
|
|
|
126
|
-
// src/paths.ts
|
|
147
|
+
// src/http/paths.ts
|
|
127
148
|
function normalizeRouterPath(path) {
|
|
128
149
|
return path.replace(/\{([^/{}]+)\}/g, ":$1");
|
|
129
150
|
}
|
|
130
151
|
|
|
131
|
-
// src/router.ts
|
|
152
|
+
// src/http/router.ts
|
|
132
153
|
var Router = class {
|
|
133
154
|
routes;
|
|
134
155
|
constructor(entries) {
|
|
@@ -170,7 +191,7 @@ function normalizeParams(params) {
|
|
|
170
191
|
return normalized;
|
|
171
192
|
}
|
|
172
193
|
|
|
173
|
-
// src/runtime.ts
|
|
194
|
+
// src/http/runtime.ts
|
|
174
195
|
var HTTP_ERROR_MARKER = Symbol.for("sst-http.HttpError");
|
|
175
196
|
var HttpError = class extends Error {
|
|
176
197
|
statusCode;
|
|
@@ -218,10 +239,19 @@ function noContent(headers = {}) {
|
|
|
218
239
|
function createHandler() {
|
|
219
240
|
const routes = getRegisteredRoutes();
|
|
220
241
|
const router = new Router(routes);
|
|
242
|
+
const eventHandlers = getRegisteredEvents();
|
|
221
243
|
return async (event, lambdaContext) => {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
244
|
+
if (isEventBridgeEvent(event)) {
|
|
245
|
+
await handleEventBridgeEvent(event, eventHandlers, lambdaContext);
|
|
246
|
+
return {
|
|
247
|
+
statusCode: 200,
|
|
248
|
+
body: ""
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const httpEvent = event;
|
|
252
|
+
const method = extractMethod(httpEvent);
|
|
253
|
+
const path = extractPath(httpEvent);
|
|
254
|
+
const preferV2 = isHttpApiEvent(httpEvent);
|
|
225
255
|
if (!method || !path) {
|
|
226
256
|
return formatResponse(text(400, "Invalid request"), preferV2);
|
|
227
257
|
}
|
|
@@ -243,14 +273,14 @@ function createHandler() {
|
|
|
243
273
|
}, preferV2);
|
|
244
274
|
}
|
|
245
275
|
const { entry, params } = match2;
|
|
246
|
-
const headers = normalizeHeaders(
|
|
247
|
-
const query = extractQuery(
|
|
276
|
+
const headers = normalizeHeaders(httpEvent.headers ?? {});
|
|
277
|
+
const query = extractQuery(httpEvent);
|
|
248
278
|
let bodyValue = void 0;
|
|
249
279
|
let bodyParsed = false;
|
|
250
280
|
const requiresJson = entry.parameters.some((p) => p.type === "body");
|
|
251
281
|
const ensureBody = () => {
|
|
252
282
|
if (!bodyParsed) {
|
|
253
|
-
bodyValue = parseBody(
|
|
283
|
+
bodyValue = parseBody(httpEvent, headers, requiresJson);
|
|
254
284
|
bodyParsed = true;
|
|
255
285
|
}
|
|
256
286
|
return bodyValue;
|
|
@@ -261,13 +291,13 @@ function createHandler() {
|
|
|
261
291
|
noContent
|
|
262
292
|
};
|
|
263
293
|
const ctx = {
|
|
264
|
-
event,
|
|
294
|
+
event: httpEvent,
|
|
265
295
|
lambdaContext,
|
|
266
296
|
params,
|
|
267
297
|
query,
|
|
268
298
|
body: void 0,
|
|
269
299
|
headers,
|
|
270
|
-
auth: extractAuthClaims(
|
|
300
|
+
auth: extractAuthClaims(httpEvent, entry),
|
|
271
301
|
response: ctxResponse
|
|
272
302
|
};
|
|
273
303
|
const getBody = (schema) => {
|
|
@@ -296,6 +326,31 @@ function createHandler() {
|
|
|
296
326
|
}
|
|
297
327
|
};
|
|
298
328
|
}
|
|
329
|
+
function isEventBridgeEvent(event) {
|
|
330
|
+
if (!event || typeof event !== "object") {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
const e = event;
|
|
334
|
+
return typeof e["detail-type"] === "string" || typeof e.detailType === "string";
|
|
335
|
+
}
|
|
336
|
+
async function handleEventBridgeEvent(event, handlers, lambdaContext) {
|
|
337
|
+
const eventType = event["detail-type"] ?? event.detailType;
|
|
338
|
+
if (!eventType) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const matches = handlers.filter((entry) => {
|
|
342
|
+
if (entry.event !== eventType) {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
return true;
|
|
346
|
+
});
|
|
347
|
+
if (matches.length === 0) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
await Promise.all(
|
|
351
|
+
matches.map((entry) => Promise.resolve(entry.handler(event.detail, event, lambdaContext)))
|
|
352
|
+
);
|
|
353
|
+
}
|
|
299
354
|
function buildHandlerArguments(entry, ctx, getBody) {
|
|
300
355
|
const maxIndex = entry.parameters.reduce((max, meta) => Math.max(max, meta.index), -1);
|
|
301
356
|
const length = Math.max(entry.handler.length, maxIndex + 1, 1);
|
|
@@ -500,7 +555,7 @@ function isSupportedMethod(value) {
|
|
|
500
555
|
return SUPPORTED_METHODS.has(value);
|
|
501
556
|
}
|
|
502
557
|
|
|
503
|
-
// src/
|
|
558
|
+
// src/core/handler.ts
|
|
504
559
|
function resolveHandler(target, propertyKey, descriptor) {
|
|
505
560
|
if (descriptor?.value && typeof descriptor.value === "function") {
|
|
506
561
|
return descriptor.value;
|
|
@@ -513,6 +568,8 @@ function resolveHandler(target, propertyKey, descriptor) {
|
|
|
513
568
|
}
|
|
514
569
|
throw new Error("Unable to determine decorated function. Ensure decorators are applied to functions.");
|
|
515
570
|
}
|
|
571
|
+
|
|
572
|
+
// src/http/decorators.ts
|
|
516
573
|
function createRouteDecorator(method) {
|
|
517
574
|
return (path) => (target, propertyKey, descriptor) => {
|
|
518
575
|
const handler = resolveHandler(target, propertyKey, descriptor);
|
|
@@ -567,6 +624,137 @@ function Req() {
|
|
|
567
624
|
function Res() {
|
|
568
625
|
return createParameterDecorator("res");
|
|
569
626
|
}
|
|
627
|
+
|
|
628
|
+
// src/bus/decorators.ts
|
|
629
|
+
function On(event) {
|
|
630
|
+
return (target, propertyKey, descriptor) => {
|
|
631
|
+
if (!event) {
|
|
632
|
+
throw new Error("@On() requires an event name.");
|
|
633
|
+
}
|
|
634
|
+
const handler = resolveHandler(target, propertyKey, descriptor);
|
|
635
|
+
registerEvent(handler, event);
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// src/bus/event-bus.ts
|
|
640
|
+
var import_node_crypto = require("crypto");
|
|
641
|
+
var AWS_TARGET = "AWSEvents.PutEvents";
|
|
642
|
+
var AWS_SERVICE = "events";
|
|
643
|
+
var DEFAULT_SOURCE = "sst-http";
|
|
644
|
+
async function publish(event, message) {
|
|
645
|
+
if (!event) {
|
|
646
|
+
throw new Error("publish() requires an event name.");
|
|
647
|
+
}
|
|
648
|
+
const payload = {
|
|
649
|
+
Entries: [
|
|
650
|
+
{
|
|
651
|
+
EventBusName: "default",
|
|
652
|
+
Source: DEFAULT_SOURCE,
|
|
653
|
+
DetailType: event,
|
|
654
|
+
Detail: JSON.stringify(message ?? null)
|
|
655
|
+
}
|
|
656
|
+
]
|
|
657
|
+
};
|
|
658
|
+
console.log(payload);
|
|
659
|
+
await putEventsViaFetch(payload);
|
|
660
|
+
}
|
|
661
|
+
async function putEventsViaFetch(payload) {
|
|
662
|
+
const region = resolveRegion();
|
|
663
|
+
const creds = resolveCredentials();
|
|
664
|
+
const host = `events.${region}.amazonaws.com`;
|
|
665
|
+
const url = `https://${host}/`;
|
|
666
|
+
const body = JSON.stringify(payload);
|
|
667
|
+
const amzDate = toAmzDate(/* @__PURE__ */ new Date());
|
|
668
|
+
const dateStamp = amzDate.slice(0, 8);
|
|
669
|
+
const headers = {
|
|
670
|
+
"content-type": "application/x-amz-json-1.1",
|
|
671
|
+
"x-amz-date": amzDate,
|
|
672
|
+
"x-amz-target": AWS_TARGET,
|
|
673
|
+
host
|
|
674
|
+
};
|
|
675
|
+
if (creds.sessionToken) {
|
|
676
|
+
headers["x-amz-security-token"] = creds.sessionToken;
|
|
677
|
+
}
|
|
678
|
+
const signedHeaders = getSignedHeaders(headers);
|
|
679
|
+
const canonicalRequest = [
|
|
680
|
+
"POST",
|
|
681
|
+
"/",
|
|
682
|
+
"",
|
|
683
|
+
canonicalizeHeaders(headers),
|
|
684
|
+
signedHeaders,
|
|
685
|
+
sha256(body)
|
|
686
|
+
].join("\n");
|
|
687
|
+
const scope = `${dateStamp}/${region}/${AWS_SERVICE}/aws4_request`;
|
|
688
|
+
const stringToSign = [
|
|
689
|
+
"AWS4-HMAC-SHA256",
|
|
690
|
+
amzDate,
|
|
691
|
+
scope,
|
|
692
|
+
sha256(canonicalRequest)
|
|
693
|
+
].join("\n");
|
|
694
|
+
const signingKey = getSigningKey(creds.secretAccessKey, dateStamp, region, AWS_SERVICE);
|
|
695
|
+
const signature = hmac(signingKey, stringToSign);
|
|
696
|
+
const authorization = `AWS4-HMAC-SHA256 Credential=${creds.accessKeyId}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`;
|
|
697
|
+
const response = await fetch(url, {
|
|
698
|
+
method: "POST",
|
|
699
|
+
headers: {
|
|
700
|
+
...headers,
|
|
701
|
+
Authorization: authorization
|
|
702
|
+
},
|
|
703
|
+
body
|
|
704
|
+
});
|
|
705
|
+
if (!response.ok) {
|
|
706
|
+
const text2 = await response.text();
|
|
707
|
+
throw new Error(`EventBridge PutEvents failed: ${response.status} ${text2}`);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
function resolveRegion() {
|
|
711
|
+
const region = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION;
|
|
712
|
+
if (!region) {
|
|
713
|
+
throw new Error("AWS region is not set");
|
|
714
|
+
}
|
|
715
|
+
return region;
|
|
716
|
+
}
|
|
717
|
+
function resolveCredentials() {
|
|
718
|
+
const accessKeyId = process.env.AWS_ACCESS_KEY_ID;
|
|
719
|
+
const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
|
|
720
|
+
const sessionToken = process.env.AWS_SESSION_TOKEN;
|
|
721
|
+
if (!accessKeyId || !secretAccessKey) {
|
|
722
|
+
throw new Error("AWS credentials are not set");
|
|
723
|
+
}
|
|
724
|
+
return { accessKeyId, secretAccessKey, sessionToken };
|
|
725
|
+
}
|
|
726
|
+
function toAmzDate(date) {
|
|
727
|
+
const pad = (value) => value.toString().padStart(2, "0");
|
|
728
|
+
return [
|
|
729
|
+
date.getUTCFullYear(),
|
|
730
|
+
pad(date.getUTCMonth() + 1),
|
|
731
|
+
pad(date.getUTCDate()),
|
|
732
|
+
"T",
|
|
733
|
+
pad(date.getUTCHours()),
|
|
734
|
+
pad(date.getUTCMinutes()),
|
|
735
|
+
pad(date.getUTCSeconds()),
|
|
736
|
+
"Z"
|
|
737
|
+
].join("");
|
|
738
|
+
}
|
|
739
|
+
function sha256(value) {
|
|
740
|
+
return (0, import_node_crypto.createHash)("sha256").update(value, "utf8").digest("hex");
|
|
741
|
+
}
|
|
742
|
+
function hmac(key, value) {
|
|
743
|
+
return (0, import_node_crypto.createHmac)("sha256", key).update(value, "utf8").digest("hex");
|
|
744
|
+
}
|
|
745
|
+
function getSigningKey(secret, date, region, service) {
|
|
746
|
+
const kDate = (0, import_node_crypto.createHmac)("sha256", `AWS4${secret}`).update(date, "utf8").digest();
|
|
747
|
+
const kRegion = (0, import_node_crypto.createHmac)("sha256", kDate).update(region, "utf8").digest();
|
|
748
|
+
const kService = (0, import_node_crypto.createHmac)("sha256", kRegion).update(service, "utf8").digest();
|
|
749
|
+
return (0, import_node_crypto.createHmac)("sha256", kService).update("aws4_request", "utf8").digest();
|
|
750
|
+
}
|
|
751
|
+
function canonicalizeHeaders(headers) {
|
|
752
|
+
return Object.keys(headers).map((key) => key.toLowerCase()).sort().map((key) => `${key}:${headers[key].trim()}
|
|
753
|
+
`).join("");
|
|
754
|
+
}
|
|
755
|
+
function getSignedHeaders(headers) {
|
|
756
|
+
return Object.keys(headers).map((key) => key.toLowerCase()).sort().join(";");
|
|
757
|
+
}
|
|
570
758
|
// Annotate the CommonJS export names for ESM import in node:
|
|
571
759
|
0 && (module.exports = {
|
|
572
760
|
Auth,
|
|
@@ -578,6 +766,7 @@ function Res() {
|
|
|
578
766
|
Header,
|
|
579
767
|
Headers,
|
|
580
768
|
HttpError,
|
|
769
|
+
On,
|
|
581
770
|
Options,
|
|
582
771
|
Param,
|
|
583
772
|
Patch,
|
|
@@ -591,5 +780,6 @@ function Res() {
|
|
|
591
780
|
handleError,
|
|
592
781
|
json,
|
|
593
782
|
noContent,
|
|
783
|
+
publish,
|
|
594
784
|
text
|
|
595
785
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,45 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readonly statusCode: number;
|
|
8
|
-
readonly headers?: Record<string, string>;
|
|
9
|
-
readonly details?: unknown;
|
|
10
|
-
constructor(statusCode: number, message: string, options?: {
|
|
11
|
-
cause?: unknown;
|
|
12
|
-
headers?: Record<string, string>;
|
|
13
|
-
details?: unknown;
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
declare function json(status: number, data: unknown, headers?: Record<string, string>): ResponseLike;
|
|
17
|
-
declare function text(status: number, body: string, headers?: Record<string, string>): ResponseLike;
|
|
18
|
-
declare function noContent(headers?: Record<string, string>): ResponseLike;
|
|
19
|
-
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
20
|
-
type LambdaResult = APIGatewayProxyResult | APIGatewayProxyResultV2;
|
|
21
|
-
declare function createHandler(): (event: LambdaEvent, lambdaContext: unknown) => Promise<LambdaResult>;
|
|
22
|
-
declare function handleError(error: unknown, preferV2: boolean): LambdaResult;
|
|
23
|
-
|
|
24
|
-
type LegacyDecorator = (target: unknown, propertyKey?: string | symbol, descriptor?: PropertyDescriptor) => void;
|
|
25
|
-
type LegacyParameterDecorator = (target: unknown, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
26
|
-
declare const Get: (path?: string) => LegacyDecorator;
|
|
27
|
-
declare const Post: (path?: string) => LegacyDecorator;
|
|
28
|
-
declare const Put: (path?: string) => LegacyDecorator;
|
|
29
|
-
declare const Patch: (path?: string) => LegacyDecorator;
|
|
30
|
-
declare const Delete: (path?: string) => LegacyDecorator;
|
|
31
|
-
declare const Head: (path?: string) => LegacyDecorator;
|
|
32
|
-
declare const Options: (path?: string) => LegacyDecorator;
|
|
33
|
-
declare function FirebaseAuth(options?: FirebaseAuthOptions): LegacyDecorator;
|
|
34
|
-
declare function Auth(): LegacyParameterDecorator;
|
|
35
|
-
declare function Body(schema?: ZodTypeAny): LegacyParameterDecorator;
|
|
36
|
-
declare function Query(name?: string): LegacyParameterDecorator;
|
|
37
|
-
declare function Param(name?: string): LegacyParameterDecorator;
|
|
38
|
-
declare function Headers(): LegacyParameterDecorator;
|
|
39
|
-
declare function Header(name: string): LegacyParameterDecorator;
|
|
40
|
-
declare function Req(): LegacyParameterDecorator;
|
|
41
|
-
declare function Res(): LegacyParameterDecorator;
|
|
42
|
-
|
|
43
|
-
declare function configureRoutes(next?: RouteOptions): void;
|
|
44
|
-
|
|
45
|
-
export { Auth, Body, Delete, FirebaseAuth, FirebaseAuthOptions, Get, Head, Header, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, ResponseLike, RouteOptions, configureRoutes, createHandler, handleError, json, noContent, text };
|
|
1
|
+
export { Auth, Body, Delete, FirebaseAuth, Get, Head, Header, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, configureRoutes, createHandler, handleError, json, noContent, text } from './http/index.cjs';
|
|
2
|
+
export { c as FirebaseAuthMetadata, F as FirebaseAuthOptions, d as FirebaseClaims, H as Handler, a as HandlerContext, b as HttpMethod, R as ResponseLike, e as RouteOptions } from './types-w1A7o_rd.cjs';
|
|
3
|
+
export { On, publish } from './bus/index.cjs';
|
|
4
|
+
import 'aws-lambda';
|
|
5
|
+
import 'zod/v4';
|
|
6
|
+
import './handler-DaM4Racx.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,45 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readonly statusCode: number;
|
|
8
|
-
readonly headers?: Record<string, string>;
|
|
9
|
-
readonly details?: unknown;
|
|
10
|
-
constructor(statusCode: number, message: string, options?: {
|
|
11
|
-
cause?: unknown;
|
|
12
|
-
headers?: Record<string, string>;
|
|
13
|
-
details?: unknown;
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
declare function json(status: number, data: unknown, headers?: Record<string, string>): ResponseLike;
|
|
17
|
-
declare function text(status: number, body: string, headers?: Record<string, string>): ResponseLike;
|
|
18
|
-
declare function noContent(headers?: Record<string, string>): ResponseLike;
|
|
19
|
-
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
20
|
-
type LambdaResult = APIGatewayProxyResult | APIGatewayProxyResultV2;
|
|
21
|
-
declare function createHandler(): (event: LambdaEvent, lambdaContext: unknown) => Promise<LambdaResult>;
|
|
22
|
-
declare function handleError(error: unknown, preferV2: boolean): LambdaResult;
|
|
23
|
-
|
|
24
|
-
type LegacyDecorator = (target: unknown, propertyKey?: string | symbol, descriptor?: PropertyDescriptor) => void;
|
|
25
|
-
type LegacyParameterDecorator = (target: unknown, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
26
|
-
declare const Get: (path?: string) => LegacyDecorator;
|
|
27
|
-
declare const Post: (path?: string) => LegacyDecorator;
|
|
28
|
-
declare const Put: (path?: string) => LegacyDecorator;
|
|
29
|
-
declare const Patch: (path?: string) => LegacyDecorator;
|
|
30
|
-
declare const Delete: (path?: string) => LegacyDecorator;
|
|
31
|
-
declare const Head: (path?: string) => LegacyDecorator;
|
|
32
|
-
declare const Options: (path?: string) => LegacyDecorator;
|
|
33
|
-
declare function FirebaseAuth(options?: FirebaseAuthOptions): LegacyDecorator;
|
|
34
|
-
declare function Auth(): LegacyParameterDecorator;
|
|
35
|
-
declare function Body(schema?: ZodTypeAny): LegacyParameterDecorator;
|
|
36
|
-
declare function Query(name?: string): LegacyParameterDecorator;
|
|
37
|
-
declare function Param(name?: string): LegacyParameterDecorator;
|
|
38
|
-
declare function Headers(): LegacyParameterDecorator;
|
|
39
|
-
declare function Header(name: string): LegacyParameterDecorator;
|
|
40
|
-
declare function Req(): LegacyParameterDecorator;
|
|
41
|
-
declare function Res(): LegacyParameterDecorator;
|
|
42
|
-
|
|
43
|
-
declare function configureRoutes(next?: RouteOptions): void;
|
|
44
|
-
|
|
45
|
-
export { Auth, Body, Delete, FirebaseAuth, FirebaseAuthOptions, Get, Head, Header, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, ResponseLike, RouteOptions, configureRoutes, createHandler, handleError, json, noContent, text };
|
|
1
|
+
export { Auth, Body, Delete, FirebaseAuth, Get, Head, Header, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, configureRoutes, createHandler, handleError, json, noContent, text } from './http/index.js';
|
|
2
|
+
export { c as FirebaseAuthMetadata, F as FirebaseAuthOptions, d as FirebaseClaims, H as Handler, a as HandlerContext, b as HttpMethod, R as ResponseLike, e as RouteOptions } from './types-w1A7o_rd.js';
|
|
3
|
+
export { On, publish } from './bus/index.js';
|
|
4
|
+
import 'aws-lambda';
|
|
5
|
+
import 'zod/v4';
|
|
6
|
+
import './handler-DaM4Racx.js';
|