@routr/common 2.0.8-alpha.10 → 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 +8 -8
- package/dist/auth.js +24 -9
- package/dist/connect/connect_error.d.ts +21 -0
- package/dist/connect/connect_error.js +44 -0
- package/dist/protos/location.proto +4 -2
- package/dist/protos/sipmessage.proto +2 -0
- package/dist/types.d.ts +31 -13
- package/dist/types.js +15 -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;
|
|
@@ -25,7 +25,7 @@ export declare const createUnauthorizedResponse: (realm: string, params?: {
|
|
|
25
25
|
algorithm: string;
|
|
26
26
|
}) => {
|
|
27
27
|
message: {
|
|
28
|
-
responseType:
|
|
28
|
+
responseType: ResponseType;
|
|
29
29
|
wwwAuthenticate: {
|
|
30
30
|
scheme: string;
|
|
31
31
|
realm: string;
|
|
@@ -39,16 +39,16 @@ export declare const createUnauthorizedResponse: (realm: string, params?: {
|
|
|
39
39
|
};
|
|
40
40
|
export declare const createUnauthorizedResponseWithoutChallenge: () => {
|
|
41
41
|
message: {
|
|
42
|
-
responseType:
|
|
42
|
+
responseType: ResponseType;
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
45
|
export declare const createServerInternalErrorResponse: () => {
|
|
46
46
|
message: {
|
|
47
|
-
responseType:
|
|
47
|
+
responseType: ResponseType;
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
export declare const createForbideenResponse: () => {
|
|
51
51
|
message: {
|
|
52
|
-
responseType:
|
|
52
|
+
responseType: ResponseType;
|
|
53
53
|
};
|
|
54
54
|
};
|
package/dist/auth.js
CHANGED
|
@@ -4,6 +4,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
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");
|
|
@@ -37,11 +56,10 @@ const calculateAuthResponse = (res, credentials) => {
|
|
|
37
56
|
exports.calculateAuthResponse = calculateAuthResponse;
|
|
38
57
|
const getCredentials = (username, users) => users.find((user) => user.username === username);
|
|
39
58
|
exports.getCredentials = getCredentials;
|
|
40
|
-
const createUnauthorizedResponse = (realm, params = { qop: "auth", algorithm:
|
|
59
|
+
const createUnauthorizedResponse = (realm, params = { qop: "auth", algorithm: DEFAULT_ALGORITHM }) => {
|
|
41
60
|
return {
|
|
42
61
|
message: {
|
|
43
|
-
|
|
44
|
-
responseType: 17,
|
|
62
|
+
responseType: types_1.ResponseType.UNAUTHORIZED,
|
|
45
63
|
wwwAuthenticate: {
|
|
46
64
|
scheme: "Digest",
|
|
47
65
|
realm: realm,
|
|
@@ -58,8 +76,7 @@ exports.createUnauthorizedResponse = createUnauthorizedResponse;
|
|
|
58
76
|
const createUnauthorizedResponseWithoutChallenge = () => {
|
|
59
77
|
return {
|
|
60
78
|
message: {
|
|
61
|
-
|
|
62
|
-
responseType: 17
|
|
79
|
+
responseType: types_1.ResponseType.UNAUTHORIZED
|
|
63
80
|
}
|
|
64
81
|
};
|
|
65
82
|
};
|
|
@@ -67,8 +84,7 @@ exports.createUnauthorizedResponseWithoutChallenge = createUnauthorizedResponseW
|
|
|
67
84
|
const createServerInternalErrorResponse = () => {
|
|
68
85
|
return {
|
|
69
86
|
message: {
|
|
70
|
-
|
|
71
|
-
responseType: 46
|
|
87
|
+
responseType: types_1.ResponseType.SERVER_INTERNAL_ERROR
|
|
72
88
|
}
|
|
73
89
|
};
|
|
74
90
|
};
|
|
@@ -76,8 +92,7 @@ exports.createServerInternalErrorResponse = createServerInternalErrorResponse;
|
|
|
76
92
|
const createForbideenResponse = () => {
|
|
77
93
|
return {
|
|
78
94
|
message: {
|
|
79
|
-
|
|
80
|
-
responseType: 19
|
|
95
|
+
responseType: types_1.ResponseType.FORBIDDEN
|
|
81
96
|
}
|
|
82
97
|
};
|
|
83
98
|
};
|
|
@@ -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;
|
|
@@ -60,8 +60,10 @@ message AddRouteRequest {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
message FindRoutesRequest {
|
|
63
|
-
string
|
|
64
|
-
|
|
63
|
+
string call_id = 1;
|
|
64
|
+
string aor = 2;
|
|
65
|
+
string session_affinity_ref = 3;
|
|
66
|
+
map<string, string> labels = 4;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
message FindRoutesResponse {
|
package/dist/types.d.ts
CHANGED
|
@@ -32,6 +32,17 @@ export declare enum Privacy {
|
|
|
32
32
|
NONE = "none",
|
|
33
33
|
PRIVATE = "id"
|
|
34
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
|
+
}
|
|
35
46
|
export interface NetInterface {
|
|
36
47
|
host: string;
|
|
37
48
|
port: number;
|
|
@@ -74,28 +85,28 @@ export interface ObjectProto {
|
|
|
74
85
|
export interface AuthChallengeRequest {
|
|
75
86
|
realm: string;
|
|
76
87
|
domain: string;
|
|
77
|
-
scheme: string;
|
|
78
|
-
nonce: string;
|
|
79
|
-
algorithm: string;
|
|
80
|
-
qop: string;
|
|
81
88
|
opaque: string;
|
|
82
89
|
stale: boolean;
|
|
90
|
+
nonce: string;
|
|
91
|
+
scheme: AuthorizationScheme;
|
|
92
|
+
algorithm: AuthorizationAlgorithm;
|
|
93
|
+
qop: Qop;
|
|
83
94
|
}
|
|
84
95
|
export interface AuthChallengeResponse {
|
|
85
96
|
realm: string;
|
|
86
97
|
domain: string;
|
|
87
|
-
scheme: string;
|
|
88
98
|
cNonce: string;
|
|
99
|
+
nonce: string;
|
|
89
100
|
nonceCount: number;
|
|
90
101
|
response: string;
|
|
91
102
|
username: string;
|
|
92
|
-
nonce: string;
|
|
93
|
-
algorithm: string;
|
|
94
|
-
qop: string;
|
|
95
103
|
opaque: string;
|
|
96
104
|
stale: boolean;
|
|
97
105
|
uri: string;
|
|
98
|
-
method:
|
|
106
|
+
method: Method;
|
|
107
|
+
scheme: AuthorizationScheme;
|
|
108
|
+
algorithm: AuthorizationAlgorithm;
|
|
109
|
+
qop: Qop;
|
|
99
110
|
}
|
|
100
111
|
export declare enum HeaderModifierAction {
|
|
101
112
|
ADD = "add",
|
|
@@ -112,6 +123,13 @@ export interface Route {
|
|
|
112
123
|
port: number;
|
|
113
124
|
transport: Transport;
|
|
114
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
|
+
*/
|
|
115
133
|
sessionCount?: number;
|
|
116
134
|
expires?: number;
|
|
117
135
|
edgePortRef: string;
|
|
@@ -193,17 +211,17 @@ export interface WWWAuthenticate {
|
|
|
193
211
|
}
|
|
194
212
|
export interface Authorization {
|
|
195
213
|
realm: string;
|
|
196
|
-
scheme:
|
|
214
|
+
scheme: AuthorizationScheme;
|
|
197
215
|
nonce: string;
|
|
198
216
|
cNonce: string;
|
|
199
217
|
nonceCount: number;
|
|
200
218
|
response: string;
|
|
201
219
|
username: string;
|
|
202
220
|
uri: string;
|
|
203
|
-
algorithm:
|
|
204
|
-
qop:
|
|
221
|
+
algorithm: AuthorizationAlgorithm;
|
|
222
|
+
qop: Qop;
|
|
205
223
|
opaque: string;
|
|
206
|
-
method?:
|
|
224
|
+
method?: Method;
|
|
207
225
|
}
|
|
208
226
|
export interface CallID {
|
|
209
227
|
callId: string;
|
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";
|
|
@@ -38,6 +38,20 @@ var Privacy;
|
|
|
38
38
|
Privacy["NONE"] = "none";
|
|
39
39
|
Privacy["PRIVATE"] = "id";
|
|
40
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 = {}));
|
|
41
55
|
var HeaderModifierAction;
|
|
42
56
|
(function (HeaderModifierAction) {
|
|
43
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
|
}
|