@remotion/lambda 3.2.22 → 3.2.24

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 (54) hide show
  1. package/dist/api/bucket-exists.js +1 -1
  2. package/dist/api/clean-items.js +1 -1
  3. package/dist/api/create-bucket.js +1 -1
  4. package/dist/api/delete-render.d.ts +19 -0
  5. package/dist/api/delete-render.js +66 -0
  6. package/dist/api/delete-site.js +0 -5
  7. package/dist/api/download-media.d.ts +13 -0
  8. package/dist/api/download-media.js +15 -3
  9. package/dist/api/enable-s3-website.js +1 -1
  10. package/dist/api/get-aws-client.d.ts +4 -2
  11. package/dist/api/get-aws-client.js +7 -2
  12. package/dist/api/get-buckets.js +2 -2
  13. package/dist/api/get-render-progress.d.ts +4 -1
  14. package/dist/api/get-render-progress.js +3 -1
  15. package/dist/api/presign-url.js +1 -1
  16. package/dist/api/render-media-on-lambda.d.ts +3 -3
  17. package/dist/api/render-media-on-lambda.js +3 -3
  18. package/dist/api/upload-dir.js +1 -1
  19. package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +1 -4
  20. package/dist/functions/chunk-optimization/s3-optimization-file.js +1 -0
  21. package/dist/functions/helpers/expected-out-name.d.ts +4 -2
  22. package/dist/functions/helpers/expected-out-name.js +26 -5
  23. package/dist/functions/helpers/find-output-file-in-bucket.d.ts +3 -1
  24. package/dist/functions/helpers/find-output-file-in-bucket.js +9 -7
  25. package/dist/functions/helpers/get-custom-out-name.d.ts +6 -0
  26. package/dist/functions/helpers/get-custom-out-name.js +31 -0
  27. package/dist/functions/helpers/get-output-url-from-metadata.d.ts +2 -1
  28. package/dist/functions/helpers/get-output-url-from-metadata.js +2 -2
  29. package/dist/functions/helpers/get-progress.d.ts +4 -2
  30. package/dist/functions/helpers/get-progress.js +8 -6
  31. package/dist/functions/helpers/io.d.ts +5 -2
  32. package/dist/functions/helpers/io.js +7 -7
  33. package/dist/functions/helpers/read-with-progress.d.ts +3 -1
  34. package/dist/functions/helpers/read-with-progress.js +2 -2
  35. package/dist/functions/helpers/write-lambda-error.js +1 -0
  36. package/dist/functions/helpers/write-post-render-data.js +1 -0
  37. package/dist/functions/index.js +2 -2
  38. package/dist/functions/launch.js +11 -3
  39. package/dist/functions/progress.d.ts +1 -1
  40. package/dist/functions/progress.js +3 -1
  41. package/dist/functions/renderer.js +3 -0
  42. package/dist/functions/start.js +1 -0
  43. package/dist/functions/still.js +5 -2
  44. package/dist/index.d.ts +4 -2
  45. package/dist/index.js +3 -1
  46. package/dist/shared/aws-clients.d.ts +13 -2
  47. package/dist/shared/aws-clients.js +56 -26
  48. package/dist/shared/constants.d.ts +11 -1
  49. package/dist/shared/constants.js +7 -1
  50. package/dist/shared/validate-outname.d.ts +2 -2
  51. package/package.json +6 -6
  52. package/remotionlambda.zip +0 -0
  53. package/dist/cli/helpers/get-cloudwatch-stream-url.d.ts +0 -8
  54. package/dist/cli/helpers/get-cloudwatch-stream-url.js +0 -7
@@ -23,7 +23,7 @@ const get_retry_stats_1 = require("./get-retry-stats");
23
23
  const get_time_to_finish_1 = require("./get-time-to-finish");
24
24
  const inspect_errors_1 = require("./inspect-errors");
25
25
  const io_1 = require("./io");
