@routr/common 2.0.8-alpha.1 → 2.0.8-alpha.11
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/auth.d.ts +43 -4
- package/dist/auth.js +63 -1
- package/dist/connect/connect_error.d.ts +21 -0
- package/dist/connect/connect_error.js +44 -0
- package/dist/connect/data_api.js +2 -2
- package/dist/connect/types.d.ts +8 -5
- package/dist/connect/types.js +14 -11
- package/dist/helper.d.ts +4 -4
- package/dist/helper.js +7 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -4
- package/dist/protos/location.proto +9 -5
- package/dist/protos/sipmessage.proto +2 -0
- package/dist/types.d.ts +41 -19
- package/dist/types.js +17 -1
- package/package.json +2 -2
package/dist/auth.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AuthChallengeRequest, AuthChallengeResponse } from "./types";
|
|
1
|
+
import { AuthChallengeRequest, AuthChallengeResponse, ResponseType } from "./types";
|
|
2
2
|
export declare const generateNonce: (algorithm?: string) => string;
|
|
3
3
|
export declare const buildAuthChallenge: (request: AuthChallengeRequest) => {
|
|
4
4
|
realm: string;
|
|
5
|
-
scheme:
|
|
6
|
-
algorithm:
|
|
7
|
-
qop:
|
|
5
|
+
scheme: import("./types").AuthorizationScheme;
|
|
6
|
+
algorithm: import("./types").AuthorizationAlgorithm;
|
|
7
|
+
qop: import("./types").Qop;
|
|
8
8
|
opaque: string;
|
|
9
9
|
stale: boolean;
|
|
10
10
|
nonce: string;
|
|
@@ -13,3 +13,42 @@ export declare const calculateAuthResponse: (res: AuthChallengeResponse, credent
|
|
|
13
13
|
username: string;
|
|
14
14
|
secret: string;
|
|
15
15
|
}) => string;
|
|
16
|
+
export declare const getCredentials: (username: string, users: {
|
|
17
|
+
username: string;
|
|
18
|
+
secret: string;
|
|
19
|
+
}[]) => {
|
|
20
|
+
username: string;
|
|
21
|
+
secret: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const createUnauthorizedResponse: (realm: string, params?: {
|
|
24
|
+
qop: string;
|
|
25
|
+
algorithm: string;
|
|
26
|
+
}) => {
|
|
27
|
+
message: {
|
|
28
|
+
responseType: ResponseType;
|
|
29
|
+
wwwAuthenticate: {
|
|
30
|
+
scheme: string;
|
|
31
|
+
realm: string;
|
|
32
|
+
qop: string;
|
|
33
|
+
opaque: string;
|
|
34
|
+
stale: boolean;
|
|
35
|
+
nonce: string;
|
|
36
|
+
algorithm: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare const createUnauthorizedResponseWithoutChallenge: () => {
|
|
41
|
+
message: {
|
|
42
|
+
responseType: ResponseType;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export declare const createServerInternalErrorResponse: () => {
|
|
46
|
+
message: {
|
|
47
|
+
responseType: ResponseType;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export declare const createForbideenResponse: () => {
|
|
51
|
+
message: {
|
|
52
|
+
responseType: ResponseType;
|
|
53
|
+
};
|
|
54
|
+
};
|
package/dist/auth.js
CHANGED
|
@@ -3,7 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.calculateAuthResponse = exports.buildAuthChallenge = exports.generateNonce = void 0;
|
|
6
|
+
exports.createForbideenResponse = exports.createServerInternalErrorResponse = exports.createUnauthorizedResponseWithoutChallenge = exports.createUnauthorizedResponse = exports.getCredentials = exports.calculateAuthResponse = exports.buildAuthChallenge = exports.generateNonce = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster/routr
|
|
10
|
+
*
|
|
11
|
+
* This file is part of Routr
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the MIT License (the "License");
|
|
14
|
+
* you may not use this file except in compliance with
|
|
15
|
+
* the License. You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* https://opensource.org/licenses/MIT
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
const types_1 = require("./types");
|
|
7
26
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
27
|
const DEFAULT_ALGORITHM = "MD5";
|
|
9
28
|
const md5hex = (str, algorithm = DEFAULT_ALGORITHM) => crypto_1.default.createHash(algorithm).update(str).digest("hex");
|
|
@@ -35,3 +54,46 @@ const calculateAuthResponse = (res, credentials) => {
|
|
|
35
54
|
: md5hex(`${ha1}:${res.nonce}:${ha2}`);
|
|
36
55
|
};
|
|
37
56
|
exports.calculateAuthResponse = calculateAuthResponse;
|
|
57
|
+
const getCredentials = (username, users) => users.find((user) => user.username === username);
|
|
58
|
+
exports.getCredentials = getCredentials;
|
|
59
|
+
const createUnauthorizedResponse = (realm, params = { qop: "auth", algorithm: DEFAULT_ALGORITHM }) => {
|
|
60
|
+
return {
|
|
61
|
+
message: {
|
|
62
|
+
responseType: types_1.ResponseType.UNAUTHORIZED,
|
|
63
|
+
wwwAuthenticate: {
|
|
64
|
+
scheme: "Digest",
|
|
65
|
+
realm: realm,
|
|
66
|
+
qop: params.qop,
|
|
67
|
+
opaque: "",
|
|
68
|
+
stale: false,
|
|
69
|
+
nonce: (0, exports.generateNonce)(),
|
|
70
|
+
algorithm: params.algorithm
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
exports.createUnauthorizedResponse = createUnauthorizedResponse;
|
|
76
|
+
const createUnauthorizedResponseWithoutChallenge = () => {
|
|
77
|
+
return {
|
|
78
|
+
message: {
|
|
79
|
+
responseType: types_1.ResponseType.UNAUTHORIZED
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
exports.createUnauthorizedResponseWithoutChallenge = createUnauthorizedResponseWithoutChallenge;
|
|
84
|
+
const createServerInternalErrorResponse = () => {
|
|
85
|
+
return {
|
|
86
|
+
message: {
|
|
87
|
+
responseType: types_1.ResponseType.SERVER_INTERNAL_ERROR
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
exports.createServerInternalErrorResponse = createServerInternalErrorResponse;
|
|
92
|
+
const createForbideenResponse = () => {
|
|
93
|
+
return {
|
|
94
|
+
message: {
|
|
95
|
+
responseType: types_1.ResponseType.FORBIDDEN
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
exports.createForbideenResponse = createForbideenResponse;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HeaderModifier, ResponseType } from "../types";
|
|
2
|
+
export declare const CodeToResponseTypeMap: {
|
|
3
|
+
401: ResponseType;
|
|
4
|
+
403: ResponseType;
|
|
5
|
+
500: ResponseType;
|
|
6
|
+
};
|
|
7
|
+
export interface ConnectError {
|
|
8
|
+
code: keyof typeof CodeToResponseTypeMap;
|
|
9
|
+
reason?: string;
|
|
10
|
+
headers: HeaderModifier[];
|
|
11
|
+
}
|
|
12
|
+
export declare const convertToErrorResponse: (connectError: ConnectError) => {
|
|
13
|
+
message: {
|
|
14
|
+
responseType: ResponseType;
|
|
15
|
+
reasonPhrase: string;
|
|
16
|
+
extensions: {
|
|
17
|
+
name: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToErrorResponse = exports.CodeToResponseTypeMap = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
7
|
+
* http://github.com/fonoster
|
|
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
|
+
exports.CodeToResponseTypeMap = {
|
|
24
|
+
401: types_1.ResponseType.UNAUTHORIZED,
|
|
25
|
+
403: types_1.ResponseType.FORBIDDEN,
|
|
26
|
+
500: types_1.ResponseType.SERVER_ERROR
|
|
27
|
+
};
|
|
28
|
+
const convertToErrorResponse = (connectError) => {
|
|
29
|
+
return {
|
|
30
|
+
message: {
|
|
31
|
+
responseType: exports.CodeToResponseTypeMap[connectError.code],
|
|
32
|
+
reasonPhrase: connectError.reason,
|
|
33
|
+
extensions: connectError.headers.map((modifier) => {
|
|
34
|
+
if (modifier.action === types_1.HeaderModifierAction.ADD) {
|
|
35
|
+
return {
|
|
36
|
+
name: modifier.name,
|
|
37
|
+
value: modifier.value
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.convertToErrorResponse = convertToErrorResponse;
|
package/dist/connect/data_api.js
CHANGED
|
@@ -60,7 +60,7 @@ function dataAPI(apiAddr) {
|
|
|
60
60
|
get: (ref) => new Promise((resolve, reject) => {
|
|
61
61
|
client.get({ ref }, (err, response) => {
|
|
62
62
|
if (err) {
|
|
63
|
-
return
|
|
63
|
+
return err.code === grpc.status.UNAVAILABLE
|
|
64
64
|
? reject(new errors_1.ServiceUnavailableError(`api server at ${apiAddr} is unavailable`))
|
|
65
65
|
: reject(err);
|
|
66
66
|
}
|
|
@@ -74,7 +74,7 @@ function dataAPI(apiAddr) {
|
|
|
74
74
|
client.findBy(request, (err, response) => {
|
|
75
75
|
var _a;
|
|
76
76
|
if (err) {
|
|
77
|
-
return
|
|
77
|
+
return err.code === grpc.status.UNAVAILABLE
|
|
78
78
|
? reject(new errors_1.ServiceUnavailableError(`api server at ${apiAddr} is unavailable`))
|
|
79
79
|
: reject(err);
|
|
80
80
|
}
|
package/dist/connect/types.d.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum Kind {
|
|
2
2
|
AGENT = "agent",
|
|
3
3
|
PEER = "peer",
|
|
4
4
|
NUMBER = "number",
|
|
5
5
|
TRUNK = "trunk",
|
|
6
6
|
DOMAIN = "domain",
|
|
7
7
|
UNKNOWN = "unknown",
|
|
8
|
-
CREDENTIAL = "credential"
|
|
8
|
+
CREDENTIAL = "credential",
|
|
9
|
+
ACL = "accesscontrollist"
|
|
9
10
|
}
|
|
10
11
|
export declare enum FindCriteria {
|
|
11
12
|
FIND_AGENT_BY_USERNAME = "find_agent_by_username",
|
|
13
|
+
FIND_PEER_BY_USERNAME = "find_peer_by_username",
|
|
12
14
|
FIND_CREDENTIAL_BY_REFERENCE = "find_credential_by_reference",
|
|
13
15
|
FIND_DOMAIN_BY_DOMAINURI = "find_domain_by_domainuri",
|
|
14
16
|
FIND_NUMBER_BY_TELURL = "find_number_by_telurl",
|
|
15
|
-
FIND_TRUNKS_WITH_SEND_REGISTER = "find_trunks_with_send_register"
|
|
17
|
+
FIND_TRUNKS_WITH_SEND_REGISTER = "find_trunks_with_send_register",
|
|
18
|
+
FIND_TRUNK_BY_REQUEST_URI = "find_trunk_by_request_uri"
|
|
16
19
|
}
|
|
17
20
|
export interface FindParameters {
|
|
18
|
-
kind:
|
|
21
|
+
kind: Kind;
|
|
19
22
|
criteria: FindCriteria;
|
|
20
23
|
parameters: Record<string, string>;
|
|
21
24
|
}
|
|
@@ -25,7 +28,7 @@ export interface DataAPI {
|
|
|
25
28
|
}
|
|
26
29
|
export interface Resource {
|
|
27
30
|
apiVersion: string;
|
|
28
|
-
kind:
|
|
31
|
+
kind: Kind;
|
|
29
32
|
ref: string;
|
|
30
33
|
metadata: {
|
|
31
34
|
name: string;
|
package/dist/connect/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FindCriteria = exports.
|
|
3
|
+
exports.FindCriteria = exports.Kind = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
6
6
|
* http://github.com/fonoster
|
|
@@ -19,21 +19,24 @@ exports.FindCriteria = exports.KIND = void 0;
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
|
-
var
|
|
23
|
-
(function (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
var Kind;
|
|
23
|
+
(function (Kind) {
|
|
24
|
+
Kind["AGENT"] = "agent";
|
|
25
|
+
Kind["PEER"] = "peer";
|
|
26
|
+
Kind["NUMBER"] = "number";
|
|
27
|
+
Kind["TRUNK"] = "trunk";
|
|
28
|
+
Kind["DOMAIN"] = "domain";
|
|
29
|
+
Kind["UNKNOWN"] = "unknown";
|
|
30
|
+
Kind["CREDENTIAL"] = "credential";
|
|
31
|
+
Kind["ACL"] = "accesscontrollist";
|
|
32
|
+
})(Kind = exports.Kind || (exports.Kind = {}));
|
|
32
33
|
var FindCriteria;
|
|
33
34
|
(function (FindCriteria) {
|
|
34
35
|
FindCriteria["FIND_AGENT_BY_USERNAME"] = "find_agent_by_username";
|
|
36
|
+
FindCriteria["FIND_PEER_BY_USERNAME"] = "find_peer_by_username";
|
|
35
37
|
FindCriteria["FIND_CREDENTIAL_BY_REFERENCE"] = "find_credential_by_reference";
|
|
36
38
|
FindCriteria["FIND_DOMAIN_BY_DOMAINURI"] = "find_domain_by_domainuri";
|
|
37
39
|
FindCriteria["FIND_NUMBER_BY_TELURL"] = "find_number_by_telurl";
|
|
38
40
|
FindCriteria["FIND_TRUNKS_WITH_SEND_REGISTER"] = "find_trunks_with_send_register";
|
|
41
|
+
FindCriteria["FIND_TRUNK_BY_REQUEST_URI"] = "find_trunk_by_request_uri";
|
|
39
42
|
})(FindCriteria = exports.FindCriteria || (exports.FindCriteria = {}));
|
package/dist/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NetInterface, Transport } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Makes a deep copy of an object.
|
|
4
4
|
*
|
|
@@ -9,8 +9,8 @@ export declare const deepCopy: <T>(source: T) => T;
|
|
|
9
9
|
/**
|
|
10
10
|
* Gets a listening point from a request.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {Transport} transport - The
|
|
12
|
+
* @param {NetInterface[]} listeningPoints - The listening points.
|
|
13
|
+
* @param {Transport} transport - The transport.
|
|
14
14
|
* @return {NetInterface} transport The deep copy of the source object.
|
|
15
15
|
*/
|
|
16
|
-
export declare const getListeningPoint: (
|
|
16
|
+
export declare const getListeningPoint: (listeningPoints: NetInterface[], transport: Transport) => NetInterface;
|
package/dist/helper.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getListeningPoint = exports.deepCopy = void 0;
|
|
2
4
|
/*
|
|
3
5
|
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
4
6
|
* http://github.com/fonoster/routr
|
|
@@ -17,8 +19,6 @@
|
|
|
17
19
|
* See the License for the specific language governing permissions and
|
|
18
20
|
* limitations under the License.
|
|
19
21
|
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.getListeningPoint = exports.deepCopy = void 0;
|
|
22
22
|
const types_1 = require("./types");
|
|
23
23
|
/**
|
|
24
24
|
* Makes a deep copy of an object.
|
|
@@ -44,14 +44,14 @@ exports.deepCopy = deepCopy;
|
|
|
44
44
|
/**
|
|
45
45
|
* Gets a listening point from a request.
|
|
46
46
|
*
|
|
47
|
-
* @param {
|
|
48
|
-
* @param {Transport} transport - The
|
|
47
|
+
* @param {NetInterface[]} listeningPoints - The listening points.
|
|
48
|
+
* @param {Transport} transport - The transport.
|
|
49
49
|
* @return {NetInterface} transport The deep copy of the source object.
|
|
50
50
|
*/
|
|
51
|
-
const getListeningPoint = (
|
|
51
|
+
const getListeningPoint = (listeningPoints, transport) => {
|
|
52
52
|
const listeningPoint = transport
|
|
53
|
-
?
|
|
54
|
-
:
|
|
53
|
+
? listeningPoints.find((lp) => lp.transport.toLowerCase() === transport.toLowerCase())
|
|
54
|
+
: listeningPoints.find((lp) => lp.transport.toLowerCase() === types_1.Transport.UDP);
|
|
55
55
|
if (!listeningPoint) {
|
|
56
56
|
throw new Error(`no listening point found for transport ${transport}`);
|
|
57
57
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { calculateAuthResponse, generateNonce } from "./auth";
|
|
2
1
|
import { ServiceUnavailableError } from "./errors";
|
|
3
2
|
import createService, { getObjectProto, LOCATION_OBJECT_PROTO, PROCESSOR_OBJECT_PROTO } from "./service";
|
|
4
3
|
import { HeaderModifier, MessageRequest, MessageResponse, Method, NetInterface, ObjectProto, ProcessorConfig, Route, ServiceInfo, Transport } from "./types";
|
|
5
|
-
export { createService, getObjectProto,
|
|
4
|
+
export { createService, getObjectProto, HeaderModifier, Route, ServiceUnavailableError, Transport, ProcessorConfig, MessageRequest, MessageResponse, NetInterface, Method, ObjectProto, ServiceInfo, PROCESSOR_OBJECT_PROTO, LOCATION_OBJECT_PROTO };
|
|
6
5
|
export * as Redis from "./redis";
|
|
7
6
|
export * as CommonTypes from "./types";
|
|
8
7
|
export * as Helper from "./helper";
|
|
@@ -11,3 +10,4 @@ export * as Tracer from "./tracer";
|
|
|
11
10
|
export * as Assertions from "./assertions";
|
|
12
11
|
export * as CommonConnect from "./connect";
|
|
13
12
|
export * as CommonRequester from "./requester";
|
|
13
|
+
export * as Auth from "./auth";
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.CommonRequester = exports.CommonConnect = exports.Assertions = exports.Tracer = exports.IpUtils = exports.Helper = exports.CommonTypes = exports.Redis = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = exports.Method = exports.Transport = exports.ServiceUnavailableError = exports.
|
|
26
|
+
exports.Auth = exports.CommonRequester = exports.CommonConnect = exports.Assertions = exports.Tracer = exports.IpUtils = exports.Helper = exports.CommonTypes = exports.Redis = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = exports.Method = exports.Transport = exports.ServiceUnavailableError = exports.getObjectProto = exports.createService = void 0;
|
|
27
27
|
/*
|
|
28
28
|
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
29
29
|
* http://github.com/fonoster/routr
|
|
@@ -42,9 +42,6 @@ exports.CommonRequester = exports.CommonConnect = exports.Assertions = exports.T
|
|
|
42
42
|
* See the License for the specific language governing permissions and
|
|
43
43
|
* limitations under the License.
|
|
44
44
|
*/
|
|
45
|
-
const auth_1 = require("./auth");
|
|
46
|
-
Object.defineProperty(exports, "calculateAuthResponse", { enumerable: true, get: function () { return auth_1.calculateAuthResponse; } });
|
|
47
|
-
Object.defineProperty(exports, "generateNonce", { enumerable: true, get: function () { return auth_1.generateNonce; } });
|
|
48
45
|
const errors_1 = require("./errors");
|
|
49
46
|
Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return errors_1.ServiceUnavailableError; } });
|
|
50
47
|
const service_1 = __importStar(require("./service"));
|
|
@@ -63,3 +60,4 @@ exports.Tracer = __importStar(require("./tracer"));
|
|
|
63
60
|
exports.Assertions = __importStar(require("./assertions"));
|
|
64
61
|
exports.CommonConnect = __importStar(require("./connect"));
|
|
65
62
|
exports.CommonRequester = __importStar(require("./requester"));
|
|
63
|
+
exports.Auth = __importStar(require("./auth"));
|
|
@@ -34,7 +34,7 @@ service Location {
|
|
|
34
34
|
rpc RemoveRoutes (RemoveRoutesRequest) returns (fonoster.routr.common.v2draft1.Empty) {}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
// A binding
|
|
37
|
+
// A binding created by an actual endpoint (Softphone, PBX, Conference System, etc.)
|
|
38
38
|
message Route {
|
|
39
39
|
string user = 1;
|
|
40
40
|
string host = 2;
|
|
@@ -44,11 +44,13 @@ message Route {
|
|
|
44
44
|
int32 expires = 6;
|
|
45
45
|
int32 session_count = 7;
|
|
46
46
|
string edge_port_ref = 8;
|
|
47
|
-
fonoster.routr.processor.v2draft1.NetInterface
|
|
47
|
+
repeated fonoster.routr.processor.v2draft1.NetInterface listening_points = 9;
|
|
48
|
+
repeated string localnets = 10;
|
|
49
|
+
repeated string external_addrs = 11;
|
|
48
50
|
// During route creation, an endpoint can request to add labels than can later be
|
|
49
51
|
// used as selectors. For example, a Softphone can add a label `priority=1` to indicate
|
|
50
52
|
// that it is the prefered endpoint for the given AOR.
|
|
51
|
-
map<string, string> labels =
|
|
53
|
+
map<string, string> labels = 12;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
message AddRouteRequest {
|
|
@@ -58,8 +60,10 @@ message AddRouteRequest {
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
message FindRoutesRequest {
|
|
61
|
-
string
|
|
62
|
-
|
|
63
|
+
string call_id = 1;
|
|
64
|
+
string aor = 2;
|
|
65
|
+
string session_affinity_ref = 3;
|
|
66
|
+
map<string, string> labels = 4;
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
message FindRoutesResponse {
|
package/dist/types.d.ts
CHANGED
|
@@ -24,12 +24,25 @@ export declare enum ExtraHeader {
|
|
|
24
24
|
REQUEST_URI = "X-Request-Uri",
|
|
25
25
|
GATEWAY_AUTH = "X-Gateway-Auth",
|
|
26
26
|
EDGEPORT_REF = "X-Edgeport-Ref",
|
|
27
|
-
SESSION_COUNT = "X-Session-Count"
|
|
27
|
+
SESSION_COUNT = "X-Session-Count",
|
|
28
|
+
DOD_NUMBER = "X-DOD-Number",
|
|
29
|
+
DOD_PRIVACY = "X-DOD-Privacy"
|
|
28
30
|
}
|
|
29
31
|
export declare enum Privacy {
|
|
30
32
|
NONE = "none",
|
|
31
33
|
PRIVATE = "id"
|
|
32
34
|
}
|
|
35
|
+
export declare enum AuthorizationAlgorithm {
|
|
36
|
+
MD5 = "MD5"
|
|
37
|
+
}
|
|
38
|
+
export declare enum AuthorizationScheme {
|
|
39
|
+
DIGEST = "Digest"
|
|
40
|
+
}
|
|
41
|
+
export declare enum Qop {
|
|
42
|
+
AUTH = "auth",
|
|
43
|
+
AUTH_INT = "auth-int",
|
|
44
|
+
NONE = ""
|
|
45
|
+
}
|
|
33
46
|
export interface NetInterface {
|
|
34
47
|
host: string;
|
|
35
48
|
port: number;
|
|
@@ -72,28 +85,28 @@ export interface ObjectProto {
|
|
|
72
85
|
export interface AuthChallengeRequest {
|
|
73
86
|
realm: string;
|
|
74
87
|
domain: string;
|
|
75
|
-
scheme: string;
|
|
76
|
-
nonce: string;
|
|
77
|
-
algorithm: string;
|
|
78
|
-
qop: string;
|
|
79
88
|
opaque: string;
|
|
80
89
|
stale: boolean;
|
|
90
|
+
nonce: string;
|
|
91
|
+
scheme: AuthorizationScheme;
|
|
92
|
+
algorithm: AuthorizationAlgorithm;
|
|
93
|
+
qop: Qop;
|
|
81
94
|
}
|
|
82
95
|
export interface AuthChallengeResponse {
|
|
83
96
|
realm: string;
|
|
84
97
|
domain: string;
|
|
85
|
-
scheme: string;
|
|
86
98
|
cNonce: string;
|
|
99
|
+
nonce: string;
|
|
87
100
|
nonceCount: number;
|
|
88
101
|
response: string;
|
|
89
102
|
username: string;
|
|
90
|
-
nonce: string;
|
|
91
|
-
algorithm: string;
|
|
92
|
-
qop: string;
|
|
93
103
|
opaque: string;
|
|
94
104
|
stale: boolean;
|
|
95
105
|
uri: string;
|
|
96
|
-
method:
|
|
106
|
+
method: Method;
|
|
107
|
+
scheme: AuthorizationScheme;
|
|
108
|
+
algorithm: AuthorizationAlgorithm;
|
|
109
|
+
qop: Qop;
|
|
97
110
|
}
|
|
98
111
|
export declare enum HeaderModifierAction {
|
|
99
112
|
ADD = "add",
|
|
@@ -110,10 +123,19 @@ export interface Route {
|
|
|
110
123
|
port: number;
|
|
111
124
|
transport: Transport;
|
|
112
125
|
registeredOn?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Number of active sessions. This is used to determine if a route is
|
|
128
|
+
* overloaded and for load balancing.
|
|
129
|
+
*
|
|
130
|
+
* This value is reported by the endpoint during the REGISTER request,
|
|
131
|
+
* using the X-Session-Count header.
|
|
132
|
+
*/
|
|
113
133
|
sessionCount?: number;
|
|
114
134
|
expires?: number;
|
|
115
135
|
edgePortRef: string;
|
|
116
|
-
|
|
136
|
+
listeningPoints: NetInterface[];
|
|
137
|
+
localnets: string[];
|
|
138
|
+
externalAddrs: string[];
|
|
117
139
|
labels?: Map<string, string>;
|
|
118
140
|
headers?: HeaderModifier[];
|
|
119
141
|
}
|
|
@@ -189,17 +211,17 @@ export interface WWWAuthenticate {
|
|
|
189
211
|
}
|
|
190
212
|
export interface Authorization {
|
|
191
213
|
realm: string;
|
|
192
|
-
scheme:
|
|
214
|
+
scheme: AuthorizationScheme;
|
|
193
215
|
nonce: string;
|
|
194
216
|
cNonce: string;
|
|
195
217
|
nonceCount: number;
|
|
196
218
|
response: string;
|
|
197
219
|
username: string;
|
|
198
220
|
uri: string;
|
|
199
|
-
algorithm:
|
|
200
|
-
qop:
|
|
221
|
+
algorithm: AuthorizationAlgorithm;
|
|
222
|
+
qop: Qop;
|
|
201
223
|
opaque: string;
|
|
202
|
-
method?:
|
|
224
|
+
method?: Method;
|
|
203
225
|
}
|
|
204
226
|
export interface CallID {
|
|
205
227
|
callId: string;
|
|
@@ -281,10 +303,10 @@ export interface SIPMessage {
|
|
|
281
303
|
wwwAuthenticate?: WWWAuthenticate;
|
|
282
304
|
maxForwards: MaxForwards;
|
|
283
305
|
authorization?: Authorization;
|
|
284
|
-
extensions
|
|
285
|
-
via
|
|
286
|
-
route
|
|
287
|
-
recordRoute
|
|
306
|
+
extensions: Extension[];
|
|
307
|
+
via: Via[];
|
|
308
|
+
route: RouteHeader[];
|
|
309
|
+
recordRoute: RecordRoute[];
|
|
288
310
|
}
|
|
289
311
|
export interface GrpcCallback {
|
|
290
312
|
(error: Error | {
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageType = exports.ResponseType = exports.HeaderModifierAction = exports.Privacy = exports.ExtraHeader = exports.Transport = exports.Method = void 0;
|
|
3
|
+
exports.MessageType = exports.ResponseType = exports.HeaderModifierAction = exports.Qop = exports.AuthorizationScheme = exports.AuthorizationAlgorithm = exports.Privacy = exports.ExtraHeader = exports.Transport = exports.Method = void 0;
|
|
4
4
|
var Method;
|
|
5
5
|
(function (Method) {
|
|
6
6
|
Method["UNKNOWN"] = "UNKNOWN";
|
|
@@ -30,12 +30,28 @@ var ExtraHeader;
|
|
|
30
30
|
ExtraHeader["GATEWAY_AUTH"] = "X-Gateway-Auth";
|
|
31
31
|
ExtraHeader["EDGEPORT_REF"] = "X-Edgeport-Ref";
|
|
32
32
|
ExtraHeader["SESSION_COUNT"] = "X-Session-Count";
|
|
33
|
+
ExtraHeader["DOD_NUMBER"] = "X-DOD-Number";
|
|
34
|
+
ExtraHeader["DOD_PRIVACY"] = "X-DOD-Privacy";
|
|
33
35
|
})(ExtraHeader = exports.ExtraHeader || (exports.ExtraHeader = {}));
|
|
34
36
|
var Privacy;
|
|
35
37
|
(function (Privacy) {
|
|
36
38
|
Privacy["NONE"] = "none";
|
|
37
39
|
Privacy["PRIVATE"] = "id";
|
|
38
40
|
})(Privacy = exports.Privacy || (exports.Privacy = {}));
|
|
41
|
+
var AuthorizationAlgorithm;
|
|
42
|
+
(function (AuthorizationAlgorithm) {
|
|
43
|
+
AuthorizationAlgorithm["MD5"] = "MD5";
|
|
44
|
+
})(AuthorizationAlgorithm = exports.AuthorizationAlgorithm || (exports.AuthorizationAlgorithm = {}));
|
|
45
|
+
var AuthorizationScheme;
|
|
46
|
+
(function (AuthorizationScheme) {
|
|
47
|
+
AuthorizationScheme["DIGEST"] = "Digest";
|
|
48
|
+
})(AuthorizationScheme = exports.AuthorizationScheme || (exports.AuthorizationScheme = {}));
|
|
49
|
+
var Qop;
|
|
50
|
+
(function (Qop) {
|
|
51
|
+
Qop["AUTH"] = "auth";
|
|
52
|
+
Qop["AUTH_INT"] = "auth-int";
|
|
53
|
+
Qop["NONE"] = "";
|
|
54
|
+
})(Qop = exports.Qop || (exports.Qop = {}));
|
|
39
55
|
var HeaderModifierAction;
|
|
40
56
|
(function (HeaderModifierAction) {
|
|
41
57
|
HeaderModifierAction["ADD"] = "add";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/common",
|
|
3
|
-
"version": "2.0.8-alpha.
|
|
3
|
+
"version": "2.0.8-alpha.11",
|
|
4
4
|
"description": "Common package",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"bugs": {
|
|
46
46
|
"url": "https://github.com/fonoster/routr/issues"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "627659ac51d0814a3106bcaac31a15c581a5809f"
|
|
49
49
|
}
|