@dora-cell/sdk 4.1.0 → 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 +66 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -23026,9 +23026,15 @@ var ApiTokenAuthProvider = class {
|
|
|
23026
23026
|
})
|
|
23027
23027
|
});
|
|
23028
23028
|
if (!authResponse.ok) {
|
|
23029
|
+
let errorData;
|
|
23030
|
+
try {
|
|
23031
|
+
errorData = await authResponse.json();
|
|
23032
|
+
} catch (e) {
|
|
23033
|
+
errorData = { message: authResponse.statusText };
|
|
23034
|
+
}
|
|
23029
23035
|
throw new AuthenticationError(
|
|
23030
|
-
|
|
23031
|
-
{ status: authResponse.status }
|
|
23036
|
+
errorData.message || errorData.error || authResponse.statusText || `HTTP ${authResponse.status}`,
|
|
23037
|
+
{ status: authResponse.status, data: errorData }
|
|
23032
23038
|
);
|
|
23033
23039
|
}
|
|
23034
23040
|
const authData = await authResponse.json();
|
|
@@ -23047,9 +23053,15 @@ var ApiTokenAuthProvider = class {
|
|
|
23047
23053
|
}
|
|
23048
23054
|
});
|
|
23049
23055
|
if (!validateResponse.ok) {
|
|
23056
|
+
let errorData;
|
|
23057
|
+
try {
|
|
23058
|
+
errorData = await validateResponse.json();
|
|
23059
|
+
} catch (e) {
|
|
23060
|
+
errorData = { message: validateResponse.statusText };
|
|
23061
|
+
}
|
|
23050
23062
|
throw new AuthenticationError(
|
|
23051
|
-
|
|
23052
|
-
{ status: validateResponse.status }
|
|
23063
|
+
errorData.message || errorData.error || validateResponse.statusText || `HTTP ${validateResponse.status}`,
|
|
23064
|
+
{ status: validateResponse.status, data: errorData }
|
|
23053
23065
|
);
|
|
23054
23066
|
}
|
|
23055
23067
|
const validateData = await validateResponse.json();
|
|
@@ -23061,11 +23073,12 @@ var ApiTokenAuthProvider = class {
|
|
|
23061
23073
|
this.credentials = this.parseCredentials(actualResponseData);
|
|
23062
23074
|
return this.credentials;
|
|
23063
23075
|
} catch (error) {
|
|
23076
|
+
console.error("Dora Cell SDK: Authentication error:", error);
|
|
23064
23077
|
if (error instanceof AuthenticationError) {
|
|
23065
23078
|
throw error;
|
|
23066
23079
|
}
|
|
23067
23080
|
throw new AuthenticationError(
|
|
23068
|
-
|
|
23081
|
+
error instanceof Error ? error.message : "Unknown error",
|
|
23069
23082
|
{ originalError: error }
|
|
23070
23083
|
);
|
|
23071
23084
|
}
|
|
@@ -23087,9 +23100,9 @@ var ApiTokenAuthProvider = class {
|
|
|
23087
23100
|
const DEFAULT_WSS_URL = "wss://cell.usedora.com:8089/ws";
|
|
23088
23101
|
const DEFAULT_SIP_IP = "64.227.10.164";
|
|
23089
23102
|
const DEFAULT_PASSWORD = "1234";
|
|
23090
|
-
const wsUrl =
|
|
23091
|
-
const sipDomain =
|
|
23092
|
-
const password =
|
|
23103
|
+
const wsUrl = DEFAULT_WSS_URL;
|
|
23104
|
+
const sipDomain = DEFAULT_SIP_IP;
|
|
23105
|
+
const password = DEFAULT_PASSWORD;
|
|
23093
23106
|
const extensions = data.extensions || [];
|
|
23094
23107
|
const expiresIn = data.expires_in || data.expiresIn;
|
|
23095
23108
|
let sipUri = data.sip_uri || data.sipUri;
|
|
@@ -23592,9 +23605,14 @@ var DoraCell = class {
|
|
|
23592
23605
|
await this.waitForRegistration();
|
|
23593
23606
|
}
|
|
23594
23607
|
} catch (error) {
|
|
23608
|
+
if (error instanceof DoraCellError) {
|
|
23609
|
+
this.emitError(error);
|
|
23610
|
+
throw error;
|
|
23611
|
+
}
|
|
23595
23612
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
23596
|
-
|
|
23597
|
-
|
|
23613
|
+
const connError = new ConnectionError(errorMessage, { originalError: error });
|
|
23614
|
+
this.emitError(connError);
|
|
23615
|
+
throw connError;
|
|
23598
23616
|
}
|
|
23599
23617
|
}
|
|
23600
23618
|
waitForRegistration(timeoutMs = 1e4) {
|
|
@@ -23604,17 +23622,19 @@ var DoraCell = class {
|
|
|
23604
23622
|
return new Promise((resolve, reject) => {
|
|
23605
23623
|
const timeout = setTimeout(() => {
|
|
23606
23624
|
this.off("connection:status", handler);
|
|
23607
|
-
|
|
23625
|
+
const statusInfo = this.connectionStatus !== "connecting" ? ` (Last status: ${this.connectionStatus})` : "";
|
|
23626
|
+
reject(new ConnectionError(`Registration timed out after ${timeoutMs}ms${statusInfo}`));
|
|
23608
23627
|
}, timeoutMs);
|
|
23609
23628
|
const handler = (state) => {
|
|
23610
23629
|
if (state.status === "registered") {
|
|
23611
23630
|
clearTimeout(timeout);
|
|
23612
23631
|
this.off("connection:status", handler);
|
|
23613
23632
|
resolve();
|
|
23614
|
-
} else if (state.status === "registrationFailed") {
|
|
23633
|
+
} else if (state.status === "registrationFailed" || state.status === "disconnected") {
|
|
23615
23634
|
clearTimeout(timeout);
|
|
23616
23635
|
this.off("connection:status", handler);
|
|
23617
|
-
|
|
23636
|
+
const cause = state.error || (state.status === "disconnected" ? "WebSocket disconnected" : "Registration failed");
|
|
23637
|
+
reject(new ConnectionError(cause));
|
|
23618
23638
|
}
|
|
23619
23639
|
};
|
|
23620
23640
|
this.on("connection:status", handler);
|
|
@@ -23628,6 +23648,7 @@ var DoraCell = class {
|
|
|
23628
23648
|
this.emitConnectionStatus();
|
|
23629
23649
|
if (this.ua) {
|
|
23630
23650
|
try {
|
|
23651
|
+
this.ua.removeAllListeners();
|
|
23631
23652
|
this.ua.stop();
|
|
23632
23653
|
} catch (e) {
|
|
23633
23654
|
}
|
|
@@ -23659,7 +23680,8 @@ var DoraCell = class {
|
|
|
23659
23680
|
}
|
|
23660
23681
|
} catch (error) {
|
|
23661
23682
|
throw new ConnectionError(
|
|
23662
|
-
|
|
23683
|
+
error instanceof Error ? error.message : "Failed to initialize User Agent",
|
|
23684
|
+
{ originalError: error }
|
|
23663
23685
|
);
|
|
23664
23686
|
}
|
|
23665
23687
|
}
|
|
@@ -23669,9 +23691,25 @@ var DoraCell = class {
|
|
|
23669
23691
|
this.connectionStatus = "connected";
|
|
23670
23692
|
this.emitConnectionStatus();
|
|
23671
23693
|
});
|
|
23672
|
-
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
|
+
}
|
|
23673
23698
|
this.connectionStatus = "disconnected";
|
|
23674
|
-
|
|
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
|
+
}
|
|
23675
23713
|
});
|
|
23676
23714
|
this.ua.on("registered", () => {
|
|
23677
23715
|
this.connectionStatus = "registered";
|
|
@@ -23680,8 +23718,15 @@ var DoraCell = class {
|
|
|
23680
23718
|
this.emitConnectionStatus();
|
|
23681
23719
|
});
|
|
23682
23720
|
this.ua.on("registrationFailed", (e) => {
|
|
23721
|
+
if (this.config.debug) {
|
|
23722
|
+
console.error("Dora Cell SDK: Registration failed:", e);
|
|
23723
|
+
}
|
|
23683
23724
|
this.connectionStatus = "registrationFailed";
|
|
23684
|
-
|
|
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);
|
|
23685
23730
|
if (this.retryCount < this.maxRetries) {
|
|
23686
23731
|
this.retryCount++;
|
|
23687
23732
|
setTimeout(() => {
|
|
@@ -23819,7 +23864,7 @@ var DoraCell = class {
|
|
|
23819
23864
|
this.credentials.sipUri = `sip:${extension}@${domain}`;
|
|
23820
23865
|
await this.initializeUserAgent();
|
|
23821
23866
|
await this.waitForRegistration();
|
|
23822
|
-
this.emitConnectionStatus(
|
|
23867
|
+
this.emitConnectionStatus();
|
|
23823
23868
|
}
|
|
23824
23869
|
}
|
|
23825
23870
|
/**
|
|
@@ -23868,14 +23913,9 @@ var DoraCell = class {
|
|
|
23868
23913
|
this.events.emit("error", error);
|
|
23869
23914
|
}
|
|
23870
23915
|
getDefaultTurnServers() {
|
|
23871
|
-
|
|
23872
|
-
|
|
23873
|
-
|
|
23874
|
-
if (typeof process !== "undefined" && process.env) {
|
|
23875
|
-
turnUri = turnUri;
|
|
23876
|
-
turnUser = turnUser;
|
|
23877
|
-
turnPass = turnPass;
|
|
23878
|
-
}
|
|
23916
|
+
const turnUri = "turn:64.227.10.164:3478";
|
|
23917
|
+
const turnUser = "02018890089";
|
|
23918
|
+
const turnPass = "dora12345";
|
|
23879
23919
|
return [
|
|
23880
23920
|
{
|
|
23881
23921
|
urls: turnUri,
|
|
@@ -23917,9 +23957,6 @@ var DoraCell = class {
|
|
|
23917
23957
|
return "https://api.cell.usedora.com/api";
|
|
23918
23958
|
}
|
|
23919
23959
|
}
|
|
23920
|
-
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_BASE_API_URL) {
|
|
23921
|
-
return process.env.NEXT_PUBLIC_BASE_API_URL;
|
|
23922
|
-
}
|
|
23923
23960
|
return "https://api.cell.usedora.com/api";
|
|
23924
23961
|
}
|
|
23925
23962
|
};
|