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

@signalwire/core

Package Overview
Dependencies
Maintainers
0
Versions
199
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.2.0-dev.202411211649.75f81c2.0 to 4.2.0-dev.202411271437.84aaad9.0

4

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, isJSONRPCRequest, isJSONRPCResponse, mapCapabilityPayload } 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, isJSONRPCRequest, isJSONRPCResponse, LOCAL_EVENT_PREFIX, stripNamespacePrefix, mapCapabilityPayload };
export * from './redux/features/component/componentSlice';

@@ -16,0 +16,0 @@ export * from './redux/features/session/sessionSlice';

@@ -44,2 +44,3 @@ import { CallState, CallConnect, CallPlay, InternalVideoRoomSessionEntity, MapToPubSubShape, SwEvent, CallEnded, CallRecord, ToInternalVideoEvent, VideoMemberEvent, VideoLayoutEvent } from '..';

room_session: InternalVideoRoomSessionEntity;
capabilities: string[];
}

@@ -223,3 +224,30 @@ export interface CallJoinedEvent extends SwEvent {

export type CallFabricAction = MapToPubSubShape<CallFabricEvent & HasEitherCallIdOrRoomSessionId>;
interface CapabilityOnOffState {
on?: true;
off?: true;
}
interface MemberCapability {
muteAudio?: CapabilityOnOffState;
muteVideo?: CapabilityOnOffState;
microphoneVolume?: true;
microphoneSensitivity?: true;
speakerVolume?: true;
deaf?: CapabilityOnOffState;
raisehand?: CapabilityOnOffState;
position?: true;
meta?: true;
remove?: true;
}
export interface CallCapabilities {
self?: MemberCapability;
member?: MemberCapability;
end?: true;
setLayout?: true;
sendDigit?: true;
vmutedHide?: CapabilityOnOffState;
lock?: CapabilityOnOffState;
device?: true;
screenshare?: true;
}
export {};
//# sourceMappingURL=callfabric.d.ts.map

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

};
export type Prettify<T> = {
export type Prettify<T> = NonNullable<unknown> & {
[K in keyof T]: Prettify<T[K]>;

@@ -71,0 +71,0 @@ } & {};

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

import { CallCapabilities } from '@signalwire/core';
export declare const stripNamespacePrefix: (event: string, namespace?: string) => string;
export declare const mapCapabilityPayload: (capabilities: string[]) => CallCapabilities;
//# sourceMappingURL=eventUtils.d.ts.map

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

"license": "MIT",
"version": "4.2.0-dev.202411211649.75f81c2.0",
"version": "4.2.0-dev.202411271437.84aaad9.0",
"main": "dist/index.node.js",

@@ -9,0 +9,0 @@ "module": "dist/index.esm.js",

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

isJSONRPCResponse,
mapCapabilityPayload
} from './utils'

@@ -78,2 +79,3 @@ import { WEBRTC_EVENT_TYPES, isWebrtcEventType } from './utils/common'

stripNamespacePrefix,
mapCapabilityPayload
}

@@ -80,0 +82,0 @@

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

room_session: InternalVideoRoomSessionEntity
capabilities: string[]
}

@@ -276,2 +277,30 @@

interface CapabilityOnOffState {
on?: true
off?: true
}
interface MemberCapability {
muteAudio?: CapabilityOnOffState
muteVideo?: CapabilityOnOffState
microphoneVolume?: true
microphoneSensitivity?: true
speakerVolume?: true
deaf?: CapabilityOnOffState
raisehand?: CapabilityOnOffState
position?: true
meta?: true
remove?: true
}
export interface CallCapabilities {
self?: MemberCapability
member?: MemberCapability
end?: true
setLayout?: true
sendDigit?: true
vmutedHide?: CapabilityOnOffState
lock?: CapabilityOnOffState
device?: true
screenshare?: true
}

@@ -147,4 +147,4 @@ export type CamelToSnakeCase<S extends string> =

