You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@signalwire/realtime-api

Package Overview
Dependencies
Maintainers
4
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@signalwire/realtime-api - npm Package Compare versions

Comparing version

to
3.0.0-beta.9

dist/core/src/types/messaging.d.ts

2

dist/core/src/index.d.ts

@@ -17,3 +17,3 @@ import { uuid, setLogger, getLogger, isGlobalEvent, toExternalJSON, toLocalEvent, toSyntheticEvent, extendComponent, validateEventsToSubscribe, toInternalEventName, serializeableProxy, timeoutPromise } from './utils';

export * from './CustomErrors';
export type { SessionState, CustomSagaParams, CustomSaga, PubSubChannel, MapToPubSubShape, } from './redux/interfaces';
export type { SessionState, CustomSagaParams, CustomSaga, PubSubChannel, MapToPubSubShape, SDKActions, } from './redux/interfaces';
export * as actions from './redux/actions';

@@ -20,0 +20,0 @@ export * as sagaHelpers from './redux/utils/sagaHelpers';

@@ -8,3 +8,3 @@ import { sagaEffects, SDKWorker, SDKWorkerParams, VideoMemberUpdatedEventParams } from '..';

payload: Error | undefined;
} | import("..").MapToPubSubShape<import("..").ChatChannelMessageEvent> | import("..").MapToPubSubShape<import("..").ChatMemberJoinedEvent> | import("..").MapToPubSubShape<import("..").ChatMemberUpdatedEvent> | import("..").MapToPubSubShape<import("..").ChatMemberLeftEvent>>, void, unknown>;
} | import("..").MapToPubSubShape<import("..").ChatChannelMessageEvent> | import("..").MapToPubSubShape<import("..").ChatMemberJoinedEvent> | import("..").MapToPubSubShape<import("..").ChatMemberUpdatedEvent> | import("..").MapToPubSubShape<import("..").ChatMemberLeftEvent> | import("..").TaskAction | import("..").MapToPubSubShape<import("..").MessagingStateEvent> | import("..").MapToPubSubShape<import("..").MessageUpdatedEvent> | import("..").MapToPubSubShape<import("..").MessagingReceiveEvent> | import("..").MapToPubSubShape<import("..").MessageReceivedEvent> | import("..").MapToPubSubShape<import("..").VoiceCallCreatedEvent> | import("..").MapToPubSubShape<import("..").VoiceCallEndedEvent>>, void, unknown>;
export declare const MEMBER_POSITION_COMPOUND_EVENTS: Map<any, any>;

@@ -11,0 +11,0 @@ export declare const memberPositionWorker: SDKWorker<any>;

import type { SagaIterator } from '@redux-saga/types';
import type { PayloadAction } from './toolkit';
import { JSONRPCResponse, SessionAuthError, SessionAuthStatus, SessionEvents, JSONRPCMethod, BaseConnectionState } from '../utils/interfaces';
import type { VideoAPIEventParams, InternalVideoAPIEvent, ChatAction, SwEventParams } from '../types';
import type { VideoAPIEventParams, InternalVideoAPIEvent, ChatAction, TaskAction, MessagingAction, SwEventParams, VoiceCallAction } from '../types';
import { SDKRunSaga } from '.';
import { MulticastChannel } from '@redux-saga/core';
import { END, MulticastChannel } from '@redux-saga/core';
interface SWComponent {

@@ -76,6 +76,7 @@ id: string;

payload: Error | undefined;
} | ChatAction;
} | ChatAction | TaskAction | MessagingAction | VoiceCallAction;
export declare type PubSubChannel = MulticastChannel<PubSubAction>;
export declare type SwEventChannel = MulticastChannel<MapToPubSubShape<SwEventParams>>;
export declare type SDKActions = MapToPubSubShape<SwEventParams> | END;
export {};
//# sourceMappingURL=interfaces.d.ts.map

@@ -24,3 +24,3 @@ import type { Task, SagaIterator } from '@redux-saga/types';

