@fonoster/ctl 0.7.44 → 0.7.45
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/README.md +1 -1
- package/bin/run.js +0 -18
- package/dist/AuthenticatedCommand.d.ts +6 -0
- package/dist/AuthenticatedCommand.js +92 -0
- package/dist/BaseCommand.d.ts +15 -0
- package/dist/BaseCommand.js +80 -0
- package/dist/Help.d.ts +6 -0
- package/dist/Help.js +52 -0
- package/dist/commands/apikeys/create.d.ts +10 -0
- package/dist/commands/apikeys/create.js +99 -0
- package/dist/commands/apikeys/delete.d.ts +9 -0
- package/dist/commands/apikeys/delete.js +87 -0
- package/dist/commands/apikeys/list.d.ts +9 -0
- package/dist/commands/apikeys/list.js +105 -0
- package/dist/commands/apikeys/regenerate.d.ts +9 -0
- package/dist/commands/apikeys/regenerate.js +91 -0
- package/dist/commands/applications/create.d.ts +6 -0
- package/dist/commands/applications/create.js +155 -0
- package/dist/commands/applications/delete.d.ts +9 -0
- package/dist/commands/applications/delete.js +87 -0
- package/dist/commands/applications/get.d.ts +9 -0
- package/dist/commands/applications/get.js +107 -0
- package/dist/commands/applications/list.d.ts +9 -0
- package/dist/commands/applications/list.js +99 -0
- package/dist/commands/applications/update.d.ts +9 -0
- package/dist/commands/applications/update.js +172 -0
- package/dist/commands/bug.d.ts +6 -0
- package/dist/commands/bug.js +42 -0
- package/dist/commands/feedback.d.ts +6 -0
- package/dist/commands/feedback.js +45 -0
- package/dist/commands/secrets/create.d.ts +6 -0
- package/dist/commands/secrets/create.js +106 -0
- package/dist/commands/secrets/delete.d.ts +9 -0
- package/dist/commands/secrets/delete.js +87 -0
- package/dist/commands/secrets/get.d.ts +9 -0
- package/dist/commands/secrets/get.js +95 -0
- package/dist/commands/secrets/list.d.ts +9 -0
- package/dist/commands/secrets/list.js +99 -0
- package/dist/commands/secrets/update.d.ts +9 -0
- package/dist/commands/secrets/update.js +116 -0
- package/dist/commands/sipnet/acls/create.d.ts +6 -0
- package/dist/commands/sipnet/acls/create.js +107 -0
- package/dist/commands/sipnet/acls/delete.d.ts +9 -0
- package/dist/commands/sipnet/acls/delete.js +87 -0
- package/dist/commands/sipnet/acls/get.d.ts +9 -0
- package/dist/commands/sipnet/acls/get.js +100 -0
- package/dist/commands/sipnet/acls/list.d.ts +9 -0
- package/dist/commands/sipnet/acls/list.js +99 -0
- package/dist/commands/sipnet/acls/update.d.ts +9 -0
- package/dist/commands/sipnet/acls/update.js +123 -0
- package/dist/commands/sipnet/agents/create.d.ts +6 -0
- package/dist/commands/sipnet/agents/create.js +132 -0
- package/dist/commands/sipnet/agents/delete.d.ts +9 -0
- package/dist/commands/sipnet/agents/delete.js +87 -0
- package/dist/commands/sipnet/agents/get.d.ts +9 -0
- package/dist/commands/sipnet/agents/get.js +109 -0
- package/dist/commands/sipnet/agents/list.d.ts +9 -0
- package/dist/commands/sipnet/agents/list.js +99 -0
- package/dist/commands/sipnet/agents/update.d.ts +9 -0
- package/dist/commands/sipnet/agents/update.js +149 -0
- package/dist/commands/sipnet/calls/create.d.ts +13 -0
- package/dist/commands/sipnet/calls/create.js +156 -0
- package/dist/commands/sipnet/calls/get.d.ts +9 -0
- package/dist/commands/sipnet/calls/get.js +104 -0
- package/dist/commands/sipnet/calls/list.d.ts +9 -0
- package/dist/commands/sipnet/calls/list.js +108 -0
- package/dist/commands/sipnet/credentials/create.d.ts +6 -0
- package/dist/commands/sipnet/credentials/create.js +110 -0
- package/dist/commands/sipnet/credentials/delete.d.ts +9 -0
- package/dist/commands/sipnet/credentials/delete.js +87 -0
- package/dist/commands/sipnet/credentials/get.d.ts +9 -0
- package/dist/commands/sipnet/credentials/get.js +100 -0
- package/dist/commands/sipnet/credentials/list.d.ts +9 -0
- package/dist/commands/sipnet/credentials/list.js +99 -0
- package/dist/commands/sipnet/credentials/update.d.ts +9 -0
- package/dist/commands/sipnet/credentials/update.js +121 -0
- package/dist/commands/sipnet/domains/create.d.ts +6 -0
- package/dist/commands/sipnet/domains/create.js +107 -0
- package/dist/commands/sipnet/domains/delete.d.ts +9 -0
- package/dist/commands/sipnet/domains/delete.js +87 -0
- package/dist/commands/sipnet/domains/get.d.ts +9 -0
- package/dist/commands/sipnet/domains/get.js +100 -0
- package/dist/commands/sipnet/domains/list.d.ts +9 -0
- package/dist/commands/sipnet/domains/list.js +99 -0
- package/dist/commands/sipnet/domains/update.d.ts +9 -0
- package/dist/commands/sipnet/domains/update.js +118 -0
- package/dist/commands/sipnet/numbers/create.d.ts +6 -0
- package/dist/commands/sipnet/numbers/create.js +148 -0
- package/dist/commands/sipnet/numbers/delete.d.ts +9 -0
- package/dist/commands/sipnet/numbers/delete.js +87 -0
- package/dist/commands/sipnet/numbers/get.d.ts +9 -0
- package/dist/commands/sipnet/numbers/get.js +119 -0
- package/dist/commands/sipnet/numbers/linkTwilioNumber.d.ts +10 -0
- package/dist/commands/sipnet/numbers/linkTwilioNumber.js +150 -0
- package/dist/commands/sipnet/numbers/list.d.ts +9 -0
- package/dist/commands/sipnet/numbers/list.js +111 -0
- package/dist/commands/sipnet/numbers/update.d.ts +9 -0
- package/dist/commands/sipnet/numbers/update.js +136 -0
- package/dist/commands/sipnet/trunks/create.d.ts +6 -0
- package/dist/commands/sipnet/trunks/create.js +156 -0
- package/dist/commands/sipnet/trunks/delete.d.ts +9 -0
- package/dist/commands/sipnet/trunks/delete.js +87 -0
- package/dist/commands/sipnet/trunks/get.d.ts +9 -0
- package/dist/commands/sipnet/trunks/get.js +120 -0
- package/dist/commands/sipnet/trunks/list.d.ts +9 -0
- package/dist/commands/sipnet/trunks/list.js +99 -0
- package/dist/commands/sipnet/trunks/update.d.ts +9 -0
- package/dist/commands/sipnet/trunks/update.js +174 -0
- package/dist/commands/workspaces/current.d.ts +6 -0
- package/dist/commands/workspaces/current.js +46 -0
- package/dist/commands/workspaces/list.d.ts +6 -0
- package/dist/commands/workspaces/list.js +53 -0
- package/dist/commands/workspaces/login.d.ts +8 -0
- package/dist/commands/workspaces/login.js +145 -0
- package/dist/commands/workspaces/logout.d.ts +9 -0
- package/dist/commands/workspaces/logout.js +55 -0
- package/dist/commands/workspaces/use.d.ts +9 -0
- package/dist/commands/workspaces/use.js +57 -0
- package/dist/config/addWorkspace.d.ts +3 -0
- package/dist/config/addWorkspace.js +15 -0
- package/dist/config/getConfig.d.ts +3 -0
- package/dist/config/getConfig.js +34 -0
- package/dist/config/getCurrentWorkspace.d.ts +3 -0
- package/dist/config/getCurrentWorkspace.js +6 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.js +41 -0
- package/dist/config/removeWorkspace.d.ts +3 -0
- package/dist/config/removeWorkspace.js +6 -0
- package/dist/config/saveConfig.d.ts +3 -0
- package/dist/config/saveConfig.js +32 -0
- package/dist/config/setCurrentWorkspace.d.ts +3 -0
- package/dist/config/setCurrentWorkspace.js +11 -0
- package/dist/config/types.d.ts +4 -0
- package/dist/config/types.js +2 -0
- package/dist/config/validations.d.ts +27 -0
- package/dist/config/validations.js +34 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.js +29 -0
- package/dist/errorHandler.d.ts +2 -0
- package/dist/errorHandler.js +31 -0
- package/dist/utils/assignTwilioNumberToTrunk.d.ts +3 -0
- package/dist/utils/assignTwilioNumberToTrunk.js +33 -0
- package/dist/utils/calculateFutureDate.d.ts +2 -0
- package/dist/utils/calculateFutureDate.js +37 -0
- package/dist/utils/createTwilioTrunk.d.ts +4 -0
- package/dist/utils/createTwilioTrunk.js +54 -0
- package/dist/utils/getFonosterNumberByTelUrl.d.ts +4 -0
- package/dist/utils/getFonosterNumberByTelUrl.js +76 -0
- package/dist/utils/getFonosterTrunkByInboundUri.d.ts +4 -0
- package/dist/utils/getFonosterTrunkByInboundUri.js +76 -0
- package/dist/utils/getOutboundUri.d.ts +7 -0
- package/dist/utils/getOutboundUri.js +10 -0
- package/dist/utils/getTwilioNumber.d.ts +4 -0
- package/dist/utils/getTwilioNumber.js +23 -0
- package/dist/utils/getTwilioTrunk.d.ts +4 -0
- package/dist/utils/getTwilioTrunk.js +23 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +43 -0
- package/dist/utils/linkTwilioNumberToApplication.d.ts +5 -0
- package/dist/utils/linkTwilioNumberToApplication.js +128 -0
- package/dist/utils/types.d.ts +14 -0
- package/dist/utils/types.js +2 -0
- package/package.json +3 -3
|
@@ -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) 2024 by Fonoster Inc (https://fonoster.com)
|
|
19
|
+
* http://github.com/fonoster/fonoster
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Fonoster
|
|
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("./addWorkspace"), exports);
|
|
36
|
+
__exportStar(require("./getConfig"), exports);
|
|
37
|
+
__exportStar(require("./getCurrentWorkspace"), exports);
|
|
38
|
+
__exportStar(require("./removeWorkspace"), exports);
|
|
39
|
+
__exportStar(require("./saveConfig"), exports);
|
|
40
|
+
__exportStar(require("./setCurrentWorkspace"), exports);
|
|
41
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.saveConfig = saveConfig;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster/fonoster
|
|
10
|
+
*
|
|
11
|
+
* This file is part of Fonoster
|
|
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 fs_1 = __importDefault(require("fs"));
|
|
26
|
+
const constants_1 = require("../constants");
|
|
27
|
+
function saveConfig(path, config) {
|
|
28
|
+
if (!fs_1.default.existsSync(constants_1.BASE_DIR)) {
|
|
29
|
+
fs_1.default.mkdirSync(constants_1.BASE_DIR, { recursive: true });
|
|
30
|
+
}
|
|
31
|
+
fs_1.default.writeFileSync(path, JSON.stringify(config, null, 2));
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setCurrentWorkspace = setCurrentWorkspace;
|
|
4
|
+
function setCurrentWorkspace(ref, workspaces) {
|
|
5
|
+
return workspaces.map((w) => {
|
|
6
|
+
if (w.workspaceRef === ref) {
|
|
7
|
+
return Object.assign(Object.assign({}, w), { active: true });
|
|
8
|
+
}
|
|
9
|
+
return Object.assign(Object.assign({}, w), { active: false });
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const workspaceConfigSchema: z.ZodObject<{
|
|
3
|
+
endpoint: z.ZodString;
|
|
4
|
+
workspaceAccessKeyId: z.ZodString;
|
|
5
|
+
accessKeyId: z.ZodString;
|
|
6
|
+
accessKeySecret: z.ZodString;
|
|
7
|
+
workspaceRef: z.ZodString;
|
|
8
|
+
workspaceName: z.ZodString;
|
|
9
|
+
active: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
endpoint?: string;
|
|
12
|
+
workspaceAccessKeyId?: string;
|
|
13
|
+
accessKeyId?: string;
|
|
14
|
+
accessKeySecret?: string;
|
|
15
|
+
workspaceRef?: string;
|
|
16
|
+
workspaceName?: string;
|
|
17
|
+
active?: boolean;
|
|
18
|
+
}, {
|
|
19
|
+
endpoint?: string;
|
|
20
|
+
workspaceAccessKeyId?: string;
|
|
21
|
+
accessKeyId?: string;
|
|
22
|
+
accessKeySecret?: string;
|
|
23
|
+
workspaceRef?: string;
|
|
24
|
+
workspaceName?: string;
|
|
25
|
+
active?: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
export { workspaceConfigSchema };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.workspaceConfigSchema = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
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 zod_1 = require("zod");
|
|
23
|
+
const workspaceConfigSchema = zod_1.z.object({
|
|
24
|
+
endpoint: zod_1.z.string().min(1, "The endpoint value is required"),
|
|
25
|
+
workspaceAccessKeyId: zod_1.z
|
|
26
|
+
.string()
|
|
27
|
+
.min(1, "The workspaceAccessKeyId value is required"),
|
|
28
|
+
accessKeyId: zod_1.z.string().min(1, "The accessKeyId value is required"),
|
|
29
|
+
accessKeySecret: zod_1.z.string().min(1, "The accessKeySecret value is required"),
|
|
30
|
+
workspaceRef: zod_1.z.string().min(1, "The workspaceRef value is required"),
|
|
31
|
+
workspaceName: zod_1.z.string().min(1, "The workspaceName value is required"),
|
|
32
|
+
active: zod_1.z.boolean().optional()
|
|
33
|
+
});
|
|
34
|
+
exports.workspaceConfigSchema = workspaceConfigSchema;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const BASE_DIR: string;
|
|
2
|
+
export declare const CONFIG_FILE: string;
|
|
3
|
+
export declare const FONOSTER_ACCESS_CONTROL_LIST: string[];
|
|
4
|
+
export declare const FONOSTER_ORIGINATION_URI_BASE = "pstn.fonoster.dev";
|
|
5
|
+
export declare const TWILIO_PSTN_URI_BASE = "pstn.twilio.com";
|
|
6
|
+
export declare const WORKSPACE_ENDPOINT = "api.fonoster.dev";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WORKSPACE_ENDPOINT = exports.TWILIO_PSTN_URI_BASE = exports.FONOSTER_ORIGINATION_URI_BASE = exports.FONOSTER_ACCESS_CONTROL_LIST = exports.CONFIG_FILE = exports.BASE_DIR = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
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 os_1 = require("os");
|
|
23
|
+
const path_1 = require("path");
|
|
24
|
+
exports.BASE_DIR = (0, path_1.join)((0, os_1.homedir)(), ".fonoster");
|
|
25
|
+
exports.CONFIG_FILE = (0, path_1.join)((0, os_1.homedir)(), ".fonoster", "config.json");
|
|
26
|
+
exports.FONOSTER_ACCESS_CONTROL_LIST = ["165.22.7.155/32"]; // Warning: We will need to allow passing this as a parameter
|
|
27
|
+
exports.FONOSTER_ORIGINATION_URI_BASE = "pstn.fonoster.dev";
|
|
28
|
+
exports.TWILIO_PSTN_URI_BASE = "pstn.twilio.com";
|
|
29
|
+
exports.WORKSPACE_ENDPOINT = "api.fonoster.dev";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/fonoster
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Fonoster
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
function errorHandler(e, log) {
|
|
22
|
+
const error = e;
|
|
23
|
+
if (error.code === 3) {
|
|
24
|
+
const splitPoint = "3 INVALID_ARGUMENT:";
|
|
25
|
+
const message = error.message.split(splitPoint);
|
|
26
|
+
log(message[1]);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
log === null || log === void 0 ? void 0 : log(error.message.trim());
|
|
30
|
+
}
|
|
31
|
+
exports.default = errorHandler;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.assignTwilioNumberToTrunk = assignTwilioNumberToTrunk;
|
|
13
|
+
function assignTwilioNumberToTrunk(client, phoneNumber, trunkSid) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
try {
|
|
16
|
+
const numbers = yield client.incomingPhoneNumbers.list({
|
|
17
|
+
phoneNumber,
|
|
18
|
+
limit: 1
|
|
19
|
+
});
|
|
20
|
+
if (numbers.length === 0) {
|
|
21
|
+
throw new Error(`Phone number ${phoneNumber} not found in your Twilio account.`);
|
|
22
|
+
}
|
|
23
|
+
const numberSid = numbers[0].sid;
|
|
24
|
+
// Step 2: Update the Voice URL of the number to point to the trunk's domain URI
|
|
25
|
+
yield client.incomingPhoneNumbers(numberSid).update({
|
|
26
|
+
trunkSid
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
throw new Error(`Failed to assign phone number to trunk: ${error.message}`);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.calculateFutureDate = calculateFutureDate;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster/fonoster
|
|
10
|
+
*
|
|
11
|
+
* This file is part of Fonoster
|
|
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 moment_1 = __importDefault(require("moment"));
|
|
26
|
+
function calculateFutureDate(input) {
|
|
27
|
+
const value = parseInt(input, 10);
|
|
28
|
+
const unit = input.replace(/\d/g, "").toLowerCase(); // Extract the unit (d, mo)
|
|
29
|
+
switch (unit) {
|
|
30
|
+
case "d":
|
|
31
|
+
return (0, moment_1.default)().add(value, "days").toDate();
|
|
32
|
+
case "mo":
|
|
33
|
+
return (0, moment_1.default)().add(value, "months").toDate();
|
|
34
|
+
default:
|
|
35
|
+
throw new Error(`Invalid unit: ${unit}. Use 'd' for days or 'mo' for months.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createTwilioTrunk = createTwilioTrunk;
|
|
13
|
+
const constants_1 = require("../constants");
|
|
14
|
+
function createTwilioTrunk(client, params) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const { resourceRef, originationUriBase, aclEntries } = params;
|
|
17
|
+
try {
|
|
18
|
+
const aclName = `ACL-${resourceRef}`;
|
|
19
|
+
const trunkName = `Trunk-${resourceRef}`;
|
|
20
|
+
const domainName = `${resourceRef}.${constants_1.TWILIO_PSTN_URI_BASE}`;
|
|
21
|
+
const originationUri = `sip:${resourceRef}.${originationUriBase}`;
|
|
22
|
+
// Create ACLresource and entries
|
|
23
|
+
const acl = yield client.sip.ipAccessControlLists.create({
|
|
24
|
+
friendlyName: aclName
|
|
25
|
+
});
|
|
26
|
+
for (const ip of aclEntries) {
|
|
27
|
+
yield client.sip.ipAccessControlLists(acl.sid).ipAddresses.create({
|
|
28
|
+
friendlyName: `${resourceRef}-entry-${ip}`,
|
|
29
|
+
ipAddress: ip
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// Create the trunk
|
|
33
|
+
const trunk = yield client.trunking.v1.trunks.create({
|
|
34
|
+
friendlyName: trunkName,
|
|
35
|
+
domainName: domainName
|
|
36
|
+
});
|
|
37
|
+
// Add the ACL to the trunk
|
|
38
|
+
yield client.trunking.v1.trunks(trunk.sid).ipAccessControlLists.create({
|
|
39
|
+
ipAccessControlListSid: acl.sid
|
|
40
|
+
});
|
|
41
|
+
// Create origination URL
|
|
42
|
+
yield client.trunking.v1.trunks(trunk.sid).originationUrls.create({
|
|
43
|
+
friendlyName: `Origination-${resourceRef}`,
|
|
44
|
+
sipUrl: originationUri,
|
|
45
|
+
priority: 10,
|
|
46
|
+
weight: 10,
|
|
47
|
+
enabled: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new Error(`Failed to create resources: ${error.message}`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.getFonosterNumberByTelUrl = getFonosterNumberByTelUrl;
|
|
46
|
+
/*
|
|
47
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
48
|
+
* http://github.com/fonoster/fonoster
|
|
49
|
+
*
|
|
50
|
+
* This file is part of Fonoster
|
|
51
|
+
*
|
|
52
|
+
* Licensed under the MIT License (the "License");
|
|
53
|
+
* you may not use this file except in compliance with
|
|
54
|
+
* the License. You may obtain a copy of the License at
|
|
55
|
+
*
|
|
56
|
+
* https://opensource.org/licenses/MIT
|
|
57
|
+
*
|
|
58
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
59
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
60
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
61
|
+
* See the License for the specific language governing permissions and
|
|
62
|
+
* limitations under the License.
|
|
63
|
+
*/
|
|
64
|
+
const Fonoster = __importStar(require("@fonoster/sdk"));
|
|
65
|
+
function getFonosterNumberByTelUrl(client, telUrl) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
try {
|
|
68
|
+
const numbers = new Fonoster.Numbers(client);
|
|
69
|
+
const numbersList = yield numbers.listNumbers({ pageSize: 1000 });
|
|
70
|
+
return numbersList.items.filter((number) => number.telUrl === telUrl)[0];
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw new Error(`Error checking Fonoster Number existence: ${error.message}`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.getFonosterTrunkByInboundUri = getFonosterTrunkByInboundUri;
|
|
46
|
+
/*
|
|
47
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
48
|
+
* http://github.com/fonoster/fonoster
|
|
49
|
+
*
|
|
50
|
+
* This file is part of Fonoster
|
|
51
|
+
*
|
|
52
|
+
* Licensed under the MIT License (the "License");
|
|
53
|
+
* you may not use this file except in compliance with
|
|
54
|
+
* the License. You may obtain a copy of the License at
|
|
55
|
+
*
|
|
56
|
+
* https://opensource.org/licenses/MIT
|
|
57
|
+
*
|
|
58
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
59
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
60
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
61
|
+
* See the License for the specific language governing permissions and
|
|
62
|
+
* limitations under the License.
|
|
63
|
+
*/
|
|
64
|
+
const Fonoster = __importStar(require("@fonoster/sdk"));
|
|
65
|
+
function getFonosterTrunkByInboundUri(client, inboundUri) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
try {
|
|
68
|
+
const trunks = new Fonoster.Trunks(client);
|
|
69
|
+
const trunksList = yield trunks.listTrunks({ pageSize: 1000 });
|
|
70
|
+
return trunksList.items.filter((trunk) => trunk.inboundUri === inboundUri)[0];
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw new Error(`Error checking SIP trunk existence: ${error.message}`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOutboundUri = getOutboundUri;
|
|
4
|
+
function getOutboundUri(uris) {
|
|
5
|
+
const uri = uris[0];
|
|
6
|
+
if (!uri) {
|
|
7
|
+
return "";
|
|
8
|
+
}
|
|
9
|
+
return `${uri.transport.toLowerCase()}://${uri.host}:${uri.port}`;
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Twilio } from "twilio";
|
|
2
|
+
import { IncomingPhoneNumberInstance } from "twilio/lib/rest/api/v2010/account/incomingPhoneNumber";
|
|
3
|
+
declare function getTwilioNumber(client: Twilio, phoneNumber: string): Promise<IncomingPhoneNumberInstance>;
|
|
4
|
+
export { getTwilioNumber };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getTwilioNumber = getTwilioNumber;
|
|
13
|
+
function getTwilioNumber(client, phoneNumber) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
try {
|
|
16
|
+
const numbers = yield client.incomingPhoneNumbers.list();
|
|
17
|
+
return numbers.filter((number) => number.phoneNumber === phoneNumber)[0];
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw new Error(`Error checking ownership of phone number: ${error.message}`);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getTwilioTrunk = getTwilioTrunk;
|
|
13
|
+
function getTwilioTrunk(client, terminationSipUri) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
try {
|
|
16
|
+
const trunks = yield client.trunking.v1.trunks.list();
|
|
17
|
+
return trunks.filter((trunk) => trunk.domainName === terminationSipUri)[0];
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw new Error(`Error checking SIP trunk existence: ${error.message}`);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|