sst-http 2.0.0-beta.12 → 2.0.0-beta.15
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 +12 -2
- package/dist/{chunk-SENBWWVV.js → chunk-P4HUTGVQ.js} +38 -0
- package/dist/http/index.cjs +39 -0
- package/dist/http/index.d.cts +2 -1
- package/dist/http/index.d.ts +2 -1
- package/dist/http/index.js +3 -1
- package/dist/index.cjs +39 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/infra.cjs +5 -4
- package/dist/infra.d.cts +6 -14
- package/dist/infra.d.ts +6 -14
- package/dist/infra.js +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -174,7 +174,8 @@ export default $config({
|
|
|
174
174
|
} = await import("sst-http/infra");
|
|
175
175
|
|
|
176
176
|
const manifest = loadRoutesManifest("routes.manifest.json");
|
|
177
|
-
const
|
|
177
|
+
const api = new sst.aws.ApiGatewayV2("Api");
|
|
178
|
+
const { registerRoute, ensureJwtAuthorizer } = httpApiAdapter({ api });
|
|
178
179
|
|
|
179
180
|
const handler = new sst.aws.Function("Handler", {
|
|
180
181
|
handler: "src/server.handler",
|
|
@@ -185,7 +186,7 @@ export default $config({
|
|
|
185
186
|
|
|
186
187
|
wireApiFromManifest(manifest, {
|
|
187
188
|
handler,
|
|
188
|
-
firebaseProjectId: process.env.FIREBASE_PROJECT_ID
|
|
189
|
+
firebaseProjectId: process.env.FIREBASE_PROJECT_ID,
|
|
189
190
|
registerRoute,
|
|
190
191
|
ensureJwtAuthorizer,
|
|
191
192
|
});
|
|
@@ -195,6 +196,15 @@ export default $config({
|
|
|
195
196
|
});
|
|
196
197
|
```
|
|
197
198
|
|
|
199
|
+
**Note:** `firebaseProjectId` and `ensureJwtAuthorizer` are optional and only required when your manifest contains routes with `@FirebaseAuth()`. For event-only handlers (no HTTP routes), you can omit `registerRoute` and `ensureJwtAuthorizer`:
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
wireApiFromManifest(manifest, {
|
|
203
|
+
handler,
|
|
204
|
+
registerRoute: (_method, _path, _config) => {},
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
198
208
|
When the manifest contains events (from `@On()` decorators), handlers are automatically subscribed to the default EventBridge bus. Swap in `restApiAdapter` if you prefer API Gateway REST APIs—the wiring contract is identical.
|
|
199
209
|
|
|
200
210
|
## Publishing
|
|
@@ -251,6 +251,14 @@ function buildHandlerArguments(entry, ctx, getBody) {
|
|
|
251
251
|
args[meta.index] = ctx.auth;
|
|
252
252
|
break;
|
|
253
253
|
}
|
|
254
|
+
case "userId": {
|
|
255
|
+
const userId = resolveUserIdFromClaims(ctx.auth);
|
|
256
|
+
if (!userId) {
|
|
257
|
+
throw new HttpError(401, "Invalid authentication");
|
|
258
|
+
}
|
|
259
|
+
args[meta.index] = userId;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
254
262
|
default: {
|
|
255
263
|
args[meta.index] = ctx;
|
|
256
264
|
}
|
|
@@ -337,6 +345,32 @@ function extractAuthClaims(event, entry) {
|
|
|
337
345
|
const claims = ctxV2?.authorizer?.jwt?.claims || ctxV1?.authorizer?.claims;
|
|
338
346
|
return claims ?? void 0;
|
|
339
347
|
}
|
|
348
|
+
function normalizeUserIdentifier(value) {
|
|
349
|
+
if (typeof value !== "string") {
|
|
350
|
+
return void 0;
|
|
351
|
+
}
|
|
352
|
+
const normalized = value.trim();
|
|
353
|
+
return normalized || void 0;
|
|
354
|
+
}
|
|
355
|
+
function resolveUserIdFromClaims(claims) {
|
|
356
|
+
const email = normalizeUserIdentifier(claims?.email);
|
|
357
|
+
if (email) {
|
|
358
|
+
return email.toLowerCase();
|
|
359
|
+
}
|
|
360
|
+
const userId = normalizeUserIdentifier(claims?.user_id);
|
|
361
|
+
if (userId) {
|
|
362
|
+
return userId;
|
|
363
|
+
}
|
|
364
|
+
const uid = normalizeUserIdentifier(claims?.uid);
|
|
365
|
+
if (uid) {
|
|
366
|
+
return uid;
|
|
367
|
+
}
|
|
368
|
+
const sub = normalizeUserIdentifier(claims?.sub);
|
|
369
|
+
if (sub) {
|
|
370
|
+
return sub;
|
|
371
|
+
}
|
|
372
|
+
return void 0;
|
|
373
|
+
}
|
|
340
374
|
function isHttpError(error) {
|
|
341
375
|
if (!error || typeof error !== "object") {
|
|
342
376
|
return false;
|
|
@@ -451,6 +485,9 @@ function FirebaseAuth(options) {
|
|
|
451
485
|
function Auth() {
|
|
452
486
|
return createParameterDecorator("auth");
|
|
453
487
|
}
|
|
488
|
+
function UserId() {
|
|
489
|
+
return createParameterDecorator("userId");
|
|
490
|
+
}
|
|
454
491
|
function Body(schema) {
|
|
455
492
|
return createParameterDecorator("body", { schema });
|
|
456
493
|
}
|
|
@@ -489,6 +526,7 @@ export {
|
|
|
489
526
|
Options,
|
|
490
527
|
FirebaseAuth,
|
|
491
528
|
Auth,
|
|
529
|
+
UserId,
|
|
492
530
|
Body,
|
|
493
531
|
Query,
|
|
494
532
|
Param,
|
package/dist/http/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ __export(http_exports, {
|
|
|
37
37
|
Query: () => Query,
|
|
38
38
|
Req: () => Req,
|
|
39
39
|
Res: () => Res,
|
|
40
|
+
UserId: () => UserId,
|
|
40
41
|
configureRoutes: () => configureRoutes,
|
|
41
42
|
createHandler: () => createHandler,
|
|
42
43
|
handleError: () => handleError,
|
|
@@ -381,6 +382,14 @@ function buildHandlerArguments(entry, ctx, getBody) {
|
|
|
381
382
|
args[meta.index] = ctx.auth;
|
|
382
383
|
break;
|
|
383
384
|
}
|
|
385
|
+
case "userId": {
|
|
386
|
+
const userId = resolveUserIdFromClaims(ctx.auth);
|
|
387
|
+
if (!userId) {
|
|
388
|
+
throw new HttpError(401, "Invalid authentication");
|
|
389
|
+
}
|
|
390
|
+
args[meta.index] = userId;
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
384
393
|
default: {
|
|
385
394
|
args[meta.index] = ctx;
|
|
386
395
|
}
|
|
@@ -467,6 +476,32 @@ function extractAuthClaims(event, entry) {
|
|
|
467
476
|
const claims = ctxV2?.authorizer?.jwt?.claims || ctxV1?.authorizer?.claims;
|
|
468
477
|
return claims ?? void 0;
|
|
469
478
|
}
|
|
479
|
+
function normalizeUserIdentifier(value) {
|
|
480
|
+
if (typeof value !== "string") {
|
|
481
|
+
return void 0;
|
|
482
|
+
}
|
|
483
|
+
const normalized = value.trim();
|
|
484
|
+
return normalized || void 0;
|
|
485
|
+
}
|
|
486
|
+
function resolveUserIdFromClaims(claims) {
|
|
487
|
+
const email = normalizeUserIdentifier(claims?.email);
|
|
488
|
+
if (email) {
|
|
489
|
+
return email.toLowerCase();
|
|
490
|
+
}
|
|
491
|
+
const userId = normalizeUserIdentifier(claims?.user_id);
|
|
492
|
+
if (userId) {
|
|
493
|
+
return userId;
|
|
494
|
+
}
|
|
495
|
+
const uid = normalizeUserIdentifier(claims?.uid);
|
|
496
|
+
if (uid) {
|
|
497
|
+
return uid;
|
|
498
|
+
}
|
|
499
|
+
const sub = normalizeUserIdentifier(claims?.sub);
|
|
500
|
+
if (sub) {
|
|
501
|
+
return sub;
|
|
502
|
+
}
|
|
503
|
+
return void 0;
|
|
504
|
+
}
|
|
470
505
|
function isHttpError(error) {
|
|
471
506
|
if (!error || typeof error !== "object") {
|
|
472
507
|
return false;
|
|
@@ -595,6 +630,9 @@ function FirebaseAuth(options2) {
|
|
|
595
630
|
function Auth() {
|
|
596
631
|
return createParameterDecorator("auth");
|
|
597
632
|
}
|
|
633
|
+
function UserId() {
|
|
634
|
+
return createParameterDecorator("userId");
|
|
635
|
+
}
|
|
598
636
|
function Body(schema) {
|
|
599
637
|
return createParameterDecorator("body", { schema });
|
|
600
638
|
}
|
|
@@ -635,6 +673,7 @@ function Res() {
|
|
|
635
673
|
Query,
|
|
636
674
|
Req,
|
|
637
675
|
Res,
|
|
676
|
+
UserId,
|
|
638
677
|
configureRoutes,
|
|
639
678
|
createHandler,
|
|
640
679
|
handleError,
|
package/dist/http/index.d.cts
CHANGED
|
@@ -38,6 +38,7 @@ declare const Head: (path?: string) => LegacyDecorator;
|
|
|
38
38
|
declare const Options: (path?: string) => LegacyDecorator;
|
|
39
39
|
declare function FirebaseAuth(options?: FirebaseAuthOptions): LegacyDecorator;
|
|
40
40
|
declare function Auth(): LegacyParameterDecorator;
|
|
41
|
+
declare function UserId(): LegacyParameterDecorator;
|
|
41
42
|
declare function Body(schema?: ZodTypeAny): LegacyParameterDecorator;
|
|
42
43
|
declare function Query(name?: string): LegacyParameterDecorator;
|
|
43
44
|
declare function Param(name?: string): LegacyParameterDecorator;
|
|
@@ -48,4 +49,4 @@ declare function Res(): LegacyParameterDecorator;
|
|
|
48
49
|
|
|
49
50
|
declare function configureRoutes(next?: RouteOptions): void;
|
|
50
51
|
|
|
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 };
|
|
52
|
+
export { Auth, Body, Delete, FirebaseAuth, FirebaseAuthOptions, Get, Head, Header, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, ResponseLike, RouteOptions, UserId, configureRoutes, createHandler, handleError, json, noContent, text };
|
package/dist/http/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ declare const Head: (path?: string) => LegacyDecorator;
|
|
|
38
38
|
declare const Options: (path?: string) => LegacyDecorator;
|
|
39
39
|
declare function FirebaseAuth(options?: FirebaseAuthOptions): LegacyDecorator;
|
|
40
40
|
declare function Auth(): LegacyParameterDecorator;
|
|
41
|
+
declare function UserId(): LegacyParameterDecorator;
|
|
41
42
|
declare function Body(schema?: ZodTypeAny): LegacyParameterDecorator;
|
|
42
43
|
declare function Query(name?: string): LegacyParameterDecorator;
|
|
43
44
|
declare function Param(name?: string): LegacyParameterDecorator;
|
|
@@ -48,4 +49,4 @@ declare function Res(): LegacyParameterDecorator;
|
|
|
48
49
|
|
|
49
50
|
declare function configureRoutes(next?: RouteOptions): void;
|
|
50
51
|
|
|
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 };
|
|
52
|
+
export { Auth, Body, Delete, FirebaseAuth, FirebaseAuthOptions, Get, Head, Header, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, ResponseLike, RouteOptions, UserId, configureRoutes, createHandler, handleError, json, noContent, text };
|
package/dist/http/index.js
CHANGED
|
@@ -16,12 +16,13 @@ import {
|
|
|
16
16
|
Query,
|
|
17
17
|
Req,
|
|
18
18
|
Res,
|
|
19
|
+
UserId,
|
|
19
20
|
createHandler,
|
|
20
21
|
handleError,
|
|
21
22
|
json,
|
|
22
23
|
noContent,
|
|
23
24
|
text
|
|
24
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-P4HUTGVQ.js";
|
|
25
26
|
import "../chunk-5OUNKYO5.js";
|
|
26
27
|
import {
|
|
27
28
|
configureRoutes
|
|
@@ -44,6 +45,7 @@ export {
|
|
|
44
45
|
Query,
|
|
45
46
|
Req,
|
|
46
47
|
Res,
|
|
48
|
+
UserId,
|
|
47
49
|
configureRoutes,
|
|
48
50
|
createHandler,
|
|
49
51
|
handleError,
|
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
Query: () => Query,
|
|
39
39
|
Req: () => Req,
|
|
40
40
|
Res: () => Res,
|
|
41
|
+
UserId: () => UserId,
|
|
41
42
|
configureRoutes: () => configureRoutes,
|
|
42
43
|
createHandler: () => createHandler,
|
|
43
44
|
handleError: () => handleError,
|
|
@@ -389,6 +390,14 @@ function buildHandlerArguments(entry, ctx, getBody) {
|
|
|
389
390
|
args[meta.index] = ctx.auth;
|
|
390
391
|
break;
|
|
391
392
|
}
|
|
393
|
+
case "userId": {
|
|
394
|
+
const userId = resolveUserIdFromClaims(ctx.auth);
|
|
395
|
+
if (!userId) {
|
|
396
|
+
throw new HttpError(401, "Invalid authentication");
|
|
397
|
+
}
|
|
398
|
+
args[meta.index] = userId;
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
392
401
|
default: {
|
|
393
402
|
args[meta.index] = ctx;
|
|
394
403
|
}
|
|
@@ -475,6 +484,32 @@ function extractAuthClaims(event, entry) {
|
|
|
475
484
|
const claims = ctxV2?.authorizer?.jwt?.claims || ctxV1?.authorizer?.claims;
|
|
476
485
|
return claims ?? void 0;
|
|
477
486
|
}
|
|
487
|
+
function normalizeUserIdentifier(value) {
|
|
488
|
+
if (typeof value !== "string") {
|
|
489
|
+
return void 0;
|
|
490
|
+
}
|
|
491
|
+
const normalized = value.trim();
|
|
492
|
+
return normalized || void 0;
|
|
493
|
+
}
|
|
494
|
+
function resolveUserIdFromClaims(claims) {
|
|
495
|
+
const email = normalizeUserIdentifier(claims?.email);
|
|
496
|
+
if (email) {
|
|
497
|
+
return email.toLowerCase();
|
|
498
|
+
}
|
|
499
|
+
const userId = normalizeUserIdentifier(claims?.user_id);
|
|
500
|
+
if (userId) {
|
|
501
|
+
return userId;
|
|
502
|
+
}
|
|
503
|
+
const uid = normalizeUserIdentifier(claims?.uid);
|
|
504
|
+
if (uid) {
|
|
505
|
+
return uid;
|
|
506
|
+
}
|
|
507
|
+
const sub = normalizeUserIdentifier(claims?.sub);
|
|
508
|
+
if (sub) {
|
|
509
|
+
return sub;
|
|
510
|
+
}
|
|
511
|
+
return void 0;
|
|
512
|
+
}
|
|
478
513
|
function isHttpError(error) {
|
|
479
514
|
if (!error || typeof error !== "object") {
|
|
480
515
|
return false;
|
|
@@ -603,6 +638,9 @@ function FirebaseAuth(options2) {
|
|
|
603
638
|
function Auth() {
|
|
604
639
|
return createParameterDecorator("auth");
|
|
605
640
|
}
|
|
641
|
+
function UserId() {
|
|
642
|
+
return createParameterDecorator("userId");
|
|
643
|
+
}
|
|
606
644
|
function Body(schema) {
|
|
607
645
|
return createParameterDecorator("body", { schema });
|
|
608
646
|
}
|
|
@@ -775,6 +813,7 @@ function getSignedHeaders(headers) {
|
|
|
775
813
|
Query,
|
|
776
814
|
Req,
|
|
777
815
|
Res,
|
|
816
|
+
UserId,
|
|
778
817
|
configureRoutes,
|
|
779
818
|
createHandler,
|
|
780
819
|
handleError,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
1
|
+
export { Auth, Body, Delete, FirebaseAuth, Get, Head, Header, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, UserId, configureRoutes, createHandler, handleError, json, noContent, text } from './http/index.cjs';
|
|
2
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-o33yWNSY.cjs';
|
|
3
3
|
export { On, publish } from './bus/index.cjs';
|
|
4
4
|
import 'aws-lambda';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
1
|
+
export { Auth, Body, Delete, FirebaseAuth, Get, Head, Header, Headers, HttpError, Options, Param, Patch, Post, Put, Query, Req, Res, UserId, configureRoutes, createHandler, handleError, json, noContent, text } from './http/index.js';
|
|
2
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-o33yWNSY.js';
|
|
3
3
|
export { On, publish } from './bus/index.js';
|
|
4
4
|
import 'aws-lambda';
|
package/dist/index.js
CHANGED
|
@@ -20,12 +20,13 @@ import {
|
|
|
20
20
|
Query,
|
|
21
21
|
Req,
|
|
22
22
|
Res,
|
|
23
|
+
UserId,
|
|
23
24
|
createHandler,
|
|
24
25
|
handleError,
|
|
25
26
|
json,
|
|
26
27
|
noContent,
|
|
27
28
|
text
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-P4HUTGVQ.js";
|
|
29
30
|
import "./chunk-5OUNKYO5.js";
|
|
30
31
|
import {
|
|
31
32
|
configureRoutes
|
|
@@ -49,6 +50,7 @@ export {
|
|
|
49
50
|
Query,
|
|
50
51
|
Req,
|
|
51
52
|
Res,
|
|
53
|
+
UserId,
|
|
52
54
|
configureRoutes,
|
|
53
55
|
createHandler,
|
|
54
56
|
handleError,
|
package/dist/infra.cjs
CHANGED
|
@@ -138,8 +138,7 @@ function wireRoutesFromManifest(manifest, opts) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
function httpApiAdapter(args) {
|
|
141
|
-
const
|
|
142
|
-
const api = args?.api ?? new aws2.ApiGatewayV2(args?.apiName ?? "HttpApi", args?.apiArgs);
|
|
141
|
+
const api = args.api;
|
|
143
142
|
const ensureJwtAuthorizer = createHttpAuthorizerManager(api);
|
|
144
143
|
const registerRoute = createRouteRegistrar(api, "ApiGatewayV2");
|
|
145
144
|
return {
|
|
@@ -149,8 +148,7 @@ function httpApiAdapter(args) {
|
|
|
149
148
|
};
|
|
150
149
|
}
|
|
151
150
|
function restApiAdapter(args) {
|
|
152
|
-
const
|
|
153
|
-
const api = args?.api ?? new aws2.ApiGateway(args?.apiName ?? "RestApi", args?.apiArgs);
|
|
151
|
+
const api = args.api;
|
|
154
152
|
const ensureJwtAuthorizer = createRestAuthorizerManager(api);
|
|
155
153
|
const registerRoute = createRouteRegistrar(api, "ApiGateway");
|
|
156
154
|
return {
|
|
@@ -166,6 +164,9 @@ function ensureFirebaseAuthorizer(firebaseRouteCount, opts) {
|
|
|
166
164
|
if (!opts.firebaseProjectId) {
|
|
167
165
|
throw new Error("firebaseProjectId is required when using @FirebaseAuth()");
|
|
168
166
|
}
|
|
167
|
+
if (!opts.ensureJwtAuthorizer) {
|
|
168
|
+
throw new Error("ensureJwtAuthorizer is required when using @FirebaseAuth()");
|
|
169
|
+
}
|
|
169
170
|
const issuer = `https://securetoken.google.com/${opts.firebaseProjectId}`;
|
|
170
171
|
return opts.ensureJwtAuthorizer("firebase", {
|
|
171
172
|
issuer,
|
package/dist/infra.d.cts
CHANGED
|
@@ -2,12 +2,6 @@ import { b as HttpMethod, f as RoutesManifest } from './types-o33yWNSY.cjs';
|
|
|
2
2
|
export { h as RoutesManifestAuth, i as RoutesManifestEvent, g as RoutesManifestRoute } from './types-o33yWNSY.cjs';
|
|
3
3
|
import 'aws-lambda';
|
|
4
4
|
|
|
5
|
-
type AwsSource = {
|
|
6
|
-
sst?: {
|
|
7
|
-
aws?: unknown;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
|
|
11
5
|
type RegisterRouteConfig = {
|
|
12
6
|
handler: unknown;
|
|
13
7
|
protected: boolean;
|
|
@@ -23,17 +17,15 @@ type EnsureJwtAuthorizer = (name: string, cfg: {
|
|
|
23
17
|
issuer: string;
|
|
24
18
|
audiences: string[];
|
|
25
19
|
}) => unknown;
|
|
26
|
-
type AdapterArgs =
|
|
27
|
-
api
|
|
28
|
-
apiName?: string;
|
|
29
|
-
apiArgs?: unknown;
|
|
20
|
+
type AdapterArgs = {
|
|
21
|
+
api: unknown;
|
|
30
22
|
};
|
|
31
|
-
declare function httpApiAdapter(args
|
|
23
|
+
declare function httpApiAdapter(args: AdapterArgs): {
|
|
32
24
|
api: unknown;
|
|
33
25
|
registerRoute: RegisterRoute;
|
|
34
26
|
ensureJwtAuthorizer: EnsureJwtAuthorizer;
|
|
35
27
|
};
|
|
36
|
-
declare function restApiAdapter(args
|
|
28
|
+
declare function restApiAdapter(args: AdapterArgs): {
|
|
37
29
|
api: unknown;
|
|
38
30
|
registerRoute: RegisterRoute;
|
|
39
31
|
ensureJwtAuthorizer: EnsureJwtAuthorizer;
|
|
@@ -41,9 +33,9 @@ declare function restApiAdapter(args?: AdapterArgs): {
|
|
|
41
33
|
|
|
42
34
|
declare function wireApiFromManifest(manifest: RoutesManifest, opts: {
|
|
43
35
|
handler: unknown;
|
|
44
|
-
firebaseProjectId
|
|
36
|
+
firebaseProjectId?: string;
|
|
45
37
|
registerRoute: RegisterRoute;
|
|
46
|
-
ensureJwtAuthorizer
|
|
38
|
+
ensureJwtAuthorizer?: EnsureJwtAuthorizer;
|
|
47
39
|
}): void;
|
|
48
40
|
declare function loadRoutesManifest(filePath: string): RoutesManifest;
|
|
49
41
|
declare function setHandlerBus(handler: unknown): void;
|
package/dist/infra.d.ts
CHANGED
|
@@ -2,12 +2,6 @@ import { b as HttpMethod, f as RoutesManifest } from './types-o33yWNSY.js';
|
|
|
2
2
|
export { h as RoutesManifestAuth, i as RoutesManifestEvent, g as RoutesManifestRoute } from './types-o33yWNSY.js';
|
|
3
3
|
import 'aws-lambda';
|
|
4
4
|
|
|
5
|
-
type AwsSource = {
|
|
6
|
-
sst?: {
|
|
7
|
-
aws?: unknown;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
|
|
11
5
|
type RegisterRouteConfig = {
|
|
12
6
|
handler: unknown;
|
|
13
7
|
protected: boolean;
|
|
@@ -23,17 +17,15 @@ type EnsureJwtAuthorizer = (name: string, cfg: {
|
|
|
23
17
|
issuer: string;
|
|
24
18
|
audiences: string[];
|
|
25
19
|
}) => unknown;
|
|
26
|
-
type AdapterArgs =
|
|
27
|
-
api
|
|
28
|
-
apiName?: string;
|
|
29
|
-
apiArgs?: unknown;
|
|
20
|
+
type AdapterArgs = {
|
|
21
|
+
api: unknown;
|
|
30
22
|
};
|
|
31
|
-
declare function httpApiAdapter(args
|
|
23
|
+
declare function httpApiAdapter(args: AdapterArgs): {
|
|
32
24
|
api: unknown;
|
|
33
25
|
registerRoute: RegisterRoute;
|
|
34
26
|
ensureJwtAuthorizer: EnsureJwtAuthorizer;
|
|
35
27
|
};
|
|
36
|
-
declare function restApiAdapter(args
|
|
28
|
+
declare function restApiAdapter(args: AdapterArgs): {
|
|
37
29
|
api: unknown;
|
|
38
30
|
registerRoute: RegisterRoute;
|
|
39
31
|
ensureJwtAuthorizer: EnsureJwtAuthorizer;
|
|
@@ -41,9 +33,9 @@ declare function restApiAdapter(args?: AdapterArgs): {
|
|
|
41
33
|
|
|
42
34
|
declare function wireApiFromManifest(manifest: RoutesManifest, opts: {
|
|
43
35
|
handler: unknown;
|
|
44
|
-
firebaseProjectId
|
|
36
|
+
firebaseProjectId?: string;
|
|
45
37
|
registerRoute: RegisterRoute;
|
|
46
|
-
ensureJwtAuthorizer
|
|
38
|
+
ensureJwtAuthorizer?: EnsureJwtAuthorizer;
|
|
47
39
|
}): void;
|
|
48
40
|
declare function loadRoutesManifest(filePath: string): RoutesManifest;
|
|
49
41
|
declare function setHandlerBus(handler: unknown): void;
|
package/dist/infra.js
CHANGED
|
@@ -108,8 +108,7 @@ function wireRoutesFromManifest(manifest, opts) {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
function httpApiAdapter(args) {
|
|
111
|
-
const
|
|
112
|
-
const api = args?.api ?? new aws2.ApiGatewayV2(args?.apiName ?? "HttpApi", args?.apiArgs);
|
|
111
|
+
const api = args.api;
|
|
113
112
|
const ensureJwtAuthorizer = createHttpAuthorizerManager(api);
|
|
114
113
|
const registerRoute = createRouteRegistrar(api, "ApiGatewayV2");
|
|
115
114
|
return {
|
|
@@ -119,8 +118,7 @@ function httpApiAdapter(args) {
|
|
|
119
118
|
};
|
|
120
119
|
}
|
|
121
120
|
function restApiAdapter(args) {
|
|
122
|
-
const
|
|
123
|
-
const api = args?.api ?? new aws2.ApiGateway(args?.apiName ?? "RestApi", args?.apiArgs);
|
|
121
|
+
const api = args.api;
|
|
124
122
|
const ensureJwtAuthorizer = createRestAuthorizerManager(api);
|
|
125
123
|
const registerRoute = createRouteRegistrar(api, "ApiGateway");
|
|
126
124
|
return {
|
|
@@ -136,6 +134,9 @@ function ensureFirebaseAuthorizer(firebaseRouteCount, opts) {
|
|
|
136
134
|
if (!opts.firebaseProjectId) {
|
|
137
135
|
throw new Error("firebaseProjectId is required when using @FirebaseAuth()");
|
|
138
136
|
}
|
|
137
|
+
if (!opts.ensureJwtAuthorizer) {
|
|
138
|
+
throw new Error("ensureJwtAuthorizer is required when using @FirebaseAuth()");
|
|
139
|
+
}
|
|
139
140
|
const issuer = `https://securetoken.google.com/${opts.firebaseProjectId}`;
|
|
140
141
|
return opts.ensureJwtAuthorizer("firebase", {
|
|
141
142
|
issuer,
|