@routr/common 2.0.8-alpha.16 → 2.0.8-alpha.18
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 +2 -2
- package/dist/connect/api/client.d.ts +1 -1
- package/dist/connect/api/client.js +8 -10
- package/dist/connect/api/types.d.ts +17 -23
- package/dist/connect/config.d.ts +7 -7
- package/dist/connect/grpc_client.d.ts +2 -2
- package/dist/connect/index.d.ts +1 -1
- package/dist/connect/index.js +1 -1
- 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 +2 -0
- package/dist/connect/mappers/assertions.js +31 -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 +21 -0
- package/dist/connect/mappers/trunk.d.ts +3 -0
- package/dist/connect/mappers/trunk.js +34 -0
- package/dist/connect/protos/acl.proto +11 -16
- package/dist/connect/protos/agents.proto +25 -24
- package/dist/connect/protos/credentials.proto +8 -10
- package/dist/connect/protos/domains.proto +16 -18
- package/dist/connect/protos/numbers.proto +15 -25
- package/dist/connect/protos/peers.proto +21 -33
- package/dist/connect/protos/trunks.proto +16 -24
- package/dist/connect/schemas/acl.d.ts +2 -0
- package/dist/connect/schemas/acl.js +4 -2
- package/dist/connect/schemas/agent.d.ts +2 -0
- package/dist/connect/schemas/agent.js +6 -4
- package/dist/connect/schemas/crendentials.d.ts +4 -0
- package/dist/connect/schemas/crendentials.js +7 -3
- package/dist/connect/schemas/domain.d.ts +2 -0
- package/dist/connect/schemas/domain.js +4 -2
- package/dist/connect/schemas/number.d.ts +4 -0
- package/dist/connect/schemas/number.js +7 -3
- package/dist/connect/schemas/peer.d.ts +2 -0
- package/dist/connect/schemas/peer.js +5 -3
- package/dist/connect/schemas/trunk.d.ts +3 -0
- package/dist/connect/schemas/trunk.js +20 -4
- package/dist/connect/types.d.ts +28 -16
- package/dist/helper.js +2 -2
- package/dist/types.d.ts +12 -20
- package/dist/types.js +9 -23
- package/package.json +3 -3
- package/dist/connect/converters.d.ts +0 -10
- package/dist/connect/converters.js +0 -176
|
@@ -25,7 +25,7 @@ exports.default = {
|
|
|
25
25
|
type: "object",
|
|
26
26
|
properties: {
|
|
27
27
|
apiVersion: {
|
|
28
|
-
enum: ["v2draft1", "v2
|
|
28
|
+
enum: ["v2draft1", "v2"]
|
|
29
29
|
},
|
|
30
30
|
kind: {
|
|
31
31
|
enum: ["Trunk", "trunk"]
|
|
@@ -40,7 +40,9 @@ exports.default = {
|
|
|
40
40
|
properties: {
|
|
41
41
|
name: {
|
|
42
42
|
description: "Resource's friendly name",
|
|
43
|
-
type: "string"
|
|
43
|
+
type: "string",
|
|
44
|
+
minLength: 3,
|
|
45
|
+
maxLength: 64
|
|
44
46
|
}
|
|
45
47
|
},
|
|
46
48
|
required: ["name"]
|
|
@@ -55,7 +57,8 @@ exports.default = {
|
|
|
55
57
|
properties: {
|
|
56
58
|
uri: {
|
|
57
59
|
description: "URI of the inbound endpoint",
|
|
58
|
-
type: "string"
|
|
60
|
+
type: "string",
|
|
61
|
+
maxLength: 255
|
|
59
62
|
},
|
|
60
63
|
accessControlListRef: {
|
|
61
64
|
description: "Reference to the ACL to be used for inbound traffic",
|
|
@@ -100,7 +103,20 @@ exports.default = {
|
|
|
100
103
|
},
|
|
101
104
|
transport: {
|
|
102
105
|
description: "Transport of the URI",
|
|
103
|
-
enum: [
|
|
106
|
+
enum: [
|
|
107
|
+
"TCP",
|
|
108
|
+
"SCTP",
|
|
109
|
+
"UDP",
|
|
110
|
+
"TLS",
|
|
111
|
+
"WS",
|
|
112
|
+
"WSS",
|
|
113
|
+
"tcp",
|
|
114
|
+
"sctp",
|
|
115
|
+
"udp",
|
|
116
|
+
"tls",
|
|
117
|
+
"ws",
|
|
118
|
+
"wss"
|
|
119
|
+
]
|
|
104
120
|
},
|
|
105
121
|
user: {
|
|
106
122
|
description: "Username of the URI",
|
package/dist/connect/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonObject } from "pb-util/build";
|
|
2
|
+
import { Privacy, Transport } from "../types";
|
|
2
3
|
export declare enum Kind {
|
|
3
4
|
AGENT = "agent",
|
|
4
5
|
PEER = "peer",
|
|
@@ -9,60 +10,69 @@ export declare enum Kind {
|
|
|
9
10
|
CREDENTIALS = "credentials",
|
|
10
11
|
ACL = "accesscontrollist"
|
|
11
12
|
}
|
|
13
|
+
export type KindWithoutUnknown = Exclude<Kind, Kind.UNKNOWN>;
|
|
12
14
|
export declare enum APIVersion {
|
|
13
15
|
V2DRAFT1 = "v2draft1",
|
|
14
16
|
V2 = "v2"
|
|
15
17
|
}
|
|
16
|
-
export interface
|
|
18
|
+
export interface BaseConnectModel {
|
|
17
19
|
apiVersion: string;
|
|
18
20
|
ref: string;
|
|
19
21
|
name: string;
|
|
20
22
|
createdAt?: Date;
|
|
21
23
|
updatedAt?: Date;
|
|
22
|
-
extended?:
|
|
24
|
+
extended?: JsonObject;
|
|
23
25
|
}
|
|
24
|
-
export interface AccessControlList extends
|
|
26
|
+
export interface AccessControlList extends BaseConnectModel {
|
|
25
27
|
allow: string[];
|
|
26
28
|
deny: string[];
|
|
27
29
|
}
|
|
28
|
-
export interface Domain extends
|
|
30
|
+
export interface Domain extends BaseConnectModel {
|
|
29
31
|
domainUri: string;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
accessControlListRef?: string;
|
|
33
|
+
accessControlList?: AccessControlList;
|
|
34
|
+
egressPolicies?: EgressPolicy[];
|
|
32
35
|
}
|
|
33
36
|
export interface EgressPolicy {
|
|
34
|
-
|
|
37
|
+
numberRef: string;
|
|
38
|
+
number?: INumber;
|
|
35
39
|
rule: string;
|
|
36
40
|
}
|
|
37
|
-
export interface Agent extends
|
|
41
|
+
export interface Agent extends BaseConnectModel {
|
|
38
42
|
username: string;
|
|
39
|
-
privacy:
|
|
43
|
+
privacy: Privacy;
|
|
40
44
|
enabled: boolean;
|
|
45
|
+
domainRef?: string;
|
|
41
46
|
domain?: Domain;
|
|
47
|
+
credentialsRef?: string;
|
|
42
48
|
credentials?: Credentials;
|
|
43
49
|
}
|
|
44
|
-
export interface Credentials extends
|
|
50
|
+
export interface Credentials extends BaseConnectModel {
|
|
45
51
|
username: string;
|
|
46
52
|
password: string;
|
|
47
53
|
}
|
|
48
|
-
export interface INumber extends
|
|
54
|
+
export interface INumber extends BaseConnectModel {
|
|
49
55
|
telUrl: string;
|
|
50
56
|
aorLink: string;
|
|
51
57
|
city: string;
|
|
52
58
|
country: string;
|
|
53
|
-
|
|
59
|
+
countryISOCode: string;
|
|
54
60
|
sessionAffinityHeader: string;
|
|
55
61
|
extraHeaders: {
|
|
56
62
|
name: string;
|
|
57
63
|
value: string;
|
|
58
64
|
}[];
|
|
65
|
+
trunkRef?: string;
|
|
59
66
|
trunk?: Trunk;
|
|
60
67
|
}
|
|
61
|
-
export interface Trunk extends
|
|
68
|
+
export interface Trunk extends BaseConnectModel {
|
|
62
69
|
sendRegister: boolean;
|
|
63
70
|
inboundUri: string;
|
|
71
|
+
accessControlListRef?: string;
|
|
64
72
|
accessControlList?: AccessControlList;
|
|
73
|
+
inboundCredentialsRef?: string;
|
|
65
74
|
inboundCredentials?: Credentials;
|
|
75
|
+
outboundCredentialsRef?: string;
|
|
66
76
|
outboundCredentials?: Credentials;
|
|
67
77
|
uris: TrunkURI[];
|
|
68
78
|
}
|
|
@@ -75,13 +85,15 @@ export interface TrunkURI {
|
|
|
75
85
|
priority: number;
|
|
76
86
|
enabled: boolean;
|
|
77
87
|
}
|
|
78
|
-
export interface Peer extends
|
|
88
|
+
export interface Peer extends BaseConnectModel {
|
|
79
89
|
username: string;
|
|
80
90
|
aor: string;
|
|
81
91
|
contactAddr: string;
|
|
82
92
|
enabled: boolean;
|
|
93
|
+
accessControlListRef?: string;
|
|
83
94
|
accessControlList?: AccessControlList;
|
|
95
|
+
credentialsRef?: string;
|
|
84
96
|
credentials?: Credentials;
|
|
85
97
|
}
|
|
86
|
-
export type
|
|
98
|
+
export type ConnectModel = Agent | Peer | INumber | Trunk | Domain | Credentials | AccessControlList;
|
|
87
99
|
export type RoutableResourceUnion = Agent | Peer | INumber;
|
package/dist/helper.js
CHANGED
|
@@ -79,8 +79,8 @@ exports.deepCopy = deepCopy;
|
|
|
79
79
|
*/
|
|
80
80
|
const getListeningPoint = (listeningPoints, transport) => {
|
|
81
81
|
const listeningPoint = transport
|
|
82
|
-
? listeningPoints.find((lp) => lp.transport.
|
|
83
|
-
: listeningPoints.find((lp) => lp.transport.
|
|
82
|
+
? listeningPoints.find((lp) => lp.transport.toUpperCase() === transport.toUpperCase())
|
|
83
|
+
: listeningPoints.find((lp) => lp.transport.toUpperCase() === types_1.Transport.UDP);
|
|
84
84
|
if (!listeningPoint) {
|
|
85
85
|
throw new Error(`no listening point found for transport ${transport}`);
|
|
86
86
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -15,12 +15,12 @@ export declare enum Method {
|
|
|
15
15
|
OPTIONS = "OPTIONS"
|
|
16
16
|
}
|
|
17
17
|
export declare enum Transport {
|
|
18
|
-
TCP = "
|
|
19
|
-
UDP = "
|
|
20
|
-
TLS = "
|
|
21
|
-
SCTP = "
|
|
22
|
-
WS = "
|
|
23
|
-
WSS = "
|
|
18
|
+
TCP = "TCP",
|
|
19
|
+
UDP = "UDP",
|
|
20
|
+
TLS = "TLS",
|
|
21
|
+
SCTP = "SCTP",
|
|
22
|
+
WS = "WS",
|
|
23
|
+
WSS = "WSS"
|
|
24
24
|
}
|
|
25
25
|
export declare enum ExtraHeader {
|
|
26
26
|
REQUEST_URI = "X-Request-Uri",
|
|
@@ -31,20 +31,12 @@ export declare enum ExtraHeader {
|
|
|
31
31
|
DOD_PRIVACY = "X-DOD-Privacy"
|
|
32
32
|
}
|
|
33
33
|
export declare enum Privacy {
|
|
34
|
-
NONE = "
|
|
35
|
-
PRIVATE = "
|
|
36
|
-
}
|
|
37
|
-
export declare enum AuthorizationAlgorithm {
|
|
38
|
-
MD5 = "MD5"
|
|
39
|
-
}
|
|
40
|
-
export declare enum AuthorizationScheme {
|
|
41
|
-
DIGEST = "Digest"
|
|
42
|
-
}
|
|
43
|
-
export declare enum Qop {
|
|
44
|
-
AUTH = "auth",
|
|
45
|
-
AUTH_INT = "auth-int",
|
|
46
|
-
NONE = ""
|
|
34
|
+
NONE = "NONE",
|
|
35
|
+
PRIVATE = "ID"
|
|
47
36
|
}
|
|
37
|
+
export type AuthorizationAlgorithm = "MD5";
|
|
38
|
+
export type AuthorizationScheme = "Digest";
|
|
39
|
+
export type Qop = "auth" | "auth-int" | "";
|
|
48
40
|
export interface NetInterface {
|
|
49
41
|
host: string;
|
|
50
42
|
port: number;
|
|
@@ -245,7 +237,7 @@ export interface SipURI {
|
|
|
245
237
|
user?: string;
|
|
246
238
|
host: string;
|
|
247
239
|
port?: number;
|
|
248
|
-
transportParam:
|
|
240
|
+
transportParam: Transport;
|
|
249
241
|
mAddrParam?: string;
|
|
250
242
|
userParam?: string;
|
|
251
243
|
ttlParam?: number;
|
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.
|
|
3
|
+
exports.MessageType = exports.ResponseType = exports.HeaderModifierAction = exports.Privacy = exports.ExtraHeader = exports.Transport = exports.Method = void 0;
|
|
4
4
|
var Method;
|
|
5
5
|
(function (Method) {
|
|
6
6
|
Method["UNKNOWN"] = "UNKNOWN";
|
|
@@ -17,12 +17,12 @@ var Method;
|
|
|
17
17
|
})(Method = exports.Method || (exports.Method = {}));
|
|
18
18
|
var Transport;
|
|
19
19
|
(function (Transport) {
|
|
20
|
-
Transport["TCP"] = "
|
|
21
|
-
Transport["UDP"] = "
|
|
22
|
-
Transport["TLS"] = "
|
|
23
|
-
Transport["SCTP"] = "
|
|
24
|
-
Transport["WS"] = "
|
|
25
|
-
Transport["WSS"] = "
|
|
20
|
+
Transport["TCP"] = "TCP";
|
|
21
|
+
Transport["UDP"] = "UDP";
|
|
22
|
+
Transport["TLS"] = "TLS";
|
|
23
|
+
Transport["SCTP"] = "SCTP";
|
|
24
|
+
Transport["WS"] = "WS";
|
|
25
|
+
Transport["WSS"] = "WSS";
|
|
26
26
|
})(Transport = exports.Transport || (exports.Transport = {}));
|
|
27
27
|
var ExtraHeader;
|
|
28
28
|
(function (ExtraHeader) {
|
|
@@ -35,23 +35,9 @@ var ExtraHeader;
|
|
|
35
35
|
})(ExtraHeader = exports.ExtraHeader || (exports.ExtraHeader = {}));
|
|
36
36
|
var Privacy;
|
|
37
37
|
(function (Privacy) {
|
|
38
|
-
Privacy["NONE"] = "
|
|
39
|
-
Privacy["PRIVATE"] = "
|
|
38
|
+
Privacy["NONE"] = "NONE";
|
|
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 = {}));
|
|
55
41
|
var HeaderModifierAction;
|
|
56
42
|
(function (HeaderModifierAction) {
|
|
57
43
|
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.18",
|
|
4
4
|
"description": "Common package",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@opentelemetry/sdk-trace-base": "^1.0.4",
|
|
25
25
|
"@opentelemetry/sdk-trace-node": "^1.0.4",
|
|
26
26
|
"@opentelemetry/semantic-conventions": "^1.0.4",
|
|
27
|
-
"ajv": "^
|
|
27
|
+
"ajv": "^6.12.6",
|
|
28
28
|
"fp-ts": "^2.11.8",
|
|
29
29
|
"ip-utils": "^2.4.0",
|
|
30
30
|
"js-yaml": "^4.1.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/js-yaml": "^4.0.5"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "66ce6b3ed832bb8c549d344b3367aceed4b6da8f"
|
|
55
55
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { UserConfig } from "./config";
|
|
2
|
-
import { AccessControlList, Agent, Credentials, Domain, INumber, Peer, Trunk } from "./types";
|
|
3
|
-
export declare const getConverter: (kind: string) => typeof convertAgentConfigToAgent | typeof convertDomainConfigToDomain | typeof convertPeerConfigToPeer | typeof convertNumberConfigToNumber | typeof convertTrunkConfigToTrunk | typeof convertCredentialsConfigToCredentials | typeof convertACLConfigToACL;
|
|
4
|
-
export declare function convertAgentConfigToAgent(config: UserConfig, list: UserConfig[]): Agent;
|
|
5
|
-
export declare function convertDomainConfigToDomain(config: UserConfig, list: UserConfig[]): Domain;
|
|
6
|
-
export declare function convertPeerConfigToPeer(config: UserConfig, list: UserConfig[]): Peer;
|
|
7
|
-
export declare function convertNumberConfigToNumber(config: UserConfig, list: UserConfig[]): INumber;
|
|
8
|
-
export declare function convertTrunkConfigToTrunk(config: UserConfig, list: UserConfig[]): Trunk;
|
|
9
|
-
export declare function convertCredentialsConfigToCredentials(config: UserConfig): Credentials;
|
|
10
|
-
export declare function convertACLConfigToACL(config: UserConfig): AccessControlList;
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertACLConfigToACL = exports.convertCredentialsConfigToCredentials = exports.convertTrunkConfigToTrunk = exports.convertNumberConfigToNumber = exports.convertPeerConfigToPeer = exports.convertDomainConfigToDomain = exports.convertAgentConfigToAgent = exports.getConverter = 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 logger_1 = require("@fonoster/logger");
|
|
24
|
-
const types_1 = require("./types");
|
|
25
|
-
const logger = (0, logger_1.getLogger)({ service: "simpledata", filePath: __filename });
|
|
26
|
-
const findByRef = (ref, list) => {
|
|
27
|
-
const resource = list.find((r) => r.ref === ref);
|
|
28
|
-
if (ref != null && resource == null) {
|
|
29
|
-
logger.error(`the resource with ref ${ref} does not exist in the configuration file; exiting`);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
return resource ? (0, exports.getConverter)(resource.kind)(resource, list) : null;
|
|
33
|
-
};
|
|
34
|
-
const getConverter = (kind) => {
|
|
35
|
-
switch (kind) {
|
|
36
|
-
case types_1.Kind.AGENT:
|
|
37
|
-
return convertAgentConfigToAgent;
|
|
38
|
-
case types_1.Kind.DOMAIN:
|
|
39
|
-
return convertDomainConfigToDomain;
|
|
40
|
-
case types_1.Kind.PEER:
|
|
41
|
-
return convertPeerConfigToPeer;
|
|
42
|
-
case types_1.Kind.NUMBER:
|
|
43
|
-
return convertNumberConfigToNumber;
|
|
44
|
-
case types_1.Kind.TRUNK:
|
|
45
|
-
return convertTrunkConfigToTrunk;
|
|
46
|
-
case types_1.Kind.CREDENTIALS:
|
|
47
|
-
return convertCredentialsConfigToCredentials;
|
|
48
|
-
case types_1.Kind.ACL:
|
|
49
|
-
return convertACLConfigToACL;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
exports.getConverter = getConverter;
|
|
53
|
-
function convertAgentConfigToAgent(config, list) {
|
|
54
|
-
if (config.kind !== types_1.Kind.AGENT)
|
|
55
|
-
throw new Error("invalid resource type `Agent`");
|
|
56
|
-
return {
|
|
57
|
-
apiVersion: config.apiVersion,
|
|
58
|
-
ref: config.ref,
|
|
59
|
-
name: config.metadata.name,
|
|
60
|
-
username: config.spec.username,
|
|
61
|
-
privacy: config.spec.privacy,
|
|
62
|
-
enabled: config.spec.enabled,
|
|
63
|
-
domain: findByRef(config.spec.domainRef, list),
|
|
64
|
-
credentials: findByRef(config.spec.credentialsRef, list)
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
exports.convertAgentConfigToAgent = convertAgentConfigToAgent;
|
|
68
|
-
function convertDomainConfigToDomain(config, list) {
|
|
69
|
-
var _a;
|
|
70
|
-
if (config.kind !== types_1.Kind.DOMAIN)
|
|
71
|
-
throw new Error("invalid resource type `Domain`");
|
|
72
|
-
const egressPolicies = (_a = config.spec.context.egressPolicies) === null || _a === void 0 ? void 0 : _a.map((policy) => {
|
|
73
|
-
return {
|
|
74
|
-
rule: policy.rule,
|
|
75
|
-
number: findByRef(policy.numberRef, list)
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
return {
|
|
79
|
-
apiVersion: config.apiVersion,
|
|
80
|
-
ref: config.ref,
|
|
81
|
-
name: config.metadata.name,
|
|
82
|
-
domainUri: config.spec.context.domainUri,
|
|
83
|
-
accessControlList: findByRef(config.spec.accessControlListRef, list),
|
|
84
|
-
egressPolicies
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
exports.convertDomainConfigToDomain = convertDomainConfigToDomain;
|
|
88
|
-
function convertPeerConfigToPeer(config, list) {
|
|
89
|
-
if (config.kind !== types_1.Kind.PEER)
|
|
90
|
-
throw new Error("invalid resource type `Peer`");
|
|
91
|
-
return {
|
|
92
|
-
apiVersion: config.apiVersion,
|
|
93
|
-
ref: config.ref,
|
|
94
|
-
name: config.metadata.name,
|
|
95
|
-
username: config.spec.username,
|
|
96
|
-
aor: config.spec.aor,
|
|
97
|
-
contactAddr: config.spec.contactAddr,
|
|
98
|
-
enabled: config.spec.enabled,
|
|
99
|
-
credentials: findByRef(config.spec.credentialsRef, list)
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
exports.convertPeerConfigToPeer = convertPeerConfigToPeer;
|
|
103
|
-
function convertNumberConfigToNumber(config, list) {
|
|
104
|
-
if (config.kind !== types_1.Kind.NUMBER)
|
|
105
|
-
throw new Error("invalid resource type `Number`");
|
|
106
|
-
const metadata = config.metadata;
|
|
107
|
-
const location = config.spec.location;
|
|
108
|
-
return {
|
|
109
|
-
apiVersion: config.apiVersion,
|
|
110
|
-
ref: config.ref,
|
|
111
|
-
name: metadata.name,
|
|
112
|
-
city: metadata.geoInfo.city,
|
|
113
|
-
country: metadata.geoInfo.country,
|
|
114
|
-
countryIsoCode: metadata.geoInfo.countryISOCode,
|
|
115
|
-
telUrl: location.telUrl,
|
|
116
|
-
aorLink: location.aorLink,
|
|
117
|
-
sessionAffinityHeader: location.sessionAffinityHeader,
|
|
118
|
-
extraHeaders: location.extraHeaders,
|
|
119
|
-
trunk: findByRef(config.spec.trunkRef, list)
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
exports.convertNumberConfigToNumber = convertNumberConfigToNumber;
|
|
123
|
-
function convertTrunkConfigToTrunk(config, list) {
|
|
124
|
-
var _a;
|
|
125
|
-
if (config.kind !== types_1.Kind.TRUNK)
|
|
126
|
-
throw new Error("invalid resource type `Trunk`");
|
|
127
|
-
const inbound = config.spec.inbound;
|
|
128
|
-
const outbound = config.spec.outbound;
|
|
129
|
-
return {
|
|
130
|
-
apiVersion: config.apiVersion,
|
|
131
|
-
ref: config.ref,
|
|
132
|
-
name: config.metadata.name,
|
|
133
|
-
sendRegister: outbound.sendRegister,
|
|
134
|
-
inboundUri: inbound.uri,
|
|
135
|
-
inboundCredentials: findByRef(inbound.credentialsRef, list),
|
|
136
|
-
outboundCredentials: findByRef(outbound.credentialsRef, list),
|
|
137
|
-
accessControlList: findByRef(inbound.accessControlListRef, list),
|
|
138
|
-
uris: (_a = config.spec.outbound.uris) === null || _a === void 0 ? void 0 : _a.map((entry) => {
|
|
139
|
-
return {
|
|
140
|
-
user: entry.uri.user,
|
|
141
|
-
host: entry.uri.host,
|
|
142
|
-
port: entry.uri.port,
|
|
143
|
-
transport: entry.uri.transport,
|
|
144
|
-
enabled: entry.enabled,
|
|
145
|
-
weight: entry.weight,
|
|
146
|
-
priority: entry.priority
|
|
147
|
-
};
|
|
148
|
-
})
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
exports.convertTrunkConfigToTrunk = convertTrunkConfigToTrunk;
|
|
152
|
-
function convertCredentialsConfigToCredentials(config) {
|
|
153
|
-
if (config.kind !== types_1.Kind.CREDENTIALS)
|
|
154
|
-
throw new Error("invalid resource type `Credentials`");
|
|
155
|
-
return {
|
|
156
|
-
apiVersion: config.apiVersion,
|
|
157
|
-
ref: config.ref,
|
|
158
|
-
name: config.metadata.name,
|
|
159
|
-
username: config.spec.credentials.username,
|
|
160
|
-
password: config.spec.credentials.password
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
exports.convertCredentialsConfigToCredentials = convertCredentialsConfigToCredentials;
|
|
164
|
-
function convertACLConfigToACL(config) {
|
|
165
|
-
var _a, _b, _c, _d;
|
|
166
|
-
if (config.kind !== types_1.Kind.ACL)
|
|
167
|
-
throw new Error("invalid resource type `AccessControlList`");
|
|
168
|
-
return {
|
|
169
|
-
apiVersion: config.apiVersion,
|
|
170
|
-
ref: config.ref,
|
|
171
|
-
name: config.metadata.name,
|
|
172
|
-
allow: (_b = (_a = config.spec.accessControlList) === null || _a === void 0 ? void 0 : _a.allow) !== null && _b !== void 0 ? _b : [],
|
|
173
|
-
deny: (_d = (_c = config.spec.accessControlList) === null || _c === void 0 ? void 0 : _c.deny) !== null && _d !== void 0 ? _d : []
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
exports.convertACLConfigToACL = convertACLConfigToACL;
|