@routr/common 2.17.0 → 2.19.0

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.
Files changed (88) hide show
  1. package/dist/connect/config.d.ts +5 -1
  2. package/dist/connect/mappers/agent.js +1 -0
  3. package/dist/connect/mappers/domain.js +1 -0
  4. package/dist/connect/mappers/peer.js +1 -0
  5. package/dist/connect/mappers/trunk.js +1 -0
  6. package/dist/connect/protos/agents.proto +7 -0
  7. package/dist/connect/protos/domains.proto +7 -0
  8. package/dist/connect/protos/peers.proto +7 -0
  9. package/dist/connect/protos/trace.proto +28 -0
  10. package/dist/connect/protos/trunks.proto +7 -0
  11. package/dist/connect/schemas/agent.d.ts +10 -0
  12. package/dist/connect/schemas/agent.js +8 -0
  13. package/dist/connect/schemas/domain.d.ts +10 -0
  14. package/dist/connect/schemas/domain.js +8 -0
  15. package/dist/connect/schemas/peer.d.ts +10 -0
  16. package/dist/connect/schemas/peer.js +8 -0
  17. package/dist/connect/schemas/trunk.d.ts +10 -0
  18. package/dist/connect/schemas/trunk.js +8 -0
  19. package/dist/connect/types.d.ts +7 -0
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.js +2 -1
  22. package/dist/protos/processor.proto +4 -0
  23. package/dist/trace/compat.d.ts +37 -0
  24. package/dist/trace/compat.js +131 -0
  25. package/dist/trace/diff.d.ts +48 -0
  26. package/dist/trace/diff.js +152 -0
  27. package/dist/trace/index.d.ts +11 -0
  28. package/dist/trace/index.js +68 -0
  29. package/dist/trace/metadata.d.ts +28 -0
  30. package/dist/trace/metadata.js +75 -0
  31. package/dist/trace/normalize.d.ts +11 -0
  32. package/dist/trace/normalize.js +39 -0
  33. package/dist/trace/redact.d.ts +19 -0
  34. package/dist/trace/redact.js +52 -0
  35. package/dist/trace/rules/facts.d.ts +43 -0
  36. package/dist/trace/rules/facts.js +117 -0
  37. package/dist/trace/rules/index.d.ts +34 -0
  38. package/dist/trace/rules/index.js +153 -0
  39. package/dist/trace/rules/sip/ack-2xx.d.ts +2 -0
  40. package/dist/trace/rules/sip/ack-2xx.js +56 -0
  41. package/dist/trace/rules/sip/cancel-matches.d.ts +2 -0
  42. package/dist/trace/rules/sip/cancel-matches.js +46 -0
  43. package/dist/trace/rules/sip/credentials-stripped.d.ts +2 -0
  44. package/dist/trace/rules/sip/credentials-stripped.js +41 -0
  45. package/dist/trace/rules/sip/cseq-ack.d.ts +2 -0
  46. package/dist/trace/rules/sip/cseq-ack.js +40 -0
  47. package/dist/trace/rules/sip/cseq-monotonic.d.ts +2 -0
  48. package/dist/trace/rules/sip/cseq-monotonic.js +50 -0
  49. package/dist/trace/rules/sip/max-forwards.d.ts +2 -0
  50. package/dist/trace/rules/sip/max-forwards.js +47 -0
  51. package/dist/trace/rules/sip/private-address.d.ts +2 -0
  52. package/dist/trace/rules/sip/private-address.js +48 -0
  53. package/dist/trace/rules/sip/record-route-self.d.ts +2 -0
  54. package/dist/trace/rules/sip/record-route-self.js +46 -0
  55. package/dist/trace/rules/sip/register-ok.d.ts +2 -0
  56. package/dist/trace/rules/sip/register-ok.js +52 -0
  57. package/dist/trace/rules/sip/retransmission.d.ts +2 -0
  58. package/dist/trace/rules/sip/retransmission.js +47 -0
  59. package/dist/trace/rules/sip/route-self-removed.d.ts +2 -0
  60. package/dist/trace/rules/sip/route-self-removed.js +38 -0
  61. package/dist/trace/rules/sip/via.d.ts +2 -0
  62. package/dist/trace/rules/sip/via.js +50 -0
  63. package/dist/trace/rules/sip-connect/from-e164-or-anonymous.d.ts +2 -0
  64. package/dist/trace/rules/sip-connect/from-e164-or-anonymous.js +43 -0
  65. package/dist/trace/rules/sip-connect/pai-e164.d.ts +2 -0
  66. package/dist/trace/rules/sip-connect/pai-e164.js +44 -0
  67. package/dist/trace/rules/sip-connect/pai-single.d.ts +2 -0
  68. package/dist/trace/rules/sip-connect/pai-single.js +41 -0
  69. package/dist/trace/rules/sip-connect/privacy.d.ts +2 -0
  70. package/dist/trace/rules/sip-connect/privacy.js +50 -0
  71. package/dist/trace/rules/sip-connect/request-uri-e164.d.ts +2 -0
  72. package/dist/trace/rules/sip-connect/request-uri-e164.js +44 -0
  73. package/dist/trace/rules/sip-connect/scope.d.ts +11 -0
  74. package/dist/trace/rules/sip-connect/scope.js +19 -0
  75. package/dist/trace/rules/types.d.ts +34 -0
  76. package/dist/trace/rules/types.js +13 -0
  77. package/dist/trace/sanitize.d.ts +40 -0
  78. package/dist/trace/sanitize.js +85 -0
  79. package/dist/trace/schema.d.ts +338 -0
  80. package/dist/trace/schema.js +197 -0
  81. package/dist/trace/status.d.ts +15 -0
  82. package/dist/trace/status.js +102 -0
  83. package/dist/trace/types.d.ts +126 -0
  84. package/dist/trace/types.js +82 -0
  85. package/dist/trace/validate.d.ts +56 -0
  86. package/dist/trace/validate.js +140 -0
  87. package/dist/types.d.ts +2 -0
  88. package/package.json +2 -2
