react-sip-kit 0.5.21 → 0.7.0-beta

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.
@@ -4,7 +4,8 @@ export declare class SipInitializer {
4
4
  private ua?;
5
5
  private configs;
6
6
  private username;
7
- constructor(configs: SipConfigs);
7
+ private configKey;
8
+ constructor(configs: SipConfigs, key: string);
8
9
  init(): Promise<void>;
9
10
  private detectDevices;
10
11
  private createUserAgent;
package/dist/manager.d.ts CHANGED
@@ -1,53 +1,81 @@
1
+ import { SipConfigs } from './configs/types';
2
+ import { useWatchSessionData } from './hooks';
1
3
  import { LineType, SipUserAgentStatus } from './store/types';
2
- import { SipManagerConfig } from './types';
4
+ import { GetAccountKey, GetMethodsKey, LineLookup, SipManagerConfig } from './types';
3
5
  export declare class SipManager {
6
+ /**
7
+ * Active SIP instances keyed by `configKey`.
8
+ *
9
+ * `configKey` defaults to `config.account.username` if not explicitly provided.
10
+ * Ensures multiple accounts (e.g., same username on different domains) can coexist.
11
+ */
4
12
  private instances;
5
13
  /**
6
- * Create and initialize a SIP session for an account.
14
+ * Hook for reactively watching session data (delegates to Zustand store).
15
+ */
16
+ useWatchSessionData: typeof useWatchSessionData;
17
+ /**
18
+ * Hook for reactively watching added configs and line rendering (delegates to Zustand store).
7
19
  *
8
- * @param {SipManagerConfig} config - SIP account configuration (account, transport, registration, etc.)
9
- * @returns {Promise<void>} Resolves when initialization is complete.
20
+ * Recommended for rendering `Lines` with unique key(config.key)
21
+ */
22
+ useWatchConfigs: () => SipConfigs[];
23
+ /**
24
+ * Update the configuration for an existing SIP instance.
25
+ *
26
+ * - Replaces stored config in memory and global store.
27
+ * - Does **not** automatically reconnect or restart the UserAgent.
28
+ *
29
+ * Use `initilizeMediaStreams` or `reconnect()` if runtime behavior must change.
30
+ *
31
+ * @param configKey - Unique identifier of the SIP instance
32
+ * @param config - Updated SIP configuration
33
+ */
34
+ private updateConfig;
35
+ /**
36
+ * Add or update a SIP account.
37
+ *
38
+ * - If identical config exists → ignored.
39
+ * - If same `configKey` but config changed → updates config + re-initializes media streams.
40
+ * - Otherwise → creates and initializes a new UserAgent instance.
41
+ *
42
+ * @param config - SIP account configuration (must contain account info, optional `key`)
10
43
  */
11
44
  add(config: SipManagerConfig): Promise<void>;
12
45
  /**
13
- * Get session methods (dial, answer, hold, etc.) for a given username.
46
+ * Get high-level session methods (answer, dial, hold, transfer, etc.).
14
47
  *
15
- * @param {string} username - The SIP account username.
16
- * @returns {ReturnType<typeof sessionMethods>} Object containing call/session methods.
48
+ * Resolves the SIP instance by `configKey`, `lineKey`, or `remoteNumber`.
17
49
  */
18
- methods(username: string): {
50
+ getSessionMethodsBy(key: GetMethodsKey): {
19
51
  receiveSession: (invitation: import("./store/types").SipInvitationType) => void;
20
- answerAudioSession: (lineNumber: LineType["lineNumber"]) => void;
21
- answerVideoSession: (lineNumber: LineType["lineNumber"], enableVideo?: boolean) => void;
52
+ answerAudioSession: (lineKey: LineType["lineKey"]) => void;
53
+ answerVideoSession: (lineKey: LineType["lineKey"], enableVideo?: boolean) => void;
22
54
  makeAudioSession: (lineObj: LineType, dialledNumber: string, extraHeaders?: Array<string>) => void;
23
55
  makeVideoSession: (lineObj: LineType, dialledNumber: string, extraHeaders?: Array<string>) => void;
24
- toggleLocalVideoTrack: (lineNumber: LineType["lineNumber"]) => Promise<void>;
25
- toggleShareScreen: (lineNumber: LineType["lineNumber"]) => Promise<void>;
26
- rejectSession: (lineNumber: LineType["lineNumber"]) => void;
56
+ toggleLocalVideoTrack: (lineKey: LineType["lineKey"]) => Promise<void>;
57
+ toggleShareScreen: (lineKey: LineType["lineKey"]) => Promise<void>;
58
+ rejectSession: (lineKey: LineType["lineKey"]) => void;
27
59
  dialByNumber: (type: Extract<import("./types").CallType, "audio" | "video">, dialNumber: string, extraHeaders?: Array<string>) => void;
28
- endSession: (lineNumber: LineType["lineNumber"]) => void;
29
- recordSession: (lineNumber: LineType["lineNumber"]) => {
60
+ endSession: (lineKey: LineType["lineKey"]) => void;
61
+ recordSession: (lineKey: LineType["lineKey"]) => {
30
62
  start: () => Promise<void>;
31
63
  stop: () => void;
32
64
  };
33
- toggleMuteSession: (lineNumber: LineType["lineNumber"]) => void;
34
- toggleHoldSession: (lineNumber: LineType["lineNumber"], forcedValue?: boolean) => void;
35
- makeTransferSession: (lineNumber: LineType["lineNumber"], transferLineNumber: LineType["lineNumber"]) => void;
36
- cancelTransferSession: (lineNumber: LineType["lineNumber"], transferLineNumber: LineType["lineNumber"]) => void;
37
- cancelSession: (lineNumber: LineType["lineNumber"]) => void;
65
+ toggleMuteSession: (lineKey: LineType["lineKey"]) => void;
66
+ toggleHoldSession: (lineKey: LineType["lineKey"], forcedValue?: boolean) => void;
67
+ makeTransferSession: (lineKey: LineType["lineKey"], transferNumber: LineType["lineKey"]) => void;
68
+ cancelTransferSession: (lineKey: LineType["lineKey"], transferNumber: LineType["lineKey"]) => void;
69
+ cancelSession: (lineKey: LineType["lineKey"]) => void;
38
70
  teardownSession: typeof import("./methods/session").teardownSession;
39
71
  };
40
72
  /**
41
- * Get SIP account state by username.
73
+ * Get SIP account state.
42
74
  *
43
- * @param {string} username - The SIP account username.
44
- * @returns {{
45
- * status: SipUserAgentStatus;
46
- * lines: LineType[];
47
- * watch: ReturnType<typeof useSipManager>;
48
- * }} An object with account status, active lines, and a reactive watcher hook.
75
+ * Resolves account by `configKey`, `lineKey`, or `remoteNumber`.
76
+ * Returns reactive account information and watcher hook.
49
77
  */
50
- get(username: string): {
78
+ getAccountBy(key: GetAccountKey): {
51
79
  status: SipUserAgentStatus;
52
80
  lines: LineType[];
53
81
  watch: () => {
@@ -55,47 +83,21 @@ export declare class SipManager {
55
83
  lines: LineType[];
56
84
  };
57
85
  };
86
+ /** Check if an instance exists for the given configKey. */
87
+ has(configKey: string): boolean;
88
+ /** Force reconnect transport for an existing SIP instance. */
89
+ reconnect(configKey: string): void;
58
90
  /**
59
- * Check if a SIP instance already exists for the username.
60
- *
61
- * @param {string} username - The SIP account username.
62
- * @returns {boolean} True if the instance exists, false otherwise.
63
- */
64
- has(username: string): boolean;
65
- /**
66
- * Attempt to reconnect the SIP transport for a given username.
67
- *
68
- * @param {string} username - The SIP account username.
69
- * @returns {void}
70
- */
71
- reconnect(username: string): void;
72
- /**
73
- * Stop and remove a SIP session for a username.
74
- * Also cleans up from the global store.
75
- *
76
- * @param {string} username - The SIP account username.
77
- * @returns {Promise<void>} Resolves when the session is stopped and removed.
78
- */
79
- stop(username: string): Promise<void>;
80
- /**
81
- * Stop and clear ALL SIP sessions.
82
- * Useful on logout or app shutdown.
83
- *
84
- * @returns {Promise<void>} Resolves when all sessions are stopped and cleared.
91
+ * Stop and remove a SIP instance.
92
+ * Cleans up associated data from the global store.
85
93
  */
94
+ stop(configKey: string): Promise<void>;
95
+ /** Stop and clear all SIP instances (e.g., on logout). */
86
96
  stopAll(): Promise<void>;
87
- /**
88
- * Find the username associated with a specific line number.
89
- *
90
- * @param {LineType['lineNumber']} lineNumber - The line number to look up.
91
- * @returns {string | undefined} The username if found, otherwise undefined.
92
- */
93
- getUsernameByNumber(lineNumber: LineType['lineNumber']): string | null;
94
- /**
95
- * Find the SIP session associated with a specific line number.
96
- *
97
- * @param {LineType['lineNumber']} lineNumber - The line number to look up.
98
- * @returns {any} The SIP session object if found, otherwise undefined.
99
- */
100
- getSessionByNumber(lineNumber: LineType['lineNumber']): import("./store/types").SipInvitationType | import("./store/types").SipInviterType | null;
97
+ /** Lookup a line by `lineKey` or `remoteNumber`. */
98
+ getLineBy(key: LineLookup): LineType | null;
99
+ /** Lookup a session by `lineKey` or `remoteNumber`. */
100
+ getSessionBy(key: LineLookup): import("./store/types").SipInvitationType | import("./store/types").SipInviterType | null;
101
+ /** Resolve the `configKey` for a given `lineKey` or `remoteNumber`. */
102
+ getConfigKeyBy(key: LineLookup): string | null;
101
103
  }
@@ -1,4 +1,4 @@
1
- import { SipAccountConfig } from '../../configs/types';
2
- export declare function register(username: SipAccountConfig['username'], userAgent?: import("../..").SipUserAgent | null): void;
3
- export declare function unregister(username: SipAccountConfig['username'], skipUnsubscribe?: boolean, userAgent?: import("../..").SipUserAgent | null): void;
4
- export declare function refreshRegistration(username: SipAccountConfig['username']): void;
1
+ import { SipConfigs } from '../../configs/types';
2
+ export declare function register(configKey: SipConfigs['key'], userAgent?: import("../..").SipUserAgent | null): void;
3
+ export declare function unregister(configKey: SipConfigs['key'], skipUnsubscribe?: boolean, userAgent?: import("../..").SipUserAgent | null): void;
4
+ export declare function refreshRegistration(configKey: SipConfigs['key']): void;
@@ -1,29 +1,29 @@
1
- import { SipAccountConfig } from '../../configs/types';
1
+ import { SipConfigs } from '../../configs/types';
2
2
  import { LineType, SipInvitationType } from '../../store/types';
3
3
  import { CallType } from '../../types';
4
4
  import { SendMessageSessionEnum, SendMessageSessionValueType } from './types';
5
- export declare const sessionMethods: ({ username }: {
6
- username: SipAccountConfig["username"];
5
+ export declare const sessionMethods: ({ configKey }: {
6
+ configKey: SipConfigs["key"];
7
7
  }) => {
8
8
  receiveSession: (invitation: SipInvitationType) => void;
9
- answerAudioSession: (lineNumber: LineType["lineNumber"]) => void;
10
- answerVideoSession: (lineNumber: LineType["lineNumber"], enableVideo?: boolean) => void;
9
+ answerAudioSession: (lineKey: LineType["lineKey"]) => void;
10
+ answerVideoSession: (lineKey: LineType["lineKey"], enableVideo?: boolean) => void;
11
11
  makeAudioSession: (lineObj: LineType, dialledNumber: string, extraHeaders?: Array<string>) => void;
12
12
  makeVideoSession: (lineObj: LineType, dialledNumber: string, extraHeaders?: Array<string>) => void;
13
- toggleLocalVideoTrack: (lineNumber: LineType["lineNumber"]) => Promise<void>;
14
- toggleShareScreen: (lineNumber: LineType["lineNumber"]) => Promise<void>;
15
- rejectSession: (lineNumber: LineType["lineNumber"]) => void;
13
+ toggleLocalVideoTrack: (lineKey: LineType["lineKey"]) => Promise<void>;
14
+ toggleShareScreen: (lineKey: LineType["lineKey"]) => Promise<void>;
15
+ rejectSession: (lineKey: LineType["lineKey"]) => void;
16
16
  dialByNumber: (type: Extract<CallType, "audio" | "video">, dialNumber: string, extraHeaders?: Array<string>) => void;
17
- endSession: (lineNumber: LineType["lineNumber"]) => void;
18
- recordSession: (lineNumber: LineType["lineNumber"]) => {
17
+ endSession: (lineKey: LineType["lineKey"]) => void;
18
+ recordSession: (lineKey: LineType["lineKey"]) => {
19
19
  start: () => Promise<void>;
20
20
  stop: () => void;
21
21
  };
22
- toggleMuteSession: (lineNumber: LineType["lineNumber"]) => void;
23
- toggleHoldSession: (lineNumber: LineType["lineNumber"], forcedValue?: boolean) => void;
24
- makeTransferSession: (lineNumber: LineType["lineNumber"], transferLineNumber: LineType["lineNumber"]) => void;
25
- cancelTransferSession: (lineNumber: LineType["lineNumber"], transferLineNumber: LineType["lineNumber"]) => void;
26
- cancelSession: (lineNumber: LineType["lineNumber"]) => void;
22
+ toggleMuteSession: (lineKey: LineType["lineKey"]) => void;
23
+ toggleHoldSession: (lineKey: LineType["lineKey"], forcedValue?: boolean) => void;
24
+ makeTransferSession: (lineKey: LineType["lineKey"], transferNumber: LineType["lineKey"]) => void;
25
+ cancelTransferSession: (lineKey: LineType["lineKey"], transferNumber: LineType["lineKey"]) => void;
26
+ cancelSession: (lineKey: LineType["lineKey"]) => void;
27
27
  teardownSession: typeof teardownSession;
28
28
  };
29
29
  /**
@@ -40,5 +40,3 @@ export declare function sendVideoActivationWithAckRetry(session: LineType['sipSe
40
40
  maxRetries?: number;
41
41
  delayMs?: number;
42
42
  }): Promise<void>;
43
- export declare const getUsernameByNumber: (lineNumber: LineType["lineNumber"]) => SipAccountConfig["username"] | null;
44
- export declare const getSessionByNumber: (lineNumber: LineType["lineNumber"]) => LineType["sipSession"] | null;
@@ -1,7 +1,7 @@
1
- import { SipAccountConfig } from '../../../configs/types';
1
+ import { SipConfigs } from '../../../configs/types';
2
2
  import { SPDOptionsType } from '../types';
3
- export declare const spdOptions: ({ username }: {
4
- username: SipAccountConfig["username"];
3
+ export declare const spdOptions: ({ configKey }: {
4
+ configKey: SipConfigs["key"];
5
5
  }) => {
6
6
  answerAudioSpdOptions: ({ option: defaultOption }?: {
7
7
  option?: SPDOptionsType;
@@ -1,4 +1,4 @@
1
- import { SipAccountConfig, SipConfigs } from '../configs/types';
1
+ import { SipConfigs } from '../configs/types';
2
2
  import { SipUserAgent } from '../types';
3
3
  import { SipStoreStateType } from './types';
4
4
  export declare const useSipStore: import("zustand").UseBoundStore<import("zustand").StoreApi<SipStoreStateType>>;
@@ -16,12 +16,12 @@ export declare const getSipStore: () => SipStoreStateType;
16
16
  *
17
17
  * Get sip store userAgent for none functional components
18
18
  */
19
- export declare const getSipStoreUserAgent: (username: SipAccountConfig["username"]) => SipUserAgent | null;
19
+ export declare const getSipStoreUserAgent: (configKey: SipConfigs["key"]) => SipUserAgent | null;
20
20
  /**
21
21
  *
22
22
  * Get sip store configs for none functional components
23
23
  */
24
- export declare const getSipUsernameConfigs: (username: SipAccountConfig["username"]) => SipConfigs | null;
24
+ export declare const getSipUsernameConfigs: (configKey: SipConfigs["key"]) => SipConfigs | null;
25
25
  /**
26
26
  *
27
27
  * Init sip store for none functional components
@@ -3,33 +3,49 @@ import { CallbackFunction, CallType, SipUserAgent } from '../types';
3
3
  import { Invitation, Inviter, Session, SessionDescriptionHandler, SessionDescriptionHandlerOptions } from 'sip.js';
4
4
  import { IncomingInviteRequest } from 'sip.js/lib/core';
5
5
  export interface SipStoreStateType {
6
- configs: Record<SipAccountConfig['username'], SipConfigs> | null;
7
- statuses: Record<SipAccountConfig['username'], SipUserAgentStatus> | null;
8
- userAgents?: Record<SipAccountConfig['username'], SipUserAgent>;
9
- lines: Record<SipAccountConfig['username'], Record<LineType['lineNumber'], LineType>>;
10
- usernamesByLineNumber: Record<LineType['lineNumber'], SipAccountConfig['username']>;
6
+ configs: Record<SipConfigs['key'], SipConfigs> | null;
7
+ statuses: Record<SipConfigs['key'], SipUserAgentStatus> | null;
8
+ userAgents?: Record<SipConfigs['key'], SipUserAgent>;
9
+ lines: Record<SipConfigs['key'], Record<LineType['lineKey'], LineType>>;
10
+ configKeysByLineKey: Record<LineType['lineKey'], SipConfigs['key']>;
11
+ lineKeyByRemoteNumber_ConfigKey: Record<SipSessionDataType['remoteNumber'], LineType['lineKey']>;
11
12
  devicesInfo: DevicesInfoType;
12
13
  setSipStore: (state: Partial<SipStoreStateType>) => void;
13
- setConfig: (username: SipAccountConfig['username'], userAgent: SipConfigs) => void;
14
- setUserAgent: (username: SipAccountConfig['username'], userAgent: SipUserAgent) => void;
15
- addLine: (username: SipAccountConfig['username'], line: LineType) => void;
14
+ setConfig: (key: SipConfigs['key'], userAgent: SipConfigs) => void;
15
+ setUserAgent: (key: SipConfigs['key'], userAgent: SipUserAgent) => void;
16
+ addLine: (line: LineType) => void;
16
17
  updateLine: (line: LineType, callback?: CallbackFunction) => void;
17
- removeLine: (lineNumber: LineType['lineNumber']) => void;
18
- remove: (username: SipAccountConfig['username']) => void;
18
+ removeLine: (lineKey: LineType['lineKey']) => void;
19
+ remove: (key: SipConfigs['key']) => void;
19
20
  removeAll: () => void;
20
- findLineByNumber: (lineNumber: LineType['lineNumber']) => LineType | null;
21
- getSessionByNumber: (lineNumber: LineType['lineNumber']) => LineType['sipSession'] | null;
22
- getUsernameByNumber: (lineNumber: LineType['lineNumber']) => SipAccountConfig['username'] | null;
23
- getNewLineNumber: () => number;
21
+ findLineByLineKey: (lineKey: LineType['lineKey']) => LineType | null;
22
+ getSessionByLineKey: (lineKey: LineType['lineKey']) => LineType['sipSession'] | null;
23
+ getConfigKeyByLineKey: (lineKey: LineType['lineKey']) => SipConfigs['key'] | null;
24
+ getConfigKeyByRemoteNumber_ConfigKey: ({ remoteNumber, configKey, }: {
25
+ remoteNumber: SipSessionDataType['remoteNumber'];
26
+ configKey: SipConfigs['key'];
27
+ }) => SipConfigs['key'] | null;
28
+ getLineKeyByRemoteNumber_ConfigKey: ({ remoteNumber, configKey, }: {
29
+ remoteNumber: SipSessionDataType['remoteNumber'];
30
+ configKey: SipConfigs['key'];
31
+ }) => LineType['lineKey'] | null;
32
+ getLineBy: ({ remoteNumber, configKey, }: {
33
+ remoteNumber: SipSessionDataType['remoteNumber'];
34
+ configKey: SipConfigs['key'];
35
+ }) => LineType | null;
36
+ remoteNumberConfigKeyResolver: ({ remoteNumber, configKey, }: {
37
+ remoteNumber: SipSessionDataType['remoteNumber'];
38
+ configKey: SipConfigs['key'];
39
+ }) => `${typeof remoteNumber}:${typeof configKey}`;
40
+ getNewLineKey: () => LineType['lineKey'];
24
41
  }
25
42
  export interface SipInvitationType extends Omit<Invitation, 'incomingInviteRequest' | 'sessionDescriptionHandler'> {
26
43
  data: Partial<SipSessionDataType>;
27
44
  incomingInviteRequest: IncomingInviteRequest;
28
45
  sessionDescriptionHandler: SipSessionDescriptionHandler;
29
46
  sessionDescriptionHandlerOptionsReInvite: SipSessionDescriptionHandlerOptions;
30
- isOnHold: boolean;
31
- initiateLocalMediaStreams: (params: InitiateMediaStreamsParams) => void;
32
- initiateRemoteMediaStreams: (params: InitiateMediaStreamsParams) => void;
47
+ initiateLocalMediaStreams: (params?: InitiateMediaStreamsParams) => void;
48
+ initiateRemoteMediaStreams: (params?: InitiateMediaStreamsParams) => void;
33
49
  }
34
50
  export interface InitiateMediaStreamsParams {
35
51
  videoEnabled?: boolean;
@@ -43,17 +59,17 @@ export interface SipInviterType extends Inviter {
43
59
  data: Partial<SipSessionDataType>;
44
60
  sessionDescriptionHandler: SipSessionDescriptionHandler;
45
61
  sessionDescriptionHandlerOptionsReInvite: SipSessionDescriptionHandlerOptions;
46
- isOnHold: boolean;
47
- initiateLocalMediaStreams: (params: InitiateMediaStreamsParams) => void;
48
- initiateRemoteMediaStreams: (params: InitiateMediaStreamsParams) => void;
62
+ initiateLocalMediaStreams: (params?: InitiateMediaStreamsParams) => void;
63
+ initiateRemoteMediaStreams: (params?: InitiateMediaStreamsParams) => void;
49
64
  }
50
65
  export interface SipSessionDescriptionHandler extends SessionDescriptionHandler {
51
66
  peerConnection: RTCPeerConnection;
52
67
  peerConnectionDelegate: any;
53
68
  }
54
69
  export interface LineType {
55
- lineNumber: number;
56
- displayNumber: string;
70
+ lineKey: string;
71
+ remoteNumber: string;
72
+ configKey: SipConfigs['key'];
57
73
  sipSession: SipInvitationType | SipInviterType | null;
58
74
  localSoundMeter: any;
59
75
  remoteSoundMeter: any;
@@ -62,11 +78,13 @@ export interface SipSessionType extends Session {
62
78
  data: SipSessionDataType;
63
79
  }
64
80
  export interface SipSessionDataType {
65
- line: number;
81
+ configKey: SipConfigs['key'];
82
+ lineKey: LineType['lineKey'];
66
83
  callDirection: 'inbound' | 'outbound';
67
84
  callType: CallType;
68
85
  terminateBy: string;
69
86
  remoteNumber: string;
87
+ username: SipAccountConfig['username'];
70
88
  earlyReject: boolean;
71
89
  reasonCode: number;
72
90
  reasonText: string;
@@ -103,7 +121,7 @@ export interface SipSessionDataType {
103
121
  }
104
122
  export interface SipSessionTransferType {
105
123
  type: 'Attended' | 'Blind';
106
- to: number;
124
+ to: LineType['remoteNumber'];
107
125
  transferTime: string;
108
126
  disposition: string;
109
127
  dispositionTime: string;
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { SipConfigs } from './configs/types';
2
2
  import { reconnectTransport } from './events/transport';
3
- import { SipSessionType } from './store/types';
3
+ import { SipInitializer } from './initializer';
4
+ import { LineType, SipSessionDataType, SipSessionType } from './store/types';
4
5
  import { Registerer, Subscriber, UserAgent } from 'sip.js';
5
6
  export interface SipUserAgent extends UserAgent {
6
7
  isReRegister: boolean;
@@ -24,6 +25,17 @@ export interface SipUserAgent extends UserAgent {
24
25
  voicemailSub: Subscriber | null;
25
26
  }
26
27
  export type SipManagerConfig = {
28
+ /**
29
+ * Unique identifier for the SIP account instance.
30
+ *
31
+ * - Default: `account.username`
32
+ * - Useful when the same username can exist across multiple domains.
33
+ * - All internal maps and store entries use this key.
34
+ */
35
+ key?: SipConfigs['key'];
36
+ /**
37
+ * Core SIP account information (username, password, domain, etc.)
38
+ */
27
39
  account: SipConfigs['account'];
28
40
  } & {
29
41
  [P in Exclude<keyof SipConfigs, 'account'>]?: Partial<SipConfigs[P]>;
@@ -36,3 +48,48 @@ export interface SipContextTransportType {
36
48
  }
37
49
  export type CallbackFunction<T = any> = (value?: T) => void;
38
50
  export type CallType = 'audio' | 'video' | 'conferenceAudio' | 'conferenceVideo' | 'transferAudio' | 'transferVideo';
51
+ /**
52
+ * Wrapper for a SIP account + its active UserAgent instance.
53
+ */
54
+ export interface SipManagerInstance {
55
+ config: SipManagerConfig;
56
+ instance: SipInitializer;
57
+ }
58
+ /**
59
+ * Keys that can resolve an account:
60
+ * - `configKey` → explicit instance key
61
+ * - `lineKey` → active line identifier
62
+ */
63
+ export type GetAccountKey = {
64
+ configKey: SipManagerConfig['key'];
65
+ lineKey?: never;
66
+ } | {
67
+ lineKey: LineType['lineKey'];
68
+ configKey?: never;
69
+ };
70
+ /**
71
+ * Keys that can resolve session control methods:
72
+ * - `configKey` → explicit instance key
73
+ * - `lineKey` → active line identifier
74
+ */
75
+ export type GetMethodsKey = {
76
+ configKey: SipManagerConfig['key'];
77
+ lineKey?: never;
78
+ } | {
79
+ lineKey: LineType['lineKey'];
80
+ configKey?: never;
81
+ };
82
+ /**
83
+ * Keys for resolving lines/sessions (mutually exclusive).
84
+ * - `configKey` & `remoteNumber` → explicit instance key and peer phone number(aka remoteNumber)
85
+ * - `lineKey` → active line identifier
86
+ */
87
+ export type LineLookup = {
88
+ lineKey: LineType['lineKey'];
89
+ remoteNumber?: never;
90
+ configKey?: never;
91
+ } | {
92
+ configKey: SipConfigs['key'];
93
+ remoteNumber: SipSessionDataType['remoteNumber'];
94
+ lineKey?: never;
95
+ };
@@ -0,0 +1 @@
1
+ export declare const generateUUID: () => string;
@@ -1,5 +1,5 @@
1
- import { SipAccountConfig } from '../../configs/types';
2
- export declare const getMediaDevices: (username: SipAccountConfig["username"]) => Promise<{
1
+ import { SipConfigs } from '../../configs/types';
2
+ export declare const getMediaDevices: (configKey: SipConfigs["key"]) => Promise<{
3
3
  hasAudioDevice: boolean;
4
4
  audioInputDevices: MediaDeviceInfo[];
5
5
  hasSpeakerDevice: boolean;
@@ -3,3 +3,4 @@ export * from './dayjs';
3
3
  export * from './deepMerge';
4
4
  export * from './utcDateNow';
5
5
  export * from './getMediaDevices';
6
+ export * from './generateUUID';