@hot-updater/aws 1.2.0-rc.3 → 1.2.0-rc.5

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.
@@ -6774,7 +6774,8 @@ const initProvider = {
6774
6774
  help: "Existing CloudFront distribution ID",
6775
6775
  optional: true
6776
6776
  }
6777
- }
6777
+ },
6778
+ secrets: ["HOT_UPDATER_S3_ACCESS_KEY_ID", "HOT_UPDATER_S3_SECRET_ACCESS_KEY"]
6778
6779
  };
6779
6780
  //#endregion
6780
6781
  //#region iac/regionLocationMap.ts
@@ -8416,7 +8417,16 @@ var SSMKeyPairManager = class {
8416
8417
  };
8417
8418
  //#endregion
8418
8419
  //#region iac/templates.ts
8419
- const getConfigScaffold = (build, authMode) => {
8420
+ /**
8421
+ * The config init writes. With the `resources` init set up, it names them,
8422
+ * and an account's access keys are read with `secretEnv`, from the
8423
+ * environment and `.env.hotupdater`, then the config's `secrets` adapter.
8424
+ * Without them, as the agent scaffold writes it, it reads every value from
8425
+ * the environment. A profile or SSO sign-in is each person's own.
8426
+ */
8427
+ const getConfigScaffold = (build, authMode, resources) => {
8428
+ const value = (envKey, resolved) => resolved === void 0 ? `process.env.${envKey}!` : JSON.stringify(resolved);
8429
+ const region = value("HOT_UPDATER_S3_REGION", resources?.region);
8420
8430
  const storageConfig = {
8421
8431
  imports: [{
8422
8432
  pkg: "@hot-updater/aws",
@@ -8424,7 +8434,7 @@ const getConfigScaffold = (build, authMode) => {
8424
8434
  }],
8425
8435
  configString: `s3Storage({
8426
8436
  ...awsOptions,
8427
- bucketName: process.env.HOT_UPDATER_S3_BUCKET_NAME!,
8437
+ bucketName: ${value("HOT_UPDATER_S3_BUCKET_NAME", resources?.bucketName)},
8428
8438
  })`
8429
8439
  };
8430
8440
  const databaseConfig = {
@@ -8434,8 +8444,8 @@ const getConfigScaffold = (build, authMode) => {
8434
8444
  }],
8435
8445
  configString: `dynamoDB({
8436
8446
  ...awsOptions,
8437
- tableName: process.env.HOT_UPDATER_DYNAMODB_TABLE_NAME!,
8438
- cloudfrontDistributionId: process.env.HOT_UPDATER_CLOUDFRONT_DISTRIBUTION_ID!,
8447
+ tableName: ${value("HOT_UPDATER_DYNAMODB_TABLE_NAME", resources?.tableName)},
8448
+ cloudfrontDistributionId: ${value("HOT_UPDATER_CLOUDFRONT_DISTRIBUTION_ID", resources?.cloudfrontDistributionId)},
8439
8449
  })`
8440
8450
  };
8441
8451
  let helperStatements;
@@ -8447,7 +8457,7 @@ const getConfigScaffold = (build, authMode) => {
8447
8457
  replaceIncompatibleProperties: ["credentials"],
8448
8458
  code: `
8449
8459
  const awsOptions = {
8450
- region: process.env.HOT_UPDATER_S3_REGION!,
8460
+ region: ${region},
8451
8461
  credentials: fromSSO({ profile: process.env.HOT_UPDATER_AWS_PROFILE! }),
8452
8462
  };`.trim()
8453
8463
  }];
@@ -8459,28 +8469,40 @@ const awsOptions = {
8459
8469
  replaceIncompatibleProperties: ["credentials"],
8460
8470
  code: authMode.profile ? `
8461
8471
  const awsOptions = {
8462
- region: process.env.HOT_UPDATER_S3_REGION!,
8472
+ region: ${region},
8463
8473
  credentials: fromIni({ profile: process.env.HOT_UPDATER_AWS_PROFILE! }),
8464
8474
  };`.trim() : `
8465
8475
  const awsOptions = {
8466
- region: process.env.HOT_UPDATER_S3_REGION!,
8476
+ region: ${region},
8467
8477
  credentials: fromNodeProviderChain(),
8468
8478
  };`.trim()
8469
8479
  }];
