@routr/processor 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.
- package/dist/processor.d.ts +1 -0
- package/dist/processor.js +50 -0
- package/dist/response.d.ts +2 -1
- package/dist/response.js +3 -4
- package/dist/target.d.ts +2 -1
- package/dist/target.js +9 -5
- package/package.json +3 -3
package/dist/processor.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Response from "./response";
|
|
2
2
|
import { ProcessorConfig } from "./types";
|
|
3
3
|
import { MessageRequest, ServiceInfo } from "@routr/common";
|
|
4
|
+
export declare const VERSION_METADATA_KEY = "routr-component-version";
|
|
4
5
|
/**
|
|
5
6
|
* Processor is a class that handles the processing of a request.
|
|
6
7
|
*/
|
package/dist/processor.js
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.VERSION_METADATA_KEY = void 0;
|
|
6
40
|
/*
|
|
7
41
|
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
8
42
|
* http://github.com/fonoster/routr
|
|
@@ -22,7 +56,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
56
|
* limitations under the License.
|
|
23
57
|
*/
|
|
24
58
|
const response_1 = __importDefault(require("./response"));
|
|
59
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
25
60
|
const common_1 = require("@routr/common");
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
62
|
+
const VERSION = require("../package.json").version;
|
|
63
|
+
// gRPC metadata key under which every processor announces its version, so a
|
|
64
|
+
// dispatcher that records messages can write which build touched them
|
|
65
|
+
exports.VERSION_METADATA_KEY = "routr-component-version";
|
|
66
|
+
// eslint-disable-next-line require-jsdoc
|
|
67
|
+
const announceVersion = (call) => {
|
|
68
|
+
const sender = call;
|
|
69
|
+
if (typeof sender.sendMetadata !== "function")
|
|
70
|
+
return;
|
|
71
|
+
const md = new grpc.Metadata();
|
|
72
|
+
md.set(exports.VERSION_METADATA_KEY, VERSION);
|
|
73
|
+
sender.sendMetadata(md);
|
|
74
|
+
};
|
|
26
75
|
/**
|
|
27
76
|
* Processor is a class that handles the processing of a request.
|
|
28
77
|
*/
|
|
@@ -49,6 +98,7 @@ class Processor {
|
|
|
49
98
|
handlers: {
|
|
50
99
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
100
|
processMessage: (call, callback) => {
|
|
101
|
+
announceVersion(call);
|
|
52
102
|
func(call.request, new response_1.default(callback));
|
|
53
103
|
}
|
|
54
104
|
}
|
package/dist/response.d.ts
CHANGED
|
@@ -24,11 +24,12 @@ export default class Response {
|
|
|
24
24
|
*
|
|
25
25
|
* @param {MessageRequest} request - The request message.
|
|
26
26
|
* @param {object[]} extraHeaders - Optional extra headers to be sent.
|
|
27
|
+
* @param {Record<string, string>} metadata - Optional metadata for the dispatcher (e.g. the recording flag).
|
|
27
28
|
*/
|
|
28
29
|
sendRegisterOk(request: MessageRequest, extraHeaders?: Array<{
|
|
29
30
|
name: string;
|
|
30
31
|
value: string;
|
|
31
|
-
}>): void;
|
|
32
|
+
}>, metadata?: Record<string, string>): void;
|
|
32
33
|
/**
|
|
33
34
|
* Sends a method not allowed response.
|
|
34
35
|
*/
|
package/dist/response.js
CHANGED
|
@@ -57,11 +57,10 @@ class Response {
|
|
|
57
57
|
*
|
|
58
58
|
* @param {MessageRequest} request - The request message.
|
|
59
59
|
* @param {object[]} extraHeaders - Optional extra headers to be sent.
|
|
60
|
+
* @param {Record<string, string>} metadata - Optional metadata for the dispatcher (e.g. the recording flag).
|
|
60
61
|
*/
|
|
61
|
-
sendRegisterOk(request, extraHeaders) {
|
|
62
|
-
this.callback(null, {
|
|
63
|
-
message: Object.assign(Object.assign({}, buildResponse({ code: common_1.CommonTypes.ResponseType.OK, extraHeaders }).message), { contact: request.message.contact })
|
|
64
|
-
});
|
|
62
|
+
sendRegisterOk(request, extraHeaders, metadata) {
|
|
63
|
+
this.callback(null, Object.assign({ message: Object.assign(Object.assign({}, buildResponse({ code: common_1.CommonTypes.ResponseType.OK, extraHeaders }).message), { contact: request.message.contact }) }, (metadata && Object.keys(metadata).length ? { metadata } : {})));
|
|
65
64
|
}
|
|
66
65
|
/**
|
|
67
66
|
* Sends a method not allowed response.
|
package/dist/target.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import { MessageRequest } from "@routr/common";
|
|
|
2
2
|
import { CommonTypes as CT } from "@routr/common";
|
|
3
3
|
export declare const getAOR: (uri: CT.SipURI) => string;
|
|
4
4
|
export declare const getTargetAOR: (request: MessageRequest) => string;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const DEFAULT_EXPIRES = 3600;
|
|
6
|
+
export declare const getTargetExpires: (request: MessageRequest, defaultExpires?: number) => number;
|
package/dist/target.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTargetExpires = exports.getTargetAOR = exports.getAOR = void 0;
|
|
3
|
+
exports.getTargetExpires = exports.DEFAULT_EXPIRES = exports.getTargetAOR = exports.getAOR = void 0;
|
|
4
4
|
const getAOR = (uri) => `${uri.secure ? "sips" : "sip"}:${uri.user ? uri.user + "@" : ""}${uri.host}`;
|
|
5
5
|
exports.getAOR = getAOR;
|
|
6
6
|
const getTargetAOR = (request) => (0, exports.getAOR)(request.message.to.address.uri);
|
|
7
7
|
exports.getTargetAOR = getTargetAOR;
|
|
8
|
-
|
|
8
|
+
// Used when a REGISTER carries neither a Contact expires parameter nor an
|
|
9
|
+
// Expires header (RFC 3261 section 10.3, step 7)
|
|
10
|
+
exports.DEFAULT_EXPIRES = 3600;
|
|
11
|
+
const getTargetExpires = (request, defaultExpires = exports.DEFAULT_EXPIRES) => {
|
|
9
12
|
var _a, _b, _c, _d, _e;
|
|
10
13
|
// The expires value in the Contact header takes presendence over the value
|
|
11
14
|
// on the Expires header
|
|
12
15
|
const expires = (_c = (_b = (_a = request.message) === null || _a === void 0 ? void 0 : _a.contact) === null || _b === void 0 ? void 0 : _b.expires) !== null && _c !== void 0 ? _c : -1;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
if (expires > -1)
|
|
17
|
+
return expires;
|
|
18
|
+
const headerExpires = (_e = (_d = request.message.expires) === null || _d === void 0 ? void 0 : _d.expires) !== null && _e !== void 0 ? _e : -1;
|
|
19
|
+
return headerExpires > -1 ? headerExpires : defaultExpires;
|
|
16
20
|
};
|
|
17
21
|
exports.getTargetExpires = getTargetExpires;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/processor",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"description": "Processor server and API",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@fonoster/logger": "0.6.0",
|
|
16
16
|
"@grpc/grpc-js": "~1.14.6",
|
|
17
17
|
"@grpc/proto-loader": "~0.7.10",
|
|
18
|
-
"@routr/common": "^2.
|
|
18
|
+
"@routr/common": "^2.19.0",
|
|
19
19
|
"fp-ts": "^2.11.8",
|
|
20
20
|
"phone": "^3.1.68"
|
|
21
21
|
},
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"bugs": {
|
|
37
37
|
"url": "https://github.com/fonoster/routr/issues"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "357116800e150d8bbfbd0ad2406689c5793675b1"
|
|
40
40
|
}
|