sst 2.5.2 → 2.5.3

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/bootstrap.js CHANGED
@@ -146,7 +146,7 @@ export async function bootstrapSST() {
146
146
  const fn = new Function(stack, "MetadataHandler", {
147
147
  code: Code.fromAsset(path.resolve(__dirname, "support/bootstrap-metadata-function")),
148
148
  handler: "index.handler",
149
- runtime: region?.startsWith("us-gov-") || region?.startsWith("cn-")
149
+ runtime: region?.startsWith("us-gov-")
150
150
  ? Runtime.NODEJS_16_X
151
151
  : Runtime.NODEJS_18_X,
152
152
  environment: {
@@ -69,7 +69,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
69
69
  });
70
70
  bus.subscribe("function.build.success", async (evt) => {
71
71
  const info = useFunctions().fromID(evt.properties.functionID);
72
- if (!info.enableLiveDev)
72
+ if (info.enableLiveDev === false)
73
73
  return;
74
74
  Colors.line(Colors.dim(Colors.prefix, "Built", info.handler));
75
75
  });
@@ -16,8 +16,8 @@ export function postPayload(endpoint, body) {
16
16
  req.write(JSON.stringify(body));
17
17
  req.end();
18
18
  }
19
- catch {
20
- resolve();
19
+ catch (ex) {
20
+ reject(ex);
21
21
  }
22
22
  });
23
23
  }
