@ateam-ai-mobile/core 0.1.25 → 0.1.27
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 +10 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/acs/ws.ts +2 -3
- package/src/chat/store.ts +2 -3
- package/src/config.ts +15 -0
package/dist/index.js
CHANGED
|
@@ -151,6 +151,14 @@ function getCoreApiUrl() {
|
|
|
151
151
|
function getCoreWsUrl() {
|
|
152
152
|
return getCoreApiUrl().replace(/^http/, "ws");
|
|
153
153
|
}
|
|
154
|
+
var CORE_WS_PROTOCOL = "adas.v1";
|
|
155
|
+
var CORE_WS_BEARER_PREFIX = "adas.bearer.";
|
|
156
|
+
function openCoreWs(tenant, token) {
|
|
157
|
+
const url = `${getCoreWsUrl()}/ws?tenant=${encodeURIComponent(tenant)}`;
|
|
158
|
+
const protocols = [CORE_WS_PROTOCOL];
|
|
159
|
+
if (token) protocols.push(CORE_WS_BEARER_PREFIX + token);
|
|
160
|
+
return new WebSocket(url, protocols);
|
|
161
|
+
}
|
|
154
162
|
function getVoiceApiUrl() {
|
|
155
163
|
const url = getConfig().voiceUrl;
|
|
156
164
|
if (!url) throw new Error("[adas] voiceUrl not configured");
|
|
@@ -1087,9 +1095,8 @@ function handleEvent(msg) {
|
|
|
1087
1095
|
function openSocket() {
|
|
1088
1096
|
if (_ws) return;
|
|
1089
1097
|
if (!_token || !_tenant) return;
|
|
1090
|
-
const url = `${getCoreWsUrl()}/ws?token=${encodeURIComponent(_token)}&tenant=${encodeURIComponent(_tenant)}`;
|
|
1091
1098
|
console.log(`[acsWs] opening`);
|
|
1092
|
-
const ws =
|
|
1099
|
+
const ws = openCoreWs(_tenant, _token);
|
|
1093
1100
|
_ws = ws;
|
|
1094
1101
|
const isCurrent = () => ws === _ws;
|
|
1095
1102
|
ws.onopen = () => {
|
|
@@ -1949,8 +1956,7 @@ function setClientDeclarationProvider(fn) {
|
|
|
1949
1956
|
var _currentJobId = null;
|
|
1950
1957
|
function ensureWs(tenant, token) {
|
|
1951
1958
|
if (_ws2 && _wsReady) return _ws2;
|
|
1952
|
-
const
|
|
1953
|
-
const ws = new WebSocket(wsUrl);
|
|
1959
|
+
const ws = openCoreWs(tenant, token);
|
|
1954
1960
|
_ws2 = ws;
|
|
1955
1961
|
_wsReady = false;
|
|
1956
1962
|
ws.onopen = () => {
|