Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@signalwire/core

Package Overview
Dependencies
Maintainers
5
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@signalwire/core - npm Package Compare versions

Comparing version 4.0.0-dev.202404041241.3a37e0a.1 to 4.0.0

3

dist/core/src/BaseComponent.d.ts

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

sessionEmitter: EventEmitter<import("./utils/interfaces").ClientEvents, any>;
unifiedEventing: boolean | undefined;
dispatch: import("redux").Dispatch<import("redux").AnyAction>;

@@ -65,4 +64,2 @@ getState(): any;

/** @internal */
get unifiedEventing(): boolean | undefined;
/** @internal */
get emitter(): EventEmitter<EventTypes, any>;

@@ -69,0 +66,0 @@ /** @internal */

import { SWCloseEvent } from './utils';
import { RPCConnectParams } from './RPCMessages';
import { SessionOptions, RPCConnectResult, JSONRPCRequest, JSONRPCResponse, WebSocketAdapter, NodeSocketAdapter, WebSocketClient, SessionStatus, SessionAuthError, InstanceMap } from './utils/interfaces';
import { SessionOptions, RPCConnectResult, JSONRPCRequest, JSONRPCResponse, WebSocketAdapter, NodeSocketAdapter, WebSocketClient, SessionStatus, SessionAuthError } from './utils/interfaces';
import { SwAuthorizationState } from '.';

@@ -21,3 +20,2 @@ import { SessionChannelAction } from './redux/interfaces';

reauthenticate?(): Promise<void>;
unifiedEventing: boolean;
protected _rpcConnectResult: RPCConnectResult;

@@ -32,3 +30,2 @@ private _requests;

private _executeConnectionClosed;
private _instanceMap;
private _checkPingDelay;

@@ -43,3 +40,2 @@ private _checkPingTimer;

constructor(options: SessionOptions);
get instanceMap(): InstanceMap | undefined;
get host(): string;

@@ -83,3 +79,2 @@ get rpcConnectResult(): RPCConnectResult;

