@unboundcx/sdk-internal 2.0.1 → 2.1.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/index.js +3 -0
- package/package.json +2 -2
- package/services/masterAuth.js +33 -0
- package/services/phoneNumbers.js +31 -0
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { InternalServersService } from './services/servers.js';
|
|
|
8
8
|
import { InternalSocketService } from './services/socket.js';
|
|
9
9
|
import { InternalMasterAuthService } from './services/masterAuth.js';
|
|
10
10
|
import { InternalBrandingService } from './services/branding.js';
|
|
11
|
+
import { InternalPhoneNumbersService } from './services/phoneNumbers.js';
|
|
11
12
|
|
|
12
13
|
export class InternalSDK {
|
|
13
14
|
constructor(sdk, buildMasterApiAuthFn) {
|
|
@@ -22,6 +23,7 @@ export class InternalSDK {
|
|
|
22
23
|
this.socket = new InternalSocketService(sdk);
|
|
23
24
|
this.masterAuth = new InternalMasterAuthService(sdk);
|
|
24
25
|
this.branding = new InternalBrandingService(sdk);
|
|
26
|
+
this.phoneNumbers = new InternalPhoneNumbersService(sdk);
|
|
25
27
|
|
|
26
28
|
// Proxy all base SDK properties and methods
|
|
27
29
|
this._proxyBaseSDK();
|
|
@@ -123,3 +125,4 @@ export {
|
|
|
123
125
|
export { InternalSocketService } from './services/socket.js';
|
|
124
126
|
export { InternalMasterAuthService } from './services/masterAuth.js';
|
|
125
127
|
export { InternalBrandingService } from './services/branding.js';
|
|
128
|
+
export { InternalPhoneNumbersService } from './services/phoneNumbers.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk-internal",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Internal SDK extension for Unbound - Provides access to internal APIs and administrative functions",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@unboundcx/sdk": "
|
|
56
|
+
"@unboundcx/sdk": ">=2.0.0 <5.0.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {},
|
|
59
59
|
"publishConfig": {
|
package/services/masterAuth.js
CHANGED
|
@@ -32,4 +32,37 @@ export class InternalMasterAuthService {
|
|
|
32
32
|
);
|
|
33
33
|
return result;
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Mint an internal service token — the kind baked into pods as BOOT_TOKEN.
|
|
38
|
+
*
|
|
39
|
+
* Requires internal auth (the caller must already hold a valid internal
|
|
40
|
+
* token). Intended for manual/operational use: the returned token is stored
|
|
41
|
+
* in Zeus connection storage and injected into the services that need it.
|
|
42
|
+
*
|
|
43
|
+
* @param {object} [opts]
|
|
44
|
+
* @param {string} [opts.service='internal'] - value for the `service` claim
|
|
45
|
+
* @param {number} [opts.expiresIn] - lifetime in seconds; omit for a
|
|
46
|
+
* non-expiring token (matches the
|
|
47
|
+
* legacy BOOT_TOKEN)
|
|
48
|
+
*/
|
|
49
|
+
async createInternalToken({ service = 'internal', expiresIn } = {}) {
|
|
50
|
+
this.sdk.validateParams(
|
|
51
|
+
{ service, expiresIn },
|
|
52
|
+
{
|
|
53
|
+
service: { type: 'string', required: false },
|
|
54
|
+
expiresIn: { type: 'number', required: false },
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const body = { service };
|
|
59
|
+
if (expiresIn !== undefined) body.expiresIn = expiresIn;
|
|
60
|
+
|
|
61
|
+
const result = await this.sdk._fetch(
|
|
62
|
+
'/internal/masterAuth/internal-token',
|
|
63
|
+
'POST',
|
|
64
|
+
{ body },
|
|
65
|
+
);
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
35
68
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export class InternalPhoneNumbersService {
|
|
2
|
+
constructor(sdk) {
|
|
3
|
+
this.sdk = sdk;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Claim a number from Telnyx into the global phoneNumbers inventory as an
|
|
8
|
+
* unassigned row. Requires an internal auth token — this bypasses normal
|
|
9
|
+
* ordering/billing and is not part of the public SDK.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} params
|
|
12
|
+
* @param {string} params.phoneNumber - +E.164 number that already exists on the Telnyx account
|
|
13
|
+
*/
|
|
14
|
+
async createInventory({ phoneNumber }) {
|
|
15
|
+
this.sdk.validateParams(
|
|
16
|
+
{ phoneNumber },
|
|
17
|
+
{
|
|
18
|
+
phoneNumber: { type: 'string', required: true },
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const result = await this.sdk._fetch(
|
|
23
|
+
'/internal/phoneNumbers/inventory',
|
|
24
|
+
'POST',
|
|
25
|
+
{
|
|
26
|
+
body: { phoneNumber },
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
}
|