@remotion/lambda-client 4.0.354 → 4.0.356
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/.turbo/turbo-make.log +2 -2
- package/.turbo/turbo-test.log +16 -11
- package/dist/app-router-webhook.d.ts +3 -3
- package/dist/app-router-webhook.js +21 -13
- package/dist/esm/index.mjs +88 -59
- package/dist/express-webhook.d.ts +1 -1
- package/dist/express-webhook.js +26 -18
- package/dist/pages-router-webhook.d.ts +1 -1
- package/dist/pages-router-webhook.js +26 -18
- package/package.json +3 -3
- package/src/app-router-webhook.ts +25 -16
- package/src/express-webhook.ts +25 -18
- package/src/pages-router-webhook.ts +29 -19
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-make.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @remotion/lambda-client@4.0.
|
|
3
|
+
> @remotion/lambda-client@4.0.356 make /Users/jonathanburger/remotion/packages/lambda-client
|
|
4
4
|
> tsc -d && bun --env-file=../.env.bundle bundle.ts
|
|
5
5
|
|
|
6
|
-
[0m[2m[[
|
|
6
|
+
[0m[2m[[1m449.07ms[0m[2m][0m Generated.
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[0m[
|
|
2
|
+
[0m[2m[35m$[0m [2m[1mbun test src[0m
|
|
3
|
+
[0m[1mbun test [0m[2mv1.2.21 (7c45ed97)[0m
|
|
4
|
+
[0m
|
|
5
|
+
src/test/request-handler.test.ts:
|
|
6
|
+
[0m[32m✓[0m[0m[1m RequestHandler type should be properly exported and defined[0m [0m[2m[0.20ms[0m[2m][0m
|
|
7
|
+
[0m[32m✓[0m[0m[1m API input types should accept requestHandler option[0m [0m[2m[0.09ms[0m[2m][0m
|
|
8
|
+
[0m
|
|
9
|
+
src/test/concurrency-payload.test.ts:
|
|
10
|
+
[0m[32m✓[0m[0m[1m Should include concurrency field in payload[0m [0m[2m[3.45ms[0m[2m][0m
|
|
11
|
+
[0m[32m✓[0m[0m[1m Should handle null concurrency[0m [0m[2m[0.63ms[0m[2m][0m
|
|
7
12
|
[0m
|
|
8
13
|
src/test/price-calculation.test.ts:
|
|
9
|
-
[0m[32m✓[0m[0m[1m Should not throw while calculating prices when time shifts occur[0m [0m[2m[
|
|
14
|
+
[0m[32m✓[0m[0m[1m Should not throw while calculating prices when time shifts occur[0m [0m[2m[1.08ms[0m[2m][0m
|
|
10
15
|
[0m
|
|
11
16
|
src/test/pricing.test.ts:
|
|
12
|
-
[0m[32m✓[0m[0m[1m Should calculate costs accurately[0m [0m[2m[0.
|
|
17
|
+
[0m[32m✓[0m[0m[1m Should calculate costs accurately[0m [0m[2m[0.34ms[0m[2m][0m
|
|
13
18
|
[0m
|
|
14
19
|
src/test/encode-aws-url.test.ts:
|
|
15
20
|
[0m[32m✓[0m[0m[1m Encode AWS URL test[0m [0m[2m[0.17ms[0m[2m][0m
|
|
16
21
|
[0m
|
|
17
22
|
src/test/validate-disk-size-in-mb.test.ts:
|
|
18
|
-
[0m[32m✓[0m[0m[1m Disk size tests[0m [0m[2m[
|
|
23
|
+
[0m[32m✓[0m[0m[1m Disk size tests[0m [0m[2m[2.71ms[0m[2m][0m
|
|
19
24
|
|
|
20
|
-
[0m[32m
|
|
25
|
+
[0m[32m 8 pass[0m
|
|
21
26
|
[0m[2m 0 fail[0m
|
|
22
|
-
|
|
23
|
-
Ran
|
|
27
|
+
17 expect() calls
|
|
28
|
+
Ran 8 tests across 6 files. [0m[2m[[1m716.00ms[0m[2m][0m
|
|
@@ -3,8 +3,8 @@ export type NextWebhookArgs = {
|
|
|
3
3
|
testing?: boolean;
|
|
4
4
|
extraHeaders?: Record<string, string>;
|
|
5
5
|
secret: string;
|
|
6
|
-
onSuccess?: (payload: WebhookSuccessPayload) => void
|
|
7
|
-
onTimeout?: (payload: WebhookTimeoutPayload) => void
|
|
8
|
-
onError?: (payload: WebhookErrorPayload) => void
|
|
6
|
+
onSuccess?: (payload: WebhookSuccessPayload) => void | Promise<void>;
|
|
7
|
+
onTimeout?: (payload: WebhookTimeoutPayload) => void | Promise<void>;
|
|
8
|
+
onError?: (payload: WebhookErrorPayload) => void | Promise<void>;
|
|
9
9
|
};
|
|
10
10
|
export declare const appRouterWebhook: (options: NextWebhookArgs) => ((req: Request) => Promise<Response>);
|
|
@@ -22,20 +22,28 @@ const appRouterWebhook = (options) => {
|
|
|
22
22
|
}
|
|
23
23
|
// Parse the body properly
|
|
24
24
|
const body = await req.json();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
try {
|
|
26
|
+
(0, validate_webhook_signature_1.validateWebhookSignature)({
|
|
27
|
+
secret,
|
|
28
|
+
body,
|
|
29
|
+
signatureHeader: req.headers.get('X-Remotion-Signature'),
|
|
30
|
+
});
|
|
31
|
+
const payload = body;
|
|
32
|
+
if (payload.type === 'success' && onSuccess) {
|
|
33
|
+
await onSuccess(payload);
|
|
34
|
+
}
|
|
35
|
+
else if (payload.type === 'timeout' && onTimeout) {
|
|
36
|
+
await onTimeout(payload);
|
|
37
|
+
}
|
|
38
|
+
else if (payload.type === 'error' && onError) {
|
|
39
|
+
await onError(payload);
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
catch (err) {
|
|
43
|
+
return new Response(JSON.stringify({
|
|
44
|
+
success: false,
|
|
45
|
+
error: err instanceof Error ? err.message : String(err),
|
|
46
|
+
}), { status: 500, headers });
|
|
39
47
|
}
|
|
40
48
|
return new Response(JSON.stringify({ success: true }), { headers });
|
|
41
49
|
};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -16679,7 +16679,7 @@ var validateDownloadBehavior = (downloadBehavior) => {
|
|
|
16679
16679
|
}
|
|
16680
16680
|
}
|
|
16681
16681
|
};
|
|
16682
|
-
var VERSION = "4.0.
|
|
16682
|
+
var VERSION = "4.0.356";
|
|
16683
16683
|
var isColorSupported = () => {
|
|
16684
16684
|
const env = process.env || {};
|
|
16685
16685
|
const isForceDisabled = "NO_COLOR" in env;
|
|
@@ -16844,6 +16844,23 @@ var verboseTag = (str) => {
|
|
|
16844
16844
|
return isColorSupported() ? chalk.bgBlack(` ${str} `) : `[${str}]`;
|
|
16845
16845
|
};
|
|
16846
16846
|
var Log = {
|
|
16847
|
+
formatLogs: (logLevel, options, args) => {
|
|
16848
|
+
return [
|
|
16849
|
+
options.indent ? INDENT_TOKEN : null,
|
|
16850
|
+
options.tag ? verboseTag(options.tag) : null
|
|
16851
|
+
].filter(truthy2).concat(args.map((a) => {
|
|
16852
|
+
if (logLevel === "warn") {
|
|
16853
|
+
return chalk.yellow(a);
|
|
16854
|
+
}
|
|
16855
|
+
if (logLevel === "error") {
|
|
16856
|
+
return chalk.red(a);
|
|
16857
|
+
}
|
|
16858
|
+
if (logLevel === "verbose" || logLevel === "trace") {
|
|
16859
|
+
return chalk.gray(a);
|
|
16860
|
+
}
|
|
16861
|
+
return a;
|
|
16862
|
+
}));
|
|
16863
|
+
},
|
|
16847
16864
|
trace: (options, ...args) => {
|
|
16848
16865
|
writeInRepro("trace", ...args);
|
|
16849
16866
|
if (isEqualOrBelowLogLevel(options.logLevel, "trace")) {
|
|
@@ -16851,10 +16868,7 @@ var Log = {
|
|
|
16851
16868
|
return process.stdout.write(`
|
|
16852
16869
|
`);
|
|
16853
16870
|
}
|
|
16854
|
-
return console.log(...
|
|
16855
|
-
options.indent ? INDENT_TOKEN : null,
|
|
16856
|
-
options.tag ? verboseTag(options.tag) : null
|
|
16857
|
-
].filter(truthy2).concat(args.map((a) => chalk.gray(a))));
|
|
16871
|
+
return console.log(...Log.formatLogs("trace", options, args));
|
|
16858
16872
|
}
|
|
16859
16873
|
},
|
|
16860
16874
|
verbose: (options, ...args) => {
|
|
@@ -16864,10 +16878,7 @@ var Log = {
|
|
|
16864
16878
|
return process.stdout.write(`
|
|
16865
16879
|
`);
|
|
16866
16880
|
}
|
|
16867
|
-
return console.log(...
|
|
16868
|
-
options.indent ? INDENT_TOKEN : null,
|
|
16869
|
-
options.tag ? verboseTag(options.tag) : null
|
|
16870
|
-
].filter(truthy2).concat(args.map((a) => chalk.gray(a))));
|
|
16881
|
+
return console.log(...Log.formatLogs("verbose", options, args));
|
|
16871
16882
|
}
|
|
16872
16883
|
},
|
|
16873
16884
|
info: (options, ...args) => {
|
|
@@ -16877,7 +16888,7 @@ var Log = {
|
|
|
16877
16888
|
return process.stdout.write(`
|
|
16878
16889
|
`);
|
|
16879
16890
|
}
|
|
16880
|
-
return console.log(...
|
|
16891
|
+
return console.log(...Log.formatLogs("info", options, args));
|
|
16881
16892
|
}
|
|
16882
16893
|
},
|
|
16883
16894
|
warn: (options, ...args) => {
|
|
@@ -16887,7 +16898,7 @@ var Log = {
|
|
|
16887
16898
|
return process.stdout.write(`
|
|
16888
16899
|
`);
|
|
16889
16900
|
}
|
|
16890
|
-
return console.warn(...
|
|
16901
|
+
return console.warn(...Log.formatLogs("warn", options, args));
|
|
16891
16902
|
}
|
|
16892
16903
|
},
|
|
16893
16904
|
error: (options, ...args) => {
|
|
@@ -16897,10 +16908,7 @@ var Log = {
|
|
|
16897
16908
|
return process.stdout.write(`
|
|
16898
16909
|
`);
|
|
16899
16910
|
}
|
|
16900
|
-
return console.error(...
|
|
16901
|
-
options.indent ? INDENT_TOKEN : null,
|
|
16902
|
-
options.tag ? verboseTag(options.tag) : null
|
|
16903
|
-
].filter(truthy2).concat(args.map((a) => chalk.red(a))));
|
|
16911
|
+
return console.error(...Log.formatLogs("error", options, args));
|
|
16904
16912
|
}
|
|
16905
16913
|
}
|
|
16906
16914
|
};
|
|
@@ -21624,18 +21632,25 @@ var appRouterWebhook = (options) => {
|
|
|
21624
21632
|
});
|
|
21625
21633
|
}
|
|
21626
21634
|
const body = await req.json();
|
|
21627
|
-
|
|
21628
|
-
|
|
21629
|
-
|
|
21630
|
-
|
|
21631
|
-
|
|
21632
|
-
|
|
21633
|
-
|
|
21634
|
-
|
|
21635
|
-
|
|
21636
|
-
|
|
21637
|
-
|
|
21638
|
-
|
|
21635
|
+
try {
|
|
21636
|
+
validateWebhookSignature({
|
|
21637
|
+
secret,
|
|
21638
|
+
body,
|
|
21639
|
+
signatureHeader: req.headers.get("X-Remotion-Signature")
|
|
21640
|
+
});
|
|
21641
|
+
const payload = body;
|
|
21642
|
+
if (payload.type === "success" && onSuccess) {
|
|
21643
|
+
await onSuccess(payload);
|
|
21644
|
+
} else if (payload.type === "timeout" && onTimeout) {
|
|
21645
|
+
await onTimeout(payload);
|
|
21646
|
+
} else if (payload.type === "error" && onError) {
|
|
21647
|
+
await onError(payload);
|
|
21648
|
+
}
|
|
21649
|
+
} catch (err) {
|
|
21650
|
+
return new Response(JSON.stringify({
|
|
21651
|
+
success: false,
|
|
21652
|
+
error: err instanceof Error ? err.message : String(err)
|
|
21653
|
+
}), { status: 500, headers });
|
|
21639
21654
|
}
|
|
21640
21655
|
return new Response(JSON.stringify({ success: true }), { headers });
|
|
21641
21656
|
};
|
|
@@ -21648,7 +21663,7 @@ var addHeaders = (res, headers) => {
|
|
|
21648
21663
|
};
|
|
21649
21664
|
var pagesRouterWebhook = (options) => {
|
|
21650
21665
|
const { testing, extraHeaders, secret, onSuccess, onTimeout, onError } = options;
|
|
21651
|
-
return function(req, res) {
|
|
21666
|
+
return async function(req, res) {
|
|
21652
21667
|
addHeaders(res, extraHeaders || {});
|
|
21653
21668
|
if (testing) {
|
|
21654
21669
|
const testingheaders = {
|
|
@@ -21662,29 +21677,36 @@ var pagesRouterWebhook = (options) => {
|
|
|
21662
21677
|
res.status(200).end();
|
|
21663
21678
|
return;
|
|
21664
21679
|
}
|
|
21665
|
-
|
|
21666
|
-
|
|
21667
|
-
|
|
21668
|
-
|
|
21669
|
-
|
|
21670
|
-
|
|
21671
|
-
|
|
21672
|
-
|
|
21673
|
-
|
|
21674
|
-
|
|
21675
|
-
|
|
21676
|
-
|
|
21677
|
-
|
|
21678
|
-
|
|
21679
|
-
|
|
21680
|
-
|
|
21680
|
+
try {
|
|
21681
|
+
validateWebhookSignature({
|
|
21682
|
+
secret,
|
|
21683
|
+
body: req.body,
|
|
21684
|
+
signatureHeader: req.headers["x-remotion-signature"]
|
|
21685
|
+
});
|
|
21686
|
+
const payload = req.body;
|
|
21687
|
+
if (payload.type === "success" && onSuccess) {
|
|
21688
|
+
await onSuccess(payload);
|
|
21689
|
+
} else if (payload.type === "timeout" && onTimeout) {
|
|
21690
|
+
await onTimeout(payload);
|
|
21691
|
+
} else if (payload.type === "error" && onError) {
|
|
21692
|
+
await onError(payload);
|
|
21693
|
+
}
|
|
21694
|
+
res.status(200).json({
|
|
21695
|
+
success: true
|
|
21696
|
+
});
|
|
21697
|
+
} catch (err) {
|
|
21698
|
+
res.status(500).json({
|
|
21699
|
+
success: false,
|
|
21700
|
+
error: err instanceof Error ? err.message : String(err)
|
|
21701
|
+
});
|
|
21702
|
+
}
|
|
21681
21703
|
};
|
|
21682
21704
|
};
|
|
21683
21705
|
|
|
21684
21706
|
// src/express-webhook.ts
|
|
21685
21707
|
var expressWebhook = (options) => {
|
|
21686
21708
|
const { testing, extraHeaders, secret, onSuccess, onTimeout, onError } = options;
|
|
21687
|
-
return (req, res) => {
|
|
21709
|
+
return async (req, res) => {
|
|
21688
21710
|
if (testing) {
|
|
21689
21711
|
const testingheaders = {
|
|
21690
21712
|
"Access-Control-Allow-Origin": "https://www.remotion.dev",
|
|
@@ -21698,20 +21720,27 @@ var expressWebhook = (options) => {
|
|
|
21698
21720
|
res.status(200).end();
|
|
21699
21721
|
return;
|
|
21700
21722
|
}
|
|
21701
|
-
|
|
21702
|
-
|
|
21703
|
-
|
|
21704
|
-
|
|
21705
|
-
|
|
21706
|
-
|
|
21707
|
-
|
|
21708
|
-
|
|
21709
|
-
|
|
21710
|
-
|
|
21711
|
-
|
|
21712
|
-
|
|
21713
|
-
|
|
21714
|
-
|
|
21723
|
+
try {
|
|
21724
|
+
validateWebhookSignature({
|
|
21725
|
+
signatureHeader: req.header("X-Remotion-Signature"),
|
|
21726
|
+
body: req.body,
|
|
21727
|
+
secret
|
|
21728
|
+
});
|
|
21729
|
+
const payload = req.body;
|
|
21730
|
+
if (payload.type === "success" && onSuccess) {
|
|
21731
|
+
await onSuccess(payload);
|
|
21732
|
+
} else if (payload.type === "error" && onError) {
|
|
21733
|
+
await onError(payload);
|
|
21734
|
+
} else if (payload.type === "timeout" && onTimeout) {
|
|
21735
|
+
await onTimeout(payload);
|
|
21736
|
+
}
|
|
21737
|
+
res.status(200).json({ success: true });
|
|
21738
|
+
} catch (err) {
|
|
21739
|
+
res.status(500).json({
|
|
21740
|
+
success: false,
|
|
21741
|
+
error: err instanceof Error ? err.message : String(err)
|
|
21742
|
+
});
|
|
21743
|
+
}
|
|
21715
21744
|
};
|
|
21716
21745
|
};
|
|
21717
21746
|
// src/get-aws-client.ts
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Request, Response } from 'express';
|
|
2
2
|
import type { NextWebhookArgs } from './app-router-webhook';
|
|
3
|
-
export declare const expressWebhook: (options: NextWebhookArgs) => (req: Request, res: Response) => void
|
|
3
|
+
export declare const expressWebhook: (options: NextWebhookArgs) => (req: Request, res: Response) => Promise<void>;
|
package/dist/express-webhook.js
CHANGED
|
@@ -5,7 +5,7 @@ const pages_router_webhook_1 = require("./pages-router-webhook");
|
|
|
5
5
|
const validate_webhook_signature_1 = require("./validate-webhook-signature");
|
|
6
6
|
const expressWebhook = (options) => {
|
|
7
7
|
const { testing, extraHeaders, secret, onSuccess, onTimeout, onError } = options;
|
|
8
|
-
return (req, res) => {
|
|
8
|
+
return async (req, res) => {
|
|
9
9
|
// add headers to enable testing
|
|
10
10
|
if (testing) {
|
|
11
11
|
const testingheaders = {
|
|
@@ -22,25 +22,33 @@ const expressWebhook = (options) => {
|
|
|
22
22
|
res.status(200).end();
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
try {
|
|
26
|
+
// validate the webhook signature
|
|
27
|
+
(0, validate_webhook_signature_1.validateWebhookSignature)({
|
|
28
|
+
signatureHeader: req.header('X-Remotion-Signature'),
|
|
29
|
+
body: req.body,
|
|
30
|
+
secret,
|
|
31
|
+
});
|
|
32
|
+
// custom logic
|
|
33
|
+
const payload = req.body;
|
|
34
|
+
if (payload.type === 'success' && onSuccess) {
|
|
35
|
+
await onSuccess(payload);
|
|
36
|
+
}
|
|
37
|
+
else if (payload.type === 'error' && onError) {
|
|
38
|
+
await onError(payload);
|
|
39
|
+
}
|
|
40
|
+
else if (payload.type === 'timeout' && onTimeout) {
|
|
41
|
+
await onTimeout(payload);
|
|
42
|
+
}
|
|
43
|
+
// send response
|
|
44
|
+
res.status(200).json({ success: true });
|
|
35
45
|
}
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
catch (err) {
|
|
47
|
+
res.status(500).json({
|
|
48
|
+
success: false,
|
|
49
|
+
error: err instanceof Error ? err.message : String(err),
|
|
50
|
+
});
|
|
38
51
|
}
|
|
39
|
-
else if (payload.type === 'timeout' && onTimeout) {
|
|
40
|
-
onTimeout(payload);
|
|
41
|
-
}
|
|
42
|
-
// send response
|
|
43
|
-
res.status(200).json({ success: true });
|
|
44
52
|
};
|
|
45
53
|
};
|
|
46
54
|
exports.expressWebhook = expressWebhook;
|
|
@@ -2,4 +2,4 @@ import type { Response } from 'express';
|
|
|
2
2
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
3
3
|
import type { NextWebhookArgs } from './app-router-webhook';
|
|
4
4
|
export declare const addHeaders: (res: NextApiResponse | Response, headers: Record<string, string>) => void;
|
|
5
|
-
export declare const pagesRouterWebhook: (options: NextWebhookArgs) => (req: NextApiRequest, res: NextApiResponse) => void
|
|
5
|
+
export declare const pagesRouterWebhook: (options: NextWebhookArgs) => (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
@@ -10,7 +10,7 @@ const addHeaders = (res, headers) => {
|
|
|
10
10
|
exports.addHeaders = addHeaders;
|
|
11
11
|
const pagesRouterWebhook = (options) => {
|
|
12
12
|
const { testing, extraHeaders, secret, onSuccess, onTimeout, onError } = options;
|
|
13
|
-
return function (req, res) {
|
|
13
|
+
return async function (req, res) {
|
|
14
14
|
(0, exports.addHeaders)(res, extraHeaders || {});
|
|
15
15
|
if (testing) {
|
|
16
16
|
const testingheaders = {
|
|
@@ -24,25 +24,33 @@ const pagesRouterWebhook = (options) => {
|
|
|
24
24
|
res.status(200).end();
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
try {
|
|
28
|
+
(0, validate_webhook_signature_1.validateWebhookSignature)({
|
|
29
|
+
secret,
|
|
30
|
+
body: req.body,
|
|
31
|
+
signatureHeader: req.headers['x-remotion-signature'],
|
|
32
|
+
});
|
|
33
|
+
// If code reaches this path, the webhook is authentic.
|
|
34
|
+
const payload = req.body;
|
|
35
|
+
if (payload.type === 'success' && onSuccess) {
|
|
36
|
+
await onSuccess(payload);
|
|
37
|
+
}
|
|
38
|
+
else if (payload.type === 'timeout' && onTimeout) {
|
|
39
|
+
await onTimeout(payload);
|
|
40
|
+
}
|
|
41
|
+
else if (payload.type === 'error' && onError) {
|
|
42
|
+
await onError(payload);
|
|
43
|
+
}
|
|
44
|
+
res.status(200).json({
|
|
45
|
+
success: true,
|
|
46
|
+
});
|
|
36
47
|
}
|
|
37
|
-
|
|
38
|
-
|
|
48
|
+
catch (err) {
|
|
49
|
+
res.status(500).json({
|
|
50
|
+
success: false,
|
|
51
|
+
error: err instanceof Error ? err.message : String(err),
|
|
52
|
+
});
|
|
39
53
|
}
|
|
40
|
-
else if (payload.type === 'error' && onError) {
|
|
41
|
-
onError(payload);
|
|
42
|
-
}
|
|
43
|
-
res.status(200).json({
|
|
44
|
-
success: true,
|
|
45
|
-
});
|
|
46
54
|
};
|
|
47
55
|
};
|
|
48
56
|
exports.pagesRouterWebhook = pagesRouterWebhook;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/lambda-client"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/lambda-client",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.356",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"author": "Jonny Burger <jonny@remotion.dev>",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"eslint": "9.19.0",
|
|
27
27
|
"next": "15.4.7",
|
|
28
28
|
"@types/mime-types": "2.1.1",
|
|
29
|
-
"@remotion/serverless-client": "4.0.
|
|
30
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
29
|
+
"@remotion/serverless-client": "4.0.356",
|
|
30
|
+
"@remotion/eslint-config-internal": "4.0.356"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
@@ -10,9 +10,9 @@ export type NextWebhookArgs = {
|
|
|
10
10
|
testing?: boolean;
|
|
11
11
|
extraHeaders?: Record<string, string>;
|
|
12
12
|
secret: string;
|
|
13
|
-
onSuccess?: (payload: WebhookSuccessPayload) => void
|
|
14
|
-
onTimeout?: (payload: WebhookTimeoutPayload) => void
|
|
15
|
-
onError?: (payload: WebhookErrorPayload) => void
|
|
13
|
+
onSuccess?: (payload: WebhookSuccessPayload) => void | Promise<void>;
|
|
14
|
+
onTimeout?: (payload: WebhookTimeoutPayload) => void | Promise<void>;
|
|
15
|
+
onError?: (payload: WebhookErrorPayload) => void | Promise<void>;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export const appRouterWebhook = (
|
|
@@ -43,20 +43,29 @@ export const appRouterWebhook = (
|
|
|
43
43
|
// Parse the body properly
|
|
44
44
|
const body = await req.json();
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const payload = body as WebhookPayload;
|
|
46
|
+
try {
|
|
47
|
+
validateWebhookSignature({
|
|
48
|
+
secret,
|
|
49
|
+
body,
|
|
50
|
+
signatureHeader: req.headers.get('X-Remotion-Signature') as string,
|
|
51
|
+
});
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
const payload = body as WebhookPayload;
|
|
54
|
+
if (payload.type === 'success' && onSuccess) {
|
|
55
|
+
await onSuccess(payload);
|
|
56
|
+
} else if (payload.type === 'timeout' && onTimeout) {
|
|
57
|
+
await onTimeout(payload);
|
|
58
|
+
} else if (payload.type === 'error' && onError) {
|
|
59
|
+
await onError(payload);
|
|
60
|
+
}
|
|
61
|
+
} catch (err) {
|
|
62
|
+
return new Response(
|
|
63
|
+
JSON.stringify({
|
|
64
|
+
success: false,
|
|
65
|
+
error: err instanceof Error ? err.message : String(err),
|
|
66
|
+
}),
|
|
67
|
+
{status: 500, headers},
|
|
68
|
+
);
|
|
60
69
|
}
|
|
61
70
|
|
|
62
71
|
return new Response(JSON.stringify({success: true}), {headers});
|
package/src/express-webhook.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {validateWebhookSignature} from './validate-webhook-signature';
|
|
|
6
6
|
export const expressWebhook = (options: NextWebhookArgs) => {
|
|
7
7
|
const {testing, extraHeaders, secret, onSuccess, onTimeout, onError} =
|
|
8
8
|
options;
|
|
9
|
-
return (req: Request, res: Response) => {
|
|
9
|
+
return async (req: Request, res: Response) => {
|
|
10
10
|
// add headers to enable testing
|
|
11
11
|
if (testing) {
|
|
12
12
|
const testingheaders = {
|
|
@@ -27,24 +27,31 @@ export const expressWebhook = (options: NextWebhookArgs) => {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
try {
|
|
31
|
+
// validate the webhook signature
|
|
32
|
+
validateWebhookSignature({
|
|
33
|
+
signatureHeader: req.header('X-Remotion-Signature') as string,
|
|
34
|
+
body: req.body,
|
|
35
|
+
secret,
|
|
36
|
+
});
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
// custom logic
|
|
39
|
+
const payload = req.body;
|
|
40
|
+
if (payload.type === 'success' && onSuccess) {
|
|
41
|
+
await onSuccess(payload);
|
|
42
|
+
} else if (payload.type === 'error' && onError) {
|
|
43
|
+
await onError(payload);
|
|
44
|
+
} else if (payload.type === 'timeout' && onTimeout) {
|
|
45
|
+
await onTimeout(payload);
|
|
46
|
+
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
// send response
|
|
49
|
+
res.status(200).json({success: true});
|
|
50
|
+
} catch (err) {
|
|
51
|
+
res.status(500).json({
|
|
52
|
+
success: false,
|
|
53
|
+
error: err instanceof Error ? err.message : String(err),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
49
56
|
};
|
|
50
57
|
};
|