execute(msg: JSONRPCRequest | JSONRPCResponse): Promise<any>;
protected get _connectParams(): RPCConnectParams;
/**

@@ -86,0 +81,0 @@ * Authenticate with the SignalWire Network

7

dist/core/src/index.d.ts

@@ -1,2 +0,2 @@

import { uuid, setLogger, getLogger, isGlobalEvent, toExternalJSON, fromSnakeToCamelCase, toSnakeCaseKeys, toLocalEvent, toSyntheticEvent, extendComponent, validateEventsToSubscribe, toInternalEventName, toInternalAction, timeoutPromise, debounce, SWCloseEvent, isSATAuth, LOCAL_EVENT_PREFIX, stripNamespacePrefix, isJSONRPCRequest, isJSONRPCResponse } from './utils';
import { uuid, setLogger, getLogger, isGlobalEvent, toExternalJSON, fromSnakeToCamelCase, toSnakeCaseKeys, toLocalEvent, toSyntheticEvent, extendComponent, validateEventsToSubscribe, toInternalEventName, toInternalAction, timeoutPromise, debounce, SWCloseEvent, isSATAuth, LOCAL_EVENT_PREFIX, stripNamespacePrefix } from './utils';
import { WEBRTC_EVENT_TYPES, isWebrtcEventType } from './utils/common';

@@ -13,3 +13,3 @@ import { BaseSession } from './BaseSession';

import { MEMBER_UPDATED_EVENTS, INTERNAL_MEMBER_UPDATED_EVENTS } from './types/videoMember';
export { uuid, setLogger, getLogger, BaseSession, BaseJWTSession, BaseComponent, BaseConsumer, BaseClient, connect, configureStore, EventEmitter, extendComponent, validateEventsToSubscribe, getEventEmitter, isGlobalEvent, toExternalJSON, fromSnakeToCamelCase, toSnakeCaseKeys, toLocalEvent, toInternalEventName, toInternalAction, toSyntheticEvent, GLOBAL_VIDEO_EVENTS, MEMBER_UPDATED_EVENTS, INTERNAL_MEMBER_UPDATED_EVENTS, findNamespaceInPayload, timeoutPromise, debounce, SWCloseEvent, WEBRTC_EVENT_TYPES, isWebrtcEventType, isSATAuth, isJSONRPCRequest, isJSONRPCResponse, LOCAL_EVENT_PREFIX, stripNamespacePrefix, };
export { uuid, setLogger, getLogger, BaseSession, BaseJWTSession, BaseComponent, BaseConsumer, BaseClient, connect, configureStore, EventEmitter, extendComponent, validateEventsToSubscribe, getEventEmitter, isGlobalEvent, toExternalJSON, fromSnakeToCamelCase, toSnakeCaseKeys, toLocalEvent, toInternalEventName, toInternalAction, toSyntheticEvent, GLOBAL_VIDEO_EVENTS, MEMBER_UPDATED_EVENTS, INTERNAL_MEMBER_UPDATED_EVENTS, findNamespaceInPayload, timeoutPromise, debounce, SWCloseEvent, WEBRTC_EVENT_TYPES, isWebrtcEventType, isSATAuth, LOCAL_EVENT_PREFIX, stripNamespacePrefix, };
export * from './redux/features/component/componentSlice';

@@ -33,3 +33,3 @@ export * from './redux/features/session/sessionSlice';

export * as MemberPosition from './memberPosition';
export type { RoomSessionRecording, RoomSessionPlayback, RoomSessionStream, RoomSessionMember, } from './rooms';
export type { RoomSessionRecording, RoomSessionPlayback, RoomSessionStream, } from './rooms';
export declare const selectors: {

@@ -45,3 +45,2 @@ getIceServers: ({ session }: import("./redux/interfaces").SDKState) => RTCIceServer[];

export * as testUtils from './testUtils';
export * from './utils/mapObject';
//# sourceMappingURL=index.d.ts.map

@@ -25,3 +25,2 @@ import { Saga, Task } from '@redux-saga/core';

sessionEmitter: import("eventemitter3").EventEmitter<import("../utils/interfaces").ClientEvents, any>;
unifiedEventing: boolean | undefined;
dispatch: import("redux").Dispatch<import("redux").AnyAction>;

@@ -28,0 +27,0 @@ getState(): any;

@@ -76,4 +76,2 @@ import type { Channel, SagaIterator } from '@redux-saga/types';

error: SessionAuthError;
}> | PayloadAction<{
token: string;
}> | PayloadAction<SessionAuthStatus>;

@@ -80,0 +78,0 @@ export declare type SwEventChannel = MulticastChannel<MapToPubSubShape<SwEventParams>>;

import { BaseSession } from '../../BaseSession';
import { ClientEvents, InstanceMap, InternalUserOptions, SessionConstructor } from '../../utils/interfaces';
import { ClientEvents, InternalUserOptions, SessionConstructor } from '../../utils/interfaces';
import { SessionChannel } from '../interfaces';

@@ -8,3 +8,2 @@ interface UseSessionOptions {

sessionChannel: SessionChannel;
instanceMap: InstanceMap;
}

@@ -11,0 +10,0 @@ export declare const useSession: (options: UseSessionOptions) => {

@@ -11,3 +11,2 @@ import { BaseComponent, EventEmitter } from '..';

export * from './RoomSessionStream';
export * from './RoomSessionMember';
//# sourceMappingURL=index.d.ts.map

@@ -20,3 +20,2 @@ declare type WithToken = {

topics?: string[];
eventing?: string[];
event_acks?: boolean;

@@ -29,7 +28,2 @@ };

};
export declare const UNIFIED_CONNECT_VERSION: {
major: number;
minor: number;
revision: number;
};
export declare const RPCConnect: (params: RPCConnectParams) => {

@@ -43,11 +37,3 @@ id: string;

};
export declare const RPCConnectUnified: (params: RPCConnectParams) => {
id: string;
method: import("..").JSONRPCMethod;
params: {
[key: string]: any;
};
jsonrpc: "2.0";
};
export {};
//# sourceMappingURL=RPCConnect.d.ts.map

@@ -25,3 +25,2 @@ /// <reference types="jest" />

sessionEmitter: EventEmitter<import(".").ClientEvents, any>;
unifiedEventing: boolean | undefined;
dispatch: import("redux").Dispatch<import("redux").AnyAction>;

@@ -53,3 +52,2 @@ getState(): any;

sessionEmitter: EventEmitter<import(".").ClientEvents, any>;
unifiedEventing: boolean | undefined;
dispatch: import("redux").Dispatch<import("redux").AnyAction>;

@@ -56,0 +54,0 @@ getState(): any;

@@ -1,6 +0,18 @@

export interface PaginatedResponse<T> {
data: Array<T> | [];
export interface FetchAddressResponse {
data: Array<{
display_name: string;
name: string;
preview_url?: string;
cover_url?: string;
resource_id: string;
type: string;
channels: {
audio?: string;
messaging?: string;
video?: string;
};
}> | [];
links: {
first?: string;
self?: string;
first: string;
self: string;
next?: string;

@@ -10,133 +22,6 @@ prev?: string;

}
export interface PaginatedResult<T> {
data: Array<T> | [];
self(): Promise<PaginatedResult<T> | undefined>;
nextPage(): Promise<PaginatedResult<T> | undefined>;
prevPage(): Promise<PaginatedResult<T> | undefined>;
firstPage(): Promise<PaginatedResult<T> | undefined>;
hasNext: boolean;
hasPrev: boolean;
}
/**
* Addresses
*/
export interface Address {
display_name: string;
name: string;
preview_url?: string;
cover_url?: string;
resource_id: string;
type: string;
channels: {
audio?: string;
messaging?: string;
video?: string;
};
}
export interface GetAddressesOptions {
type?: string;
displayName?: string;
pageSize?: number;
}
export interface GetAddressOptions {
id: string;
}
export interface GetAddressResponse extends Address {
}
export interface FetchAddressResponse extends PaginatedResponse<Address> {
}
/**
* Conversations
*/
export interface SendConversationMessageOptions {
text: string;
addressId: string;
metadata?: Record<string, any>;
details?: Record<string, any>;
}
export interface GetConversationsOptions {
pageSize?: number;
}
export interface Conversation {
created_at: number;
id: string;
last_message_at: number;
metadata: Record<string, any>;
name: string;
sendMessage(options: {
text: string;
}): Promise<SendConversationMessageResponse>;
getMessages(options: {
pageSize?: number;
}): Promise<PaginatedResult<ConversationMessage>>;
}
export interface SendConversationMessageResponse {
table: {
conversation_id: string;
text: string;
};
}
export interface FetchConversationsResponse extends PaginatedResponse<Conversation> {
}
/**
* Conversation Messages
*/
export interface GetMessagesOptions {
pageSize?: number;
}
export interface ConversationMessage {
id: string;
conversation_id: string;
user_id: string;
ts: number;
details: Record<string, any>;
type: string;
subtype: string;
kind: string;
}
export interface FetchConversationMessagesResponse extends PaginatedResponse<ConversationMessage> {
}
export interface GetConversationMessagesOptions {
addressId: string;
pageSize?: number;
}
/**
* Subsriber info
*/
export interface SubscriberInfoResponse {
id: string;
email: string;
first_name?: string;
last_name?: string;
display_name?: string;
job_title?: string;
time_zone?: number;
country?: string;
region?: string;
company_name?: string;
push_notification_key: string;
app_settings?: {
display_name: string;
scopes: string[];
};
}
/**
* Device registration
*/
export declare type RegisterDeviceType = 'iOS' | 'Android' | 'Desktop';
export interface RegisterDeviceParams {
deviceType: RegisterDeviceType;
deviceToken: string;
}
export interface UnregisterDeviceParams {
id: string;
}
export interface RegisterDeviceResponse {
date_registered: Date;
device_name?: string;
device_token: string;
device_type: RegisterDeviceType;
id: string;
push_notification_key: string;
}
//# sourceMappingURL=callfabric.d.ts.map

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

