@dora-cell/sdk 4.1.1 → 4.1.2
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 +52 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -23033,7 +23033,7 @@ var ApiTokenAuthProvider = class {
|
|
|
23033
23033
|
errorData = { message: authResponse.statusText };
|
|
23034
23034
|
}
|
|
23035
23035
|
throw new AuthenticationError(
|
|
23036
|
-
errorData.message || errorData.error ||
|
|
23036
|
+
errorData.message || errorData.error || authResponse.statusText || `HTTP ${authResponse.status}`,
|
|
23037
23037
|
{ status: authResponse.status, data: errorData }
|
|
23038
23038
|
);
|
|
23039
23039
|
}
|
|
@@ -23060,7 +23060,7 @@ var ApiTokenAuthProvider = class {
|
|
|
23060
23060
|
errorData = { message: validateResponse.statusText };
|
|
23061
23061
|
}
|
|
23062
23062
|
throw new AuthenticationError(
|
|
23063
|
-
errorData.message || errorData.error ||
|
|
23063
|
+
errorData.message || errorData.error || validateResponse.statusText || `HTTP ${validateResponse.status}`,
|
|
23064
23064
|
{ status: validateResponse.status, data: errorData }
|
|
23065
23065
|
);
|
|
23066
23066
|
}
|
|
@@ -23073,11 +23073,12 @@ var ApiTokenAuthProvider = class {
|
|
|
23073
23073
|
this.credentials = this.parseCredentials(actualResponseData);
|
|
23074
23074
|
return this.credentials;
|
|
23075
23075
|
} catch (error) {
|
|
23076
|
+
console.error("Dora Cell SDK: Authentication error:", error);
|
|
23076
23077
|
if (error instanceof AuthenticationError) {
|
|
23077
23078
|
throw error;
|
|
23078
23079
|
}
|
|
23079
23080
|
throw new AuthenticationError(
|
|
23080
|
-
|
|
23081
|
+
error instanceof Error ? error.message : "Unknown error",
|
|
23081
23082
|
{ originalError: error }
|
|
23082
23083
|
);
|
|
23083
23084
|
}
|
|
@@ -23099,9 +23100,9 @@ var ApiTokenAuthProvider = class {
|
|
|
23099
23100
|
const DEFAULT_WSS_URL = "wss://cell.usedora.com:8089/ws";
|
|
23100
23101
|
const DEFAULT_SIP_IP = "64.227.10.164";
|
|
23101
23102
|
const DEFAULT_PASSWORD = "1234";
|
|
23102
|
-
const wsUrl =
|
|
23103
|
-
const sipDomain =
|
|
23104
|
-
const password =
|
|
23103
|
+
const wsUrl = DEFAULT_WSS_URL;
|
|
23104
|
+
const sipDomain = DEFAULT_SIP_IP;
|
|
23105
|
+
const password = DEFAULT_PASSWORD;
|
|
23105
23106
|
const extensions = data.extensions || [];
|
|
23106
23107
|
const expiresIn = data.expires_in || data.expiresIn;
|
|
23107
23108
|
let sipUri = data.sip_uri || data.sipUri;
|
|
@@ -23604,9 +23605,14 @@ var DoraCell = class {
|
|
|
23604
23605
|
await this.waitForRegistration();
|
|
23605
23606
|
}
|
|
23606
23607
|
} catch (error) {
|
|
23608
|
+
if (error instanceof DoraCellError) {
|
|
23609
|
+
this.emitError(error);
|
|
23610
|
+
throw error;
|
|
23611
|
+
}
|
|
23607
23612
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
23608
|
-
|
|
23609
|
-
|
|
23613
|
+
const connError = new ConnectionError(errorMessage, { originalError: error });
|
|
23614
|
+
this.emitError(connError);
|
|
23615
|
+
throw connError;
|
|
23610
23616
|
}
|
|
23611
23617
|
}
|
|
23612
23618
|
waitForRegistration(timeoutMs = 1e4) {
|
|
@@ -23616,17 +23622,19 @@ var DoraCell = class {
|
|
|
23616
23622
|
return new Promise((resolve, reject) => {
|
|
23617
23623
|
const timeout = setTimeout(() => {
|
|
23618
23624
|
this.off("connection:status", handler);
|
|
23619
|
-
|
|
23625
|
+
const statusInfo = this.connectionStatus !== "connecting" ? ` (Last status: ${this.connectionStatus})` : "";
|
|
23626
|
+
reject(new ConnectionError(`Registration timed out after ${timeoutMs}ms${statusInfo}`));
|
|
23620
23627
|
}, timeoutMs);
|
|
23621
23628
|
const handler = (state) => {
|
|
23622
23629
|
if (state.status === "registered") {
|
|
23623
23630
|
clearTimeout(timeout);
|
|
23624
23631
|
this.off("connection:status", handler);
|
|
23625
23632
|
resolve();
|
|
23626
|
-
} else if (state.status === "registrationFailed") {
|
|
23633
|
+
} else if (state.status === "registrationFailed" || state.status === "disconnected") {
|
|
23627
23634
|
clearTimeout(timeout);
|
|
23628
23635
|
this.off("connection:status", handler);
|
|
23629
|
-
|
|
23636
|
+
const cause = state.error || (state.status === "disconnected" ? "WebSocket disconnected" : "Registration failed");
|
|
23637
|
+
reject(new ConnectionError(cause));
|
|
23630
23638
|
}
|
|
23631
23639
|
};
|
|
23632
23640
|
this.on("connection:status", handler);
|
|
@@ -23640,6 +23648,7 @@ var DoraCell = class {
|
|
|
23640
23648
|
this.emitConnectionStatus();
|
|
23641
23649
|
if (this.ua) {
|
|
23642
23650
|
try {
|
|
23651
|
+
this.ua.removeAllListeners();
|
|
23643
23652
|
this.ua.stop();
|
|
23644
23653
|
} catch (e) {
|
|
23645
23654
|
}
|
|
@@ -23671,7 +23680,8 @@ var DoraCell = class {
|
|
|
23671
23680
|
}
|
|
23672
23681
|
} catch (error) {
|
|
23673
23682
|
throw new ConnectionError(
|
|
23674
|
-
|
|
23683
|
+
error instanceof Error ? error.message : "Failed to initialize User Agent",
|
|
23684
|
+
{ originalError: error }
|
|
23675
23685
|
);
|
|
23676
23686
|
}
|
|
23677
23687
|
}
|
|
@@ -23681,9 +23691,25 @@ var DoraCell = class {
|
|
|
23681
23691
|
this.connectionStatus = "connected";
|
|
23682
23692
|
this.emitConnectionStatus();
|
|
23683
23693
|
});
|
|
23684
|
-
this.ua.on("disconnected", () => {
|
|
23694
|
+
this.ua.on("disconnected", (e) => {
|
|
23695
|
+
if (this.config.debug) {
|
|
23696
|
+
console.error("Dora Cell SDK: WebSocket disconnected:", e);
|
|
23697
|
+
}
|
|
23685
23698
|
this.connectionStatus = "disconnected";
|
|
23686
|
-
|
|
23699
|
+
let reason = e.reason || (e.error ? `WebSocket error` : void 0);
|
|
23700
|
+
if (reason && e.code) {
|
|
23701
|
+
reason = `${reason} (Code: ${e.code})`;
|
|
23702
|
+
}
|
|
23703
|
+
this.emitConnectionStatus(reason);
|
|
23704
|
+
if (e.error && this.retryCount < this.maxRetries) {
|
|
23705
|
+
this.retryCount++;
|
|
23706
|
+
setTimeout(() => {
|
|
23707
|
+
if (this.connectionStatus !== "registered" && this.connectionStatus !== "connected") {
|
|
23708
|
+
this.initializeUserAgent().catch(() => {
|
|
23709
|
+
});
|
|
23710
|
+
}
|
|
23711
|
+
}, 5e3);
|
|
23712
|
+
}
|
|
23687
23713
|
});
|
|
23688
23714
|
this.ua.on("registered", () => {
|
|
23689
23715
|
this.connectionStatus = "registered";
|
|
@@ -23692,8 +23718,15 @@ var DoraCell = class {
|
|
|
23692
23718
|
this.emitConnectionStatus();
|
|
23693
23719
|
});
|
|
23694
23720
|
this.ua.on("registrationFailed", (e) => {
|
|
23721
|
+
if (this.config.debug) {
|
|
23722
|
+
console.error("Dora Cell SDK: Registration failed:", e);
|
|
23723
|
+
}
|
|
23695
23724
|
this.connectionStatus = "registrationFailed";
|
|
23696
|
-
|
|
23725
|
+
let error = e.cause;
|
|
23726
|
+
if (e.response) {
|
|
23727
|
+
error = `${e.response.status_code} ${e.response.reason_phrase} (${e.cause})`;
|
|
23728
|
+
}
|
|
23729
|
+
this.emitConnectionStatus(error);
|
|
23697
23730
|
if (this.retryCount < this.maxRetries) {
|
|
23698
23731
|
this.retryCount++;
|
|
23699
23732
|
setTimeout(() => {
|
|
@@ -23831,7 +23864,7 @@ var DoraCell = class {
|
|
|
23831
23864
|
this.credentials.sipUri = `sip:${extension}@${domain}`;
|
|
23832
23865
|
await this.initializeUserAgent();
|
|
23833
23866
|
await this.waitForRegistration();
|
|
23834
|
-
this.emitConnectionStatus(
|
|
23867
|
+
this.emitConnectionStatus();
|
|
23835
23868
|
}
|
|
23836
23869
|
}
|
|
23837
23870
|
/**
|
|
@@ -23880,14 +23913,9 @@ var DoraCell = class {
|
|
|
23880
23913
|
this.events.emit("error", error);
|
|
23881
23914
|
}
|
|
23882
23915
|
getDefaultTurnServers() {
|
|
23883
|
-
|
|
23884
|
-
|
|
23885
|
-
|
|
23886
|
-
if (typeof process !== "undefined" && process.env) {
|
|
23887
|
-
turnUri = turnUri;
|
|
23888
|
-
turnUser = turnUser;
|
|
23889
|
-
turnPass = turnPass;
|
|
23890
|
-
}
|
|
23916
|
+
const turnUri = "turn:64.227.10.164:3478";
|
|
23917
|
+
const turnUser = "02018890089";
|
|
23918
|
+
const turnPass = "dora12345";
|
|
23891
23919
|
return [
|
|
23892
23920
|
{
|
|
23893
23921
|
urls: turnUri,
|
|
@@ -23929,9 +23957,6 @@ var DoraCell = class {
|
|
|
23929
23957
|
return "https://api.cell.usedora.com/api";
|
|
23930
23958
|
}
|
|
23931
23959
|
}
|
|
23932
|
-
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_BASE_API_URL) {
|
|
23933
|
-
return process.env.NEXT_PUBLIC_BASE_API_URL;
|
|
23934
|
-
}
|
|
23935
23960
|
return "https://api.cell.usedora.com/api";
|
|
23936
23961
|
}
|
|
23937
23962
|
};
|