26
- const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region, memorySizeInMb, timeoutInMiliseconds, }) => {
26
+ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region, memorySizeInMb, timeoutInMilliseconds, customCredentials, }) => {
27
27
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
28
28
  const postRenderData = await (0, get_post_render_data_1.getPostRenderData)({
29
29
  bucketName,
@@ -32,7 +32,7 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
32
32
  expectedBucketOwner,
33
33
  });
34
34
  if (postRenderData) {
35
- const outData = (0, expected_out_name_1.getExpectedOutName)(postRenderData.renderMetadata, bucketName);
35
+ const outData = (0, expected_out_name_1.getExpectedOutName)(postRenderData.renderMetadata, bucketName, customCredentials);
36
36
  return {
37
37
  bucket: bucketName,
38
38
  renderSize: postRenderData.renderSize,
@@ -112,6 +112,7 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
112
112
  bucketName,
113
113
  renderMetadata,
114
114
  region,
115
+ customCredentials,
115
116
  })
116
117
  : null;
117
118
  const accruedSoFar = Number((0, calculate_price_from_bucket_1.estimatePriceFromBucket)({
@@ -162,13 +163,13 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
162
163
  : chunks.length;
163
164
  // We add a 20 second buffer for it, since AWS timeshifts can be quite a lot. Once it's 20sec over the limit, we consider it timed out
164
165
  const isBeyondTimeout = renderMetadata &&
165
- Date.now() > renderMetadata.startedDate + timeoutInMiliseconds + 20000;
166
+ Date.now() > renderMetadata.startedDate + timeoutInMilliseconds + 20000;
166
167
  const allErrors = [
167
168
  isBeyondTimeout
168
169
  ? {
169
170
  attempt: 1,
170
171
  chunk: null,
171
- explanation: `The main function timed out after ${timeoutInMiliseconds}ms. Consider increasing the timeout of your function. You can use the "--timeout" parameter when deploying a function via CLI, or the "timeoutInSeconds" parameter when using the deployFunction API. ${docs_url_1.DOCS_URL}/docs/lambda/cli/functions#deploy`,
172
+ explanation: `The main function timed out after ${timeoutInMilliseconds}ms. Consider increasing the timeout of your function. You can use the "--timeout" parameter when deploying a function via CLI, or the "timeoutInSeconds" parameter when using the deployFunction API. ${docs_url_1.DOCS_URL}/docs/lambda/cli/functions#deploy`,
172
173
  frame: null,
173
174
  isFatal: true,
174
175
  s3Location: '',
@@ -219,10 +220,11 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
219
220
  }),
220
221
  retriesInfo,
221
222
  outKey: outputFile && renderMetadata
222
- ? (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName).key
223
+ ? (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName, customCredentials).key
223
224
  : null,
224
225
  outBucket: outputFile && renderMetadata
225
- ? (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName).renderBucketName
226
+ ? (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName, customCredentials)
227
+ .renderBucketName
226
228
  : null,
227
229
  mostExpensiveFrameRanges: null,
228
230
  };
@@ -2,6 +2,7 @@ import type { _Object } from '@aws-sdk/client-s3';
2
2
  import type { ReadStream } from 'fs';
3
3
  import type { Readable } from 'stream';
4
4
  import type { AwsRegion } from '../../pricing/aws-regions';
5
+ import type { CustomCredentials } from '../../shared/aws-clients';
5
6
  import type { Privacy } from '../../shared/constants';
6
7
  import type { DownloadBehavior } from '../../shared/content-disposition-header';
7
8
  export declare type LambdaLSInput = {
@@ -13,12 +14,13 @@ export declare type LambdaLSInput = {
13
14
  };
14
15
  export declare type LambdaLsReturnType = Promise<_Object[]>;
15
16
  export declare const lambdaLs: ({ bucketName, prefix, region, expectedBucketOwner, continuationToken, }: LambdaLSInput) => LambdaLsReturnType;
16
- export declare const lambdaDeleteFile: ({ bucketName, key, region, }: {
17
+ export declare const lambdaDeleteFile: ({ bucketName, key, region, customCredentials, }: {
17
18
  region: AwsRegion;
18
19
  bucketName: string;
19
20
  key: string;
21
+ customCredentials: CustomCredentials | null;
20
22
  }) => Promise<void>;
21
- export declare const lambdaWriteFile: ({ bucketName, key, body, region, privacy, expectedBucketOwner, downloadBehavior, }: {
23
+ export declare const lambdaWriteFile: ({ bucketName, key, body, region, privacy, expectedBucketOwner, downloadBehavior, customCredentials, }: {
22
24
  bucketName: string;
23
25
  key: string;
24
26
  body: ReadStream | string;
@@ -26,6 +28,7 @@ export declare const lambdaWriteFile: ({ bucketName, key, body, region, privacy,
26
28
  privacy: Privacy;
27
29
  expectedBucketOwner: string | null;
28
30
  downloadBehavior: DownloadBehavior | null;
31
+ customCredentials: CustomCredentials | null;
29
32
  }) => Promise<void>;
30
33
  export declare const lambdaReadFile: ({ bucketName, key, region, expectedBucketOwner, }: {
31
34
  bucketName: string;
@@ -11,7 +11,7 @@ const content_disposition_header_1 = require("../../shared/content-disposition-h
11
11
  const lambdaLs = async ({ bucketName, prefix, region, expectedBucketOwner, continuationToken, }) => {
12
12
  var _a, _b, _c;
13
13
  try {
14
- const list = await (0, aws_clients_1.getS3Client)(region).send(new client_s3_1.ListObjectsV2Command({
14
+ const list = await (0, aws_clients_1.getS3Client)(region, null).send(new client_s3_1.ListObjectsV2Command({
15
15
  Bucket: bucketName,
16
16
  Prefix: prefix,
17
17
  ExpectedBucketOwner: expectedBucketOwner !== null && expectedBucketOwner !== void 0 ? expectedBucketOwner : undefined,
@@ -37,7 +37,7 @@ const lambdaLs = async ({ bucketName, prefix, region, expectedBucketOwner, conti
37
37
  }
38
38
  // Prevent from accessing a foreign bucket, retry without ExpectedBucketOwner and see if it works. If it works then it's an owner mismatch.
39
39
  if ((_c = err.stack) === null || _c === void 0 ? void 0 : _c.includes('AccessDenied')) {
40
- await (0, aws_clients_1.getS3Client)(region).send(new client_s3_1.ListObjectsV2Command({
40
+ await (0, aws_clients_1.getS3Client)(region, null).send(new client_s3_1.ListObjectsV2Command({
41
41
  Bucket: bucketName,
42
42
  Prefix: prefix,
43
43
  }));
@@ -47,15 +47,15 @@ const lambdaLs = async ({ bucketName, prefix, region, expectedBucketOwner, conti
47
47
  }
48
48
  };
49
49
  exports.lambdaLs = lambdaLs;
50
- const lambdaDeleteFile = async ({ bucketName, key, region, }) => {
51
- await (0, aws_clients_1.getS3Client)(region).send(new client_s3_1.DeleteObjectCommand({
50
+ const lambdaDeleteFile = async ({ bucketName, key, region, customCredentials, }) => {
51
+ await (0, aws_clients_1.getS3Client)(region, customCredentials).send(new client_s3_1.DeleteObjectCommand({
52
52
  Bucket: bucketName,
53
53
  Key: key,
54
54
  }));
55
55
  };
56
56
  exports.lambdaDeleteFile = lambdaDeleteFile;
57
- const lambdaWriteFile = async ({ bucketName, key, body, region, privacy, expectedBucketOwner, downloadBehavior, }) => {
58
- await (0, aws_clients_1.getS3Client)(region).send(new client_s3_1.PutObjectCommand({
57
+ const lambdaWriteFile = async ({ bucketName, key, body, region, privacy, expectedBucketOwner, downloadBehavior, customCredentials, }) => {
58
+ await (0, aws_clients_1.getS3Client)(region, customCredentials).send(new client_s3_1.PutObjectCommand({
59
59
  Bucket: bucketName,
60
60
  Key: key,
61
61
  Body: body,
@@ -71,7 +71,7 @@ const lambdaWriteFile = async ({ bucketName, key, body, region, privacy, expecte
71
71
  };
72
72
  exports.lambdaWriteFile = lambdaWriteFile;
73
73
  const lambdaReadFile = async ({ bucketName, key, region, expectedBucketOwner, }) => {
74
- const { Body } = await (0, aws_clients_1.getS3Client)(region).send(new client_s3_1.GetObjectCommand({
74
+ const { Body } = await (0, aws_clients_1.getS3Client)(region, null).send(new client_s3_1.GetObjectCommand({
75
75
  Bucket: bucketName,
76
76
  Key: key,
77
77
  ExpectedBucketOwner: expectedBucketOwner,
@@ -1,16 +1,18 @@
1
1
  import type { AwsRegion } from '../../pricing/aws-regions';
2
+ import type { CustomCredentials } from '../../shared/aws-clients';
2
3
  export declare type LambdaReadFileProgress = (progress: {
3
4
  totalSize: number;
4
5
  downloaded: number;
5
6
  percent: number;
6
7
  }) => unknown;
7
- export declare const lambdaDownloadFileWithProgress: ({ bucketName, key, region, expectedBucketOwner, outputPath, onProgress, }: {
8
+ export declare const lambdaDownloadFileWithProgress: ({ bucketName, key, region, expectedBucketOwner, outputPath, onProgress, customCredentials, }: {
8
9
  bucketName: string;
9
10
  key: string;
10
11
  region: AwsRegion;
11
12
  expectedBucketOwner: string;
12
13
  outputPath: string;
13
14
  onProgress: LambdaReadFileProgress;
15
+ customCredentials: CustomCredentials | null;
14
16
  }) => Promise<{
15
17
  sizeInBytes: number;
16
18
  to: string;
@@ -5,8 +5,8 @@ const client_s3_1 = require("@aws-sdk/client-s3");
5
5
  const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
6
6
  const renderer_1 = require("@remotion/renderer");
7
7
  const aws_clients_1 = require("../../shared/aws-clients");
8
- const lambdaDownloadFileWithProgress = async ({ bucketName, key, region, expectedBucketOwner, outputPath, onProgress, }) => {
9
- const client = (0, aws_clients_1.getS3Client)(region);
8
+ const lambdaDownloadFileWithProgress = async ({ bucketName, key, region, expectedBucketOwner, outputPath, onProgress, customCredentials, }) => {
9
+ const client = (0, aws_clients_1.getS3Client)(region, customCredentials);
10
10
  const command = new client_s3_1.GetObjectCommand({
11
11
  Bucket: bucketName,
12
12
  ExpectedBucketOwner: expectedBucketOwner,
@@ -34,6 +34,7 @@ const writeLambdaError = async ({ bucketName, renderId, errorInfo, expectedBucke
34
34
  privacy: 'private',
35
35
  expectedBucketOwner,
36
36
  downloadBehavior: null,
37
+ customCredentials: null,
37
38
  });
38
39
  };
39
40
  exports.writeLambdaError = writeLambdaError;
@@ -12,6 +12,7 @@ const writePostRenderData = async ({ bucketName, renderId, postRenderData, expec
12
12
  expectedBucketOwner,
13
13
  region,
14
14
  downloadBehavior: null,
15
+ customCredentials: null,
15
16
  });
16
17
  };
17
18
  exports.writePostRenderData = writePostRenderData;
@@ -14,7 +14,7 @@ const start_1 = require("./start");
14
14
  const still_1 = require("./still");
15
15
  const handler = async (params, context) => {
16
16
  process.env.__RESERVED_IS_INSIDE_REMOTION_LAMBDA = 'true';
17
- const timeoutInMiliseconds = context.getRemainingTimeInMillis();
17
+ const timeoutInMilliseconds = context.getRemainingTimeInMillis();
18
18
  if (!context || !context.invokedFunctionArn) {
19
19
  throw new Error('Lambda function unexpectedly does not have context.invokedFunctionArn');
20
20
  }
@@ -53,7 +53,7 @@ const handler = async (params, context) => {
53
53
  });
54
54
  return (0, progress_1.progressHandler)(params, {
55
55
  expectedBucketOwner: currentUserId,
56
- timeoutInMiliseconds,
56
+ timeoutInMilliseconds,
57
57
  });
58
58
  }
59
59
  if (params.type === constants_1.LambdaRoutines.renderer) {
@@ -62,7 +62,7 @@ const callFunctionWithRetry = async (payload, retries = 0) => {
62
62
  }
63
63
  };
64
64
  const innerLaunchHandler = async (params, options) => {
65
- var _a, _b;
65
+ var _a, _b, _c, _d;
66
66
  if (params.type !== constants_1.LambdaRoutines.launch) {
67
67
  throw new Error('Expected launch type');
68
68
  }
@@ -181,6 +181,7 @@ const innerLaunchHandler = async (params, options) => {
181
181
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
182
182
  renderId: params.renderId,
183
183
  outName: (_b = params.outName) !== null && _b !== void 0 ? _b : undefined,
184
+ privacy: params.privacy,
184
185
  };
185
186
  await (0, io_1.lambdaWriteFile)({
186
187
  bucketName: params.bucketName,
@@ -190,6 +191,7 @@ const innerLaunchHandler = async (params, options) => {
190
191
  privacy: 'private',
191
192
  expectedBucketOwner: options.expectedBucketOwner,
192
193
  downloadBehavior: null,
194
+ customCredentials: null,
193
195
  });
194
196
  await Promise.all(lambdaPayloads.map(async (payload, index) => {
195
197
  const callingLambdaTimer = (0, timer_1.timer)('Calling chunk ' + index);
@@ -223,6 +225,7 @@ const innerLaunchHandler = async (params, options) => {
223
225
  privacy: 'private',
224
226
  expectedBucketOwner: options.expectedBucketOwner,
225
227
  downloadBehavior: null,
228
+ customCredentials: null,
226
229
  }).catch((err) => {
227
230
  (0, write_lambda_error_1.writeLambdaError)({
228
231
  bucketName: params.bucketName,
@@ -260,7 +263,9 @@ const innerLaunchHandler = async (params, options) => {
260
263
  if (!encodingStop) {
261
264
  encodingStop = Date.now();
262
265
  }
263
- const { key, renderBucketName } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, params.bucketName);
266
+ const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, params.bucketName, typeof params.outName === 'string' || typeof params.outName === 'undefined'
267
+ ? null
268
+ : (_d = (_c = params.outName) === null || _c === void 0 ? void 0 : _c.s3OutputProvider) !== null && _d !== void 0 ? _d : null);
264
269
  const outputSize = fs_1.default.statSync(outfile);
265
270
  await (0, io_1.lambdaWriteFile)({
266
271
  bucketName: renderBucketName,
@@ -270,6 +275,7 @@ const innerLaunchHandler = async (params, options) => {
270
275
  privacy: params.privacy,
271
276
  expectedBucketOwner: options.expectedBucketOwner,
272
277
  downloadBehavior: params.downloadBehavior,
278
+ customCredentials,
273
279
  });
274
280
  let chunkProm = Promise.resolve();
275
281
  // TODO: Enable in a later release
@@ -332,6 +338,7 @@ const innerLaunchHandler = async (params, options) => {
332
338
  privacy: 'private',
333
339
  expectedBucketOwner: options.expectedBucketOwner,
334
340
  downloadBehavior: null,
341
+ customCredentials: null,
335
342
  });
336
343
  const errorExplanationsProm = (0, inspect_errors_1.inspectErrors)({
337
344
  contents,
@@ -363,7 +370,7 @@ const innerLaunchHandler = async (params, options) => {
363
370
  outputFile: {
364
371
  lastModified: Date.now(),
365
372
  size: outputSize.size,
366
- url: (0, get_output_url_from_metadata_1.getOutputUrlFromMetadata)(renderMetadata, params.bucketName),
373
+ url: (0, get_output_url_from_metadata_1.getOutputUrlFromMetadata)(renderMetadata, params.bucketName, customCredentials),
367
374
  },
368
375
  });
369
376
  await finalEncodingProgressProm;
@@ -378,6 +385,7 @@ const innerLaunchHandler = async (params, options) => {
378
385
  bucketName: params.bucketName,
379
386
  key: (0, constants_1.initalizedMetadataKey)(params.renderId),
380
387
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
388
+ customCredentials: null,
381
389
  });
382
390
  await Promise.all([cleanupChunksProm, fs_1.default.promises.rm(outfile)]);
383
391
  };
@@ -1,7 +1,7 @@
1
1
  import type { LambdaPayload, RenderProgress } from '../shared/constants';
2
2
  declare type Options = {
3
3
  expectedBucketOwner: string;
4
- timeoutInMiliseconds: number;
4
+ timeoutInMilliseconds: number;
5
5
  };
6
6
  export declare const progressHandler: (lambdaParams: LambdaPayload, options: Options) => Promise<RenderProgress>;
7
7
  export {};
@@ -6,6 +6,7 @@ const constants_1 = require("../shared/constants");
6
6
  const get_current_region_1 = require("./helpers/get-current-region");
7
7
  const get_progress_1 = require("./helpers/get-progress");
8
8
  const progressHandler = (lambdaParams, options) => {
9
+ var _a;
9
10
  if (lambdaParams.type !== constants_1.LambdaRoutines.status) {
10
11
  throw new TypeError('Expected status type');
11
12
  }
@@ -21,7 +22,8 @@ const progressHandler = (lambdaParams, options) => {
21
22
  expectedBucketOwner: options.expectedBucketOwner,
22
23
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
23
24
  memorySizeInMb: Number(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE),
24
- timeoutInMiliseconds: options.timeoutInMiliseconds,
25
+ timeoutInMilliseconds: options.timeoutInMilliseconds,
26
+ customCredentials: (_a = lambdaParams.s3OutputProvider) !== null && _a !== void 0 ? _a : null,
25
27
  });
26
28
  };
27
29
  exports.progressHandler = progressHandler;
@@ -87,6 +87,7 @@ const renderHandler = async (params, options, logs) => {
87
87
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
88
88
  expectedBucketOwner: options.expectedBucketOwner,
89
89
  downloadBehavior: null,
90
+ customCredentials: null,
90
91
  }).catch((err) => reject(err));
91
92
  },
92
93
  puppeteerInstance: browserInstance,
@@ -155,6 +156,7 @@ const renderHandler = async (params, options, logs) => {
155
156
  privacy: params.privacy,
156
157
  expectedBucketOwner: options.expectedBucketOwner,
157
158
  downloadBehavior: null,
159
+ customCredentials: null,
158
160
  });
159
161
  await Promise.all([
160
162
  fs_1.default.promises.rm(outputLocation, { recursive: true }),
@@ -172,6 +174,7 @@ const renderHandler = async (params, options, logs) => {
172
174
  privacy: 'private',
173
175
  expectedBucketOwner: options.expectedBucketOwner,
174
176
  downloadBehavior: null,
177
+ customCredentials: null,
175
178
  }),
176
179
  ]);
177
180
  };
@@ -32,6 +32,7 @@ const startHandler = async (params, options) => {
32
32
  expectedBucketOwner: options.expectedBucketOwner,
33
33
  key: (0, constants_1.initalizedMetadataKey)(renderId),
34
34
  privacy: 'private',
35
+ customCredentials: null,
35
36
  });
36
37
  const payload = {
37
38
  type: constants_1.LambdaRoutines.launch,
@@ -83,6 +83,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
83
83
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
84
84
  renderId,
85
85
  outName: (_b = lambdaParams.outName) !== null && _b !== void 0 ? _b : undefined,
86
+ privacy: lambdaParams.privacy,
86
87
  };
87
88
  await (0, io_1.lambdaWriteFile)({
88
89
  bucketName,
@@ -92,6 +93,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
92
93
  privacy: 'private',
93
94
  expectedBucketOwner: options.expectedBucketOwner,
94
95
  downloadBehavior: null,
96
+ customCredentials: null,
95
97
  });
96
98
  await (0, renderer_1.renderStill)({
97
99
  composition,
@@ -110,7 +112,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
110
112
  timeoutInMilliseconds: lambdaParams.timeoutInMilliseconds,
111
113
  downloadMap,
112
114
  });
113
- const { key, renderBucketName } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName);
115
+ const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName, (0, expected_out_name_1.getCredentialsFromOutName)(lambdaParams.outName));
114
116
  const { size } = await fs_1.default.promises.stat(outputPath);
115
117
  await (0, io_1.lambdaWriteFile)({
116
118
  bucketName: renderBucketName,
@@ -120,6 +122,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
120
122
  expectedBucketOwner: options.expectedBucketOwner,
121
123
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
122
124
  downloadBehavior: lambdaParams.downloadBehavior,
125
+ customCredentials,
123
126
  });
124
127
  await fs_1.default.promises.rm(outputPath, { recursive: true });
125
128
  const estimatedPrice = (0, estimate_price_1.estimatePrice)({
@@ -133,7 +136,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
133
136
  diskSizeInMb: constants_1.MAX_EPHEMERAL_STORAGE_IN_MB,
134
137
  });
135
138
  return {
136
- output: (0, get_output_url_from_metadata_1.getOutputUrlFromMetadata)(renderMetadata, bucketName),
139
+ output: (0, get_output_url_from_metadata_1.getOutputUrlFromMetadata)(renderMetadata, bucketName, customCredentials),
137
140
  size,
138
141
  bucketName,
139
142
  estimatedPrice: (0, format_costs_info_1.formatCostsInfo)(estimatedPrice),
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { DeleteFunctionInput } from './api/delete-function';
2
2
  import { deleteFunction } from './api/delete-function';
3
+ import { deleteRender } from './api/delete-render';
3
4
  import type { DeleteSiteInput, DeleteSiteOutput } from './api/delete-site';
4
5
  import { deleteSite } from './api/delete-site';
5
6
  import type { DeployFunctionInput, DeployFunctionOutput } from './api/deploy-function';
@@ -34,7 +35,8 @@ import { renderStillOnLambda } from './api/render-still-on-lambda';
34
35
  import type { LambdaLSInput, LambdaLsReturnType } from './functions/helpers/io';
35
36
  import { LambdaInternals } from './internals';
36
37
  import type { AwsRegion } from './pricing/aws-regions';
38
+ import type { CustomCredentials } from './shared/aws-clients';
37
39
  import type { RenderProgress } from './shared/constants';
38
40
  import type { LambdaArchitecture } from './shared/validate-architecture';
39
- export { deleteSite, deployFunction, deploySite, downloadMedia, downloadVideo, getFunctions, getUserPolicy, getRolePolicy, getSites, getOrCreateBucket, getRenderProgress, renderVideoOnLambda, renderMediaOnLambda, simulatePermissions, deleteFunction, getFunctionInfo, estimatePrice, LambdaInternals, renderStillOnLambda, getRegions, getAwsClient, presignUrl, };
40
- export type { AwsRegion, RenderProgress, DeploySiteInput, DeploySiteOutput, LambdaLsReturnType, LambdaLSInput, DeleteSiteInput, DeleteSiteOutput, EstimatePriceInput, DeployFunctionInput, DeployFunctionOutput, DeleteFunctionInput, GetFunctionInfoInput, FunctionInfo, GetFunctionsInput, GetSitesInput, GetSitesOutput, DownloadMediaInput, DownloadMediaOutput, GetOrCreateBucketInput, GetOrCreateBucketOutput, GetRenderInput, RenderMediaOnLambdaInput, RenderMediaOnLambdaOutput, RenderStillOnLambdaInput, RenderStillOnLambdaOutput, SimulatePermissionsInput, SimulatePermissionsOutput, GetAwsClientInput, GetAwsClientOutput, LambdaArchitecture, };
41
+ export { deleteSite, deployFunction, deploySite, downloadMedia, downloadVideo, getFunctions, getUserPolicy, getRolePolicy, getSites, getOrCreateBucket, getRenderProgress, renderVideoOnLambda, renderMediaOnLambda, simulatePermissions, deleteFunction, getFunctionInfo, estimatePrice, LambdaInternals, renderStillOnLambda, getRegions, getAwsClient, presignUrl, deleteRender, };
42
+ export type { AwsRegion, RenderProgress, DeploySiteInput, DeploySiteOutput, LambdaLsReturnType, LambdaLSInput, DeleteSiteInput, DeleteSiteOutput, EstimatePriceInput, DeployFunctionInput, DeployFunctionOutput, DeleteFunctionInput, GetFunctionInfoInput, FunctionInfo, GetFunctionsInput, GetSitesInput, GetSitesOutput, DownloadMediaInput, DownloadMediaOutput, GetOrCreateBucketInput, GetOrCreateBucketOutput, GetRenderInput, RenderMediaOnLambdaInput, RenderMediaOnLambdaOutput, RenderStillOnLambdaInput, RenderStillOnLambdaOutput, SimulatePermissionsInput, SimulatePermissionsOutput, GetAwsClientInput, GetAwsClientOutput, LambdaArchitecture, CustomCredentials, };
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.presignUrl = exports.getAwsClient = exports.getRegions = exports.renderStillOnLambda = exports.LambdaInternals = exports.estimatePrice = exports.getFunctionInfo = exports.deleteFunction = exports.simulatePermissions = exports.renderMediaOnLambda = exports.renderVideoOnLambda = exports.getRenderProgress = exports.getOrCreateBucket = exports.getSites = exports.getRolePolicy = exports.getUserPolicy = exports.getFunctions = exports.downloadVideo = exports.downloadMedia = exports.deploySite = exports.deployFunction = exports.deleteSite = void 0;
3
+ exports.deleteRender = exports.presignUrl = exports.getAwsClient = exports.getRegions = exports.renderStillOnLambda = exports.LambdaInternals = exports.estimatePrice = exports.getFunctionInfo = exports.deleteFunction = exports.simulatePermissions = exports.renderMediaOnLambda = exports.renderVideoOnLambda = exports.getRenderProgress = exports.getOrCreateBucket = exports.getSites = exports.getRolePolicy = exports.getUserPolicy = exports.getFunctions = exports.downloadVideo = exports.downloadMedia = exports.deploySite = exports.deployFunction = exports.deleteSite = void 0;
4
4
  const delete_function_1 = require("./api/delete-function");
5
5
  Object.defineProperty(exports, "deleteFunction", { enumerable: true, get: function () { return delete_function_1.deleteFunction; } });
6
+ const delete_render_1 = require("./api/delete-render");
7
+ Object.defineProperty(exports, "deleteRender", { enumerable: true, get: function () { return delete_render_1.deleteRender; } });
6
8
  const delete_site_1 = require("./api/delete-site");
7
9
  Object.defineProperty(exports, "deleteSite", { enumerable: true, get: function () { return delete_site_1.deleteSite; } });
8
10
  const deploy_function_1 = require("./api/deploy-function");
@@ -11,9 +11,20 @@ export declare type ServiceMapping = {
11
11
  lambda: LambdaClient;
12
12
  servicequotas: ServiceQuotasClient;
13
13
  };
14
- export declare const getServiceClient: <T extends keyof ServiceMapping>(region: AwsRegion, service: T) => ServiceMapping[T];
14
+ export declare type CustomCredentialsWithoutSensitiveData = {
15
+ endpoint: string;
16
+ };
17
+ export declare type CustomCredentials = CustomCredentialsWithoutSensitiveData & {
18
+ accessKeyId: string | null;
19
+ secretAccessKey: string | null;
20
+ };
21
+ export declare const getServiceClient: <T extends keyof ServiceMapping>({ region, service, customCredentials, }: {
22
+ region: AwsRegion;
23
+ service: T;
24
+ customCredentials: CustomCredentials | null;
25
+ }) => ServiceMapping[T];
15
26
  export declare const getCloudWatchLogsClient: (region: AwsRegion) => CloudWatchLogsClient;
16
- export declare const getS3Client: (region: AwsRegion) => S3Client;
27
+ export declare const getS3Client: (region: AwsRegion, customCredentials: CustomCredentials | null) => S3Client;
17
28
  export declare const getLambdaClient: (region: AwsRegion) => LambdaClient;
18
29
  export declare const getIamClient: (region: AwsRegion) => IAMClient;
19
30
  export declare const getServiceQuotasClient: (region: AwsRegion) => ServiceQuotasClient;
@@ -28,11 +28,17 @@ const getCredentials = () => {
28
28
  }
29
29
  return undefined;
30
30
  };
31
- const getCredentialsKey = () => JSON.stringify(getCredentials());
32
- const getServiceClient = (region, service) => {
33
- if (!_clients[region]) {
34
- _clients[region] = {};
35
- }
31
+ const getKey = ({ credentials, customCredentials, region, service, }) => [
32
+ credentials === null || credentials === void 0 ? void 0 : credentials.accessKeyId,
33
+ credentials === null || credentials === void 0 ? void 0 : credentials.secretAccessKey,
34
+ customCredentials === null || customCredentials === void 0 ? void 0 : customCredentials.accessKeyId,
35
+ customCredentials === null || customCredentials === void 0 ? void 0 : customCredentials.endpoint,
36
+ customCredentials === null || customCredentials === void 0 ? void 0 : customCredentials.secretAccessKey,
37
+ region,
38
+ service,
39
+ ].join('-');
40
+ const getServiceClient = ({ region, service, customCredentials, }) => {
41
+ var _a;
36
42
  const Client = (() => {
37
43
  if (service === 'cloudwatch') {
38
44
  return client_cloudwatch_logs_1.CloudWatchLogsClient;
@@ -49,43 +55,67 @@ const getServiceClient = (region, service) => {
49
55
  if (service === 'servicequotas') {
50
56
  return client_service_quotas_1.ServiceQuotasClient;
51
57
  }
58
+ throw new TypeError('unknown client ' + service);
52
59
  })();
53
- const key = getCredentialsKey();
54
- // @ts-expect-error
55
- if (!_clients[region][key]) {
56
- // @ts-expect-error
57
- _clients[region][key] = {};
58
- }
59
- // @ts-expect-error
60
- if (!_clients[region][key][service]) {
60
+ const key = getKey({
61
+ credentials: (_a = getCredentials()) !== null && _a !== void 0 ? _a : null,
62
+ region,
63
+ customCredentials,
64
+ service,
65
+ });
66
+ if (!_clients[key]) {
61
67
  (0, check_credentials_1.checkCredentials)();
62
- // @ts-expect-error
63
- _clients[region][key][service] = new Client({
64
- region,
65
- credentials: getCredentials(),
66
- });
68
+ if (customCredentials) {
69
+ _clients[key] = new Client({
70
+ region: 'us-east-1',
71
+ credentials: customCredentials.accessKeyId && customCredentials.secretAccessKey
72
+ ? {
73
+ accessKeyId: customCredentials.accessKeyId,
74
+ secretAccessKey: customCredentials.secretAccessKey,
75
+ }
76
+ : undefined,
77
+ endpoint: customCredentials.endpoint,
78
+ });
79
+ }
80
+ else {
81
+ _clients[key] = new Client({
82
+ region,
83
+ credentials: getCredentials(),
84
+ });
85
+ }
67
86
  }
68
- // @ts-expect-error
69
- return _clients[region][key][service];
87
+ return _clients[key];
70
88
  };
71
89
  exports.getServiceClient = getServiceClient;
72
90
  const getCloudWatchLogsClient = (region) => {
73
- return (0, exports.getServiceClient)(region, 'cloudwatch');
91
+ return (0, exports.getServiceClient)({
92
+ region,
93
+ service: 'cloudwatch',
94
+ customCredentials: null,
95
+ });
74
96
  };
75
97
  exports.getCloudWatchLogsClient = getCloudWatchLogsClient;
76
- const getS3Client = (region) => {
77
- return (0, exports.getServiceClient)(region, 's3');
98
+ const getS3Client = (region, customCredentials) => {
99
+ return (0, exports.getServiceClient)({ region, service: 's3', customCredentials });
78
100
  };
79
101
  exports.getS3Client = getS3Client;
80
102
  const getLambdaClient = (region) => {
81
- return (0, exports.getServiceClient)(region, 'lambda');
103
+ return (0, exports.getServiceClient)({
104
+ region,
105
+ service: 'lambda',
106
+ customCredentials: null,
107
+ });
82
108
  };
83
109
  exports.getLambdaClient = getLambdaClient;
84
110
  const getIamClient = (region) => {
85
- return (0, exports.getServiceClient)(region, 'iam');
111
+ return (0, exports.getServiceClient)({ region, service: 'iam', customCredentials: null });
86
112
  };
87
113
  exports.getIamClient = getIamClient;
88
114
  const getServiceQuotasClient = (region) => {
89
- return (0, exports.getServiceClient)(region, 'servicequotas');
115
+ return (0, exports.getServiceClient)({
116
+ region,
117
+ service: 'servicequotas',
118
+ customCredentials: null,
119
+ });
90
120
  };
91
121
  exports.getServiceQuotasClient = getServiceQuotasClient;
@@ -3,6 +3,7 @@ import type { VideoConfig } from 'remotion';
3
3
  import type { ChunkRetry } from '../functions/helpers/get-retry-stats';
4
4
  import type { EnhancedErrorInfo } from '../functions/helpers/write-lambda-error';
5
5
  import type { AwsRegion } from '../pricing/aws-regions';
6
+ import type { CustomCredentials, CustomCredentialsWithoutSensitiveData } from './aws-clients';
6
7
  import type { DownloadBehavior } from './content-disposition-header';
7
8
  import type { ExpensiveChunk } from './get-most-expensive-chunks';
8
9
  import type { LambdaArchitecture } from './validate-architecture';
@@ -62,10 +63,17 @@ export declare const getErrorFileName: ({ renderId, chunk, attempt, }: {
62
63
  export declare type OutNameInput = string | {
63
64
  bucketName: string;
64
65
  key: string;
66
+ s3OutputProvider?: CustomCredentials;
67
+ };
68
+ export declare type OutNameInputWithoutCredentials = string | {
69
+ bucketName: string;
70
+ key: string;
71
+ s3OutputProvider?: CustomCredentialsWithoutSensitiveData;
65
72
  };
66
73
  export declare type OutNameOutput = {
67
74
  renderBucketName: string;
68
75
  key: string;
76
+ customCredentials: CustomCredentials | null;
69
77
  };
70
78
  export declare const optimizationProfile: (siteId: string, compositionId: string) => string;
71
79
  export declare const getSitesKey: (siteId: string) => string;
@@ -151,6 +159,7 @@ export declare type LambdaPayloads = {
151
159
  bucketName: string;
152
160
  renderId: string;
153
161
  version: string;
162
+ s3OutputProvider?: CustomCredentials;
154
163
  };
155
164
  renderer: {
156
165
  concurrencyPerLambda: number;
@@ -229,7 +238,8 @@ export declare type RenderMetadata = {
229
238
  lambdaVersion: string;
230
239
  region: AwsRegion;
231
240
  renderId: string;
232
- outName: OutNameInput | undefined;
241
+ outName: OutNameInputWithoutCredentials | undefined;
242
+ privacy: Privacy;
233
243
  };
234
244
  export declare type PostRenderData = {
235
245
  cost: {
@@ -60,13 +60,19 @@ exports.outName = outName;
60
60
  const outStillName = (renderId, imageFormat) => `${(0, exports.rendersPrefix)(renderId)}/out.${imageFormat}`;
61
61
  exports.outStillName = outStillName;
62
62
  const customOutName = (renderId, bucketName, name) => {
63
+ var _a;
63
64
  if (typeof name === 'string') {
64
65
  return {
65
66
  renderBucketName: bucketName,
66
67
  key: `${(0, exports.rendersPrefix)(renderId)}/${name}`,
68
+ customCredentials: null,
67
69
  };
68
70
  }
69
- return { key: name.key, renderBucketName: name.bucketName };
71
+ return {
72
+ key: name.key,
73
+ renderBucketName: name.bucketName,
74
+ customCredentials: (_a = name.s3OutputProvider) !== null && _a !== void 0 ? _a : null,
75
+ };
70
76
  };
71
77
  exports.customOutName = customOutName;
72
78
  const postRenderDataKey = (renderId) => {
@@ -1,2 +1,2 @@
1
- import type { OutNameInput } from './constants';
2
- export declare const validateOutname: (outName: OutNameInput | undefined | null) => void;
1
+ import type { OutNameInputWithoutCredentials } from './constants';
2
+ export declare const validateOutname: (outName: OutNameInputWithoutCredentials | undefined | null) => void;