@hot-updater/aws 1.2.0-rc.24 → 1.2.0-rc.25

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/dist/index.cjs CHANGED
@@ -541,6 +541,22 @@ const MAX_SECRET_ID_LENGTH = 512;
541
541
  /** AWS's limit on a `SecretString`, in bytes. */
542
542
  const MAX_SECRET_BYTES = 65536;
543
543
  const REQUEST_TIMEOUT_MS = 3e4;
544
+ /**
545
+ * How long `set` waits, between reads, for a read to return the version it
546
+ * wrote: Secrets Manager's reads are eventually consistent. About 30 seconds.
547
+ */
548
+ const VERSION_RETRY_DELAYS_MS = [
549
+ 250,
550
+ 500,
551
+ 1e3,
552
+ 2e3,
553
+ 4e3,
554
+ 8e3,
555
+ 15e3
556
+ ];
557
+ const delay = (ms) => new Promise((resolve) => {
558
+ setTimeout(resolve, ms);
559
+ });
544
560
  /** Errors of credentials AWS no longer takes: signing in again fixes them. */
545
561
  const EXPIRED_CREDENTIAL_ERRORS = /* @__PURE__ */ new Set([
546
562
  "ExpiredToken",
@@ -616,10 +632,11 @@ const checkCredentials = async (credentials) => {
616
632
  * Secrets from AWS Secrets Manager: each name is the secret
617
633
  * `<prefix><name>`, its `SecretString`, or its `SecretBinary` as base64.
618
634
  * `set` puts a new version of the secret, and creates the secret when it
619
- * does not exist; AWS keeps the versions labeled `AWSCURRENT` and
620
- * `AWSPREVIOUS`, and removes the older ones itself. The AWS SDK loads on
621
- * the first read or write, so a config that only uses `s3Storage` never
622
- * loads it.
635
+ * does not exist, then waits until a read returns that version, so a `get`
636
+ * after it reads the new value; AWS keeps the versions labeled
637
+ * `AWSCURRENT` and `AWSPREVIOUS`, and removes the older ones itself. The
638
+ * AWS SDK loads on the first read or write, so a config that only uses
639
+ * `s3Storage` never loads it.
623
640
  *
624
641
  * @example
625
642
  * secrets: secretsManager({ region: "us-east-1" })
@@ -671,7 +688,8 @@ const secretsManager = ({ credentials, endpoint, prefix = "hot-updater/", region
671
688
  if (/marked for deletion|scheduled for deletion/iu.test(errorMessage(error))) return failure([`${id} is scheduled for deletion. Restore it, or wait until it is gone:`, `aws secretsmanager restore-secret --secret-id ${id}`], error);
672
689
  return failure([`AWS Secrets Manager failed to ${verb} ${id}.`, `${name || "Error"}${status ? ` (${status})` : ""}: ${errorMessage(error)}.`], error);
673
690
  };
674
- const read = async ({ sdk, client }, id) => {
691
+ /** The secret's `AWSCURRENT` version and value; undefined without one. */
692
+ const readCurrent = async ({ sdk, client }, id) => {
675
693
  let output;
676
694
  try {
677
695
  output = await client.send(new sdk.GetSecretValueCommand({ SecretId: id }));
@@ -681,7 +699,22 @@ const secretsManager = ({ credentials, endpoint, prefix = "hot-updater/", region
681
699
  }
682
700
  const value = output.SecretString ?? (output.SecretBinary === void 0 ? void 0 : Buffer.from(output.SecretBinary).toString("base64"));
683
701
  await mask([value]);
684
- return value;
702
+ return {
703
+ version: output.VersionId,
704
+ value
705
+ };
706
+ };
707
+ /**
708
+ * Waits until a read of `id` returns `version`, the one `set` wrote, for
709
+ * about 30 seconds: until then, a read may return the previous version,
710
+ * or nothing for a secret just created.
711
+ */
712
+ const waitForVersion = async (client, id, version) => {
713
+ for (const ms of [0, ...VERSION_RETRY_DELAYS_MS]) {
714
+ if (ms > 0) await delay(ms);
715
+ if ((await readCurrent(client, id))?.version === version) return;
716
+ }
717
+ throw failure([`AWS Secrets Manager doesn't return the new version of ${id} yet.`, "Run the same command again."]);
685
718
  };
686
719
  return {
687
720
  name: NAME,
@@ -691,7 +724,7 @@ const secretsManager = ({ credentials, endpoint, prefix = "hot-updater/", region
691
724
  const result = Object.create(null);
692
725
  if (unique.length === 0) return result;
693
726
  const client = await open();
694
- const values = await Promise.all(ids.map((id) => read(client, id)));
727
+ const values = await Promise.all(ids.map(async (id) => (await readCurrent(client, id))?.value));
695
728
  unique.forEach((name, index) => {
696
729
  result[name] = values[index];
697
730
  });
@@ -702,34 +735,38 @@ const secretsManager = ({ credentials, endpoint, prefix = "hot-updater/", region
702
735
  if (typeof value !== "string" || value === "") throw new Error(`${NAME} can't store an empty ${id}.`);
703
736
  if (Buffer.byteLength(value, "utf8") > MAX_SECRET_BYTES) throw failure([`${NAME} can't store ${id}.`, `AWS takes up to ${MAX_SECRET_BYTES} bytes per secret.`]);
704
737
  await mask([value]);
705
- const { sdk, client } = await open();
738
+ const opened = await open();
739
+ const { sdk, client } = opened;
706
740
  const token = (0, node_crypto.randomUUID)();
707
741
  const put = () => client.send(new sdk.PutSecretValueCommand({
708
742
  ClientRequestToken: token,
709
743
  SecretId: id,
710
744
  SecretString: value
711
745
  }));
712
- try {
713
- await put();
714
- return;
715
- } catch (error) {
716
- if (!(error instanceof sdk.ResourceNotFoundException)) throw describeFailure("write", id, error, "secretsmanager:PutSecretValue");
717
- }
718
- try {
719
- await client.send(new sdk.CreateSecretCommand({
720
- ClientRequestToken: token,
721
- Description: "Stored by Hot Updater.",
722
- Name: id,
723
- SecretString: value
724
- }));
725
- } catch (error) {
726
- if (!(error instanceof sdk.ResourceExistsException)) throw describeFailure("create", id, error, "secretsmanager:CreateSecret");
746
+ /** The version the write made. */
747
+ const write = async () => {
748
+ try {
749
+ return (await put()).VersionId;
750
+ } catch (error) {
751
+ if (!(error instanceof sdk.ResourceNotFoundException)) throw describeFailure("write", id, error, "secretsmanager:PutSecretValue");
752
+ }
753
+ try {
754
+ return (await client.send(new sdk.CreateSecretCommand({
755
+ ClientRequestToken: token,
756
+ Description: "Stored by Hot Updater.",
757
+ Name: id,
758
+ SecretString: value
759
+ }))).VersionId;
760
+ } catch (error) {
761
+ if (!(error instanceof sdk.ResourceExistsException)) throw describeFailure("create", id, error, "secretsmanager:CreateSecret");
762
+ }
727
763
  try {
728
- await put();
764
+ return (await put()).VersionId;
729
765
  } catch (retryError) {
730
766
  throw describeFailure("write", id, retryError, "secretsmanager:PutSecretValue");
731
767
  }
732
- }
768
+ };
769
+ await waitForVersion(opened, id, await write() ?? token);
733
770
  },
734
771
  describe: (name) => `the secret ${JSON.stringify(`${prefix}${name}`)} in AWS Secrets Manager (${region})`
735
772
  };
package/dist/index.d.cts CHANGED
@@ -127,10 +127,11 @@ interface SecretsManagerOptions {
127
127
  * Secrets from AWS Secrets Manager: each name is the secret
128
128
  * `<prefix><name>`, its `SecretString`, or its `SecretBinary` as base64.
129
129
  * `set` puts a new version of the secret, and creates the secret when it
130
- * does not exist; AWS keeps the versions labeled `AWSCURRENT` and
131
- * `AWSPREVIOUS`, and removes the older ones itself. The AWS SDK loads on
132
- * the first read or write, so a config that only uses `s3Storage` never
133
- * loads it.
130
+ * does not exist, then waits until a read returns that version, so a `get`
131
+ * after it reads the new value; AWS keeps the versions labeled
132
+ * `AWSCURRENT` and `AWSPREVIOUS`, and removes the older ones itself. The
133
+ * AWS SDK loads on the first read or write, so a config that only uses
134
+ * `s3Storage` never loads it.
134
135
  *
135
136
  * @example
136
137
  * secrets: secretsManager({ region: "us-east-1" })
package/dist/index.d.mts CHANGED
@@ -127,10 +127,11 @@ interface SecretsManagerOptions {
127
127
  * Secrets from AWS Secrets Manager: each name is the secret
128
128
  * `<prefix><name>`, its `SecretString`, or its `SecretBinary` as base64.
129
129
  * `set` puts a new version of the secret, and creates the secret when it
130
- * does not exist; AWS keeps the versions labeled `AWSCURRENT` and
131
- * `AWSPREVIOUS`, and removes the older ones itself. The AWS SDK loads on
132
- * the first read or write, so a config that only uses `s3Storage` never
133
- * loads it.
130
+ * does not exist, then waits until a read returns that version, so a `get`
131
+ * after it reads the new value; AWS keeps the versions labeled
132
+ * `AWSCURRENT` and `AWSPREVIOUS`, and removes the older ones itself. The
133
+ * AWS SDK loads on the first read or write, so a config that only uses
134
+ * `s3Storage` never loads it.
134
135
  *
135
136
  * @example
136
137
  * secrets: secretsManager({ region: "us-east-1" })
package/dist/index.mjs CHANGED
@@ -540,6 +540,22 @@ const MAX_SECRET_ID_LENGTH = 512;
540
540
  /** AWS's limit on a `SecretString`, in bytes. */
541
541
  const MAX_SECRET_BYTES = 65536;
542
542
  const REQUEST_TIMEOUT_MS = 3e4;
543
+ /**
544
+ * How long `set` waits, between reads, for a read to return the version it
545
+ * wrote: Secrets Manager's reads are eventually consistent. About 30 seconds.
546
+ */
547
+ const VERSION_RETRY_DELAYS_MS = [
548
+ 250,
549
+ 500,
550
+ 1e3,
551
+ 2e3,
552
+ 4e3,
553
+ 8e3,
554
+ 15e3
555
+ ];
556
+ const delay = (ms) => new Promise((resolve) => {
557
+ setTimeout(resolve, ms);
558
+ });
543
559
  /** Errors of credentials AWS no longer takes: signing in again fixes them. */
544
560
  const EXPIRED_CREDENTIAL_ERRORS = /* @__PURE__ */ new Set([
545
561
  "ExpiredToken",
@@ -615,10 +631,11 @@ const checkCredentials = async (credentials) => {
615
631
  * Secrets from AWS Secrets Manager: each name is the secret
616
632
  * `<prefix><name>`, its `SecretString`, or its `SecretBinary` as base64.
617
633
  * `set` puts a new version of the secret, and creates the secret when it
618
- * does not exist; AWS keeps the versions labeled `AWSCURRENT` and
619
- * `AWSPREVIOUS`, and removes the older ones itself. The AWS SDK loads on
620
- * the first read or write, so a config that only uses `s3Storage` never
621
- * loads it.
634
+ * does not exist, then waits until a read returns that version, so a `get`
635
+ * after it reads the new value; AWS keeps the versions labeled
636
+ * `AWSCURRENT` and `AWSPREVIOUS`, and removes the older ones itself. The
637
+ * AWS SDK loads on the first read or write, so a config that only uses
638
+ * `s3Storage` never loads it.
622
639
  *
623
640
  * @example
624
641
  * secrets: secretsManager({ region: "us-east-1" })
@@ -670,7 +687,8 @@ const secretsManager = ({ credentials, endpoint, prefix = "hot-updater/", region
670
687
  if (/marked for deletion|scheduled for deletion/iu.test(errorMessage(error))) return failure([`${id} is scheduled for deletion. Restore it, or wait until it is gone:`, `aws secretsmanager restore-secret --secret-id ${id}`], error);
671
688
  return failure([`AWS Secrets Manager failed to ${verb} ${id}.`, `${name || "Error"}${status ? ` (${status})` : ""}: ${errorMessage(error)}.`], error);
672
689
  };
673
- const read = async ({ sdk, client }, id) => {
690
+ /** The secret's `AWSCURRENT` version and value; undefined without one. */
691
+ const readCurrent = async ({ sdk, client }, id) => {
674
692
  let output;
675
693
  try {
676
694
  output = await client.send(new sdk.GetSecretValueCommand({ SecretId: id }));
@@ -680,7 +698,22 @@ const secretsManager = ({ credentials, endpoint, prefix = "hot-updater/", region
680
698
  }
681
699
  const value = output.SecretString ?? (output.SecretBinary === void 0 ? void 0 : Buffer.from(output.SecretBinary).toString("base64"));
682
700
  await mask([value]);
683
- return value;
701
+ return {
702
+ version: output.VersionId,
703
+ value
704
+ };
705
+ };
706
+ /**
707
+ * Waits until a read of `id` returns `version`, the one `set` wrote, for
708
+ * about 30 seconds: until then, a read may return the previous version,
709
+ * or nothing for a secret just created.
710
+ */
711
+ const waitForVersion = async (client, id, version) => {
712
+ for (const ms of [0, ...VERSION_RETRY_DELAYS_MS]) {
713
+ if (ms > 0) await delay(ms);
714
+ if ((await readCurrent(client, id))?.version === version) return;
715
+ }
716
+ throw failure([`AWS Secrets Manager doesn't return the new version of ${id} yet.`, "Run the same command again."]);
684
717
  };
685
718
  return {
686
719
  name: NAME,
@@ -690,7 +723,7 @@ const secretsManager = ({ credentials, endpoint, prefix = "hot-updater/", region
690
723
  const result = Object.create(null);
691
724
  if (unique.length === 0) return result;
692
725
  const client = await open();
693
- const values = await Promise.all(ids.map((id) => read(client, id)));
726
+ const values = await Promise.all(ids.map(async (id) => (await readCurrent(client, id))?.value));
694
727
  unique.forEach((name, index) => {
695
728
  result[name] = values[index];
696
729
  });
@@ -701,34 +734,38 @@ const secretsManager = ({ credentials, endpoint, prefix = "hot-updater/", region
701
734
  if (typeof value !== "string" || value === "") throw new Error(`${NAME} can't store an empty ${id}.`);
702
735
  if (Buffer.byteLength(value, "utf8") > MAX_SECRET_BYTES) throw failure([`${NAME} can't store ${id}.`, `AWS takes up to ${MAX_SECRET_BYTES} bytes per secret.`]);
703
736
  await mask([value]);
704
- const { sdk, client } = await open();
737
+ const opened = await open();
738
+ const { sdk, client } = opened;
705
739
  const token = randomUUID();
706
740
  const put = () => client.send(new sdk.PutSecretValueCommand({
707
741
  ClientRequestToken: token,
708
742
  SecretId: id,
709
743
  SecretString: value
710
744
  }));
711
- try {
712
- await put();
713
- return;
714
- } catch (error) {
715
- if (!(error instanceof sdk.ResourceNotFoundException)) throw describeFailure("write", id, error, "secretsmanager:PutSecretValue");
716
- }
717
- try {
718
- await client.send(new sdk.CreateSecretCommand({
719
- ClientRequestToken: token,
720
- Description: "Stored by Hot Updater.",
721
- Name: id,
722
- SecretString: value
723
- }));
724
- } catch (error) {
725
- if (!(error instanceof sdk.ResourceExistsException)) throw describeFailure("create", id, error, "secretsmanager:CreateSecret");
745
+ /** The version the write made. */
746
+ const write = async () => {
747
+ try {
748
+ return (await put()).VersionId;
749
+ } catch (error) {
750
+ if (!(error instanceof sdk.ResourceNotFoundException)) throw describeFailure("write", id, error, "secretsmanager:PutSecretValue");
751
+ }
752
+ try {
753
+ return (await client.send(new sdk.CreateSecretCommand({
754
+ ClientRequestToken: token,
755
+ Description: "Stored by Hot Updater.",
756
+ Name: id,
757
+ SecretString: value
758
+ }))).VersionId;
759
+ } catch (error) {
760
+ if (!(error instanceof sdk.ResourceExistsException)) throw describeFailure("create", id, error, "secretsmanager:CreateSecret");
761
+ }
726
762
  try {
727
- await put();
763
+ return (await put()).VersionId;
728
764
  } catch (retryError) {
729
765
  throw describeFailure("write", id, retryError, "secretsmanager:PutSecretValue");
730
766
  }
731
- }
767
+ };
768
+ await waitForVersion(opened, id, await write() ?? token);
732
769
  },
733
770
  describe: (name) => `the secret ${JSON.stringify(`${prefix}${name}`)} in AWS Secrets Manager (${region})`
734
771
  };
@@ -2404,7 +2404,9 @@ const channels = defineTable({
2404
2404
  * for that build alone, so `byStoreBuild` holds one entry per scope at most,
2405
2405
  * on every store, while any number of a scope's builds hold none.
2406
2406
  * `is_sandbox` is true on a sandbox build, set when it registers and never
2407
- * changed. Boolean columns follow one rule: `is_*` for a fact about the row or
2407
+ * changed, and `sandbox_url_scheme` is the URL scheme its artifact registers,
2408
+ * which its preview links open; null on any other build, and on a sandbox
2409
+ * build registered before the column, which registered the derived one. Boolean columns follow one rule: `is_*` for a fact about the row or
2408
2410
  * `should_*` for an instruction to the client, never null; a unique index over
2409
2411
  * the rows where one is true keys a derived slot, not the boolean.
2410
2412
  */
@@ -2485,7 +2487,13 @@ const nativeBuilds = defineTable({
2485
2487
  required: false
2486
2488
  },
2487
2489
  is_store_build: { type: "boolean" },
2488
- is_sandbox: { type: "boolean" }
2490
+ is_sandbox: { type: "boolean" },
2491
+ sandbox_url_scheme: {
2492
+ type: "string",
2493
+ maxLength: 255,
2494
+ ascii: true,
2495
+ required: false
2496
+ }
2489
2497
  }, {
2490
2498
  key: ["id"],
2491
2499
  derived: {
@@ -4646,7 +4654,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
4646
4654
  };
4647
4655
  //#endregion
4648
4656
  //#region ../../packages/server/dist/version.mjs
4649
- const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.24";
4657
+ const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.25";
4650
4658
  //#endregion
4651
4659
  //#region ../../packages/server/dist/handlerVersionRoutes.mjs
4652
4660
  /**
@@ -5713,6 +5721,18 @@ const createCoreReads = (db, storage) => {
5713
5721
  };
5714
5722
  };
5715
5723
  //#endregion
5724
+ //#region ../../packages/server/dist/core/nativeBuildDestinations.mjs
5725
+ /** Store destinations accepted for each native platform. */
5726
+ const NATIVE_BUILD_SUBMISSION_DESTINATIONS = {
5727
+ android: [
5728
+ "play-internal",
5729
+ "play-closed",
5730
+ "play-open",
5731
+ "play-production"
5732
+ ],
5733
+ ios: ["testflight"]
5734
+ };
5735
+ //#endregion
5716
5736
  //#region ../../packages/server/dist/core/writes.mjs
5717
5737
  const PAGE$2 = 500;
5718
5738
  /** Moves one bundle into or out of its platform's total and the overall total. */
@@ -5830,6 +5850,13 @@ const GIT_COMMIT_HASH_MAX_LENGTH = 255;
5830
5850
  * and looks up nothing else.
5831
5851
  */
5832
5852
  const BUILD_KEY = /^nbk1:[0-9a-f]{64}$/;
5853
+ /** `native_builds.sandbox_url_scheme`'s bound in core's schema. */
5854
+ const SANDBOX_URL_SCHEME_MAX_LENGTH = 255;
5855
+ /**
5856
+ * A URL scheme as RFC 3986 spells it, in lower case: what a sandbox build's
5857
+ * artifact registers, as `@hot-updater/protocol/native-artifact` reads it.
5858
+ */
5859
+ const URL_SCHEME = new RegExp(`^[a-z][a-z0-9+.-]{0,254}$`);
5833
5860
  /** A native build or scope core cannot store or look up: the caller's input. */
5834
5861
  var NativeBuildInputError = class extends TypeError {
5835
5862
  name = "NativeBuildInputError";
@@ -5853,7 +5880,8 @@ const pick = (row) => ({
5853
5880
  submitted_at_ms: row.submitted_at_ms ?? null,
5854
5881
  submitted_version: row.submitted_version ?? null,
5855
5882
  is_store_build: row.is_store_build === true,
5856
- is_sandbox: row.is_sandbox === true
5883
+ is_sandbox: row.is_sandbox === true,
5884
+ sandbox_url_scheme: row.sandbox_url_scheme ?? null
5857
5885
  });
5858
5886
  /**
5859
5887
  * The channels only sandbox builds register on: a registration's `sandbox`
@@ -5868,11 +5896,6 @@ const SANDBOX_CHANNEL_PREFIX = "sandbox-";
5868
5896
  const OLDER_BUILDS_PAGE = 20;
5869
5897
  /** How many times a mark runs again after losing its scope's mark to another. */
5870
5898
  const MARK_ATTEMPTS = 8;
5871
- /** The store track each platform's builds are submitted to. */
5872
- const SUBMISSION_DESTINATIONS = {
5873
- android: "play-internal",
5874
- ios: "testflight"
5875
- };
5876
5899
  /** `native_builds.build_number`'s bound in core's schema. */
5877
5900
  const BUILD_NUMBER_MAX_LENGTH = 64;
5878
5901
  /** `native_builds.submitted_version`'s bound in core's schema. */
@@ -5905,7 +5928,7 @@ const nativeBuildScopeKey = (scope) => {
5905
5928
  };
5906
5929
  /** Whether `bundleId` is a native build's built-in bundle: one unique read. */
5907
5930
  const isBuiltInBundle = async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null;
5908
- const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, artifact }) => {
5931
+ const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, artifact }) => {
5909
5932
  if (!isUUIDv7(id)) return "id must be a UUIDv7";
5910
5933
  if (!isUUIDv7(minBundleId)) return "minBundleId must be the UUIDv7 a release build compiles in";
5911
5934
  if (platform !== "ios" && platform !== "android") return "platform must be ios or android";
@@ -5914,6 +5937,10 @@ const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVer
5914
5937
  const reserved = channel.startsWith(SANDBOX_CHANNEL_PREFIX);
5915
5938
  if (isSandbox === true && !reserved) return `a sandbox build registers on a ${SANDBOX_CHANNEL_PREFIX}* channel, not ${channel}`;
5916
5939
  if (isSandbox !== true && reserved) return `channel ${channel} is reserved for sandbox builds`;
5940
+ if (sandboxUrlScheme !== void 0 && sandboxUrlScheme !== null) {
5941
+ if (isSandbox !== true) return "sandboxUrlScheme is a sandbox build's, and this isn't one";
5942
+ if (typeof sandboxUrlScheme !== "string" || !URL_SCHEME.test(sandboxUrlScheme)) return `sandboxUrlScheme must be a URL scheme in lower case, up to ${SANDBOX_URL_SCHEME_MAX_LENGTH} characters, or null`;
5943
+ }
5917
5944
  if (gitCommitHash !== null && gitCommitHash.length > GIT_COMMIT_HASH_MAX_LENGTH) return `gitCommitHash must be at most ${GIT_COMMIT_HASH_MAX_LENGTH} characters`;
5918
5945
  if (fingerprintHash === null === (appVersion === null)) return "exactly one of fingerprintHash and appVersion is required";
5919
5946
  if (buildKey !== null && !BUILD_KEY.test(buildKey)) return "buildKey must be nbk1: and a SHA-256, or null";
@@ -5950,7 +5977,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
5950
5977
  submitted_at_ms: null,
5951
5978
  submitted_version: null,
5952
5979
  is_store_build: false,
5953
- is_sandbox: registration.isSandbox === true
5980
+ is_sandbox: registration.isSandbox === true,
5981
+ sandbox_url_scheme: registration.sandboxUrlScheme ?? null
5954
5982
  };
5955
5983
  for (let attempt = 1;; attempt += 1) {
5956
5984
  await insertChannel(db, {
@@ -6031,7 +6059,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
6031
6059
  const row = await tx.findOne("native_builds", { id });
6032
6060
  if (row === null) return null;
6033
6061
  const build = pick(row);
6034
- if (SUBMISSION_DESTINATIONS[build.platform] !== destination) throw new NativeBuildInputError(`Invalid native build submission: an ${build.platform} build is submitted to ${SUBMISSION_DESTINATIONS[build.platform]}, not ${destination}.`);
6062
+ if (!NATIVE_BUILD_SUBMISSION_DESTINATIONS[build.platform].includes(destination)) throw new NativeBuildInputError(`Invalid native build submission: an ${build.platform} build is submitted to ${NATIVE_BUILD_SUBMISSION_DESTINATIONS[build.platform].join(" or ")}, not ${destination}.`);
6063
+ if (build.is_sandbox && destination !== "testflight" && destination !== "play-internal") throw new NativeBuildInputError("A sandbox build can submit only to TestFlight or Play internal testing.");
6035
6064
  const set = {
6036
6065
  submitted_to: destination,
6037
6066
  submitted_at_ms: now(),
@@ -7037,7 +7066,7 @@ const refusingInvalid = async (operation) => {
7037
7066
  throw error;
7038
7067
  }
7039
7068
  };
7040
- const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
7069
+ const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && (value.sandboxUrlScheme === void 0 || isTextOrNull$1(value.sandboxUrlScheme)) && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
7041
7070
  const scopeKeyOf = (params) => decodeMaybe(requireRouteParam(params, "scopeKey")) ?? "";
7042
7071
  /** Every admin route's handler, by the name `ADMIN_ROUTES` mounts it under. */
7043
7072
  const createAdminRouteHandlers = () => ({
@@ -7186,7 +7215,7 @@ const createAdminRouteHandlers = () => ({
7186
7215
  }),
7187
7216
  recordNativeBuildSubmission: onCore(async (core, request, params) => {
7188
7217
  const input = await body(request);
7189
- if (!isRecord$5(input) || input.destination !== "testflight" && input.destination !== "play-internal" || !isText$2(input.version)) throw new HandlerBadRequestError("A native build submission needs destination (testflight or play-internal) and version.");
7218
+ if (!isRecord$5(input) || !Object.values(NATIVE_BUILD_SUBMISSION_DESTINATIONS).flat().includes(input.destination) || !isText$2(input.version)) throw new HandlerBadRequestError("A native build submission needs a valid store destination and version.");
7190
7219
  const submission = {
7191
7220
  destination: input.destination,
7192
7221
  version: input.version
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.24",
4
+ "version": "1.2.0-rc.25",
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/protocol": "1.2.0-rc.24",
49
- "@hot-updater/test-utils": "1.2.0-rc.24",
50
- "@hot-updater/mock": "1.2.0-rc.24"
48
+ "@hot-updater/protocol": "1.2.0-rc.25",
49
+ "@hot-updater/mock": "1.2.0-rc.25",
50
+ "@hot-updater/test-utils": "1.2.0-rc.25"
51
51
  },
52
52
  "dependencies": {
53
53
  "@aws-sdk/client-cloudfront": "3.1066.0",
@@ -64,10 +64,10 @@
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.24",
68
- "@hot-updater/plugin-core": "1.2.0-rc.24",
69
- "@hot-updater/server": "1.2.0-rc.24",
70
- "@hot-updater/storage-s3": "1.2.0-rc.24"
67
+ "@hot-updater/cli-tools": "1.2.0-rc.25",
68
+ "@hot-updater/plugin-core": "1.2.0-rc.25",
69
+ "@hot-updater/server": "1.2.0-rc.25",
70
+ "@hot-updater/storage-s3": "1.2.0-rc.25"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "tsdown",