@hot-updater/aws 1.0.0-rc.43 → 1.0.0-rc.45

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
@@ -7,9 +7,6 @@ let _aws_sdk_client_ssm = require("@aws-sdk/client-ssm");
7
7
  let _aws_sdk_cloudfront_signer = require("@aws-sdk/cloudfront-signer");
8
8
  let _aws_sdk_client_s3 = require("@aws-sdk/client-s3");
9
9
  let _aws_sdk_lib_storage = require("@aws-sdk/lib-storage");
10
- let _hot_updater_server_plugins_api_keys = require("@hot-updater/server/plugins/api-keys");
11
- let _hot_updater_server_plugins_insights = require("@hot-updater/server/plugins/insights");
12
- let _hot_updater_server_plugins_remote_config = require("@hot-updater/server/plugins/remote-config");
13
10
  //#region src/cloudFrontInvalidation.ts
14
11
  const DEFAULT_POLL_INTERVAL_MS = 2e3;
15
12
  const DEFAULT_TIMEOUT_MS = 3e5;
@@ -438,10 +435,11 @@ const cloudFrontDownloadUrl = (config) => async ({ storageUri }) => {
438
435
  };
439
436
  //#endregion
440
437
  //#region src/s3Storage.ts
438
+ /** Devices download right after the update check that returns the URL. */
439
+ const PRESIGNED_URL_EXPIRES_IN_SECONDS = 3600;
441
440
  const isObjectNotFoundError = (error) => error instanceof Error && (error.name === "NotFound" || error.name === "NoSuchKey");
442
441
  function s3Storage(config) {
443
- const { bucketName, basePath, downloadUrlSigningKey, getDownloadUrl: configuredGetDownloadUrl, ...s3Config } = config;
444
- const getDownloadUrl = configuredGetDownloadUrl ?? (downloadUrlSigningKey ? (0, _hot_updater_plugin_core.createStorageDownloadUrl)(downloadUrlSigningKey) : void 0);
442
+ const { bucketName, basePath, getDownloadUrl, ...s3Config } = config;
445
443
  const client = new _aws_sdk_client_s3.S3Client(applyS3RuntimeAwsConfig(s3Config));
446
444
  const normalizedBasePath = basePath?.replace(/^\/+|\/+$/g, "") ?? "";
447
445
  const getStorageKey = (0, _hot_updater_plugin_core.createStorageKeyBuilder)(normalizedBasePath);
@@ -554,10 +552,15 @@ function s3Storage(config) {
554
552
  throw error;
555
553
  }
556
554
  },
557
- ...getDownloadUrl ? { async getDownloadUrl(input) {
558
- parseAndValidate(input.storageUri);
559
- return getDownloadUrl(input);
560
- } } : {},
555
+ async getDownloadUrl({ storageUri }) {
556
+ const { key } = parseAndValidate(storageUri);
557
+ if (getDownloadUrl) return getDownloadUrl({ storageUri });
558
+ const { getSignedUrl } = await import("@aws-sdk/s3-request-presigner");
559
+ return { url: await getSignedUrl(client, new _aws_sdk_client_s3.GetObjectCommand({
560
+ Bucket: bucketName,
561
+ Key: key
562
+ }), { expiresIn: PRESIGNED_URL_EXPIRES_IN_SECONDS }) };
563
+ },
561
564
  async exists({ storageUri }) {
562
565
  const { key } = parseAndValidate(storageUri);
563
566
  try {
@@ -582,19 +585,7 @@ function s3Storage(config) {
582
585
  });
583
586
  }
584
587
  //#endregion
585
- //#region src/plugins.ts
586
- /**
587
- * The plugins the managed AWS server runs: Insights, API keys on every
588
- * client route, and Remote Config. Its Lambda@Edge function imports this list.
589
- */
590
- const plugins = [
591
- (0, _hot_updater_server_plugins_insights.insights)(),
592
- (0, _hot_updater_server_plugins_api_keys.apiKeys)(),
593
- (0, _hot_updater_server_plugins_remote_config.remoteConfig)()
594
- ];
595
- //#endregion
596
588
  exports.cloudFrontDownloadUrl = cloudFrontDownloadUrl;
597
589
  exports.dynamoDB = dynamoDB;
598
590
  exports.migrateDynamoDB = migrateDynamoDB;
599
- exports.plugins = plugins;
600
591
  exports.s3Storage = s3Storage;