@scalemule/nextjs 0.1.38 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +33 -3
- package/dist/client.mjs +33 -3
- package/dist/{index-Tq5WdDfS.d.mts → index-Bv1m_qQ8.d.mts} +20 -0
- package/dist/{index-Tq5WdDfS.d.ts → index-Bv1m_qQ8.d.ts} +20 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +33 -3
- package/dist/index.mjs +33 -3
- package/dist/server/auth.js +110 -62
- package/dist/server/auth.mjs +111 -63
- package/dist/server/index.d.mts +24 -4
- package/dist/server/index.d.ts +24 -4
- package/dist/server/index.js +161 -103
- package/dist/server/index.mjs +161 -103
- package/dist/server/webhook-handler.d.mts +2 -2
- package/dist/server/webhook-handler.d.ts +2 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +3 -0
- package/dist/testing.mjs +3 -0
- package/dist/{webhook-handler-Cfa7-yKN.d.ts → webhook-handler-5ymVecTD.d.ts} +1 -1
- package/dist/{webhook-handler-DN4WBjbm.d.mts → webhook-handler-CVmBvPFN.d.mts} +1 -1
- package/package.json +4 -3
package/dist/server/auth.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createMoneyClient } from '@scalemule/money';
|
|
2
|
-
import { cookies } from 'next/headers';
|
|
2
|
+
import { cookies, headers } from 'next/headers';
|
|
3
3
|
import 'next/server';
|
|
4
4
|
|
|
5
5
|
// src/types/index.ts
|
|
@@ -10,6 +10,9 @@ var ScaleMuleApiError = class extends Error {
|
|
|
10
10
|
this.code = error.code;
|
|
11
11
|
this.field = error.field;
|
|
12
12
|
this.status = status;
|
|
13
|
+
this.requestId = error.requestId;
|
|
14
|
+
this.traceId = error.traceId;
|
|
15
|
+
this.problem = error.problem;
|
|
13
16
|
}
|
|
14
17
|
};
|
|
15
18
|
|
|
@@ -27,40 +30,40 @@ function validateIP(ip) {
|
|
|
27
30
|
return void 0;
|
|
28
31
|
}
|
|
29
32
|
function extractClientContext(request) {
|
|
30
|
-
const
|
|
33
|
+
const headers2 = request.headers;
|
|
31
34
|
let ip;
|
|
32
|
-
const cfConnectingIp =
|
|
35
|
+
const cfConnectingIp = headers2.get("cf-connecting-ip");
|
|
33
36
|
if (cfConnectingIp) {
|
|
34
37
|
ip = validateIP(cfConnectingIp);
|
|
35
38
|
}
|
|
36
39
|
if (!ip) {
|
|
37
|
-
const doConnectingIp =
|
|
40
|
+
const doConnectingIp = headers2.get("do-connecting-ip");
|
|
38
41
|
if (doConnectingIp) {
|
|
39
42
|
ip = validateIP(doConnectingIp);
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
if (!ip) {
|
|
43
|
-
const realIp =
|
|
46
|
+
const realIp = headers2.get("x-real-ip");
|
|
44
47
|
if (realIp) {
|
|
45
48
|
ip = validateIP(realIp);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
if (!ip) {
|
|
49
|
-
const forwardedFor =
|
|
52
|
+
const forwardedFor = headers2.get("x-forwarded-for");
|
|
50
53
|
if (forwardedFor) {
|
|
51
54
|
const firstIp = forwardedFor.split(",")[0]?.trim();
|
|
52
55
|
ip = validateIP(firstIp);
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
if (!ip) {
|
|
56
|
-
const vercelForwarded =
|
|
59
|
+
const vercelForwarded = headers2.get("x-vercel-forwarded-for");
|
|
57
60
|
if (vercelForwarded) {
|
|
58
61
|
const firstIp = vercelForwarded.split(",")[0]?.trim();
|
|
59
62
|
ip = validateIP(firstIp);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
if (!ip) {
|
|
63
|
-
const trueClientIp =
|
|
66
|
+
const trueClientIp = headers2.get("true-client-ip");
|
|
64
67
|
if (trueClientIp) {
|
|
65
68
|
ip = validateIP(trueClientIp);
|
|
66
69
|
}
|
|
@@ -68,10 +71,10 @@ function extractClientContext(request) {
|
|
|
68
71
|
if (!ip && request.ip) {
|
|
69
72
|
ip = validateIP(request.ip);
|
|
70
73
|
}
|
|
71
|
-
const userAgent =
|
|
72
|
-
const deviceFingerprint =
|
|
73
|
-
const referrer =
|
|
74
|
-
const anonymousId =
|
|
74
|
+
const userAgent = headers2.get("user-agent") || void 0;
|
|
75
|
+
const deviceFingerprint = headers2.get("x-device-fingerprint") || void 0;
|
|
76
|
+
const referrer = headers2.get("referer") || void 0;
|
|
77
|
+
const anonymousId = headers2.get("x-anonymous-id") || void 0;
|
|
75
78
|
return {
|
|
76
79
|
ip,
|
|
77
80
|
userAgent,
|
|
@@ -81,27 +84,46 @@ function extractClientContext(request) {
|
|
|
81
84
|
};
|
|
82
85
|
}
|
|
83
86
|
function buildClientContextHeaders(context) {
|
|
84
|
-
const
|
|
87
|
+
const headers2 = {};
|
|
85
88
|
if (!context) {
|
|
86
|
-
return
|
|
89
|
+
return headers2;
|
|
87
90
|
}
|
|
88
91
|
if (context.ip) {
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
headers2["x-sm-forwarded-client-ip"] = context.ip;
|
|
93
|
+
headers2["X-Client-IP"] = context.ip;
|
|
91
94
|
}
|
|
92
95
|
if (context.userAgent) {
|
|
93
|
-
|
|
96
|
+
headers2["X-Client-User-Agent"] = context.userAgent;
|
|
94
97
|
}
|
|
95
98
|
if (context.deviceFingerprint) {
|
|
96
|
-
|
|
99
|
+
headers2["X-Client-Device-Fingerprint"] = context.deviceFingerprint;
|
|
97
100
|
}
|
|
98
101
|
if (context.referrer) {
|
|
99
|
-
|
|
102
|
+
headers2["X-Client-Referrer"] = context.referrer;
|
|
100
103
|
}
|
|
101
104
|
if (context.anonymousId) {
|
|
102
|
-
|
|
105
|
+
headers2["x-anonymous-id"] = context.anonymousId;
|
|
103
106
|
}
|
|
104
|
-
return
|
|
107
|
+
return headers2;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/error-context.ts
|
|
111
|
+
function withErrorContext(error, responseData, headers2) {
|
|
112
|
+
const enriched = { ...error };
|
|
113
|
+
const meta = responseData?.meta;
|
|
114
|
+
const requestId = meta?.request_id ?? headers2?.get("x-request-id") ?? void 0;
|
|
115
|
+
if (requestId !== void 0 && enriched.requestId === void 0) {
|
|
116
|
+
enriched.requestId = requestId;
|
|
117
|
+
}
|
|
118
|
+
const traceId = meta?.trace_id;
|
|
119
|
+
if (traceId !== void 0 && enriched.traceId === void 0) {
|
|
120
|
+
enriched.traceId = traceId;
|
|
121
|
+
}
|
|
122
|
+
const rawError = responseData?.error;
|
|
123
|
+
if (rawError !== null && typeof rawError === "object" && enriched.problem === void 0) {
|
|
124
|
+
enriched.problem = rawError;
|
|
125
|
+
}
|
|
126
|
+
return enriched;
|
|
105
127
|
}
|
|
106
128
|
|
|
107
129
|
// src/server/client.ts
|
|
@@ -112,6 +134,7 @@ var GATEWAY_URLS = {
|
|
|
112
134
|
function resolveGatewayUrl(config) {
|
|
113
135
|
if (config.gatewayUrl) return config.gatewayUrl;
|
|
114
136
|
if (process.env.SCALEMULE_API_URL) return process.env.SCALEMULE_API_URL;
|
|
137
|
+
if (process.env.SCALEMULE_GATEWAY_URL) return process.env.SCALEMULE_GATEWAY_URL;
|
|
115
138
|
return GATEWAY_URLS[config.environment || "prod"];
|
|
116
139
|
}
|
|
117
140
|
var ScaleMuleServer = class {
|
|
@@ -500,7 +523,7 @@ var ScaleMuleServer = class {
|
|
|
500
523
|
formData.append("file", blob, file.filename);
|
|
501
524
|
formData.append("sm_user_id", userId);
|
|
502
525
|
const url = `${this.gatewayUrl}/v1/storage/upload`;
|
|
503
|
-
const
|
|
526
|
+
const headers2 = {
|
|
504
527
|
"x-api-key": this.apiKey,
|
|
505
528
|
"x-user-id": userId,
|
|
506
529
|
...buildClientContextHeaders(options?.clientContext)
|
|
@@ -511,7 +534,7 @@ var ScaleMuleServer = class {
|
|
|
511
534
|
try {
|
|
512
535
|
const response = await fetch(url, {
|
|
513
536
|
method: "POST",
|
|
514
|
-
headers,
|
|
537
|
+
headers: headers2,
|
|
515
538
|
body: formData
|
|
516
539
|
});
|
|
517
540
|
const text = await response.text();
|
|
@@ -522,7 +545,11 @@ var ScaleMuleServer = class {
|
|
|
522
545
|
}
|
|
523
546
|
if (!response.ok) {
|
|
524
547
|
throw new ScaleMuleApiError(
|
|
525
|
-
|
|
548
|
+
withErrorContext(
|
|
549
|
+
responseData?.error || { code: "UPLOAD_FAILED", message: text || "Upload failed" },
|
|
550
|
+
responseData,
|
|
551
|
+
response.headers
|
|
552
|
+
)
|
|
526
553
|
);
|
|
527
554
|
}
|
|
528
555
|
const data = responseData?.data !== void 0 ? responseData.data : responseData;
|
|
@@ -733,14 +760,14 @@ var ScaleMuleServer = class {
|
|
|
733
760
|
*/
|
|
734
761
|
async request(method, path, options = {}) {
|
|
735
762
|
const url = `${this.gatewayUrl}${path}`;
|
|
736
|
-
const
|
|
763
|
+
const headers2 = {
|
|
737
764
|
"x-api-key": this.apiKey,
|
|
738
765
|
"Content-Type": "application/json",
|
|
739
766
|
// Forward client context headers if provided
|
|
740
767
|
...buildClientContextHeaders(options.clientContext)
|
|
741
768
|
};
|
|
742
769
|
if (options.sessionToken) {
|
|
743
|
-
|
|
770
|
+
headers2["Authorization"] = `Bearer ${options.sessionToken}`;
|
|
744
771
|
}
|
|
745
772
|
if (this.debug) {
|
|
746
773
|
console.log(`[ScaleMule Server] ${method} ${path}`);
|
|
@@ -751,7 +778,7 @@ var ScaleMuleServer = class {
|
|
|
751
778
|
try {
|
|
752
779
|
const response = await fetch(url, {
|
|
753
780
|
method,
|
|
754
|
-
headers,
|
|
781
|
+
headers: headers2,
|
|
755
782
|
body: options.body ? JSON.stringify(options.body) : void 0
|
|
756
783
|
});
|
|
757
784
|
const rotated = response.headers.get("x-rotated-session-token");
|
|
@@ -765,10 +792,11 @@ var ScaleMuleServer = class {
|
|
|
765
792
|
} catch {
|
|
766
793
|
}
|
|
767
794
|
if (!response.ok) {
|
|
768
|
-
const
|
|
795
|
+
const baseError = responseData?.error || {
|
|
769
796
|
code: `HTTP_${response.status}`,
|
|
770
797
|
message: responseData?.message || text || response.statusText
|
|
771
798
|
};
|
|
799
|
+
const error = withErrorContext(baseError, responseData, response.headers);
|
|
772
800
|
if (response.status === 401 && options.sessionToken && !options.isAutoRefresh) {
|
|
773
801
|
if (this.debug) console.log("[ScaleMule Server] 401 received, attempting auto-refresh...");
|
|
774
802
|
try {
|
|
@@ -847,66 +875,86 @@ function createCookieHeader(name, value, options = {}) {
|
|
|
847
875
|
}
|
|
848
876
|
function createClearCookieHeader(name, options = {}) {
|
|
849
877
|
const path = options.path ?? "/";
|
|
850
|
-
|
|
878
|
+
const secure = options.secure ?? process.env.NODE_ENV === "production";
|
|
879
|
+
const sameSite = options.sameSite ?? "lax";
|
|
880
|
+
let cookie = `${name}=; Path=${path}; Max-Age=0; HttpOnly; SameSite=${sameSite}`;
|
|
881
|
+
if (secure) {
|
|
882
|
+
cookie += "; Secure";
|
|
883
|
+
}
|
|
851
884
|
if (options.domain) {
|
|
852
885
|
cookie += `; Domain=${options.domain}`;
|
|
853
886
|
}
|
|
854
887
|
return cookie;
|
|
855
888
|
}
|
|
856
889
|
function withSession(loginResponse, responseBody, options = {}) {
|
|
857
|
-
const
|
|
858
|
-
|
|
859
|
-
|
|
890
|
+
const headers2 = new Headers();
|
|
891
|
+
headers2.set("Content-Type", "application/json");
|
|
892
|
+
headers2.append(
|
|
860
893
|
"Set-Cookie",
|
|
861
894
|
createCookieHeader(SESSION_COOKIE_NAME, loginResponse.session_token, options)
|
|
862
895
|
);
|
|
863
|
-
|
|
896
|
+
headers2.append(
|
|
864
897
|
"Set-Cookie",
|
|
865
898
|
createCookieHeader(USER_ID_COOKIE_NAME, loginResponse.user.id, options)
|
|
866
899
|
);
|
|
867
900
|
return new Response(JSON.stringify({ success: true, data: responseBody }), {
|
|
868
901
|
status: 200,
|
|
869
|
-
headers
|
|
902
|
+
headers: headers2
|
|
870
903
|
});
|
|
871
904
|
}
|
|
872
905
|
function withRefreshedSession(sessionToken, userId, responseBody, options = {}) {
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
|
|
906
|
+
const headers2 = new Headers();
|
|
907
|
+
headers2.set("Content-Type", "application/json");
|
|
908
|
+
headers2.append(
|
|
876
909
|
"Set-Cookie",
|
|
877
910
|
createCookieHeader(SESSION_COOKIE_NAME, sessionToken, options)
|
|
878
911
|
);
|
|
879
|
-
|
|
912
|
+
headers2.append(
|
|
880
913
|
"Set-Cookie",
|
|
881
914
|
createCookieHeader(USER_ID_COOKIE_NAME, userId, options)
|
|
882
915
|
);
|
|
883
916
|
return new Response(JSON.stringify({ success: true, data: responseBody }), {
|
|
884
917
|
status: 200,
|
|
885
|
-
headers
|
|
918
|
+
headers: headers2
|
|
886
919
|
});
|
|
887
920
|
}
|
|
888
921
|
function clearSession(responseBody, options = {}, status = 200) {
|
|
889
|
-
const
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
922
|
+
const headers2 = new Headers();
|
|
923
|
+
headers2.set("Content-Type", "application/json");
|
|
924
|
+
headers2.append("Set-Cookie", createClearCookieHeader(SESSION_COOKIE_NAME, options));
|
|
925
|
+
headers2.append("Set-Cookie", createClearCookieHeader(USER_ID_COOKIE_NAME, options));
|
|
893
926
|
return new Response(JSON.stringify({ success: status < 300, data: responseBody }), {
|
|
894
927
|
status,
|
|
895
|
-
headers
|
|
928
|
+
headers: headers2
|
|
896
929
|
});
|
|
897
930
|
}
|
|
898
931
|
async function getSession() {
|
|
899
932
|
const cookieStore = await cookies();
|
|
900
933
|
const sessionCookie = cookieStore.get(SESSION_COOKIE_NAME);
|
|
901
934
|
const userIdCookie = cookieStore.get(USER_ID_COOKIE_NAME);
|
|
902
|
-
if (
|
|
903
|
-
return
|
|
935
|
+
if (sessionCookie?.value && userIdCookie?.value) {
|
|
936
|
+
return {
|
|
937
|
+
sessionToken: sessionCookie.value,
|
|
938
|
+
userId: userIdCookie.value,
|
|
939
|
+
expiresAt: /* @__PURE__ */ new Date()
|
|
940
|
+
// Note: actual expiry is managed by ScaleMule backend
|
|
941
|
+
};
|
|
904
942
|
}
|
|
943
|
+
const headerStore = await headers();
|
|
944
|
+
return sessionFromAuthHeaders(
|
|
945
|
+
headerStore.get("authorization"),
|
|
946
|
+
headerStore.get("x-sm-user-id")
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
function sessionFromAuthHeaders(authorization, userId) {
|
|
950
|
+
if (!authorization || !userId) return null;
|
|
951
|
+
const match = /^Bearer\s+(.+)$/i.exec(authorization.trim());
|
|
952
|
+
const token = match?.[1]?.trim();
|
|
953
|
+
if (!token) return null;
|
|
905
954
|
return {
|
|
906
|
-
sessionToken:
|
|
907
|
-
userId
|
|
955
|
+
sessionToken: token,
|
|
956
|
+
userId,
|
|
908
957
|
expiresAt: /* @__PURE__ */ new Date()
|
|
909
|
-
// Note: actual expiry is managed by ScaleMule backend
|
|
910
958
|
};
|
|
911
959
|
}
|
|
912
960
|
var MAX_KNOWN_ACCOUNTS = 10;
|
|
@@ -948,7 +996,7 @@ function applyPrivacyToEntry(entry, privacy) {
|
|
|
948
996
|
};
|
|
949
997
|
}
|
|
950
998
|
}
|
|
951
|
-
function appendKnownAccountCookie(
|
|
999
|
+
function appendKnownAccountCookie(headers2, account, existingCookie, options = {}, privacy) {
|
|
952
1000
|
let accounts = {};
|
|
953
1001
|
if (existingCookie) {
|
|
954
1002
|
try {
|
|
@@ -977,9 +1025,9 @@ function appendKnownAccountCookie(headers, account, existingCookie, options = {}
|
|
|
977
1025
|
if (options.domain) {
|
|
978
1026
|
cookie += `; Domain=${options.domain}`;
|
|
979
1027
|
}
|
|
980
|
-
|
|
1028
|
+
headers2.append("Set-Cookie", cookie);
|
|
981
1029
|
}
|
|
982
|
-
function removeKnownAccountFromCookie(
|
|
1030
|
+
function removeKnownAccountFromCookie(headers2, userId, existingCookie, options = {}) {
|
|
983
1031
|
let accounts = {};
|
|
984
1032
|
if (existingCookie) {
|
|
985
1033
|
try {
|
|
@@ -999,15 +1047,15 @@ function removeKnownAccountFromCookie(headers, userId, existingCookie, options =
|
|
|
999
1047
|
if (options.domain) {
|
|
1000
1048
|
cookie += `; Domain=${options.domain}`;
|
|
1001
1049
|
}
|
|
1002
|
-
|
|
1050
|
+
headers2.append("Set-Cookie", cookie);
|
|
1003
1051
|
}
|
|
1004
|
-
function clearKnownAccountsCookie(
|
|
1052
|
+
function clearKnownAccountsCookie(headers2, options = {}) {
|
|
1005
1053
|
const path = options.path ?? "/";
|
|
1006
1054
|
let cookie = `${KNOWN_ACCOUNTS_COOKIE_NAME}=; Path=${path}; Max-Age=0`;
|
|
1007
1055
|
if (options.domain) {
|
|
1008
1056
|
cookie += `; Domain=${options.domain}`;
|
|
1009
1057
|
}
|
|
1010
|
-
|
|
1058
|
+
headers2.append("Set-Cookie", cookie);
|
|
1011
1059
|
}
|
|
1012
1060
|
function getKnownAccountsFromRequest(request) {
|
|
1013
1061
|
const cookieHeader = request.headers.get("cookie");
|
|
@@ -1432,13 +1480,13 @@ function createAuthRoutes(config = {}) {
|
|
|
1432
1480
|
if (!user_id) {
|
|
1433
1481
|
return errorResponse("VALIDATION_ERROR", "user_id required", 400);
|
|
1434
1482
|
}
|
|
1435
|
-
const
|
|
1436
|
-
|
|
1483
|
+
const headers2 = new Headers();
|
|
1484
|
+
headers2.set("Content-Type", "application/json");
|
|
1437
1485
|
const existingKnown = getKnownAccountsCookieRaw(request);
|
|
1438
|
-
removeKnownAccountFromCookie(
|
|
1486
|
+
removeKnownAccountFromCookie(headers2, user_id, existingKnown, cookieOptions);
|
|
1439
1487
|
return new Response(
|
|
1440
1488
|
JSON.stringify({ success: true, data: { message: "Account forgotten" } }),
|
|
1441
|
-
{ status: 200, headers }
|
|
1489
|
+
{ status: 200, headers: headers2 }
|
|
1442
1490
|
);
|
|
1443
1491
|
}
|
|
1444
1492
|
// ==================== Forget All Accounts ====================
|
|
@@ -1446,12 +1494,12 @@ function createAuthRoutes(config = {}) {
|
|
|
1446
1494
|
if (!config.enableAccountSwitcher) {
|
|
1447
1495
|
return errorResponse("NOT_FOUND", "Account switcher not enabled", 404);
|
|
1448
1496
|
}
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1451
|
-
clearKnownAccountsCookie(
|
|
1497
|
+
const headers2 = new Headers();
|
|
1498
|
+
headers2.set("Content-Type", "application/json");
|
|
1499
|
+
clearKnownAccountsCookie(headers2, cookieOptions);
|
|
1452
1500
|
return new Response(
|
|
1453
1501
|
JSON.stringify({ success: true, data: { message: "All accounts forgotten" } }),
|
|
1454
|
-
{ status: 200, headers }
|
|
1502
|
+
{ status: 200, headers: headers2 }
|
|
1455
1503
|
);
|
|
1456
1504
|
}
|
|
1457
1505
|
default:
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ServerConfig } from '../webhook-handler-
|
|
2
|
-
export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-
|
|
3
|
-
import { p as ClientContext, A as ApiError } from '../index-
|
|
1
|
+
import { S as ServerConfig } from '../webhook-handler-CVmBvPFN.mjs';
|
|
2
|
+
export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-CVmBvPFN.mjs';
|
|
3
|
+
import { p as ClientContext, A as ApiError } from '../index-Bv1m_qQ8.mjs';
|
|
4
4
|
export { L as LedveryRoutesConfig, a as LedverySessionData, S as SM_LEDVERY_ACCESS_TOKEN_COOKIE, b as SM_LEDVERY_ID_TOKEN_COOKIE, c as SM_LEDVERY_NONCE_COOKIE, d as SM_LEDVERY_PKCE_VERIFIER_COOKIE, e as SM_LEDVERY_STATE_COOKIE, f as createLedveryRoutes, g as getLedverySession } from '../ledvery-CxPzZpxP.mjs';
|
|
5
5
|
import { NextRequest, NextResponse } from 'next/server';
|
|
6
6
|
import '@scalemule/money';
|
|
@@ -509,7 +509,21 @@ declare class ScaleMuleError extends Error {
|
|
|
509
509
|
readonly code: string;
|
|
510
510
|
readonly status: number;
|
|
511
511
|
readonly details?: Record<string, unknown> | undefined;
|
|
512
|
-
|
|
512
|
+
/**
|
|
513
|
+
* Correlation id of the upstream platform request that produced this
|
|
514
|
+
* error, when there was one. `apiHandler()` echoes it back to the browser
|
|
515
|
+
* as `meta.request_id` so a client-side failure can be traced all the way
|
|
516
|
+
* through the route handler to the platform service.
|
|
517
|
+
*/
|
|
518
|
+
readonly requestId?: string | undefined;
|
|
519
|
+
constructor(code: string, message: string, status?: number, details?: Record<string, unknown> | undefined,
|
|
520
|
+
/**
|
|
521
|
+
* Correlation id of the upstream platform request that produced this
|
|
522
|
+
* error, when there was one. `apiHandler()` echoes it back to the browser
|
|
523
|
+
* as `meta.request_id` so a client-side failure can be traced all the way
|
|
524
|
+
* through the route handler to the platform service.
|
|
525
|
+
*/
|
|
526
|
+
requestId?: string | undefined);
|
|
513
527
|
}
|
|
514
528
|
declare function errorCodeToStatus(code: string): number;
|
|
515
529
|
/**
|
|
@@ -521,6 +535,12 @@ type SdkResult<T> = {
|
|
|
521
535
|
data?: T | null;
|
|
522
536
|
error?: ApiError | null;
|
|
523
537
|
success?: boolean;
|
|
538
|
+
/** Platform envelope metadata; `request_id` is echoed onto ScaleMuleError. */
|
|
539
|
+
meta?: {
|
|
540
|
+
request_id?: string;
|
|
541
|
+
trace_id?: string;
|
|
542
|
+
timestamp?: string;
|
|
543
|
+
};
|
|
524
544
|
};
|
|
525
545
|
/**
|
|
526
546
|
* Convert an SDK result into throw-on-error, or pass through a raw value.
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ServerConfig } from '../webhook-handler-
|
|
2
|
-
export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-
|
|
3
|
-
import { p as ClientContext, A as ApiError } from '../index-
|
|
1
|
+
import { S as ServerConfig } from '../webhook-handler-5ymVecTD.js';
|
|
2
|
+
export { a as ScaleMuleServer, V as VideoFailedEvent, b as VideoReadyEvent, c as VideoTranscodedEvent, d as VideoUploadedEvent, W as WebhookEvent, e as WebhookRoutesConfig, f as createServerClient, g as createWebhookHandler, h as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, i as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-5ymVecTD.js';
|
|
3
|
+
import { p as ClientContext, A as ApiError } from '../index-Bv1m_qQ8.js';
|
|
4
4
|
export { L as LedveryRoutesConfig, a as LedverySessionData, S as SM_LEDVERY_ACCESS_TOKEN_COOKIE, b as SM_LEDVERY_ID_TOKEN_COOKIE, c as SM_LEDVERY_NONCE_COOKIE, d as SM_LEDVERY_PKCE_VERIFIER_COOKIE, e as SM_LEDVERY_STATE_COOKIE, f as createLedveryRoutes, g as getLedverySession } from '../ledvery-CxPzZpxP.js';
|
|
5
5
|
import { NextRequest, NextResponse } from 'next/server';
|
|
6
6
|
import '@scalemule/money';
|
|
@@ -509,7 +509,21 @@ declare class ScaleMuleError extends Error {
|
|
|
509
509
|
readonly code: string;
|
|
510
510
|
readonly status: number;
|
|
511
511
|
readonly details?: Record<string, unknown> | undefined;
|
|
512
|
-
|
|
512
|
+
/**
|
|
513
|
+
* Correlation id of the upstream platform request that produced this
|
|
514
|
+
* error, when there was one. `apiHandler()` echoes it back to the browser
|
|
515
|
+
* as `meta.request_id` so a client-side failure can be traced all the way
|
|
516
|
+
* through the route handler to the platform service.
|
|
517
|
+
*/
|
|
518
|
+
readonly requestId?: string | undefined;
|
|
519
|
+
constructor(code: string, message: string, status?: number, details?: Record<string, unknown> | undefined,
|
|
520
|
+
/**
|
|
521
|
+
* Correlation id of the upstream platform request that produced this
|
|
522
|
+
* error, when there was one. `apiHandler()` echoes it back to the browser
|
|
523
|
+
* as `meta.request_id` so a client-side failure can be traced all the way
|
|
524
|
+
* through the route handler to the platform service.
|
|
525
|
+
*/
|
|
526
|
+
requestId?: string | undefined);
|
|
513
527
|
}
|
|
514
528
|
declare function errorCodeToStatus(code: string): number;
|
|
515
529
|
/**
|
|
@@ -521,6 +535,12 @@ type SdkResult<T> = {
|
|
|
521
535
|
data?: T | null;
|
|
522
536
|
error?: ApiError | null;
|
|
523
537
|
success?: boolean;
|
|
538
|
+
/** Platform envelope metadata; `request_id` is echoed onto ScaleMuleError. */
|
|
539
|
+
meta?: {
|
|
540
|
+
request_id?: string;
|
|
541
|
+
trace_id?: string;
|
|
542
|
+
timestamp?: string;
|
|
543
|
+
};
|
|
524
544
|
};
|
|
525
545
|
/**
|
|
526
546
|
* Convert an SDK result into throw-on-error, or pass through a raw value.
|