sst 2.5.7 → 2.7.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/cli/commands/secrets/load.d.ts +15 -0
- package/cli/commands/secrets/load.js +41 -0
- package/cli/commands/secrets/secrets.js +2 -0
- package/cli/commands/secrets/set.js +1 -1
- package/config.d.ts +1 -1
- package/config.js +3 -3
- package/constructs/NextjsSite.js +5 -1
- package/constructs/SsrSite.d.ts +7 -2
- package/constructs/SsrSite.js +14 -9
- package/node/api/index.d.ts +1 -4
- package/node/api/index.js +8 -9
- package/node/auth/auth.js +2 -2
- package/node/auth/index.js +1 -2
- package/node/bucket/index.js +2 -3
- package/node/config/index.js +4 -4
- package/node/event-bus/index.js +3 -3
- package/node/function/index.js +3 -3
- package/node/future/auth/adapter/link.d.ts +1 -1
- package/node/future/auth/adapter/link.js +5 -3
- package/node/future/auth/handler.js +7 -2
- package/node/future/auth/index.js +2 -3
- package/node/future/auth/session.js +3 -1
- package/node/graphql/index.d.ts +11 -38
- package/node/graphql/index.js +21 -45
- package/node/job/index.d.ts +1 -1
- package/node/job/index.js +11 -8
- package/node/kinesis-stream/index.js +3 -3
- package/node/queue/index.js +2 -3
- package/node/rds/index.js +2 -3
- package/node/site/index.js +18 -19
- package/node/table/index.js +4 -3
- package/node/topic/index.js +4 -3
- package/node/util/index.d.ts +1 -1
- package/node/util/index.js +4 -2
- package/package.json +4 -3
- package/sst.mjs +59 -4
- package/support/base-site-archiver.mjs +12 -12
- package/support/bootstrap-metadata-function/index.mjs +1409 -1345
- package/support/bridge/bridge.mjs +35 -46
- package/support/custom-resources/index.mjs +6503 -6439
- package/support/job-invoker/index.mjs +907 -90
- package/support/rds-migrator/index.mjs +16 -16
- package/support/script-function/index.mjs +907 -90
- package/support/ssr-site-function-archiver.mjs +9 -9
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="yargs" />
|
|
2
|
+
import type { Program } from "../../program.js";
|
|
3
|
+
export declare const load: (program: Program) => import("yargs").Argv<{
|
|
4
|
+
stage: string | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
profile: string | undefined;
|
|
7
|
+
} & {
|
|
8
|
+
region: string | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
verbose: boolean | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
role: string | undefined;
|
|
13
|
+
} & {
|
|
14
|
+
filename: string;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const load = (program) => program.command("load <filename>", "Loads secrets from an .env file", (yargs) => yargs.positional("filename", {
|
|
2
|
+
type: "string",
|
|
3
|
+
demandOption: true,
|
|
4
|
+
}), async (args) => {
|
|
5
|
+
const { Config } = await import("../../../config.js");
|
|
6
|
+
const { Colors } = await import("../../colors.js");
|
|
7
|
+
const { blue } = await import("colorette");
|
|
8
|
+
const { createSpinner } = await import("../../spinner.js");
|
|
9
|
+
const { parse } = await import("dotenv");
|
|
10
|
+
const fs = await import("fs/promises");
|
|
11
|
+
// Parse .env file
|
|
12
|
+
const fileContent = await fs.readFile(args.filename, "utf-8");
|
|
13
|
+
const envVars = parse(fileContent);
|
|
14
|
+
// Set secrets
|
|
15
|
+
const setting = createSpinner(` Setting secrets from "${args.filename}"`).start();
|
|
16
|
+
for (const [key, value] of Object.entries(envVars)) {
|
|
17
|
+
await Config.setSecret({ key, value });
|
|
18
|
+
}
|
|
19
|
+
setting.succeed();
|
|
20
|
+
// Restart functions & sites
|
|
21
|
+
const envNames = Object.keys(envVars);
|
|
22
|
+
const restarting = createSpinner(` Restarting all resources using ${blue(envNames.join(", "))}...`).start();
|
|
23
|
+
const { edgeSites, sites, placeholderSites, functions } = await Config.restart(envNames);
|
|
24
|
+
restarting.stop().clear();
|
|
25
|
+
const siteCount = sites.length + placeholderSites.length;
|
|
26
|
+
if (siteCount > 0) {
|
|
27
|
+
Colors.line(Colors.success(`✔ `), siteCount === 1
|
|
28
|
+
? `Reloaded ${siteCount} site`
|
|
29
|
+
: `Reloaded ${siteCount} sites`);
|
|
30
|
+
}
|
|
31
|
+
const functionCount = functions.length;
|
|
32
|
+
if (functionCount > 0) {
|
|
33
|
+
Colors.line(Colors.success(`✔ `), functionCount === 1
|
|
34
|
+
? `Reloaded ${functionCount} function`
|
|
35
|
+
: `Reloaded ${functionCount} functions`);
|
|
36
|
+
}
|
|
37
|
+
edgeSites.forEach(({ id, type }) => {
|
|
38
|
+
Colors.line(Colors.primary(`➜ `), `Redeploy the "${id}" ${type} to use the new secret`);
|
|
39
|
+
});
|
|
40
|
+
process.exit(0);
|
|
41
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { get } from "./get.js";
|
|
2
2
|
import { list } from "./list.js";
|
|
3
|
+
import { load } from "./load.js";
|
|
3
4
|
import { remove } from "./remove.js";
|
|
4
5
|
import { set } from "./set.js";
|
|
5
6
|
export function secrets(program) {
|
|
@@ -7,6 +8,7 @@ export function secrets(program) {
|
|
|
7
8
|
yargs.demandCommand(1);
|
|
8
9
|
set(yargs);
|
|
9
10
|
get(yargs);
|
|
11
|
+
load(yargs);
|
|
10
12
|
list(yargs);
|
|
11
13
|
remove(yargs);
|
|
12
14
|
return yargs;
|
|
@@ -27,7 +27,7 @@ export const set = (program) => program.command("set <name> <value>", "Set the v
|
|
|
27
27
|
setting.succeed();
|
|
28
28
|
// Restart functions & sites
|
|
29
29
|
const restarting = createSpinner(` Reloading all resources using ${blue(args.name)}...`).start();
|
|
30
|
-
const { edgeSites, sites, placeholderSites, functions } = await Config.restart(args.name);
|
|
30
|
+
const { edgeSites, sites, placeholderSites, functions } = await Config.restart([args.name]);
|
|
31
31
|
restarting.stop().clear();
|
|
32
32
|
const siteCount = sites.length + placeholderSites.length;
|
|
33
33
|
if (siteCount > 0) {
|
package/config.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export declare namespace Config {
|
|
|
46
46
|
key: string;
|
|
47
47
|
fallback?: boolean;
|
|
48
48
|
}): Promise<void>;
|
|
49
|
-
function restart(
|
|
49
|
+
function restart(keys: string[]): Promise<{
|
|
50
50
|
edgeSites: SsrSiteMetadata[];
|
|
51
51
|
sites: SsrSiteMetadata[];
|
|
52
52
|
placeholderSites: SsrSiteMetadata[];
|
package/config.js
CHANGED
|
@@ -115,7 +115,7 @@ export var Config;
|
|
|
115
115
|
}));
|
|
116
116
|
}
|
|
117
117
|
Config.removeSecret = removeSecret;
|
|
118
|
-
async function restart(
|
|
118
|
+
async function restart(keys) {
|
|
119
119
|
const metadata = await Stacks.metadata();
|
|
120
120
|
const siteData = Object.values(metadata)
|
|
121
121
|
.flat()
|
|
@@ -123,7 +123,7 @@ export var Config;
|
|
|
123
123
|
c.type === "NextjsSite" ||
|
|
124
124
|
c.type === "RemixSite" ||
|
|
125
125
|
c.type === "SolidStartSite")
|
|
126
|
-
.filter((c) => c.data.secrets.includes(key));
|
|
126
|
+
.filter((c) => keys.some((key) => c.data.secrets.includes(key)));
|
|
127
127
|
const siteDataPlaceholder = siteData.filter((c) => c.data.mode === "placeholder");
|
|
128
128
|
const siteDataEdge = siteData
|
|
129
129
|
.filter((c) => c.data.mode === "deployed")
|
|
@@ -137,7 +137,7 @@ export var Config;
|
|
|
137
137
|
.filter((c) => c.type === "Function")
|
|
138
138
|
// filter out SSR functions for sites
|
|
139
139
|
.filter((c) => !regionalSiteArns.includes(c.data.arn))
|
|
140
|
-
.filter((c) => c.data.secrets.includes(key));
|
|
140
|
+
.filter((c) => keys.some((key) => c.data.secrets.includes(key)));
|
|
141
141
|
// Restart sites
|
|
142
142
|
const restartedSites = (await Promise.all(siteDataRegional.map(async (s) => {
|
|
143
143
|
const restarted = await restartFunction(s.data.server);
|
package/constructs/NextjsSite.js
CHANGED
|
@@ -26,7 +26,7 @@ const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
|
26
26
|
export class NextjsSite extends SsrSite {
|
|
27
27
|
constructor(scope, id, props) {
|
|
28
28
|
super(scope, id, {
|
|
29
|
-
buildCommand: "npx --yes open-next
|
|
29
|
+
buildCommand: "npx --yes open-next@~1.1.0 build",
|
|
30
30
|
...props,
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -203,6 +203,7 @@ export class NextjsSite extends SsrSite {
|
|
|
203
203
|
buildServerBehaviorForRegional(serverOrigin, cachePolicy, originRequestPolicy) {
|
|
204
204
|
return {
|
|
205
205
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
206
|
+
functionAssociations: this.buildBehaviorFunctionAssociations(),
|
|
206
207
|
origin: serverOrigin,
|
|
207
208
|
allowedMethods: AllowedMethods.ALLOW_ALL,
|
|
208
209
|
cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
|
@@ -214,6 +215,7 @@ export class NextjsSite extends SsrSite {
|
|
|
214
215
|
buildServerBehaviorForEdge(functionVersion, s3Origin, cachePolicy, originRequestPolicy) {
|
|
215
216
|
return {
|
|
216
217
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
218
|
+
functionAssociations: this.buildBehaviorFunctionAssociations(),
|
|
217
219
|
origin: s3Origin,
|
|
218
220
|
allowedMethods: AllowedMethods.ALLOW_ALL,
|
|
219
221
|
cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
|
@@ -268,6 +270,7 @@ export class NextjsSite extends SsrSite {
|
|
|
268
270
|
return {
|
|
269
271
|
origin: fallbackOriginGroup,
|
|
270
272
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
273
|
+
functionAssociations: this.buildBehaviorFunctionAssociations(),
|
|
271
274
|
compress: true,
|
|
272
275
|
cachePolicy,
|
|
273
276
|
originRequestPolicy,
|
|
@@ -279,6 +282,7 @@ export class NextjsSite extends SsrSite {
|
|
|
279
282
|
const cfDistributionProps = cdk?.distribution || {};
|
|
280
283
|
return {
|
|
281
284
|
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
285
|
+
functionAssociations: this.buildBehaviorFunctionAssociations(),
|
|
282
286
|
origin: s3Origin,
|
|
283
287
|
allowedMethods: AllowedMethods.ALLOW_ALL,
|
|
284
288
|
cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Construct } from "constructs";
|
|
|
2
2
|
import { Bucket, BucketProps, IBucket } from "aws-cdk-lib/aws-s3";
|
|
3
3
|
import { Function as CdkFunction, FunctionProps } from "aws-cdk-lib/aws-lambda";
|
|
4
4
|
import { IHostedZone } from "aws-cdk-lib/aws-route53";
|
|
5
|
-
import { Distribution, ICachePolicy, BehaviorOptions, CachePolicy } from "aws-cdk-lib/aws-cloudfront";
|
|
5
|
+
import { Distribution, ICachePolicy, BehaviorOptions, CachePolicy, Function as CfFunction, FunctionEventType as CfFunctionEventType } from "aws-cdk-lib/aws-cloudfront";
|
|
6
6
|
import { ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
7
7
|
import { SSTConstruct } from "./Construct.js";
|
|
8
8
|
import { NodeJSProps, Function } from "./Function.js";
|
|
@@ -201,6 +201,7 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
201
201
|
protected serverLambdaForRegional?: CdkFunction;
|
|
202
202
|
private serverLambdaForDev?;
|
|
203
203
|
private bucket;
|
|
204
|
+
private cfFunction;
|
|
204
205
|
private distribution;
|
|
205
206
|
private hostedZone?;
|
|
206
207
|
private certificate?;
|
|
@@ -262,12 +263,16 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
262
263
|
private createFunctionPermissionsForRegional;
|
|
263
264
|
private createFunctionPermissionsForEdge;
|
|
264
265
|
private validateCloudFrontDistributionSettings;
|
|
266
|
+
private createCloudFrontFunction;
|
|
265
267
|
protected createCloudFrontDistributionForRegional(): Distribution;
|
|
266
268
|
protected createCloudFrontDistributionForEdge(): Distribution;
|
|
267
269
|
protected buildDistributionDomainNames(): string[];
|
|
268
270
|
protected buildDefaultBehaviorForRegional(): BehaviorOptions;
|
|
269
271
|
private buildDefaultBehaviorForEdge;
|
|
270
|
-
|
|
272
|
+
protected buildBehaviorFunctionAssociations(): {
|
|
273
|
+
eventType: CfFunctionEventType;
|
|
274
|
+
function: CfFunction;
|
|
275
|
+
}[];
|
|
271
276
|
private buildStaticFileBehaviors;
|
|
272
277
|
protected buildServerCachePolicy(): CachePolicy;
|
|
273
278
|
protected buildServerOriginRequestPolicy(): import("aws-cdk-lib/aws-cloudfront").IOriginRequestPolicy;
|
package/constructs/SsrSite.js
CHANGED
|
@@ -49,6 +49,7 @@ export class SsrSite extends Construct {
|
|
|
49
49
|
serverLambdaForRegional;
|
|
50
50
|
serverLambdaForDev;
|
|
51
51
|
bucket;
|
|
52
|
+
cfFunction;
|
|
52
53
|
distribution;
|
|
53
54
|
hostedZone;
|
|
54
55
|
certificate;
|
|
@@ -73,7 +74,7 @@ export class SsrSite extends Construct {
|
|
|
73
74
|
useSites().add(id, this.constructor.name, this.props);
|
|
74
75
|
if (this.doNotDeploy) {
|
|
75
76
|
// @ts-ignore
|
|
76
|
-
this.bucket = this.distribution = null;
|
|
77
|
+
this.cfFunction = this.bucket = this.distribution = null;
|
|
77
78
|
this.serverLambdaForDev = this.createFunctionForDev();
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
@@ -101,6 +102,7 @@ export class SsrSite extends Construct {
|
|
|
101
102
|
const s3deployCR = this.createS3Deployment(cliLayer, assets, assetFileOptions);
|
|
102
103
|
// Create CloudFront
|
|
103
104
|
this.validateCloudFrontDistributionSettings();
|
|
105
|
+
this.cfFunction = this.createCloudFrontFunction();
|
|
104
106
|
this.distribution = this.props.edge
|
|
105
107
|
? this.createCloudFrontDistributionForEdge()
|
|
106
108
|
: this.createCloudFrontDistributionForRegional();
|
|
@@ -458,6 +460,16 @@ export class SsrSite extends Construct {
|
|
|
458
460
|
throw new Error(`Do not configure the "cfDistribution.domainNames". Use the "customDomain" to configure the domain name.`);
|
|
459
461
|
}
|
|
460
462
|
}
|
|
463
|
+
createCloudFrontFunction() {
|
|
464
|
+
return new CfFunction(this, "CloudFrontFunction", {
|
|
465
|
+
code: CfFunctionCode.fromInline(`
|
|
466
|
+
function handler(event) {
|
|
467
|
+
var request = event.request;
|
|
468
|
+
request.headers["x-forwarded-host"] = request.headers.host;
|
|
469
|
+
return request;
|
|
470
|
+
}`),
|
|
471
|
+
});
|
|
472
|
+
}
|
|
461
473
|
createCloudFrontDistributionForRegional() {
|
|
462
474
|
const { cdk } = this.props;
|
|
463
475
|
const cfDistributionProps = cdk?.distribution || {};
|
|
@@ -560,14 +572,7 @@ export class SsrSite extends Construct {
|
|
|
560
572
|
return [
|
|
561
573
|
{
|
|
562
574
|
eventType: CfFunctionEventType.VIEWER_REQUEST,
|
|
563
|
-
function:
|
|
564
|
-
code: CfFunctionCode.fromInline(`
|
|
565
|
-
function handler(event) {
|
|
566
|
-
var request = event.request;
|
|
567
|
-
request.headers["x-forwarded-host"] = request.headers.host;
|
|
568
|
-
return request;
|
|
569
|
-
}`),
|
|
570
|
-
}),
|
|
575
|
+
function: this.cfFunction,
|
|
571
576
|
},
|
|
572
577
|
];
|
|
573
578
|
}
|
package/node/api/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node/url.js" />
|
|
3
|
-
/// <reference types=".pnpm/@types+node@17.0.45/node_modules/@types/node/url.js" />
|
|
4
1
|
import { Handler } from "../../context/handler.js";
|
|
5
2
|
import { APIGatewayProxyStructuredResultV2 } from "aws-lambda";
|
|
6
3
|
export interface ApiResources {
|
|
@@ -31,7 +28,7 @@ export declare const useCookies: () => {
|
|
|
31
28
|
export declare function useCookie(name: string): string | undefined;
|
|
32
29
|
export declare const useBody: () => string | undefined;
|
|
33
30
|
export declare const useJsonBody: () => any;
|
|
34
|
-
export declare const useFormData: () =>
|
|
31
|
+
export declare const useFormData: () => URLSearchParams | undefined;
|
|
35
32
|
export declare const usePath: () => string[];
|
|
36
33
|
interface CookieOptions {
|
|
37
34
|
expires?: Date;
|
package/node/api/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { createProxy
|
|
1
|
+
import { createProxy } from "../util/index.js";
|
|
2
2
|
import { Context } from "../../context/context.js";
|
|
3
3
|
import { useEvent, Handler } from "../../context/handler.js";
|
|
4
|
-
export const Api = createProxy("Api");
|
|
5
|
-
export const AppSyncApi =
|
|
6
|
-
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Object.assign(WebSocketApi, getVariables("WebSocketApi"));
|
|
4
|
+
export const Api = /* @__PURE__ */ createProxy("Api");
|
|
5
|
+
export const AppSyncApi =
|
|
6
|
+
/* @__PURE__ */ createProxy("AppSyncApi");
|
|
7
|
+
export const ApiGatewayV1Api =
|
|
8
|
+
/* @__PURE__ */ createProxy("ApiGatewayV1Api");
|
|
9
|
+
export const WebSocketApi =
|
|
10
|
+
/* @__PURE__ */ createProxy("WebSocketApi");
|
|
12
11
|
/**
|
|
13
12
|
* Create a new api handler that can be used to create an authenticated session.
|
|
14
13
|
*
|
package/node/auth/auth.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getVariables2 } from "../util/index.js";
|
|
2
2
|
import { Handler } from "../../context/handler.js";
|
|
3
3
|
import { useDomainName, usePath } from "../api/index.js";
|
|
4
4
|
const className = "Auth";
|
|
5
5
|
// Each function can only be attached to one Auth construct, so we can
|
|
6
6
|
// assume there is only one entry in authData.
|
|
7
|
-
const authData =
|
|
7
|
+
const authData = getVariables2(className);
|
|
8
8
|
const authValues = Object.values(authData);
|
|
9
9
|
let prefix;
|
|
10
10
|
let publicKey;
|
package/node/auth/index.js
CHANGED
|
@@ -8,6 +8,5 @@ export * from "./adapter/github.js";
|
|
|
8
8
|
export * from "./adapter/oidc.js";
|
|
9
9
|
export * from "./adapter/oauth.js";
|
|
10
10
|
export * from "./adapter/link.js";
|
|
11
|
-
import { createProxy
|
|
11
|
+
import { createProxy } from "../util/index.js";
|
|
12
12
|
export const Auth = createProxy("Auth");
|
|
13
|
-
Object.assign(Auth, await getVariables("Auth"));
|
package/node/bucket/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { createProxy
|
|
2
|
-
export const Bucket = createProxy("Bucket");
|
|
3
|
-
Object.assign(Bucket, getVariables("Bucket"));
|
|
1
|
+
import { createProxy } from "../util/index.js";
|
|
2
|
+
export const Bucket = /* @__PURE__ */ createProxy("Bucket");
|
package/node/config/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createProxy,
|
|
2
|
-
export const Config = createProxy("Config");
|
|
1
|
+
import { createProxy, getVariables2 } from "../util/index.js";
|
|
2
|
+
export const Config = /* @__PURE__ */ createProxy("Config");
|
|
3
3
|
const metadata = parseMetadataEnvironment();
|
|
4
|
-
const parameters = flattenValues(
|
|
5
|
-
const secrets = flattenValues(
|
|
4
|
+
const parameters = flattenValues(getVariables2("Parameter"));
|
|
5
|
+
const secrets = flattenValues(getVariables2("Secret"));
|
|
6
6
|
Object.assign(Config, metadata, parameters, secrets);
|
|
7
7
|
///////////////
|
|
8
8
|
// Functions
|
package/node/event-bus/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createProxy
|
|
2
|
-
export const EventBus =
|
|
3
|
-
|
|
1
|
+
import { createProxy } from "../util/index.js";
|
|
2
|
+
export const EventBus =
|
|
3
|
+
/* @__PURE__ */ createProxy("EventBus");
|
package/node/function/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createProxy
|
|
2
|
-
export const Function =
|
|
3
|
-
|
|
1
|
+
import { createProxy } from "../util/index.js";
|
|
2
|
+
export const Function =
|
|
3
|
+
/* @__PURE__ */ createProxy("Function");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIGatewayProxyStructuredResultV2 } from "aws-lambda";
|
|
2
2
|
export declare function LinkAdapter(config: {
|
|
3
3
|
onLink: (link: string, claims: Record<string, any>) => Promise<APIGatewayProxyStructuredResultV2>;
|
|
4
|
-
onError: () => Promise<APIGatewayProxyStructuredResultV2>;
|
|
4
|
+
onError: (error: any) => Promise<APIGatewayProxyStructuredResultV2>;
|
|
5
5
|
}): () => Promise<{
|
|
6
6
|
type: "step";
|
|
7
7
|
properties: APIGatewayProxyStructuredResultV2;
|
|
@@ -4,6 +4,8 @@ import { useDomainName, usePathParam, useQueryParam, useQueryParams, } from "../
|
|
|
4
4
|
export function LinkAdapter(config) {
|
|
5
5
|
// @ts-expect-error
|
|
6
6
|
const key = Config[process.env.AUTH_ID + "PrivateKey"];
|
|
7
|
+
// @ts-expect-error
|
|
8
|
+
const publicKey = Config[process.env.AUTH_ID + "PublicKey"];
|
|
7
9
|
const signer = createSigner({
|
|
8
10
|
expiresIn: 1000 * 60 * 10,
|
|
9
11
|
key,
|
|
@@ -28,7 +30,7 @@ export function LinkAdapter(config) {
|
|
|
28
30
|
try {
|
|
29
31
|
const verifier = createVerifier({
|
|
30
32
|
algorithms: ["RS512"],
|
|
31
|
-
key,
|
|
33
|
+
key: publicKey,
|
|
32
34
|
});
|
|
33
35
|
const jwt = verifier(token);
|
|
34
36
|
return {
|
|
@@ -36,10 +38,10 @@ export function LinkAdapter(config) {
|
|
|
36
38
|
properties: jwt,
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
|
-
catch {
|
|
41
|
+
catch (ex) {
|
|
40
42
|
return {
|
|
41
43
|
type: "step",
|
|
42
|
-
properties: await config.onError(),
|
|
44
|
+
properties: await config.onError(ex),
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
47
|
}
|
|
@@ -167,10 +167,12 @@ export function AuthHandler(input) {
|
|
|
167
167
|
...useQueryParams(),
|
|
168
168
|
};
|
|
169
169
|
if (response_type === "token") {
|
|
170
|
+
const location = new URL(redirect_uri);
|
|
171
|
+
location.hash = `access_token=${token}&state=${state || ""}`;
|
|
170
172
|
return {
|
|
171
173
|
statusCode: 302,
|
|
172
174
|
headers: {
|
|
173
|
-
Location:
|
|
175
|
+
Location: location.href,
|
|
174
176
|
},
|
|
175
177
|
};
|
|
176
178
|
}
|
|
@@ -187,10 +189,13 @@ export function AuthHandler(input) {
|
|
|
187
189
|
redirect_uri,
|
|
188
190
|
token: token,
|
|
189
191
|
});
|
|
192
|
+
const location = new URL(redirect_uri);
|
|
193
|
+
location.searchParams.set("code", code);
|
|
194
|
+
location.searchParams.set("state", state || "");
|
|
190
195
|
return {
|
|
191
196
|
statusCode: 302,
|
|
192
197
|
headers: {
|
|
193
|
-
Location:
|
|
198
|
+
Location: location.href,
|
|
194
199
|
},
|
|
195
200
|
};
|
|
196
201
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { createProxy
|
|
2
|
-
export const Auth = createProxy("Auth");
|
|
3
|
-
Object.assign(Auth, getVariables("Auth"));
|
|
1
|
+
import { createProxy } from "../../util/index.js";
|
|
2
|
+
export const Auth = /* @__PURE__ */ createProxy("Auth");
|
|
4
3
|
export * from "./adapter/oidc.js";
|
|
5
4
|
export * from "./adapter/google.js";
|
|
6
5
|
export * from "./adapter/link.js";
|
package/node/graphql/index.d.ts
CHANGED
|
@@ -1,42 +1,15 @@
|
|
|
1
|
-
import { Context } from "aws-lambda";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
formatPayload?: (params: FormatPayloadParams<C, any>) => any;
|
|
10
|
-
/**
|
|
11
|
-
* This function specifies the ctx object passed to the GraphQL resolver. This is usually not needed
|
|
12
|
-
*/
|
|
13
|
-
context?: (request: {
|
|
14
|
-
event: APIGatewayProxyEventV2;
|
|
15
|
-
context: Context;
|
|
16
|
-
execution: ExecutionContext;
|
|
17
|
-
}) => Promise<C>;
|
|
18
|
-
/**
|
|
19
|
-
* The GraphQL schema to be executed
|
|
20
|
-
*/
|
|
21
|
-
schema: GraphQLSchema;
|
|
22
|
-
/**
|
|
23
|
-
* Override the GraphQL execute function, sometimes used by plugins
|
|
24
|
-
*/
|
|
25
|
-
execute?: ProcessRequestOptions<any, any>["execute"];
|
|
26
|
-
/**
|
|
27
|
-
* Disable introspection for production
|
|
28
|
-
*/
|
|
29
|
-
disableIntrospection?: boolean;
|
|
30
|
-
}
|
|
31
|
-
export declare function GraphQLHandler<C>(config: GraphQLHandlerConfig<C>): (event: APIGatewayProxyEventV2, context: Context) => Promise<{
|
|
32
|
-
statusCode: any;
|
|
33
|
-
body: string;
|
|
1
|
+
import { APIGatewayProxyEventV2, Context } from "aws-lambda";
|
|
2
|
+
import { YogaServerOptions } from "graphql-yoga";
|
|
3
|
+
type ServerContext = {
|
|
4
|
+
event: APIGatewayProxyEventV2;
|
|
5
|
+
context: Context;
|
|
6
|
+
};
|
|
7
|
+
export declare function GraphQLHandler<UserContext extends {}>(options: YogaServerOptions<ServerContext, UserContext>): (event: APIGatewayProxyEventV2, context: Context) => Promise<{
|
|
8
|
+
statusCode: number;
|
|
34
9
|
headers: {
|
|
35
|
-
[k: string]:
|
|
10
|
+
[k: string]: string;
|
|
36
11
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
body?: undefined;
|
|
40
|
-
headers?: undefined;
|
|
12
|
+
body: string;
|
|
13
|
+
isBase64Encoded: boolean;
|
|
41
14
|
}>;
|
|
42
15
|
export {};
|
package/node/graphql/index.js
CHANGED
|
@@ -1,53 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getGraphQLParameters, processRequest,
|
|
3
|
-
// @ts-expect-error
|
|
4
|
-
} from "graphql-helix";
|
|
1
|
+
import { createYoga } from "graphql-yoga";
|
|
5
2
|
import { Handler, useEvent, useLambdaContext } from "../../context/handler.js";
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export function GraphQLHandler(options) {
|
|
4
|
+
const yoga = createYoga(options);
|
|
8
5
|
return Handler("api", async () => {
|
|
6
|
+
const event = useEvent("api");
|
|
7
|
+
const parameters = new URLSearchParams(event.queryStringParameters || {}).toString();
|
|
8
|
+
const url = `${event.rawPath}?${parameters}`;
|
|
9
9
|
const request = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
method: event.requestContext.http.method,
|
|
11
|
+
headers: event.headers,
|
|
12
|
+
body: event.body
|
|
13
|
+
? Buffer.from(event.body, event.isBase64Encoded ? "base64" : "utf8")
|
|
14
|
+
: undefined,
|
|
14
15
|
};
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
query,
|
|
22
|
-
variables,
|
|
23
|
-
request,
|
|
24
|
-
validationRules,
|
|
25
|
-
execute: config.execute,
|
|
26
|
-
schema: config.schema,
|
|
27
|
-
formatPayload: config.formatPayload,
|
|
28
|
-
// @ts-expect-error
|
|
29
|
-
contextFactory: async (execution) => {
|
|
30
|
-
if (config.context) {
|
|
31
|
-
return config.context({
|
|
32
|
-
event: useEvent("api"),
|
|
33
|
-
context: useLambdaContext(),
|
|
34
|
-
execution,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return;
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
if (result.type === "RESPONSE") {
|
|
41
|
-
return {
|
|
42
|
-
statusCode: result.status,
|
|
43
|
-
body: JSON.stringify(result.payload),
|
|
44
|
-
headers: Object.fromEntries(
|
|
45
|
-
// @ts-expect-error
|
|
46
|
-
result.headers.map((h) => [h.name, h.value])),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
16
|
+
const serverContext = {
|
|
17
|
+
event,
|
|
18
|
+
context: useLambdaContext(),
|
|
19
|
+
};
|
|
20
|
+
const response = await yoga.fetch(url, request, serverContext);
|
|
21
|
+
const responseHeaders = Object.fromEntries(response.headers.entries());
|
|
49
22
|
return {
|
|
50
|
-
statusCode:
|
|
23
|
+
statusCode: response.status,
|
|
24
|
+
headers: responseHeaders,
|
|
25
|
+
body: await response.text(),
|
|
26
|
+
isBase64Encoded: false,
|
|
51
27
|
};
|
|
52
28
|
});
|
|
53
29
|
}
|
package/node/job/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare function JobControl<Name extends keyof JobResources>(name: Name): {
|
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```ts
|
|
20
|
-
* declare module "
|
|
20
|
+
* declare module "sst/node/job" {
|
|
21
21
|
* export interface JobTypes {
|
|
22
22
|
* MyJob: {
|
|
23
23
|
* title: string;
|
package/node/job/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { createProxy,
|
|
1
|
+
import { createProxy, getVariables2 } from "../util/index.js";
|
|
2
2
|
import { InvokeCommand, LambdaClient } from "@aws-sdk/client-lambda";
|
|
3
3
|
const lambda = new LambdaClient({});
|
|
4
|
-
export const Job =
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export const Job = /* @__PURE__ */ (() => {
|
|
5
|
+
const result = createProxy("Job");
|
|
6
|
+
const vars = getVariables2("Job");
|
|
7
|
+
Object.keys(vars).forEach((name) => {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
result[name] = JobControl(name);
|
|
10
|
+
});
|
|
11
|
+
return result;
|
|
12
|
+
})();
|
|
10
13
|
function JobControl(name) {
|
|
11
14
|
return {
|
|
12
15
|
async run(props) {
|
|
@@ -31,7 +34,7 @@ function JobControl(name) {
|
|
|
31
34
|
*
|
|
32
35
|
* @example
|
|
33
36
|
* ```ts
|
|
34
|
-
* declare module "
|
|
37
|
+
* declare module "sst/node/job" {
|
|
35
38
|
* export interface JobTypes {
|
|
36
39
|
* MyJob: {
|
|
37
40
|
* title: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createProxy
|
|
2
|
-
export const KinesisStream =
|
|
3
|
-
|
|
1
|
+
import { createProxy } from "../util/index.js";
|
|
2
|
+
export const KinesisStream =
|
|
3
|
+
/* @__PURE__ */ createProxy("KinesisStream");
|
package/node/queue/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { createProxy
|
|
2
|
-
export const Queue = createProxy("Queue");
|
|
3
|
-
Object.assign(Queue, getVariables("Queue"));
|
|
1
|
+
import { createProxy } from "../util/index.js";
|
|
2
|
+
export const Queue = /* @__PURE__ */ createProxy("Queue");
|
package/node/rds/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { createProxy
|
|
2
|
-
export const RDS = createProxy("RDS");
|
|
3
|
-
Object.assign(RDS, getVariables("RDS"));
|
|
1
|
+
import { createProxy } from "../util/index.js";
|
|
2
|
+
export const RDS = /* @__PURE__ */ createProxy("RDS");
|