@routr/sdk 2.34.2 → 3.0.0

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 CHANGED
@@ -264,7 +264,7 @@ Creates a new Agent on Routr.
264
264
  | request.privacy | <code>Privacy</code> | Privacy of the Agent (e.g., Privacy.PRIVATE) |
265
265
  | request.domainRef | <code>string</code> | Domain reference of the Domain the Agent belongs to |
266
266
  | request.credentialsRef | <code>string</code> | Credentials reference of the Credentials for the Agent |
267
- | request.enabled | <code>boolean</code> | Whether the Agent is enabled or not (for future use) |
267
+ | request.enabled | <code>boolean</code> | Whether the Agent is enabled; when false, it can't register or place calls (403) and calls to it from other Agents get 480 |
268
268
  | request.extended | <code>Object</code> | Optional extended attributes |
269
269
 
270
270
  **Example**
@@ -300,7 +300,7 @@ Updates an already existing Agent on Routr.
300
300
  | request.privacy | <code>Privacy</code> | Privacy of the Agent (e.g., Privacy.PRIVATE) |
301
301
  | request.domainRef | <code>string</code> | Domain reference of the Domain the Agent belongs to |
302
302
  | request.credentialsRef | <code>string</code> | Credentials reference of the Credentials for the Agent |
303
- | request.enabled | <code>boolean</code> | Whether the Agent is enabled or not (for future use) |
303
+ | request.enabled | <code>boolean</code> | Whether the Agent is enabled; when false, it can't register or place calls (403) and calls to it from other Agents get 480 |
304
304
  | request.extended | <code>Object</code> | Optional extended attributes |
305
305
 
306
306
  **Example**
@@ -654,7 +654,8 @@ Updates an already existing Domain on Routr.
654
654
  | request | <code>UpdateDomainRequest</code> | Partial with the fields to update |
655
655
  | request.name | <code>string</code> | Name of the Domain |
656
656
  | request.accessControlListRef | <code>string</code> | The reference to the AccessControlList for the Domain |
657
- | request.egressPolicies | <code>Array.&lt;EgressPolicy&gt;</code> | The list of EgressPolicies for the Domain |
657
+ | request.egressPolicies | <code>Array.&lt;EgressPolicy&gt;</code> | A non-empty list replaces the Domain's EgressPolicies; an empty list keeps them |
658
+ | request.clearEgressPolicies | <code>boolean</code> | Set to true to remove every EgressPolicy |
658
659
  | request.extended | <code>string</code> | Optional extended attributes |
659
660
 
660
661
  **Example**
@@ -852,7 +853,8 @@ Updates an already existing Number on Routr.
852
853
  | request | <code>UpdateNumberRequest</code> | Partial with the fields to update |
853
854
  | request.name | <code>string</code> | Name of the Number |
854
855
  | request.aorLink | <code>string</code> | The AOR link to be used (e.g., sip:1001@sip.local) |
855
- | request.extraHeaders | <code>Array.&lt;{name: string, value: string}&gt;</code> | Extra headers to be used (e.g., [\{name: "X-Room-Id", value: "abc-us-123"\}]) |
856
+ | request.extraHeaders | <code>Array.&lt;{name: string, value: string}&gt;</code> | A non-empty list replaces the Number's extra headers (e.g., [\{name: "X-Room-Id", value: "abc-us-123"\}]); an empty list keeps them |
857
+ | request.clearExtraHeaders | <code>boolean</code> | Set to true to remove every extra header |
856
858
  | request.trunkRef | <code>string</code> | The Trunk reference to be used |
857
859
  | request.aliases | <code>Array.&lt;string&gt;</code> | A non-empty list replaces the Number's aliases; an empty list keeps them |
858
860
  | request.clearAliases | <code>boolean</code> | Set to true to remove every alias |
@@ -1205,6 +1207,10 @@ Creates a new Trunk on Routr.
1205
1207
  | request.inboundCredentialsRef | <code>string</code> | The reference of the inbound credentials |
1206
1208
  | request.outboundCredentialsRef | <code>string</code> | The reference of the outbound credentials |
1207
1209
  | request.uris | <code>Array.&lt;TrunkURI&gt;</code> | The outbound URIs of the Trunk |
