@scalemule/nextjs 0.0.7 → 0.0.9

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 CHANGED
@@ -64,6 +64,7 @@ declare class ScaleMuleClient {
64
64
  private enableOfflineQueue;
65
65
  private sessionGate;
66
66
  private resolveSessionGate;
67
+ private workspaceId;
67
68
  constructor(config: ClientConfig);
68
69
  /**
69
70
  * Sync offline queue when coming back online
@@ -85,6 +86,15 @@ declare class ScaleMuleClient {
85
86
  * Check if currently rate limited
86
87
  */
87
88
  isRateLimited(): boolean;
89
+ /**
90
+ * Set the active workspace context. All subsequent requests will include
91
+ * x-sm-workspace-id header. Pass null to clear.
92
+ */
93
+ setWorkspaceContext(id: string | null): void;
94
+ /**
95
+ * Get the current workspace ID
96
+ */
97
+ getWorkspaceId(): string | null;
88
98
  /**
89
99
  * Get the gateway URL
90
100
  */
package/dist/client.d.ts CHANGED
@@ -64,6 +64,7 @@ declare class ScaleMuleClient {
64
64
  private enableOfflineQueue;
65
65
  private sessionGate;
66
66
  private resolveSessionGate;
67
+ private workspaceId;
67
68
  constructor(config: ClientConfig);
68
69
  /**
69
70
  * Sync offline queue when coming back online
@@ -85,6 +86,15 @@ declare class ScaleMuleClient {
85
86
  * Check if currently rate limited
86
87
  */
87
88
  isRateLimited(): boolean;
89
+ /**
90
+ * Set the active workspace context. All subsequent requests will include
91
+ * x-sm-workspace-id header. Pass null to clear.
92
+ */
93
+ setWorkspaceContext(id: string | null): void;
94
+ /**
95
+ * Get the current workspace ID
96
+ */
97
+ getWorkspaceId(): string | null;
88
98
  /**
89
99
  * Get the gateway URL
90
100
  */
package/dist/client.js CHANGED
@@ -17,6 +17,7 @@ var GATEWAY_URLS = {
17
17
  };
18
18
  var SESSION_STORAGE_KEY = "scalemule_session";
19
19
  var USER_ID_STORAGE_KEY = "scalemule_user_id";
20
+ var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
20
21
  var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
21
22
  function sleep(ms) {
22
23
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -275,6 +276,7 @@ var ScaleMuleClient = class {
275
276
  this.offlineQueue = null;
276
277
  this.sessionGate = null;
277
278
  this.resolveSessionGate = null;
279
+ this.workspaceId = null;
278
280
  this.apiKey = config.apiKey;
279
281
  this.applicationId = config.applicationId || null;
280
282
  this.gatewayUrl = resolveGatewayUrl(config);
@@ -345,6 +347,24 @@ var ScaleMuleClient = class {
345
347
  isRateLimited() {
346
348
  return this.rateLimitQueue?.isRateLimited || false;
347
349
  }
350
+ /**
351
+ * Set the active workspace context. All subsequent requests will include
352
+ * x-sm-workspace-id header. Pass null to clear.
353
+ */
354
+ setWorkspaceContext(id) {
355
+ this.workspaceId = id;
356
+ if (id) {
357
+ this.storage.setItem(WORKSPACE_STORAGE_KEY, id);
358
+ } else {
359
+ this.storage.removeItem(WORKSPACE_STORAGE_KEY);
360
+ }
361
+ }
362
+ /**
363
+ * Get the current workspace ID
364
+ */
365
+ getWorkspaceId() {
366
+ return this.workspaceId;
367
+ }
348
368
  /**
349
369
  * Get the gateway URL
350
370
  */
@@ -387,6 +407,8 @@ var ScaleMuleClient = class {
387
407
  const userId = await this.storage.getItem(USER_ID_STORAGE_KEY);
388
408
  if (token) this.sessionToken = token;
389
409
  if (userId) this.userId = userId;
410
+ const wsId = await this.storage.getItem(WORKSPACE_STORAGE_KEY);
411
+ if (wsId) this.workspaceId = wsId;
390
412
  if (token) {
391
413
  this.resolveSessionPending();
392
414
  }
@@ -412,8 +434,10 @@ var ScaleMuleClient = class {
412
434
  async clearSession() {
413
435
  this.sessionToken = null;
414
436
  this.userId = null;
437
+ this.workspaceId = null;
415
438
  await this.storage.removeItem(SESSION_STORAGE_KEY);
416
439
  await this.storage.removeItem(USER_ID_STORAGE_KEY);
440
+ await this.storage.removeItem(WORKSPACE_STORAGE_KEY);
417
441
  if (this.debug) {
418
442
  console.log("[ScaleMule] Session cleared");
419
443
  }
@@ -445,6 +469,9 @@ var ScaleMuleClient = class {
445
469
  if (!options?.skipAuth && this.sessionToken) {
446
470
  headers.set("Authorization", `Bearer ${this.sessionToken}`);
447
471
  }
472
+ if (this.workspaceId) {
473
+ headers.set("x-sm-workspace-id", this.workspaceId);
474
+ }
448
475
  if (!headers.has("Content-Type") && options?.body && typeof options.body === "string") {
449
476
  headers.set("Content-Type", "application/json");
450
477
  }
@@ -600,6 +627,9 @@ var ScaleMuleClient = class {
600
627
  if (this.sessionToken) {
601
628
  headers.set("Authorization", `Bearer ${this.sessionToken}`);
602
629
  }
630
+ if (this.workspaceId) {
631
+ headers.set("x-sm-workspace-id", this.workspaceId);
632
+ }
603
633
  let lastError = null;
604
634
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
605
635
  try {
@@ -737,6 +767,9 @@ var ScaleMuleClient = class {
737
767
  if (this.sessionToken) {
738
768
  xhr.setRequestHeader("Authorization", `Bearer ${this.sessionToken}`);
739
769
  }
770
+ if (this.workspaceId) {
771
+ xhr.setRequestHeader("x-sm-workspace-id", this.workspaceId);
772
+ }
740
773
  xhr.send(formData);
741
774
  });
742
775
  }
package/dist/client.mjs CHANGED
@@ -15,6 +15,7 @@ var GATEWAY_URLS = {
15
15
  };
16
16
  var SESSION_STORAGE_KEY = "scalemule_session";
17
17
  var USER_ID_STORAGE_KEY = "scalemule_user_id";
18
+ var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
18
19
  var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
19
20
  function sleep(ms) {
20
21
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -273,6 +274,7 @@ var ScaleMuleClient = class {
273
274
  this.offlineQueue = null;
274
275
  this.sessionGate = null;
275
276
  this.resolveSessionGate = null;
277
+ this.workspaceId = null;
276
278
  this.apiKey = config.apiKey;
277
279
  this.applicationId = config.applicationId || null;
278
280
  this.gatewayUrl = resolveGatewayUrl(config);
@@ -343,6 +345,24 @@ var ScaleMuleClient = class {
343
345
  isRateLimited() {
344
346
  return this.rateLimitQueue?.isRateLimited || false;
345
347
  }
348
+ /**
349
+ * Set the active workspace context. All subsequent requests will include
350
+ * x-sm-workspace-id header. Pass null to clear.
351
+ */
352
+ setWorkspaceContext(id) {
353
+ this.workspaceId = id;
354
+ if (id) {
355
+ this.storage.setItem(WORKSPACE_STORAGE_KEY, id);
356
+ } else {
357
+ this.storage.removeItem(WORKSPACE_STORAGE_KEY);
358
+ }
359
+ }
360
+ /**
361
+ * Get the current workspace ID
362
+ */
363
+ getWorkspaceId() {
364
+ return this.workspaceId;
365
+ }
346
366
  /**
347
367
  * Get the gateway URL
348
368
  */
@@ -385,6 +405,8 @@ var ScaleMuleClient = class {
385
405
  const userId = await this.storage.getItem(USER_ID_STORAGE_KEY);
386
406
  if (token) this.sessionToken = token;
387
407
  if (userId) this.userId = userId;
408
+ const wsId = await this.storage.getItem(WORKSPACE_STORAGE_KEY);
409
+ if (wsId) this.workspaceId = wsId;
388
410
  if (token) {
389
411
  this.resolveSessionPending();
390
412
  }
@@ -410,8 +432,10 @@ var ScaleMuleClient = class {
410
432
  async clearSession() {
411
433
  this.sessionToken = null;
412
434
  this.userId = null;
435
+ this.workspaceId = null;
413
436
  await this.storage.removeItem(SESSION_STORAGE_KEY);
414
437
  await this.storage.removeItem(USER_ID_STORAGE_KEY);
438
+ await this.storage.removeItem(WORKSPACE_STORAGE_KEY);
415
439
  if (this.debug) {
416
440
  console.log("[ScaleMule] Session cleared");
417
441
  }
@@ -443,6 +467,9 @@ var ScaleMuleClient = class {
443
467
  if (!options?.skipAuth && this.sessionToken) {
444
468
  headers.set("Authorization", `Bearer ${this.sessionToken}`);
445
469
  }
470
+ if (this.workspaceId) {
471
+ headers.set("x-sm-workspace-id", this.workspaceId);
472
+ }
446
473
  if (!headers.has("Content-Type") && options?.body && typeof options.body === "string") {
447
474
  headers.set("Content-Type", "application/json");
448
475
  }
@@ -598,6 +625,9 @@ var ScaleMuleClient = class {
598
625
  if (this.sessionToken) {
599
626
  headers.set("Authorization", `Bearer ${this.sessionToken}`);
600
627
  }
628
+ if (this.workspaceId) {
629
+ headers.set("x-sm-workspace-id", this.workspaceId);
630
+ }
601
631
  let lastError = null;
602
632
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
603
633
  try {
@@ -735,6 +765,9 @@ var ScaleMuleClient = class {
735
765
  if (this.sessionToken) {
736
766
  xhr.setRequestHeader("Authorization", `Bearer ${this.sessionToken}`);
737
767
  }
768
+ if (this.workspaceId) {
769
+ xhr.setRequestHeader("x-sm-workspace-id", this.workspaceId);
770
+ }
738
771
  xhr.send(formData);
739
772
  });
740
773
  }
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ var GATEWAY_URLS = {
22
22
  };
23
23
  var SESSION_STORAGE_KEY = "scalemule_session";
24
24
  var USER_ID_STORAGE_KEY = "scalemule_user_id";
25
+ var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
25
26
  var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
26
27
  function sleep(ms) {
27
28
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -280,6 +281,7 @@ var ScaleMuleClient = class {
280
281
  this.offlineQueue = null;
281
282
  this.sessionGate = null;
282
283
  this.resolveSessionGate = null;
284
+ this.workspaceId = null;
283
285
  this.apiKey = config.apiKey;
284
286
  this.applicationId = config.applicationId || null;
285
287
  this.gatewayUrl = resolveGatewayUrl(config);
@@ -350,6 +352,24 @@ var ScaleMuleClient = class {
350
352
  isRateLimited() {
351
353
  return this.rateLimitQueue?.isRateLimited || false;
352
354
  }
355
+ /**
356
+ * Set the active workspace context. All subsequent requests will include
357
+ * x-sm-workspace-id header. Pass null to clear.
358
+ */
359
+ setWorkspaceContext(id) {
360
+ this.workspaceId = id;
361
+ if (id) {
362
+ this.storage.setItem(WORKSPACE_STORAGE_KEY, id);
363
+ } else {
364
+ this.storage.removeItem(WORKSPACE_STORAGE_KEY);
365
+ }
366
+ }
367
+ /**
368
+ * Get the current workspace ID
369
+ */
370
+ getWorkspaceId() {
371
+ return this.workspaceId;
372
+ }
353
373
  /**
354
374
  * Get the gateway URL
355
375
  */
@@ -392,6 +412,8 @@ var ScaleMuleClient = class {
392
412
  const userId = await this.storage.getItem(USER_ID_STORAGE_KEY);
393
413
  if (token) this.sessionToken = token;
394
414
  if (userId) this.userId = userId;
415
+ const wsId = await this.storage.getItem(WORKSPACE_STORAGE_KEY);
416
+ if (wsId) this.workspaceId = wsId;
395
417
  if (token) {
396
418
  this.resolveSessionPending();
397
419
  }
@@ -417,8 +439,10 @@ var ScaleMuleClient = class {
417
439
  async clearSession() {
418
440
  this.sessionToken = null;
419
441
  this.userId = null;
442
+ this.workspaceId = null;
420
443
  await this.storage.removeItem(SESSION_STORAGE_KEY);
421
444
  await this.storage.removeItem(USER_ID_STORAGE_KEY);
445
+ await this.storage.removeItem(WORKSPACE_STORAGE_KEY);
422
446
  if (this.debug) {
423
447
  console.log("[ScaleMule] Session cleared");
424
448
  }
@@ -450,6 +474,9 @@ var ScaleMuleClient = class {
450
474
  if (!options?.skipAuth && this.sessionToken) {
451
475
  headers.set("Authorization", `Bearer ${this.sessionToken}`);
452
476
  }
477
+ if (this.workspaceId) {
478
+ headers.set("x-sm-workspace-id", this.workspaceId);
479
+ }
453
480
  if (!headers.has("Content-Type") && options?.body && typeof options.body === "string") {
454
481
  headers.set("Content-Type", "application/json");
455
482
  }
@@ -605,6 +632,9 @@ var ScaleMuleClient = class {
605
632
  if (this.sessionToken) {
606
633
  headers.set("Authorization", `Bearer ${this.sessionToken}`);
607
634
  }
635
+ if (this.workspaceId) {
636
+ headers.set("x-sm-workspace-id", this.workspaceId);
637
+ }
608
638
  let lastError = null;
609
639
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
610
640
  try {
@@ -742,6 +772,9 @@ var ScaleMuleClient = class {
742
772
  if (this.sessionToken) {
743
773
  xhr.setRequestHeader("Authorization", `Bearer ${this.sessionToken}`);
744
774
  }
775
+ if (this.workspaceId) {
776
+ xhr.setRequestHeader("x-sm-workspace-id", this.workspaceId);
777
+ }
745
778
  xhr.send(formData);
746
779
  });
747
780
  }
package/dist/index.mjs CHANGED
@@ -20,6 +20,7 @@ var GATEWAY_URLS = {
20
20
  };
21
21
  var SESSION_STORAGE_KEY = "scalemule_session";
22
22
  var USER_ID_STORAGE_KEY = "scalemule_user_id";
23
+ var WORKSPACE_STORAGE_KEY = "scalemule_workspace_id";
23
24
  var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
24
25
  function sleep(ms) {
25
26
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -278,6 +279,7 @@ var ScaleMuleClient = class {
278
279
  this.offlineQueue = null;
279
280
  this.sessionGate = null;
280
281
  this.resolveSessionGate = null;
282
+ this.workspaceId = null;
281
283
  this.apiKey = config.apiKey;
282
284
  this.applicationId = config.applicationId || null;
283
285
  this.gatewayUrl = resolveGatewayUrl(config);
@@ -348,6 +350,24 @@ var ScaleMuleClient = class {
348
350
  isRateLimited() {
349
351
  return this.rateLimitQueue?.isRateLimited || false;
350
352
  }
353
+ /**
354
+ * Set the active workspace context. All subsequent requests will include
355
+ * x-sm-workspace-id header. Pass null to clear.
356
+ */
357
+ setWorkspaceContext(id) {
358
+ this.workspaceId = id;
359
+ if (id) {
360
+ this.storage.setItem(WORKSPACE_STORAGE_KEY, id);
361
+ } else {
362
+ this.storage.removeItem(WORKSPACE_STORAGE_KEY);
363
+ }
364
+ }
365
+ /**
366
+ * Get the current workspace ID
367
+ */
368
+ getWorkspaceId() {
369
+ return this.workspaceId;
370
+ }
351
371
  /**
352
372
  * Get the gateway URL
353
373
  */
@@ -390,6 +410,8 @@ var ScaleMuleClient = class {
390
410
  const userId = await this.storage.getItem(USER_ID_STORAGE_KEY);
391
411
  if (token) this.sessionToken = token;
392
412
  if (userId) this.userId = userId;
413
+ const wsId = await this.storage.getItem(WORKSPACE_STORAGE_KEY);
414
+ if (wsId) this.workspaceId = wsId;
393
415
  if (token) {
394
416
  this.resolveSessionPending();
395
417
  }
@@ -415,8 +437,10 @@ var ScaleMuleClient = class {
415
437
  async clearSession() {
416
438
  this.sessionToken = null;
417
439
  this.userId = null;
440
+ this.workspaceId = null;
418
441
  await this.storage.removeItem(SESSION_STORAGE_KEY);
419
442
  await this.storage.removeItem(USER_ID_STORAGE_KEY);
443
+ await this.storage.removeItem(WORKSPACE_STORAGE_KEY);
420
444
  if (this.debug) {
421
445
  console.log("[ScaleMule] Session cleared");
422
446
  }
@@ -448,6 +472,9 @@ var ScaleMuleClient = class {
448
472
  if (!options?.skipAuth && this.sessionToken) {
449
473
  headers.set("Authorization", `Bearer ${this.sessionToken}`);
450
474
  }
475
+ if (this.workspaceId) {
476
+ headers.set("x-sm-workspace-id", this.workspaceId);
477
+ }
451
478
  if (!headers.has("Content-Type") && options?.body && typeof options.body === "string") {
452
479
  headers.set("Content-Type", "application/json");
453
480
  }
@@ -603,6 +630,9 @@ var ScaleMuleClient = class {
603
630
  if (this.sessionToken) {
604
631
  headers.set("Authorization", `Bearer ${this.sessionToken}`);
605
632
  }
633
+ if (this.workspaceId) {
634
+ headers.set("x-sm-workspace-id", this.workspaceId);
635
+ }
606
636
  let lastError = null;
607
637
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
608
638
  try {
@@ -740,6 +770,9 @@ var ScaleMuleClient = class {
740
770
  if (this.sessionToken) {
741
771
  xhr.setRequestHeader("Authorization", `Bearer ${this.sessionToken}`);
742
772
  }
773
+ if (this.workspaceId) {
774
+ xhr.setRequestHeader("x-sm-workspace-id", this.workspaceId);
775
+ }
743
776
  xhr.send(formData);
744
777
  });
745
778
  }
@@ -14,6 +14,70 @@ var ScaleMuleApiError = class extends Error {
14
14
  };
15
15
 
16
16
  // src/server/context.ts
17
+ function validateIP(ip) {
18
+ if (!ip) return void 0;
19
+ const trimmed = ip.trim();
20
+ if (!trimmed) return void 0;
21
+ const ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
22
+ const ipv6Regex = /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^::(?:[0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}$|^(?:[0-9a-fA-F]{1,4}:){1,7}:$|^(?:[0-9a-fA-F]{1,4}:){0,6}::(?:[0-9a-fA-F]{1,4}:){0,5}[0-9a-fA-F]{1,4}$/;
23
+ const ipv4MappedRegex = /^::ffff:(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i;
24
+ if (ipv4Regex.test(trimmed) || ipv6Regex.test(trimmed) || ipv4MappedRegex.test(trimmed)) {
25
+ return trimmed;
26
+ }
27
+ return void 0;
28
+ }
29
+ function extractClientContext(request) {
30
+ const headers = request.headers;
31
+ let ip;
32
+ const cfConnectingIp = headers.get("cf-connecting-ip");
33
+ if (cfConnectingIp) {
34
+ ip = validateIP(cfConnectingIp);
35
+ }
36
+ if (!ip) {
37
+ const doConnectingIp = headers.get("do-connecting-ip");
38
+ if (doConnectingIp) {
39
+ ip = validateIP(doConnectingIp);
40
+ }
41
+ }
42
+ if (!ip) {
43
+ const realIp = headers.get("x-real-ip");
44
+ if (realIp) {
45
+ ip = validateIP(realIp);
46
+ }
47
+ }
48
+ if (!ip) {
49
+ const forwardedFor = headers.get("x-forwarded-for");
50
+ if (forwardedFor) {
51
+ const firstIp = forwardedFor.split(",")[0]?.trim();
52
+ ip = validateIP(firstIp);
53
+ }
54
+ }
55
+ if (!ip) {
56
+ const vercelForwarded = headers.get("x-vercel-forwarded-for");
57
+ if (vercelForwarded) {
58
+ const firstIp = vercelForwarded.split(",")[0]?.trim();
59
+ ip = validateIP(firstIp);
60
+ }
61
+ }
62
+ if (!ip) {
63
+ const trueClientIp = headers.get("true-client-ip");
64
+ if (trueClientIp) {
65
+ ip = validateIP(trueClientIp);
66
+ }
67
+ }
68
+ if (!ip && request.ip) {
69
+ ip = validateIP(request.ip);
70
+ }
71
+ const userAgent = headers.get("user-agent") || void 0;
72
+ const deviceFingerprint = headers.get("x-device-fingerprint") || void 0;
73
+ const referrer = headers.get("referer") || void 0;
74
+ return {
75
+ ip,
76
+ userAgent,
77
+ deviceFingerprint,
78
+ referrer
79
+ };
80
+ }
17
81
  function buildClientContextHeaders(context) {
18
82
  const headers = {};
19
83
  if (!context) {
@@ -54,14 +118,14 @@ var ScaleMuleServer = class {
54
118
  /**
55
119
  * Register a new user
56
120
  */
57
- register: async (data) => {
58
- return this.request("POST", "/v1/auth/register", { body: data });
121
+ register: async (data, options) => {
122
+ return this.request("POST", "/v1/auth/register", { body: data, clientContext: options?.clientContext });
59
123
  },
60
124
  /**
61
125
  * Login user - returns session token (store in HTTP-only cookie)
62
126
  */
63
- login: async (data) => {
64
- return this.request("POST", "/v1/auth/login", { body: data });
127
+ login: async (data, options) => {
128
+ return this.request("POST", "/v1/auth/login", { body: data, clientContext: options?.clientContext });
65
129
  },
66
130
  /**
67
131
  * Logout user
@@ -88,15 +152,16 @@ var ScaleMuleServer = class {
88
152
  /**
89
153
  * Request password reset email
90
154
  */
91
- forgotPassword: async (email) => {
92
- return this.request("POST", "/v1/auth/forgot-password", { body: { email } });
155
+ forgotPassword: async (email, options) => {
156
+ return this.request("POST", "/v1/auth/forgot-password", { body: { email }, clientContext: options?.clientContext });
93
157
  },
94
158
  /**
95
159
  * Reset password with token
96
160
  */
97
- resetPassword: async (token, newPassword) => {
161
+ resetPassword: async (token, newPassword, options) => {
98
162
  return this.request("POST", "/v1/auth/reset-password", {
99
- body: { token, new_password: newPassword }
163
+ body: { token, new_password: newPassword },
164
+ clientContext: options?.clientContext
100
165
  });
101
166
  },
102
167
  /**
@@ -809,6 +874,7 @@ function createAuthRoutes(config = {}) {
809
874
  const path = params?.scalemule?.join("/") || "";
810
875
  try {
811
876
  const body = await request.json().catch(() => ({}));
877
+ const clientContext = extractClientContext(request);
812
878
  switch (path) {
813
879
  // ==================== Register ====================
814
880
  case "register": {
@@ -818,7 +884,7 @@ function createAuthRoutes(config = {}) {
818
884
  }
819
885
  let registeredUser;
820
886
  try {
821
- registeredUser = await sm.auth.register({ email, password, full_name, username, phone });
887
+ registeredUser = await sm.auth.register({ email, password, full_name, username, phone }, { clientContext });
822
888
  } catch (err) {
823
889
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
824
890
  return errorResponse(
@@ -832,7 +898,7 @@ function createAuthRoutes(config = {}) {
832
898
  }
833
899
  let loginData;
834
900
  try {
835
- loginData = await sm.auth.login({ email, password });
901
+ loginData = await sm.auth.login({ email, password }, { clientContext });
836
902
  } catch {
837
903
  return successResponse({ user: registeredUser, message: "Registration successful" }, 201);
838
904
  }
@@ -846,7 +912,7 @@ function createAuthRoutes(config = {}) {
846
912
  }
847
913
  let loginData;
848
914
  try {
849
- loginData = await sm.auth.login({ email, password, remember_me });
915
+ loginData = await sm.auth.login({ email, password, remember_me }, { clientContext });
850
916
  } catch (err) {
851
917
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
852
918
  const errorCode = apiErr?.code || "LOGIN_FAILED";
@@ -886,7 +952,7 @@ function createAuthRoutes(config = {}) {
886
952
  if (!email) {
887
953
  return errorResponse("VALIDATION_ERROR", "Email required", 400);
888
954
  }
889
- const result = await sm.auth.forgotPassword(email);
955
+ const result = await sm.auth.forgotPassword(email, { clientContext });
890
956
  return successResponse({ message: "If an account exists, a reset email has been sent" });
891
957
  }
892
958
  // ==================== Reset Password ====================
@@ -896,7 +962,7 @@ function createAuthRoutes(config = {}) {
896
962
  return errorResponse("VALIDATION_ERROR", "Token and new password required", 400);
897
963
  }
898
964
  try {
899
- await sm.auth.resetPassword(token, new_password);
965
+ await sm.auth.resetPassword(token, new_password, { clientContext });
900
966
  } catch (err) {
901
967
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
902
968
  return errorResponse(
@@ -12,6 +12,70 @@ var ScaleMuleApiError = class extends Error {
12
12
  };
13
13
 
14
14
  // src/server/context.ts
15
+ function validateIP(ip) {
16
+ if (!ip) return void 0;
17
+ const trimmed = ip.trim();
18
+ if (!trimmed) return void 0;
19
+ const ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
20
+ const ipv6Regex = /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^::(?:[0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}$|^(?:[0-9a-fA-F]{1,4}:){1,7}:$|^(?:[0-9a-fA-F]{1,4}:){0,6}::(?:[0-9a-fA-F]{1,4}:){0,5}[0-9a-fA-F]{1,4}$/;
21
+ const ipv4MappedRegex = /^::ffff:(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i;
22
+ if (ipv4Regex.test(trimmed) || ipv6Regex.test(trimmed) || ipv4MappedRegex.test(trimmed)) {
23
+ return trimmed;
24
+ }
25
+ return void 0;
26
+ }
27
+ function extractClientContext(request) {
28
+ const headers = request.headers;
29
+ let ip;
30
+ const cfConnectingIp = headers.get("cf-connecting-ip");
31
+ if (cfConnectingIp) {
32
+ ip = validateIP(cfConnectingIp);
33
+ }
34
+ if (!ip) {
35
+ const doConnectingIp = headers.get("do-connecting-ip");
36
+ if (doConnectingIp) {
37
+ ip = validateIP(doConnectingIp);
38
+ }
39
+ }
40
+ if (!ip) {
41
+ const realIp = headers.get("x-real-ip");
42
+ if (realIp) {
43
+ ip = validateIP(realIp);
44
+ }
45
+ }
46
+ if (!ip) {
47
+ const forwardedFor = headers.get("x-forwarded-for");
48
+ if (forwardedFor) {
49
+ const firstIp = forwardedFor.split(",")[0]?.trim();
50
+ ip = validateIP(firstIp);
51
+ }
52
+ }
53
+ if (!ip) {
54
+ const vercelForwarded = headers.get("x-vercel-forwarded-for");
55
+ if (vercelForwarded) {
56
+ const firstIp = vercelForwarded.split(",")[0]?.trim();
57
+ ip = validateIP(firstIp);
58
+ }
59
+ }
60
+ if (!ip) {
61
+ const trueClientIp = headers.get("true-client-ip");
62
+ if (trueClientIp) {
63
+ ip = validateIP(trueClientIp);
64
+ }
65
+ }
66
+ if (!ip && request.ip) {
67
+ ip = validateIP(request.ip);
68
+ }
69
+ const userAgent = headers.get("user-agent") || void 0;
70
+ const deviceFingerprint = headers.get("x-device-fingerprint") || void 0;
71
+ const referrer = headers.get("referer") || void 0;
72
+ return {
73
+ ip,
74
+ userAgent,
75
+ deviceFingerprint,
76
+ referrer
77
+ };
78
+ }
15
79
  function buildClientContextHeaders(context) {
16
80
  const headers = {};
17
81
  if (!context) {
@@ -52,14 +116,14 @@ var ScaleMuleServer = class {
52
116
  /**
53
117
  * Register a new user
54
118
  */
55
- register: async (data) => {
56
- return this.request("POST", "/v1/auth/register", { body: data });
119
+ register: async (data, options) => {
120
+ return this.request("POST", "/v1/auth/register", { body: data, clientContext: options?.clientContext });
57
121
  },
58
122
  /**
59
123
  * Login user - returns session token (store in HTTP-only cookie)
60
124
  */
61
- login: async (data) => {
62
- return this.request("POST", "/v1/auth/login", { body: data });
125
+ login: async (data, options) => {
126
+ return this.request("POST", "/v1/auth/login", { body: data, clientContext: options?.clientContext });
63
127
  },
64
128
  /**
65
129
  * Logout user
@@ -86,15 +150,16 @@ var ScaleMuleServer = class {
86
150
  /**
87
151
  * Request password reset email
88
152
  */
89
- forgotPassword: async (email) => {
90
- return this.request("POST", "/v1/auth/forgot-password", { body: { email } });
153
+ forgotPassword: async (email, options) => {
154
+ return this.request("POST", "/v1/auth/forgot-password", { body: { email }, clientContext: options?.clientContext });
91
155
  },
92
156
  /**
93
157
  * Reset password with token
94
158
  */
95
- resetPassword: async (token, newPassword) => {
159
+ resetPassword: async (token, newPassword, options) => {
96
160
  return this.request("POST", "/v1/auth/reset-password", {
97
- body: { token, new_password: newPassword }
161
+ body: { token, new_password: newPassword },
162
+ clientContext: options?.clientContext
98
163
  });
99
164
  },
100
165
  /**
@@ -807,6 +872,7 @@ function createAuthRoutes(config = {}) {
807
872
  const path = params?.scalemule?.join("/") || "";
808
873
  try {
809
874
  const body = await request.json().catch(() => ({}));
875
+ const clientContext = extractClientContext(request);
810
876
  switch (path) {
811
877
  // ==================== Register ====================
812
878
  case "register": {
@@ -816,7 +882,7 @@ function createAuthRoutes(config = {}) {
816
882
  }
817
883
  let registeredUser;
818
884
  try {
819
- registeredUser = await sm.auth.register({ email, password, full_name, username, phone });
885
+ registeredUser = await sm.auth.register({ email, password, full_name, username, phone }, { clientContext });
820
886
  } catch (err) {
821
887
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
822
888
  return errorResponse(
@@ -830,7 +896,7 @@ function createAuthRoutes(config = {}) {
830
896
  }
831
897
  let loginData;
832
898
  try {
833
- loginData = await sm.auth.login({ email, password });
899
+ loginData = await sm.auth.login({ email, password }, { clientContext });
834
900
  } catch {
835
901
  return successResponse({ user: registeredUser, message: "Registration successful" }, 201);
836
902
  }
@@ -844,7 +910,7 @@ function createAuthRoutes(config = {}) {
844
910
  }
845
911
  let loginData;
846
912
  try {
847
- loginData = await sm.auth.login({ email, password, remember_me });
913
+ loginData = await sm.auth.login({ email, password, remember_me }, { clientContext });
848
914
  } catch (err) {
849
915
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
850
916
  const errorCode = apiErr?.code || "LOGIN_FAILED";
@@ -884,7 +950,7 @@ function createAuthRoutes(config = {}) {
884
950
  if (!email) {
885
951
  return errorResponse("VALIDATION_ERROR", "Email required", 400);
886
952
  }
887
- const result = await sm.auth.forgotPassword(email);
953
+ const result = await sm.auth.forgotPassword(email, { clientContext });
888
954
  return successResponse({ message: "If an account exists, a reset email has been sent" });
889
955
  }
890
956
  // ==================== Reset Password ====================
@@ -894,7 +960,7 @@ function createAuthRoutes(config = {}) {
894
960
  return errorResponse("VALIDATION_ERROR", "Token and new password required", 400);
895
961
  }
896
962
  try {
897
- await sm.auth.resetPassword(token, new_password);
963
+ await sm.auth.resetPassword(token, new_password, { clientContext });
898
964
  } catch (err) {
899
965
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
900
966
  return errorResponse(
@@ -1,5 +1,5 @@
1
- import { S as ServerConfig } from '../webhook-handler-B_S2RgMO.mjs';
2
- export { a as ScaleMuleServer, d as VideoFailedEvent, V as VideoReadyEvent, f as VideoTranscodedEvent, e as VideoUploadedEvent, W as WebhookEvent, g as WebhookRoutesConfig, c as createServerClient, h as createWebhookHandler, b as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, v as verifyWebhookSignature } from '../webhook-handler-B_S2RgMO.mjs';
1
+ import { S as ServerConfig } from '../webhook-handler-BzBvYbZU.mjs';
2
+ export { a as ScaleMuleServer, d as VideoFailedEvent, V as VideoReadyEvent, f as VideoTranscodedEvent, e as VideoUploadedEvent, W as WebhookEvent, g as WebhookRoutesConfig, c as createServerClient, h as createWebhookHandler, b as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, v as verifyWebhookSignature } from '../webhook-handler-BzBvYbZU.mjs';
3
3
  import { $ as ClientContext, L as LoginResponse, A as ApiError } from '../index-jomBa89d.mjs';
4
4
  import { NextRequest, NextResponse } from 'next/server';
5
5
 
@@ -1,5 +1,5 @@
1
- import { S as ServerConfig } from '../webhook-handler-BKhYMJ9A.js';
2
- export { a as ScaleMuleServer, d as VideoFailedEvent, V as VideoReadyEvent, f as VideoTranscodedEvent, e as VideoUploadedEvent, W as WebhookEvent, g as WebhookRoutesConfig, c as createServerClient, h as createWebhookHandler, b as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, v as verifyWebhookSignature } from '../webhook-handler-BKhYMJ9A.js';
1
+ import { S as ServerConfig } from '../webhook-handler-tcJtRpkE.js';
2
+ export { a as ScaleMuleServer, d as VideoFailedEvent, V as VideoReadyEvent, f as VideoTranscodedEvent, e as VideoUploadedEvent, W as WebhookEvent, g as WebhookRoutesConfig, c as createServerClient, h as createWebhookHandler, b as createWebhookRoutes, p as parseWebhookEvent, r as registerVideoWebhook, v as verifyWebhookSignature } from '../webhook-handler-tcJtRpkE.js';
3
3
  import { $ as ClientContext, L as LoginResponse, A as ApiError } from '../index-jomBa89d.js';
4
4
  import { NextRequest, NextResponse } from 'next/server';
5
5
 
@@ -178,14 +178,14 @@ var ScaleMuleServer = class {
178
178
  /**
179
179
  * Register a new user
180
180
  */
181
- register: async (data) => {
182
- return this.request("POST", "/v1/auth/register", { body: data });
181
+ register: async (data, options) => {
182
+ return this.request("POST", "/v1/auth/register", { body: data, clientContext: options?.clientContext });
183
183
  },
184
184
  /**
185
185
  * Login user - returns session token (store in HTTP-only cookie)
186
186
  */
187
- login: async (data) => {
188
- return this.request("POST", "/v1/auth/login", { body: data });
187
+ login: async (data, options) => {
188
+ return this.request("POST", "/v1/auth/login", { body: data, clientContext: options?.clientContext });
189
189
  },
190
190
  /**
191
191
  * Logout user
@@ -212,15 +212,16 @@ var ScaleMuleServer = class {
212
212
  /**
213
213
  * Request password reset email
214
214
  */
215
- forgotPassword: async (email) => {
216
- return this.request("POST", "/v1/auth/forgot-password", { body: { email } });
215
+ forgotPassword: async (email, options) => {
216
+ return this.request("POST", "/v1/auth/forgot-password", { body: { email }, clientContext: options?.clientContext });
217
217
  },
218
218
  /**
219
219
  * Reset password with token
220
220
  */
221
- resetPassword: async (token, newPassword) => {
221
+ resetPassword: async (token, newPassword, options) => {
222
222
  return this.request("POST", "/v1/auth/reset-password", {
223
- body: { token, new_password: newPassword }
223
+ body: { token, new_password: newPassword },
224
+ clientContext: options?.clientContext
224
225
  });
225
226
  },
226
227
  /**
@@ -1026,6 +1027,7 @@ function createAuthRoutes(config = {}) {
1026
1027
  const path = params?.scalemule?.join("/") || "";
1027
1028
  try {
1028
1029
  const body = await request.json().catch(() => ({}));
1030
+ const clientContext = extractClientContext(request);
1029
1031
  switch (path) {
1030
1032
  // ==================== Register ====================
1031
1033
  case "register": {
@@ -1035,7 +1037,7 @@ function createAuthRoutes(config = {}) {
1035
1037
  }
1036
1038
  let registeredUser;
1037
1039
  try {
1038
- registeredUser = await sm.auth.register({ email, password, full_name, username, phone });
1040
+ registeredUser = await sm.auth.register({ email, password, full_name, username, phone }, { clientContext });
1039
1041
  } catch (err) {
1040
1042
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
1041
1043
  return errorResponse(
@@ -1049,7 +1051,7 @@ function createAuthRoutes(config = {}) {
1049
1051
  }
1050
1052
  let loginData;
1051
1053
  try {
1052
- loginData = await sm.auth.login({ email, password });
1054
+ loginData = await sm.auth.login({ email, password }, { clientContext });
1053
1055
  } catch {
1054
1056
  return successResponse({ user: registeredUser, message: "Registration successful" }, 201);
1055
1057
  }
@@ -1063,7 +1065,7 @@ function createAuthRoutes(config = {}) {
1063
1065
  }
1064
1066
  let loginData;
1065
1067
  try {
1066
- loginData = await sm.auth.login({ email, password, remember_me });
1068
+ loginData = await sm.auth.login({ email, password, remember_me }, { clientContext });
1067
1069
  } catch (err) {
1068
1070
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
1069
1071
  const errorCode = apiErr?.code || "LOGIN_FAILED";
@@ -1103,7 +1105,7 @@ function createAuthRoutes(config = {}) {
1103
1105
  if (!email) {
1104
1106
  return errorResponse("VALIDATION_ERROR", "Email required", 400);
1105
1107
  }
1106
- const result = await sm.auth.forgotPassword(email);
1108
+ const result = await sm.auth.forgotPassword(email, { clientContext });
1107
1109
  return successResponse({ message: "If an account exists, a reset email has been sent" });
1108
1110
  }
1109
1111
  // ==================== Reset Password ====================
@@ -1113,7 +1115,7 @@ function createAuthRoutes(config = {}) {
1113
1115
  return errorResponse("VALIDATION_ERROR", "Token and new password required", 400);
1114
1116
  }
1115
1117
  try {
1116
- await sm.auth.resetPassword(token, new_password);
1118
+ await sm.auth.resetPassword(token, new_password, { clientContext });
1117
1119
  } catch (err) {
1118
1120
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
1119
1121
  return errorResponse(
@@ -176,14 +176,14 @@ var ScaleMuleServer = class {
176
176
  /**
177
177
  * Register a new user
178
178
  */
179
- register: async (data) => {
180
- return this.request("POST", "/v1/auth/register", { body: data });
179
+ register: async (data, options) => {
180
+ return this.request("POST", "/v1/auth/register", { body: data, clientContext: options?.clientContext });
181
181
  },
182
182
  /**
183
183
  * Login user - returns session token (store in HTTP-only cookie)
184
184
  */
185
- login: async (data) => {
186
- return this.request("POST", "/v1/auth/login", { body: data });
185
+ login: async (data, options) => {
186
+ return this.request("POST", "/v1/auth/login", { body: data, clientContext: options?.clientContext });
187
187
  },
188
188
  /**
189
189
  * Logout user
@@ -210,15 +210,16 @@ var ScaleMuleServer = class {
210
210
  /**
211
211
  * Request password reset email
212
212
  */
213
- forgotPassword: async (email) => {
214
- return this.request("POST", "/v1/auth/forgot-password", { body: { email } });
213
+ forgotPassword: async (email, options) => {
214
+ return this.request("POST", "/v1/auth/forgot-password", { body: { email }, clientContext: options?.clientContext });
215
215
  },
216
216
  /**
217
217
  * Reset password with token
218
218
  */
219
- resetPassword: async (token, newPassword) => {
219
+ resetPassword: async (token, newPassword, options) => {
220
220
  return this.request("POST", "/v1/auth/reset-password", {
221
- body: { token, new_password: newPassword }
221
+ body: { token, new_password: newPassword },
222
+ clientContext: options?.clientContext
222
223
  });
223
224
  },
224
225
  /**
@@ -1024,6 +1025,7 @@ function createAuthRoutes(config = {}) {
1024
1025
  const path = params?.scalemule?.join("/") || "";
1025
1026
  try {
1026
1027
  const body = await request.json().catch(() => ({}));
1028
+ const clientContext = extractClientContext(request);
1027
1029
  switch (path) {
1028
1030
  // ==================== Register ====================
1029
1031
  case "register": {
@@ -1033,7 +1035,7 @@ function createAuthRoutes(config = {}) {
1033
1035
  }
1034
1036
  let registeredUser;
1035
1037
  try {
1036
- registeredUser = await sm.auth.register({ email, password, full_name, username, phone });
1038
+ registeredUser = await sm.auth.register({ email, password, full_name, username, phone }, { clientContext });
1037
1039
  } catch (err) {
1038
1040
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
1039
1041
  return errorResponse(
@@ -1047,7 +1049,7 @@ function createAuthRoutes(config = {}) {
1047
1049
  }
1048
1050
  let loginData;
1049
1051
  try {
1050
- loginData = await sm.auth.login({ email, password });
1052
+ loginData = await sm.auth.login({ email, password }, { clientContext });
1051
1053
  } catch {
1052
1054
  return successResponse({ user: registeredUser, message: "Registration successful" }, 201);
1053
1055
  }
@@ -1061,7 +1063,7 @@ function createAuthRoutes(config = {}) {
1061
1063
  }
1062
1064
  let loginData;
1063
1065
  try {
1064
- loginData = await sm.auth.login({ email, password, remember_me });
1066
+ loginData = await sm.auth.login({ email, password, remember_me }, { clientContext });
1065
1067
  } catch (err) {
1066
1068
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
1067
1069
  const errorCode = apiErr?.code || "LOGIN_FAILED";
@@ -1101,7 +1103,7 @@ function createAuthRoutes(config = {}) {
1101
1103
  if (!email) {
1102
1104
  return errorResponse("VALIDATION_ERROR", "Email required", 400);
1103
1105
  }
1104
- const result = await sm.auth.forgotPassword(email);
1106
+ const result = await sm.auth.forgotPassword(email, { clientContext });
1105
1107
  return successResponse({ message: "If an account exists, a reset email has been sent" });
1106
1108
  }
1107
1109
  // ==================== Reset Password ====================
@@ -1111,7 +1113,7 @@ function createAuthRoutes(config = {}) {
1111
1113
  return errorResponse("VALIDATION_ERROR", "Token and new password required", 400);
1112
1114
  }
1113
1115
  try {
1114
- await sm.auth.resetPassword(token, new_password);
1116
+ await sm.auth.resetPassword(token, new_password, { clientContext });
1115
1117
  } catch (err) {
1116
1118
  const apiErr = err instanceof ScaleMuleApiError ? err : null;
1117
1119
  return errorResponse(
@@ -1,2 +1,2 @@
1
- export { h as createWebhookHandler } from '../webhook-handler-B_S2RgMO.mjs';
1
+ export { h as createWebhookHandler } from '../webhook-handler-BzBvYbZU.mjs';
2
2
  import '../index-jomBa89d.mjs';
@@ -1,2 +1,2 @@
1
- export { h as createWebhookHandler } from '../webhook-handler-BKhYMJ9A.js';
1
+ export { h as createWebhookHandler } from '../webhook-handler-tcJtRpkE.js';
2
2
  import '../index-jomBa89d.js';
@@ -1,4 +1,4 @@
1
- import { R as RegisterRequest, U as User, l as LoginRequest, L as LoginResponse, c as ListFilesParams, T as ListFilesResponse, N as StorageFile, $ as ClientContext, W as UploadResponse } from './index-jomBa89d.mjs';
1
+ import { R as RegisterRequest, $ as ClientContext, U as User, l as LoginRequest, L as LoginResponse, c as ListFilesParams, T as ListFilesResponse, N as StorageFile, W as UploadResponse } from './index-jomBa89d.mjs';
2
2
 
3
3
  /**
4
4
  * Server-Side ScaleMule Client
@@ -39,11 +39,15 @@ declare class ScaleMuleServer {
39
39
  /**
40
40
  * Register a new user
41
41
  */
42
- register: (data: RegisterRequest) => Promise<User>;
42
+ register: (data: RegisterRequest, options?: {
43
+ clientContext?: ClientContext;
44
+ }) => Promise<User>;
43
45
  /**
44
46
  * Login user - returns session token (store in HTTP-only cookie)
45
47
  */
46
- login: (data: LoginRequest) => Promise<LoginResponse>;
48
+ login: (data: LoginRequest, options?: {
49
+ clientContext?: ClientContext;
50
+ }) => Promise<LoginResponse>;
47
51
  /**
48
52
  * Logout user
49
53
  */
@@ -62,13 +66,17 @@ declare class ScaleMuleServer {
62
66
  /**
63
67
  * Request password reset email
64
68
  */
65
- forgotPassword: (email: string) => Promise<{
69
+ forgotPassword: (email: string, options?: {
70
+ clientContext?: ClientContext;
71
+ }) => Promise<{
66
72
  message: string;
67
73
  }>;
68
74
  /**
69
75
  * Reset password with token
70
76
  */
71
- resetPassword: (token: string, newPassword: string) => Promise<{
77
+ resetPassword: (token: string, newPassword: string, options?: {
78
+ clientContext?: ClientContext;
79
+ }) => Promise<{
72
80
  message: string;
73
81
  }>;
74
82
  /**
@@ -1,4 +1,4 @@
1
- import { R as RegisterRequest, U as User, l as LoginRequest, L as LoginResponse, c as ListFilesParams, T as ListFilesResponse, N as StorageFile, $ as ClientContext, W as UploadResponse } from './index-jomBa89d.js';
1
+ import { R as RegisterRequest, $ as ClientContext, U as User, l as LoginRequest, L as LoginResponse, c as ListFilesParams, T as ListFilesResponse, N as StorageFile, W as UploadResponse } from './index-jomBa89d.js';
2
2
 
3
3
  /**
4
4
  * Server-Side ScaleMule Client
@@ -39,11 +39,15 @@ declare class ScaleMuleServer {
39
39
  /**
40
40
  * Register a new user
41
41
  */
42
- register: (data: RegisterRequest) => Promise<User>;
42
+ register: (data: RegisterRequest, options?: {
43
+ clientContext?: ClientContext;
44
+ }) => Promise<User>;
43
45
  /**
44
46
  * Login user - returns session token (store in HTTP-only cookie)
45
47
  */
46
- login: (data: LoginRequest) => Promise<LoginResponse>;
48
+ login: (data: LoginRequest, options?: {
49
+ clientContext?: ClientContext;
50
+ }) => Promise<LoginResponse>;
47
51
  /**
48
52
  * Logout user
49
53
  */
@@ -62,13 +66,17 @@ declare class ScaleMuleServer {
62
66
  /**
63
67
  * Request password reset email
64
68
  */
65
- forgotPassword: (email: string) => Promise<{
69
+ forgotPassword: (email: string, options?: {
70
+ clientContext?: ClientContext;
71
+ }) => Promise<{
66
72
  message: string;
67
73
  }>;
68
74
  /**
69
75
  * Reset password with token
70
76
  */
71
- resetPassword: (token: string, newPassword: string) => Promise<{
77
+ resetPassword: (token: string, newPassword: string, options?: {
78
+ clientContext?: ClientContext;
79
+ }) => Promise<{
72
80
  message: string;
73
81
  }>;
74
82
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalemule/nextjs",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "ScaleMule SDK for Next.js applications - authentication, storage, and user management",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",