@scalemule/sdk 0.0.67 → 0.0.69
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.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +14 -4
- package/dist/index.mjs +14 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -130,6 +130,9 @@ interface ScaleMuleConfig {
|
|
|
130
130
|
applicationId?: string;
|
|
131
131
|
/** Base URL for API requests. Overrides environment preset. */
|
|
132
132
|
baseUrl?: string;
|
|
133
|
+
/** Public gateway for WebSockets when HTTP uses a same-origin cookie proxy.
|
|
134
|
+
* When set, realtime requires a successful ticket exchange; bearer fallback is disabled. */
|
|
135
|
+
realtimeUrl?: string;
|
|
133
136
|
/** Environment preset ('dev' or 'prod'). Defaults to 'prod'. */
|
|
134
137
|
environment?: 'dev' | 'prod';
|
|
135
138
|
/** Retry configuration for transient failures */
|
|
@@ -442,6 +445,7 @@ declare class ScaleMuleClient {
|
|
|
442
445
|
private apiKey;
|
|
443
446
|
private applicationId;
|
|
444
447
|
private baseUrl;
|
|
448
|
+
private realtimeUrl?;
|
|
445
449
|
private debug;
|
|
446
450
|
private storage;
|
|
447
451
|
private defaultTimeout;
|
|
@@ -525,6 +529,8 @@ declare class ScaleMuleClient {
|
|
|
525
529
|
/** Persist known accounts to storage */
|
|
526
530
|
private persistKnownAccounts;
|
|
527
531
|
getBaseUrl(): string;
|
|
532
|
+
getRealtimeUrl(): string;
|
|
533
|
+
requiresRealtimeTicket(): boolean;
|
|
528
534
|
getApiKey(): string;
|
|
529
535
|
isOnline(): boolean;
|
|
530
536
|
getOfflineQueueLength(): number;
|
|
@@ -908,6 +914,8 @@ declare class AuthService extends ServiceModule {
|
|
|
908
914
|
session_id?: string;
|
|
909
915
|
}, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
|
|
910
916
|
login(data: {
|
|
917
|
+
challenge_token?: string;
|
|
918
|
+
challenge_code?: string;
|
|
911
919
|
email: string;
|
|
912
920
|
password: string;
|
|
913
921
|
remember_me?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -130,6 +130,9 @@ interface ScaleMuleConfig {
|
|
|
130
130
|
applicationId?: string;
|
|
131
131
|
/** Base URL for API requests. Overrides environment preset. */
|
|
132
132
|
baseUrl?: string;
|
|
133
|
+
/** Public gateway for WebSockets when HTTP uses a same-origin cookie proxy.
|
|
134
|
+
* When set, realtime requires a successful ticket exchange; bearer fallback is disabled. */
|
|
135
|
+
realtimeUrl?: string;
|
|
133
136
|
/** Environment preset ('dev' or 'prod'). Defaults to 'prod'. */
|
|
134
137
|
environment?: 'dev' | 'prod';
|
|
135
138
|
/** Retry configuration for transient failures */
|
|
@@ -442,6 +445,7 @@ declare class ScaleMuleClient {
|
|
|
442
445
|
private apiKey;
|
|
443
446
|
private applicationId;
|
|
444
447
|
private baseUrl;
|
|
448
|
+
private realtimeUrl?;
|
|
445
449
|
private debug;
|
|
446
450
|
private storage;
|
|
447
451
|
private defaultTimeout;
|
|
@@ -525,6 +529,8 @@ declare class ScaleMuleClient {
|
|
|
525
529
|
/** Persist known accounts to storage */
|
|
526
530
|
private persistKnownAccounts;
|
|
527
531
|
getBaseUrl(): string;
|
|
532
|
+
getRealtimeUrl(): string;
|
|
533
|
+
requiresRealtimeTicket(): boolean;
|
|
528
534
|
getApiKey(): string;
|
|
529
535
|
isOnline(): boolean;
|
|
530
536
|
getOfflineQueueLength(): number;
|
|
@@ -908,6 +914,8 @@ declare class AuthService extends ServiceModule {
|
|
|
908
914
|
session_id?: string;
|
|
909
915
|
}, options?: RequestOptions): Promise<ApiResponse<AuthSession>>;
|
|
910
916
|
login(data: {
|
|
917
|
+
challenge_token?: string;
|
|
918
|
+
challenge_code?: string;
|
|
911
919
|
email: string;
|
|
912
920
|
password: string;
|
|
913
921
|
remember_me?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -830,6 +830,7 @@ var ScaleMuleClient = class {
|
|
|
830
830
|
this.apiKey = config.apiKey;
|
|
831
831
|
this.applicationId = config.applicationId || null;
|
|
832
832
|
this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
|
|
833
|
+
this.realtimeUrl = config.realtimeUrl;
|
|
833
834
|
this.debug = config.debug || false;
|
|
834
835
|
this.storage = config.storage || createDefaultStorage();
|
|
835
836
|
this.defaultTimeout = config.timeout || DEFAULT_TIMEOUT;
|
|
@@ -1122,6 +1123,12 @@ var ScaleMuleClient = class {
|
|
|
1122
1123
|
getBaseUrl() {
|
|
1123
1124
|
return this.baseUrl;
|
|
1124
1125
|
}
|
|
1126
|
+
getRealtimeUrl() {
|
|
1127
|
+
return this.realtimeUrl || this.baseUrl;
|
|
1128
|
+
}
|
|
1129
|
+
requiresRealtimeTicket() {
|
|
1130
|
+
return this.realtimeUrl !== void 0;
|
|
1131
|
+
}
|
|
1125
1132
|
getApiKey() {
|
|
1126
1133
|
return this.apiKey;
|
|
1127
1134
|
}
|
|
@@ -1228,7 +1235,7 @@ var ScaleMuleClient = class {
|
|
|
1228
1235
|
responseData = { message: text };
|
|
1229
1236
|
}
|
|
1230
1237
|
}
|
|
1231
|
-
if (!response.ok) {
|
|
1238
|
+
if (!response.ok || responseData?.success === false) {
|
|
1232
1239
|
const error = {
|
|
1233
1240
|
code: responseData?.error?.code || responseData?.code || statusToErrorCode(response.status),
|
|
1234
1241
|
message: responseData?.error?.message || responseData?.message || response.statusText,
|
|
@@ -1670,7 +1677,7 @@ function asString(parent, key) {
|
|
|
1670
1677
|
return typeof value === "string" ? value : void 0;
|
|
1671
1678
|
}
|
|
1672
1679
|
|
|
1673
|
-
//
|
|
1680
|
+
// node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
1674
1681
|
var PHONE_COUNTRIES = [
|
|
1675
1682
|
{ code: "US", name: "United States", dialCode: "+1" },
|
|
1676
1683
|
{ code: "CA", name: "Canada", dialCode: "+1" },
|
|
@@ -4322,6 +4329,7 @@ var RealtimeService = class extends ServiceModule {
|
|
|
4322
4329
|
}
|
|
4323
4330
|
async fetchTicketAndConnect() {
|
|
4324
4331
|
const baseUrl = this.client.getBaseUrl();
|
|
4332
|
+
const realtimeUrl = this.client.getRealtimeUrl();
|
|
4325
4333
|
try {
|
|
4326
4334
|
const headers = { "Content-Type": "application/json" };
|
|
4327
4335
|
const apiKey = this.client.getApiKey();
|
|
@@ -4344,10 +4352,12 @@ var RealtimeService = class extends ServiceModule {
|
|
|
4344
4352
|
if (ticketRes.ok) {
|
|
4345
4353
|
const ticketData = await ticketRes.json();
|
|
4346
4354
|
const ticket = ticketData.ticket;
|
|
4347
|
-
|
|
4355
|
+
if (typeof ticket !== "string" || !ticket) throw new Error("Missing realtime ticket");
|
|
4356
|
+
wsUrl = realtimeUrl.replace(/^http/, "ws") + `/v1/realtime/ws?ticket=${encodeURIComponent(ticket)}`;
|
|
4348
4357
|
this.usedTicketAuth = true;
|
|
4349
4358
|
} else {
|
|
4350
|
-
|
|
4359
|
+
if (this.client.requiresRealtimeTicket()) throw new Error("Realtime ticket required");
|
|
4360
|
+
wsUrl = realtimeUrl.replace(/^http/, "ws") + "/v1/realtime/ws";
|
|
4351
4361
|
this.usedTicketAuth = false;
|
|
4352
4362
|
}
|
|
4353
4363
|
this.ws = new WebSocket(wsUrl);
|
package/dist/index.mjs
CHANGED
|
@@ -721,6 +721,7 @@ var ScaleMuleClient = class {
|
|
|
721
721
|
this.apiKey = config.apiKey;
|
|
722
722
|
this.applicationId = config.applicationId || null;
|
|
723
723
|
this.baseUrl = config.baseUrl || GATEWAY_URLS[config.environment || "prod"];
|
|
724
|
+
this.realtimeUrl = config.realtimeUrl;
|
|
724
725
|
this.debug = config.debug || false;
|
|
725
726
|
this.storage = config.storage || createDefaultStorage();
|
|
726
727
|
this.defaultTimeout = config.timeout || DEFAULT_TIMEOUT;
|
|
@@ -1013,6 +1014,12 @@ var ScaleMuleClient = class {
|
|
|
1013
1014
|
getBaseUrl() {
|
|
1014
1015
|
return this.baseUrl;
|
|
1015
1016
|
}
|
|
1017
|
+
getRealtimeUrl() {
|
|
1018
|
+
return this.realtimeUrl || this.baseUrl;
|
|
1019
|
+
}
|
|
1020
|
+
requiresRealtimeTicket() {
|
|
1021
|
+
return this.realtimeUrl !== void 0;
|
|
1022
|
+
}
|
|
1016
1023
|
getApiKey() {
|
|
1017
1024
|
return this.apiKey;
|
|
1018
1025
|
}
|
|
@@ -1119,7 +1126,7 @@ var ScaleMuleClient = class {
|
|
|
1119
1126
|
responseData = { message: text };
|
|
1120
1127
|
}
|
|
1121
1128
|
}
|
|
1122
|
-
if (!response.ok) {
|
|
1129
|
+
if (!response.ok || responseData?.success === false) {
|
|
1123
1130
|
const error = {
|
|
1124
1131
|
code: responseData?.error?.code || responseData?.code || statusToErrorCode(response.status),
|
|
1125
1132
|
message: responseData?.error?.message || responseData?.message || response.statusText,
|
|
@@ -1561,7 +1568,7 @@ function asString(parent, key) {
|
|
|
1561
1568
|
return typeof value === "string" ? value : void 0;
|
|
1562
1569
|
}
|
|
1563
1570
|
|
|
1564
|
-
//
|
|
1571
|
+
// node_modules/@scalemule/ui/dist/phone/index.mjs
|
|
1565
1572
|
var PHONE_COUNTRIES = [
|
|
1566
1573
|
{ code: "US", name: "United States", dialCode: "+1" },
|
|
1567
1574
|
{ code: "CA", name: "Canada", dialCode: "+1" },
|
|
@@ -4213,6 +4220,7 @@ var RealtimeService = class extends ServiceModule {
|
|
|
4213
4220
|
}
|
|
4214
4221
|
async fetchTicketAndConnect() {
|
|
4215
4222
|
const baseUrl = this.client.getBaseUrl();
|
|
4223
|
+
const realtimeUrl = this.client.getRealtimeUrl();
|
|
4216
4224
|
try {
|
|
4217
4225
|
const headers = { "Content-Type": "application/json" };
|
|
4218
4226
|
const apiKey = this.client.getApiKey();
|
|
@@ -4235,10 +4243,12 @@ var RealtimeService = class extends ServiceModule {
|
|
|
4235
4243
|
if (ticketRes.ok) {
|
|
4236
4244
|
const ticketData = await ticketRes.json();
|
|
4237
4245
|
const ticket = ticketData.ticket;
|
|
4238
|
-
|
|
4246
|
+
if (typeof ticket !== "string" || !ticket) throw new Error("Missing realtime ticket");
|
|
4247
|
+
wsUrl = realtimeUrl.replace(/^http/, "ws") + `/v1/realtime/ws?ticket=${encodeURIComponent(ticket)}`;
|
|
4239
4248
|
this.usedTicketAuth = true;
|
|
4240
4249
|
} else {
|
|
4241
|
-
|
|
4250
|
+
if (this.client.requiresRealtimeTicket()) throw new Error("Realtime ticket required");
|
|
4251
|
+
wsUrl = realtimeUrl.replace(/^http/, "ws") + "/v1/realtime/ws";
|
|
4242
4252
|
this.usedTicketAuth = false;
|
|
4243
4253
|
}
|
|
4244
4254
|
this.ws = new WebSocket(wsUrl);
|