drachtio-srf 4.5.39 → 4.5.40
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/.github/workflows/ci.yml +8 -3
- package/lib/@types/index.d.ts +139 -138
- package/package.json +1 -1
package/.github/workflows/ci.yml
CHANGED
|
@@ -6,12 +6,17 @@ jobs:
|
|
|
6
6
|
build:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
steps:
|
|
9
|
-
- uses: actions/checkout@
|
|
10
|
-
- uses: actions/setup-node@
|
|
9
|
+
- uses: actions/checkout@v4
|
|
10
|
+
- uses: actions/setup-node@v4
|
|
11
11
|
with:
|
|
12
|
-
node-version:
|
|
12
|
+
node-version: 20.x
|
|
13
13
|
- run: npm install
|
|
14
14
|
- run: npm run jslint
|
|
15
|
+
- name: Install Docker Compose
|
|
16
|
+
run: |
|
|
17
|
+
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
18
|
+
sudo chmod +x /usr/local/bin/docker-compose
|
|
19
|
+
docker-compose --version
|
|
15
20
|
- run: npm test
|
|
16
21
|
|
|
17
22
|
|
package/lib/@types/index.d.ts
CHANGED
|
@@ -2,154 +2,155 @@ declare module 'drachtio-srf' {
|
|
|
2
2
|
import { Socket } from 'net';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
namespace Srf {
|
|
6
|
+
type SipMethod = 'ACK' | 'BYE' | 'CANCEL' | 'INFO' | 'INVITE' | 'MESSAGE' | 'NOTIFY' | 'OPTIONS' | 'PRACK' | 'PUBLISH' | 'REFER' | 'REGISTER' | 'SUBSCRIBE' | 'UPDATE';
|
|
7
|
+
type SipMessageHeaders = Record<string, string>;
|
|
8
|
+
type AOR = { name: string; uri: string; params?: Record<string, any>; };
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export interface SrfConfig {
|
|
11
|
+
apiSecret?: string;
|
|
12
|
+
host?: string;
|
|
13
|
+
port?: number;
|
|
14
|
+
secret?: string;
|
|
15
|
+
}
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
export function parseUri(uri: string): { user: string; host: string; params?: Record<string, any>; };
|
|
18
|
+
export function stringifyUri(uri: object): string;
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
export interface SipMessage {
|
|
21
|
+
type: "request" | "response";
|
|
22
|
+
body: string;
|
|
23
|
+
payload: object[];
|
|
24
|
+
source: "network" | "application";
|
|
25
|
+
source_address: string;
|
|
26
|
+
source_port: string;
|
|
27
|
+
protocol: string;
|
|
28
|
+
stackTime: string;
|
|
29
|
+
calledNumber: string;
|
|
30
|
+
callingNumber: string;
|
|
31
|
+
raw: string;
|
|
32
|
+
get(name: string): string;
|
|
33
|
+
has(name: string): boolean;
|
|
34
|
+
set(name: string, value: string);
|
|
35
|
+
getParsedHeader(name: "contact" | "Contact"): Array<AOR>;
|
|
36
|
+
getParsedHeader(name: "via" | "Via"): Array<Via>;
|
|
37
|
+
getParsedHeader(name: "To" | "to" | "From" | "from" | "refer-to" | "referred-by" | "p-asserted-identity" | "remote-party-id"): AOR;
|
|
38
|
+
getParsedHeader(name: string): string;
|
|
39
|
+
}
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
export interface SrfRequest extends SipMessage {
|
|
42
|
+
method: SipMethod;
|
|
43
|
+
isNewInvite(): boolean
|
|
44
|
+
cancel(callback: () => {})
|
|
45
|
+
branch: string;
|
|
46
|
+
callId: string;
|
|
47
|
+
from: string;
|
|
48
|
+
headers: Record<string, string>;
|
|
49
|
+
msg: any;
|
|
50
|
+
sdp: string;
|
|
51
|
+
srf: any;
|
|
52
|
+
to: string;
|
|
53
|
+
uri: string;
|
|
54
|
+
registration?: {
|
|
55
|
+
type: "unregister" | "register";
|
|
56
|
+
expires: number;
|
|
57
|
+
contact: Array<AOR>;
|
|
58
|
+
aor: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
export interface SrfResponse extends SipMessage {
|
|
63
|
+
status: number;
|
|
64
|
+
statusCode: number;
|
|
65
|
+
reason: string;
|
|
66
|
+
finalResponseSent: boolean;
|
|
67
|
+
send(status: number);
|
|
68
|
+
send(status: number, opts: object);
|
|
69
|
+
send(status: number, reason: string, opts: object);
|
|
70
|
+
send(status: number, reason: string, opts: object, callback: (err, msg) => {});
|
|
71
|
+
end();
|
|
72
|
+
}
|
|
72
73
|
|
|
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
|
-
}
|
|
74
|
+
export interface Dialog {
|
|
75
|
+
sip: { callId: string; localTag: string; remoteTag: string; };
|
|
76
|
+
onHold: boolean;
|
|
77
|
+
other: Dialog;
|
|
78
|
+
type: "uac" | "uas";
|
|
79
|
+
local: { uri: string; sdp: string; };
|
|
80
|
+
remote: { uri: string; sdp: string; };
|
|
81
|
+
req: SrfRequest;
|
|
82
|
+
destroy(opts?: { headers: Record<string, string>; }, callback?: (err, msg) => {}): void;
|
|
83
|
+
modify(sdp, callback?: (err: any, msg: SrfResponse) => void): void;
|
|
84
|
+
modify({ noAck: boolean }, callback?: (err: any, resp: any, resAck: any) => void): void;
|
|
85
|
+
on(messageType: "ack", callback: (msg: SrfRequest) => void): void;
|
|
86
|
+
on(messageType: "destroy", callback: (msg: SrfRequest) => void): void;
|
|
87
|
+
on(messageType: "info", callback: (req: SrfRequest, res: SrfResponse) => void): void;
|
|
88
|
+
on(messageType: "message", callback: (req: SrfRequest, res: SrfResponse) => void): void;
|
|
89
|
+
on(messageType: "modify", callback: (req: SrfRequest, res: SrfResponse) => void): void;
|
|
90
|
+
on(messageType: "notify", callback: (req: SrfRequest, res: SrfResponse) => void): void;
|
|
91
|
+
on(messageType: "options", callback: (req: SrfRequest, res: SrfResponse) => void): void;
|
|
92
|
+
on(messageType: "refer", callback: (req: SrfRequest, res: SrfResponse) => void): void;
|
|
93
|
+
on(messageType: "refresh", callback: (msg: SrfRequest) => void): void;
|
|
94
|
+
on(messageType: "update", callback: (req: SrfRequest, res: SrfResponse) => void): void;
|
|
95
|
+
on(messageType: "modify", callback: (req: SrfRequest, res: SrfResponse) => void): void;
|
|
96
|
+
once(messageType: string, callback: (msg: SrfResponse) => void): void;
|
|
97
|
+
listeners(messageType: string): any[];
|
|
98
|
+
request(opts?: { method: SipMethod; headers?: Record<string, string | number>; body?: string; }, callback?: (err, msg) => {});
|
|
99
|
+
}
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
export interface CreateUASOptions {
|
|
102
|
+
localSdp: string;
|
|
103
|
+
headers?: SipMessageHeaders;
|
|
104
|
+
}
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
export interface CreateUACOptions {
|
|
107
|
+
headers?: SipMessageHeaders;
|
|
108
|
+
uri?: string;
|
|
109
|
+
noAck?: boolean;
|
|
110
|
+
localSdp?: string;
|
|
111
|
+
proxy?: string;
|
|
112
|
+
auth?: { username: string; password: string; };
|
|
113
|
+
}
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
export interface CreateB2BUAOptions {
|
|
116
|
+
headers?: SipMessageHeaders;
|
|
117
|
+
responseHeaders?: SipMessageHeaders | ((uacRes: SipMessageHeaders, headers: SipMessageHeaders) => SipMessageHeaders | null);
|
|
118
|
+
localSdpA?: string | ((sdp: string, res: SrfResponse) => string | Promise<string>);
|
|
119
|
+
localSdpB?: string | ((sdp: string) => string | Promise<string>);
|
|
120
|
+
proxyRequestHeaders?: string[];
|
|
121
|
+
proxyResponseHeaders?: string[];
|
|
122
|
+
passFailure?: boolean;
|
|
123
|
+
passProvisionalResponses?: boolean;
|
|
124
|
+
proxy?: string;
|
|
125
|
+
auth?: { username: string; password: string; };
|
|
126
|
+
}
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
128
|
+
class Srf extends EventEmitter {
|
|
129
|
+
constructor();
|
|
130
|
+
constructor(tags: string | string[]);
|
|
131
|
+
connect(config?: SrfConfig): Promise<void>;
|
|
132
|
+
disconnect(): void;
|
|
133
|
+
use(callback: (req: SrfRequest, res: SrfResponse, next: Function) => void): void;
|
|
134
|
+
use(messageType: string, callback: (req: SrfRequest, res: SrfResponse, next: Function) => void): void;
|
|
135
|
+
invite(callback: (req: SrfRequest, res: SrfResponse) => void): void;
|
|
136
|
+
request(uri: string, opts, method, [body], callback?: (err, requestSent: SrfRequest) => void);
|
|
137
|
+
proxyRequest(req: SrfRequest, destination: string | string[], [opts], callback?: (err, results) => {}): void;
|
|
138
|
+
createUAS(req: SrfRequest, res: SrfResponse, opts: CreateUASOptions, callback?: (err, dialog: Dialog) => void): Promise<Dialog>;
|
|
139
|
+
createUAC(uri: string | CreateUACOptions, opts?: CreateUACOptions, progressCallbacks?: { cbRequest?: (req: SrfRequest) => void; cbProvisional?: (provisionalRes: SrfResponse) => void; }, callback?: (err, dialog: Dialog) => void): Promise<Dialog>;
|
|
140
|
+
createB2BUA(req: SrfRequest, res: SrfResponse, uri: string, opts: CreateB2BUAOptions, progressCallbacks?: { cbRequest?: (req: SrfRequest) => void; cbProvisional?: (provisionalRes: Response) => void; cbFinalizedUac?: (uac: Dialog) => void; }, callback?: (err, dialog: Dialog) => {}): Promise<{ uas: Dialog; uac: Dialog }>;
|
|
141
|
+
on(event: 'connect', listener: (err: Error, hostPort: string) => void): this;
|
|
142
|
+
on(event: 'error', listener: (err: Error) => void): this;
|
|
143
|
+
on(event: 'disconnect', listener: () => void): this;
|
|
144
|
+
on(event: 'message', listener: (req: SrfRequest, res: SrfResponse) => void): this;
|
|
145
|
+
on(event: 'request', listener: (req: SrfRequest, res: SrfResponse) => void): this;
|
|
146
|
+
on(event: 'register' | 'invite' | 'bye' | 'cancel' | 'ack' | 'info' | 'notify' | 'options' | 'prack' | 'publish' | 'refer' | 'subscribe' | 'update', listener: (req: SrfRequest, res: SrfResponse) => void): this;
|
|
147
|
+
on(event: 'cdr:attempt', listener: (source: string, time: string, msg: SipMessage) => void): this;
|
|
148
|
+
on(event: 'cdr:start', listener: (source: string, time: string, role: string, msg: SipMessage) => void): this;
|
|
149
|
+
on(event: 'cdr:stop', listener: (source: string, time: string, reason: string, msg: SipMessage) => void): this;
|
|
150
|
+
locals: {[name: string]: any};
|
|
151
|
+
socket: Socket;
|
|
152
|
+
}
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
export
|
|
155
|
+
export = Srf.Srf;
|
|
155
156
|
}
|