@@ -0,0 +1,338 @@
1
+ import { HopAction, HopKind, Profile, Severity, TraceKind, TraceOutcome } from "./types";
2
+ /**
3
+ * JSON Schema (draft-07) for one line of a trace file, traceVersion 1.
4
+ * The envelope is strict; the SIP message payloads mirror the processor
5
+ * proto and are validated only for shape.
6
+ */
7
+ export declare const traceRecordSchema: {
8
+ title: string;
9
+ type: string;
10
+ properties: {
11
+ traceVersion: {
12
+ type: string;
13
+ const: number;
14
+ };
15
+ recordedAt: {
16
+ type: string;
17
+ pattern: string;
18
+ };
19
+ callId: {
20
+ type: string;
21
+ minLength: number;
22
+ };
23
+ seq: {
24
+ type: string;
25
+ minimum: number;
26
+ };
27
+ tOffsetMs: {
28
+ type: string;
29
+ minimum: number;
30
+ };
31
+ kind: {
32
+ type: string;
33
+ enum: TraceKind[];
34
+ };
35
+ method: {
36
+ type: string;
37
+ minLength: number;
38
+ };
39
+ status: {
40
+ type: string;
41
+ minimum: number;
42
+ maximum: number;
43
+ };
44
+ edgePort: {
45
+ type: string;
46
+ properties: {
47
+ ref: {
48
+ type: string;
49
+ };
50
+ version: {
51
+ type: string;
52
+ };
53
+ };
54
+ required: string[];
55
+ additionalProperties: boolean;
56
+ };
57
+ dispatcher: {
58
+ type: string;
59
+ properties: {
60
+ ref: {
61
+ type: string;
62
+ };
63
+ version: {
64
+ type: string;
65
+ };
66
+ };
67
+ required: string[];
68
+ additionalProperties: boolean;
69
+ };
70
+ trunkRef: {
71
+ type: string;
72
+ };
73
+ request: {
74
+ type: string;
75
+ properties: {
76
+ ref: {
77
+ type: string;
78
+ };
79
+ edgePortRef: {
80
+ type: string;
81
+ };
82
+ method: {
83
+ type: string;
84
+ };
85
+ sender: {
86
+ type: string;
87
+ };
88
+ listeningPoints: {
89
+ type: string;
90
+ };
91
+ externalAddrs: {
92
+ type: string;
93
+ items: {
94
+ type: string;
95
+ };
96
+ };
97
+ localnets: {
98
+ type: string;
99
+ items: {
100
+ type: string;
101
+ };
102
+ };
103
+ message: {
104
+ type: string;
105
+ properties: {
106
+ messageType: {
107
+ type: string;
108
+ };
109
+ from: {
110
+ type: string[];
111
+ };
112
+ to: {
113
+ type: string[];
114
+ };
115
+ via: {
116
+ type: string;
117
+ };
118
+ extensions: {
119
+ type: string;
120
+ };
121
+ };
122
+ };
123
+ metadata: {
124
+ type: string;
125
+ additionalProperties: {
126
+ type: string;
127
+ };
128
+ };
129
+ edgePortVersion: {
130
+ type: string;
131
+ };
132
+ receivedOn: {
133
+ type: string;
134
+ properties: {
135
+ host: {
136
+ type: string;
137
+ };
138
+ port: {
139
+ type: string;
140
+ };
141
+ transport: {
142
+ type: string;
143
+ };
144
+ };
145
+ required: string[];
146
+ };
147
+ };
148
+ required: string[];
149
+ };
150
+ hops: {
151
+ type: string;
152
+ items: {
153
+ type: string;
154
+ properties: {
155
+ component: {
156
+ type: string;
157
+ minLength: number;
158
+ };
159
+ kind: {
160
+ type: string;
161
+ enum: HopKind[];
162
+ };
163
+ version: {
164
+ type: string;
165
+ };
166
+ durationMs: {
167
+ type: string;
168
+ minimum: number;
169
+ };
170
+ action: {
171
+ type: string;
172
+ enum: HopAction[];
173
+ };
174
+ diff: {
175
+ type: string;
176
+ properties: {
177
+ requestUri: {
178
+ type: string;
179
+ properties: {
180
+ from: {
181
+ type: string;
182
+ };
183
+ to: {
184
+ type: string;
185
+ };
186
+ };
187
+ required: string[];
188
+ additionalProperties: boolean;
189
+ };
190
+ headers: {
191
+ type: string;
192
+ properties: {
193
+ added: {
194
+ type: string;
195
+ additionalProperties: {
196
+ type: string;
197
+ };
198
+ };
199
+ removed: {
200
+ type: string;
201
+ additionalProperties: {
202
+ type: string;
203
+ };
204
+ };
205
+ changed: {
206
+ type: string;
207
+ additionalProperties: {
208
+ type: string;
209
+ properties: {
210
+ from: {
211
+ type: string;
212
+ };
213
+ to: {
214
+ type: string;
215
+ };
216
+ };
217
+ required: string[];
218
+ additionalProperties: boolean;
219
+ };
220
+ };
221
+ };
222
+ required: string[];
223
+ additionalProperties: boolean;
224
+ };
225
+ };
226
+ required: string[];
227
+ additionalProperties: boolean;
228
+ };
229
+ error: {
230
+ type: string;
231
+ };
232
+ metadata: {
233
+ type: string;
234
+ additionalProperties: {
235
+ type: string;
236
+ };
237
+ };
238
+ };
239
+ required: string[];
240
+ additionalProperties: boolean;
241
+ };
242
+ };
243
+ response: {
244
+ type: string[];
245
+ properties: {
246
+ message: {
247
+ type: string;
248
+ properties: {
249
+ messageType: {
250
+ type: string;
251
+ };
252
+ from: {
253
+ type: string[];
254
+ };
255
+ to: {
256
+ type: string[];
257
+ };
258
+ via: {
259
+ type: string;
260
+ };
261
+ extensions: {
262
+ type: string;
263
+ };
264
+ };
265
+ };
266
+ metadata: {
267
+ type: string;
268
+ additionalProperties: {
269
+ type: string;
270
+ };
271
+ };
272
+ };
273
+ required: string[];
274
+ };
275
+ outcome: {
276
+ type: string;
277
+ enum: TraceOutcome[];
278
+ };
279
+ totalMs: {
280
+ type: string;
281
+ minimum: number;
282
+ };
283
+ lint: {
284
+ type: string;
285
+ properties: {
286
+ version: {
287
+ type: string;
288
+ };
289
+ profiles: {
290
+ type: string;
291
+ items: {
292
+ type: string;
293
+ enum: Profile[];
294
+ };
295
+ };
296
+ };
297
+ required: string[];
298
+ additionalProperties: boolean;
299
+ };
300
+ findings: {
301
+ type: string;
302
+ items: {
303
+ type: string;
304
+ properties: {
305
+ rule: {
306
+ type: string;
307
+ minLength: number;
308
+ };
309
+ profile: {
310
+ type: string;
311
+ enum: Profile[];
312
+ };
313
+ severity: {
314
+ type: string;
315
+ enum: Severity[];
316
+ };
317
+ spec: {
318
+ type: string;
319
+ };
320
+ message: {
321
+ type: string;
322
+ };
323
+ side: {
324
+ type: string;
325
+ enum: string[];
326
+ };
327
+ header: {
328
+ type: string;
329
+ };
330
+ };
331
+ required: string[];
332
+ additionalProperties: boolean;
333
+ };
334
+ };
335
+ };
336
+ required: string[];
337
+ additionalProperties: boolean;
338
+ };
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.traceRecordSchema = void 0;
4
+ /*
5
+ * Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
6
+ * http://github.com/fonoster/routr
7
+ *
8
+ * This file is part of Routr.
9
+ *
10
+ * Licensed under the MIT License (the "License");
11
+ * you may not use this file except in compliance with
12
+ * the License. You may obtain a copy of the License at
13
+ *
14
+ * https://opensource.org/licenses/MIT
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ const types_1 = require("./types");
23
+ const headerChange = {
24
+ type: "object",
25
+ properties: {
26
+ from: { type: "string" },
27
+ to: { type: "string" }
28
+ },
29
+ required: ["from", "to"],
30
+ additionalProperties: false
31
+ };
32
+ const stringMap = {
33
+ type: "object",
34
+ additionalProperties: { type: "string" }
35
+ };
36
+ const component = {
37
+ type: "object",
38
+ properties: {
39
+ ref: { type: "string" },
40
+ version: { type: "string" }
41
+ },
42
+ required: ["ref"],
43
+ additionalProperties: false
44
+ };
45
+ const diff = {
46
+ type: "object",
47
+ properties: {
48
+ requestUri: headerChange,
49
+ headers: {
50
+ type: "object",
51
+ properties: {
52
+ added: stringMap,
53
+ removed: stringMap,
54
+ changed: { type: "object", additionalProperties: headerChange }
55
+ },
56
+ required: ["added", "removed", "changed"],
57
+ additionalProperties: false
58
+ }
59
+ },
60
+ required: ["headers"],
61
+ additionalProperties: false
62
+ };
63
+ const hop = {
64
+ type: "object",
65
+ properties: {
66
+ component: { type: "string", minLength: 1 },
67
+ kind: { type: "string", enum: Object.values(types_1.HopKind) },
68
+ version: { type: "string" },
69
+ durationMs: { type: "number", minimum: 0 },
70
+ action: { type: "string", enum: Object.values(types_1.HopAction) },
71
+ diff,
72
+ error: { type: "string" },
73
+ metadata: stringMap
74
+ },
75
+ required: ["component", "kind", "durationMs", "action"],
76
+ additionalProperties: false
77
+ };
78
+ // A processor-generated response (a 401 challenge, a 404) carries only the
79
+ // fields the processor set; the EdgePort completes it from the request.
80
+ // So only the shape is checked here, no header is required.
81
+ const sipMessage = {
82
+ type: "object",
83
+ properties: {
84
+ messageType: { type: "string" },
85
+ // proto-loader emits null for unset message fields
86
+ from: { type: ["object", "null"] },
87
+ to: { type: ["object", "null"] },
88
+ via: { type: "array" },
89
+ extensions: { type: "array" }
90
+ }
91
+ };
92
+ const netInterface = {
93
+ type: "object",
94
+ properties: {
95
+ host: { type: "string" },
96
+ port: { type: "integer" },
97
+ transport: { type: "string" }
98
+ },
99
+ required: ["host", "port", "transport"]
100
+ };
101
+ const request = {
102
+ type: "object",
103
+ properties: {
104
+ ref: { type: "string" },
105
+ edgePortRef: { type: "string" },
106
+ method: { type: "string" },
107
+ sender: { type: "object" },
108
+ listeningPoints: { type: "array" },
109
+ externalAddrs: { type: "array", items: { type: "string" } },
110
+ localnets: { type: "array", items: { type: "string" } },
111
+ message: sipMessage,
112
+ metadata: stringMap,
113
+ edgePortVersion: { type: "string" },
114
+ receivedOn: netInterface
115
+ },
116
+ required: ["ref", "edgePortRef", "method", "sender", "message"]
117
+ };
118
+ const finding = {
119
+ type: "object",
120
+ properties: {
121
+ rule: { type: "string", minLength: 1 },
122
+ profile: { type: "string", enum: Object.values(types_1.Profile) },
123
+ severity: { type: "string", enum: Object.values(types_1.Severity) },
124
+ spec: { type: "string" },
125
+ message: { type: "string" },
126
+ side: { type: "string", enum: ["in", "out", "call"] },
127
+ header: { type: "string" }
128
+ },
129
+ required: ["rule", "profile", "severity", "spec", "message", "side"],
130
+ additionalProperties: false
131
+ };
132
+ const lint = {
133
+ type: "object",
134
+ properties: {
135
+ version: { type: "string" },
136
+ profiles: {
137
+ type: "array",
138
+ items: { type: "string", enum: Object.values(types_1.Profile) }
139
+ }
140
+ },
141
+ required: ["version", "profiles"],
142
+ additionalProperties: false
143
+ };
144
+ const response = {
145
+ type: ["object", "null"],
146
+ properties: {
147
+ message: sipMessage,
148
+ metadata: stringMap
149
+ },
150
+ required: ["message"]
151
+ };
152
+ /**
153
+ * JSON Schema (draft-07) for one line of a trace file, traceVersion 1.
154
+ * The envelope is strict; the SIP message payloads mirror the processor
155
+ * proto and are validated only for shape.
156
+ */
157
+ exports.traceRecordSchema = {
158
+ title: "Routr trace record",
159
+ type: "object",
160
+ properties: {
161
+ traceVersion: { type: "integer", const: 1 },
162
+ recordedAt: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}T" },
163
+ callId: { type: "string", minLength: 1 },
164
+ seq: { type: "integer", minimum: 1 },
165
+ tOffsetMs: { type: "number", minimum: 0 },
166
+ kind: { type: "string", enum: Object.values(types_1.TraceKind) },
167
+ method: { type: "string", minLength: 1 },
168
+ status: { type: "integer", minimum: 100, maximum: 699 },
169
+ edgePort: component,
170
+ dispatcher: component,
171
+ trunkRef: { type: "string" },
172
+ request,
173
+ hops: { type: "array", items: hop },
174
+ response,
175
+ outcome: { type: "string", enum: Object.values(types_1.TraceOutcome) },
176
+ totalMs: { type: "number", minimum: 0 },
177
+ lint,
178
+ findings: { type: "array", items: finding }
179
+ },
180
+ required: [
181
+ "traceVersion",
182
+ "recordedAt",
183
+ "callId",
184
+ "seq",
185
+ "tOffsetMs",
186
+ "kind",
187
+ "method",
188
+ "edgePort",
189
+ "dispatcher",
190
+ "request",
191
+ "hops",
192
+ "response",
193
+ "outcome",
194
+ "totalMs"
195
+ ],
196
+ additionalProperties: false
197
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Returns the numeric SIP status for a response type, or undefined when the
3
+ * type is unknown.
4
+ *
5
+ * @param {string} responseType - A ResponseType name as carried by the proto
6
+ * @return {number | undefined} The status code
7
+ */
8
+ export declare function statusCodeOf(responseType?: string): number | undefined;
9
+ /**
10
+ * Returns a lowercase reason phrase for a response type, e.g. "ringing".
11
+ *
12
+ * @param {string} responseType - A ResponseType name as carried by the proto
13
+ * @return {string} The phrase
14
+ */
15
+ export declare function reasonPhraseOf(responseType?: string): string;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.statusCodeOf = statusCodeOf;
4
+ exports.reasonPhraseOf = reasonPhraseOf;
5
+ /*
6
+ * Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
7
+ * http://github.com/fonoster/routr
8
+ *
9
+ * This file is part of Routr.
10
+ *
11
+ * Licensed under the MIT License (the "License");
12
+ * you may not use this file except in compliance with
13
+ * the License. You may obtain a copy of the License at
14
+ *
15
+ * https://opensource.org/licenses/MIT
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License.
22
+ */
23
+ const types_1 = require("../types");
24
+ // RFC 3261 §21 status codes for every ResponseType the proto can carry
25
+ const STATUS_CODES = {
26
+ [types_1.ResponseType.TRYING]: 100,
27
+ [types_1.ResponseType.RINGING]: 180,
28
+ [types_1.ResponseType.CALL_IS_BEING_FORWARDED]: 181,
29
+ [types_1.ResponseType.QUEUED]: 182,
30
+ [types_1.ResponseType.SESSION_PROGRESS]: 183,
31
+ [types_1.ResponseType.SUCCESS]: 200,
32
+ [types_1.ResponseType.OK]: 200,
33
+ [types_1.ResponseType.ACCEPTED]: 202,
34
+ [types_1.ResponseType.REDIRECTION]: 300,
35
+ [types_1.ResponseType.MULTIPLE_CHOICES]: 300,
36
+ [types_1.ResponseType.MOVED_PERMANENTLY]: 301,
37
+ [types_1.ResponseType.MOVED_TEMPORARILY]: 302,
38
+ [types_1.ResponseType.USE_PROXY]: 305,
39
+ [types_1.ResponseType.ALTERNATIVE_SERVICE]: 380,
40
+ [types_1.ResponseType.CLIENT_ERROR]: 400,
41
+ [types_1.ResponseType.BAD_REQUEST]: 400,
42
+ [types_1.ResponseType.UNAUTHORIZED]: 401,
43
+ [types_1.ResponseType.PAYMENT_REQUIRED]: 402,
44
+ [types_1.ResponseType.FORBIDDEN]: 403,
45
+ [types_1.ResponseType.NOT_FOUND]: 404,
46
+ [types_1.ResponseType.METHOD_NOT_ALLOWED]: 405,
47
+ [types_1.ResponseType.NOT_ACCEPTABLE]: 406,
48
+ [types_1.ResponseType.PROXY_AUTHENTICATION_REQUIRED]: 407,
49
+ [types_1.ResponseType.REQUEST_TIMEOUT]: 408,
50
+ [types_1.ResponseType.GONE]: 410,
51
+ [types_1.ResponseType.REQUEST_ENTITY_TOO_LARGE]: 413,
52
+ [types_1.ResponseType.REQUEST_URI_TOO_LONG]: 414,
53
+ [types_1.ResponseType.UNSUPPORTED_MEDIA_TYPE]: 415,
54
+ [types_1.ResponseType.UNSUPPORTED_URI_SCHEME]: 416,
55
+ [types_1.ResponseType.BAD_EXTENSION]: 420,
56
+ [types_1.ResponseType.EXTENSION_REQUIRED]: 421,
57
+ [types_1.ResponseType.INTERVAL_TOO_BRIEF]: 423,
58
+ [types_1.ResponseType.TEMPORARILY_UNAVAILABLE]: 480,
59
+ [types_1.ResponseType.CALL_OR_TRANSACTION_DOES_NOT_EXIST]: 481,
60
+ [types_1.ResponseType.LOOP_DETECTED]: 482,
61
+ [types_1.ResponseType.TOO_MANY_HOPS]: 483,
62
+ [types_1.ResponseType.ADDRESS_INCOMPLETE]: 484,
63
+ [types_1.ResponseType.AMBIGUOUS]: 485,
64
+ [types_1.ResponseType.BUSY_HERE]: 486,
65
+ [types_1.ResponseType.REQUEST_TERMINATED]: 487,
66
+ [types_1.ResponseType.NOT_ACCEPTABLE_HERE]: 488,
67
+ [types_1.ResponseType.BAD_EVENT]: 489,
68
+ [types_1.ResponseType.REQUEST_PENDING]: 491,
69
+ [types_1.ResponseType.UNDECIPHERABLE]: 493,
70
+ [types_1.ResponseType.SERVER_ERROR]: 500,
71
+ [types_1.ResponseType.SERVER_INTERNAL_ERROR]: 500,
72
+ [types_1.ResponseType.NOT_IMPLEMENTED]: 501,
73
+ [types_1.ResponseType.BAD_GATEWAY]: 502,
74
+ [types_1.ResponseType.SERVICE_UNAVAILABLE]: 503,
75
+ [types_1.ResponseType.SERVER_TIMEOUT]: 504,
76
+ [types_1.ResponseType.VERSION_NOT_SUPPORTED]: 505,
77
+ [types_1.ResponseType.MESSAGE_TOO_LARGE]: 513,
78
+ [types_1.ResponseType.GLOBAL_ERROR]: 600,
79
+ [types_1.ResponseType.BUSY_EVERYWHERE]: 600,
80
+ [types_1.ResponseType.DECLINE]: 603,
81
+ [types_1.ResponseType.DOES_NOT_EXIST_ANYWHERE]: 604,
82
+ [types_1.ResponseType.SESSION_NOT_ACCEPTABLE]: 606
83
+ };
84
+ /**
85
+ * Returns the numeric SIP status for a response type, or undefined when the
86
+ * type is unknown.
87
+ *
88
+ * @param {string} responseType - A ResponseType name as carried by the proto
89
+ * @return {number | undefined} The status code
90
+ */
91
+ function statusCodeOf(responseType) {
92
+ return responseType ? STATUS_CODES[responseType] : undefined;
93
+ }
94
+ /**
95
+ * Returns a lowercase reason phrase for a response type, e.g. "ringing".
96
+ *
97
+ * @param {string} responseType - A ResponseType name as carried by the proto
98
+ * @return {string} The phrase
99
+ */
100
+ function reasonPhraseOf(responseType) {
101
+ return (responseType || "unknown").toLowerCase().replace(/_/g, " ");
102
+ }