8470
8480
  break;
8471
- case "account": helperStatements = [{
8472
- name: "awsOptions",
8473
- strategy: "merge-object",
8474
- replaceIncompatibleProperties: ["credentials"],
8475
- code: `
8481
+ case "account":
8482
+ helperStatements = [{
8483
+ name: "awsOptions",
8484
+ strategy: "merge-object",
8485
+ replaceIncompatibleProperties: ["credentials"],
8486
+ code: resources === void 0 ? `
8476
8487
  const awsOptions = {
8477
- region: process.env.HOT_UPDATER_S3_REGION!,
8488
+ region: ${region},
8478
8489
  credentials: {
8479
8490
  accessKeyId: process.env.HOT_UPDATER_S3_ACCESS_KEY_ID!,
8480
8491
  secretAccessKey: process.env.HOT_UPDATER_S3_SECRET_ACCESS_KEY!,
8481
8492
  },
8493
+ };`.trim() : `
8494
+ const awsOptions = {
8495
+ region: ${region},
8496
+ credentials: async () => {
8497
+ const env = await deploySecrets();
8498
+ return {
8499
+ accessKeyId: env.HOT_UPDATER_S3_ACCESS_KEY_ID,
8500
+ secretAccessKey: env.HOT_UPDATER_S3_SECRET_ACCESS_KEY,
8501
+ };
8502
+ },
8482
8503
  };`.trim()
8483
- }];
8504
+ }];
8505
+ if (resources !== void 0) helperStatements.unshift((0, _hot_updater_cli_tools.secretEnvHelper)("deploySecrets", ["HOT_UPDATER_S3_ACCESS_KEY_ID", "HOT_UPDATER_S3_SECRET_ACCESS_KEY"]));
8484
8506
  }
8485
8507
  const builder = new _hot_updater_cli_tools.ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig).setPlugins({
8486
8508
  imports: [{
@@ -8500,9 +8522,15 @@ const awsOptions = {
8500
8522
  named: ["fromSSO"]
8501
8523
  });
8502
8524
  break;
8503
- case "local": builder.addImport({
8504
- pkg: "@aws-sdk/credential-providers",
8505
- named: [authMode.profile ? "fromIni" : "fromNodeProviderChain"]
8525
+ case "local":
8526
+ builder.addImport({
8527
+ pkg: "@aws-sdk/credential-providers",
8528
+ named: [authMode.profile ? "fromIni" : "fromNodeProviderChain"]
8529
+ });
8530
+ break;
8531
+ case "account": if (resources !== void 0) builder.addImport({
8532
+ pkg: "hot-updater",
8533
+ named: ["secretEnv"]
8506
8534
  });
8507
8535
  }
8508
8536
  return (0, _hot_updater_cli_tools.createHotUpdaterConfigScaffoldFromBuilder)(builder, { helperStatements });
@@ -8528,9 +8556,9 @@ const prepareDynamoDBDeployment = async (input) => {
8528
8556
  (0, _hot_updater_server_plugins.remoteConfig)()
8529
8557
  ]);
8530
8558
  };
8531
- const runInit = async ({ build, envFile }) => {
8559
+ const runInit = async ({ build, envFile, secretsEnv }) => {
8532
8560
  const nonInteractive = envFile !== void 0;
8533
- const initEnvSources = await (0, _hot_updater_cli_tools.readHotUpdaterInitEnv)(process.cwd(), envFile);
8561
+ const initEnvSources = await (0, _hot_updater_cli_tools.readHotUpdaterInitEnv)(process.cwd(), envFile, secretsEnv);
8534
8562
  const { managedEnv } = initEnvSources;
8535
8563
  const providerEnv = (0, _hot_updater_cli_tools.getHotUpdaterInitInputEnv)(initEnvSources, nonInteractive);
8536
8564
  const savedInputs = resolveAwsInitInputs(providerEnv);
@@ -8739,7 +8767,12 @@ const runInit = async ({ build, envFile }) => {
8739
8767
  if (mode === "sso") await (0, _hot_updater_cli_tools.ensureInstallPackages)({ devDependencies: ["@aws-sdk/credential-provider-sso"] });
8740
8768
  else if (mode === "local-session" || mode === "shared-profile") await (0, _hot_updater_cli_tools.ensureInstallPackages)({ devDependencies: ["@aws-sdk/credential-providers"] });
8741
8769
  _hot_updater_cli_tools.p.log.success("Generated '.env.hotupdater' file with AWS settings.");
8742
- await (0, _hot_updater_cli_tools.writeHotUpdaterFiles)(getConfigScaffold(build, configAuthMode), {
8770
+ await (0, _hot_updater_cli_tools.writeHotUpdaterFiles)(getConfigScaffold(build, configAuthMode, {
8771
+ region: bucketRegion,
8772
+ bucketName,
8773
+ tableName: resolvedDynamoDBTableName,
8774
+ cloudfrontDistributionId: distributionId
8775
+ }), {
8743
8776
  cwd: process.cwd(),
8744
8777
  settings: "AWS"
8745
8778
  });
@@ -206,6 +206,7 @@ declare const initProvider: {
206
206
  readonly optional: true;
207
207
  };
208
208
  };
209
+ readonly secrets: readonly ["HOT_UPDATER_S3_ACCESS_KEY_ID", "HOT_UPDATER_S3_SECRET_ACCESS_KEY"];
209
210
  };
210
211
  //#endregion
211
212
  //#region iac/index.d.ts
@@ -218,6 +219,6 @@ declare const prepareDynamoDBDeployment: (input: {
218
219
  readonly region: string;
219
220
  readonly tableName: string;
220
221
  }) => Promise<void>;
221
- declare const runInit: ({ build, envFile }: RunInitOptions) => Promise<void>;
222
+ declare const runInit: ({ build, envFile, secretsEnv }: RunInitOptions) => Promise<void>;
222
223
  //#endregion
223
224
  export { LAMBDA_EDGE_TRUST_POLICY, buildDynamoDBBackupInput, buildDynamoDBCreateTableInput, buildDynamoDBPolicy, buildDynamoDBSchemaSettingsInput, buildDynamoDBTimeToLiveInput, buildS3Policy, buildSsmPolicy, initProvider, prepareDynamoDBDeployment, runInit };
@@ -206,6 +206,7 @@ declare const initProvider: {
206
206
  readonly optional: true;
207
207
  };
208
208
  };
209
+ readonly secrets: readonly ["HOT_UPDATER_S3_ACCESS_KEY_ID", "HOT_UPDATER_S3_SECRET_ACCESS_KEY"];
209
210
  };
210
211
  //#endregion
211
212
  //#region iac/index.d.ts
@@ -218,6 +219,6 @@ declare const prepareDynamoDBDeployment: (input: {
218
219
  readonly region: string;
219
220
  readonly tableName: string;
220
221
  }) => Promise<void>;
221
- declare const runInit: ({ build, envFile }: RunInitOptions) => Promise<void>;
222
+ declare const runInit: ({ build, envFile, secretsEnv }: RunInitOptions) => Promise<void>;
222
223
  //#endregion
223
224
  export { LAMBDA_EDGE_TRUST_POLICY, buildDynamoDBBackupInput, buildDynamoDBCreateTableInput, buildDynamoDBPolicy, buildDynamoDBSchemaSettingsInput, buildDynamoDBTimeToLiveInput, buildS3Policy, buildSsmPolicy, initProvider, prepareDynamoDBDeployment, runInit };
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from "node:module";
2
- import { ConfigBuilder, InitError, MissingInitInputsError, assembleServer, assertInfrastructureGenerationAtUrl, assertInfrastructureGenerationPayload, assertInitProviderInputs, colors, confirmInitInputPersistence, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, createZip, ensureInstallPackages, getCwd, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveInitProviderInput, transformEnv, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
2
+ import { ConfigBuilder, InitError, MissingInitInputsError, assembleServer, assertInfrastructureGenerationAtUrl, assertInfrastructureGenerationPayload, assertInitProviderInputs, colors, confirmInitInputPersistence, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, createZip, ensureInstallPackages, getCwd, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveInitProviderInput, secretEnvHelper, transformEnv, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
3
3
  import { apiKeys, insights, remoteConfig } from "@hot-updater/server/plugins";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
@@ -6769,7 +6769,8 @@ const initProvider = {
6769
6769
  help: "Existing CloudFront distribution ID",
6770
6770
  optional: true
6771
6771
  }
6772
- }
6772
+ },
6773
+ secrets: ["HOT_UPDATER_S3_ACCESS_KEY_ID", "HOT_UPDATER_S3_SECRET_ACCESS_KEY"]
6773
6774
  };
6774
6775
  //#endregion
6775
6776
  //#region iac/regionLocationMap.ts
@@ -8411,7 +8412,16 @@ var SSMKeyPairManager = class {
8411
8412
  };
8412
8413
  //#endregion
8413
8414
  //#region iac/templates.ts
8414
- const getConfigScaffold = (build, authMode) => {
8415
+ /**
8416
+ * The config init writes. With the `resources` init set up, it names them,
8417
+ * and an account's access keys are read with `secretEnv`, from the
8418
+ * environment and `.env.hotupdater`, then the config's `secrets` adapter.
8419
+ * Without them, as the agent scaffold writes it, it reads every value from
8420
+ * the environment. A profile or SSO sign-in is each person's own.
8421
+ */
8422
+ const getConfigScaffold = (build, authMode, resources) => {
8423
+ const value = (envKey, resolved) => resolved === void 0 ? `process.env.${envKey}!` : JSON.stringify(resolved);
8424
+ const region = value("HOT_UPDATER_S3_REGION", resources?.region);
8415
8425
  const storageConfig = {
8416
8426
  imports: [{
8417
8427
  pkg: "@hot-updater/aws",
@@ -8419,7 +8429,7 @@ const getConfigScaffold = (build, authMode) => {
8419
8429
  }],
8420
8430
  configString: `s3Storage({
8421
8431
  ...awsOptions,
8422
- bucketName: process.env.HOT_UPDATER_S3_BUCKET_NAME!,
8432
+ bucketName: ${value("HOT_UPDATER_S3_BUCKET_NAME", resources?.bucketName)},
8423
8433
  })`
8424
8434
  };
8425
8435
  const databaseConfig = {
@@ -8429,8 +8439,8 @@ const getConfigScaffold = (build, authMode) => {
8429
8439
  }],
8430
8440
  configString: `dynamoDB({
8431
8441
  ...awsOptions,
8432
- tableName: process.env.HOT_UPDATER_DYNAMODB_TABLE_NAME!,
8433
- cloudfrontDistributionId: process.env.HOT_UPDATER_CLOUDFRONT_DISTRIBUTION_ID!,
8442
+ tableName: ${value("HOT_UPDATER_DYNAMODB_TABLE_NAME", resources?.tableName)},
8443
+ cloudfrontDistributionId: ${value("HOT_UPDATER_CLOUDFRONT_DISTRIBUTION_ID", resources?.cloudfrontDistributionId)},
8434
8444
  })`
8435
8445
  };
8436
8446
  let helperStatements;
@@ -8442,7 +8452,7 @@ const getConfigScaffold = (build, authMode) => {
8442
8452
  replaceIncompatibleProperties: ["credentials"],
8443
8453
  code: `
8444
8454
  const awsOptions = {
8445
- region: process.env.HOT_UPDATER_S3_REGION!,
8455
+ region: ${region},
8446
8456
  credentials: fromSSO({ profile: process.env.HOT_UPDATER_AWS_PROFILE! }),
8447
8457
  };`.trim()
8448
8458
  }];
@@ -8454,28 +8464,40 @@ const awsOptions = {
8454
8464
  replaceIncompatibleProperties: ["credentials"],
8455
8465
  code: authMode.profile ? `
8456
8466
  const awsOptions = {
8457
- region: process.env.HOT_UPDATER_S3_REGION!,
8467
+ region: ${region},
8458
8468
  credentials: fromIni({ profile: process.env.HOT_UPDATER_AWS_PROFILE! }),
8459
8469
  };`.trim() : `
8460
8470
  const awsOptions = {
8461
- region: process.env.HOT_UPDATER_S3_REGION!,
8471
+ region: ${region},
8462
8472
  credentials: fromNodeProviderChain(),
8463
8473
  };`.trim()
8464
8474
  }];
8465
8475
  break;
8466
- case "account": helperStatements = [{
8467
- name: "awsOptions",
8468
- strategy: "merge-object",
8469
- replaceIncompatibleProperties: ["credentials"],
8470
- code: `
8476
+ case "account":
8477
+ helperStatements = [{
8478
+ name: "awsOptions",
8479
+ strategy: "merge-object",
8480
+ replaceIncompatibleProperties: ["credentials"],
8481
+ code: resources === void 0 ? `
8471
8482
  const awsOptions = {
8472
- region: process.env.HOT_UPDATER_S3_REGION!,
8483
+ region: ${region},
8473
8484
  credentials: {
8474
8485
  accessKeyId: process.env.HOT_UPDATER_S3_ACCESS_KEY_ID!,
8475
8486
  secretAccessKey: process.env.HOT_UPDATER_S3_SECRET_ACCESS_KEY!,
8476
8487
  },
8488
+ };`.trim() : `
8489
+ const awsOptions = {
8490
+ region: ${region},
8491
+ credentials: async () => {
8492
+ const env = await deploySecrets();
8493
+ return {
8494
+ accessKeyId: env.HOT_UPDATER_S3_ACCESS_KEY_ID,
8495
+ secretAccessKey: env.HOT_UPDATER_S3_SECRET_ACCESS_KEY,
8496
+ };
8497
+ },
8477
8498
  };`.trim()
8478
- }];
8499
+ }];
8500
+ if (resources !== void 0) helperStatements.unshift(secretEnvHelper("deploySecrets", ["HOT_UPDATER_S3_ACCESS_KEY_ID", "HOT_UPDATER_S3_SECRET_ACCESS_KEY"]));
8479
8501
  }
