@signalwire/js 3.22.0 → 3.23.0-dev.202307071726.37bfb58.0
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/core/src/RPCMessages/VertoMessages.d.ts +8 -0
- package/dist/core/src/RPCMessages/VertoMessages.d.ts.map +1 -1
- package/dist/index.esm.js +151 -10
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +175 -28
- package/dist/index.js.map +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/js/src/JWTSession.d.ts.map +1 -1
- package/dist/js/src/fabric/HTTPClient.d.ts +24 -0
- package/dist/js/src/fabric/HTTPClient.d.ts.map +1 -0
- package/dist/js/src/fabric/SignalWire.d.ts +19 -0
- package/dist/js/src/fabric/SignalWire.d.ts.map +1 -0
- package/dist/js/src/fabric/WSClient.d.ts +18 -4
- package/dist/js/src/fabric/WSClient.d.ts.map +1 -1
- package/dist/js/src/fabric/index.d.ts +1 -0
- package/dist/js/src/fabric/index.d.ts.map +1 -1
- package/dist/js/src/index.d.ts +2 -2
- package/dist/js/src/index.d.ts.map +1 -1
- package/dist/js/tsconfig.build.tsbuildinfo +1 -1
- package/dist/webrtc/src/BaseConnection.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/fabric/HTTPClient.ts +78 -0
- package/src/fabric/SignalWire.ts +45 -0
- package/src/fabric/WSClient.ts +81 -21
- package/src/fabric/WSClientWorker.ts +1 -1
- package/src/fabric/index.ts +1 -0
- package/src/index.ts +2 -2
|
@@ -50,6 +50,14 @@ export declare const VertoAnswer: (params?: VertoParams) => {
|
|
|
50
50
|
};
|
|
51
51
|
jsonrpc: "2.0";
|
|
52
52
|
};
|
|
53
|
+
export declare const VertoSubscribe: (params?: VertoParams) => {
|
|
54
|
+
id: string;
|
|
55
|
+
method: import("../utils/interfaces").JSONRPCMethod;
|
|
56
|
+
params: {
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
};
|
|
59
|
+
jsonrpc: "2.0";
|
|
60
|
+
};
|
|
53
61
|
export declare const VertoPong: (params?: VertoParams) => {
|
|
54
62
|
id: string;
|
|
55
63
|
method: import("../utils/interfaces").JSONRPCMethod;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VertoMessages.d.ts","sourceRoot":"","sources":["../../../../../core/src/RPCMessages/VertoMessages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,aAAK,WAAW,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AA6CzC,eAAO,MAAM,WAAW,YARN,WAAW;;;;;;;CAQkC,CAAA;AAC/D,eAAO,MAAM,QAAQ,YATH,WAAW;;;;;;;CAS4B,CAAA;AACzD,eAAO,MAAM,WAAW,YAVN,WAAW;;;;;;;CAUkC,CAAA;AAC/D,eAAO,MAAM,WAAW,YAXN,WAAW;;;;;;;CAWkC,CAAA;AAC/D,eAAO,MAAM,SAAS,YAZJ,WAAW;;;;;;;CAY8B,CAAA;AAC3D,eAAO,MAAM,WAAW,YAbN,WAAW;;;;;;;CAakC,CAAA;AAC/D,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"VertoMessages.d.ts","sourceRoot":"","sources":["../../../../../core/src/RPCMessages/VertoMessages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,aAAK,WAAW,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AA6CzC,eAAO,MAAM,WAAW,YARN,WAAW;;;;;;;CAQkC,CAAA;AAC/D,eAAO,MAAM,QAAQ,YATH,WAAW;;;;;;;CAS4B,CAAA;AACzD,eAAO,MAAM,WAAW,YAVN,WAAW;;;;;;;CAUkC,CAAA;AAC/D,eAAO,MAAM,WAAW,YAXN,WAAW;;;;;;;CAWkC,CAAA;AAC/D,eAAO,MAAM,SAAS,YAZJ,WAAW;;;;;;;CAY8B,CAAA;AAC3D,eAAO,MAAM,WAAW,YAbN,WAAW;;;;;;;CAakC,CAAA;AAC/D,eAAO,MAAM,cAAc,YAdT,WAAW;;;;;;;CAcwC,CAAA;AACrE,eAAO,MAAM,SAAS,YAfJ,WAAW;;;;;;;CAe8B,CAAA;AAC3D,eAAO,MAAM,WAAW,OAAQ,MAAM,UAAU,WAAW;;;;;;CAO1D,CAAA"}
|
package/dist/index.esm.js
CHANGED
|
@@ -43,6 +43,7 @@ var fabric_exports = {};
|
|
|
43
43
|
__export(fabric_exports, {
|
|
44
44
|
Client: () => Client2,
|
|
45
45
|
SWClient: () => SWClient,
|
|
46
|
+
SignalWire: () => SignalWire,
|
|
46
47
|
WSClient: () => WSClient
|
|
47
48
|
});
|
|
48
49
|
|
|
@@ -1601,7 +1602,7 @@ var JWTSession = class extends BaseJWTSession {
|
|
|
1601
1602
|
this.options = options;
|
|
1602
1603
|
__publicField(this, "WebSocketConstructor", WebSocket);
|
|
1603
1604
|
__publicField(this, "CloseEventConstructor", SwCloseEvent);
|
|
1604
|
-
__publicField(this, "agent", "@signalwire/js/browser/3.
|
|
1605
|
+
__publicField(this, "agent", "@signalwire/js/browser/3.23.0-dev.202307071726.37bfb58.0");
|
|
1605
1606
|
__publicField(this, "tokenTyp");
|
|
1606
1607
|
this.tokenTyp = (_a = decodedJwt.typ) != null ? _a : "VRT";
|
|
1607
1608
|
}
|
|
@@ -2202,6 +2203,9 @@ var SWClient = class {
|
|
|
2202
2203
|
}
|
|
2203
2204
|
};
|
|
2204
2205
|
|
|
2206
|
+
// src/fabric/WSClient.ts
|
|
2207
|
+
import { getLogger as getLogger11, VertoSubscribe } from "@signalwire/core";
|
|
2208
|
+
|
|
2205
2209
|
// src/fabric/WSClientWorker.ts
|
|
2206
2210
|
import {
|
|
2207
2211
|
getLogger as getLogger10,
|
|
@@ -2226,7 +2230,6 @@ var WSClientWorker = function* (options) {
|
|
|
2226
2230
|
};
|
|
2227
2231
|
|
|
2228
2232
|
// src/fabric/WSClient.ts
|
|
2229
|
-
import { getLogger as getLogger11 } from "@signalwire/core";
|
|
2230
2233
|
var WSClient = class {
|
|
2231
2234
|
constructor(options) {
|
|
2232
2235
|
this.options = options;
|
|
@@ -2281,11 +2284,42 @@ var WSClient = class {
|
|
|
2281
2284
|
}
|
|
2282
2285
|
});
|
|
2283
2286
|
}
|
|
2284
|
-
|
|
2287
|
+
handlePushNotification(payload) {
|
|
2285
2288
|
return new Promise(async (resolve, reject) => {
|
|
2289
|
+
const { decrypted, type } = payload;
|
|
2290
|
+
if (type !== "call_invite") {
|
|
2291
|
+
this.logger.warn("Unknown notification type", payload);
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2294
|
+
this.logger.debug("handlePushNotification", payload);
|
|
2295
|
+
const { params: jsonrpc, node_id: nodeId } = decrypted;
|
|
2296
|
+
const {
|
|
2297
|
+
params: {
|
|
2298
|
+
callID,
|
|
2299
|
+
sdp,
|
|
2300
|
+
caller_id_name,
|
|
2301
|
+
caller_id_number,
|
|
2302
|
+
callee_id_name,
|
|
2303
|
+
callee_id_number,
|
|
2304
|
+
display_direction
|
|
2305
|
+
}
|
|
2306
|
+
} = jsonrpc;
|
|
2307
|
+
this.logger.debug("handlePushNotification data", {
|
|
2308
|
+
callID,
|
|
2309
|
+
sdp,
|
|
2310
|
+
caller_id_name,
|
|
2311
|
+
caller_id_number,
|
|
2312
|
+
callee_id_name,
|
|
2313
|
+
callee_id_number,
|
|
2314
|
+
display_direction
|
|
2315
|
+
});
|
|
2286
2316
|
try {
|
|
2287
|
-
|
|
2288
|
-
|
|
2317
|
+
await this.connect();
|
|
2318
|
+
try {
|
|
2319
|
+
await this.executeVertoSubscribe(callID, nodeId);
|
|
2320
|
+
} catch (error) {
|
|
2321
|
+
this.logger.warn("Verto Subscribe", error);
|
|
2322
|
+
}
|
|
2289
2323
|
const call = this.wsClient.rooms.makeRoomObject({
|
|
2290
2324
|
negotiateAudio: true,
|
|
2291
2325
|
negotiateVideo: true,
|
|
@@ -2294,22 +2328,128 @@ var WSClient = class {
|
|
|
2294
2328
|
stopCameraWhileMuted: true,
|
|
2295
2329
|
stopMicrophoneWhileMuted: true,
|
|
2296
2330
|
watchMediaPackets: false,
|
|
2297
|
-
remoteSdp:
|
|
2298
|
-
prevCallId:
|
|
2331
|
+
remoteSdp: sdp,
|
|
2332
|
+
prevCallId: callID,
|
|
2299
2333
|
nodeId
|
|
2300
2334
|
});
|
|
2301
2335
|
call.once("destroy", () => {
|
|
2302
2336
|
getLogger11().debug("RTC Connection Destroyed");
|
|
2303
2337
|
});
|
|
2304
2338
|
call.attachPreConnectWorkers();
|
|
2305
|
-
getLogger11().debug("Resolving Call
|
|
2306
|
-
resolve(call);
|
|
2339
|
+
getLogger11().debug("Resolving Call", call);
|
|
2340
|
+
resolve({ resultType: "inboundCall", resultObject: call });
|
|
2307
2341
|
} catch (error) {
|
|
2308
|
-
getLogger11().error("WSClient dial", error);
|
|
2309
2342
|
reject(error);
|
|
2310
2343
|
}
|
|
2311
2344
|
});
|
|
2312
2345
|
}
|
|
2346
|
+
async executeVertoSubscribe(callId, nodeId) {
|
|
2347
|
+
try {
|
|
2348
|
+
return await this.wsClient.execute({
|
|
2349
|
+
method: "webrtc.verto",
|
|
2350
|
+
params: {
|
|
2351
|
+
callID: callId,
|
|
2352
|
+
node_id: nodeId,
|
|
2353
|
+
subscribe: [],
|
|
2354
|
+
message: VertoSubscribe({
|
|
2355
|
+
sessid: callId,
|
|
2356
|
+
eventChannel: []
|
|
2357
|
+
})
|
|
2358
|
+
}
|
|
2359
|
+
});
|
|
2360
|
+
} catch (error) {
|
|
2361
|
+
this.logger.warn("The call is not available anymore", callId);
|
|
2362
|
+
throw error;
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
|
|
2367
|
+
// src/fabric/HTTPClient.ts
|
|
2368
|
+
var HTTPClient = class {
|
|
2369
|
+
constructor(options) {
|
|
2370
|
+
this.options = options;
|
|
2371
|
+
__publicField(this, "httpClient");
|
|
2372
|
+
this.httpClient = createHttpClient({
|
|
2373
|
+
baseUrl: `https://${this.httpHost}`,
|
|
2374
|
+
headers: {
|
|
2375
|
+
Authorization: `Bearer ${this.options.token}`
|
|
2376
|
+
}
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
get httpHost() {
|
|
2380
|
+
const { host } = this.options;
|
|
2381
|
+
if (!host) {
|
|
2382
|
+
return "fabric.signalwire.com";
|
|
2383
|
+
}
|
|
2384
|
+
return `fabric.${host.split(".").splice(1).join(".")}`;
|
|
2385
|
+
}
|
|
2386
|
+
async getAddresses() {
|
|
2387
|
+
const path = "/addresses";
|
|
2388
|
+
const { body } = await this.httpClient(path);
|
|
2389
|
+
const anotherPage = async (url) => {
|
|
2390
|
+
const { search } = new URL(url);
|
|
2391
|
+
const { body: body2 } = await this.httpClient(`${path}${search}`);
|
|
2392
|
+
return buildResult(body2);
|
|
2393
|
+
};
|
|
2394
|
+
const buildResult = (body2) => {
|
|
2395
|
+
return {
|
|
2396
|
+
addresses: body2.data,
|
|
2397
|
+
nextPage: async () => {
|
|
2398
|
+
const { next } = body2.links;
|
|
2399
|
+
return next ? anotherPage(next) : void 0;
|
|
2400
|
+
},
|
|
2401
|
+
prevPage: async () => {
|
|
2402
|
+
const { prev } = body2.links;
|
|
2403
|
+
return prev ? anotherPage(prev) : void 0;
|
|
2404
|
+
}
|
|
2405
|
+
};
|
|
2406
|
+
};
|
|
2407
|
+
return buildResult(body);
|
|
2408
|
+
}
|
|
2409
|
+
async registerDevice({
|
|
2410
|
+
deviceType,
|
|
2411
|
+
deviceToken
|
|
2412
|
+
}) {
|
|
2413
|
+
const path = "/subscriber/devices";
|
|
2414
|
+
const { body } = await this.httpClient(path, {
|
|
2415
|
+
method: "POST",
|
|
2416
|
+
body: {
|
|
2417
|
+
device_type: deviceType,
|
|
2418
|
+
device_token: deviceToken
|
|
2419
|
+
}
|
|
2420
|
+
});
|
|
2421
|
+
return body;
|
|
2422
|
+
}
|
|
2423
|
+
async unregisterDevice({ id }) {
|
|
2424
|
+
const path = `/subscriber/devices/${id}`;
|
|
2425
|
+
return await this.httpClient(path, {
|
|
2426
|
+
method: "DELETE"
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
};
|
|
2430
|
+
|
|
2431
|
+
// src/fabric/SignalWire.ts
|
|
2432
|
+
var SignalWire = (options) => {
|
|
2433
|
+
return new Promise(async (resolve, reject) => {
|
|
2434
|
+
try {
|
|
2435
|
+
const httpClient = new HTTPClient(options);
|
|
2436
|
+
const wsClient = new WSClient(options);
|
|
2437
|
+
resolve({
|
|
2438
|
+
httpHost: httpClient.httpHost,
|
|
2439
|
+
getAddresses: httpClient.getAddresses.bind(httpClient),
|
|
2440
|
+
registerDevice: httpClient.registerDevice.bind(httpClient),
|
|
2441
|
+
unregisterDevice: httpClient.unregisterDevice.bind(httpClient),
|
|
2442
|
+
connect: wsClient.connect.bind(wsClient),
|
|
2443
|
+
disconnect: wsClient.disconnect.bind(wsClient),
|
|
2444
|
+
dial: wsClient.dial.bind(wsClient),
|
|
2445
|
+
handlePushNotification: wsClient.handlePushNotification.bind(wsClient),
|
|
2446
|
+
__httpClient: httpClient,
|
|
2447
|
+
__wsClient: wsClient
|
|
2448
|
+
});
|
|
2449
|
+
} catch (error) {
|
|
2450
|
+
reject(error);
|
|
2451
|
+
}
|
|
2452
|
+
});
|
|
2313
2453
|
};
|
|
2314
2454
|
|
|
2315
2455
|
// src/chat/index.ts
|
|
@@ -2477,6 +2617,7 @@ export {
|
|
|
2477
2617
|
fabric_exports as Fabric,
|
|
2478
2618
|
pubSub_exports as PubSub,
|
|
2479
2619
|
SWClient,
|
|
2620
|
+
SignalWire,
|
|
2480
2621
|
video_exports as Video,
|
|
2481
2622
|
webrtc_exports as WebRTC
|
|
2482
2623
|
};
|