import type { VoiceCallEvent } from './voice';
import { ConversationEvent } from '..';
export interface SwEvent {

@@ -144,13 +143,2 @@ event_channel: string;

export interface ClientContract<ClientInstance, EventTypes extends EventEmitter.ValidEventTypes> extends EmitterContract<EventTypes> {
/**
* Connect the underlay WebSocket connection to the SignalWire network.
*
* @returns Promise that will resolve with the Client object.
*
* @example
*
* ```js
* client.connect()
* ```
*/
connect(): Promise<ClientInstance>;

@@ -185,3 +173,3 @@ /**

}
export declare type SwEventParams = VideoAPIEventParams | WebRTCMessageParams | VideoManagerEvent | ChatEvent | TaskEvent | MessagingEvent | VoiceCallEvent | SwAuthorizationStateParams | ConversationEvent;
export declare type SwEventParams = VideoAPIEventParams | WebRTCMessageParams | VideoManagerEvent | ChatEvent | TaskEvent | MessagingEvent | VoiceCallEvent | SwAuthorizationStateParams;
export declare type PubSubChannelEvents = InternalVideoEventNames | SessionEvents;

@@ -198,3 +186,2 @@ export * from './video';

export * from './callfabric';
export * from './conversation';
//# sourceMappingURL=index.d.ts.map

@@ -68,6 +68,3 @@ export declare type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ? `${T extends Capitalize<T> ? '_' : ''}${Lowercase<T>}${CamelToSnakeCase<U>}` : S;

};
export declare type Prettify<T> = {
[K in keyof T]: Prettify<T[K]>;
} & {};
export {};
//# sourceMappingURL=utils.d.ts.map

@@ -275,8 +275,2 @@ import type { SwEvent, VideoPosition } from '.';

};
export interface InternalUnifiedVideoMemberEntity extends InternalVideoMemberEntity {
memberId: string;
callId: string;
nodeId: string;
}
export declare type InternalUnifiedMethodTarget = Pick<InternalUnifiedVideoMemberEntity, 'memberId' | 'callId' | 'nodeId'>;
/**

@@ -283,0 +277,0 @@ * VideoMember entity plus `updated` field

@@ -50,4 +50,2 @@ import type { BaseConnectionContract, SwEvent } from '.';

id: string;
/** Unique id for this room session */
roomSessionId?: string;
/** Display name for this room. Defaults to the value of `name` */

@@ -839,3 +837,2 @@ displayName: string;

member_id: string;
node_id?: string;
}

@@ -842,0 +839,0 @@ export interface VideoRoomSubscribedEvent extends SwEvent {

@@ -15,3 +15,2 @@ import { Authorization, JSONRPCRequest, JSONRPCResponse, SATAuthorization } from '..';

export * from './eventUtils';
export * from './mapObject';
export { LOCAL_EVENT_PREFIX };

@@ -18,0 +17,0 @@ export declare const mutateStorageKey: (key: string) => string;

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

export declare type WebRTCMethod = 'video.message' | 'webrtc.verto';
export declare type SubscriberMethod = 'subscriber.online' | 'subscriber.offline';
export declare type JSONRPCMethod = 'signalwire.connect' | 'signalwire.ping' | 'signalwire.disconnect' | 'signalwire.event' | 'signalwire.reauthenticate' | 'signalwire.subscribe' | 'signalwire.unsubscribe' | SubscriberMethod | WebRTCMethod | RoomMethod | VertoMethod | ChatJSONRPCMethod | MessagingJSONRPCMethod | VoiceJSONRPCMethod | ClientContextMethod;
export declare type JSONRPCMethod = 'signalwire.connect' | 'signalwire.ping' | 'signalwire.disconnect' | 'signalwire.event' | 'signalwire.reauthenticate' | 'signalwire.subscribe' | 'signalwire.unsubscribe' | WebRTCMethod | RoomMethod | VertoMethod | ChatJSONRPCMethod | MessagingJSONRPCMethod | VoiceJSONRPCMethod | ClientContextMethod;
export declare type JSONRPCSubscribeMethod = Extract<JSONRPCMethod, 'signalwire.subscribe' | 'chat.subscribe'>;

@@ -49,8 +48,12 @@ export declare type JSONRPCUnSubscribeMethod = Extract<JSONRPCMethod, 'signalwire.unsubscribe'>;

logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent';
/** The SDK invokes this method and uses the new token to re-auth. */
onRefreshToken?(): Promise<string>;
/** To refresh the auth token */
onRefreshToken?(): Promise<void>;
/**
* The SDK invokes this method and uses the new token to re-auth.
* TODO: rename it: getNewToken, getRefreshedToken, fetchToken (?)
*
* @internal
* */
_onRefreshToken?(): Promise<void>;
sessionChannel?: SessionChannel;
/** Unified eventing is required only with Call Fabric SDK */
unifiedEventing?: boolean;
instanceMap?: InstanceMap;
}

@@ -57,0 +60,0 @@ export interface UserOptions extends SessionOptions {

@@ -6,6 +6,5 @@ {

"license": "MIT",
"version": "4.0.0-dev.202404041241.3a37e0a.1",
"version": "4.0.0",
"main": "dist/index.node.js",
"module": "dist/index.esm.js",
"beta": true,
"files": [

@@ -12,0 +11,0 @@ "dist",

@@ -89,11 +89,6 @@ import type { Task } from '@redux-saga/types'

get instanceMap() {
return this.store.instanceMap
return this.options.store.instanceMap
}
/** @internal */
get unifiedEventing() {
return this.store.unifiedEventing
}
/** @internal */
get emitter() {

@@ -105,3 +100,3 @@ return this.eventEmitter

get sessionEmitter() {
return this.store.sessionEmitter
return this.options.store.sessionEmitter
}

@@ -108,0 +103,0 @@

@@ -9,3 +9,3 @@ import {

import { BaseSession } from './BaseSession'
import { authExpiringAction, reauthAction } from './redux/actions'
import { authExpiringAction } from './redux/actions'
import { type SWCloseEvent, isSATAuth } from './utils'

@@ -68,3 +68,4 @@

const params: RPCConnectParams = {
...this._connectParams,
agent: this.agent,
version: this.connectVersion,
authentication: {

@@ -155,3 +156,4 @@ jwt_token: this.options.token,

}
const refreshTokenFn = this.options.onRefreshToken
const refreshTokenFn =
this.options._onRefreshToken || this.options.onRefreshToken
if (this.expiresIn <= this._refreshTokenNotificationDiff) {

@@ -162,4 +164,3 @@ this.dispatch(authExpiringAction())

try {
const token = await refreshTokenFn()
this.dispatch(reauthAction({ token }))
await refreshTokenFn()
} catch (error) {

@@ -166,0 +167,0 @@ this.logger.error(error)

@@ -9,3 +9,2 @@ import WS from 'jest-websocket-mock'

RPCDisconnectResponse,
RPCConnectUnified,
} from './RPCMessages'

@@ -69,33 +68,2 @@ import { SWCloseEvent } from './utils'

it('should subscribe to unified event when session the initialize with unifiedEventing:true', async () => {
const unifiedEventingSession = new BaseSession({
host,
project,
token,
unifiedEventing: true,
})
const rpcConnectUnified = RPCConnectUnified({
authentication: {
project,
token,
}
})
unifiedEventingSession.WebSocketConstructor = WebSocket
unifiedEventingSession.CloseEventConstructor = SWCloseEvent
unifiedEventingSession.dispatch = jest.fn()
unifiedEventingSession.connect()
await ws.connected
expect(unifiedEventingSession.connected).toBe(true)
await expect(ws).toReceiveMessage(JSON.stringify(rpcConnectUnified))
unifiedEventingSession.disconnect()
expect(unifiedEventingSession.connected).toBe(false)
expect(unifiedEventingSession.closed).toBe(true)
})
it('should connect and disconnect to/from the provided host', async () => {

@@ -102,0 +70,0 @@ session.connect()

@@ -20,3 +20,2 @@ import {

RPCEventAckResponse,
UNIFIED_CONNECT_VERSION,
} from './RPCMessages'

@@ -34,3 +33,2 @@ import {

SessionAuthError,
InstanceMap
} from './utils/interfaces'

@@ -67,5 +65,3 @@ import {

public reauthenticate?(): Promise<void>
public unifiedEventing = false
protected _rpcConnectResult: RPCConnectResult

@@ -82,4 +78,2 @@

private _executeConnectionClosed = Symbol.for('sw-execute-connection-closed')
// FIXME should never be undefined
private _instanceMap:InstanceMap | undefined;

@@ -96,16 +90,3 @@ private _checkPingDelay = 15 * 1000

constructor(public options: SessionOptions) {
const {
host,
logLevel = 'info',
sessionChannel,
unifiedEventing = false,
instanceMap
} = options
this._instanceMap = instanceMap
this.unifiedEventing = unifiedEventing
this.connectVersion = unifiedEventing
? UNIFIED_CONNECT_VERSION
: DEFAULT_CONNECT_VERSION
const { host, logLevel = 'info', sessionChannel } = options
if (host) {

@@ -152,6 +133,2 @@ this._host = checkWebSocketHost(host)

get instanceMap() {
return this._instanceMap
}
get host() {

@@ -371,4 +348,8 @@ return this._host

protected get _connectParams(): RPCConnectParams {
return {
/**
* Authenticate with the SignalWire Network
* @return Promise<void>
*/
async authenticate() {
const params: RPCConnectParams = {
agent: this.agent,

@@ -380,14 +361,3 @@ version: this.connectVersion,

},
// FIXME: Remove this once server is ready
// eventing: this.unifiedEventing ? ['unified'] : undefined,
}
}
/**
* Authenticate with the SignalWire Network
* @return Promise<void>
*/
async authenticate() {
const params: RPCConnectParams = this._connectParams
if (this._relayProtocolIsValid()) {

@@ -394,0 +364,0 @@ params.protocol = this.relayProtocol

@@ -21,4 +21,2 @@ import {

stripNamespacePrefix,
isJSONRPCRequest,
isJSONRPCResponse,
} from './utils'

@@ -74,4 +72,2 @@ import { WEBRTC_EVENT_TYPES, isWebrtcEventType } from './utils/common'

isSATAuth,
isJSONRPCRequest,
isJSONRPCResponse,
LOCAL_EVENT_PREFIX,

@@ -112,3 +108,2 @@ stripNamespacePrefix,

RoomSessionStream,
RoomSessionMember,
} from './rooms'

@@ -121,2 +116,1 @@ export const selectors = {

export * as testUtils from './testUtils'
export * from './utils/mapObject'

@@ -25,4 +25,3 @@ import { fork } from '@redux-saga/core/effects'

) {
const event = stripNamespacePrefix(type)
instance.emit(event, payload)
instance.emit(type, payload)
}

@@ -66,3 +65,3 @@

if (processedMembers[memberId]) {
yield dispatcher?.('video.member.updated', payload, instance)
yield dispatcher?.('member.updated', payload, instance)

@@ -85,7 +84,3 @@ /**

yield dispatcher?.(
'video.member.updated',
updatedMemberEventParams,
instance
)
yield dispatcher?.('member.updated', updatedMemberEventParams, instance)
}

@@ -129,8 +124,9 @@ }

const event = stripNamespacePrefix(action.type)
for (const key of updated) {
const type = `${action.type}.${key}` as InternalMemberUpdatedEventNames
const type = `${event}.${key}` as InternalMemberUpdatedEventNames
yield dispatcher?.(type, memberUpdatedPayload, instance)
}
yield dispatcher?.(action.type, memberUpdatedPayload, instance)
yield dispatcher?.(event, memberUpdatedPayload, instance)
}

@@ -137,0 +133,0 @@

@@ -64,4 +64,2 @@ import { Store } from 'redux'

}) as Store
const instanceMap = useInstanceMap()

@@ -72,6 +70,5 @@ const { initSession, getSession, sessionEmitter } = useSession({

SessionConstructor,
//@ts-ignore FIXME
instanceMap,
})
const map = useInstanceMap()

@@ -89,3 +86,3 @@ const runSaga = <T>(

getSession,
instanceMap,
instanceMap: map,
})

@@ -106,5 +103,4 @@ }

channels,
instanceMap: instanceMap,
instanceMap: map,
sessionEmitter,
unifiedEventing: userOptions.unifiedEventing,
}

@@ -111,0 +107,0 @@ }

@@ -123,3 +123,2 @@ import type { Channel, SagaIterator } from '@redux-saga/types'

| PayloadAction<{ error: SessionAuthError }>
| PayloadAction<{ token: string }>
| PayloadAction<SessionAuthStatus>

@@ -126,0 +125,0 @@

@@ -6,3 +6,2 @@ import { BaseSession } from '../../BaseSession'

ClientEvents,
InstanceMap,
InternalUserOptions,

@@ -17,7 +16,6 @@ SessionConstructor,

sessionChannel: SessionChannel
instanceMap: InstanceMap
}
export const useSession = (options: UseSessionOptions) => {
const { SessionConstructor, userOptions, sessionChannel, instanceMap } = options
const { SessionConstructor, userOptions, sessionChannel } = options

@@ -32,3 +30,2 @@ const sessionEmitter = getEventEmitter<ClientEvents>()

sessionChannel,
instanceMap,
})

@@ -35,0 +32,0 @@ return session

@@ -15,2 +15,1 @@ import { BaseComponent, EventEmitter } from '..'

export * from './RoomSessionStream'
export * from './RoomSessionMember'

@@ -14,3 +14,2 @@ import { makeRPCRequest } from './helpers'

topics?: string[]
eventing?: string[]
event_acks?: boolean

@@ -25,8 +24,2 @@ }

export const UNIFIED_CONNECT_VERSION = {
major: 4,
minor: 0,
revision: 0,
}
export const RPCConnect = (params: RPCConnectParams) => {

@@ -42,12 +35,1 @@ return makeRPCRequest({

}
export const RPCConnectUnified = (params: RPCConnectParams) => {
return makeRPCRequest({
method: 'signalwire.connect',
params: {
version: UNIFIED_CONNECT_VERSION,
event_acks: true,
...params,
},
})
}

@@ -1,6 +0,20 @@

export interface PaginatedResponse<T> {
data: Array<T> | []
export interface FetchAddressResponse {
data:
| Array<{
display_name: string
name: string
preview_url?: string
cover_url?: string
resource_id: string
type: string
channels: {
audio?: string
messaging?: string
video?: string
}
}>
| []
links: {
first?: string
self?: string
first: string
self: string
next?: string

@@ -11,148 +25,5 @@ prev?: string

export interface PaginatedResult<T> {
data: Array<T> | []
self() : Promise<PaginatedResult<T> | undefined>
nextPage() : Promise<PaginatedResult<T> | undefined>
prevPage() : Promise<PaginatedResult<T> | undefined>
firstPage() : Promise<PaginatedResult<T> | undefined>
hasNext : boolean
hasPrev : boolean
}
/**
* Addresses
*/
export interface Address {
display_name: string
name: string
preview_url?: string
cover_url?: string
resource_id: string
type: string
channels: {
audio?: string
messaging?: string
video?: string
}
}
export interface GetAddressesOptions {
type?: string
displayName?: string
pageSize?: number
}
export interface GetAddressOptions {
id: string
}
export interface GetAddressResponse extends Address {}
export interface FetchAddressResponse extends PaginatedResponse<Address> {}
/**
* Conversations
*/
export interface SendConversationMessageOptions {
text: string
addressId: string
metadata?: Record<string, any>
details?: Record<string, any>
}
export interface GetConversationsOptions {
pageSize?: number
}
export interface Conversation {
created_at: number
id: string
last_message_at: number
metadata: Record<string, any>
name: string
sendMessage(options: { text: string }): Promise<SendConversationMessageResponse>
getMessages(options: { pageSize?: number }): Promise<PaginatedResult<ConversationMessage>>
}
export interface SendConversationMessageResponse {
table: {
conversation_id: string
text: string
}
}
export interface FetchConversationsResponse
extends PaginatedResponse<Conversation> {}
/**
* Conversation Messages
*/
export interface GetMessagesOptions {
pageSize?: number
}
export interface ConversationMessage {
id: string
conversation_id: string
user_id: string
ts: number
details: Record<string, any>
type: string
subtype: string
kind: string
}
export interface FetchConversationMessagesResponse
extends PaginatedResponse<ConversationMessage> {}
export interface GetConversationMessagesOptions {
addressId: string
pageSize?: number
}
/**
* Subsriber info
*/
export interface SubscriberInfoResponse {
id: string
email: string
first_name?: string
last_name?: string
display_name?: string
job_title?: string
time_zone?: number
country?: string
region?: string
company_name?: string
push_notification_key: string
app_settings?: {
display_name: string
scopes: string[]
}
}
/**
* Device registration
*/
export type RegisterDeviceType = 'iOS' | 'Android' | 'Desktop'
export interface RegisterDeviceParams {
deviceType: RegisterDeviceType
deviceToken: string
}
export interface UnregisterDeviceParams {
id: string
}
export interface RegisterDeviceResponse {
date_registered: Date
device_name?: string
device_token: string
device_type: RegisterDeviceType
id: string
push_notification_key: string
}

@@ -9,3 +9,2 @@ import type { EventEmitter } from '../utils/EventEmitter'

import type { VoiceCallEvent } from './voice'
import { ConversationEvent } from '..'

@@ -181,14 +180,4 @@ export interface SwEvent {

> extends EmitterContract<EventTypes> {
/**
* Connect the underlay WebSocket connection to the SignalWire network.
*
* @returns Promise that will resolve with the Client object.
*
* @example
*
* ```js
* client.connect()
* ```
*/
connect(): Promise<ClientInstance>
/**

@@ -238,3 +227,2 @@ * Disconnects this client. The client will stop receiving events and you will

| SwAuthorizationStateParams
| ConversationEvent

@@ -256,2 +244,1 @@ // prettier-ignore

export * from './callfabric'
export * from './conversation'

@@ -143,8 +143,1 @@ export type CamelToSnakeCase<S extends string> =

}
/*
* Type Debug Helper
*/
export type Prettify<T> = {
[K in keyof T]: Prettify<T[K]>
} & {}

@@ -357,9 +357,2 @@ import { PRODUCT_PREFIX_VIDEO } from '../utils/constants'

export interface InternalUnifiedVideoMemberEntity extends InternalVideoMemberEntity {
memberId: string
callId: string,
nodeId: string
}
export type InternalUnifiedMethodTarget = Pick<InternalUnifiedVideoMemberEntity, 'memberId' | 'callId' |'nodeId'>
/**

@@ -366,0 +359,0 @@ * VideoMember entity plus `updated` field

@@ -84,4 +84,2 @@ import type { BaseConnectionContract, SwEvent } from '.'

id: string
/** Unique id for this room session */
roomSessionId?: string
/** Display name for this room. Defaults to the value of `name` */

@@ -911,3 +909,2 @@ displayName: string

member_id: string
node_id?: string
}

@@ -914,0 +911,0 @@

@@ -28,3 +28,2 @@ import {

export * from './eventUtils'
export * from './mapObject'
export { LOCAL_EVENT_PREFIX }

@@ -31,0 +30,0 @@

@@ -52,3 +52,2 @@ import type { SagaIterator } from '@redux-saga/types'

export type WebRTCMethod = 'video.message' | 'webrtc.verto'
export type SubscriberMethod = 'subscriber.online' | 'subscriber.offline'
export type JSONRPCMethod =

@@ -62,3 +61,2 @@ | 'signalwire.connect'

| 'signalwire.unsubscribe'
| SubscriberMethod
| WebRTCMethod

@@ -115,8 +113,12 @@ | RoomMethod

logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent'
/** The SDK invokes this method and uses the new token to re-auth. */
onRefreshToken?(): Promise<string>
/** To refresh the auth token */
onRefreshToken?(): Promise<void>
/**
* The SDK invokes this method and uses the new token to re-auth.
* TODO: rename it: getNewToken, getRefreshedToken, fetchToken (?)
*
* @internal
* */
_onRefreshToken?(): Promise<void>
sessionChannel?: SessionChannel
/** Unified eventing is required only with Call Fabric SDK */
unifiedEventing?: boolean
instanceMap?: InstanceMap
}

@@ -123,0 +125,0 @@ export interface UserOptions extends SessionOptions {

@@ -16,3 +16,3 @@ import { call } from '@redux-saga/core/effects'

const { requestId: id, method, params } = initialState
const { requestId, method, params } = initialState

@@ -29,4 +29,7 @@ const session = getSession()

try {
let message = RPCExecute({ id, method, params })
const message = RPCExecute({
id: requestId,
method,
params,
})
const response = yield call(session.execute, message)

@@ -33,0 +36,0 @@ onDone?.(response)

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

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc