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.
@@ -6,12 +6,17 @@ jobs:
6
6
  build:
7
7
  runs-on: ubuntu-latest
8
8
  steps:
9
- - uses: actions/checkout@v3
10
- - uses: actions/setup-node@v3
9
+ - uses: actions/checkout@v4
10
+ - uses: actions/setup-node@v4
11
11
  with:
12
- node-version: lts/*
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
 
@@ -2,154 +2,155 @@ declare module 'drachtio-srf' {
2
2
  import { Socket } from 'net';
3
3
  import { EventEmitter } from 'events';
4
4
 
5
- type SipMethod = 'ACK' | 'BYE' | 'CANCEL' | 'INFO' | 'INVITE' | 'MESSAGE' | 'NOTIFY' | 'OPTIONS' | 'PRACK' | 'PUBLISH' | 'REFER' | 'REGISTER' | 'SUBSCRIBE' | 'UPDATE';
6
- type SipMessageHeaders = Record<string, string>;
7
- type AOR = { name: string; uri: string; params?: Record<string, any>; };
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
- export interface SrfConfig {
10
- apiSecret?: string;
11
- host?: string;
12
- port?: number;
13
- secret?: string;
14
- }
10
+ export interface SrfConfig {
11
+ apiSecret?: string;
12
+ host?: string;
13
+ port?: number;
14
+ secret?: string;
15
+ }
15
16
 
16
- export function parseUri(uri: string): { user: string; host: string; params?: Record<string, any>; };
17
- export function stringifyUri(uri: object): string;
17
+ export function parseUri(uri: string): { user: string; host: string; params?: Record<string, any>; };
18
+ export function stringifyUri(uri: object): string;
18
19
 
19
- export interface SipMessage {
20
- type: "request" | "response";
21
- body: string;
22
- payload: object[];
23
- source: "network" | "application";
24
- source_address: string;
25
- source_port: string;
26
- protocol: string;
27
- stackTime: string;
28
- calledNumber: string;
29
- callingNumber: string;
30
- raw: string;
31
- get(name: string): string;
32
- has(name: string): boolean;
33
- set(name: string, value: string);
34
- getParsedHeader(name: "contact" | "Contact"): Array<AOR>;
35
- getParsedHeader(name: "via" | "Via"): Array<Via>;
36
- getParsedHeader(name: "To" | "to" | "From" | "from" | "refer-to" | "referred-by" | "p-asserted-identity" | "remote-party-id"): AOR;
37
- getParsedHeader(name: string): string;
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
- export interface SrfRequest extends SipMessage {
41
- method: SipMethod;
42
- isNewInvite(): boolean
43
- cancel(callback: () => {})
44
- branch: string;
45
- callId: string;
46
- from: string;
47
- headers: Record<string, string>;
48
- msg: any;
49
- sdp: string;
50
- srf: any;
51
- to: string;
52
- uri: string;
53
- registration?: {
54
- type: "unregister" | "register";
55
- expires: number;
56
- contact: Array<AOR>;
57
- aor: string;
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
- export interface SrfResponse extends SipMessage {
62
- status: number;
63
- statusCode: number;
64
- reason: string;
65
- finalResponseSent: boolean;
66
- send(status: number);
67
- send(status: number, opts: object);
68
- send(status: number, reason: string, opts: object);
69
- send(status: number, reason: string, opts: object, callback: (err, msg) => {});
70
- end();
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
- export interface Dialog {
74
- sip: { callId: string; localTag: string; remoteTag: string; };
75
- onHold: boolean;
76
- other: Dialog;
77
- type: "uac" | "uas";
78
- local: { uri: string; sdp: string; };
79
- remote: { uri: string; sdp: string; };
80
- req: SrfRequest;
81
- destroy(opts?: { headers: Record<string, string>; }, callback?: (err, msg) => {}): void;
82
- modify(sdp, callback?: (err: any, msg: SrfResponse) => void): void;
83
- modify({ noAck: boolean }, callback?: (err: any, resp: any, resAck: any) => void): void;
84
- ack(string): void;
85
- on(messageType: "ack", callback: (msg: SrfResponse) => 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: SrfResponse) => 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
- }
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
- export interface CreateUASOptions {
102
- localSdp: string;
103
- headers?: SipMessageHeaders;
104
- }
101
+ export interface CreateUASOptions {
102
+ localSdp: string;
103
+ headers?: SipMessageHeaders;
104
+ }
105
105
 
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
- }
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
- 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
- }
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
- 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;
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 default Srf
155
+ export = Srf.Srf;
155
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drachtio-srf",
3
- "version": "4.5.39",
3
+ "version": "4.5.40",
4
4
  "description": "drachtio signaling resource framework",
5
5
  "main": "lib/srf.js",
6
6
  "types": "lib/@types/index.d.ts",