react-sip-kit 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +107 -0
  3. package/dist/components/audio/index.d.ts +7 -0
  4. package/dist/components/index.d.ts +2 -0
  5. package/dist/components/video/index.d.ts +13 -0
  6. package/dist/configs/index.d.ts +12 -0
  7. package/dist/configs/types.d.ts +111 -0
  8. package/dist/constructors/audioBlobs.d.ts +13 -0
  9. package/dist/constructors/buddy.d.ts +26 -0
  10. package/dist/constructors/index.d.ts +3 -0
  11. package/dist/constructors/line.d.ts +12 -0
  12. package/dist/events/registration/index.d.ts +15 -0
  13. package/dist/events/transport/index.d.ts +5 -0
  14. package/dist/hooks/index.d.ts +2 -0
  15. package/dist/hooks/useDetectDevices/index.d.ts +1 -0
  16. package/dist/hooks/useSessionEvents/index.d.ts +18 -0
  17. package/dist/hooks/useSessionEvents/types.d.ts +13 -0
  18. package/dist/hooks/useSessionMethods/index.d.ts +21 -0
  19. package/dist/hooks/useSessionMethods/types.d.ts +31 -0
  20. package/dist/hooks/useSpdOptions/index.d.ts +27 -0
  21. package/dist/index.cjs +19616 -0
  22. package/dist/index.d.ts +378 -0
  23. package/dist/index.mjs +19611 -0
  24. package/dist/methods/initialization/index.d.ts +3 -0
  25. package/dist/methods/registration/index.d.ts +3 -0
  26. package/dist/methods/session/index.d.ts +2 -0
  27. package/dist/provider.d.ts +5 -0
  28. package/dist/store/index.d.ts +28 -0
  29. package/dist/store/types.d.ts +149 -0
  30. package/dist/types.d.ts +49 -0
  31. package/dist/utils/dayjs.d.ts +3 -0
  32. package/dist/utils/deepMerge.d.ts +1 -0
  33. package/dist/utils/formatDuration.d.ts +1 -0
  34. package/dist/utils/index.d.ts +4 -0
  35. package/dist/utils/utcDateNow.d.ts +1 -0
  36. package/package.json +98 -0
