ringcentral-softphone 1.1.7 → 1.1.8

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/README.md CHANGED
@@ -19,11 +19,11 @@ yarn install ringcentral-softphone
19
19
  1. Login to https://service.ringcentral.com
20
20
  2. Find the user/extension you want to use
21
21
  3. Check the user's "Devices & Numbers"
22
- 4. Find a phone/device that you want to use
23
- 5. if there is none, you need to create one. Check steps below for more details
24
- 6. Click the "Set Up and Provision" button
25
- 7. Click the link "Set up manually using SIP"
26
- 8. You will find "SIP Domain", "Outbound Proxy", "User Name", "Password" and
22
+ 4. Find a phone/device that you want to use (Phone type **must** be "Existing
23
+ Phone"), if there is none, you need to create one.
24
+ 5. Click the "Set Up and Provision" button
25
+ 6. Click the link "Set up manually using SIP"
26
+ 7. You will find "SIP Domain", "Outbound Proxy", "User Name", "Password" and
27
27
  "Authorization ID"
28
28
 
29
29
  Please note that, "SIP Domain" name should come without port number. I don't
@@ -29,7 +29,7 @@ a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${utils_js_1.localKey}
29
29
  `.trim();
30
30
  const newMessage = new index_js_2.OutboundMessage("SIP/2.0 200 OK", {
31
31
  Via: this.sipMessage.headers.Via,
32
- "Call-ID": this.sipMessage.headers["Call-ID"],
32
+ "Call-ID": this.sipMessage.getHeader("Call-ID"),
33
33
  From: this.sipMessage.headers.From,
34
34
  To: this.sipMessage.headers.To,
35
35
  CSeq: this.sipMessage.headers.CSeq,
@@ -50,7 +50,7 @@ class CallSession extends node_events_1.default {
50
50
  });
51
51
  }
52
52
  get callId() {
53
- return this.sipMessage.headers["Call-ID"];
53
+ return this.sipMessage.getHeader("Call-ID");
54
54
  }
55
55
  send(data) {
56
56
  this.socket.send(data, this.remotePort, this.remoteIP);
@@ -143,7 +143,7 @@ class CallSession extends node_events_1.default {
143
143
  // send a message to remote server so that it knows where to reply
144
144
  this.send("hello");
145
145
  const byeHandler = (inboundMessage) => {
146
- if (inboundMessage.headers["Call-ID"] !== this.callId) {
146
+ if (inboundMessage.getHeader("Call-ID") !== this.callId) {
147
147
  return;
148
148
  }
149
149
  if (inboundMessage.headers.CSeq.endsWith(" BYE")) {
package/dist/cjs/index.js CHANGED
@@ -80,8 +80,7 @@ class Softphone extends node_events_1.default {
80
80
  // sometimes the server will return 200 OK directly
81
81
  return;
82
82
  }
83
- const wwwAuth = inboundMessage.headers["Www-Authenticate"] ||
84
- inboundMessage.headers["WWW-Authenticate"];
83
+ const wwwAuth = inboundMessage.getHeader("Www-Authenticate");
85
84
  const nonce = wwwAuth.match(/, nonce="(.+?)"/)[1];
86
85
  const newMessage = requestMessage.fork();
87
86
  newMessage.headers.Authorization = (0, utils_js_1.generateAuthorization)(this.sipInfo, nonce, "REGISTER");
@@ -97,7 +96,7 @@ class Softphone extends node_events_1.default {
97
96
  }
98
97
  const outboundMessage = new index_js_1.OutboundMessage("SIP/2.0 100 Trying", {
99
98
  Via: inboundMessage.headers.Via,
100
- "Call-ID": inboundMessage.headers["Call-ID"],
99
+ "Call-ID": inboundMessage.getHeader("Call-ID"),
101
100
  From: inboundMessage.headers.From,
102
101
  To: inboundMessage.headers.To,
103
102
  CSeq: inboundMessage.headers.CSeq,
@@ -181,7 +180,7 @@ a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${utils_js_1.localKey}
181
180
  "Content-Type": "application/sdp",
182
181
  }, offerSDP);
183
182
  const inboundMessage = await this.send(inviteMessage, true);
184
- const proxyAuthenticate = inboundMessage.headers["Proxy-Authenticate"];
183
+ const proxyAuthenticate = inboundMessage.getHeader("Proxy-Authenticate");
185
184
  const nonce = proxyAuthenticate.match(/, nonce="(.+?)"/)[1];
186
185
  const newMessage = inviteMessage.fork();
187
186
  newMessage.headers["Proxy-Authorization"] = (0, utils_js_1.generateAuthorization)(this.sipInfo, nonce, "INVITE");
@@ -6,5 +6,6 @@ declare class SipMessage {
6
6
  body: string;
7
7
  constructor(subject?: string, headers?: {}, body?: string);
8
8
  toString(): string;
9
+ getHeader(key: string): string | undefined;
9
10
  }
10
11
  export default SipMessage;
@@ -24,5 +24,11 @@ class SipMessage {
24
24
  ].join("\r\n");
25
25
  return r;
26
26
  }
27
+ getHeader(key) {
28
+ const foundKey = Object.keys(this.headers).find((k) => k.toLowerCase() === key.toLowerCase());
29
+ if (foundKey) {
30
+ return this.headers[foundKey];
31
+ }
32
+ }
27
33
  }
28
34
  exports.default = SipMessage;
@@ -24,7 +24,7 @@ a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${localKey}
24
24
  `.trim();
25
25
  const newMessage = new OutboundMessage("SIP/2.0 200 OK", {
26
26
  Via: this.sipMessage.headers.Via,
27
- "Call-ID": this.sipMessage.headers["Call-ID"],
27
+ "Call-ID": this.sipMessage.getHeader("Call-ID"),
28
28
  From: this.sipMessage.headers.From,
29
29
  To: this.sipMessage.headers.To,
30
30
  CSeq: this.sipMessage.headers.CSeq,
@@ -45,7 +45,7 @@ class CallSession extends EventEmitter {
45
45
  });
46
46
  }
47
47
  get callId() {
48
- return this.sipMessage.headers["Call-ID"];
48
+ return this.sipMessage.getHeader("Call-ID");
49
49
  }
50
50
  send(data) {
51
51
  this.socket.send(data, this.remotePort, this.remoteIP);
@@ -138,7 +138,7 @@ class CallSession extends EventEmitter {
138
138
  // send a message to remote server so that it knows where to reply
139
139
  this.send("hello");
140
140
  const byeHandler = (inboundMessage) => {
141
- if (inboundMessage.headers["Call-ID"] !== this.callId) {
141
+ if (inboundMessage.getHeader("Call-ID") !== this.callId) {
142
142
  return;
143
143
  }
144
144
  if (inboundMessage.headers.CSeq.endsWith(" BYE")) {
package/dist/esm/index.js CHANGED
@@ -75,8 +75,7 @@ class Softphone extends EventEmitter {
75
75
  // sometimes the server will return 200 OK directly
76
76
  return;
77
77
  }
78
- const wwwAuth = inboundMessage.headers["Www-Authenticate"] ||
79
- inboundMessage.headers["WWW-Authenticate"];
78
+ const wwwAuth = inboundMessage.getHeader("Www-Authenticate");
80
79
  const nonce = wwwAuth.match(/, nonce="(.+?)"/)[1];
81
80
  const newMessage = requestMessage.fork();
82
81
  newMessage.headers.Authorization = generateAuthorization(this.sipInfo, nonce, "REGISTER");
@@ -92,7 +91,7 @@ class Softphone extends EventEmitter {
92
91
  }
93
92
  const outboundMessage = new OutboundMessage("SIP/2.0 100 Trying", {
94
93
  Via: inboundMessage.headers.Via,
95
- "Call-ID": inboundMessage.headers["Call-ID"],
94
+ "Call-ID": inboundMessage.getHeader("Call-ID"),
96
95
  From: inboundMessage.headers.From,
97
96
  To: inboundMessage.headers.To,
98
97
  CSeq: inboundMessage.headers.CSeq,
@@ -176,7 +175,7 @@ a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:${localKey}
176
175
  "Content-Type": "application/sdp",
177
176
  }, offerSDP);
178
177
  const inboundMessage = await this.send(inviteMessage, true);
179
- const proxyAuthenticate = inboundMessage.headers["Proxy-Authenticate"];
178
+ const proxyAuthenticate = inboundMessage.getHeader("Proxy-Authenticate");
180
179
  const nonce = proxyAuthenticate.match(/, nonce="(.+?)"/)[1];
181
180
  const newMessage = inviteMessage.fork();
182
181
  newMessage.headers["Proxy-Authorization"] = generateAuthorization(this.sipInfo, nonce, "INVITE");
@@ -6,5 +6,6 @@ declare class SipMessage {
6
6
  body: string;
7
7
  constructor(subject?: string, headers?: {}, body?: string);
8
8
  toString(): string;
9
+ getHeader(key: string): string | undefined;
9
10
  }
10
11
  export default SipMessage;
@@ -22,5 +22,11 @@ class SipMessage {
22
22
  ].join("\r\n");
23
23
  return r;
24
24
  }
25
+ getHeader(key) {
26
+ const foundKey = Object.keys(this.headers).find((k) => k.toLowerCase() === key.toLowerCase());
27
+ if (foundKey) {
28
+ return this.headers[foundKey];
29
+ }
30
+ }
25
31
  }
26
32
  export default SipMessage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ringcentral-softphone",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "homepage": "https://github.com/ringcentral/ringcentral-softphone-ts",
5
5
  "license": "MIT",
6
6
  "types": "dist/esm/index.d.ts",