@remotion/lambda 4.0.0-copy.4 → 4.0.0-esm.17

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.
Files changed (100) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/admin/bundle-lambda.js +20 -4
  3. package/dist/admin/generate-etag-list.d.ts +1 -0
  4. package/dist/admin/generate-etag-list.js +14 -0
  5. package/dist/admin/make-layer-public.js +23 -1
  6. package/dist/api/deploy-function.js +3 -1
  7. package/dist/api/deploy-site.d.ts +5 -0
  8. package/dist/api/deploy-site.js +39 -21
  9. package/dist/api/get-aws-client.d.ts +2 -0
  10. package/dist/api/get-aws-client.js +2 -0
  11. package/dist/api/get-buckets.js +26 -9
  12. package/dist/api/get-compositions-on-lambda.d.ts +2 -1
  13. package/dist/api/get-compositions-on-lambda.js +1 -3
  14. package/dist/api/get-or-create-bucket.js +2 -7
  15. package/dist/api/get-regions.d.ts +5 -1
  16. package/dist/api/get-regions.js +5 -2
  17. package/dist/api/iam-validation/simulate-rule.js +0 -22
  18. package/dist/api/iam-validation/simulate.js +24 -5
  19. package/dist/api/iam-validation/user-permissions.js +0 -8
  20. package/dist/api/render-media-on-lambda.d.ts +2 -1
  21. package/dist/api/render-media-on-lambda.js +6 -10
  22. package/dist/api/render-still-on-lambda.d.ts +2 -1
  23. package/dist/api/render-still-on-lambda.js +1 -3
  24. package/dist/api/upload-dir.d.ts +4 -3
  25. package/dist/api/upload-dir.js +33 -19
  26. package/dist/cli/args.d.ts +1 -0
  27. package/dist/cli/commands/compositions/index.js +1 -3
  28. package/dist/cli/commands/regions.js +5 -1
  29. package/dist/cli/commands/render/progress.d.ts +6 -3
  30. package/dist/cli/commands/render/progress.js +49 -39
  31. package/dist/cli/commands/render/render.js +17 -4
  32. package/dist/cli/commands/sites/create.js +12 -4
  33. package/dist/cli/commands/still.js +5 -9
  34. package/dist/cli/helpers/progress-bar.d.ts +9 -3
  35. package/dist/cli/helpers/progress-bar.js +19 -3
  36. package/dist/cli/index.js +6 -1
  37. package/dist/functions/compositions.js +10 -3
  38. package/dist/functions/helpers/concat-videos.d.ts +10 -6
  39. package/dist/functions/helpers/concat-videos.js +8 -25
  40. package/dist/functions/helpers/create-post-render-data.js +0 -12
  41. package/dist/functions/helpers/expected-out-name.js +1 -1
  42. package/dist/functions/helpers/get-chromium-executable-path.js +2 -1
  43. package/dist/functions/helpers/get-current-region.d.ts +1 -1
  44. package/dist/functions/helpers/get-encoding-metadata.d.ts +4 -8
  45. package/dist/functions/helpers/get-encoding-metadata.js +4 -18
  46. package/dist/functions/helpers/get-final-encoding-status.d.ts +2 -4
  47. package/dist/functions/helpers/get-final-encoding-status.js +1 -4
  48. package/dist/functions/helpers/get-lambdas-invoked-stats.d.ts +1 -5
  49. package/dist/functions/helpers/get-lambdas-invoked-stats.js +1 -9
  50. package/dist/functions/helpers/get-overall-progress.d.ts +2 -1
  51. package/dist/functions/helpers/get-overall-progress.js +7 -5
  52. package/dist/functions/helpers/get-progress.js +40 -26
  53. package/dist/functions/helpers/get-rendered-frames-progress.d.ts +8 -0
  54. package/dist/functions/helpers/get-rendered-frames-progress.js +37 -0
  55. package/dist/functions/launch.js +50 -38
  56. package/dist/functions/renderer.js +19 -24
  57. package/dist/functions/start.js +9 -2
  58. package/dist/functions/still.js +16 -5
  59. package/dist/index.d.ts +9 -2
  60. package/dist/index.js +10 -2
  61. package/dist/pricing/aws-regions.d.ts +2 -1
  62. package/dist/pricing/aws-regions.js +31 -1
  63. package/dist/pricing/price-per-1-s.js +413 -39
  64. package/dist/shared/aws-clients.d.ts +3 -0
  65. package/dist/shared/aws-clients.js +75 -13
  66. package/dist/shared/check-credentials.js +3 -0
  67. package/dist/shared/chunk-progress.d.ts +9 -0
  68. package/dist/shared/chunk-progress.js +2034 -0
  69. package/dist/shared/constants.d.ts +13 -12
  70. package/dist/shared/convert-to-serve-url.d.ts +5 -1
  71. package/dist/shared/convert-to-serve-url.js +1 -5
  72. package/dist/shared/deserialize-input-props.d.ts +1 -1
  73. package/dist/shared/deserialize-input-props.js +1 -1
  74. package/dist/shared/function-zip-path.d.ts +2 -1
  75. package/dist/shared/function-zip-path.js +3 -2
  76. package/dist/shared/get-account-id.js +4 -6
  77. package/dist/shared/get-etag.d.ts +1 -0
  78. package/dist/shared/get-etag.js +24 -0
  79. package/dist/shared/get-s3-operations.d.ts +10 -0
  80. package/dist/shared/get-s3-operations.js +36 -0
  81. package/dist/shared/hosted-layers.js +368 -60
  82. package/dist/shared/invoke-webhook.d.ts +2 -0
  83. package/dist/shared/parse-chunk-key.d.ts +4 -0
  84. package/dist/shared/parse-chunk-key.js +14 -0
  85. package/dist/shared/read-dir.d.ts +9 -0
  86. package/dist/shared/read-dir.js +57 -0
  87. package/dist/shared/validate-bucketname.d.ts +5 -0
  88. package/dist/shared/validate-bucketname.js +19 -1
  89. package/dist/shared/validate-lambda-codec.d.ts +1 -1
  90. package/dist/shared/validate-lambda-codec.js +0 -1
  91. package/package.json +18 -14
  92. package/remotionlambda-arm64.zip +0 -0
  93. package/remotionlambda-x64.zip +0 -0
  94. package/remotionlambda.zip +0 -0
  95. package/.prettierrc.js +0 -14
  96. package/dist/api/enable-s3-website.d.ts +0 -5
  97. package/dist/api/enable-s3-website.js +0 -16
  98. package/dist/shared/get-cloudwatch-stream-url.d.ts +0 -8
  99. package/dist/shared/get-cloudwatch-stream-url.js +0 -7
  100. package/tsconfig.json +0 -16