@@ -0,0 +1,3 @@
1
+ import { CallbackFunction } from '../../types';
2
+ export declare function detectDevices(callback: CallbackFunction<MediaDeviceInfo[]>): void;
3
+ export declare function getMediaPermissions(media?: 'audio' | 'video'): Promise<MediaStream>;
@@ -0,0 +1,3 @@
1
+ import { SipUserAgent } from '../../types';
2
+ export declare function Register(userAgent?: SipUserAgent): void;
3
+ export declare function Unregister(skipUnsubscribe?: boolean, userAgent?: SipUserAgent): void;
@@ -0,0 +1,2 @@
1
+ import { LineType } from '../../store/types';
2
+ export declare function teardownSession(lineObj: LineType): void;
@@ -0,0 +1,5 @@
1
+ import { SipContextType, SipProviderProps } from './types';
2
+ import React from 'react';
3
+ export declare const SipContext: React.Context<SipContextType | undefined>;
4
+ export declare const SipProvider: React.FC<SipProviderProps>;
5
+ export declare const useSipProvider: () => SipContextType;
@@ -0,0 +1,28 @@
1
+ import { SipConfigs } from '../configs/types';
2
+ import { SipStoreStateType } from './types';
3
+ export declare const useSipStore: import("zustand").UseBoundStore<import("zustand").StoreApi<SipStoreStateType>>;
4
+ /**
5
+ *
6
+ * Set sip store for none functional components
7
+ */
8
+ export declare const setSipStore: (state: Partial<SipStoreStateType>) => void;
9
+ /**
10
+ *
11
+ * Get sip store for none functional components
12
+ */
13
+ export declare const getSipStore: () => SipStoreStateType;
14
+ /**
15
+ *
16
+ * Get sip store userAgent for none functional components
17
+ */
18
+ export declare const getSipStoreUserAgent: () => SipStoreStateType["userAgent"];
19
+ /**
20
+ *
21
+ * Get sip store configs for none functional components
22
+ */
23
+ export declare const getSipStoreConfigs: () => SipConfigs;
24
+ /**
25
+ *
26
+ * Init sip store for none functional components
27
+ */
28
+ export declare const initSipStore: () => void;
@@ -0,0 +1,149 @@
1
+ import { SipConfigs } from '../configs/types';
2
+ import { AudioBlobs } from '../constructors';
3
+ import { SipUserAgent } from '../types';
4
+ import { Dayjs } from 'dayjs';
5
+ import { Invitation, Inviter, Session, SessionDescriptionHandler, SessionDescriptionHandlerOptions } from 'sip.js';
6
+ import { IncomingInviteRequest } from 'sip.js/lib/core';
7
+ export interface SipStoreStateType {
8
+ configs: SipConfigs;
9
+ userAgent?: SipUserAgent;
10
+ buddies: Array<BuddyType>;
11
+ selectedBuddy: Array<any>;
12
+ selectedLine: Array<any>;
13
+ lines: Array<LineType>;
14
+ newLineNumber: number;
15
+ SipUsername: string;
16
+ SipDomain: string;
17
+ audioBlobs: AudioBlobs['audioBlobs'];
18
+ devicesInfo: DevicesInfoType;
19
+ setSipStore: (state: Partial<SipStoreStateType>) => void;
20
+ setUserAgent: (userAgent: SipStoreStateType['userAgent']) => void;
21
+ addLine: (line: LineType) => void;
22
+ updateLine: (line: LineType) => void;
23
+ removeLine: (lineNum: LineType['lineNumber']) => void;
24
+ addBuddy: (buddy: BuddyType) => void;
25
+ findBuddyByDid: (did: string) => BuddyType | null;
26
+ findBuddyByIdentity: (indentity: BuddyType['identity']) => BuddyType | null;
27
+ findLineByNumber: (lineNum: LineType['lineNumber']) => LineType | null;
28
+ getSession: (did: string) => SipSessionType | null;
29
+ getSessions: () => SipUserAgent['sessions'] | null;
30
+ countSessions: (id: string) => number;
31
+ }
32
+ export interface SipInvitationType extends Omit<Invitation, 'incomingInviteRequest' | 'sessionDescriptionHandler'> {
33
+ data: Partial<SipSessionDataType>;
34
+ incomingInviteRequest: IncomingInviteRequest;
35
+ sessionDescriptionHandler: SipSessionDescriptionHandler;
36
+ sessionDescriptionHandlerOptionsReInvite: SipSessionDescriptionHandlerOptions;
37
+ isOnHold: boolean;
38
+ }
39
+ export interface SipSessionDescriptionHandlerOptions extends SessionDescriptionHandlerOptions {
40
+ hold: boolean;
41
+ }
42
+ export interface SipInviterType extends Inviter {
43
+ data: Partial<SipSessionDataType>;
44
+ sessionDescriptionHandler: SipSessionDescriptionHandler;
45
+ sessionDescriptionHandlerOptionsReInvite: SipSessionDescriptionHandlerOptions;
46
+ isOnHold: boolean;
47
+ }
48
+ export interface SipSessionDescriptionHandler extends SessionDescriptionHandler {
49
+ peerConnection: RTCPeerConnection;
50
+ peerConnectionDelegate: any;
51
+ }
52
+ export interface LineType {
53
+ lineNumber: number;
54
+ DisplayName: string;
55
+ DisplayNumber: string;
56
+ IsSelected: boolean;
57
+ BuddyObj: BuddyType | null;
58
+ sipSession: SipInvitationType | SipInviterType | null;
59
+ LocalSoundMeter: any;
60
+ RemoteSoundMeter: any;
61
+ }
62
+ export interface SipSessionType extends Session {
63
+ data: SipSessionDataType;
64
+ }
65
+ export interface SipSessionDataType {
66
+ line: number;
67
+ calldirection: 'inbound' | 'outbound';
68
+ terminateby: string;
69
+ src: string;
70
+ buddyId: string;
71
+ callstart: string;
72
+ earlyReject: boolean;
73
+ withvideo: boolean;
74
+ reasonCode: number;
75
+ reasonText: string;
76
+ teardownComplete: boolean;
77
+ childsession: SipSessionType | null;
78
+ startTime: Dayjs;
79
+ started: boolean;
80
+ hold: Array<{
81
+ event: 'hold' | 'unhold';
82
+ eventTime: string;
83
+ }>;
84
+ isHold: boolean;
85
+ mute: Array<{
86
+ event: 'mute' | 'unmute';
87
+ eventTime: string;
88
+ }>;
89
+ isMute: boolean;
90
+ videoChannelNames: Array<Record<'mid' | 'channel', string>>;
91
+ dst: string;
92
+ transfer: Array<SipSessionTransferType>;
93
+ AudioSourceTrack: any;
94
+ earlyMedia: any;
95
+ ringerObj: {
96
+ [key: string]: any;
97
+ } | null;
98
+ ConfbridgeChannels: Array<any>;
99
+ ConfbridgeEvents: Array<any>;
100
+ videoSourceDevice: string | null;
101
+ audioSourceDevice: string | null;
102
+ audioOutputDevice: string | null;
103
+ }
104
+ export interface SipSessionTransferType {
105
+ type: 'Attended' | 'Blind';
106
+ to: number;
107
+ transferTime: string;
108
+ disposition: string;
109
+ dispositionTime: string;
110
+ accept: {
111
+ complete: boolean | null;
112
+ eventTime: string | null;
113
+ disposition: string;
114
+ };
115
+ onCancle?: Function;
116
+ }
117
+ export interface BuddyType {
118
+ type: 'extension' | 'xmpp' | 'contact' | 'group';
119
+ identity: string;
120
+ CallerIDName: string;
121
+ ExtNo: string;
122
+ MobileNumber?: string;
123
+ ContactNumber1?: string;
124
+ ContactNumber2?: string;
125
+ lastActivity: string;
126
+ Desc: string;
127
+ Email: string;
128
+ jid?: string;
129
+ devState: string;
130
+ presence: string;
131
+ missed: number;
132
+ IsSelected: boolean;
133
+ imageObjectURL: string;
134
+ presenceText: string;
135
+ EnableDuringDnd: boolean;
136
+ EnableSubscribe: boolean;
137
+ SubscribeUser: string;
138
+ AllowAutoDelete: boolean;
139
+ Pinned: boolean;
140
+ }
141
+ interface DevicesInfoType {
142
+ hasVideoDevice: boolean;
143
+ hasAudioDevice: boolean;
144
+ hasSpeakerDevice: boolean;
145
+ audioInputDevices: any[];
146
+ videoInputDevices: any[];
147
+ speakerDevices: any[];
148
+ }
149
+ export {};
@@ -0,0 +1,49 @@
1
+ import { SipConfigs } from './configs/types';
2
+ import { reconnectTransport } from './events/transport';
3
+ import { useSessionMethods, useSessionEvents } from './hooks';
4
+ import { SipSessionType, SipStoreStateType } from './store/types';
5
+ import { UserAgent, Registerer, Subscriber } from 'sip.js';
6
+ export interface SipUserAgent extends UserAgent {
7
+ isReRegister: boolean;
8
+ isRegistered: () => boolean;
9
+ registerer: Registerer;
10
+ sessions: {
11
+ [id: string]: SipSessionType;
12
+ };
13
+ _sessions: {
14
+ [id: string]: SipSessionType;
15
+ };
16
+ registrationCompleted: boolean;
17
+ registering: boolean;
18
+ transport: UserAgent['transport'] & {
19
+ ReconnectionAttempts: number;
20
+ attemptingReconnection: boolean;
21
+ };
22
+ BlfSubs: any[];
23
+ lastVoicemailCount: number;
24
+ selfSub: Subscriber | null;
25
+ voicemailSub: Subscriber | null;
26
+ }
27
+ type SipProviderConfigs<T extends SipConfigs> = {
28
+ account: T['account'];
29
+ } & {
30
+ [P in Exclude<keyof T, 'account'>]?: Partial<T[P]>;
31
+ };
32
+ export interface SipProviderProps<T extends SipConfigs = SipConfigs> {
33
+ children: React.ReactNode;
34
+ configs: SipProviderConfigs<T>;
35
+ }
36
+ export interface SipContextType {
37
+ lines: SipStoreStateType['lines'];
38
+ session: SipContextSessionType;
39
+ transport: SipContextTransportType;
40
+ }
41
+ export interface SipContextSessionType {
42
+ methods: Omit<ReturnType<typeof useSessionMethods>, 'receiveCall'>;
43
+ events: ReturnType<typeof useSessionEvents>;
44
+ }
45
+ export interface SipContextTransportType {
46
+ reconnectTransport: typeof reconnectTransport;
47
+ }
48
+ export type CallbackFunction<T> = (value?: T) => void;
49
+ export {};
@@ -0,0 +1,3 @@
1
+ import dayjs from 'dayjs';
2
+ declare const dayJs: typeof dayjs;
3
+ export { dayJs };
@@ -0,0 +1 @@
1
+ export declare function deepMerge<T extends object>(target: T, source: Partial<T>): T;
@@ -0,0 +1 @@
1
+ export declare const formatDuration: (seconds: number) => string;
@@ -0,0 +1,4 @@
1
+ export * from './formatDuration';
2
+ export * from './dayjs';
3
+ export * from './deepMerge';
4
+ export * from './utcDateNow';
@@ -0,0 +1 @@
1
+ export declare function utcDateNow(): string;
package/package.json ADDED
@@ -0,0 +1,98 @@
1
+ {
2
+ "name": "react-sip-kit",
3
+ "private": false,
4
+ "version": "0.2.0",
5
+ "type": "module",
6
+ "author": {
7
+ "name": "Shervin Ghajar",
8
+ "email": "ssghajar.work@gmail.com"
9
+ },
10
+ "homepage": "https://github.com/shervin-ghajar/react-sip-kit#readme",
11
+ "keywords": [
12
+ "react",
13
+ "sip",
14
+ "sipjs",
15
+ "jssip",
16
+ "voip",
17
+ "communication",
18
+ "webRTC",
19
+ "telephony",
20
+ "react-hooks",
21
+ "sip.js",
22
+ "react-sip",
23
+ "react-sip-provider",
24
+ "real-time",
25
+ "session-initiation-protocol",
26
+ "frontend",
27
+ "javascript",
28
+ "typescript",
29
+ "npm",
30
+ "library",
31
+ "utility",
32
+ "responsive",
33
+ "design",
34
+ "state-management",
35
+ "zustand"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/shervin-ghajar/react-sip-kit.git"
40
+ },
41
+ "license": "MIT",
42
+ "main": "dist/index.cjs",
43
+ "module": "dist/index.mjs",
44
+ "types": "dist/index.d.ts",
45
+ "exports": {
46
+ ".": {
47
+ "import": "./dist/index.mjs",
48
+ "require": "./dist/index.cjs",
49
+ "types": "./dist/index.d.ts"
50
+ }
51
+ },
52
+ "scripts": {
53
+ "build": "rollup -c",
54
+ "lint": "eslint .",
55
+ "format": "prettier --write --cache . --plugin=prettier-plugin-organize-imports"
56
+ },
57
+ "dependencies": {
58
+ "clone": "^2.1.2",
59
+ "dayjs": "^1.11.13",
60
+ "sip.js": "0.21.2",
61
+ "uuid": "^11.0.3",
62
+ "zustand": "^5.0.1"
63
+ },
64
+ "devDependencies": {
65
+ "react-dom": "18.3.1",
66
+ "@eslint/js": "9.13.0",
67
+ "prettier-plugin-organize-imports": "^4.1.0",
68
+ "@trivago/prettier-plugin-sort-imports": "^4.3.0",
69
+ "@types/clone": "^2.1.4",
70
+ "@types/react": "18.3.12",
71
+ "@types/react-dom": "18.3.1",
72
+ "@typescript-eslint/eslint-plugin": "^8.15.0",
73
+ "@typescript-eslint/parser": "^8.15.0",
74
+ "eslint": "^9.15.0",
75
+ "eslint-config-prettier": "^9.1.0",
76
+ "eslint-plugin-prettier": "^5.2.1",
77
+ "eslint-plugin-react-hooks": "5.0.0",
78
+ "eslint-plugin-react-refresh": "0.4.14",
79
+ "globals": "15.11.0",
80
+ "prettier": "^3.3.3",
81
+ "typescript": "~5.6.2",
82
+ "typescript-eslint": "8.11.0",
83
+ "@rollup/plugin-commonjs": "^28.0.3",
84
+ "@rollup/plugin-node-resolve": "^16.0.1",
85
+ "@rollup/plugin-typescript": "^12.1.2",
86
+ "rollup": "^4.41.1",
87
+ "rollup-plugin-delete": "^3.0.1",
88
+ "rollup-plugin-dts": "^6.2.1"
89
+ },
90
+ "peerDependencies": {
91
+ "react": ">=17.0.0"
92
+ },
93
+ "files": [
94
+ "dist",
95
+ "README.md",
96
+ "LICENSE"
97
+ ]
98
+ }