*/
export type Prettify<T> = {
export type Prettify<T> = NonNullable<unknown> & {
[K in keyof T]: Prettify<T[K]>
} & {}

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

import { stripNamespacePrefix } from './eventUtils'
import { mapCapabilityPayload, stripNamespacePrefix } from './eventUtils'

@@ -26,2 +26,164 @@ describe('eventUtils', () => {

})
describe('mapCapabilitiesPayload', () => {
it('should have all capabilities', () => {
const callCapabilities = mapCapabilityPayload([
'self',
'member',
'device',
'screenshare',
'lock',
'end',
'vmuted',
'layout',
'digit',
'lock',
])
expect(callCapabilities.member?.deaf?.on).toEqual(true)
expect(callCapabilities.member?.deaf?.off).toEqual(true)
expect(callCapabilities.member?.raisehand?.on).toEqual(true)
expect(callCapabilities.member?.raisehand?.off).toEqual(true)
expect(callCapabilities.member?.muteVideo?.on).toEqual(true)
expect(callCapabilities.member?.muteVideo?.off).toEqual(true)
expect(callCapabilities.member?.muteAudio?.on).toEqual(true)
expect(callCapabilities.member?.muteAudio?.off).toEqual(true)
expect(callCapabilities.member?.meta).toEqual(true)
expect(callCapabilities.member?.position).toEqual(true)
expect(callCapabilities.member?.remove).toEqual(true)
expect(callCapabilities.member?.microphoneSensitivity).toEqual(true)
expect(callCapabilities.member?.microphoneVolume).toEqual(true)
expect(callCapabilities.member?.speakerVolume).toEqual(true)
expect(callCapabilities.self?.deaf?.on).toEqual(true)
expect(callCapabilities.self?.deaf?.off).toEqual(true)
expect(callCapabilities.self?.raisehand?.on).toEqual(true)
expect(callCapabilities.self?.raisehand?.off).toEqual(true)
expect(callCapabilities.self?.muteVideo?.on).toEqual(true)
expect(callCapabilities.self?.muteVideo?.off).toEqual(true)
expect(callCapabilities.self?.muteAudio?.on).toEqual(true)
expect(callCapabilities.self?.muteAudio?.off).toEqual(true)
expect(callCapabilities.self?.meta).toEqual(true)
expect(callCapabilities.self?.position).toEqual(true)
expect(callCapabilities.self?.remove).toEqual(true)
expect(callCapabilities.self?.microphoneSensitivity).toEqual(true)
expect(callCapabilities.self?.microphoneVolume).toEqual(true)
expect(callCapabilities.self?.speakerVolume).toEqual(true)
expect(callCapabilities.device).toEqual(true)
expect(callCapabilities.screenshare).toEqual(true)
expect(callCapabilities.sendDigit).toEqual(true)
expect(callCapabilities.setLayout).toEqual(true)
expect(callCapabilities.end).toEqual(true)
expect(callCapabilities.lock?.on).toEqual(true)
expect(callCapabilities.lock?.off).toEqual(true)
expect(callCapabilities.vmutedHide?.on).toEqual(true)
expect(callCapabilities.vmutedHide?.off).toEqual(true)
})
it('should have some self capabilities and others member capabilities', () => {
const callCapabilities = mapCapabilityPayload([
'member.deaf',
'member.mute.video',
'member.mute.audio.on',
'self.remove',
'self.microphone',
])
expect(callCapabilities.member?.deaf?.on).toEqual(true)
expect(callCapabilities.member?.deaf?.off).toEqual(true)
expect(callCapabilities.member?.raisehand?.on).toBeFalsy()
expect(callCapabilities.member?.raisehand?.off).toBeFalsy()
expect(callCapabilities.member?.muteVideo?.on).toEqual(true)
expect(callCapabilities.member?.muteVideo?.off).toEqual(true)
expect(callCapabilities.member?.muteAudio?.on).toEqual(true)
expect(callCapabilities.member?.muteAudio?.off).toBeFalsy()
expect(callCapabilities.member?.meta).toBeFalsy()
expect(callCapabilities.member?.position).toBeFalsy()
expect(callCapabilities.member?.remove).toBeFalsy()
expect(callCapabilities.member?.microphoneSensitivity).toBeFalsy()
expect(callCapabilities.member?.microphoneVolume).toBeFalsy()
expect(callCapabilities.member?.speakerVolume).toBeFalsy()
expect(callCapabilities.self?.deaf?.on).toBeFalsy()
expect(callCapabilities.self?.deaf?.off).toBeFalsy()
expect(callCapabilities.self?.raisehand?.on).toBeFalsy()
expect(callCapabilities.self?.raisehand?.off).toBeFalsy()
expect(callCapabilities.self?.muteVideo?.on).toBeFalsy()
expect(callCapabilities.self?.muteVideo?.off).toBeFalsy()
expect(callCapabilities.self?.muteAudio?.on).toBeFalsy()
expect(callCapabilities.self?.muteAudio?.off).toBeFalsy()
expect(callCapabilities.self?.meta).toBeFalsy()
expect(callCapabilities.self?.position).toBeFalsy()
expect(callCapabilities.self?.remove).toEqual(true)
expect(callCapabilities.self?.microphoneSensitivity).toEqual(true)
expect(callCapabilities.self?.microphoneVolume).toEqual(true)
expect(callCapabilities.self?.speakerVolume).toBeFalsy()
expect(callCapabilities.device).toBeFalsy()
expect(callCapabilities.screenshare).toBeFalsy()
expect(callCapabilities.sendDigit).toBeFalsy()
expect(callCapabilities.setLayout).toBeFalsy()
expect(callCapabilities.end).toBeFalsy()
expect(callCapabilities.lock?.on).toBeFalsy()
expect(callCapabilities.lock?.off).toBeFalsy()
expect(callCapabilities.vmutedHide?.on).toBeFalsy()
expect(callCapabilities.vmutedHide?.off).toBeFalsy()
})
})
it('should not break if the server send redundant capability', () => {
const callCapabilities = mapCapabilityPayload([
'self',
'self.deaf',
'self.mute.audio',
'self.mute.audio.on',
'member',
'device',
'screenshare',
'lock',
'end',
'vmuted',
'layout',
'digit',
'lock',
])
expect(callCapabilities.member?.deaf?.on).toEqual(true)
expect(callCapabilities.member?.deaf?.off).toEqual(true)
expect(callCapabilities.member?.raisehand?.on).toEqual(true)
expect(callCapabilities.member?.raisehand?.off).toEqual(true)
expect(callCapabilities.member?.muteVideo?.on).toEqual(true)
expect(callCapabilities.member?.muteVideo?.off).toEqual(true)
expect(callCapabilities.member?.muteAudio?.on).toEqual(true)
expect(callCapabilities.member?.muteAudio?.off).toEqual(true)
expect(callCapabilities.member?.meta).toEqual(true)
expect(callCapabilities.member?.position).toEqual(true)
expect(callCapabilities.member?.remove).toEqual(true)
expect(callCapabilities.member?.microphoneSensitivity).toEqual(true)
expect(callCapabilities.member?.microphoneVolume).toEqual(true)
expect(callCapabilities.member?.speakerVolume).toEqual(true)
expect(callCapabilities.self?.deaf?.on).toEqual(true)
expect(callCapabilities.self?.deaf?.off).toEqual(true)
expect(callCapabilities.self?.raisehand?.on).toEqual(true)
expect(callCapabilities.self?.raisehand?.off).toEqual(true)
expect(callCapabilities.self?.muteVideo?.on).toEqual(true)
expect(callCapabilities.self?.muteVideo?.off).toEqual(true)
expect(callCapabilities.self?.muteAudio?.on).toEqual(true)
expect(callCapabilities.self?.muteAudio?.off).toEqual(true)
expect(callCapabilities.self?.meta).toEqual(true)
expect(callCapabilities.self?.position).toEqual(true)
expect(callCapabilities.self?.remove).toEqual(true)
expect(callCapabilities.self?.microphoneSensitivity).toEqual(true)
expect(callCapabilities.self?.microphoneVolume).toEqual(true)
expect(callCapabilities.self?.speakerVolume).toEqual(true)
expect(callCapabilities.device).toEqual(true)
expect(callCapabilities.screenshare).toEqual(true)
expect(callCapabilities.sendDigit).toEqual(true)
expect(callCapabilities.setLayout).toEqual(true)
expect(callCapabilities.end).toEqual(true)
expect(callCapabilities.lock?.on).toEqual(true)
expect(callCapabilities.lock?.off).toEqual(true)
expect(callCapabilities.vmutedHide?.on).toEqual(true)
expect(callCapabilities.vmutedHide?.off).toEqual(true)
})
})