8480
8502
  const builder = new ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig).setPlugins({
8481
8503
  imports: [{
@@ -8495,9 +8517,15 @@ const awsOptions = {
8495
8517
  named: ["fromSSO"]
8496
8518
  });
8497
8519
  break;
8498
- case "local": builder.addImport({
8499
- pkg: "@aws-sdk/credential-providers",
8500
- named: [authMode.profile ? "fromIni" : "fromNodeProviderChain"]
8520
+ case "local":
8521
+ builder.addImport({
8522
+ pkg: "@aws-sdk/credential-providers",
8523
+ named: [authMode.profile ? "fromIni" : "fromNodeProviderChain"]
8524
+ });
8525
+ break;
8526
+ case "account": if (resources !== void 0) builder.addImport({
8527
+ pkg: "hot-updater",
8528
+ named: ["secretEnv"]
8501
8529
  });
8502
8530
  }
8503
8531
  return createHotUpdaterConfigScaffoldFromBuilder(builder, { helperStatements });
@@ -8523,9 +8551,9 @@ const prepareDynamoDBDeployment = async (input) => {
8523
8551
  remoteConfig()
8524
8552
  ]);
8525
8553
  };
8526
- const runInit = async ({ build, envFile }) => {
8554
+ const runInit = async ({ build, envFile, secretsEnv }) => {
8527
8555
  const nonInteractive = envFile !== void 0;
8528
- const initEnvSources = await readHotUpdaterInitEnv(process.cwd(), envFile);
8556
+ const initEnvSources = await readHotUpdaterInitEnv(process.cwd(), envFile, secretsEnv);
8529
8557
  const { managedEnv } = initEnvSources;
8530
8558
  const providerEnv = getHotUpdaterInitInputEnv(initEnvSources, nonInteractive);
8531
8559
  const savedInputs = resolveAwsInitInputs(providerEnv);
@@ -8734,7 +8762,12 @@ const runInit = async ({ build, envFile }) => {
8734
8762
  if (mode === "sso") await ensureInstallPackages({ devDependencies: ["@aws-sdk/credential-provider-sso"] });
8735
8763
  else if (mode === "local-session" || mode === "shared-profile") await ensureInstallPackages({ devDependencies: ["@aws-sdk/credential-providers"] });
8736
8764
  p.log.success("Generated '.env.hotupdater' file with AWS settings.");
8737
- await writeHotUpdaterFiles(getConfigScaffold(build, configAuthMode), {
8765
+ await writeHotUpdaterFiles(getConfigScaffold(build, configAuthMode, {
8766
+ region: bucketRegion,
8767
+ bucketName,
8768
+ tableName: resolvedDynamoDBTableName,
8769
+ cloudfrontDistributionId: distributionId
8770
+ }), {
8738
8771
  cwd: process.cwd(),
8739
8772
  settings: "AWS"
8740
8773
  });
@@ -4707,7 +4707,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
4707
4707
  };
4708
4708
  //#endregion
4709
4709
  //#region ../../packages/server/dist/version.mjs
4710
- const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.3";
4710
+ const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.5";
4711
4711
  //#endregion
4712
4712
  //#region ../../packages/server/dist/handlerVersionRoutes.mjs
4713
4713
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/aws",
3
3
  "type": "module",
4
- "version": "1.2.0-rc.3",
4
+ "version": "1.2.0-rc.5",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -45,9 +45,9 @@
45
45
  "es-toolkit": "^1.32.0",
46
46
  "execa": "9.5.2",
47
47
  "mime": "^4.0.4",
48
- "@hot-updater/test-utils": "1.2.0-rc.3",
49
- "@hot-updater/protocol": "1.2.0-rc.3",
50
- "@hot-updater/mock": "1.2.0-rc.3"
48
+ "@hot-updater/protocol": "1.2.0-rc.5",
49
+ "@hot-updater/mock": "1.2.0-rc.5",
50
+ "@hot-updater/test-utils": "1.2.0-rc.5"
51
51
  },
52
52
  "dependencies": {
53
53
  "@aws-sdk/client-cloudfront": "3.1066.0",
@@ -64,9 +64,9 @@
64
64
  "@aws-sdk/lib-dynamodb": "3.1066.0",
65
65
  "@aws-sdk/s3-request-presigner": "3.1066.0",
66
66
  "hono": "4.12.34",
67
- "@hot-updater/cli-tools": "1.2.0-rc.3",
68
- "@hot-updater/plugin-core": "1.2.0-rc.3",
69
- "@hot-updater/server": "1.2.0-rc.3"
67
+ "@hot-updater/cli-tools": "1.2.0-rc.5",
68
+ "@hot-updater/server": "1.2.0-rc.5",
69
+ "@hot-updater/plugin-core": "1.2.0-rc.5"
70
70
  },
71
71
  "scripts": {
72
72
  "build": "tsdown",