package/LICENSE.md CHANGED
@@ -7,7 +7,7 @@ Depending on the type of your legal entity, you are granted permission to use Re
7
7
 
8
8
  ## Free license
9
9
 
10
- Copyright © 2022 [Remotion](https://www.remotion.dev/)
10
+ Copyright © 2023 [Remotion](https://www.remotion.dev/)
11
11
 
12
12
  ### Eligibility
13
13
 
@@ -4,12 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const bundler_1 = require("@remotion/bundler");
7
+ const compositor_linux_arm64_musl_1 = require("@remotion/compositor-linux-arm64-musl");
8
+ const compositor_linux_x64_musl_1 = require("@remotion/compositor-linux-x64-musl");
7
9
  const fs_1 = __importDefault(require("fs"));
8
10
  const path_1 = __importDefault(require("path"));
9
11
  const quit_1 = require("../cli/helpers/quit");
10
12
  const function_zip_path_1 = require("../shared/function-zip-path");
11
13
  const zl = require("zip-lib");
12
- const bundleLambda = async () => {
14
+ const bundleLambda = async (arch) => {
13
15
  var _a;
14
16
  const outdir = path_1.default.join(__dirname, '..', `build-render`);
15
17
  fs_1.default.mkdirSync(outdir, {
@@ -26,13 +28,27 @@ const bundleLambda = async () => {
26
28
  outfile,
27
29
  entryPoints: [template],
28
30
  treeShaking: true,
31
+ external: ['./compositor', './compositor.exe'],
29
32
  });
30
- await zl.archiveFolder(outdir, function_zip_path_1.FUNCTION_ZIP);
33
+ const compositorFile = `${outdir}/compositor`;
34
+ if (arch === 'arm64') {
35
+ fs_1.default.copyFileSync(compositor_linux_arm64_musl_1.binaryPath, compositorFile);
36
+ await zl.archiveFolder(outdir, function_zip_path_1.FUNCTION_ZIP_ARM64);
37
+ }
38
+ else {
39
+ fs_1.default.copyFileSync(compositor_linux_x64_musl_1.binaryPath, compositorFile);
40
+ await zl.archiveFolder(outdir, function_zip_path_1.FUNCTION_ZIP_X86_64);
41
+ }
42
+ fs_1.default.unlinkSync(compositorFile);
31
43
  fs_1.default.unlinkSync(outfile);
32
44
  };
33
- bundleLambda()
45
+ bundleLambda('arm64')
34
46
  .then(() => {
35
- console.log('Lambda bundled');
47
+ console.log('Lambda bundled for arm64');
48
+ return bundleLambda('x86_64');
49
+ })
50
+ .then(() => {
51
+ console.log('Lambda bundled for x86_64');
36
52
  })
37
53
  .catch((err) => {
38
54
  console.log(err);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const crypto_1 = __importDefault(require("crypto"));
7
+ const fs_1 = require("fs");
8
+ const md5 = (data) => crypto_1.default.createHash('md5').update(data).digest('hex');
9
+ const chunks = [];
10
+ for (let i = 0; i < 2000; i++) {
11
+ const etag = `"${md5(String(i))}"`;
12
+ chunks.push(etag);
13
+ }
14
+ (0, fs_1.writeFileSync)('etags.json', JSON.stringify(chunks));
@@ -20,6 +20,17 @@ const layerInfo = {
20
20
  'us-east-1': [],
21
21
  'us-east-2': [],
22
22
  'us-west-2': [],
23
+ 'af-south-1': [],
24
+ 'ap-east-1': [],
25
+ 'ap-northeast-2': [],
26
+ 'ap-northeast-3': [],
27
+ 'ca-central-1': [],
28
+ 'eu-north-1': [],
29
+ 'eu-south-1': [],
30
+ 'eu-west-3': [],
31
+ 'me-south-1': [],
32
+ 'sa-east-1': [],
33
+ 'us-west-1': [],
23
34
  },
24
35
  x86_64: {
25
36
  'ap-northeast-1': [],
@@ -32,6 +43,17 @@ const layerInfo = {
32
43
  'us-east-1': [],
33
44
  'us-east-2': [],
34
45
  'us-west-2': [],
46
+ 'af-south-1': [],
47
+ 'ap-east-1': [],
48
+ 'ap-northeast-2': [],
49
+ 'ap-northeast-3': [],
50
+ 'ca-central-1': [],
51
+ 'eu-north-1': [],
52
+ 'eu-south-1': [],
53
+ 'eu-west-3': [],
54
+ 'me-south-1': [],
55
+ 'sa-east-1': [],
56
+ 'us-west-1': [],
35
57
  },
36
58
  };
37
59
  const makeLayerPublic = async () => {
@@ -43,7 +65,7 @@ const makeLayerPublic = async () => {
43
65
  const { Version, LayerArn } = await (0, aws_clients_1.getLambdaClient)(region).send(new client_lambda_1.PublishLayerVersionCommand({
44
66
  Content: {
45
67
  S3Bucket: 'remotionlambda-binaries-' + region,
46
- S3Key: `remotion-layer-${layer}-v8-${architecture}.zip`,
68
+ S3Key: `remotion-layer-${layer}-v9-${architecture}.zip`,
47
69
  },
48
70
  LayerName: layerName,
49
71
  LicenseInfo: layer === 'chromium'
@@ -55,7 +55,9 @@ const deployFunction = async (options) => {
55
55
  const created = await (0, create_function_1.createFunction)({
56
56
  createCloudWatchLogGroup: options.createCloudWatchLogGroup,
57
57
  region: options.region,
58
- zipFile: function_zip_path_1.FUNCTION_ZIP,
58
+ zipFile: options.architecture === 'arm64'
59
+ ? function_zip_path_1.FUNCTION_ZIP_ARM64
60
+ : function_zip_path_1.FUNCTION_ZIP_X86_64,
59
61
  functionName: fnNameRender,
60
62
  accountId,
61
63
  memorySizeInMb: options.memorySizeInMb,
@@ -18,6 +18,11 @@ export declare type DeploySiteInput = {
18
18
  export declare type DeploySiteOutput = Promise<{
19
19
  serveUrl: string;
20
20
  siteName: string;
21
+ stats: {
22
+ uploadedFiles: number;
23
+ deletedFiles: number;
24
+ untouchedFiles: number;
25
+ };
21
26
  }>;
22
27
  /**
23
28
  * @description Deploys a Remotion project to an S3 bucket to prepare it for rendering on AWS Lambda.
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deploySite = void 0;
4
- const delete_site_1 = require("../api/delete-site");
4
+ const io_1 = require("../functions/helpers/io");
5
5
  const bundle_site_1 = require("../shared/bundle-site");
6
6
  const constants_1 = require("../shared/constants");
7
7
  const get_account_id_1 = require("../shared/get-account-id");
8
+ const get_s3_operations_1 = require("../shared/get-s3-operations");
8
9
  const make_s3_url_1 = require("../shared/make-s3-url");
9
10
  const random_hash_1 = require("../shared/random-hash");
10
11
  const validate_aws_region_1 = require("../shared/validate-aws-region");
11
12
  const validate_bucketname_1 = require("../shared/validate-bucketname");
12
13
  const validate_site_name_1 = require("../shared/validate-site-name");
13
14
  const bucket_exists_1 = require("./bucket-exists");
14
- const enable_s3_website_1 = require("./enable-s3-website");
15
15
  const upload_dir_1 = require("./upload-dir");
16
16
  /**
17
17
  * @description Deploys a Remotion project to an S3 bucket to prepare it for rendering on AWS Lambda.
@@ -28,45 +28,63 @@ const deploySite = async ({ bucketName, entryPoint, siteName, options, region, }
28
28
  (0, validate_bucketname_1.validateBucketName)(bucketName, { mustStartWithRemotion: true });
29
29
  const siteId = siteName !== null && siteName !== void 0 ? siteName : (0, random_hash_1.randomHash)();
30
30
  (0, validate_site_name_1.validateSiteName)(siteId);
31
+ const accountId = await (0, get_account_id_1.getAccountId)({ region });
31
32
  const bucketExists = await (0, bucket_exists_1.bucketExistsInRegion)({
32
33
  bucketName,
33
34
  region,
34
- expectedBucketOwner: await (0, get_account_id_1.getAccountId)({ region }),
35
+ expectedBucketOwner: accountId,
35
36
  });
36
37
  if (!bucketExists) {
37
38
  throw new Error(`No bucket with the name ${bucketName} exists`);
38
39
  }
39
40
  const subFolder = (0, constants_1.getSitesKey)(siteId);
40
- await (0, delete_site_1.deleteSite)({
41
- bucketName,
42
- onAfterItemDeleted: () => undefined,
43
- region,
44
- siteName: siteId,
45
- });
46
- const bundled = await (0, bundle_site_1.bundleSite)(entryPoint, (_a = options === null || options === void 0 ? void 0 : options.onBundleProgress) !== null && _a !== void 0 ? _a : (() => undefined), {
47
- publicPath: `/${subFolder}/`,
48
- webpackOverride: (_b = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _b !== void 0 ? _b : ((f) => f),
49
- enableCaching: (_c = options === null || options === void 0 ? void 0 : options.enableCaching) !== null && _c !== void 0 ? _c : true,
50
- publicDir: options === null || options === void 0 ? void 0 : options.publicDir,
51
- rootDir: options === null || options === void 0 ? void 0 : options.rootDir,
41
+ const [files, bundled] = await Promise.all([
42
+ (0, io_1.lambdaLs)({
43
+ bucketName,
44
+ expectedBucketOwner: accountId,
45
+ region,
46
+ prefix: subFolder,
47
+ }),
48
+ (0, bundle_site_1.bundleSite)(entryPoint, (_a = options === null || options === void 0 ? void 0 : options.onBundleProgress) !== null && _a !== void 0 ? _a : (() => undefined), {
49
+ publicPath: `/${subFolder}/`,
50
+ webpackOverride: (_b = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _b !== void 0 ? _b : ((f) => f),
51
+ enableCaching: (_c = options === null || options === void 0 ? void 0 : options.enableCaching) !== null && _c !== void 0 ? _c : true,
52
+ publicDir: options === null || options === void 0 ? void 0 : options.publicDir,
53
+ rootDir: options === null || options === void 0 ? void 0 : options.rootDir,
54
+ }),
55
+ ]);
56
+ const { toDelete, toUpload, existingCount } = await (0, get_s3_operations_1.getS3DiffOperations)({
57
+ objects: files,
58
+ bundle: bundled,
59
+ prefix: subFolder,
52
60
  });
53
61
  await Promise.all([
54
62
  (0, upload_dir_1.uploadDir)({
55
63
  bucket: bucketName,
56
64
  region,
57
- dir: bundled,
65
+ localDir: bundled,
58
66
  onProgress: (_d = options === null || options === void 0 ? void 0 : options.onUploadProgress) !== null && _d !== void 0 ? _d : (() => undefined),
59
- folder: subFolder,
67
+ keyPrefix: subFolder,
60
68
  privacy: 'public',
69
+ toUpload,
61
70
  }),
62
- (0, enable_s3_website_1.enableS3Website)({
63
- region,
64
- bucketName,
65
- }),
71
+ Promise.all(toDelete.map((d) => {
72
+ return (0, io_1.lambdaDeleteFile)({
73
+ bucketName,
74
+ customCredentials: null,
75
+ key: d.Key,
76
+ region,
77
+ });
78
+ })),
66
79
  ]);
67
80
  return {
68
81
  serveUrl: (0, make_s3_url_1.makeS3ServeUrl)({ bucketName, subFolder, region }),
69
82
  siteName: siteId,
83
+ stats: {
84
+ uploadedFiles: toUpload.length,
85
+ deletedFiles: toDelete.length,
86
+ untouchedFiles: existingCount,
87
+ },
70
88
  };
71
89
  };
72
90
  exports.deploySite = deploySite;
@@ -3,6 +3,7 @@ import * as IamSdk from '@aws-sdk/client-iam';
3
3
  import * as LambdaSDK from '@aws-sdk/client-lambda';
4
4
  import * as S3SDK from '@aws-sdk/client-s3';
5
5
  import * as ServiceQuotasSDK from '@aws-sdk/client-service-quotas';
6
+ import * as StsSdk from '@aws-sdk/client-sts';
6
7
  import type { AwsRegion } from '../client';
7
8
  import type { CustomCredentials, ServiceMapping } from '../shared/aws-clients';
8
9
  export declare type GetAwsClientInput<T extends keyof ServiceMapping> = {
@@ -16,6 +17,7 @@ declare type SdkMapping = {
16
17
  iam: typeof IamSdk;
17
18
  lambda: typeof LambdaSDK;
18
19
  servicequotas: typeof ServiceQuotasSDK;
20
+ sts: typeof StsSdk;
19
21
  };
20
22
  export declare type GetAwsClientOutput<T extends keyof ServiceMapping> = {
21
23
  client: ServiceMapping[T];
@@ -29,6 +29,7 @@ const IamSdk = __importStar(require("@aws-sdk/client-iam"));
29
29
  const LambdaSDK = __importStar(require("@aws-sdk/client-lambda"));
30
30
  const S3SDK = __importStar(require("@aws-sdk/client-s3"));
31
31
  const ServiceQuotasSDK = __importStar(require("@aws-sdk/client-service-quotas"));
32
+ const StsSdk = __importStar(require("@aws-sdk/client-sts"));
32
33
  const aws_clients_1 = require("../shared/aws-clients");
33
34
  /**
34
35
  * @description Gets the full AWS SDK and an instantiated client for an AWS service
@@ -51,6 +52,7 @@ const getAwsClient = ({ region, service, customCredentials, }) => {
51
52
  iam: IamSdk,
52
53
  s3: S3SDK,
53
54
  servicequotas: ServiceQuotasSDK,
55
+ sts: StsSdk,
54
56
  }[service],
55
57
  };
56
58
  };
@@ -4,26 +4,43 @@ exports.getRemotionS3Buckets = void 0;
4
4
  const client_s3_1 = require("@aws-sdk/client-s3");
5
5
  const aws_clients_1 = require("../shared/aws-clients");
6
6
  const constants_1 = require("../shared/constants");
7
+ const validate_bucketname_1 = require("../shared/validate-bucketname");
7
8
  const getRemotionS3Buckets = async (region) => {
8
9
  const { Buckets } = await (0, aws_clients_1.getS3Client)(region, null).send(new client_s3_1.ListBucketsCommand({}));
9
10
  if (!Buckets) {
10
11
  return { remotionBuckets: [] };
11
12
  }
12
13
  const remotionBuckets = Buckets.filter((b) => { var _a; return (_a = b.Name) === null || _a === void 0 ? void 0 : _a.startsWith(constants_1.REMOTION_BUCKET_PREFIX); });
13
- const locations = await Promise.all(remotionBuckets.map((bucket) => {
14
- return (0, aws_clients_1.getS3Client)(region, null).send(new client_s3_1.GetBucketLocationCommand({
15
- Bucket: bucket.Name,
16
- }));
14
+ const locations = await Promise.all(remotionBuckets.map(async (bucket) => {
15
+ var _a, _b;
16
+ const { region: parsedRegion } = (0, validate_bucketname_1.parseBucketName)(bucket.Name);
17
+ if (parsedRegion) {
18
+ return parsedRegion;
19
+ }
20
+ try {
21
+ const result = await (0, aws_clients_1.getS3Client)(region, null).send(new client_s3_1.GetBucketLocationCommand({
22
+ Bucket: bucket.Name,
23
+ }));
24
+ // AWS docs: Buckets in Region us-east-1 have a LocationConstraint of null!!
25
+ return (_a = result.LocationConstraint) !== null && _a !== void 0 ? _a : 'us-east-1';
26
+ }
27
+ catch (err) {
28
+ // Sometimes the API returns a bucket even if it was deleted before
29
+ if ((_b = err.stack) === null || _b === void 0 ? void 0 : _b.includes('NoSuchBucket')) {
30
+ return null;
31
+ }
32
+ throw err;
33
+ }
17
34
  }));
18
- const bucketsWithLocation = remotionBuckets.map((bucket, i) => {
19
- var _a;
35
+ const bucketsWithLocation = remotionBuckets
36
+ .map((bucket, i) => {
20
37
  return {
21
38
  creationDate: bucket.CreationDate.getTime(),
22
39
  name: bucket.Name,
23
- // AWS docs: Buckets in Region us-east-1 have a LocationConstraint of null!!
24
- region: ((_a = locations[i].LocationConstraint) !== null && _a !== void 0 ? _a : 'us-east-1'),
40
+ region: locations[i],
25
41
  };
26
- });
42
+ })
43
+ .filter((b) => b.region);
27
44
  return {
28
45
  remotionBuckets: bucketsWithLocation.filter((bucket) => {
29
46
  return bucket.region === region;
@@ -1,4 +1,5 @@
1
- import type { ChromiumOptions, LogLevel } from '@remotion/renderer';
1
+ import type { LogLevel } from '@remotion/renderer';
2
+ import type { ChromiumOptions } from '@remotion/renderer/src/open-browser';
2
3
  import type { TCompMetadata } from 'remotion';
3
4
  import type { AwsRegion } from '../client';
4
5
  export declare type GetCompositionsOnLambdaInput = {
@@ -4,7 +4,6 @@ exports.getCompositionsOnLambda = void 0;
4
4
  const version_1 = require("remotion/version");
5
5
  const defaults_1 = require("../defaults");
6
6
  const call_lambda_1 = require("../shared/call-lambda");
7
- const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
8
7
  const serialize_input_props_1 = require("../shared/serialize-input-props");
9
8
  /**
10
9
  * @description Returns the compositions from a serveUrl
@@ -21,7 +20,6 @@ const serialize_input_props_1 = require("../shared/serialize-input-props");
21
20
  */
22
21
  const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inputProps, functionName, envVariables, logLevel, timeoutInMilliseconds, }) => {
23
22
  var _a;
24
- const realServeUrl = await (0, convert_to_serve_url_1.convertToServeUrl)(serveUrl, region);
25
23
  const serializedInputProps = await (0, serialize_input_props_1.serializeInputProps)({
26
24
  inputProps,
27
25
  region,
@@ -33,7 +31,7 @@ const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inpu
33
31
  type: defaults_1.LambdaRoutines.compositions,
34
32
  payload: {
35
33
  chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
36
- serveUrl: realServeUrl,
34
+ serveUrl,
37
35
  envVariables,
38
36
  inputProps: serializedInputProps,
39
37
  logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
@@ -2,9 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getOrCreateBucket = void 0;
4
4
  const constants_1 = require("../shared/constants");
5
- const random_hash_1 = require("../shared/random-hash");
5
+ const validate_bucketname_1 = require("../shared/validate-bucketname");
6
6
  const create_bucket_1 = require("./create-bucket");
7
- const enable_s3_website_1 = require("./enable-s3-website");
8
7
  const get_buckets_1 = require("./get-buckets");
9
8
  /**
10
9
  * @description Creates a bucket for Remotion Lambda in your S3 account. If one already exists, it will get returned instead.
@@ -22,16 +21,12 @@ const getOrCreateBucket = async (options) => {
22
21
  (_a = options.onBucketEnsured) === null || _a === void 0 ? void 0 : _a.call(options);
23
22
  return { bucketName: remotionBuckets[0].name };
24
23
  }
25
- const bucketName = constants_1.REMOTION_BUCKET_PREFIX + (0, random_hash_1.randomHash)();
24
+ const bucketName = (0, validate_bucketname_1.makeBucketName)(options.region);
26
25
  await (0, create_bucket_1.createBucket)({
27
26
  bucketName,
28
27
  region: options.region,
29
28
  });
30
29
  (_b = options.onBucketEnsured) === null || _b === void 0 ? void 0 : _b.call(options);
31
- await (0, enable_s3_website_1.enableS3Website)({
32
- region: options.region,
33
- bucketName,
34
- });
35
30
  return { bucketName };
36
31
  };
37
32
  exports.getOrCreateBucket = getOrCreateBucket;
@@ -1,7 +1,11 @@
1
1
  import type { AwsRegion } from '../pricing/aws-regions';
2
+ declare type Options = {
3
+ enabledByDefaultOnly?: boolean;
4
+ };
2
5
  /**
3
6
  * @description Gets an array of all supported AWS regions of this release of Remotion Lambda.
4
7
  * @link https://remotion.dev/docs/lambda/getregions
5
8
  * @returns {AwsRegion[]} A list of AWS regions.
6
9
  */
7
- export declare const getRegions: () => readonly AwsRegion[];
10
+ export declare const getRegions: (options?: Options) => readonly AwsRegion[];
11
+ export {};
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRegions = void 0;
4
+ const aws_regions_1 = require("../pricing/aws-regions");
4
5
  const regions_1 = require("../regions");
5
6
  /**
6
7
  * @description Gets an array of all supported AWS regions of this release of Remotion Lambda.
7
8
  * @link https://remotion.dev/docs/lambda/getregions
8
9
  * @returns {AwsRegion[]} A list of AWS regions.
9
10
  */
10
- const getRegions = () => {
11
- return regions_1.AWS_REGIONS;
11
+ const getRegions = (options) => {
12
+ var _a;
13
+ const onlyEnabledByDefault = (_a = options === null || options === void 0 ? void 0 : options.enabledByDefaultOnly) !== null && _a !== void 0 ? _a : false;
14
+ return onlyEnabledByDefault ? aws_regions_1.DEFAULT_AWS_REGIONS : regions_1.AWS_REGIONS;
12
15
  };
13
16
  exports.getRegions = getRegions;
@@ -2,32 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.simulateRule = void 0;
4
4
  const client_iam_1 = require("@aws-sdk/client-iam");
5
- const aws_policies_1 = require("aws-policies");
6
5
  const aws_clients_1 = require("../../shared/aws-clients");
7
6
  const simulateRule = async (options) => {
8
7
  var _a;
9
8
  try {
10
- if (options.actionNames.includes(aws_policies_1.iam.GetUser)) {
11
- try {
12
- await (0, aws_clients_1.getIamClient)(options.region).send(new client_iam_1.GetUserCommand({}));
13
- const result = [
14
- {
15
- decision: 'allowed',
16
- name: aws_policies_1.iam.GetUser,
17
- },
18
- ];
19
- return result;
20
- }
21
- catch (err) {
22
- const result = [
23
- {
24
- decision: 'explicitDeny',
25
- name: aws_policies_1.iam.GetUser,
26
- },
27
- ];
28
- return result;
29
- }
30
- }
31
9
  const res = await (0, aws_clients_1.getIamClient)(options.region).send(new client_iam_1.SimulatePrincipalPolicyCommand({
32
10
  ActionNames: options.actionNames,
33
11
  PolicySourceArn: options.arn,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.simulatePermissions = exports.logPermissionOutput = void 0;
4
- const client_iam_1 = require("@aws-sdk/client-iam");
4
+ const client_sts_1 = require("@aws-sdk/client-sts");
5
5
  const aws_clients_1 = require("../../shared/aws-clients");
6
6
  const simulate_rule_1 = require("./simulate-rule");
7
7
  const user_permissions_1 = require("./user-permissions");
@@ -26,15 +26,34 @@ exports.logPermissionOutput = logPermissionOutput;
26
26
  */
27
27
  const simulatePermissions = async (options) => {
28
28
  var _a;
29
- const user = await (0, aws_clients_1.getIamClient)(options.region).send(new client_iam_1.GetUserCommand({}));
30
- if (!user || !user.User) {
31
- throw new Error('No valid AWS user detected');
29
+ const callerIdentity = await (0, aws_clients_1.getStsClient)(options.region).send(new client_sts_1.GetCallerIdentityCommand({}));
30
+ if (!callerIdentity || !callerIdentity.Arn) {
31
+ throw new Error('No valid AWS Caller Identity detected');
32
+ }
33
+ const callerIdentityArnComponents = callerIdentity.Arn.match(/arn:aws:([^:]+)::(\d+):([^/]+)(.*)/);
34
+ if (!callerIdentityArnComponents) {
35
+ throw new Error('Unknown AWS Caller Identity ARN detected');
36
+ }
37
+ const callerIdentityArnType = callerIdentityArnComponents[1];
38
+ let callerArn;
39
+ if (callerIdentityArnType === 'iam' && callerIdentityArnComponents[3] === 'user') {
40
+ callerArn = callerIdentity.Arn;
41
+ }
42
+ else if (callerIdentityArnType === 'sts' && callerIdentityArnComponents[3] === 'assumed-role') {
43
+ const assumedRoleComponents = callerIdentityArnComponents[4].match(/\/([^/]+)\/(.*)/);
44
+ if (!assumedRoleComponents) {
45
+ throw new Error('Unsupported AWS Caller Identity as Assumed-Role ARN detected');
46
+ }
47
+ callerArn = `arn:aws:iam::${callerIdentityArnComponents[2]}:role/${assumedRoleComponents[1]}`;
48
+ }
49
+ else {
50
+ throw new Error('Unsupported AWS Caller Identity ARN detected');
32
51
  }
33
52
  const results = [];
34
53
  for (const per of user_permissions_1.requiredPermissions) {
35
54
  const result = await (0, simulate_rule_1.simulateRule)({
36
55
  actionNames: per.actions,
37
- arn: user.User.Arn,
56
+ arn: callerArn,
38
57
  region: options.region,
39
58
  resource: per.resource,
40
59
  retries: 2,
@@ -15,12 +15,6 @@ exports.requiredPermissions = [
15
15
  ],
16
16
  resource: ['*'],
17
17
  },
18
- {
19
- id: 'Identity',
20
- actions: [aws_policies_1.iam.GetUser],
21
- // eslint-disable-next-line no-template-curly-in-string
22
- resource: ['arn:aws:iam::*:user/${aws:username}'],
23
- },
24
18
  {
25
19
  id: 'PermissionValidation',
26
20
  actions: [aws_policies_1.iam.SimulatePrincipalPolicy],
@@ -43,8 +37,6 @@ exports.requiredPermissions = [
43
37
  aws_policies_1.s3.GetBucketLocation,
44
38
  aws_policies_1.s3.PutBucketAcl,
45
39
  aws_policies_1.s3.DeleteBucket,
46
- aws_policies_1.s3.PutBucketWebsite,
47
- aws_policies_1.s3.DeleteBucketWebsite,
48
40
  ],
49
41
  resource: [`arn:aws:s3:::${constants_1.REMOTION_BUCKET_PREFIX}*`],
50
42
  },
@@ -1,4 +1,5 @@
1
- import type { ChromiumOptions, FrameRange, ImageFormat, LogLevel, PixelFormat, ProResProfile } from '@remotion/renderer';
1
+ import type { FrameRange, ImageFormat, LogLevel, PixelFormat, ProResProfile } from '@remotion/renderer';
2
+ import type { ChromiumOptions } from '@remotion/renderer/src/open-browser';
2
3
  import type { AwsRegion } from '../pricing/aws-regions';
3
4
  import type { OutNameInput, Privacy } from '../shared/constants';
4
5
  import type { DownloadBehavior } from '../shared/content-disposition-header';
@@ -4,7 +4,6 @@ exports.renderVideoOnLambda = exports.renderMediaOnLambda = void 0;
4
4
  const version_1 = require("remotion/version");
5
5
  const call_lambda_1 = require("../shared/call-lambda");
6
6
  const constants_1 = require("../shared/constants");
7
- const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
8
7
  const get_aws_urls_1 = require("../shared/get-aws-urls");
9
8
  const serialize_input_props_1 = require("../shared/serialize-input-props");
10
9
  const validate_download_behavior_1 = require("../shared/validate-download-behavior");
@@ -39,14 +38,11 @@ const renderMediaOnLambda = async ({ functionName, serveUrl, inputProps, codec,
39
38
  durationInFrames: 1,
40
39
  });
41
40
  (0, validate_download_behavior_1.validateDownloadBehavior)(downloadBehavior);
42
- const [realServeUrl, serializedInputProps] = await Promise.all([
43
- (0, convert_to_serve_url_1.convertToServeUrl)(serveUrl, region),
44
- (0, serialize_input_props_1.serializeInputProps)({
45
- inputProps,
46
- region,
47
- type: 'video-or-audio',
48
- }),
49
- ]);
41
+ const serializedInputProps = await (0, serialize_input_props_1.serializeInputProps)({
42
+ inputProps,
43
+ region,
44
+ type: 'video-or-audio',
45
+ });
50
46
  try {
51
47
  const res = await (0, call_lambda_1.callLambda)({
52
48
  functionName,
@@ -54,7 +50,7 @@ const renderMediaOnLambda = async ({ functionName, serveUrl, inputProps, codec,
54
50
  payload: {
55
51
  framesPerLambda: framesPerLambda !== null && framesPerLambda !== void 0 ? framesPerLambda : null,
56
52
  composition,
57
- serveUrl: realServeUrl,
53
+ serveUrl,
58
54
  inputProps: serializedInputProps,
59
55
  codec: actualCodec,
60
56
  imageFormat: imageFormat !== null && imageFormat !== void 0 ? imageFormat : 'jpeg',
@@ -1,4 +1,5 @@
1
- import type { ChromiumOptions, LogLevel, StillImageFormat } from '@remotion/renderer';
1
+ import type { LogLevel, StillImageFormat } from '@remotion/renderer';
2
+ import type { ChromiumOptions } from '@remotion/renderer/src/open-browser';
2
3
  import type { AwsRegion } from '../pricing/aws-regions';
3
4
  import type { CostsInfo, OutNameInput, Privacy } from '../shared/constants';
4
5
  import type { DownloadBehavior } from '../shared/content-disposition-header';
@@ -4,7 +4,6 @@ exports.renderStillOnLambda = void 0;
4
4
  const version_1 = require("remotion/version");
5
5
  const call_lambda_1 = require("../shared/call-lambda");
6
6
  const constants_1 = require("../shared/constants");
7
- const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
8
7
  const get_aws_urls_1 = require("../shared/get-aws-urls");
9
8
  const serialize_input_props_1 = require("../shared/serialize-input-props");
10
9
  /**
@@ -25,7 +24,6 @@ const serialize_input_props_1 = require("../shared/serialize-input-props");
25
24
  */
26
25
  const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, }) => {
27
26
  var _a;
28
- const realServeUrl = await (0, convert_to_serve_url_1.convertToServeUrl)(serveUrl, region);
29
27
  const serializedInputProps = await (0, serialize_input_props_1.serializeInputProps)({
30
28
  inputProps,
31
29
  region,
@@ -37,7 +35,7 @@ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFo
37
35
  type: constants_1.LambdaRoutines.still,
38
36
  payload: {
39
37
  composition,
40
- serveUrl: realServeUrl,
38
+ serveUrl,
41
39
  inputProps: serializedInputProps,
42
40
  imageFormat,
43
41
  envVariables,
@@ -11,11 +11,12 @@ export declare type MockFile = {
11
11
  content: string;
12
12
  };
13
13
  export declare const getDirFiles: (entry: string) => MockFile[];
14
- export declare const uploadDir: ({ bucket, region, dir, onProgress, folder, privacy, }: {
14
+ export declare const uploadDir: ({ bucket, region, localDir, onProgress, keyPrefix, privacy, toUpload, }: {
15
15
  bucket: string;
16
16
  region: AwsRegion;
17
- dir: string;
18
- folder: string;
17
+ localDir: string;
18
+ keyPrefix: string;
19
19
  onProgress: (progress: UploadDirProgress) => void;
20
20
  privacy: Privacy;
21
+ toUpload: string[];
21
22
  }) => Promise<void>;