@@ -0,1 +1,3 @@

import { CallCapabilities } from '@signalwire/core'
export const stripNamespacePrefix = (

@@ -16,1 +18,108 @@ event: string,

}
const capabilityStringToObjectMap = {
device: { device: true } as CallCapabilities,
'digit.send': { sendDigit: true } as CallCapabilities,
end: { end: true } as CallCapabilities,
'layout.set': { setLayout: true } as CallCapabilities,
screenshare: { screenshare: true } as CallCapabilities,
'vmuted.hide.on': { vmutedHide: { on: true } } as CallCapabilities,
'vmuted.hide.off': { vmutedHide: { off: true } } as CallCapabilities,
'lock.on': { lock: { on: true } } as CallCapabilities,
'lock.off': { lock: { off: true } } as CallCapabilities,
'member.position.set': { member: { position: true } } as CallCapabilities,
'member.meta': { member: { meta: true } } as CallCapabilities,
'member.remove': { member: { remove: true } } as CallCapabilities,
'member.microphone.volume.set': {
member: { microphoneVolume: true },
} as CallCapabilities,
'member.microphone.sensitivity.set': {
member: { microphoneSensitivity: true },
} as CallCapabilities,
'member.speaker.volume.set': {
member: { speakerVolume: true },
} as CallCapabilities,
'member.deaf.on': { member: { deaf: { on: true } } } as CallCapabilities,
'member.deaf.off': { member: { deaf: { off: true } } } as CallCapabilities,
'member.mute.audio.on': {
member: { muteAudio: { on: true } },
} as CallCapabilities,
'member.mute.audio.off': {
member: { muteAudio: { off: true } },
} as CallCapabilities,
'member.mute.video.on': {
member: { muteVideo: { on: true } },
} as CallCapabilities,
'member.mute.video.off': {
member: { muteVideo: { off: true } },
} as CallCapabilities,
'member.raisehand.on': {
member: { raisehand: { on: true } },
} as CallCapabilities,
'member.raisehand.off': {
member: { raisehand: { off: true } },
} as CallCapabilities,
'self.position.set': { self: { position: true } } as CallCapabilities,
'self.meta': { self: { meta: true } } as CallCapabilities,
'self.remove': { self: { remove: true } } as CallCapabilities,
'self.microphone': {
self: { microphoneVolume: true, microphoneSensitivity: true },
} as CallCapabilities,
'self.microphone.volume.set': {
self: { microphoneVolume: true },
} as CallCapabilities,
'self.microphone.sensitivity.set': {
self: { microphoneSensitivity: true },
} as CallCapabilities,
'self.speaker.volume.set': {
self: { speakerVolume: true },
} as CallCapabilities,
'self.deaf.on': { self: { deaf: { on: true } } } as CallCapabilities,
'self.deaf.off': { self: { deaf: { off: true } } } as CallCapabilities,
'self.mute.audio.on': {
self: { muteAudio: { on: true } },
} as CallCapabilities,
'self.mute.audio.off': {
self: { muteAudio: { off: true } },
} as CallCapabilities,
'self.mute.video.on': {
self: { muteVideo: { on: true } },
} as CallCapabilities,
'self.mute.video.off': {
self: { muteVideo: { off: true } },
} as CallCapabilities,
'self.raisehand.on': {
self: { raisehand: { on: true } },
} as CallCapabilities,
'self.raisehand.off': {
self: { raisehand: { off: true } },
} as CallCapabilities,
}
const isObjectGuard = (o: unknown): o is Object => o instanceof Object
const capabilityStringToObjects = (capability: string) =>
Object.entries(capabilityStringToObjectMap)
.filter(([key]) => key.startsWith(capability))
.map(([_, value]) => value)
const mergeCapabilityObjects = <T extends Object>(target: T, source: T): T => {
const result = { ...target }
for (const key in source) {
if (
result[key] &&
isObjectGuard(target[key]) &&
isObjectGuard(source[key])
) {
result[key] = mergeCapabilityObjects(target[key], source[key])
} else {
result[key] = source[key]
}
}
return result
}
export const mapCapabilityPayload = (capabilities: string[]) =>
capabilities
.flatMap(capabilityStringToObjects)
.reduce<CallCapabilities>(mergeCapabilityObjects, {} as CallCapabilities)

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