drachtio-srf 4.5.22 → 4.5.25
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/publish.yml +3 -3
- package/lib/@types/index.d.ts +64 -0
- package/lib/drachtio-agent.js +4 -0
- package/package.json +10 -7
|
@@ -12,10 +12,10 @@ jobs:
|
|
|
12
12
|
runs-on: ubuntu-latest
|
|
13
13
|
|
|
14
14
|
steps:
|
|
15
|
-
- uses: actions/checkout@
|
|
16
|
-
- uses: actions/setup-node@
|
|
15
|
+
- uses: actions/checkout@v3
|
|
16
|
+
- uses: actions/setup-node@v3
|
|
17
17
|
with:
|
|
18
|
-
node-version:
|
|
18
|
+
node-version: lts/*
|
|
19
19
|
registry-url: 'https://registry.npmjs.org'
|
|
20
20
|
- run: npm install
|
|
21
21
|
- run: npm publish --access public
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
declare module 'drachtio-srf' {
|
|
2
|
+
import { Socket } from 'net';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
|
|
5
|
+
type SipMethod = 'ACK' | 'BYE' | 'CANCEL' | 'INFO' | 'INVITE' | 'MESSAGE' | 'NOTIFY' | 'OPTIONS' | 'PRACK' | 'PUBLISH' | 'REFER' | 'REGISTER' | 'SUBSCRIBE' | 'UPDATE';
|
|
6
|
+
|
|
7
|
+
interface SrfConfig {
|
|
8
|
+
apiSecret?: string;
|
|
9
|
+
host?: string;
|
|
10
|
+
port?: number;
|
|
11
|
+
secret?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface SrfRequest {
|
|
15
|
+
headers: {[name: string]: any};
|
|
16
|
+
msg: any;
|
|
17
|
+
method: SipMethod;
|
|
18
|
+
uri: string;
|
|
19
|
+
from: string;
|
|
20
|
+
to: string;
|
|
21
|
+
callId: string;
|
|
22
|
+
branch: string;
|
|
23
|
+
sdp: string;
|
|
24
|
+
get(name: string): string;
|
|
25
|
+
has(name: string): boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface SrfResponse {
|
|
29
|
+
headers: {[name: string]: any};
|
|
30
|
+
status: number;
|
|
31
|
+
send(sdp?: string): void;
|
|
32
|
+
end(): void;
|
|
33
|
+
set(name: string, value: string | number): void;
|
|
34
|
+
get(name: string): string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface Srf extends EventEmitter {
|
|
38
|
+
connect(config?: SrfConfig): Promise<void>;
|
|
39
|
+
disconnect(): void;
|
|
40
|
+
register(options: any): void;
|
|
41
|
+
invite(sipUri: string, options: any): void;
|
|
42
|
+
bye(request: SrfRequest, options: any): void;
|
|
43
|
+
cancel(request: SrfRequest, options: any): void;
|
|
44
|
+
ack(request: SrfRequest, options: any): void;
|
|
45
|
+
info(request: SrfRequest, options: any): void;
|
|
46
|
+
message(request: SrfRequest, options: any): void;
|
|
47
|
+
notify(request: SrfRequest, options: any): void;
|
|
48
|
+
options(request: SrfRequest, options: any): void;
|
|
49
|
+
prack(request: SrfRequest, options: any): void;
|
|
50
|
+
publish(request: SrfRequest, options: any): void;
|
|
51
|
+
refer(request: SrfRequest, target: string, options: any): void;
|
|
52
|
+
subscribe(request: SrfRequest, target: string, options: any): void;
|
|
53
|
+
update(request: SrfRequest, options: any): void;
|
|
54
|
+
on(event: 'connect' | 'error' | 'disconnect', listener: () => void): this;
|
|
55
|
+
on(event: 'message', listener: (req: SrfRequest, res: SrfResponse) => void): this;
|
|
56
|
+
on(event: 'request', listener: (req: SrfRequest, res: SrfResponse) => void): this;
|
|
57
|
+
on(event: 'register' | 'invite' | 'bye' | 'cancel' | 'ack' | 'info' | 'notify' | 'options' | 'prack' | 'publish' | 'refer' | 'subscribe' | 'update', listener: (req: SrfRequest, res: SrfResponse) => void): this;
|
|
58
|
+
locals: {[name: string]: any};
|
|
59
|
+
socket: Socket;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default function srf(config?: SrfConfig): Srf;
|
|
63
|
+
}
|
|
64
|
+
|
package/lib/drachtio-agent.js
CHANGED
|
@@ -336,6 +336,10 @@ class DrachtioAgent extends Emitter {
|
|
|
336
336
|
sendResponse(res, opts, callback, fnAck) {
|
|
337
337
|
const obj = this.mapServer.get(res.socket) ;
|
|
338
338
|
debug(`agent#sendResponse: ${JSON.stringify(res.msg)}`);
|
|
339
|
+
if (!obj) {
|
|
340
|
+
callback && callback(new Error('drachtio-agent:sendResponse: socket connection closed'));
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
339
343
|
const msgId = this.sendMessage(res.socket, res.msg, Object.assign({stackTxnId: res.req.stackTxnId}, opts)) ;
|
|
340
344
|
if ((callback && typeof callback === 'function') || fnAck) {
|
|
341
345
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drachtio-srf",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.25",
|
|
4
4
|
"description": "drachtio signaling resource framework",
|
|
5
5
|
"main": "lib/srf.js",
|
|
6
|
+
"types": "lib/@types/index.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "NODE_ENV=test node test/ ",
|
|
8
9
|
"coverage": "./node_modules/.bin/nyc --reporter html --report-dir ./coverage npm run test",
|
|
@@ -25,23 +26,25 @@
|
|
|
25
26
|
"dependencies": {
|
|
26
27
|
"debug": "^3.2.7",
|
|
27
28
|
"delegates": "^0.1.0",
|
|
28
|
-
"eslint": "^8.30.0",
|
|
29
|
-
"eslint-plugin-promise": "^6.1.1",
|
|
30
29
|
"node-noop": "^0.0.1",
|
|
31
30
|
"only": "^0.0.2",
|
|
32
|
-
"uuid-random": "^1.3.2",
|
|
33
31
|
"sdp-transform": "^2.14.1",
|
|
34
|
-
"short-uuid": "^4.2.
|
|
32
|
+
"short-uuid": "^4.2.2",
|
|
35
33
|
"sip-methods": "^0.3.0",
|
|
36
34
|
"sip-status": "^0.1.0",
|
|
37
|
-
"utils-merge": "^1.0.0"
|
|
35
|
+
"utils-merge": "^1.0.0",
|
|
36
|
+
"uuid-random": "^1.3.2"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
39
|
+
"@types/node": "^16.0.0",
|
|
40
40
|
"config": "^3.3.7",
|
|
41
|
+
"eslint": "^8.30.0",
|
|
42
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
41
43
|
"mocha": "^9.2.2",
|
|
42
44
|
"nyc": "^15.1.0",
|
|
43
45
|
"should": "^13.2.3",
|
|
44
46
|
"sip-message-examples": "^0.0.6",
|
|
45
|
-
"tape": "^5.5.3"
|
|
47
|
+
"tape": "^5.5.3",
|
|
48
|
+
"typescript": "^4.3.2"
|
|
46
49
|
}
|
|
47
50
|
}
|