payload: Error | undefined;
} | import("./interfaces").MapToPubSubShape<import("..").ChatChannelMessageEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberJoinedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberUpdatedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberLeftEvent>> | import("@redux-saga/core/effects").CallEffect<true> | import("@redux-saga/core/effects").CallEffect<void>, void, unknown>;
} | import("./interfaces").MapToPubSubShape<import("..").ChatChannelMessageEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberJoinedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberUpdatedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberLeftEvent> | import("..").TaskAction | import("./interfaces").MapToPubSubShape<import("..").MessagingStateEvent> | import("./interfaces").MapToPubSubShape<import("..").MessageUpdatedEvent> | import("./interfaces").MapToPubSubShape<import("..").MessagingReceiveEvent> | import("./interfaces").MapToPubSubShape<import("..").MessageReceivedEvent> | import("./interfaces").MapToPubSubShape<import("..").VoiceCallCreatedEvent> | import("./interfaces").MapToPubSubShape<import("..").VoiceCallEndedEvent>> | import("@redux-saga/core/effects").CallEffect<true> | import("@redux-saga/core/effects").CallEffect<void>, void, unknown>;
export declare function reauthenticateWorker({ session, token, pubSubChannel, }: {

@@ -33,3 +33,3 @@ session: BaseSession;

payload: Error | undefined;
} | import("./interfaces").MapToPubSubShape<import("..").ChatChannelMessageEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberJoinedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberUpdatedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberLeftEvent>> | import("@redux-saga/core/effects").CallEffect<void> | import("@redux-saga/core/effects").PutEffect<{
} | import("./interfaces").MapToPubSubShape<import("..").ChatChannelMessageEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberJoinedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberUpdatedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberLeftEvent> | import("..").TaskAction | import("./interfaces").MapToPubSubShape<import("..").MessagingStateEvent> | import("./interfaces").MapToPubSubShape<import("..").MessageUpdatedEvent> | import("./interfaces").MapToPubSubShape<import("..").MessagingReceiveEvent> | import("./interfaces").MapToPubSubShape<import("..").MessageReceivedEvent> | import("./interfaces").MapToPubSubShape<import("..").VoiceCallCreatedEvent> | import("./interfaces").MapToPubSubShape<import("..").VoiceCallEndedEvent>> | import("@redux-saga/core/effects").CallEffect<void> | import("@redux-saga/core/effects").PutEffect<{
payload: {

@@ -50,3 +50,3 @@ error: import("../utils/interfaces").SessionAuthError;

payload: Error | undefined;
} | import("./interfaces").MapToPubSubShape<import("..").ChatChannelMessageEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberJoinedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberUpdatedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberLeftEvent>>, void, Task>;
} | import("./interfaces").MapToPubSubShape<import("..").ChatChannelMessageEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberJoinedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberUpdatedEvent> | import("./interfaces").MapToPubSubShape<import("..").ChatMemberLeftEvent> | import("..").TaskAction | import("./interfaces").MapToPubSubShape<import("..").MessagingStateEvent> | import("./interfaces").MapToPubSubShape<import("..").MessageUpdatedEvent> | import("./interfaces").MapToPubSubShape<import("..").MessagingReceiveEvent> | import("./interfaces").MapToPubSubShape<import("..").MessageReceivedEvent> | import("./interfaces").MapToPubSubShape<import("..").VoiceCallCreatedEvent> | import("./interfaces").MapToPubSubShape<import("..").VoiceCallEndedEvent>>, void, Task>;
interface RootSagaOptions {

@@ -53,0 +53,0 @@ SessionConstructor: SessionConstructor;

@@ -6,2 +6,4 @@ import type { EventEmitter } from '../utils/EventEmitter';

import type { ChatEvent } from './chat';
import type { TaskEvent } from './task';
import type { MessagingEvent } from './messaging';
export interface SwEvent {

@@ -79,3 +81,3 @@ event_channel: string;

}
export declare type SwEventParams = VideoAPIEventParams | WebRTCMessageParams | CantinaEvent | ChatEvent;
export declare type SwEventParams = VideoAPIEventParams | WebRTCMessageParams | CantinaEvent | ChatEvent | TaskEvent | MessagingEvent;
export declare type PubSubChannelEvents = InternalVideoEventNames | SessionEvents;

@@ -86,2 +88,5 @@ export * from './video';

export * from './chat';
export * from './task';
export * from './messaging';
export * from './voice';
//# sourceMappingURL=index.d.ts.map

@@ -21,4 +21,8 @@ export declare const STORAGE_PREFIX = "@signalwire:";

export declare const PRODUCT_PREFIX_CHAT = "chat";
export declare const PRODUCT_PREFIX_TASK = "tasking";
export declare const PRODUCT_PREFIX_MESSAGING = "messaging";
export declare const PRODUCT_PREFIX_VOICE = "voice";
export declare const PRODUCT_PREFIX_VOICE_CALL = "calling";
export declare const GLOBAL_VIDEO_EVENTS: readonly ["room.started", "room.ended"];
export declare const PRODUCT_PREFIXES: readonly ["video", "cantina-manager", "chat"];
export declare const PRODUCT_PREFIXES: readonly ["video", "cantina-manager", "chat", "tasking", "messaging", "voice", "calling"];
/**

@@ -25,0 +29,0 @@ * For internal usage only. These are the fully qualified event names

@@ -9,3 +9,3 @@ /// <reference types="node" />

import type { URL as NodeURL } from 'node:url';
import { ChatJSONRPCMethod, ChatTransformType } from '..';
import { ChatJSONRPCMethod, ChatTransformType, MessagingJSONRPCMethod, MessagingTransformType, VoiceJSONRPCMethod } from '..';
declare type JSONRPCParams = Record<string, any>;

@@ -15,3 +15,3 @@ declare type JSONRPCResult = Record<string, any>;

export declare type VertoMethod = 'verto.invite' | 'verto.attach' | 'verto.answer' | 'verto.info' | 'verto.display' | 'verto.media' | 'verto.event' | 'verto.bye' | 'verto.punt' | 'verto.broadcast' | 'verto.subscribe' | 'verto.unsubscribe' | 'verto.clientReady' | 'verto.modify' | 'verto.mediaParams' | 'verto.prompt' | 'jsapi' | 'verto.stats' | 'verto.ping' | 'verto.announce';
export declare type JSONRPCMethod = 'signalwire.connect' | 'signalwire.ping' | 'signalwire.disconnect' | 'signalwire.event' | 'signalwire.reauthenticate' | 'signalwire.subscribe' | 'video.message' | RoomMethod | VertoMethod | ChatJSONRPCMethod;
export declare type JSONRPCMethod = 'signalwire.connect' | 'signalwire.ping' | 'signalwire.disconnect' | 'signalwire.event' | 'signalwire.reauthenticate' | 'signalwire.subscribe' | 'video.message' | RoomMethod | VertoMethod | ChatJSONRPCMethod | MessagingJSONRPCMethod | VoiceJSONRPCMethod;
export declare type JSONRPCSubscribeMethod = Extract<JSONRPCMethod, 'signalwire.subscribe' | 'chat.subscribe'>;

@@ -41,2 +41,4 @@ export interface JSONRPCRequest {

token: string;
/** SignalWire contexts, e.g. 'home', 'office'.. */
contexts?: string[];
/** logging level */

@@ -181,3 +183,3 @@ logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent';

*/
export declare type EventTransformType = 'roomSession' | 'roomSessionSubscribed' | 'roomSessionMember' | 'roomSessionLayout' | 'roomSessionRecording' | 'roomSessionPlayback' | ChatTransformType;
export declare type EventTransformType = 'roomSession' | 'roomSessionSubscribed' | 'roomSessionMember' | 'roomSessionLayout' | 'roomSessionRecording' | 'roomSessionPlayback' | ChatTransformType | MessagingTransformType;
/**

@@ -184,0 +186,0 @@ * `EventTransform`s represent our internal pipeline for

import { MapToPubSubShape } from '../redux/interfaces';
export declare const toInternalAction: <T extends {
event_type: unknown;
params: unknown;
params?: unknown;
}>(event: T) => MapToPubSubShape<T>;
//# sourceMappingURL=toInternalAction.d.ts.map

@@ -86,3 +86,6 @@ var __create = Object.create;

Chat: () => Chat_exports,
Messaging: () => Messaging_exports,
Task: () => Task_exports,
Video: () => Video_exports,
Voice: () => Voice_exports,
config: () => config,

@@ -463,3 +466,3 @@ createClient: () => createClient2,

__publicField(this, "WebSocketConstructor", import_ws.default);
__publicField(this, "agent", "@signalwire/realtime-api/3.0.0-beta.8");
__publicField(this, "agent", "@signalwire/realtime-api/3.0.0-beta.9");
}

@@ -817,2 +820,520 @@ };

};
// src/task/Task.ts
var Task_exports = {};
__export(Task_exports, {
Client: () => TaskClient,
createTaskObject: () => createTaskObject,
send: () => send
});
var import_core17 = require("@signalwire/core");
// src/task/workers.ts
var import_core16 = require("@signalwire/core");
var taskWorker = function* (options) {
const { channels } = options;
const { swEventChannel, pubSubChannel } = channels;
const action = yield import_core16.sagaEffects.take(swEventChannel, (action2) => {
return action2.type === "queuing.relay.tasks";
});
yield import_core16.sagaEffects.put(pubSubChannel, {
type: "task.received",
payload: action.payload.message
});
};
// src/task/TaskClient.ts
var TaskClient = function(options) {
const { client, store, emitter } = setupClient(options);
const task = createTaskObject({
store,
emitter
});
const taskOn = (...args) => {
clientConnect(client);
return task.on(...args);
};
const taskOnce = (...args) => {
clientConnect(client);
return task.once(...args);
};
const interceptors = {
on: taskOn,
once: taskOnce,
_session: client
};
return new Proxy(task, {
get(target, prop, receiver) {
if (prop in interceptors) {
return interceptors[prop];
}
return Reflect.get(target, prop, receiver);
}
});
};
// src/task/send.ts
var import_node_https = require("https");
var PATH = "/api/relay/rest/tasks";
var HOST = "relay.signalwire.com";
var send = ({
host = HOST,
project,
token,
context,
message
}) => {
if (!project || !token) {
throw new Error("Invalid options: project and token are required!");
}
return new Promise((resolve, reject) => {
try {
const Authorization = `Basic ${Buffer.from(`${project}:${token}`).toString("base64")}`;
const data = JSON.stringify({ context, message });
const options = {
host,
port: 443,
method: "POST",
path: PATH,
headers: {
Authorization,
"Content-Type": "application/json",
"Content-Length": data.length
}
};
const req = (0, import_node_https.request)(options, ({ statusCode }) => {
statusCode === 204 ? resolve() : reject();
});
req.on("error", reject);
req.write(data);
req.end();
} catch (error) {
reject(error);
}
});
};
// src/task/Task.ts
var TaskAPI = class extends import_core17.BaseConsumer {
constructor(options) {
super(options);
this.setWorker("taskWorker", {
worker: taskWorker
});
this.attachWorkers();
this._attachListeners("");
}
};
var createTaskObject = (params) => {
const task = (0, import_core17.connect)({
store: params.store,
Component: TaskAPI,
componentListeners: {
errors: "onError",
responses: "onSuccess"
}
})(params);
return task;
};
// src/messaging/Messaging.ts
var Messaging_exports = {};
__export(Messaging_exports, {
Client: () => MessagingClient,
Message: () => Message,
createMessagingObject: () => createMessagingObject
});
var import_core19 = require("@signalwire/core");
var import_core20 = require("@signalwire/core");
// src/messaging/workers.ts
var import_core18 = require("@signalwire/core");
var messagingWorker = function* (options) {
const { channels } = options;
const { swEventChannel, pubSubChannel } = channels;
while (true) {
const action = yield import_core18.sagaEffects.take(swEventChannel, (action2) => {
return action2.type.startsWith("messaging.");
});
(0, import_core18.getLogger)().debug("messagingWorker:", action);
switch (action.type) {
case "messaging.receive": {
yield import_core18.sagaEffects.put(pubSubChannel, {
type: "message.received",
payload: action.payload
});
break;
}
case "messaging.state": {
yield import_core18.sagaEffects.put(pubSubChannel, {
type: "message.updated",
payload: action.payload
});
break;
}
default: {
(0, import_core18.getLogger)().warn("[messagingWorker] Unrecognized Action", action);
break;
}
}
}
};
// src/messaging/Message.ts
var Message = class {
constructor(options) {
__publicField(this, "id");
__publicField(this, "state");
__publicField(this, "context");
__publicField(this, "from");
__publicField(this, "to");
__publicField(this, "body");
__publicField(this, "direction");
__publicField(this, "media");
__publicField(this, "segments");
__publicField(this, "tags");
__publicField(this, "reason");
this.id = options.message_id;
this.state = options.message_state;
this.context = options.context;
this.from = options.from_number;
this.to = options.to_number;
this.body = options.body;
this.direction = options.direction;
this.media = options.media || [];
this.segments = options.segments;
this.tags = options.tags || [];
this.reason = options.reason;
}
};
// src/messaging/MessagingClient.ts
var MessagingClient = function(options) {
const { client, store, emitter } = setupClient(options);
const messaging = createMessagingObject({
store,
emitter
});
client.once("session.connected", () => {
messaging.applyEmitterTransforms();
});
const messagingOn = (...args) => {
clientConnect(client);
return messaging.on(...args);
};
const messagingOnce = (...args) => {
clientConnect(client);
return messaging.once(...args);
};
const send2 = (...args) => __async(this, null, function* () {
yield clientConnect(client);
return messaging.send(...args);
});
const interceptors = {
on: messagingOn,
once: messagingOnce,
send: send2,
_session: client
};
return new Proxy(messaging, {
get(target, prop, receiver) {
if (prop in interceptors) {
return interceptors[prop];
}
return Reflect.get(target, prop, receiver);
}
});
};
// src/messaging/Messaging.ts
var MessagingAPI = class extends import_core20.BaseConsumer {
constructor(options) {
super(options);
this.setWorker("messagingWorker", {
worker: messagingWorker
});
this.attachWorkers();
this._attachListeners("");
}
getEmitterTransforms() {
return /* @__PURE__ */ new Map([
[
[
"messaging.state",
"messaging.receive",
"message.updated",
"message.received"
],
{
type: "messagingMessage",
instanceFactory: (payload) => {
return new Message(payload);
},
payloadTransform: (payload) => {
const _a = payload, {
message_id,
message_state,
from_number,
to_number,
tag
} = _a, rest = __objRest(_a, [
"message_id",
"message_state",
"from_number",
"to_number",
"tag"
]);
return (0, import_core19.toExternalJSON)(__spreadProps(__spreadValues({}, rest), {
id: message_id,
state: message_state,
from: from_number,
to: to_number
}));
}
}
]
]);
}
send(params) {
return __async(this, null, function* () {
const _a = params, { from = "", to = "" } = _a, rest = __objRest(_a, ["from", "to"]);
const sendParams = __spreadProps(__spreadValues({}, rest), {
from_number: from,
to_number: to
});
try {
const response = yield this.execute({
method: "messaging.send",
params: sendParams
});
return (0, import_core19.toExternalJSON)(response);
} catch (error) {
this.logger.error("Error sending message", error.jsonrpc);
throw error.jsonrpc;
}
});
}
};
var createMessagingObject = (params) => {
const messaging = (0, import_core20.connect)({
store: params.store,
Component: MessagingAPI,
componentListeners: {
errors: "onError",
responses: "onSuccess"
}
})(params);
return messaging;
};
// src/voice/Voice.ts
var Voice_exports = {};
__export(Voice_exports, {
Client: () => CallClient
});
// src/voice/CallClient.ts
var import_core24 = require("@signalwire/core");
// src/voice/Call.ts
var import_core23 = require("@signalwire/core");
// src/AutoSubscribeConsumer.ts
var import_core21 = require("@signalwire/core");
var AutoSubscribeConsumer = class extends import_core21.BaseConsumer {
constructor(options) {
super(options);
__publicField(this, "debouncedSubscribe");
this.debouncedSubscribe = debounce(this.subscribe, 100);
}
on(event, fn) {
const instance = super.on(event, fn);
this.debouncedSubscribe();
return instance;
}
once(event, fn) {
const instance = super.once(event, fn);
this.debouncedSubscribe();
return instance;
}
};
// src/voice/utils.ts
var toInternalDevice = (device) => {
switch (device.type) {
case "sip":
case "phone": {
const _a = device, { to, from, type } = _a, rest = __objRest(_a, ["to", "from", "type"]);
return {
type,
params: __spreadProps(__spreadValues({}, rest), {
to_number: to,
from_number: from
})
};
}
}
return device;
};
var toInternalDevices = (params, internalDevices = []) => {
params.forEach((dev, index) => {
if (Array.isArray(dev)) {
internalDevices[index] = toInternalDevices(dev);
} else {
internalDevices[index] = toInternalDevice(dev);
}
});
return internalDevices;
};
// src/voice/workers.ts
var import_core22 = require("@signalwire/core");
var SYNTHETIC_CALL_STATE_ANSWERED_EVENT = (0, import_core22.toSyntheticEvent)("calling.call.answered");
var SYNTHETIC_CALL_STATE_FAILED_EVENT = (0, import_core22.toSyntheticEvent)("calling.call.failed");
var SYNTHETIC_CALL_STATE_ENDED_EVENT = (0, import_core22.toSyntheticEvent)("calling.call.ended");
var TARGET_CALL_STATES = ["answered", "failed", "ended"];
var voiceCallStateWorker = function* (options) {
let isDone = false;
while (!isDone) {
const { channels, instance } = options;
const { swEventChannel } = channels;
const action = yield import_core22.sagaEffects.take(swEventChannel, (action2) => {
return action2.type === "calling.call.state" && (0, import_core22.findNamespaceInPayload)(action2) === instance.__uuid && TARGET_CALL_STATES.includes(action2.payload.call_state);
});
if (action.payload.call_state === "answered") {
yield import_core22.sagaEffects.put(channels.pubSubChannel, {
type: SYNTHETIC_CALL_STATE_ANSWERED_EVENT,
payload: action.payload
});
} else if (action.payload.call_state === "failed") {
yield import_core22.sagaEffects.put(channels.pubSubChannel, {
type: SYNTHETIC_CALL_STATE_FAILED_EVENT,
payload: action.payload
});
} else if (action.payload.call_state === "ended") {
isDone = true;
yield import_core22.sagaEffects.put(channels.pubSubChannel, {
type: SYNTHETIC_CALL_STATE_ENDED_EVENT,
payload: action.payload
});
} else {
throw new Error("[voiceCallStateWorker] unhandled call_state");
}
}
};
// src/voice/Call.ts
var CallConsumer = class extends AutoSubscribeConsumer {
constructor(options) {
super(options);
__publicField(this, "_eventsPrefix", "calling");
__publicField(this, "subscribeParams", {
get_initial_state: true
});
__publicField(this, "_callId");
__publicField(this, "_nodeId");
this._attachListeners(this.__uuid);
this.setWorker("voiceCallStateWorker", {
worker: voiceCallStateWorker
});
this.attachWorkers();
}
dial(params) {
return new Promise((resolve, reject) => {
this.once(SYNTHETIC_CALL_STATE_ANSWERED_EVENT, (payload) => {
this._callId = payload.call_id;
this._nodeId = payload.node_id;
resolve(this);
});
this.once(SYNTHETIC_CALL_STATE_FAILED_EVENT, () => {
reject(new Error("Failed to establish the call."));
});
this.execute({
method: "calling.dial",
params: __spreadProps(__spreadValues({}, params), {
tag: this.__uuid,
devices: toInternalDevices(params.devices)
})
}).catch((e) => {
reject(e);
});
});
}
hangup(reason = "hangup") {
return new Promise((resolve, reject) => {
if (!this._callId || !this._nodeId) {
reject(new Error(`Can't call hangup() on a call that hasn't been established.`));
}
this.once(SYNTHETIC_CALL_STATE_ENDED_EVENT, () => {
resolve(void 0);
});
this.execute({
method: "calling.end",
params: {
node_id: this._nodeId,
call_id: this._callId,
reason
}
}).catch((e) => {
reject(e);
});
});
}
};
var CallAPI = (0, import_core23.extendComponent)(CallConsumer, {});
var createCallObject = (params) => {
const call = (0, import_core23.connect)({
store: params.store,
Component: CallAPI,
componentListeners: {
errors: "onError",
responses: "onSuccess"
}
})(params);
return call;
};
// src/voice/CallClient.ts
var CallClient = function(options) {
const { client, store, emitter } = setupClient(options);
const clientOn = (...args) => {
clientConnect(client);
return client.on(...args);
};
const clientOnce = (...args) => {
clientConnect(client);
return client.once(...args);
};
const callDial = (...args) => __async(this, null, function* () {
yield clientConnect(client);
const call = createCallObject({
store,
emitter
});
client.once("session.connected", () => __async(this, null, function* () {
try {
yield call.subscribe();
} catch (e) {
(0, import_core24.getLogger)().error("Client subscription failed.");
client.disconnect();
}
}));
yield call.dial(...args);
return call;
});
const interceptors = {
on: clientOn,
once: clientOnce,
dial: callDial,
_session: client
};
return new Proxy(client, {
get(target, prop, receiver) {
if (prop in interceptors) {
return interceptors[prop];
}
return Reflect.get(target, prop, receiver);
}
});
};
module.exports = __toCommonJS(src_exports);

