@hot-updater/aws 0.24.4 → 0.24.6

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.
@@ -7561,7 +7561,7 @@ var SSMKeyPairManager = class {
7561
7561
 
7562
7562
  //#endregion
7563
7563
  //#region iac/templates.ts
7564
- const getConfigTemplate = (build, { sessionToken }) => {
7564
+ const getConfigTemplate = (build, { profile }) => {
7565
7565
  const storageConfig = {
7566
7566
  imports: [{
7567
7567
  pkg: "@hot-updater/aws",
@@ -7580,16 +7580,11 @@ const getConfigTemplate = (build, { sessionToken }) => {
7580
7580
  })`
7581
7581
  };
7582
7582
  let intermediate = "";
7583
- if (sessionToken) intermediate = `
7583
+ if (profile) intermediate = `
7584
7584
  const commonOptions = {
7585
7585
  bucketName: process.env.HOT_UPDATER_S3_BUCKET_NAME!,
7586
7586
  region: process.env.HOT_UPDATER_S3_REGION!,
7587
- credentials: {
7588
- accessKeyId: process.env.HOT_UPDATER_S3_ACCESS_KEY_ID!,
7589
- secretAccessKey: process.env.HOT_UPDATER_S3_SECRET_ACCESS_KEY!,
7590
- // This token may expire. For permanent use, it's recommended to use a key with S3FullAccess and CloudFrontFullAccess permission and remove this field.
7591
- sessionToken: process.env.HOT_UPDATER_S3_SESSION_TOKEN!,
7592
- },
7587
+ credentials: fromSSO({ profile: process.env.HOT_UPDATER_AWS_PROFILE! }),
7593
7588
  };`.trim();
7594
7589
  else intermediate = `
7595
7590
  const commonOptions = {
@@ -7600,7 +7595,12 @@ const commonOptions = {
7600
7595
  secretAccessKey: process.env.HOT_UPDATER_S3_SECRET_ACCESS_KEY!,
7601
7596
  },
7602
7597
  };`.trim();
7603
- return new __hot_updater_cli_tools.ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig).setIntermediateCode(intermediate).getResult();
7598
+ const builder = new __hot_updater_cli_tools.ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig);
7599
+ if (profile) builder.addImport({
7600
+ pkg: "@aws-sdk/credential-provider-sso",
7601
+ named: ["fromSSO"]
7602
+ });
7603
+ return builder.setIntermediateCode(intermediate).getResult();
7604
7604
  };
7605
7605
  const SOURCE_TEMPLATE = `// Add this to your App.tsx
7606
7606
  import { HotUpdater } from "@hot-updater/react-native";
@@ -7634,11 +7634,11 @@ const runInit = async ({ build }) => {
7634
7634
  const mode = await __hot_updater_cli_tools.p.select({
7635
7635
  message: "Select the mode to login to AWS",
7636
7636
  options: [{
7637
- label: "AWS Access Key ID & Secret Access Key (Recommend)",
7638
- value: "account"
7639
- }, {
7640
7637
  label: "AWS SSO Login",
7641
7638
  value: "sso"
7639
+ }, {
7640
+ label: "AWS Access Key ID & Secret Access Key",
7641
+ value: "account"
7642
7642
  }]
7643
7643
  });
7644
7644
  if (__hot_updater_cli_tools.p.isCancel(mode)) process.exit(1);
@@ -7648,6 +7648,7 @@ const runInit = async ({ build }) => {
7648
7648
  __hot_updater_cli_tools.p.log.message(`${__hot_updater_cli_tools.colors.blue("CloudFrontFullAccess")}: Create and update CloudFront distributions`);
7649
7649
  __hot_updater_cli_tools.p.log.message(`${__hot_updater_cli_tools.colors.blue("IAMFullAccess")}: Get or create IAM roles for Lambda@Edge`);
7650
7650
  __hot_updater_cli_tools.p.log.message(`${__hot_updater_cli_tools.colors.blue("AmazonSSMFullAccess")}: Access to SSM Parameters for storing CloudFront key pairs`);
7651
+ let ssoProfile = null;
7651
7652
  if (mode === "sso") try {
7652
7653
  const profile = await __hot_updater_cli_tools.p.text({
7653
7654
  message: "Enter the SSO profile name",
@@ -7655,6 +7656,7 @@ const runInit = async ({ build }) => {
7655
7656
  placeholder: "default"
7656
7657
  });
7657
7658
  if (__hot_updater_cli_tools.p.isCancel(profile)) process.exit(1);
7659
+ ssoProfile = profile;
7658
7660
  await execa("aws", [
7659
7661
  "sso",
7660
7662
  "login",
@@ -7764,23 +7766,24 @@ const runInit = async ({ build }) => {
7764
7766
  distributionId,
7765
7767
  accountId
7766
7768
  });
7767
- if (mode === "sso") await fs.default.promises.writeFile("hot-updater.config.ts", getConfigTemplate(build, { sessionToken: true }));
7768
- else await fs.default.promises.writeFile("hot-updater.config.ts", getConfigTemplate(build, { sessionToken: false }));
7769
- const comment = mode === "account" ? "The current key may have excessive permissions. Update it with an S3FullAccess and CloudFrontFullAccess key." : "This key was generated via SSO login and may expire. Update it with an S3FullAccess and CloudFrontFullAccess key.";
7769
+ await fs.default.promises.writeFile("hot-updater.config.ts", getConfigTemplate(build, { profile: ssoProfile }));
7770
7770
  await (0, __hot_updater_cli_tools.makeEnv)({
7771
7771
  HOT_UPDATER_S3_BUCKET_NAME: bucketName,
7772
7772
  HOT_UPDATER_S3_REGION: bucketRegion,
7773
- HOT_UPDATER_S3_ACCESS_KEY_ID: {
7774
- comment,
7775
- value: credentials.accessKeyId
7776
- },
7777
- HOT_UPDATER_S3_SECRET_ACCESS_KEY: {
7778
- comment,
7779
- value: credentials.secretAccessKey
7780
- },
7781
- ...mode === "sso" && { HOT_UPDATER_S3_SESSION_TOKEN: credentials.sessionToken },
7773
+ ...mode === "account" ? {
7774
+ HOT_UPDATER_S3_ACCESS_KEY_ID: {
7775
+ comment: "The current key may have excessive permissions. Update it with an S3FullAccess and CloudFrontFullAccess key.",
7776
+ value: credentials.accessKeyId
7777
+ },
7778
+ HOT_UPDATER_S3_SECRET_ACCESS_KEY: {
7779
+ comment: "The current key may have excessive permissions. Update it with an S3FullAccess and CloudFrontFullAccess key.",
7780
+ value: credentials.secretAccessKey
7781
+ }
7782
+ } : {},
7783
+ ...ssoProfile !== null ? { HOT_UPDATER_AWS_PROFILE: ssoProfile } : {},
7782
7784
  HOT_UPDATER_CLOUDFRONT_DISTRIBUTION_ID: distributionId
7783
7785
  });
7786
+ if (mode === "sso") await (0, __hot_updater_cli_tools.ensureInstallPackages)({ devDependencies: ["@aws-sdk/credential-provider-sso"] });
7784
7787
  __hot_updater_cli_tools.p.log.success("Generated '.env.hotupdater' file with AWS settings.");
7785
7788
  __hot_updater_cli_tools.p.log.success("Generated 'hot-updater.config.ts' file with AWS settings.");
7786
7789
  const sourceUrl = `https://${distributionDomain}/api/check-update`;
package/dist/iac/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { fromSSO } from "@aws-sdk/credential-providers";
3
- import { ConfigBuilder, colors, copyDirToTmp, createZip, getCwd, link, makeEnv, p, transformEnv, transformTemplate } from "@hot-updater/cli-tools";
3
+ import { ConfigBuilder, colors, copyDirToTmp, createZip, ensureInstallPackages, getCwd, link, makeEnv, p, transformEnv, transformTemplate } from "@hot-updater/cli-tools";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
6
6
  import { StringDecoder } from "node:string_decoder";
@@ -7535,7 +7535,7 @@ var SSMKeyPairManager = class {
7535
7535
 
7536
7536
  //#endregion
7537
7537
  //#region iac/templates.ts
7538
- const getConfigTemplate = (build, { sessionToken }) => {
7538
+ const getConfigTemplate = (build, { profile }) => {
7539
7539
  const storageConfig = {
7540
7540
  imports: [{
7541
7541
  pkg: "@hot-updater/aws",
@@ -7554,16 +7554,11 @@ const getConfigTemplate = (build, { sessionToken }) => {
7554
7554
  })`
7555
7555
  };
7556
7556
  let intermediate = "";
7557
- if (sessionToken) intermediate = `
7557
+ if (profile) intermediate = `
7558
7558
  const commonOptions = {
7559
7559
  bucketName: process.env.HOT_UPDATER_S3_BUCKET_NAME!,
7560
7560
  region: process.env.HOT_UPDATER_S3_REGION!,
7561
- credentials: {
7562
- accessKeyId: process.env.HOT_UPDATER_S3_ACCESS_KEY_ID!,
7563
- secretAccessKey: process.env.HOT_UPDATER_S3_SECRET_ACCESS_KEY!,
7564
- // This token may expire. For permanent use, it's recommended to use a key with S3FullAccess and CloudFrontFullAccess permission and remove this field.
7565
- sessionToken: process.env.HOT_UPDATER_S3_SESSION_TOKEN!,
7566
- },
7561
+ credentials: fromSSO({ profile: process.env.HOT_UPDATER_AWS_PROFILE! }),
7567
7562
  };`.trim();
7568
7563
  else intermediate = `
7569
7564
  const commonOptions = {
@@ -7574,7 +7569,12 @@ const commonOptions = {
7574
7569
  secretAccessKey: process.env.HOT_UPDATER_S3_SECRET_ACCESS_KEY!,
7575
7570
  },
7576
7571
  };`.trim();
7577
- return new ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig).setIntermediateCode(intermediate).getResult();
7572
+ const builder = new ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig);
7573
+ if (profile) builder.addImport({
7574
+ pkg: "@aws-sdk/credential-provider-sso",
7575
+ named: ["fromSSO"]
7576
+ });
7577
+ return builder.setIntermediateCode(intermediate).getResult();
7578
7578
  };
7579
7579
  const SOURCE_TEMPLATE = `// Add this to your App.tsx
7580
7580
  import { HotUpdater } from "@hot-updater/react-native";
@@ -7608,11 +7608,11 @@ const runInit = async ({ build }) => {
7608
7608
  const mode = await p.select({
7609
7609
  message: "Select the mode to login to AWS",
7610
7610
  options: [{
7611
- label: "AWS Access Key ID & Secret Access Key (Recommend)",
7612
- value: "account"
7613
- }, {
7614
7611
  label: "AWS SSO Login",
7615
7612
  value: "sso"
7613
+ }, {
7614
+ label: "AWS Access Key ID & Secret Access Key",
7615
+ value: "account"
7616
7616
  }]
7617
7617
  });
7618
7618
  if (p.isCancel(mode)) process.exit(1);
@@ -7622,6 +7622,7 @@ const runInit = async ({ build }) => {
7622
7622
  p.log.message(`${colors.blue("CloudFrontFullAccess")}: Create and update CloudFront distributions`);
7623
7623
  p.log.message(`${colors.blue("IAMFullAccess")}: Get or create IAM roles for Lambda@Edge`);
7624
7624
  p.log.message(`${colors.blue("AmazonSSMFullAccess")}: Access to SSM Parameters for storing CloudFront key pairs`);
7625
+ let ssoProfile = null;
7625
7626
  if (mode === "sso") try {
7626
7627
  const profile = await p.text({
7627
7628
  message: "Enter the SSO profile name",
@@ -7629,6 +7630,7 @@ const runInit = async ({ build }) => {
7629
7630
  placeholder: "default"
7630
7631
  });
7631
7632
  if (p.isCancel(profile)) process.exit(1);
7633
+ ssoProfile = profile;
7632
7634
  await execa("aws", [
7633
7635
  "sso",
7634
7636
  "login",
@@ -7738,23 +7740,24 @@ const runInit = async ({ build }) => {
7738
7740
  distributionId,
7739
7741
  accountId
7740
7742
  });
7741
- if (mode === "sso") await fs.promises.writeFile("hot-updater.config.ts", getConfigTemplate(build, { sessionToken: true }));
7742
- else await fs.promises.writeFile("hot-updater.config.ts", getConfigTemplate(build, { sessionToken: false }));
7743
- const comment = mode === "account" ? "The current key may have excessive permissions. Update it with an S3FullAccess and CloudFrontFullAccess key." : "This key was generated via SSO login and may expire. Update it with an S3FullAccess and CloudFrontFullAccess key.";
7743
+ await fs.promises.writeFile("hot-updater.config.ts", getConfigTemplate(build, { profile: ssoProfile }));
7744
7744
  await makeEnv({
7745
7745
  HOT_UPDATER_S3_BUCKET_NAME: bucketName,
7746
7746
  HOT_UPDATER_S3_REGION: bucketRegion,
7747
- HOT_UPDATER_S3_ACCESS_KEY_ID: {
7748
- comment,
7749
- value: credentials.accessKeyId
7750
- },
7751
- HOT_UPDATER_S3_SECRET_ACCESS_KEY: {
7752
- comment,
7753
- value: credentials.secretAccessKey
7754
- },
7755
- ...mode === "sso" && { HOT_UPDATER_S3_SESSION_TOKEN: credentials.sessionToken },
7747
+ ...mode === "account" ? {
7748
+ HOT_UPDATER_S3_ACCESS_KEY_ID: {
7749
+ comment: "The current key may have excessive permissions. Update it with an S3FullAccess and CloudFrontFullAccess key.",
7750
+ value: credentials.accessKeyId
7751
+ },
7752
+ HOT_UPDATER_S3_SECRET_ACCESS_KEY: {
7753
+ comment: "The current key may have excessive permissions. Update it with an S3FullAccess and CloudFrontFullAccess key.",
7754
+ value: credentials.secretAccessKey
7755
+ }
7756
+ } : {},
7757
+ ...ssoProfile !== null ? { HOT_UPDATER_AWS_PROFILE: ssoProfile } : {},
7756
7758
  HOT_UPDATER_CLOUDFRONT_DISTRIBUTION_ID: distributionId
7757
7759
  });
7760
+ if (mode === "sso") await ensureInstallPackages({ devDependencies: ["@aws-sdk/credential-provider-sso"] });
7758
7761
  p.log.success("Generated '.env.hotupdater' file with AWS settings.");
7759
7762
  p.log.success("Generated 'hot-updater.config.ts' file with AWS settings.");
7760
7763
  const sourceUrl = `https://${distributionDomain}/api/check-update`;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import * as _hot_updater_plugin_core0 from "@hot-updater/plugin-core";
1
+ import * as _hot_updater_plugin_core1 from "@hot-updater/plugin-core";
2
2
  import { S3ClientConfig } from "@aws-sdk/client-s3";
3
3
 
4
4
  //#region src/s3Database.d.ts
@@ -14,7 +14,7 @@ interface S3DatabaseConfig extends S3ClientConfig {
14
14
  cloudfrontDistributionId?: string;
15
15
  apiBasePath?: string;
16
16
  }
17
- declare const s3Database: (config: S3DatabaseConfig, hooks?: _hot_updater_plugin_core0.DatabasePluginHooks) => () => _hot_updater_plugin_core0.DatabasePlugin;
17
+ declare const s3Database: (config: S3DatabaseConfig, hooks?: _hot_updater_plugin_core1.DatabasePluginHooks) => () => _hot_updater_plugin_core1.DatabasePlugin;
18
18
  //#endregion
19
19
  //#region src/s3Storage.d.ts
20
20
  interface S3StorageConfig extends S3ClientConfig {
@@ -24,6 +24,6 @@ interface S3StorageConfig extends S3ClientConfig {
24
24
  */
25
25
  basePath?: string;
26
26
  }
27
- declare const s3Storage: (config: S3StorageConfig, hooks?: _hot_updater_plugin_core0.StoragePluginHooks) => () => _hot_updater_plugin_core0.StoragePlugin;
27
+ declare const s3Storage: (config: S3StorageConfig, hooks?: _hot_updater_plugin_core1.StoragePluginHooks) => () => _hot_updater_plugin_core1.StoragePlugin;
28
28
  //#endregion
29
29
  export { S3DatabaseConfig, S3StorageConfig, s3Database, s3Storage };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/aws",
3
3
  "type": "module",
4
- "version": "0.24.4",
4
+ "version": "0.24.6",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
@@ -44,9 +44,9 @@
44
44
  "execa": "9.5.2",
45
45
  "hono": "^4.6.3",
46
46
  "mime": "^4.0.4",
47
- "@hot-updater/core": "0.24.4",
48
- "@hot-updater/js": "0.24.4",
49
- "@hot-updater/test-utils": "0.24.4"
47
+ "@hot-updater/core": "0.24.6",
48
+ "@hot-updater/js": "0.24.6",
49
+ "@hot-updater/test-utils": "0.24.6"
50
50
  },
51
51
  "dependencies": {
52
52
  "@aws-sdk/client-cloudfront": "3.772.0",
@@ -59,8 +59,8 @@
59
59
  "@aws-sdk/credential-providers": "3.772.0",
60
60
  "@aws-sdk/lib-storage": "3.772.0",
61
61
  "aws-lambda": "1.0.7",
62
- "@hot-updater/cli-tools": "0.24.4",
63
- "@hot-updater/plugin-core": "0.24.4"
62
+ "@hot-updater/cli-tools": "0.24.6",
63
+ "@hot-updater/plugin-core": "0.24.6"
64
64
  },
65
65
  "scripts": {
66
66
  "build": "tsdown",