1210
+ | request.calledNumberFormat | <code>NumberFormat</code> | How the To and Request-URI users go out: E164, E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; unset sends them as dialed |
1211
+ | request.calledNumberPrefix | <code>string</code> | Goes before the called number; needs E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; digits, * and # (up to 20) |
1212
+ | request.callerNumberFormat | <code>NumberFormat</code> | How the Number in From, P-Asserted-Identity and Remote-Party-ID goes out |
1213
+ | request.callerNumberPrefix | <code>string</code> | Goes before the caller number; same rules as calledNumberPrefix |
1208
1214
 
1209
1215
  **Example**
1210
1216
  ```js
@@ -1247,7 +1253,12 @@ Updates an already existing Trunk on Routr.
1247
1253
  | request.accessControlListRef | <code>string</code> | Access Control List reference |
1248
1254
  | request.inboundCredentialsRef | <code>string</code> | The reference of the inbound credentials |
1249
1255
  | request.outboundCredentialsRef | <code>string</code> | The reference of the outbound credentials |
1250
- | request.uris | <code>Array.&lt;TrunkURI&gt;</code> | The outbound URIs of the Trunk |
1256
+ | request.uris | <code>Array.&lt;TrunkURI&gt;</code> | A non-empty list replaces the Trunk's outbound URIs; an empty list keeps them |
1257
+ | request.clearUris | <code>boolean</code> | Set to true to remove every outbound URI; the Trunk then can't carry outbound calls |
1258
+ | request.calledNumberFormat | <code>NumberFormat</code> | How the To and Request-URI users go out: E164, E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; UNSPECIFIED resets it |
1259
+ | request.calledNumberPrefix | <code>string</code> | Goes before the called number; needs E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; digits, * and # (up to 20); an empty string clears it |
1260
+ | request.callerNumberFormat | <code>NumberFormat</code> | How the Number in From, P-Asserted-Identity and Remote-Party-ID goes out |
1261
+ | request.callerNumberPrefix | <code>string</code> | Goes before the caller number; same rules as calledNumberPrefix |
1251
1262
  | request.extended | <code>Object</code> | Optional extended attributes |
1252
1263
 
1253
1264
  **Example**
@@ -44,7 +44,7 @@ export declare class Agents extends APIClient {
44
44
  * @param {Privacy} request.privacy - Privacy of the Agent (e.g., Privacy.PRIVATE)
45
45
  * @param {string} request.domainRef - Domain reference of the Domain the Agent belongs to
46
46
  * @param {string} request.credentialsRef - Credentials reference of the Credentials for the Agent
47
- * @param {boolean} request.enabled - Whether the Agent is enabled or not (for future use)
47
+ * @param {boolean} request.enabled - Whether the Agent is enabled; when false, it can't register or place calls (403) and calls to it from other Agents get 480
48
48
  * @param {Object} request.extended - Optional extended attributes
49
49
  * @return {Promise<CreateAgentResponse>} The newly created Agent
50
50
  * @throws if request is null
@@ -75,7 +75,7 @@ export declare class Agents extends APIClient {
75
75
  * @param {Privacy} request.privacy - Privacy of the Agent (e.g., Privacy.PRIVATE)
76
76
  * @param {string} request.domainRef - Domain reference of the Domain the Agent belongs to
77
77
  * @param {string} request.credentialsRef - Credentials reference of the Credentials for the Agent
78
- * @param {boolean} request.enabled - Whether the Agent is enabled or not (for future use)
78
+ * @param {boolean} request.enabled - Whether the Agent is enabled; when false, it can't register or place calls (403) and calls to it from other Agents get 480
79
79
  * @param {Object} request.extended - Optional extended attributes
80
80
  * @return {Promise<UpdateAgentResponse>} The updated Agent
81
81
  * @example
@@ -74,7 +74,7 @@ class Agents extends client_1.APIClient {
74
74
  * @param {Privacy} request.privacy - Privacy of the Agent (e.g., Privacy.PRIVATE)
75
75
  * @param {string} request.domainRef - Domain reference of the Domain the Agent belongs to
76
76
  * @param {string} request.credentialsRef - Credentials reference of the Credentials for the Agent
77
- * @param {boolean} request.enabled - Whether the Agent is enabled or not (for future use)
77
+ * @param {boolean} request.enabled - Whether the Agent is enabled; when false, it can't register or place calls (403) and calls to it from other Agents get 480
78
78
  * @param {Object} request.extended - Optional extended attributes
79
79
  * @return {Promise<CreateAgentResponse>} The newly created Agent
80
80
  * @throws if request is null
@@ -109,7 +109,7 @@ class Agents extends client_1.APIClient {
109
109
  * @param {Privacy} request.privacy - Privacy of the Agent (e.g., Privacy.PRIVATE)
110
110
  * @param {string} request.domainRef - Domain reference of the Domain the Agent belongs to
111
111
  * @param {string} request.credentialsRef - Credentials reference of the Credentials for the Agent
112
- * @param {boolean} request.enabled - Whether the Agent is enabled or not (for future use)
112
+ * @param {boolean} request.enabled - Whether the Agent is enabled; when false, it can't register or place calls (403) and calls to it from other Agents get 480
113
113
  * @param {Object} request.extended - Optional extended attributes
114
114
  * @return {Promise<UpdateAgentResponse>} The updated Agent
115
115
  * @example
@@ -0,0 +1,14 @@
1
+ import * as grpc from "@grpc/grpc-js";
2
+ import { ClientOptions } from "./types";
3
+ /**
4
+ * Builds the channel credentials for an endpoint: TLS, verified with cacert or
5
+ * the system store, unless insecure is true or ALLOW_INSECURE=true. A cacert
6
+ * wins over ALLOW_INSECURE. Throws instead of letting ALLOW_INSECURE send a
7
+ * credential in clear beyond loopback, when insecure and cacert are both given
8
+ * (the CA certificate would be ignored), and when the cacert file does not
9
+ * exist (an Error with code ENOENT).
10
+ *
11
+ * @param {ClientOptions} options - The client's options
12
+ * @return {grpc.ChannelCredentials} The credentials to dial with
13
+ */
14
+ export declare function buildCredentials(options: ClientOptions): grpc.ChannelCredentials;
@@ -0,0 +1,121 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.buildCredentials = buildCredentials;
40
+ /*
41
+ * Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
42
+ * http://github.com/fonoster/routr
43
+ *
44
+ * This file is part of Routr.
45
+ *
46
+ * Licensed under the MIT License (the "License");
47
+ * you may not use this file except in compliance with
48
+ * the License. You may obtain a copy of the License at
49
+ *
50
+ * https://opensource.org/licenses/MIT
51
+ *
52
+ * Unless required by applicable law or agreed to in writing, software
53
+ * distributed under the License is distributed on an "AS IS" BASIS,
54
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
55
+ * See the License for the specific language governing permissions and
56
+ * limitations under the License.
57
+ */
58
+ const grpc = __importStar(require("@grpc/grpc-js"));
59
+ const fs_1 = __importDefault(require("fs"));
60
+ const net_1 = __importDefault(require("net"));
61
+ /**
62
+ * Splits the host from an endpoint the way Go's net.SplitHostPort does:
63
+ * "[::1]:51907" is "::1" and "localhost:51907" is "localhost".
64
+ *
65
+ * @param {string} endpoint - host:port
66
+ * @return {string} The host
67
+ */
68
+ function hostOf(endpoint) {
69
+ if (net_1.default.isIP(endpoint))
70
+ return endpoint;
71
+ if (endpoint.startsWith("[")) {
72
+ const end = endpoint.indexOf("]");
73
+ return end === -1 ? endpoint : endpoint.slice(1, end);
74
+ }
75
+ const colon = endpoint.lastIndexOf(":");
76
+ return colon === -1 ? endpoint : endpoint.slice(0, colon);
77
+ }
78
+ /**
79
+ * Tells if a host is this machine: localhost, 127.0.0.0/8 or ::1. It never
80
+ * resolves a name.
81
+ *
82
+ * @param {string} host - A host name or an IP address
83
+ * @return {boolean} True for loopback
84
+ */
85
+ function isLoopback(host) {
86
+ return (host.toLowerCase() === "localhost" ||
87
+ (net_1.default.isIPv4(host) && host.startsWith("127.")) ||
88
+ host === "::1");
89
+ }
90
+ /**
91
+ * Builds the channel credentials for an endpoint: TLS, verified with cacert or
92
+ * the system store, unless insecure is true or ALLOW_INSECURE=true. A cacert
93
+ * wins over ALLOW_INSECURE. Throws instead of letting ALLOW_INSECURE send a
94
+ * credential in clear beyond loopback, when insecure and cacert are both given
95
+ * (the CA certificate would be ignored), and when the cacert file does not
96
+ * exist (an Error with code ENOENT).
97
+ *
98
+ * @param {ClientOptions} options - The client's options
99
+ * @return {grpc.ChannelCredentials} The credentials to dial with
100
+ */
101
+ function buildCredentials(options) {
102
+ if (options.insecure === true && options.cacert) {
103
+ throw new Error("insecure and cacert can't be used together: insecure is plaintext and would ignore the CA certificate. Remove insecure (--insecure in rctl) to verify the server with the cacert, or remove cacert (--cacert in rctl) for plaintext.");
104
+ }
105
+ if (options.insecure === true)
106
+ return grpc.credentials.createInsecure();
107
+ if (options.cacert) {
108
+ if (!fs_1.default.existsSync(options.cacert)) {
109
+ throw Object.assign(new Error(`the file ${options.cacert} does not exist`), { code: "ENOENT" });
110
+ }
111
+ return grpc.credentials.createSsl(fs_1.default.readFileSync(options.cacert));
112
+ }
113
+ if (process.env.ALLOW_INSECURE !== "true") {
114
+ return grpc.credentials.createSsl();
115
+ }
116
+ const sendsCredential = !!options.apiKey || !!(options.username && options.password);
117
+ if (sendsCredential && !isLoopback(hostOf(options.endpoint))) {
118
+ throw new Error(`ALLOW_INSECURE would send the API key in clear to ${options.endpoint}. Set insecure: true (--insecure in rctl) to accept that, or unset ALLOW_INSECURE for TLS (cacert, --cacert in rctl, for a private CA).`);
119
+ }
120
+ return grpc.credentials.createInsecure();
121
+ }
package/dist/client.d.ts CHANGED
@@ -1,5 +1,14 @@
1
+ import { Metadata } from "@grpc/grpc-js";
1
2
  import { CommonConnect as CC } from "@routr/common";
2
3
  import { ClientOptions } from "./types";
4
+ /**
5
+ * Builds the metadata every call carries: the API key or, without one, the
6
+ * username and password.
7
+ *
8
+ * @param {ClientOptions} options - The client's options
9
+ * @return {Metadata} The metadata
10
+ */
11
+ export declare function buildMetadata(options: ClientOptions): Metadata;
3
12
  export declare abstract class APIClient {
4
13
  client: CC.APIClient;
5
14
  constructor(options: ClientOptions);
package/dist/client.js CHANGED
@@ -1,42 +1,7 @@
1
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 __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.APIClient = void 0;
4
+ exports.buildMetadata = buildMetadata;
40
5
  /*
41
6
  * Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
42
7
  * http://github.com/fonoster/routr
@@ -56,25 +21,30 @@ exports.APIClient = void 0;
56
21
  * limitations under the License.
57
22
  */
58
23
  /* eslint-disable require-jsdoc */
59
- const grpc = __importStar(require("@grpc/grpc-js"));
60
24
  const grpc_js_1 = require("@grpc/grpc-js");
61
25
  const common_1 = require("@routr/common");
62
- const fs_1 = __importDefault(require("fs"));
26
+ const build_credentials_1 = require("./build_credentials");
27
+ /**
28
+ * Builds the metadata every call carries: the API key or, without one, the
29
+ * username and password.
30
+ *
31
+ * @param {ClientOptions} options - The client's options
32
+ * @return {Metadata} The metadata
33
+ */
34
+ function buildMetadata(options) {
35
+ const metadata = new grpc_js_1.Metadata();
36
+ if (options.apiKey) {
37
+ metadata.set("authorization", `Bearer ${options.apiKey}`);
38
+ }
39
+ else if (options.username && options.password) {
40
+ metadata.set("authorization", `Basic ${Buffer.from(`${options.username}:${options.password}`).toString("base64")}`);
41
+ }
42
+ return metadata;
43
+ }
63
44
  class APIClient {
64
45
  constructor(options) {
65
- const metadata = new grpc_js_1.Metadata();
66
- if (options.username && options.password) {
67
- metadata.set("authorization", `Basic ${Buffer.from(`${options.username}:${options.password}`).toString("base64")}`);
68
- }
69
- if (options.cacert) {
70
- common_1.Assertions.assertFileExist(options.cacert);
71
- }
72
- const cacert = fs_1.default.existsSync(options.cacert)
73
- ? fs_1.default.readFileSync(options.cacert)
74
- : null;
75
- const credentials = process.env.ALLOW_INSECURE === "true" || options.insecure === true
76
- ? grpc.credentials.createInsecure()
77
- : grpc.credentials.createSsl(cacert);
46
+ const metadata = buildMetadata(options);
47
+ const credentials = (0, build_credentials_1.buildCredentials)(options);
78
48
  this.client = common_1.CommonConnect.apiClient({
79
49
  apiAddr: options.endpoint,
80
50
  metadata,
@@ -73,7 +73,8 @@ export declare class Domains extends APIClient {
73
73
  * @param {UpdateDomainRequest} request - Partial with the fields to update
74
74
  * @param {string} request.name - Name of the Domain
75
75
  * @param {string} request.accessControlListRef - The reference to the AccessControlList for the Domain
76
- * @param {EgressPolicy[]} request.egressPolicies - The list of EgressPolicies for the Domain
76
+ * @param {EgressPolicy[]} request.egressPolicies - A non-empty list replaces the Domain's EgressPolicies; an empty list keeps them
77
+ * @param {boolean} request.clearEgressPolicies - Set to true to remove every EgressPolicy
77
78
  * @param {string} request.extended - Optional extended attributes
78
79
  * @return {Promise<UpdateDomainResponse>} The updated Domain
79
80
  * @example
@@ -107,7 +107,8 @@ class Domains extends client_1.APIClient {
107
107
  * @param {UpdateDomainRequest} request - Partial with the fields to update
108
108
  * @param {string} request.name - Name of the Domain
109
109
  * @param {string} request.accessControlListRef - The reference to the AccessControlList for the Domain
110
- * @param {EgressPolicy[]} request.egressPolicies - The list of EgressPolicies for the Domain
110
+ * @param {EgressPolicy[]} request.egressPolicies - A non-empty list replaces the Domain's EgressPolicies; an empty list keeps them
111
+ * @param {boolean} request.clearEgressPolicies - Set to true to remove every EgressPolicy
111
112
  * @param {string} request.extended - Optional extended attributes
112
113
  * @return {Promise<UpdateDomainResponse>} The updated Domain
113
114
  * @example
@@ -6,6 +6,7 @@ export type CreateDomainRequest = Omit<CC.Domain, CreateBaseOmit | "accessContro
6
6
  export type CreateDomainResponse = CC.Domain;
7
7
  export type UpdateDomainRequest = {
8
8
  ref: string;
9
+ clearEgressPolicies?: boolean;
9
10
  } & Partial<Omit<CreateDomainRequest, "domainUri">>;
10
11
  export type UpdateDomainResponse = CC.Domain;
11
12
  export type ListDomainRequest = CC.ListRequest;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import Credentials from "./credentials";
5
5
  import Peers from "./peers";
6
6
  import Numbers from "./numbers";
7
7
  import Trunks from "./trunks";
8
+ import { buildCredentials } from "./build_credentials";
8
9
  declare const SDK: {
9
10
  Acls: typeof Acls;
10
11
  Agents: typeof Agents;
@@ -14,4 +15,4 @@ declare const SDK: {
14
15
  Trunks: typeof Trunks;
15
16
  Credentials: typeof Credentials;
16
17
  };
17
- export { SDK as default };
18
+ export { SDK as default, buildCredentials };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = void 0;
6
+ exports.buildCredentials = exports.default = void 0;
7
7
  /*
8
8
  * Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
9
9
  * http://github.com/fonoster/routr
@@ -29,6 +29,8 @@ const credentials_1 = __importDefault(require("./credentials"));
29
29
  const peers_1 = __importDefault(require("./peers"));
30
30
  const numbers_1 = __importDefault(require("./numbers"));
31
31
  const trunks_1 = __importDefault(require("./trunks"));
32
+ const build_credentials_1 = require("./build_credentials");
33
+ Object.defineProperty(exports, "buildCredentials", { enumerable: true, get: function () { return build_credentials_1.buildCredentials; } });
32
34
  const SDK = {
33
35
  Acls: acls_1.default,
34
36
  Agents: agents_1.default,
@@ -90,7 +90,8 @@ export declare class Numbers extends APIClient {
90
90
  * @param {UpdateNumberRequest} request - Partial with the fields to update
91
91
  * @param {string} request.name - Name of the Number
92
92
  * @param {string} request.aorLink - The AOR link to be used (e.g., sip:1001@sip.local)
93
- * @param {Array<{name: string, value: string}>} request.extraHeaders - Extra headers to be used (e.g., [\{name: "X-Room-Id", value: "abc-us-123"\}])
93
+ * @param {Array<{name: string, value: string}>} request.extraHeaders - A non-empty list replaces the Number's extra headers (e.g., [\{name: "X-Room-Id", value: "abc-us-123"\}]); an empty list keeps them
94
+ * @param {boolean} request.clearExtraHeaders - Set to true to remove every extra header
94
95
  * @param {string} request.trunkRef - The Trunk reference to be used
95
96
  * @param {string[]} request.aliases - A non-empty list replaces the Number's aliases; an empty list keeps them
96
97
  * @param {boolean} request.clearAliases - Set to true to remove every alias
@@ -124,7 +124,8 @@ class Numbers extends client_1.APIClient {
124
124
  * @param {UpdateNumberRequest} request - Partial with the fields to update
125
125
  * @param {string} request.name - Name of the Number
126
126
  * @param {string} request.aorLink - The AOR link to be used (e.g., sip:1001@sip.local)
127
- * @param {Array<{name: string, value: string}>} request.extraHeaders - Extra headers to be used (e.g., [\{name: "X-Room-Id", value: "abc-us-123"\}])
127
+ * @param {Array<{name: string, value: string}>} request.extraHeaders - A non-empty list replaces the Number's extra headers (e.g., [\{name: "X-Room-Id", value: "abc-us-123"\}]); an empty list keeps them
128
+ * @param {boolean} request.clearExtraHeaders - Set to true to remove every extra header
128
129
  * @param {string} request.trunkRef - The Trunk reference to be used
129
130
  * @param {string[]} request.aliases - A non-empty list replaces the Number's aliases; an empty list keeps them
130
131
  * @param {boolean} request.clearAliases - Set to true to remove every alias
@@ -5,6 +5,7 @@ export type CreateNumberResponse = CC.INumber;
5
5
  export type UpdateNumberRequest = {
6
6
  ref: string;
7
7
  clearAliases?: boolean;
8
+ clearExtraHeaders?: boolean;
8
9
  } & Partial<Omit<CreateNumberRequest, "telUrl" | "city" | "country" | "countryIsoCode">>;
9
10
  export type UpdateNumberResponse = CC.INumber;
10
11
  export type ListNumberRequest = CC.ListRequest;
@@ -52,6 +52,10 @@ export declare class Trunks extends APIClient {
52
52
  * @param {string} request.inboundCredentialsRef - The reference of the inbound credentials
53
53
  * @param {string} request.outboundCredentialsRef - The reference of the outbound credentials
54
54
  * @param {TrunkURI[]} request.uris - The outbound URIs of the Trunk
55
+ * @param {NumberFormat} request.calledNumberFormat - How the To and Request-URI users go out: E164, E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; unset sends them as dialed
56
+ * @param {string} request.calledNumberPrefix - Goes before the called number; needs E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; digits, * and # (up to 20)
57
+ * @param {NumberFormat} request.callerNumberFormat - How the Number in From, P-Asserted-Identity and Remote-Party-ID goes out
58
+ * @param {string} request.callerNumberPrefix - Goes before the caller number; same rules as calledNumberPrefix
55
59
  * @return {Promise<CreateTrunkResponse>} The newly created Trunk
56
60
  * @throws if request is null
57
61
  * @example
@@ -89,7 +93,12 @@ export declare class Trunks extends APIClient {
89
93
  * @param {string} request.accessControlListRef - Access Control List reference
90
94
  * @param {string} request.inboundCredentialsRef - The reference of the inbound credentials
91
95
  * @param {string} request.outboundCredentialsRef - The reference of the outbound credentials
92
- * @param {TrunkURI[]} request.uris - The outbound URIs of the Trunk
96
+ * @param {TrunkURI[]} request.uris - A non-empty list replaces the Trunk's outbound URIs; an empty list keeps them
97
+ * @param {boolean} request.clearUris - Set to true to remove every outbound URI; the Trunk then can't carry outbound calls
98
+ * @param {NumberFormat} request.calledNumberFormat - How the To and Request-URI users go out: E164, E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; UNSPECIFIED resets it
99
+ * @param {string} request.calledNumberPrefix - Goes before the called number; needs E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; digits, * and # (up to 20); an empty string clears it
100
+ * @param {NumberFormat} request.callerNumberFormat - How the Number in From, P-Asserted-Identity and Remote-Party-ID goes out
101
+ * @param {string} request.callerNumberPrefix - Goes before the caller number; same rules as calledNumberPrefix
93
102
  * @param {Object} request.extended - Optional extended attributes
94
103
  * @return {Promise<UpdateTrunkResponse>} The updated Trunk
95
104
  * @example
@@ -82,6 +82,10 @@ class Trunks extends client_1.APIClient {
82
82
  * @param {string} request.inboundCredentialsRef - The reference of the inbound credentials
83
83
  * @param {string} request.outboundCredentialsRef - The reference of the outbound credentials
84
84
  * @param {TrunkURI[]} request.uris - The outbound URIs of the Trunk
85
+ * @param {NumberFormat} request.calledNumberFormat - How the To and Request-URI users go out: E164, E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; unset sends them as dialed
86
+ * @param {string} request.calledNumberPrefix - Goes before the called number; needs E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; digits, * and # (up to 20)
87
+ * @param {NumberFormat} request.callerNumberFormat - How the Number in From, P-Asserted-Identity and Remote-Party-ID goes out
88
+ * @param {string} request.callerNumberPrefix - Goes before the caller number; same rules as calledNumberPrefix
85
89
  * @return {Promise<CreateTrunkResponse>} The newly created Trunk
86
90
  * @throws if request is null
87
91
  * @example
@@ -123,7 +127,12 @@ class Trunks extends client_1.APIClient {
123
127
  * @param {string} request.accessControlListRef - Access Control List reference
124
128
  * @param {string} request.inboundCredentialsRef - The reference of the inbound credentials
125
129
  * @param {string} request.outboundCredentialsRef - The reference of the outbound credentials
126
- * @param {TrunkURI[]} request.uris - The outbound URIs of the Trunk
130
+ * @param {TrunkURI[]} request.uris - A non-empty list replaces the Trunk's outbound URIs; an empty list keeps them
131
+ * @param {boolean} request.clearUris - Set to true to remove every outbound URI; the Trunk then can't carry outbound calls
132
+ * @param {NumberFormat} request.calledNumberFormat - How the To and Request-URI users go out: E164, E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; UNSPECIFIED resets it
133
+ * @param {string} request.calledNumberPrefix - Goes before the called number; needs E164_WITHOUT_PLUS, NATIONAL or INTERNATIONAL; digits, * and # (up to 20); an empty string clears it
134
+ * @param {NumberFormat} request.callerNumberFormat - How the Number in From, P-Asserted-Identity and Remote-Party-ID goes out
135
+ * @param {string} request.callerNumberPrefix - Goes before the caller number; same rules as calledNumberPrefix
127
136
  * @param {Object} request.extended - Optional extended attributes
128
137
  * @return {Promise<UpdateTrunkResponse>} The updated Trunk
129
138
  * @example
@@ -4,6 +4,7 @@ export type CreateTrunkRequest = Omit<CC.Trunk, CreateBaseOmit | "accessControlL
4
4
  export type CreateTrunkResponse = Flatten<CC.Trunk>;
5
5
  export type UpdateTrunkRequest = Flatten<{
6
6
  ref: string;
7
+ clearUris?: boolean;
7
8
  } & Partial<CreateTrunkRequest>>;
8
9
  export type UpdateTrunkResponse = Flatten<CC.Trunk>;
9
10
  export type ListTrunkRequest = Flatten<CC.ListRequest>;
package/dist/types.d.ts CHANGED
@@ -4,6 +4,7 @@ export interface ClientOptions {
4
4
  username?: string;
5
5
  password?: string;
6
6
  cacert?: string;
7
+ apiKey?: string;
7
8
  }
8
9
  export type Flatten<T> = {
9
10
  [K in keyof T]: T[K];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/sdk",
3
- "version": "2.34.2",
3
+ "version": "3.0.0",
4
4
  "description": "The Routr SDK for Node.js",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@fonoster/logger": "0.6.0",
21
21
  "@grpc/grpc-js": "~1.14.6",
22
- "@routr/common": "^2.34.2",
22
+ "@routr/common": "^3.0.0",
23
23
  "google-protobuf": "^3.21.4",
24
24
  "pb-util": "^1.0.3"
25
25
  },
@@ -39,5 +39,5 @@
39
39
  "devDependencies": {
40
40
  "@types/google-protobuf": "^3.15.6"
41
41
  },
42
- "gitHead": "5766eb15fd60f870fc260d4ec52db232c038ab7c"
42
+ "gitHead": "0d1c70fd63fa2add5daf718db15fa3b281a46cd6"
43
43
  }