@routr/common 2.0.8-alpha.4 → 2.0.8-alpha.41
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/assertions.js +2 -2
- package/dist/auth.d.ts +47 -4
- package/dist/auth.js +67 -1
- package/dist/connect/api/client.d.ts +3 -0
- package/dist/connect/api/client.js +158 -0
- package/dist/connect/api/index.d.ts +2 -0
- package/dist/connect/api/index.js +36 -0
- package/dist/connect/api/types.d.ts +51 -0
- package/dist/connect/api/types.js +2 -0
- package/dist/connect/assertions.d.ts +37 -0
- package/dist/connect/assertions.js +112 -0
- package/dist/connect/client.d.ts +8 -0
- package/dist/connect/client.js +94 -0
- package/dist/connect/config.d.ts +113 -0
- package/dist/connect/config.js +2 -0
- package/dist/connect/connect_error.d.ts +21 -0
- package/dist/connect/connect_error.js +44 -0
- package/dist/connect/index.d.ts +7 -2
- package/dist/connect/index.js +8 -3
- package/dist/connect/mappers/acl.d.ts +3 -0
- package/dist/connect/mappers/acl.js +19 -0
- package/dist/connect/mappers/agent.d.ts +3 -0
- package/dist/connect/mappers/agent.js +42 -0
- package/dist/connect/mappers/assertions.d.ts +3 -0
- package/dist/connect/mappers/assertions.js +43 -0
- package/dist/connect/mappers/credentials.d.ts +3 -0
- package/dist/connect/mappers/credentials.js +18 -0
- package/dist/connect/mappers/domain.d.ts +3 -0
- package/dist/connect/mappers/domain.js +19 -0
- package/dist/connect/mappers/index.d.ts +7 -0
- package/dist/connect/mappers/index.js +41 -0
- package/dist/connect/mappers/number.d.ts +3 -0
- package/dist/connect/mappers/number.js +26 -0
- package/dist/connect/mappers/peer.d.ts +3 -0
- package/dist/connect/mappers/peer.js +26 -0
- package/dist/connect/mappers/trunk.d.ts +3 -0
- package/dist/connect/mappers/trunk.js +34 -0
- package/dist/connect/protos/acl.proto +112 -0
- package/dist/connect/protos/agents.proto +153 -0
- package/dist/connect/protos/credentials.proto +114 -0
- package/dist/connect/protos/domains.proto +146 -0
- package/dist/connect/protos/numbers.proto +166 -0
- package/dist/connect/protos/peers.proto +174 -0
- package/dist/connect/protos/trunks.proto +178 -0
- package/dist/connect/schemas/acl.d.ts +66 -0
- package/dist/connect/schemas/acl.js +85 -0
- package/dist/connect/schemas/agent.d.ts +61 -0
- package/dist/connect/schemas/agent.js +80 -0
- package/dist/connect/schemas/crendentials.d.ts +59 -0
- package/dist/connect/schemas/crendentials.js +78 -0
- package/dist/connect/schemas/domain.d.ts +72 -0
- package/dist/connect/schemas/domain.js +91 -0
- package/dist/connect/schemas/index.d.ts +1 -0
- package/dist/connect/schemas/index.js +35 -0
- package/dist/connect/schemas/number.d.ts +81 -0
- package/dist/connect/schemas/number.js +100 -0
- package/dist/connect/schemas/peer.d.ts +84 -0
- package/dist/connect/schemas/peer.js +103 -0
- package/dist/connect/schemas/trunk.d.ts +125 -0
- package/dist/connect/schemas/trunk.js +157 -0
- package/dist/connect/schemas/validators.d.ts +2 -0
- package/dist/connect/schemas/validators.js +43 -0
- package/dist/connect/types.d.ts +91 -23
- package/dist/connect/types.js +17 -37
- package/dist/connect/validations.d.ts +43 -0
- package/dist/connect/validations.js +272 -0
- package/dist/envs.d.ts +2 -0
- package/dist/envs.js +23 -0
- package/dist/errors.d.ts +35 -1
- package/dist/errors.js +52 -6
- package/dist/healthcheck.d.ts +1 -0
- package/dist/healthcheck.js +24 -0
- package/dist/helper.d.ts +17 -4
- package/dist/helper.js +82 -8
- package/dist/index.d.ts +8 -4
- package/dist/index.js +9 -8
- package/dist/ip_utils.js +1 -1
- package/dist/protos/common.proto +1 -3
- package/dist/protos/location.proto +23 -8
- package/dist/protos/processor.proto +5 -3
- package/dist/protos/requester.proto +1 -1
- package/dist/protos/sipmessage.proto +8 -1
- package/dist/protos/verifier.proto +39 -0
- package/dist/requester/grpc_client.js +1 -1
- package/dist/requester/index.js +1 -1
- package/dist/service.d.ts +2 -2
- package/dist/service.js +26 -4
- package/dist/tracer.js +1 -1
- package/dist/types.d.ts +121 -88
- package/dist/types.js +79 -69
- package/dist/verifier/grpc_client.d.ts +1 -0
- package/dist/{connect → verifier}/grpc_client.js +4 -4
- package/dist/verifier/index.d.ts +2 -0
- package/dist/verifier/index.js +36 -0
- package/dist/verifier/types.d.ts +10 -0
- package/dist/verifier/types.js +2 -0
- package/dist/verifier/verifier.d.ts +3 -0
- package/dist/verifier/verifier.js +64 -0
- package/package.json +17 -7
- package/dist/connect/data_api.d.ts +0 -11
- package/dist/connect/data_api.js +0 -91
- package/dist/connect/grpc_client.d.ts +0 -1
- package/dist/protos/resources.proto +0 -108
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { LoadBalancingAlgorithm, Privacy, Transport } from "../types";
|
|
2
|
+
import { Kind } from "./types";
|
|
3
|
+
export interface ConfigBase {
|
|
4
|
+
apiVersion: string;
|
|
5
|
+
ref: string;
|
|
6
|
+
metadata: {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface AccessControlListConfig extends ConfigBase {
|
|
11
|
+
kind: Kind.ACL;
|
|
12
|
+
spec: {
|
|
13
|
+
accessControlList: {
|
|
14
|
+
allow: string[];
|
|
15
|
+
deny: string[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface AgentConfig extends ConfigBase {
|
|
20
|
+
kind: Kind.AGENT;
|
|
21
|
+
spec: {
|
|
22
|
+
username: string;
|
|
23
|
+
domainRef: string;
|
|
24
|
+
credentialsRef: string;
|
|
25
|
+
privacy: Privacy;
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface PeerConfig extends ConfigBase {
|
|
30
|
+
kind: Kind.PEER;
|
|
31
|
+
spec: {
|
|
32
|
+
aor: string;
|
|
33
|
+
username: string;
|
|
34
|
+
credentialsRef?: string;
|
|
35
|
+
contactAddr?: string;
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
loadBalancing?: {
|
|
38
|
+
algorithm: LoadBalancingAlgorithm;
|
|
39
|
+
withSessionAffinity: boolean;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface CredentialsConfig extends ConfigBase {
|
|
44
|
+
kind: Kind.CREDENTIALS;
|
|
45
|
+
spec: {
|
|
46
|
+
credentials: {
|
|
47
|
+
username: string;
|
|
48
|
+
password: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export interface DomainConfig extends ConfigBase {
|
|
53
|
+
kind: Kind.DOMAIN;
|
|
54
|
+
spec: {
|
|
55
|
+
accessControlListRef?: string;
|
|
56
|
+
context: {
|
|
57
|
+
domainUri: string;
|
|
58
|
+
egressPolicies?: {
|
|
59
|
+
rule: string;
|
|
60
|
+
numberRef: string;
|
|
61
|
+
}[];
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export interface NumberConfig extends Omit<ConfigBase, "metadata"> {
|
|
66
|
+
kind: Kind.NUMBER;
|
|
67
|
+
metadata: {
|
|
68
|
+
name: string;
|
|
69
|
+
geoInfo: {
|
|
70
|
+
city: string;
|
|
71
|
+
country: string;
|
|
72
|
+
countryISOCode: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
spec: {
|
|
76
|
+
trunkRef: string;
|
|
77
|
+
location: {
|
|
78
|
+
telUrl: string;
|
|
79
|
+
aorLink: string;
|
|
80
|
+
sessionAffinityHeader: string;
|
|
81
|
+
extraHeaders: {
|
|
82
|
+
name: string;
|
|
83
|
+
value: string;
|
|
84
|
+
}[];
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export interface TrunkConfig extends ConfigBase {
|
|
89
|
+
kind: Kind.TRUNK;
|
|
90
|
+
spec: {
|
|
91
|
+
inbound: {
|
|
92
|
+
uri: string;
|
|
93
|
+
accessControlListRef: string;
|
|
94
|
+
credentialsRef: string;
|
|
95
|
+
};
|
|
96
|
+
outbound: {
|
|
97
|
+
sendRegister: boolean;
|
|
98
|
+
credentialsRef: string;
|
|
99
|
+
uris: {
|
|
100
|
+
uri: {
|
|
101
|
+
user: string;
|
|
102
|
+
host: string;
|
|
103
|
+
port: number;
|
|
104
|
+
transport: Transport;
|
|
105
|
+
};
|
|
106
|
+
priority: number;
|
|
107
|
+
weight: number;
|
|
108
|
+
enabled: boolean;
|
|
109
|
+
}[];
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export type UserConfig = AccessControlListConfig | AgentConfig | PeerConfig | CredentialsConfig | DomainConfig | NumberConfig | TrunkConfig;
|
|
@@ -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
|
+
/*
|
|
5
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster
|
|
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
|
+
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/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./api";
|
|
2
|
+
export * from "./client";
|
|
3
3
|
export * from "./types";
|
|
4
|
+
export * from "./config";
|
|
5
|
+
export * from "./mappers";
|
|
6
|
+
export * from "./assertions";
|
|
7
|
+
export * from "./validations";
|
|
8
|
+
export * from "./connect_error";
|
package/dist/connect/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
/*
|
|
18
|
-
* Copyright (C)
|
|
18
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
19
19
|
* http://github.com/fonoster
|
|
20
20
|
*
|
|
21
21
|
* This file is part of Routr.
|
|
@@ -32,6 +32,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
32
32
|
* See the License for the specific language governing permissions and
|
|
33
33
|
* limitations under the License.
|
|
34
34
|
*/
|
|
35
|
-
__exportStar(require("./
|
|
36
|
-
__exportStar(require("./
|
|
35
|
+
__exportStar(require("./api"), exports);
|
|
36
|
+
__exportStar(require("./client"), exports);
|
|
37
37
|
__exportStar(require("./types"), exports);
|
|
38
|
+
__exportStar(require("./config"), exports);
|
|
39
|
+
__exportStar(require("./mappers"), exports);
|
|
40
|
+
__exportStar(require("./assertions"), exports);
|
|
41
|
+
__exportStar(require("./validations"), exports);
|
|
42
|
+
__exportStar(require("./connect_error"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapToACL = void 0;
|
|
4
|
+
const schemas_1 = require("../schemas");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const assertions_1 = require("./assertions");
|
|
7
|
+
const valid = schemas_1.schemaValidators.get(types_1.Kind.ACL);
|
|
8
|
+
function mapToACL(config) {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
|
+
(0, assertions_1.assertValidSchema)(config, valid);
|
|
11
|
+
return {
|
|
12
|
+
apiVersion: config.apiVersion,
|
|
13
|
+
ref: config.ref,
|
|
14
|
+
name: config.metadata.name,
|
|
15
|
+
allow: (_b = (_a = config.spec.accessControlList) === null || _a === void 0 ? void 0 : _a.allow) !== null && _b !== void 0 ? _b : [],
|
|
16
|
+
deny: (_d = (_c = config.spec.accessControlList) === null || _c === void 0 ? void 0 : _c.deny) !== null && _d !== void 0 ? _d : []
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.mapToACL = mapToACL;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapToAgent = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster
|
|
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
|
+
/* eslint-disable require-jsdoc */
|
|
23
|
+
const types_1 = require("../../types");
|
|
24
|
+
const schemas_1 = require("../schemas");
|
|
25
|
+
const types_2 = require("../types");
|
|
26
|
+
const assertions_1 = require("./assertions");
|
|
27
|
+
const valid = schemas_1.schemaValidators.get(types_2.Kind.AGENT);
|
|
28
|
+
function mapToAgent(config) {
|
|
29
|
+
var _a;
|
|
30
|
+
(0, assertions_1.assertValidSchema)(config, valid);
|
|
31
|
+
return {
|
|
32
|
+
apiVersion: config.apiVersion,
|
|
33
|
+
ref: config.ref,
|
|
34
|
+
name: config.metadata.name,
|
|
35
|
+
username: config.spec.username,
|
|
36
|
+
privacy: (_a = config.spec.privacy) !== null && _a !== void 0 ? _a : types_1.Privacy.NONE,
|
|
37
|
+
enabled: config.spec.enabled,
|
|
38
|
+
domainRef: config.spec.domainRef,
|
|
39
|
+
credentialsRef: config.spec.credentialsRef
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.mapToAgent = mapToAgent;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertValidAorSchema = exports.assertValidSchema = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster
|
|
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 logger_1 = require("@fonoster/logger");
|
|
23
|
+
const logger = (0, logger_1.getLogger)({ service: "common", filePath: __filename });
|
|
24
|
+
const assertValidSchema = (config, valid) => {
|
|
25
|
+
if (!valid(config)) {
|
|
26
|
+
const error = valid.errors[0];
|
|
27
|
+
logger.error("found a bad resource: " + error.message + " at `" + error.dataPath + "`");
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.assertValidSchema = assertValidSchema;
|
|
32
|
+
const assertValidAorSchema = (config) => {
|
|
33
|
+
const spec = config.spec;
|
|
34
|
+
if (spec.aor.startsWith("backend:") && !spec.loadBalancing) {
|
|
35
|
+
logger.error("found a bad resource: balancing algorithm is required for `backend:` aors");
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
if (spec.aor.startsWith("sip:") && spec.loadBalancing) {
|
|
39
|
+
logger.error("found a bad resource: balancing algorithm is not allowed for `sip:` aors");
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.assertValidAorSchema = assertValidAorSchema;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapToCredentials = void 0;
|
|
4
|
+
const schemas_1 = require("../schemas");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const assertions_1 = require("./assertions");
|
|
7
|
+
const valid = schemas_1.schemaValidators.get(types_1.Kind.CREDENTIALS);
|
|
8
|
+
function mapToCredentials(config) {
|
|
9
|
+
(0, assertions_1.assertValidSchema)(config, valid);
|
|
10
|
+
return {
|
|
11
|
+
apiVersion: config.apiVersion,
|
|
12
|
+
ref: config.ref,
|
|
13
|
+
name: config.metadata.name,
|
|
14
|
+
username: config.spec.credentials.username,
|
|
15
|
+
password: config.spec.credentials.password
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.mapToCredentials = mapToCredentials;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapToDomain = void 0;
|
|
4
|
+
const schemas_1 = require("../schemas");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const assertions_1 = require("./assertions");
|
|
7
|
+
const valid = schemas_1.schemaValidators.get(types_1.Kind.DOMAIN);
|
|
8
|
+
function mapToDomain(config) {
|
|
9
|
+
(0, assertions_1.assertValidSchema)(config, valid);
|
|
10
|
+
return {
|
|
11
|
+
apiVersion: config.apiVersion,
|
|
12
|
+
ref: config.ref,
|
|
13
|
+
name: config.metadata.name,
|
|
14
|
+
domainUri: config.spec.context.domainUri,
|
|
15
|
+
accessControlListRef: config.spec.accessControlListRef,
|
|
16
|
+
egressPolicies: config.spec.context.egressPolicies
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.mapToDomain = mapToDomain;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/*
|
|
18
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
19
|
+
* http://github.com/fonoster
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Routr.
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the MIT License (the "License");
|
|
24
|
+
* you may not use this file except in compliance with
|
|
25
|
+
* the License. You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* https://opensource.org/licenses/MIT
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
__exportStar(require("./acl"), exports);
|
|
36
|
+
__exportStar(require("./agent"), exports);
|
|
37
|
+
__exportStar(require("./credentials"), exports);
|
|
38
|
+
__exportStar(require("./trunk"), exports);
|
|
39
|
+
__exportStar(require("./number"), exports);
|
|
40
|
+
__exportStar(require("./peer"), exports);
|
|
41
|
+
__exportStar(require("./domain"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapToNumber = void 0;
|
|
4
|
+
const schemas_1 = require("../schemas");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const assertions_1 = require("./assertions");
|
|
7
|
+
const valid = schemas_1.schemaValidators.get(types_1.Kind.NUMBER);
|
|
8
|
+
function mapToNumber(config) {
|
|
9
|
+
(0, assertions_1.assertValidSchema)(config, valid);
|
|
10
|
+
const metadata = config.metadata;
|
|
11
|
+
const location = config.spec.location;
|
|
12
|
+
return {
|
|
13
|
+
apiVersion: config.apiVersion,
|
|
14
|
+
ref: config.ref,
|
|
15
|
+
name: metadata.name,
|
|
16
|
+
city: metadata.geoInfo.city,
|
|
17
|
+
country: metadata.geoInfo.country,
|
|
18
|
+
countryIsoCode: metadata.geoInfo.countryISOCode,
|
|
19
|
+
telUrl: location.telUrl,
|
|
20
|
+
aorLink: location.aorLink,
|
|
21
|
+
sessionAffinityHeader: location.sessionAffinityHeader,
|
|
22
|
+
extraHeaders: location.extraHeaders,
|
|
23
|
+
trunkRef: config.spec.trunkRef
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.mapToNumber = mapToNumber;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapToPeer = void 0;
|
|
4
|
+
const schemas_1 = require("../schemas");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const assertions_1 = require("./assertions");
|
|
7
|
+
const valid = schemas_1.schemaValidators.get(types_1.Kind.PEER);
|
|
8
|
+
function mapToPeer(config) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
(0, assertions_1.assertValidSchema)(config, valid);
|
|
11
|
+
(0, assertions_1.assertValidAorSchema)(config);
|
|
12
|
+
const normalizeAlgorithm = (algorithm) => algorithm === null || algorithm === void 0 ? void 0 : algorithm.replace(/-/g, "_").toUpperCase();
|
|
13
|
+
return {
|
|
14
|
+
apiVersion: config.apiVersion,
|
|
15
|
+
ref: config.ref,
|
|
16
|
+
name: config.metadata.name,
|
|
17
|
+
username: config.spec.username,
|
|
18
|
+
aor: config.spec.aor,
|
|
19
|
+
contactAddr: config.spec.contactAddr,
|
|
20
|
+
enabled: config.spec.enabled,
|
|
21
|
+
credentialsRef: config.spec.credentialsRef,
|
|
22
|
+
balancingAlgorithm: normalizeAlgorithm((_a = config.spec.loadBalancing) === null || _a === void 0 ? void 0 : _a.algorithm),
|
|
23
|
+
withSessionAffinity: (_b = config.spec.loadBalancing) === null || _b === void 0 ? void 0 : _b.withSessionAffinity
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.mapToPeer = mapToPeer;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapToTrunk = void 0;
|
|
4
|
+
const schemas_1 = require("../schemas");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const assertions_1 = require("./assertions");
|
|
7
|
+
const valid = schemas_1.schemaValidators.get(types_1.Kind.TRUNK);
|
|
8
|
+
function mapToTrunk(config) {
|
|
9
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10
|
+
(0, assertions_1.assertValidSchema)(config, valid);
|
|
11
|
+
return {
|
|
12
|
+
apiVersion: config.apiVersion,
|
|
13
|
+
ref: config.ref,
|
|
14
|
+
name: config.metadata.name,
|
|
15
|
+
sendRegister: config.spec.outbound.sendRegister,
|
|
16
|
+
inboundUri: (_a = config.spec.inbound) === null || _a === void 0 ? void 0 : _a.uri,
|
|
17
|
+
inboundCredentialsRef: (_b = config.spec.inbound) === null || _b === void 0 ? void 0 : _b.credentialsRef,
|
|
18
|
+
outboundCredentialsRef: (_c = config.spec.outbound) === null || _c === void 0 ? void 0 : _c.credentialsRef,
|
|
19
|
+
accessControlListRef: (_d = config.spec.inbound) === null || _d === void 0 ? void 0 : _d.accessControlListRef,
|
|
20
|
+
uris: (_f = (_e = config.spec.outbound) === null || _e === void 0 ? void 0 : _e.uris) === null || _f === void 0 ? void 0 : _f.map((entry) => {
|
|
21
|
+
var _a;
|
|
22
|
+
return {
|
|
23
|
+
user: entry.uri.user,
|
|
24
|
+
host: entry.uri.host,
|
|
25
|
+
port: entry.uri.port,
|
|
26
|
+
transport: (_a = entry.uri.transport) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
27
|
+
enabled: entry.enabled,
|
|
28
|
+
weight: entry.weight,
|
|
29
|
+
priority: entry.priority
|
|
30
|
+
};
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.mapToTrunk = mapToTrunk;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/routr
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Routr
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License")
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
syntax = "proto3";
|
|
20
|
+
|
|
21
|
+
package fonoster.routr.connect.acl.v2draft1;
|
|
22
|
+
|
|
23
|
+
import "google/protobuf/struct.proto";
|
|
24
|
+
import "google/protobuf/empty.proto";
|
|
25
|
+
|
|
26
|
+
// AccessControlList(ACL) service definition
|
|
27
|
+
service ACLService {
|
|
28
|
+
// Create a new ACL
|
|
29
|
+
rpc Create (CreateACLRequest) returns (AccessControlList) {}
|
|
30
|
+
// Update an existing ACL
|
|
31
|
+
rpc Update (UpdateACLRequest) returns (AccessControlList) {}
|
|
32
|
+
// Get an existing ACL
|
|
33
|
+
rpc Get (GetACLRequest) returns (AccessControlList) {}
|
|
34
|
+
// Delete an existing ACL
|
|
35
|
+
rpc Delete (DeleteACLRequest) returns (.google.protobuf.Empty) {}
|
|
36
|
+
// Get a list of ACLs
|
|
37
|
+
rpc List (ListACLsRequest) returns (ListACLsResponse) {}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// The message for AccessControlList resource
|
|
41
|
+
message AccessControlList {
|
|
42
|
+
// The version of the API
|
|
43
|
+
string api_version = 1;
|
|
44
|
+
// The ACL reference
|
|
45
|
+
string ref = 2;
|
|
46
|
+
// A friendly name for the ACL
|
|
47
|
+
string name = 3;
|
|
48
|
+
// The list of allowed IP addresses
|
|
49
|
+
repeated string allow = 4;
|
|
50
|
+
// The list of denied IP addresses
|
|
51
|
+
repeated string deny = 5;
|
|
52
|
+
// The date the ACL was created
|
|
53
|
+
int32 created_at = 6;
|
|
54
|
+
// The date the ACL was last updated
|
|
55
|
+
int32 updated_at = 7;
|
|
56
|
+
// The extended attributes of the ACL
|
|
57
|
+
.google.protobuf.Struct extended = 8;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// The request message for the AccessControlList.Create method
|
|
61
|
+
message CreateACLRequest {
|
|
62
|
+
// A friendly name for the ACL
|
|
63
|
+
string name = 2;
|
|
64
|
+
// The list of allowed IP addresses
|
|
65
|
+
repeated string allow = 3;
|
|
66
|
+
// The list of denied IP addresses
|
|
67
|
+
repeated string deny = 4;
|
|
68
|
+
// The extended attributes of the ACL
|
|
69
|
+
.google.protobuf.Struct extended = 5;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// The request message for the AccessControlList.Update method
|
|
73
|
+
message UpdateACLRequest {
|
|
74
|
+
// The ACL reference
|
|
75
|
+
string ref = 1;
|
|
76
|
+
// A friendly name for the ACL
|
|
77
|
+
string name = 2;
|
|
78
|
+
// The list of allowed IP addresses
|
|
79
|
+
repeated string allow = 3;
|
|
80
|
+
// The list of denied IP addresses
|
|
81
|
+
repeated string deny = 4;
|
|
82
|
+
// The extended attributes of the ACL
|
|
83
|
+
.google.protobuf.Struct extended = 5;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// The request message for the AccessControlList.Get method
|
|
87
|
+
message GetACLRequest {
|
|
88
|
+
string ref = 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// The request message for the AccessControlList.Delete method
|
|
92
|
+
message DeleteACLRequest {
|
|
93
|
+
string ref = 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// The request message for the AccessControlList.List method
|
|
97
|
+
message ListACLsRequest {
|
|
98
|
+
// The maximum number of items in the list
|
|
99
|
+
int32 page_size = 1;
|
|
100
|
+
|
|
101
|
+
// The next_page_token value returned from the previous request, if any
|
|
102
|
+
string page_token = 2;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// The response message for the AccessControlList.List method
|
|
106
|
+
message ListACLsResponse {
|
|
107
|
+
// List of items
|
|
108
|
+
repeated AccessControlList items = 1;
|
|
109
|
+
|
|
110
|
+
// Token to retrieve the next page of results, or empty if there are no more results in the list
|
|
111
|
+
string next_page_token = 2;
|
|
112
|
+
}
|