@@ -822,3 +1343,6 @@ // Annotate the CommonJS export names for ESM import in node:

Chat,
Messaging,
Task,
Video,
Voice,
config,

@@ -825,0 +1349,0 @@ createClient,

@@ -75,2 +75,8 @@ /**

export * from './configure';
/** @ignore */
export * as Task from './task/Task';
/** @ignore */
export * as Messaging from './messaging/Messaging';
/** @ignore */
export * as Voice from './voice/Voice';
//# sourceMappingURL=index.d.ts.map
export * from './video';
export * from './task';
export * from './messaging';
export * from './voice';
//# sourceMappingURL=index.d.ts.map

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "3.0.0-beta.8",
"version": "3.0.0-beta.9",
"main": "dist/index.node.js",

@@ -46,3 +46,3 @@ "beta": true,

"dependencies": {
"@signalwire/core": "3.7.0",
"@signalwire/core": "3.7.1",
"ws": "^8.5.0"

@@ -49,0 +49,0 @@ },

@@ -79,1 +79,10 @@ /**

export * from './configure'
/** @ignore */
export * as Task from './task/Task'
/** @ignore */
export * as Messaging from './messaging/Messaging'
/** @ignore */
export * as Voice from './voice/Voice'
export * from './video'
export * from './task'
export * from './messaging'
export * from './voice'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet