@scalemule/nextjs 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +30 -14
- package/dist/index.mjs +30 -14
- package/dist/server/auth.js +9 -1
- package/dist/server/auth.mjs +9 -1
- package/dist/server/index.d.mts +9 -5
- package/dist/server/index.d.ts +9 -5
- package/dist/server/index.js +9 -1
- package/dist/server/index.mjs +9 -1
- package/dist/server/webhook-handler.d.mts +1 -1
- package/dist/server/webhook-handler.d.ts +1 -1
- package/dist/{webhook-handler-DrC9rOoh.d.ts → webhook-handler-Dok4jfub.d.ts} +5 -1
- package/dist/{webhook-handler-CN_N2XlA.d.mts → webhook-handler-aT2C5z2y.d.mts} +5 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1000,6 +1000,9 @@ function useAuth() {
|
|
|
1000
1000
|
if (response.data.sessionToken) {
|
|
1001
1001
|
await client.setSession(response.data.sessionToken, response.data.userId || response.data.user?.id || "");
|
|
1002
1002
|
}
|
|
1003
|
+
if (response.data.user) {
|
|
1004
|
+
setUser(response.data.user);
|
|
1005
|
+
}
|
|
1003
1006
|
return response.data.user;
|
|
1004
1007
|
}
|
|
1005
1008
|
try {
|
|
@@ -1011,7 +1014,7 @@ function useAuth() {
|
|
|
1011
1014
|
throw err;
|
|
1012
1015
|
}
|
|
1013
1016
|
},
|
|
1014
|
-
[client, setError, authProxyUrl]
|
|
1017
|
+
[client, setUser, setError, authProxyUrl]
|
|
1015
1018
|
);
|
|
1016
1019
|
const login = react.useCallback(
|
|
1017
1020
|
async (data) => {
|
|
@@ -1151,7 +1154,11 @@ function useAuth() {
|
|
|
1151
1154
|
}
|
|
1152
1155
|
} else {
|
|
1153
1156
|
try {
|
|
1154
|
-
await client.post("/v1/auth/verify-email", { token });
|
|
1157
|
+
const result = await client.post("/v1/auth/verify-email", { token });
|
|
1158
|
+
if (result?.session_token && result?.user) {
|
|
1159
|
+
await client.setSession(result.session_token, result.user.id);
|
|
1160
|
+
setUser(result.user);
|
|
1161
|
+
}
|
|
1155
1162
|
} catch (err) {
|
|
1156
1163
|
if (err instanceof ScaleMuleApiError) {
|
|
1157
1164
|
setError(err);
|
|
@@ -1159,22 +1166,27 @@ function useAuth() {
|
|
|
1159
1166
|
throw err;
|
|
1160
1167
|
}
|
|
1161
1168
|
}
|
|
1162
|
-
if (
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
} catch {
|
|
1169
|
+
if (authProxyUrl) {
|
|
1170
|
+
const userResponse = await proxyFetch(
|
|
1171
|
+
authProxyUrl,
|
|
1172
|
+
"me",
|
|
1173
|
+
{ method: "GET" }
|
|
1174
|
+
);
|
|
1175
|
+
if (userResponse.success && userResponse.data?.user) {
|
|
1176
|
+
setUser(userResponse.data.user);
|
|
1177
|
+
if (userResponse.data.sessionToken) {
|
|
1178
|
+
await client.setSession(userResponse.data.sessionToken, userResponse.data.userId || userResponse.data.user.id);
|
|
1173
1179
|
}
|
|
1174
1180
|
}
|
|
1181
|
+
} else {
|
|
1182
|
+
try {
|
|
1183
|
+
const userData = await client.get("/v1/auth/me");
|
|
1184
|
+
setUser(userData);
|
|
1185
|
+
} catch {
|
|
1186
|
+
}
|
|
1175
1187
|
}
|
|
1176
1188
|
},
|
|
1177
|
-
[client,
|
|
1189
|
+
[client, setUser, setError, authProxyUrl]
|
|
1178
1190
|
);
|
|
1179
1191
|
const resendVerification = react.useCallback(async (email) => {
|
|
1180
1192
|
setError(null);
|
|
@@ -2474,6 +2486,10 @@ function parseUtmParams() {
|
|
|
2474
2486
|
utm.utm_campaign = gadCampaign;
|
|
2475
2487
|
}
|
|
2476
2488
|
}
|
|
2489
|
+
if (!utm.utm_source && params.get("fbclid")) {
|
|
2490
|
+
utm.utm_source = "facebook";
|
|
2491
|
+
utm.utm_medium = utm.utm_medium || "cpc";
|
|
2492
|
+
}
|
|
2477
2493
|
return Object.keys(utm).length > 0 ? utm : null;
|
|
2478
2494
|
}
|
|
2479
2495
|
function detectDeviceInfo() {
|
package/dist/index.mjs
CHANGED
|
@@ -998,6 +998,9 @@ function useAuth() {
|
|
|
998
998
|
if (response.data.sessionToken) {
|
|
999
999
|
await client.setSession(response.data.sessionToken, response.data.userId || response.data.user?.id || "");
|
|
1000
1000
|
}
|
|
1001
|
+
if (response.data.user) {
|
|
1002
|
+
setUser(response.data.user);
|
|
1003
|
+
}
|
|
1001
1004
|
return response.data.user;
|
|
1002
1005
|
}
|
|
1003
1006
|
try {
|
|
@@ -1009,7 +1012,7 @@ function useAuth() {
|
|
|
1009
1012
|
throw err;
|
|
1010
1013
|
}
|
|
1011
1014
|
},
|
|
1012
|
-
[client, setError, authProxyUrl]
|
|
1015
|
+
[client, setUser, setError, authProxyUrl]
|
|
1013
1016
|
);
|
|
1014
1017
|
const login = useCallback(
|
|
1015
1018
|
async (data) => {
|
|
@@ -1149,7 +1152,11 @@ function useAuth() {
|
|
|
1149
1152
|
}
|
|
1150
1153
|
} else {
|
|
1151
1154
|
try {
|
|
1152
|
-
await client.post("/v1/auth/verify-email", { token });
|
|
1155
|
+
const result = await client.post("/v1/auth/verify-email", { token });
|
|
1156
|
+
if (result?.session_token && result?.user) {
|
|
1157
|
+
await client.setSession(result.session_token, result.user.id);
|
|
1158
|
+
setUser(result.user);
|
|
1159
|
+
}
|
|
1153
1160
|
} catch (err) {
|
|
1154
1161
|
if (err instanceof ScaleMuleApiError) {
|
|
1155
1162
|
setError(err);
|
|
@@ -1157,22 +1164,27 @@ function useAuth() {
|
|
|
1157
1164
|
throw err;
|
|
1158
1165
|
}
|
|
1159
1166
|
}
|
|
1160
|
-
if (
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
} catch {
|
|
1167
|
+
if (authProxyUrl) {
|
|
1168
|
+
const userResponse = await proxyFetch(
|
|
1169
|
+
authProxyUrl,
|
|
1170
|
+
"me",
|
|
1171
|
+
{ method: "GET" }
|
|
1172
|
+
);
|
|
1173
|
+
if (userResponse.success && userResponse.data?.user) {
|
|
1174
|
+
setUser(userResponse.data.user);
|
|
1175
|
+
if (userResponse.data.sessionToken) {
|
|
1176
|
+
await client.setSession(userResponse.data.sessionToken, userResponse.data.userId || userResponse.data.user.id);
|
|
1171
1177
|
}
|
|
1172
1178
|
}
|
|
1179
|
+
} else {
|
|
1180
|
+
try {
|
|
1181
|
+
const userData = await client.get("/v1/auth/me");
|
|
1182
|
+
setUser(userData);
|
|
1183
|
+
} catch {
|
|
1184
|
+
}
|
|
1173
1185
|
}
|
|
1174
1186
|
},
|
|
1175
|
-
[client,
|
|
1187
|
+
[client, setUser, setError, authProxyUrl]
|
|
1176
1188
|
);
|
|
1177
1189
|
const resendVerification = useCallback(async (email) => {
|
|
1178
1190
|
setError(null);
|
|
@@ -2472,6 +2484,10 @@ function parseUtmParams() {
|
|
|
2472
2484
|
utm.utm_campaign = gadCampaign;
|
|
2473
2485
|
}
|
|
2474
2486
|
}
|
|
2487
|
+
if (!utm.utm_source && params.get("fbclid")) {
|
|
2488
|
+
utm.utm_source = "facebook";
|
|
2489
|
+
utm.utm_medium = utm.utm_medium || "cpc";
|
|
2490
|
+
}
|
|
2475
2491
|
return Object.keys(utm).length > 0 ? utm : null;
|
|
2476
2492
|
}
|
|
2477
2493
|
function detectDeviceInfo() {
|
package/dist/server/auth.js
CHANGED
|
@@ -1010,8 +1010,9 @@ function createAuthRoutes(config = {}) {
|
|
|
1010
1010
|
if (!token) {
|
|
1011
1011
|
return errorResponse("VALIDATION_ERROR", "Token required", 400);
|
|
1012
1012
|
}
|
|
1013
|
+
let verifyData;
|
|
1013
1014
|
try {
|
|
1014
|
-
await sm.auth.verifyEmail(token);
|
|
1015
|
+
verifyData = await sm.auth.verifyEmail(token);
|
|
1015
1016
|
} catch (err) {
|
|
1016
1017
|
const apiErr = err instanceof ScaleMuleApiError ? err : null;
|
|
1017
1018
|
return errorResponse(
|
|
@@ -1020,6 +1021,13 @@ function createAuthRoutes(config = {}) {
|
|
|
1020
1021
|
400
|
|
1021
1022
|
);
|
|
1022
1023
|
}
|
|
1024
|
+
if (verifyData?.session_token && verifyData?.user) {
|
|
1025
|
+
return withSession(
|
|
1026
|
+
{ session_token: verifyData.session_token, user: verifyData.user },
|
|
1027
|
+
{ message: "Email verified successfully", verified: true, user: verifyData.user, sessionToken: verifyData.session_token, userId: verifyData.user.id },
|
|
1028
|
+
cookieOptions
|
|
1029
|
+
);
|
|
1030
|
+
}
|
|
1023
1031
|
return successResponse({ message: "Email verified successfully" });
|
|
1024
1032
|
}
|
|
1025
1033
|
// ==================== Resend Verification ====================
|
package/dist/server/auth.mjs
CHANGED
|
@@ -1008,8 +1008,9 @@ function createAuthRoutes(config = {}) {
|
|
|
1008
1008
|
if (!token) {
|
|
1009
1009
|
return errorResponse("VALIDATION_ERROR", "Token required", 400);
|
|
1010
1010
|
}
|
|
1011
|
+
let verifyData;
|
|
1011
1012
|
try {
|
|
1012
|
-
await sm.auth.verifyEmail(token);
|
|
1013
|
+
verifyData = await sm.auth.verifyEmail(token);
|
|
1013
1014
|
} catch (err) {
|
|
1014
1015
|
const apiErr = err instanceof ScaleMuleApiError ? err : null;
|
|
1015
1016
|
return errorResponse(
|
|
@@ -1018,6 +1019,13 @@ function createAuthRoutes(config = {}) {
|
|
|
1018
1019
|
400
|
|
1019
1020
|
);
|
|
1020
1021
|
}
|
|
1022
|
+
if (verifyData?.session_token && verifyData?.user) {
|
|
1023
|
+
return withSession(
|
|
1024
|
+
{ session_token: verifyData.session_token, user: verifyData.user },
|
|
1025
|
+
{ message: "Email verified successfully", verified: true, user: verifyData.user, sessionToken: verifyData.session_token, userId: verifyData.user.id },
|
|
1026
|
+
cookieOptions
|
|
1027
|
+
);
|
|
1028
|
+
}
|
|
1021
1029
|
return successResponse({ message: "Email verified successfully" });
|
|
1022
1030
|
}
|
|
1023
1031
|
// ==================== Resend Verification ====================
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ServerConfig } from '../webhook-handler-
|
|
2
|
-
export { a as ScaleMuleServer, e as VideoFailedEvent, V as VideoReadyEvent, g as VideoTranscodedEvent, f as VideoUploadedEvent, W as WebhookEvent, h as WebhookRoutesConfig, c as createServerClient, i as createWebhookHandler, d as createWebhookRoutes, p as parseWebhookEvent, b as registerVideoWebhook, r as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-
|
|
3
|
-
import { $ as ClientContext,
|
|
1
|
+
import { S as ServerConfig } from '../webhook-handler-aT2C5z2y.mjs';
|
|
2
|
+
export { a as ScaleMuleServer, e as VideoFailedEvent, V as VideoReadyEvent, g as VideoTranscodedEvent, f as VideoUploadedEvent, W as WebhookEvent, h as WebhookRoutesConfig, c as createServerClient, i as createWebhookHandler, d as createWebhookRoutes, p as parseWebhookEvent, b as registerVideoWebhook, r as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-aT2C5z2y.mjs';
|
|
3
|
+
import { $ as ClientContext, A as ApiError } from '../index-jomBa89d.mjs';
|
|
4
4
|
import { NextRequest, NextResponse } from 'next/server';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -101,7 +101,6 @@ declare function buildClientContextHeaders(context: ClientContext | undefined):
|
|
|
101
101
|
* Handles HTTP-only secure cookies for authentication.
|
|
102
102
|
* Tokens are never exposed to the browser.
|
|
103
103
|
*/
|
|
104
|
-
|
|
105
104
|
declare const SESSION_COOKIE_NAME = "sm_session";
|
|
106
105
|
declare const USER_ID_COOKIE_NAME = "sm_user_id";
|
|
107
106
|
interface SessionCookieOptions {
|
|
@@ -135,7 +134,12 @@ interface SessionData {
|
|
|
135
134
|
* }
|
|
136
135
|
* ```
|
|
137
136
|
*/
|
|
138
|
-
declare function withSession<T extends Record<string, unknown>>(loginResponse:
|
|
137
|
+
declare function withSession<T extends Record<string, unknown>>(loginResponse: {
|
|
138
|
+
session_token: string;
|
|
139
|
+
user: {
|
|
140
|
+
id: string;
|
|
141
|
+
};
|
|
142
|
+
}, responseBody: T, options?: SessionCookieOptions): Response;
|
|
139
143
|
/**
|
|
140
144
|
* Create a Response that clears session cookies
|
|
141
145
|
*
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ServerConfig } from '../webhook-handler-
|
|
2
|
-
export { a as ScaleMuleServer, e as VideoFailedEvent, V as VideoReadyEvent, g as VideoTranscodedEvent, f as VideoUploadedEvent, W as WebhookEvent, h as WebhookRoutesConfig, c as createServerClient, i as createWebhookHandler, d as createWebhookRoutes, p as parseWebhookEvent, b as registerVideoWebhook, r as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-
|
|
3
|
-
import { $ as ClientContext,
|
|
1
|
+
import { S as ServerConfig } from '../webhook-handler-Dok4jfub.js';
|
|
2
|
+
export { a as ScaleMuleServer, e as VideoFailedEvent, V as VideoReadyEvent, g as VideoTranscodedEvent, f as VideoUploadedEvent, W as WebhookEvent, h as WebhookRoutesConfig, c as createServerClient, i as createWebhookHandler, d as createWebhookRoutes, p as parseWebhookEvent, b as registerVideoWebhook, r as resolveGatewayUrl, v as verifyWebhookSignature } from '../webhook-handler-Dok4jfub.js';
|
|
3
|
+
import { $ as ClientContext, A as ApiError } from '../index-jomBa89d.js';
|
|
4
4
|
import { NextRequest, NextResponse } from 'next/server';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -101,7 +101,6 @@ declare function buildClientContextHeaders(context: ClientContext | undefined):
|
|
|
101
101
|
* Handles HTTP-only secure cookies for authentication.
|
|
102
102
|
* Tokens are never exposed to the browser.
|
|
103
103
|
*/
|
|
104
|
-
|
|
105
104
|
declare const SESSION_COOKIE_NAME = "sm_session";
|
|
106
105
|
declare const USER_ID_COOKIE_NAME = "sm_user_id";
|
|
107
106
|
interface SessionCookieOptions {
|
|
@@ -135,7 +134,12 @@ interface SessionData {
|
|
|
135
134
|
* }
|
|
136
135
|
* ```
|
|
137
136
|
*/
|
|
138
|
-
declare function withSession<T extends Record<string, unknown>>(loginResponse:
|
|
137
|
+
declare function withSession<T extends Record<string, unknown>>(loginResponse: {
|
|
138
|
+
session_token: string;
|
|
139
|
+
user: {
|
|
140
|
+
id: string;
|
|
141
|
+
};
|
|
142
|
+
}, responseBody: T, options?: SessionCookieOptions): Response;
|
|
139
143
|
/**
|
|
140
144
|
* Create a Response that clears session cookies
|
|
141
145
|
*
|
package/dist/server/index.js
CHANGED
|
@@ -1164,8 +1164,9 @@ function createAuthRoutes(config = {}) {
|
|
|
1164
1164
|
if (!token) {
|
|
1165
1165
|
return errorResponse("VALIDATION_ERROR", "Token required", 400);
|
|
1166
1166
|
}
|
|
1167
|
+
let verifyData;
|
|
1167
1168
|
try {
|
|
1168
|
-
await sm.auth.verifyEmail(token);
|
|
1169
|
+
verifyData = await sm.auth.verifyEmail(token);
|
|
1169
1170
|
} catch (err) {
|
|
1170
1171
|
const apiErr = err instanceof ScaleMuleApiError ? err : null;
|
|
1171
1172
|
return errorResponse(
|
|
@@ -1174,6 +1175,13 @@ function createAuthRoutes(config = {}) {
|
|
|
1174
1175
|
400
|
|
1175
1176
|
);
|
|
1176
1177
|
}
|
|
1178
|
+
if (verifyData?.session_token && verifyData?.user) {
|
|
1179
|
+
return withSession(
|
|
1180
|
+
{ session_token: verifyData.session_token, user: verifyData.user },
|
|
1181
|
+
{ message: "Email verified successfully", verified: true, user: verifyData.user, sessionToken: verifyData.session_token, userId: verifyData.user.id },
|
|
1182
|
+
cookieOptions
|
|
1183
|
+
);
|
|
1184
|
+
}
|
|
1177
1185
|
return successResponse({ message: "Email verified successfully" });
|
|
1178
1186
|
}
|
|
1179
1187
|
// ==================== Resend Verification ====================
|
package/dist/server/index.mjs
CHANGED
|
@@ -1162,8 +1162,9 @@ function createAuthRoutes(config = {}) {
|
|
|
1162
1162
|
if (!token) {
|
|
1163
1163
|
return errorResponse("VALIDATION_ERROR", "Token required", 400);
|
|
1164
1164
|
}
|
|
1165
|
+
let verifyData;
|
|
1165
1166
|
try {
|
|
1166
|
-
await sm.auth.verifyEmail(token);
|
|
1167
|
+
verifyData = await sm.auth.verifyEmail(token);
|
|
1167
1168
|
} catch (err) {
|
|
1168
1169
|
const apiErr = err instanceof ScaleMuleApiError ? err : null;
|
|
1169
1170
|
return errorResponse(
|
|
@@ -1172,6 +1173,13 @@ function createAuthRoutes(config = {}) {
|
|
|
1172
1173
|
400
|
|
1173
1174
|
);
|
|
1174
1175
|
}
|
|
1176
|
+
if (verifyData?.session_token && verifyData?.user) {
|
|
1177
|
+
return withSession(
|
|
1178
|
+
{ session_token: verifyData.session_token, user: verifyData.user },
|
|
1179
|
+
{ message: "Email verified successfully", verified: true, user: verifyData.user, sessionToken: verifyData.session_token, userId: verifyData.user.id },
|
|
1180
|
+
cookieOptions
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1175
1183
|
return successResponse({ message: "Email verified successfully" });
|
|
1176
1184
|
}
|
|
1177
1185
|
// ==================== Resend Verification ====================
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { i as createWebhookHandler } from '../webhook-handler-
|
|
1
|
+
export { i as createWebhookHandler } from '../webhook-handler-aT2C5z2y.mjs';
|
|
2
2
|
import '../index-jomBa89d.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { i as createWebhookHandler } from '../webhook-handler-
|
|
1
|
+
export { i as createWebhookHandler } from '../webhook-handler-Dok4jfub.js';
|
|
2
2
|
import '../index-jomBa89d.js';
|
|
@@ -84,7 +84,11 @@ declare class ScaleMuleServer {
|
|
|
84
84
|
* Verify email with token
|
|
85
85
|
*/
|
|
86
86
|
verifyEmail: (token: string) => Promise<{
|
|
87
|
-
message
|
|
87
|
+
message?: string;
|
|
88
|
+
verified?: boolean;
|
|
89
|
+
session_token?: string;
|
|
90
|
+
user?: User;
|
|
91
|
+
expires_at?: string;
|
|
88
92
|
}>;
|
|
89
93
|
/**
|
|
90
94
|
* Resend verification email.
|
|
@@ -84,7 +84,11 @@ declare class ScaleMuleServer {
|
|
|
84
84
|
* Verify email with token
|
|
85
85
|
*/
|
|
86
86
|
verifyEmail: (token: string) => Promise<{
|
|
87
|
-
message
|
|
87
|
+
message?: string;
|
|
88
|
+
verified?: boolean;
|
|
89
|
+
session_token?: string;
|
|
90
|
+
user?: User;
|
|
91
|
+
expires_at?: string;
|
|
88
92
|
}>;
|
|
89
93
|
/**
|
|
90
94
|
* Resend verification email.
|
package/package.json
CHANGED