react-sip-kit 0.2.3 โ 0.3.62
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.
- package/LICENSE +21 -21
- package/README.md +144 -105
- package/dist/components/audio/index.d.ts +12 -4
- package/dist/components/video/index.d.ts +2 -0
- package/dist/configs/types.d.ts +2 -2
- package/dist/constructors/line.d.ts +2 -3
- package/dist/events/transport/index.d.ts +3 -3
- package/dist/hooks/useGetMediaDevices/index.d.ts +10 -0
- package/dist/hooks/useSessionEvents/index.d.ts +2 -2
- package/dist/hooks/useSessionMethods/index.d.ts +14 -8
- package/dist/index.cjs +1 -10
- package/dist/index.d.ts +5 -343
- package/dist/index.mjs +1 -10
- package/dist/methods/initialization/index.d.ts +1 -2
- package/dist/methods/registration/index.d.ts +3 -3
- package/dist/methods/session/index.d.ts +9 -0
- package/dist/methods/session/type.d.ts +16 -0
- package/dist/provider.d.ts +2 -3
- package/dist/store/types.d.ts +25 -15
- package/dist/types.d.ts +8 -7
- package/package.json +98 -98
- package/dist/hooks/useDetectDevices/index.d.ts +0 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Shervin Ghajar
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Shervin Ghajar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,105 +1,144 @@
|
|
|
1
|
-
# react-sip-kit
|
|
2
|
-
|
|
3
|
-
A modern
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Features
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install react-sip-kit
|
|
25
|
-
# or
|
|
26
|
-
yarn add react-sip-kit
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## Usage
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
domain: 'sip.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
1
|
+
# react-sip-kit
|
|
2
|
+
|
|
3
|
+
A modern **React SIP.js toolkit** for building web-based softphones and SIP clients.
|
|
4
|
+
Supports **audio/video calls**, **recording**, **screen sharing**, and **device management** โ all with a clean, extensible architecture.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## โจ Features
|
|
9
|
+
|
|
10
|
+
* ๐ **Audio & Video Calls** โ with automatic device detection
|
|
11
|
+
* ๐ฅ **Video support** โ manage local & remote streams seamlessly
|
|
12
|
+
* ๐ด **Call Recording** โ audio and video recording out of the box
|
|
13
|
+
* ๐ฅ๏ธ **Screen Sharing** โ during video calls
|
|
14
|
+
* ๐ง **Device Management** โ select audio/video input & output devices
|
|
15
|
+
* ๐ **Multi-line Support** โ handle multiple concurrent calls
|
|
16
|
+
* โก **TypeScript-first** โ fast, modular, type-safe APIs
|
|
17
|
+
* ๐ ๏ธ **Configurable & Extensible** โ tailor to your SIP setup
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## ๐ฆ Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install react-sip-kit
|
|
25
|
+
# or
|
|
26
|
+
yarn add react-sip-kit
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## ๐ Basic Usage
|
|
32
|
+
|
|
33
|
+
### 1. Wrap your app with `SipProvider`
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { SipProvider } from 'react-sip-kit';
|
|
37
|
+
|
|
38
|
+
<SipProvider
|
|
39
|
+
configs={{
|
|
40
|
+
account: {
|
|
41
|
+
domain: 'your.sip.domain',
|
|
42
|
+
username: 'your-username',
|
|
43
|
+
password: 'your-password',
|
|
44
|
+
wssServer: 'your.sip.domain',
|
|
45
|
+
webSocketPort: '8089',
|
|
46
|
+
serverPath: '/ws',
|
|
47
|
+
},
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<App />
|
|
51
|
+
</SipProvider>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### 2. Make calls with hooks
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { useSipProvider, useSessionMethods } from 'react-sip-kit';
|
|
60
|
+
|
|
61
|
+
function DialPad() {
|
|
62
|
+
const { status } = useSipProvider();
|
|
63
|
+
const { dialByNumber } = useSessionMethods();
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<p>Status: {status}</p>
|
|
68
|
+
<button onClick={() => dialByNumber('audio', '1012')}>Call 1012</button>
|
|
69
|
+
<button onClick={() => dialByNumber('video', '1012')}>Video Call 1012</button>
|
|
70
|
+
</>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### 3. Render media streams
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { VideoStream, AudioStream } from 'react-sip-kit';
|
|
81
|
+
|
|
82
|
+
<VideoStream type="local" lineNumber={1} />
|
|
83
|
+
<VideoStream type="remote" lineNumber={1} />
|
|
84
|
+
<AudioStream type="local" lineNumber={1} />
|
|
85
|
+
<AudioStream type="remote" lineNumber={1} />
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## โ๏ธ Configuration
|
|
91
|
+
|
|
92
|
+
All SIP and media settings can be customized via the `configs` prop.
|
|
93
|
+
See [types.ts](https://github.com/shervin-ghajar/react-sip-kit/blob/main/src/configs/types.ts) for the full options.
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
{
|
|
97
|
+
account: { ... },
|
|
98
|
+
features: { enableVideo: true },
|
|
99
|
+
media: { audioInputDeviceId: 'default' },
|
|
100
|
+
registration: { registerExpires: 3600 },
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## ๐ก Best Practices
|
|
107
|
+
|
|
108
|
+
* Use hooks (`useSipProvider`, `useSessionMethods`) for SIP state & actions.
|
|
109
|
+
* Render media components only for active calls.
|
|
110
|
+
* Handle device permissions and selection gracefully.
|
|
111
|
+
* Reinitialize streams with `initiateRemoteMediaStreams` or `initiateLocalMediaStreams` if `<video>`/`<audio>` is rendered after the call starts.
|
|
112
|
+
* Prefer TypeScript for better DX and safety.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## ๐งโ๐ป Full Example
|
|
117
|
+
|
|
118
|
+
A full working demo (with call controls, transfer, hold, recording, etc.) is available in the
|
|
119
|
+
[`/example`](https://github.com/shervin-ghajar/react-sip-kit/tree/main/example) folder of this repo.
|
|
120
|
+
|
|
121
|
+
This example demonstrates:
|
|
122
|
+
|
|
123
|
+
* Multi-line SIP handling
|
|
124
|
+
* Answering/rejecting calls
|
|
125
|
+
* Call transfer, hold, mute
|
|
126
|
+
* Recording and screen sharing
|
|
127
|
+
* Local/remote audio & video streams
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## ๐ License
|
|
132
|
+
|
|
133
|
+
MIT License
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## ๐ค Author
|
|
138
|
+
|
|
139
|
+
**Shervin Ghajar**
|
|
140
|
+
|
|
141
|
+
* GitHub: [@shervin-ghajar](https://github.com/shervin-ghajar)
|
|
142
|
+
* NPM: [react-sip-kit](https://www.npmjs.com/package/react-sip-kit)
|
|
143
|
+
* Repository: [react-sip-kit](https://github.com/shervin-ghajar/react-sip-kit)
|
|
144
|
+
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { AudioHTMLAttributes } from 'react';
|
|
2
|
-
interface
|
|
1
|
+
import { AudioHTMLAttributes, HTMLAttributes } from 'react';
|
|
2
|
+
interface DefaultAudioProps {
|
|
3
3
|
lineNumber: string | number;
|
|
4
|
-
type?: 'transfer' | 'conference';
|
|
5
4
|
}
|
|
6
|
-
|
|
5
|
+
interface LocalAudioProps extends AudioHTMLAttributes<HTMLAudioElement>, DefaultAudioProps {
|
|
6
|
+
type: 'local';
|
|
7
|
+
id?: `line-${number}-${LocalAudioProps['type']}Audio`;
|
|
8
|
+
}
|
|
9
|
+
interface RemoteAudioProps extends HTMLAttributes<HTMLDivElement>, DefaultAudioProps {
|
|
10
|
+
type: 'remote';
|
|
11
|
+
id?: `line-${number}-remoteAudios`;
|
|
12
|
+
}
|
|
13
|
+
type AudioProps = LocalAudioProps | RemoteAudioProps;
|
|
14
|
+
export declare const Audio: ({ lineNumber, ...rest }: AudioProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
15
|
export {};
|
|
@@ -4,9 +4,11 @@ interface DefaultVideoProps {
|
|
|
4
4
|
}
|
|
5
5
|
interface LocalVideoProps extends VideoHTMLAttributes<HTMLVideoElement>, DefaultVideoProps {
|
|
6
6
|
type: 'local';
|
|
7
|
+
id?: `line-${number}-${LocalVideoProps['type']}Video` | `line-${number}-remoteVideos`;
|
|
7
8
|
}
|
|
8
9
|
interface RemoteVidepProps extends HTMLAttributes<HTMLDivElement>, DefaultVideoProps {
|
|
9
10
|
type: 'remote';
|
|
11
|
+
id?: `line-${number}-${RemoteVidepProps['type']}Video` | `line-${number}-remoteVideos`;
|
|
10
12
|
}
|
|
11
13
|
type VideoProps = LocalVideoProps | RemoteVidepProps;
|
|
12
14
|
export declare const Video: ({ lineNumber, ...rest }: VideoProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/configs/types.d.ts
CHANGED
|
@@ -36,8 +36,8 @@ export interface SipAdvancedConfig {
|
|
|
36
36
|
chatEngine: string;
|
|
37
37
|
}
|
|
38
38
|
export interface SipRecordingConfig {
|
|
39
|
-
videoResampleSize:
|
|
40
|
-
recordingVideoSize:
|
|
39
|
+
videoResampleSize: 'HD' | 'FHD';
|
|
40
|
+
recordingVideoSize: 'HD' | 'FHD';
|
|
41
41
|
recordingVideoFps: number;
|
|
42
42
|
recordingLayout: string;
|
|
43
43
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { LineType, SipInvitationType } from '../store/types';
|
|
2
|
-
export declare class Line
|
|
2
|
+
export declare class Line implements LineType {
|
|
3
3
|
lineNumber: number;
|
|
4
4
|
displayNumber: string;
|
|
5
|
-
metaData: Partial<T>;
|
|
6
5
|
sipSession: SipInvitationType | null;
|
|
7
6
|
localSoundMeter: any;
|
|
8
7
|
remoteSoundMeter: any;
|
|
9
|
-
constructor(lineNumber: number, displayNumber: string
|
|
8
|
+
constructor(lineNumber: number, displayNumber: string);
|
|
10
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SipUserAgent } from '../../types';
|
|
2
|
-
export declare function onTransportConnected(userAgent?: SipUserAgent): void;
|
|
3
|
-
export declare function onTransportConnectError(error:
|
|
2
|
+
export declare function onTransportConnected(userAgent?: SipUserAgent | undefined): void;
|
|
3
|
+
export declare function onTransportConnectError(error: Error, userAgent?: SipUserAgent | undefined): void;
|
|
4
4
|
export declare function onTransportDisconnected(userAgent: SipUserAgent): void;
|
|
5
|
-
export declare function reconnectTransport(userAgent?: SipUserAgent): void;
|
|
5
|
+
export declare function reconnectTransport(userAgent?: SipUserAgent | undefined): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const useGetMediaDevices: () => {
|
|
2
|
+
getDevices: () => Promise<{
|
|
3
|
+
hasAudioDevice: boolean;
|
|
4
|
+
audioInputDevices: MediaDeviceInfo[];
|
|
5
|
+
hasSpeakerDevice: boolean;
|
|
6
|
+
speakerDevices: MediaDeviceInfo[];
|
|
7
|
+
hasVideoDevice: boolean;
|
|
8
|
+
videoInputDevices: MediaDeviceInfo[];
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
@@ -4,7 +4,7 @@ import { Bye, Message } from 'sip.js';
|
|
|
4
4
|
import { IncomingRequestMessage, IncomingResponse } from 'sip.js/lib/core';
|
|
5
5
|
export declare const useSessionEvents: () => {
|
|
6
6
|
onInviteCancel: (lineObj: LineType, response: IncomingRequestMessage, callback?: CallbackFunction<any>) => void;
|
|
7
|
-
onInviteAccepted: (lineObj: LineType,
|
|
7
|
+
onInviteAccepted: (lineObj: LineType, videoEnabled: boolean, response?: IncomingResponse) => Promise<void>;
|
|
8
8
|
onInviteTrying: (lineObj: LineType, response: IncomingResponse) => void;
|
|
9
9
|
onInviteProgress: (lineObj: LineType, response: IncomingResponse) => void;
|
|
10
10
|
onInviteRejected: (lineObj: LineType, response: IncomingResponse, callback?: CallbackFunction<any>) => void;
|
|
@@ -13,6 +13,6 @@ export declare const useSessionEvents: () => {
|
|
|
13
13
|
onSessionReinvited: (lineObj: LineType, response: IncomingRequestMessage) => void;
|
|
14
14
|
onSessionReceivedMessage: (lineObj: LineType, response: Message) => void;
|
|
15
15
|
onSessionDescriptionHandlerCreated: (lineObj: LineType, sdh: SipSessionDescriptionHandler, provisional: boolean, includeVideo?: boolean) => void;
|
|
16
|
-
onTrackAddedEvent: (lineObj: LineType,
|
|
16
|
+
onTrackAddedEvent: (lineObj: LineType, videoEnabled?: boolean) => Promise<void>;
|
|
17
17
|
onTransferSessionDescriptionHandlerCreated: (lineObj: LineType, session: SipSessionType, sdh: SipSessionDescriptionHandler, includeVideo?: boolean) => void;
|
|
18
18
|
};
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { LineType, SipInvitationType } from '../../store/types';
|
|
2
|
+
import { CallType } from '../../types';
|
|
2
3
|
export declare const useSessionMethods: () => {
|
|
3
|
-
|
|
4
|
+
receiveSession: (invitation: SipInvitationType) => void;
|
|
4
5
|
answerAudioSession: (lineNumber: LineType["lineNumber"]) => void;
|
|
5
|
-
answerVideoSession: (lineNumber: LineType["lineNumber"]) => void;
|
|
6
|
+
answerVideoSession: (lineNumber: LineType["lineNumber"], enableVideo?: boolean) => void;
|
|
6
7
|
makeAudioSession: (lineObj: LineType, dialledNumber: string, extraHeaders?: Array<string>) => void;
|
|
7
8
|
makeVideoSession: (lineObj: LineType, dialledNumber: string, extraHeaders?: Array<string>) => void;
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
toggleLocalVideoTrack: (lineNumber: LineType["lineNumber"]) => Promise<void>;
|
|
10
|
+
toggleShareScreen: (lineNumber: LineType["lineNumber"]) => Promise<void>;
|
|
11
|
+
rejectSession: (lineNumber: LineType["lineNumber"]) => void;
|
|
12
|
+
dialByNumber: (type: Extract<CallType, "audio" | "video">, dialNumber: string, extraHeaders?: Array<string>) => void;
|
|
13
|
+
makeConferenceSession: (lineObj: LineType, extraHeaders?: Array<string>) => void;
|
|
10
14
|
endSession: (lineNumber: LineType["lineNumber"]) => void;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
recordSession: (lineNumber: LineType["lineNumber"]) => {
|
|
16
|
+
start: () => Promise<void>;
|
|
17
|
+
stop: () => void;
|
|
18
|
+
};
|
|
19
|
+
toggleMuteSession: (lineNumber: LineType["lineNumber"]) => void;
|
|
20
|
+
toggleHoldSession: (lineNumber: LineType["lineNumber"], forcedValue?: boolean) => Promise<void>;
|
|
15
21
|
cancelSession: (lineNumber: LineType["lineNumber"]) => void;
|
|
16
22
|
startTransferSession: (lineNumber: LineType["lineNumber"]) => void;
|
|
17
23
|
cancelTransferSession: (lineNumber: LineType["lineNumber"]) => void;
|