@@ -56,7 +56,7 @@ function notify() {
56
56
  function willNotRecord() {
57
57
  return !isEnabled() || !!process.env.SST_TELEMETRY_DISABLED;
58
58
  }
59
- function record(name, properties) {
59
+ async function record(name, properties) {
60
60
  if (willNotRecord()) {
61
61
  return Promise.resolve();
62
62
  }
@@ -65,16 +65,19 @@ function record(name, properties) {
65
65
  projectId,
66
66
  sessionId,
67
67
  };
68
- return postPayload(TELEMETRY_API, {
69
- context,
70
- environment: getEnvironmentData(),
71
- events: [
72
- {
73
- name,
74
- properties,
75
- },
76
- ],
77
- });
68
+ try {
69
+ await postPayload(TELEMETRY_API, {
70
+ context,
71
+ environment: getEnvironmentData(),
72
+ events: [
73
+ {
74
+ name,
75
+ properties,
76
+ },
77
+ ],
78
+ });
79
+ }
80
+ catch { }
78
81
  }
79
82
  function getAnonymousId() {
80
83
  const val = conf && conf.get(TELEMETRY_KEY_ID);
@@ -130,7 +130,7 @@ export declare class App extends CDKApp {
130
130
  *
131
131
  * @example
132
132
  * ```js
133
- * app.addDefaultFunctionPermissions({
133
+ * app.addDefaultFunctionEnv({
134
134
  * "MY_ENV_VAR": "my-value"
135
135
  * })
136
136
  * ```
package/constructs/App.js CHANGED
@@ -145,7 +145,7 @@ export class App extends CDKApp {
145
145
  *
146
146
  * @example
147
147
  * ```js
148
- * app.addDefaultFunctionPermissions({
148
+ * app.addDefaultFunctionEnv({
149
149
  * "MY_ENV_VAR": "my-value"
150
150
  * })
151
151
  * ```
@@ -20,6 +20,7 @@ import { RetentionDays } from "aws-cdk-lib/aws-logs";
20
20
  import { Token, Size as CDKSize, Duration as CDKDuration } from "aws-cdk-lib";
21
21
  import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
22
22
  import { StringParameter } from "aws-cdk-lib/aws-ssm";
23
+ import { useBootstrap } from "../bootstrap.js";
23
24
  const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
24
25
  const supportedRuntimes = {
25
26
  rust: CDKRuntime.PROVIDED_AL2,
@@ -159,13 +160,21 @@ export class Function extends CDKFunction {
159
160
  ...(debugOverrideProps || {}),
160
161
  });
161
162
  this.addEnvironment("SST_FUNCTION_ID", this.node.addr);
162
- this.attachPermissions([
163
- new PolicyStatement({
164
- actions: ["iot:*", "s3:*"],
165
- effect: Effect.ALLOW,
166
- resources: ["*"],
167
- }),
168
- ]);
163
+ useDeferredTasks().add(async () => {
164
+ const bootstrap = await useBootstrap();
165
+ this.attachPermissions([
166
+ new PolicyStatement({
167
+ actions: ["iot:*"],
168
+ effect: Effect.ALLOW,
169
+ resources: ["*"],
170
+ }),
171
+ new PolicyStatement({
172
+ actions: ["s3:*"],
173
+ effect: Effect.ALLOW,
174
+ resources: [`arn:aws:s3:::${bootstrap.bucket}`],
175
+ }),
176
+ ]);
177
+ });
169
178
  }
170
179
  // Handle build
171
180
  else {
package/iot.js CHANGED
@@ -52,7 +52,7 @@ export const useIOT = Context.memo(async () => {
52
52
  },
53
53
  ];
54
54
  }
55
- const parts = json.match(/.{1,100000}/g);
55
+ const parts = json.match(/.{1,50000}/g);
56
56
  if (!parts)
57
57
  return [];
58
58
  Logger.debug("Encoded iot message into", parts?.length, "parts");
@@ -1,5 +1,11 @@
1
1
  import { OauthBasicConfig } from "./oauth.js";
2
- export declare const GithubAdapter: (config: OauthBasicConfig) => () => Promise<{
2
+ import { OidcBasicConfig } from "./oidc.js";
3
+ type Config = ({
4
+ mode: "oauth";
5
+ } & OauthBasicConfig) | ({
6
+ mode: "oidc";
7
+ } & OidcBasicConfig);
8
+ export declare const GithubAdapter: (config: Config) => () => Promise<{
3
9
  type: "success";
4
10
  properties: {
5
11
  tokenset: import("openid-client").TokenSet;
@@ -14,3 +20,4 @@ export declare const GithubAdapter: (config: OauthBasicConfig) => () => Promise<
14
20
  };
15
21
  };
16
22
  }>;
23
+ export {};
@@ -9,7 +9,7 @@ const issuer = new Issuer({
9
9
  export const GithubAdapter =
10
10
  /* @__PURE__ */
11
11
  (config) => {
12
- if (config.clientSecret) {
12
+ if (config.mode === "oauth") {
13
13
  return OauthAdapter({
14
14
  issuer,
15
15
  ...config,
@@ -17,6 +17,7 @@ export const GithubAdapter =
17
17
  }
18
18
  return OidcAdapter({
19
19
  issuer,
20
+ scope: "openid email profile",
20
21
  ...config,
21
22
  });
22
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
package/project.js CHANGED
@@ -82,6 +82,16 @@ export async function initProject(globals) {
82
82
  artifacts: path.join(out, "artifacts"),
83
83
  },
84
84
  };
85
+ // Cleanup old config files
86
+ (async function () {
87
+ const files = await fs.readdir(project.paths.root);
88
+ for (const file of files) {
89
+ if (file.startsWith(".sst.config")) {
90
+ await fs.unlink(path.join(project.paths.root, file));
91
+ Logger.debug(`Removed old config file ${file}`);
92
+ }
93
+ }
94
+ })();
85
95
  ProjectContext.provide(project);
86
96
  dotenv.config({
87
97
  path: path.join(project.paths.root, `.env.${project.config.stage}`),
package/sst.mjs CHANGED
@@ -387,6 +387,15 @@ async function initProject(globals) {
387
387
  artifacts: path4.join(out, "artifacts")
388
388
  }
389
389
  };
390
+ (async function() {
391
+ const files = await fs4.readdir(project.paths.root);
392
+ for (const file2 of files) {
393
+ if (file2.startsWith(".sst.config")) {
394
+ await fs4.unlink(path4.join(project.paths.root, file2));
395
+ Logger.debug(`Removed old config file ${file2}`);
396
+ }
397
+ }
398
+ })();
390
399
  ProjectContext.provide(project);
391
400
  dotenv.config({
392
401
  path: path4.join(project.paths.root, `.env.${project.config.stage}`),
@@ -488,8 +497,8 @@ function postPayload(endpoint, body) {
488
497
  );
489
498
  req.write(JSON.stringify(body));
490
499
  req.end();
491
- } catch {
492
- resolve();
500
+ } catch (ex) {
501
+ reject(ex);
493
502
  }
494
503
  });
495
504
  }
@@ -636,7 +645,7 @@ function notify() {
636
645
  function willNotRecord() {
637
646
  return !isEnabled() || !!process.env.SST_TELEMETRY_DISABLED;
638
647
  }
639
- function record(name, properties) {
648
+ async function record(name, properties) {
640
649
  if (willNotRecord()) {
641
650
  return Promise.resolve();
642
651
  }
@@ -645,16 +654,19 @@ function record(name, properties) {
645
654
  projectId,
646
655
  sessionId
647
656
  };
648
- return postPayload(TELEMETRY_API, {
649
- context,
650
- environment: getEnvironmentData(),
651
- events: [
652
- {
653
- name,
654
- properties
655
- }
656
- ]
657
- });
657
+ try {
658
+ await postPayload(TELEMETRY_API, {
659
+ context,
660
+ environment: getEnvironmentData(),
661
+ events: [
662
+ {
663
+ name,
664
+ properties
665
+ }
666
+ ]
667
+ });
668
+ } catch {
669
+ }
658
670
  }
659
671
  function getAnonymousId() {
660
672
  const val = conf && conf.get(TELEMETRY_KEY_ID);
@@ -5211,7 +5223,7 @@ async function bootstrapSST() {
5211
5223
  path15.resolve(__dirname2, "support/bootstrap-metadata-function")
5212
5224
  ),
5213
5225
  handler: "index.handler",
5214
- runtime: region?.startsWith("us-gov-") || region?.startsWith("cn-") ? Runtime2.NODEJS_16_X : Runtime2.NODEJS_18_X,
5226
+ runtime: region?.startsWith("us-gov-") ? Runtime2.NODEJS_16_X : Runtime2.NODEJS_18_X,
5215
5227
  environment: {
5216
5228
  BUCKET_NAME: bucket.bucketName
5217
5229
  },
@@ -5777,7 +5789,7 @@ var init_iot = __esm({
5777
5789
  }
5778
5790
  ];
5779
5791
  }
5780
- const parts = json.match(/.{1,100000}/g);
5792
+ const parts = json.match(/.{1,50000}/g);
5781
5793
  if (!parts)
5782
5794
  return [];
5783
5795
  Logger.debug("Encoded iot message into", parts?.length, "parts");
@@ -6851,7 +6863,7 @@ var dev = (program2) => program2.command(
6851
6863
  });
6852
6864
  bus.subscribe("function.build.success", async (evt) => {
6853
6865
  const info = useFunctions3().fromID(evt.properties.functionID);
6854
- if (!info.enableLiveDev)
6866
+ if (info.enableLiveDev === false)
6855
6867
  return;
6856
6868
  Colors2.line(Colors2.dim(Colors2.prefix, "Built", info.handler));
6857
6869
  });