@zeltjs/adapter-lambda 0.0.1 → 0.4.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 9wick / Kohei Kido
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,341 @@
1
+ import { EnvConfig, HttpApp, ReadyResult } from "@zeltjs/core";
2
+ import { Writable } from "node:stream";
3
+
4
+ //#region src/lambda-env.config.d.ts
5
+ declare class LambdaEnvConfig extends EnvConfig {
6
+ get(key: string): string | undefined;
7
+ }
8
+ //#endregion
9
+ //#region ../../node_modules/.pnpm/@types+aws-lambda@8.10.150/node_modules/@types/aws-lambda/common/api-gateway.d.ts
10
+ // Default authorizer type, prefer using a specific type with the "...WithAuthorizer..." variant types.
11
+ // Note that this doesn't have to be a context from a custom lambda outhorizer, AWS also has a cognito
12
+ // authorizer type and could add more, so the property won't always be a string.
13
+ type APIGatewayEventDefaultAuthorizerContext = undefined | null | {
14
+ [name: string]: any;
15
+ };
16
+ // The requestContext property of both request authorizer and proxy integration events.
17
+ interface APIGatewayEventRequestContextWithAuthorizer<TAuthorizerContext> {
18
+ accountId: string;
19
+ apiId: string; // This one is a bit confusing: it is not actually present in authorizer calls
20
+ // and proxy calls without an authorizer. We model this by allowing undefined in the type,
21
+ // since it ends up the same and avoids breaking users that are testing the property.
22
+ // This lets us allow parameterizing the authorizer for proxy events that know what authorizer
23
+ // context values they have.
24
+ authorizer: TAuthorizerContext;
25
+ connectedAt?: number | undefined;
26
+ connectionId?: string | undefined;
27
+ domainName?: string | undefined;
28
+ domainPrefix?: string | undefined;
29
+ eventType?: string | undefined;
30
+ extendedRequestId?: string | undefined;
31
+ protocol: string;
32
+ httpMethod: string;
33
+ identity: APIGatewayEventIdentity;
34
+ messageDirection?: string | undefined;
35
+ messageId?: string | null | undefined;
36
+ path: string;
37
+ stage: string;
38
+ requestId: string;
39
+ requestTime?: string | undefined;
40
+ requestTimeEpoch: number;
41
+ resourceId: string;
42
+ resourcePath: string;
43
+ routeKey?: string | undefined;
44
+ }
45
+ interface APIGatewayEventClientCertificate {
46
+ clientCertPem: string;
47
+ serialNumber: string;
48
+ subjectDN: string;
49
+ issuerDN: string;
50
+ validity: {
51
+ notAfter: string;
52
+ notBefore: string;
53
+ };
54
+ }
55
+ interface APIGatewayEventIdentity {
56
+ accessKey: string | null;
57
+ accountId: string | null;
58
+ apiKey: string | null;
59
+ apiKeyId: string | null;
60
+ caller: string | null;
61
+ clientCert: APIGatewayEventClientCertificate | null;
62
+ cognitoAuthenticationProvider: string | null;
63
+ cognitoAuthenticationType: string | null;
64
+ cognitoIdentityId: string | null;
65
+ cognitoIdentityPoolId: string | null;
66
+ principalOrgId: string | null;
67
+ sourceIp: string;
68
+ user: string | null;
69
+ userAgent: string | null;
70
+ userArn: string | null;
71
+ }
72
+ //#endregion
73
+ //#region ../../node_modules/.pnpm/@types+aws-lambda@8.10.150/node_modules/@types/aws-lambda/handler.d.ts
74
+ /**
75
+ * {@link Handler} context parameter.
76
+ * See {@link https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html AWS documentation}.
77
+ */
78
+ interface Context {
79
+ callbackWaitsForEmptyEventLoop: boolean;
80
+ functionName: string;
81
+ functionVersion: string;
82
+ invokedFunctionArn: string;
83
+ memoryLimitInMB: string;
84
+ awsRequestId: string;
85
+ logGroupName: string;
86
+ logStreamName: string;
87
+ identity?: CognitoIdentity | undefined;
88
+ clientContext?: ClientContext | undefined;
89
+ getRemainingTimeInMillis(): number; // Functions for compatibility with earlier Node.js Runtime v0.10.42
90
+ // No longer documented, so they are deprecated, but they still work
91
+ // as of the 12.x runtime, so they are not removed from the types.
92
+ /** @deprecated Use handler callback or promise result */
93
+ done(error?: Error, result?: any): void;
94
+ /** @deprecated Use handler callback with first argument or reject a promise result */
95
+ fail(error: Error | string): void;
96
+ /** @deprecated Use handler callback with second argument or resolve a promise result */
97
+ succeed(messageOrObject: any): void; // Unclear what behavior this is supposed to have, I couldn't find any still extant reference,
98
+ // and it behaves like the above, ignoring the object parameter.
99
+ /** @deprecated Use handler callback or promise result */
100
+ succeed(message: string, object: any): void;
101
+ }
102
+ interface CognitoIdentity {
103
+ cognitoIdentityId: string;
104
+ cognitoIdentityPoolId: string;
105
+ }
106
+ interface ClientContext {
107
+ client: ClientContextClient;
108
+ Custom?: any;
109
+ env: ClientContextEnv;
110
+ }
111
+ interface ClientContextClient {
112
+ installationId: string;
113
+ appTitle: string;
114
+ appVersionName: string;
115
+ appVersionCode: string;
116
+ appPackageName: string;
117
+ }
118
+ interface ClientContextEnv {
119
+ platformVersion: string;
120
+ platform: string;
121
+ make: string;
122
+ model: string;
123
+ locale: string;
124
+ }
125
+ /**
126
+ * Interface for using response streaming from AWS Lambda.
127
+ * To indicate to the runtime that Lambda should stream your function’s responses, you must wrap your function handler with the `awslambda.streamifyResponse()` decorator.
128
+ *
129
+ * The `streamifyResponse` decorator accepts the following additional parameter, `responseStream`, besides the default node handler parameters, `event`, and `context`.
130
+ * The new `responseStream` object provides a stream object that your function can write data to. Data written to this stream is sent immediately to the client. You can optionally set the Content-Type header of the response to pass additional metadata to your client about the contents of the stream.
131
+ *
132
+ * {@link https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/ AWS blog post}
133
+ * {@link https://docs.aws.amazon.com/lambda/latest/dg/config-rs-write-functions.html AWS documentation}
134
+ *
135
+ * @example <caption>Writing to the response stream</caption>
136
+ * import 'aws-lambda';
137
+ *
138
+ * export const handler = awslambda.streamifyResponse(
139
+ * async (event, responseStream, context) => {
140
+ * responseStream.setContentType("text/plain");
141
+ * responseStream.write("Hello, world!");
142
+ * responseStream.end();
143
+ * }
144
+ * );
145
+ *
146
+ * @example <caption>Using pipeline</caption>
147
+ * import 'aws-lambda';
148
+ * import { Readable } from 'stream';
149
+ * import { pipeline } from 'stream/promises';
150
+ * import zlib from 'zlib';
151
+ *
152
+ * export const handler = awslambda.streamifyResponse(
153
+ * async (event, responseStream, context) => {
154
+ * // As an example, convert event to a readable stream.
155
+ * const requestStream = Readable.from(Buffer.from(JSON.stringify(event)));
156
+ *
157
+ * await pipeline(requestStream, zlib.createGzip(), responseStream);
158
+ * }
159
+ * );
160
+ */
161
+ type StreamifyHandler<TEvent = any, TResult = any> = (event: TEvent, responseStream: awslambda.HttpResponseStream, context: Context) => TResult | Promise<TResult>;
162
+ declare global {
163
+ namespace awslambda {
164
+ class HttpResponseStream extends Writable {
165
+ static from(writable: Writable, metadata: Record<string, unknown>): HttpResponseStream;
166
+ setContentType: (contentType: string) => void;
167
+ }
168
+ /**
169
+ * Decorator for using response streaming from AWS Lambda.
170
+ * To indicate to the runtime that Lambda should stream your function’s responses, you must wrap your function handler with the `awslambda.streamifyResponse()` decorator.
171
+ *
172
+ * The `streamifyResponse` decorator accepts the following additional parameter, `responseStream`, besides the default node handler parameters, `event`, and `context`.
173
+ * The new `responseStream` object provides a stream object that your function can write data to. Data written to this stream is sent immediately to the client. You can optionally set the Content-Type header of the response to pass additional metadata to your client about the contents of the stream.
174
+ *
175
+ * {@link https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/ AWS blog post}
176
+ * {@link https://docs.aws.amazon.com/lambda/latest/dg/config-rs-write-functions.html AWS documentation}
177
+ *
178
+ * @example <caption>Writing to the response stream</caption>
179
+ * import 'aws-lambda';
180
+ *
181
+ * export const handler = awslambda.streamifyResponse(
182
+ * async (event, responseStream, context) => {
183
+ * responseStream.setContentType("text/plain");
184
+ * responseStream.write("Hello, world!");
185
+ * responseStream.end();
186
+ * }
187
+ * );
188
+ *
189
+ * @example <caption>Using pipeline</caption>
190
+ * import 'aws-lambda';
191
+ * import { Readable } from 'stream';
192
+ * import { pipeline } from 'stream/promises';
193
+ * import zlib from 'zlib';
194
+ *
195
+ * export const handler = awslambda.streamifyResponse(
196
+ * async (event, responseStream, context) => {
197
+ * // As an example, convert event to a readable stream.
198
+ * const requestStream = Readable.from(Buffer.from(JSON.stringify(event)));
199
+ *
200
+ * await pipeline(requestStream, zlib.createGzip(), responseStream);
201
+ * }
202
+ * );
203
+ */
204
+ function streamifyResponse<TEvent = any, TResult = void>(handler: StreamifyHandler<TEvent, TResult>): StreamifyHandler<TEvent, TResult>;
205
+ }
206
+ }
207
+ //#endregion
208
+ //#region ../../node_modules/.pnpm/@types+aws-lambda@8.10.150/node_modules/@types/aws-lambda/trigger/api-gateway-proxy.d.ts
209
+ /**
210
+ * Works with Lambda Proxy Integration for Rest API or HTTP API integration Payload Format version 1.0
211
+ * @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
212
+ */
213
+ type APIGatewayProxyEvent = APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>;
214
+ interface APIGatewayProxyEventHeaders {
215
+ [name: string]: string | undefined;
216
+ }
217
+ interface APIGatewayProxyEventMultiValueHeaders {
218
+ [name: string]: string[] | undefined;
219
+ }
220
+ interface APIGatewayProxyEventPathParameters {
221
+ [name: string]: string | undefined;
222
+ }
223
+ interface APIGatewayProxyEventQueryStringParameters {
224
+ [name: string]: string | undefined;
225
+ }
226
+ interface APIGatewayProxyEventMultiValueQueryStringParameters {
227
+ [name: string]: string[] | undefined;
228
+ }
229
+ interface APIGatewayProxyEventStageVariables {
230
+ [name: string]: string | undefined;
231
+ }
232
+ interface APIGatewayProxyEventBase<TAuthorizerContext> {
233
+ body: string | null;
234
+ headers: APIGatewayProxyEventHeaders;
235
+ multiValueHeaders: APIGatewayProxyEventMultiValueHeaders;
236
+ httpMethod: string;
237
+ isBase64Encoded: boolean;
238
+ path: string;
239
+ pathParameters: APIGatewayProxyEventPathParameters | null;
240
+ queryStringParameters: APIGatewayProxyEventQueryStringParameters | null;
241
+ multiValueQueryStringParameters: APIGatewayProxyEventMultiValueQueryStringParameters | null;
242
+ stageVariables: APIGatewayProxyEventStageVariables | null;
243
+ requestContext: APIGatewayEventRequestContextWithAuthorizer<TAuthorizerContext>;
244
+ resource: string;
245
+ }
246
+ /**
247
+ * Works with Lambda Proxy Integration for Rest API or HTTP API integration Payload Format version 1.0
248
+ * @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
249
+ */
250
+ interface APIGatewayProxyResult {
251
+ statusCode: number;
252
+ headers?: {
253
+ [header: string]: boolean | number | string;
254
+ } | undefined;
255
+ multiValueHeaders?: {
256
+ [header: string]: Array<boolean | number | string>;
257
+ } | undefined;
258
+ body: string;
259
+ isBase64Encoded?: boolean | undefined;
260
+ }
261
+ /**
262
+ * Works with HTTP API integration Payload Format version 2.0
263
+ * @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
264
+ */
265
+ interface APIGatewayEventRequestContextV2 {
266
+ accountId: string;
267
+ apiId: string;
268
+ authentication?: {
269
+ clientCert: APIGatewayEventClientCertificate;
270
+ };
271
+ domainName: string;
272
+ domainPrefix: string;
273
+ http: {
274
+ method: string;
275
+ path: string;
276
+ protocol: string;
277
+ sourceIp: string;
278
+ userAgent: string;
279
+ };
280
+ requestId: string;
281
+ routeKey: string;
282
+ stage: string;
283
+ time: string;
284
+ timeEpoch: number;
285
+ }
286
+ /**
287
+ * Proxy Event with adaptable requestContext for different authorizer scenarios
288
+ */
289
+ interface APIGatewayProxyEventV2WithRequestContext<TRequestContext> {
290
+ version: string;
291
+ routeKey: string;
292
+ rawPath: string;
293
+ rawQueryString: string;
294
+ cookies?: string[];
295
+ headers: APIGatewayProxyEventHeaders;
296
+ queryStringParameters?: APIGatewayProxyEventQueryStringParameters;
297
+ requestContext: TRequestContext;
298
+ body?: string;
299
+ pathParameters?: APIGatewayProxyEventPathParameters;
300
+ isBase64Encoded: boolean;
301
+ stageVariables?: APIGatewayProxyEventStageVariables;
302
+ }
303
+ /**
304
+ * Default Proxy event with no Authorizer
305
+ */
306
+ type APIGatewayProxyEventV2 = APIGatewayProxyEventV2WithRequestContext<APIGatewayEventRequestContextV2>;
307
+ /**
308
+ * Works with HTTP API integration Payload Format version 2.0
309
+ * @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
310
+ */
311
+ type APIGatewayProxyResultV2<T = never> = APIGatewayProxyStructuredResultV2 | string | T;
312
+ /**
313
+ * Interface for structured response with `statusCode` and`headers`
314
+ * Works with HTTP API integration Payload Format version 2.0
315
+ * @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
316
+ */
317
+ interface APIGatewayProxyStructuredResultV2 {
318
+ statusCode?: number | undefined;
319
+ headers?: {
320
+ [header: string]: boolean | number | string;
321
+ } | undefined;
322
+ body?: string | undefined;
323
+ isBase64Encoded?: boolean | undefined;
324
+ cookies?: string[] | undefined;
325
+ }
326
+ //#endregion
327
+ //#region src/on-lambda.d.ts
328
+ type LambdaAppOptions = {
329
+ readonly warmup?: boolean;
330
+ };
331
+ type LambdaHandlerV2 = (event: APIGatewayProxyEventV2, context: Context) => Promise<APIGatewayProxyResultV2>;
332
+ type LambdaHandlerV1 = (event: APIGatewayProxyEvent, context: Context) => Promise<APIGatewayProxyResult>;
333
+ type LambdaApp = ReadyResult & {
334
+ readonly handler: LambdaHandlerV2;
335
+ readonly handlerV1: LambdaHandlerV1;
336
+ readonly shutdown: () => Promise<void>;
337
+ };
338
+ declare const onLambda: (app: HttpApp, options?: LambdaAppOptions) => Promise<LambdaApp>;
339
+ //#endregion
340
+ export { type LambdaApp, type LambdaAppOptions, LambdaEnvConfig, type LambdaHandlerV1, type LambdaHandlerV2, onLambda };
341
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["APIGatewayAuthorizerResultContext","name","APIGatewayEventDefaultAuthorizerContext","APIGatewayEventRequestContext","APIGatewayEventRequestContextWithAuthorizer","TAuthorizerContext","APIGatewayEventIdentity","accountId","apiId","authorizer","connectedAt","connectionId","domainName","domainPrefix","eventType","extendedRequestId","protocol","httpMethod","identity","messageDirection","messageId","path","stage","requestId","requestTime","requestTimeEpoch","resourceId","resourcePath","routeKey","APIGatewayEventClientCertificate","clientCertPem","serialNumber","subjectDN","issuerDN","validity","notAfter","notBefore","accessKey","apiKey","apiKeyId","caller","clientCert","cognitoAuthenticationProvider","cognitoAuthenticationType","cognitoIdentityId","cognitoIdentityPoolId","principalOrgId","sourceIp","user","userAgent","userArn","Writable","Handler","TEvent","TResult","Context","Callback","Promise","event","context","callback","CognitoIdentity","ClientContext","Error","callbackWaitsForEmptyEventLoop","functionName","functionVersion","invokedFunctionArn","memoryLimitInMB","awsRequestId","logGroupName","logStreamName","identity","clientContext","getRemainingTimeInMillis","done","error","result","fail","succeed","messageOrObject","message","object","cognitoIdentityId","cognitoIdentityPoolId","ClientContextClient","ClientContextEnv","client","Custom","env","installationId","appTitle","appVersionName","appVersionCode","appPackageName","platformVersion","platform","make","model","locale","StreamifyHandler","awslambda","HttpResponseStream","responseStream","_0","Record","global","from","writable","metadata","setContentType","contentType","streamifyResponse","handler","sideEffect","APIGatewayEventClientCertificate","APIGatewayEventDefaultAuthorizerContext","APIGatewayEventRequestContextWithAuthorizer","Callback","CognitoIdentity","Handler","APIGatewayProxyHandler","APIGatewayProxyEvent","APIGatewayProxyResult","APIGatewayProxyCallback","APIGatewayProxyHandlerV2","T","APIGatewayProxyEventV2","APIGatewayProxyResultV2","APIGatewayProxyWebsocketHandlerV2","APIGatewayProxyWebsocketEventV2","APIGatewayProxyHandlerV2WithJWTAuthorizer","APIGatewayProxyEventV2WithJWTAuthorizer","APIGatewayProxyHandlerV2WithLambdaAuthorizer","TAuthorizerContext","APIGatewayProxyEventV2WithLambdaAuthorizer","APIGatewayProxyHandlerV2WithIAMAuthorizer","APIGatewayProxyEventV2WithIAMAuthorizer","APIGatewayProxyCallbackV2","APIGatewayProxyEventBase","APIGatewayProxyWithLambdaAuthorizerHandler","APIGatewayProxyWithLambdaAuthorizerEvent","APIGatewayProxyWithCognitoAuthorizerHandler","APIGatewayProxyWithCognitoAuthorizerEvent","APIGatewayEventLambdaAuthorizerContext","APIGatewayProxyWithLambdaAuthorizerEventRequestContext","P","principalId","integrationLatency","APIGatewayProxyCognitoAuthorizer","claims","name","APIGatewayProxyEventHeaders","APIGatewayProxyEventMultiValueHeaders","APIGatewayProxyEventPathParameters","APIGatewayProxyEventQueryStringParameters","APIGatewayProxyEventMultiValueQueryStringParameters","APIGatewayProxyEventStageVariables","body","headers","multiValueHeaders","httpMethod","isBase64Encoded","path","pathParameters","queryStringParameters","multiValueQueryStringParameters","stageVariables","requestContext","resource","Array","statusCode","header","APIGatewayEventRequestContextV2","accountId","apiId","authentication","clientCert","domainName","domainPrefix","http","method","protocol","sourceIp","userAgent","requestId","routeKey","stage","time","timeEpoch","APIGatewayEventWebsocketRequestContextV2","messageId","eventType","extendedRequestId","requestTime","messageDirection","connectedAt","requestTimeEpoch","connectionId","APIGatewayProxyEventV2WithRequestContext","TRequestContext","version","rawPath","rawQueryString","cookies","APIGatewayProxyWebsocketEventV2WithRequestContext","APIGatewayEventRequestContextLambdaAuthorizer","lambda","APIGatewayEventRequestContextJWTAuthorizer","jwt","scopes","APIGatewayEventRequestContextIAMAuthorizer","iam","accessKey","callerId","cognitoIdentity","principalOrgId","userArn","userId","APIGatewayEventRequestContextV2WithAuthorizer","TAuthorizer","authorizer","APIGatewayProxyStructuredResultV2","ProxyHandler","ProxyCallback","APIGatewayEvent","ProxyResult"],"sources":["../src/lambda-env.config.ts","../../../node_modules/.pnpm/@types+aws-lambda@8.10.150/node_modules/@types/aws-lambda/common/api-gateway.d.ts","../../../node_modules/.pnpm/@types+aws-lambda@8.10.150/node_modules/@types/aws-lambda/handler.d.ts","../../../node_modules/.pnpm/@types+aws-lambda@8.10.150/node_modules/@types/aws-lambda/trigger/api-gateway-proxy.d.ts","../src/on-lambda.ts"],"x_google_ignoreList":[1,2,3],"mappings":";;;;cAGa,eAAA,SAAwB,SAAA;EAC1B,GAAA,CAAI,GAAA;AAAA;;;;;;KCSHE,uCAAAA;EAAAA,CAIHD,IAAAA;AAAAA;AAAAA;AAAAA,UAQQG,2CAAAA;EACbG,SAAAA;EACAC,KAAAA;EAAAA;EAAAA;EAAAA;EAAAA;EAMAC,UAAAA,EAAYJ,kBAAAA;EACZK,WAAAA;EACAC,YAAAA;EACAC,UAAAA;EACAC,YAAAA;EACAC,SAAAA;EACAC,iBAAAA;EACAC,QAAAA;EACAC,UAAAA;EACAC,QAAAA,EAAUZ,uBAAAA;EACVa,gBAAAA;EACAC,SAAAA;EACAC,IAAAA;EACAC,KAAAA;EACAC,SAAAA;EACAC,WAAAA;EACAC,gBAAAA;EACAC,UAAAA;EACAC,YAAAA;EACAC,QAAAA;AAAAA;AAAAA,UAGaC,gCAAAA;EACbC,aAAAA;EACAC,YAAAA;EACAC,SAAAA;EACAC,QAAAA;EACAC,QAAAA;IACIC,QAAAA;IACAC,SAAAA;EAAAA;AAAAA;AAAAA,UAIS9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ACT,SAAA,EAAW,eAAA;EAAA,SACX,QAAA,QAAgB,OAAA;AAAA;AAAA,cA0Jd,QAAA,GACX,GAAA,EAAK,OAAA,EACL,OAAA,GAAS,gBAAA,KACR,OAAA,CAAQ,SAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,112 @@
1
+ import { Config, EnvConfig } from "@zeltjs/core";
2
+ //#region src/lambda-env.config.ts
3
+ var LambdaEnvConfig = @Config class extends EnvConfig {
4
+ get(key) {
5
+ return process.env[key];
6
+ }
7
+ };
8
+ //#endregion
9
+ //#region src/on-lambda.ts
10
+ const buildHeadersFromRecord = (headersRecord) => {
11
+ const headers = new Headers();
12
+ if (headersRecord) {
13
+ for (const [key, value] of Object.entries(headersRecord)) if (value) headers.set(key, value);
14
+ }
15
+ return headers;
16
+ };
17
+ const buildBodyFromEvent = (body, isBase64Encoded) => {
18
+ if (!body) return null;
19
+ if (isBase64Encoded) {
20
+ const buffer = Buffer.from(body, "base64");
21
+ return new Blob([buffer]);
22
+ }
23
+ return body;
24
+ };
25
+ const buildRequestBody = (method, body) => {
26
+ return method !== "GET" && method !== "HEAD" ? body : null;
27
+ };
28
+ const buildRequestFromEventV2 = (event) => {
29
+ const headers = buildHeadersFromRecord(event.headers);
30
+ const url = `${headers.get("x-forwarded-proto") ?? "https"}://${event.requestContext.domainName}${event.rawPath}${event.rawQueryString ? `?${event.rawQueryString}` : ""}`;
31
+ const method = event.requestContext.http.method;
32
+ const requestBody = buildRequestBody(method, buildBodyFromEvent(event.body, event.isBase64Encoded));
33
+ return new Request(url, {
34
+ method,
35
+ headers,
36
+ body: requestBody
37
+ });
38
+ };
39
+ const buildQueryStringFromParams = (queryParams) => {
40
+ if (!queryParams) return "";
41
+ const params = {};
42
+ for (const [key, value] of Object.entries(queryParams)) if (value !== void 0) params[key] = value;
43
+ return `?${new URLSearchParams(params).toString()}`;
44
+ };
45
+ const buildRequestFromEventV1 = (event) => {
46
+ const headers = buildHeadersFromRecord(event.headers);
47
+ const url = `${headers.get("x-forwarded-proto") ?? "https"}://${headers.get("host") ?? "localhost"}${event.path}${buildQueryStringFromParams(event.queryStringParameters)}`;
48
+ const method = event.httpMethod;
49
+ const requestBody = buildRequestBody(method, buildBodyFromEvent(event.body, event.isBase64Encoded));
50
+ return new Request(url, {
51
+ method,
52
+ headers,
53
+ body: requestBody
54
+ });
55
+ };
56
+ const buildResultFromResponseV2 = async (response) => {
57
+ const headers = {};
58
+ response.headers.forEach((value, key) => {
59
+ headers[key] = value;
60
+ });
61
+ const contentType = response.headers.get("content-type") ?? "";
62
+ const isBinary = contentType.startsWith("image/") || contentType.startsWith("audio/") || contentType.startsWith("video/") || contentType === "application/octet-stream";
63
+ const body = isBinary ? Buffer.from(await response.arrayBuffer()).toString("base64") : await response.text();
64
+ return {
65
+ statusCode: response.status,
66
+ headers,
67
+ body,
68
+ isBase64Encoded: isBinary
69
+ };
70
+ };
71
+ const buildResultFromResponseV1 = async (response) => {
72
+ const headers = {};
73
+ response.headers.forEach((value, key) => {
74
+ headers[key] = value;
75
+ });
76
+ const contentType = response.headers.get("content-type") ?? "";
77
+ const isBinary = contentType.startsWith("image/") || contentType.startsWith("audio/") || contentType.startsWith("video/") || contentType === "application/octet-stream";
78
+ const body = isBinary ? Buffer.from(await response.arrayBuffer()).toString("base64") : await response.text();
79
+ return {
80
+ statusCode: response.status,
81
+ headers,
82
+ body,
83
+ isBase64Encoded: isBinary
84
+ };
85
+ };
86
+ const createHandlerV2 = (appFetch) => {
87
+ return async (event, _context) => {
88
+ return buildResultFromResponseV2(await appFetch(buildRequestFromEventV2(event)));
89
+ };
90
+ };
91
+ const createHandlerV1 = (appFetch) => {
92
+ return async (event, _context) => {
93
+ return buildResultFromResponseV1(await appFetch(buildRequestFromEventV1(event)));
94
+ };
95
+ };
96
+ const onLambda = async (app, options = {}) => {
97
+ app.addFallbackConfig(LambdaEnvConfig);
98
+ const readyOptions = { warmup: options.warmup ?? false };
99
+ const resolver = await app.ready(readyOptions);
100
+ const handler = createHandlerV2(app.fetch);
101
+ const handlerV1 = createHandlerV1(app.fetch);
102
+ return {
103
+ ...resolver,
104
+ handler,
105
+ handlerV1,
106
+ shutdown: app.shutdown
107
+ };
108
+ };
109
+ //#endregion
110
+ export { LambdaEnvConfig, onLambda };
111
+
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/lambda-env.config.ts","../src/on-lambda.ts"],"sourcesContent":["import { Config, EnvConfig } from '@zeltjs/core';\n\n@Config\nexport class LambdaEnvConfig extends EnvConfig {\n override get(key: string): string | undefined {\n return process.env[key];\n }\n}\n","import type { HttpApp, ReadyOptions, ReadyResult } from '@zeltjs/core';\nimport type {\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n APIGatewayProxyResult,\n APIGatewayProxyResultV2,\n Context,\n} from 'aws-lambda';\n\nimport { LambdaEnvConfig } from './lambda-env.config';\n\nexport type LambdaAppOptions = {\n readonly warmup?: boolean;\n};\n\nexport type LambdaHandlerV2 = (\n event: APIGatewayProxyEventV2,\n context: Context,\n) => Promise<APIGatewayProxyResultV2>;\n\nexport type LambdaHandlerV1 = (\n event: APIGatewayProxyEvent,\n context: Context,\n) => Promise<APIGatewayProxyResult>;\n\nexport type LambdaApp = ReadyResult & {\n readonly handler: LambdaHandlerV2;\n readonly handlerV1: LambdaHandlerV1;\n readonly shutdown: () => Promise<void>;\n};\n\nconst buildHeadersFromRecord = (\n headersRecord: Record<string, string | undefined> | undefined,\n): Headers => {\n const headers = new Headers();\n if (headersRecord) {\n for (const [key, value] of Object.entries(headersRecord)) {\n if (value) headers.set(key, value);\n }\n }\n return headers;\n};\n\nconst buildBodyFromEvent = (\n body: string | null | undefined,\n isBase64Encoded: boolean,\n): BodyInit | null => {\n if (!body) return null;\n if (isBase64Encoded) {\n const buffer = Buffer.from(body, 'base64');\n return new Blob([buffer]);\n }\n return body;\n};\n\nconst buildRequestBody = (method: string, body: BodyInit | null): BodyInit | null => {\n return method !== 'GET' && method !== 'HEAD' ? body : null;\n};\n\nconst buildRequestFromEventV2 = (event: APIGatewayProxyEventV2): Request => {\n const headers = buildHeadersFromRecord(event.headers);\n\n const protocol = headers.get('x-forwarded-proto') ?? 'https';\n const host = event.requestContext.domainName;\n const path = event.rawPath;\n const queryString = event.rawQueryString ? `?${event.rawQueryString}` : '';\n const url = `${protocol}://${host}${path}${queryString}`;\n\n const method = event.requestContext.http.method;\n const body = buildBodyFromEvent(event.body, event.isBase64Encoded);\n const requestBody = buildRequestBody(method, body);\n\n return new Request(url, {\n method,\n headers,\n body: requestBody,\n });\n};\n\nconst buildQueryStringFromParams = (\n queryParams: Record<string, string | undefined> | null | undefined,\n): string => {\n if (!queryParams) return '';\n const params: Record<string, string> = {};\n for (const [key, value] of Object.entries(queryParams)) {\n if (value !== undefined) {\n params[key] = value;\n }\n }\n return `?${new URLSearchParams(params).toString()}`;\n};\n\nconst buildRequestFromEventV1 = (event: APIGatewayProxyEvent): Request => {\n const headers = buildHeadersFromRecord(event.headers);\n\n const protocol = headers.get('x-forwarded-proto') ?? 'https';\n const host = headers.get('host') ?? 'localhost';\n const path = event.path;\n\n const queryString = buildQueryStringFromParams(event.queryStringParameters);\n const url = `${protocol}://${host}${path}${queryString}`;\n\n const method = event.httpMethod;\n const body = buildBodyFromEvent(event.body, event.isBase64Encoded);\n const requestBody = buildRequestBody(method, body);\n\n return new Request(url, {\n method,\n headers,\n body: requestBody,\n });\n};\n\nconst buildResultFromResponseV2 = async (response: Response): Promise<APIGatewayProxyResultV2> => {\n const headers: Record<string, string> = {};\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n const contentType = response.headers.get('content-type') ?? '';\n const isBinary =\n contentType.startsWith('image/') ||\n contentType.startsWith('audio/') ||\n contentType.startsWith('video/') ||\n contentType === 'application/octet-stream';\n\n const body = isBinary\n ? Buffer.from(await response.arrayBuffer()).toString('base64')\n : await response.text();\n\n return {\n statusCode: response.status,\n headers,\n body,\n isBase64Encoded: isBinary,\n };\n};\n\nconst buildResultFromResponseV1 = async (response: Response): Promise<APIGatewayProxyResult> => {\n const headers: Record<string, string> = {};\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n const contentType = response.headers.get('content-type') ?? '';\n const isBinary =\n contentType.startsWith('image/') ||\n contentType.startsWith('audio/') ||\n contentType.startsWith('video/') ||\n contentType === 'application/octet-stream';\n\n const body = isBinary\n ? Buffer.from(await response.arrayBuffer()).toString('base64')\n : await response.text();\n\n return {\n statusCode: response.status,\n headers,\n body,\n isBase64Encoded: isBinary,\n };\n};\n\nconst createHandlerV2 = (appFetch: (request: Request) => Promise<Response>): LambdaHandlerV2 => {\n return async (\n event: APIGatewayProxyEventV2,\n _context: Context,\n ): Promise<APIGatewayProxyResultV2> => {\n const request = buildRequestFromEventV2(event);\n const response = await appFetch(request);\n return buildResultFromResponseV2(response);\n };\n};\n\nconst createHandlerV1 = (appFetch: (request: Request) => Promise<Response>): LambdaHandlerV1 => {\n return async (event: APIGatewayProxyEvent, _context: Context): Promise<APIGatewayProxyResult> => {\n const request = buildRequestFromEventV1(event);\n const response = await appFetch(request);\n return buildResultFromResponseV1(response);\n };\n};\n\nexport const onLambda = async (\n app: HttpApp,\n options: LambdaAppOptions = {},\n): Promise<LambdaApp> => {\n app.addFallbackConfig(LambdaEnvConfig);\n\n const readyOptions: ReadyOptions = { warmup: options.warmup ?? false };\n const resolver = await app.ready(readyOptions);\n\n const handler = createHandlerV2(app.fetch);\n const handlerV1 = createHandlerV1(app.fetch);\n\n return {\n ...resolver,\n handler,\n handlerV1,\n shutdown: app.shutdown,\n };\n};\n"],"mappings":";;AAGA,IAAa,kBADb,CAAC,OAAD,cACqC,UAAU;CAC7C,IAAa,KAAiC;AAC5C,SAAO,QAAQ,IAAI;;;;;AC0BvB,MAAM,0BACJ,kBACY;CACZ,MAAM,UAAU,IAAI,SAAS;AAC7B,KAAI;OACG,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,cAAc,CACtD,KAAI,M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AAM,eAA6B,EAAE,QAAQ,QAAQ,UAAU,OAAO;CACtE,MAAM,WAAW,MAAM,IAAI,MAAM,aAAa;CAE9C,MAAM,UAAU,gBAAgB,IAAI,MAAM;CAC1C,MAAM,YAAY,gBAAgB,IAAI,MAAM;AAE5C,QAAO;EACL,GAAG;EACH;EACA;EACA,UAAU,IAAI;EACf"}
package/package.json CHANGED
@@ -1,10 +1,38 @@
1
1
  {
2
2
  "name": "@zeltjs/adapter-lambda",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @zeltjs/adapter-lambda",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
3
+ "version": "0.4.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/zeltjs/zelt.git",
9
+ "directory": "packages/adapter-lambda"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "dependencies": {
24
+ "@zeltjs/core": "0.4.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/aws-lambda": "8.10.150",
28
+ "@types/node": "22.19.17"
29
+ },
30
+ "volta": {
31
+ "extends": "../../package.json"
32
+ },
33
+ "scripts": {
34
+ "build": "tsdown",
35
+ "test": "vitest run",
36
+ "typecheck": "tsc -b"
37
+ }
38
+ }
package/README.md DELETED
@@ -1,45 +0,0 @@
1
- # @zeltjs/adapter-lambda
2
-
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@zeltjs/adapter-lambda`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**