@unboundcx/sdk-internal 1.0.0 → 1.0.1

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
@@ -16,6 +16,7 @@ npm install @unbound/sdk-internal
16
16
  ```
17
17
 
18
18
  **Requirements:**
19
+
19
20
  - `@unbound/sdk` ^1.0.0
20
21
  - Node.js environment (browser usage not supported)
21
22
 
@@ -30,17 +31,17 @@ import InternalSDK from '@unbound/sdk-internal';
30
31
  const api = new SDK({
31
32
  namespace: 'namespace',
32
33
  callId: 'call-id',
33
- token: 'jwt-token'
34
+ token: 'jwt-token',
34
35
  });
35
36
 
36
37
  // Extend with internal functionality
37
38
  api.use(InternalSDK);
38
39
 
39
40
  // Now has access to internal methods
40
- await api.buildMasterAuth({
41
+ await api.buildMasterAuth({
41
42
  namespace: 'target-namespace',
42
- accountId: 'account-123',
43
- userId: 'user-456'
43
+ accountId: 'account-123',
44
+ userId: 'user-456',
44
45
  });
45
46
  ```
46
47
 
@@ -65,9 +66,9 @@ Build master authentication tokens for cross-account access:
65
66
 
66
67
  ```javascript
67
68
  const token = await api.buildMasterAuth({
68
- namespace: 'target-namespace', // Target namespace
69
- accountId: 'account-123', // Target account ID
70
- userId: 'user-456' // Target user ID
69
+ namespace: 'target-namespace', // Target namespace
70
+ accountId: 'account-123', // Target account ID
71
+ userId: 'user-456', // Target user ID
71
72
  });
72
73
 
73
74
  // Token is automatically set on the SDK instance
@@ -79,26 +80,31 @@ console.log(api.token); // JWT token for the target account/user
79
80
  Administrative SIP functions for call routing and registration:
80
81
 
81
82
  #### Router
83
+
82
84
  ```javascript
83
85
  await api.internal.sip.router(
84
- '+1234567890', // to
85
- '+0987654321', // from
86
- 'call-123', // callId
87
- { /* auth */ }, // auth object
88
- 'inbound' // peerDirection
86
+ '+1234567890', // to
87
+ '+0987654321', // from
88
+ 'call-123', // callId
89
+ {
90
+ /* auth */
91
+ }, // auth object
92
+ 'inbound', // peerDirection
89
93
  );
90
94
  ```
91
95
 
92
96
  #### Server Management
97
+
93
98
  ```javascript
94
99
  const server = await api.internal.sip.getServer(
95
- 'voice', // type
96
- 'us-east-1', // regionCode
97
- 'call-123' // callId
100
+ 'voice', // type
101
+ 'us-east-1', // regionCode
102
+ 'call-123', // callId
98
103
  );
99
104
  ```
100
105
 
101
106
  #### Registration Management
107
+
102
108
  ```javascript
103
109
  // Register SIP endpoint
104
110
  await api.internal.sip.register({
@@ -113,7 +119,7 @@ await api.internal.sip.register({
113
119
  contact: 'sip:user@example.com',
114
120
  domain: 'sip.example.com',
115
121
  userAgent: 'Unbound-SIP/1.0',
116
- expiresAt: Date.now() + 3600000 // 1 hour from now
122
+ expiresAt: Date.now() + 3600000, // 1 hour from now
117
123
  });
118
124
 
119
125
  // Unregister SIP endpoint
@@ -121,6 +127,7 @@ await api.internal.sip.unregister('call-123', 'user123', 'account-123');
121
127
  ```
122
128
 
123
129
  #### Authentication Validation
130
+
124
131
  ```javascript
125
132
  await api.internal.sip.validate({
126
133
  method: 'INVITE',
@@ -135,17 +142,20 @@ await api.internal.sip.validate({
135
142
  authType: 'digest',
136
143
  ip: '192.168.1.100',
137
144
  peerDirection: 'inbound',
138
- location: 'us-east-1'
145
+ location: 'us-east-1',
139
146
  });
140
147
  ```
141
148
 
142
149
  #### Logging
150
+
143
151
  ```javascript
144
152
  await api.internal.sip.log({
145
153
  callId: 'call-123',
146
154
  level: 'info',
147
155
  message: 'Call established',
148
- data: { /* additional data */ }
156
+ data: {
157
+ /* additional data */
158
+ },
149
159
  });
150
160
  ```
151
161
 
@@ -154,8 +164,9 @@ await api.internal.sip.log({
154
164
  This package is designed for **Node.js environments only** and will throw errors when used in browser environments. The internal APIs require server-side authentication and access patterns.
155
165
 
156
166
  ### Supported Environments
167
+
157
168
  - ✅ Node.js servers
158
- - ✅ AWS Lambda functions
169
+ - ✅ AWS Lambda functions
159
170
  - ✅ Docker containers
160
171
  - ✅ Kubernetes pods
161
172
  - ❌ Browser applications
@@ -164,16 +175,19 @@ This package is designed for **Node.js environments only** and will throw errors
164
175
  ## Security Considerations
165
176
 
166
177
  ### Access Control
178
+
167
179
  - All internal APIs require elevated authentication
168
180
  - Methods may bypass normal user permission checks
169
181
  - Use with extreme caution in production environments
170
182
 
171
183
  ### Authentication
184
+
172
185
  - Requires valid JWT tokens with administrative privileges
173
186
  - `buildMasterAuth` provides cross-account access capabilities
174
187
  - Always validate target accounts/users before authentication
175
188
 
176
189
  ### Network Security
190
+
177
191
  - Internal APIs may be accessible only from specific IP ranges
178
192
  - SIP functions interact with core telephony infrastructure
179
193
  - Audit all usage for security compliance
@@ -182,9 +196,9 @@ This package is designed for **Node.js environments only** and will throw errors
182
196
 
183
197
  ```javascript
184
198
  try {
185
- await api.buildMasterAuth({
199
+ await api.buildMasterAuth({
186
200
  namespace: 'invalid-namespace',
187
- accountId: 'invalid-account'
201
+ accountId: 'invalid-account',
188
202
  });
189
203
  } catch (error) {
190
204
  if (error.message.includes('Master authentication failed')) {
@@ -198,6 +212,7 @@ try {
198
212
  ## Development
199
213
 
200
214
  ### Setup
215
+
201
216
  ```bash
202
217
  git clone https://github.com/unbound/sdk-js-internal.git
203
218
  cd sdk-js-internal
@@ -205,12 +220,14 @@ npm install
205
220
  ```
206
221
 
207
222
  ### Testing
223
+
208
224
  ```bash
209
225
  npm test # Run tests
210
- npm run test:watch # Watch mode
226
+ npm run test:watch # Watch mode
211
227
  ```
212
228
 
213
229
  ### Building
230
+
214
231
  ```bash
215
232
  npm run build # Build for production
216
233
  npm run lint # Check code style
@@ -228,6 +245,7 @@ Internal package contributions require:
228
245
  ## Support
229
246
 
230
247
  For internal support:
248
+
231
249
  - 📧 [Internal Support](mailto:internal-support@unbound.cx)
232
250
  - 📚 [Internal Documentation](https://internal-docs.unbound.cx/sdk)
233
251
  - 🚨 [Security Issues](mailto:security@unbound.cx)
@@ -236,4 +254,4 @@ For internal support:
236
254
 
237
255
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
238
256
 
239
- **Note**: While the code is MIT licensed, access to Unbound's internal APIs requires proper authentication and authorization.
257
+ **Note**: While the code is MIT licensed, access to Unbound's internal APIs requires proper authentication and authorization.
package/index.js CHANGED
@@ -8,8 +8,9 @@ import { InternalServersService } from './services/servers.js';
8
8
  import { InternalSocketService } from './services/socket.js';
9
9
 
10
10
  export class InternalSDK {
11
- constructor(sdk) {
11
+ constructor(sdk, buildMasterApiAuthFn) {
12
12
  this.sdk = sdk;
13
+ this.buildMasterApiAuthFn = buildMasterApiAuthFn;
13
14
  this.sip = new InternalSipService(sdk);
14
15
  this.email = new InternalEmailService(sdk);
15
16
  this.programmableVoice = new InternalProgrammableVoiceService(sdk);
@@ -20,14 +21,25 @@ export class InternalSDK {
20
21
  // Master auth method - only available in Node.js
21
22
  async buildMasterAuth({ namespace, accountId, userId }) {
22
23
  if (typeof window !== 'undefined') {
23
- throw new Error('buildMasterAuth is only available in Node.js environment');
24
+ throw new Error(
25
+ 'buildMasterAuth is only available in Node.js environment',
26
+ );
24
27
  }
25
-
26
- const { buildMasterApiAuth } = await import('../src/utils/index.js');
28
+
29
+ if (!this.buildMasterApiAuthFn) {
30
+ throw new Error(
31
+ 'buildMasterApiAuth function not provided to InternalSDK constructor',
32
+ );
33
+ }
34
+
27
35
  if (namespace) {
28
36
  this.sdk.setNamespace(namespace);
29
37
  }
30
- const auth = await buildMasterApiAuth(this.sdk.namespace, accountId, userId);
38
+ const auth = await this.buildMasterApiAuthFn(
39
+ this.sdk.namespace,
40
+ accountId,
41
+ userId,
42
+ );
31
43
  if (auth?.token?.jwt) {
32
44
  this.sdk.token = auth.token.jwt;
33
45
  }
@@ -36,12 +48,12 @@ export class InternalSDK {
36
48
  }
37
49
 
38
50
  // Extension pattern for the main SDK
39
- export function install(sdk) {
40
- const internal = new InternalSDK(sdk);
41
-
51
+ export function install(sdk, buildMasterApiAuthFn) {
52
+ const internal = new InternalSDK(sdk, buildMasterApiAuthFn);
53
+
42
54
  // Add buildMasterAuth to the main SDK instance
43
55
  sdk.buildMasterAuth = internal.buildMasterAuth.bind(internal);
44
-
56
+
45
57
  // Add internal services
46
58
  sdk.internal = {
47
59
  sip: internal.sip,
@@ -58,6 +70,13 @@ export default { install };
58
70
  // Individual service exports
59
71
  export { InternalSipService } from './services/sip.js';
60
72
  export { InternalEmailService } from './services/email.js';
61
- export { InternalProgrammableVoiceService, VoiceChannelService, TranscriptionService } from './services/programmableVoice.js';
62
- export { InternalServersService, AwsServersService } from './services/servers.js';
63
- export { InternalSocketService } from './services/socket.js';
73
+ export {
74
+ InternalProgrammableVoiceService,
75
+ VoiceChannelService,
76
+ TranscriptionService,
77
+ } from './services/programmableVoice.js';
78
+ export {
79
+ InternalServersService,
80
+ AwsServersService,
81
+ } from './services/servers.js';
82
+ export { InternalSocketService } from './services/socket.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk-internal",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
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",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "scripts": {
49
49
  "build": "echo 'Build complete - ESM modules ready'",
50
- "test": "echo 'Tests would run here'",
50
+ "test": "echo 'Tests would run here'",
51
51
  "lint": "echo 'Linting would run here'",
52
52
  "prepublishOnly": "npm run build"
53
53
  },
@@ -60,4 +60,4 @@
60
60
  "registry": "https://registry.npmjs.org/",
61
61
  "access": "restricted"
62
62
  }
63
- }
63
+ }
package/services/email.js CHANGED
@@ -59,4 +59,4 @@ export class InternalEmailService {
59
59
  );
60
60
  return result;
61
61
  }
62
- }
62
+ }
@@ -17,7 +17,11 @@ export class InternalProgrammableVoiceService {
17
17
  body: streamData,
18
18
  };
19
19
 
20
- const result = await this.sdk._fetch('/internal/programmableVoice/streamProxy', 'POST', params);
20
+ const result = await this.sdk._fetch(
21
+ '/internal/programmableVoice/streamProxy',
22
+ 'POST',
23
+ params,
24
+ );
21
25
  return result;
22
26
  }
23
27
 
@@ -33,7 +37,11 @@ export class InternalProgrammableVoiceService {
33
37
  body: webhookData,
34
38
  };
35
39
 
36
- const result = await this.sdk._fetch('/internal/programmableVoice/proxy', 'POST', params);
40
+ const result = await this.sdk._fetch(
41
+ '/internal/programmableVoice/proxy',
42
+ 'POST',
43
+ params,
44
+ );
37
45
  return result;
38
46
  }
39
47
 
@@ -61,7 +69,11 @@ export class InternalProgrammableVoiceService {
61
69
  },
62
70
  };
63
71
 
64
- const result = await this.sdk._fetch('/internal/programmableVoice/setVariable', 'POST', params);
72
+ const result = await this.sdk._fetch(
73
+ '/internal/programmableVoice/setVariable',
74
+ 'POST',
75
+ params,
76
+ );
65
77
  return result;
66
78
  }
67
79
 
@@ -87,7 +99,11 @@ export class InternalProgrammableVoiceService {
87
99
  },
88
100
  };
89
101
 
90
- const result = await this.sdk._fetch('/internal/programmableVoice/getVariable', 'POST', params);
102
+ const result = await this.sdk._fetch(
103
+ '/internal/programmableVoice/getVariable',
104
+ 'POST',
105
+ params,
106
+ );
91
107
  return result;
92
108
  }
93
109
 
@@ -101,7 +117,7 @@ export class InternalProgrammableVoiceService {
101
117
  loopCount,
102
118
  engagementSessionId,
103
119
  voiceChannelId,
104
- serverId
120
+ serverId,
105
121
  }) {
106
122
  this.sdk.validateParams(
107
123
  { meetingId },
@@ -126,7 +142,8 @@ export class InternalProgrammableVoiceService {
126
142
  if (callerIdNumber) meetingData.callerIdNumber = callerIdNumber;
127
143
  if (channelId) meetingData.channelId = channelId;
128
144
  if (loopCount) meetingData.loopCount = loopCount;
129
- if (engagementSessionId) meetingData.engagementSessionId = engagementSessionId;
145
+ if (engagementSessionId)
146
+ meetingData.engagementSessionId = engagementSessionId;
130
147
  if (voiceChannelId) meetingData.voiceChannelId = voiceChannelId;
131
148
  if (serverId) meetingData.serverId = serverId;
132
149
 
@@ -134,7 +151,11 @@ export class InternalProgrammableVoiceService {
134
151
  body: meetingData,
135
152
  };
136
153
 
137
- const result = await this.sdk._fetch('/internal/programmableVoice/joinMeetingRoom', 'POST', params);
154
+ const result = await this.sdk._fetch(
155
+ '/internal/programmableVoice/joinMeetingRoom',
156
+ 'POST',
157
+ params,
158
+ );
138
159
  return result;
139
160
  }
140
161
 
@@ -151,7 +172,11 @@ export class InternalProgrammableVoiceService {
151
172
  body: sessionData,
152
173
  };
153
174
 
154
- const result = await this.sdk._fetch(`/internal/programmableVoice/${location}`, 'POST', params);
175
+ const result = await this.sdk._fetch(
176
+ `/internal/programmableVoice/${location}`,
177
+ 'POST',
178
+ params,
179
+ );
155
180
  return result;
156
181
  }
157
182
  }
@@ -223,7 +248,11 @@ export class VoiceChannelService {
223
248
  },
224
249
  };
225
250
 
226
- const result = await this.sdk._fetch('/internal/programmableVoice/voiceChannel', 'POST', params);
251
+ const result = await this.sdk._fetch(
252
+ '/internal/programmableVoice/voiceChannel',
253
+ 'POST',
254
+ params,
255
+ );
227
256
  return result;
228
257
  }
229
258
 
@@ -293,7 +322,11 @@ export class VoiceChannelService {
293
322
  },
294
323
  };
295
324
 
296
- const result = await this.sdk._fetch('/internal/programmableVoice/voiceChannel', 'PUT', params);
325
+ const result = await this.sdk._fetch(
326
+ '/internal/programmableVoice/voiceChannel',
327
+ 'PUT',
328
+ params,
329
+ );
297
330
  return result;
298
331
  }
299
332
  }
@@ -311,7 +344,7 @@ export class TranscriptionService {
311
344
  direction,
312
345
  role,
313
346
  userId,
314
- playbookId
347
+ playbookId,
315
348
  }) {
316
349
  this.sdk.validateParams(
317
350
  { voiceChannelId, engagementSessionId, accountId },
@@ -327,7 +360,11 @@ export class TranscriptionService {
327
360
  },
328
361
  );
329
362
 
330
- const transcriptionData = { voiceChannelId, engagementSessionId, accountId };
363
+ const transcriptionData = {
364
+ voiceChannelId,
365
+ engagementSessionId,
366
+ accountId,
367
+ };
331
368
  if (name) transcriptionData.name = name;
332
369
  if (direction) transcriptionData.direction = direction;
333
370
  if (role) transcriptionData.role = role;
@@ -338,7 +375,11 @@ export class TranscriptionService {
338
375
  body: transcriptionData,
339
376
  };
340
377
 
341
- const result = await this.sdk._fetch('/internal/programmableVoice/transcription/', 'POST', params);
378
+ const result = await this.sdk._fetch(
379
+ '/internal/programmableVoice/transcription/',
380
+ 'POST',
381
+ params,
382
+ );
342
383
  return result;
343
384
  }
344
385
 
@@ -355,7 +396,11 @@ export class TranscriptionService {
355
396
  body: completionData,
356
397
  };
357
398
 
358
- const result = await this.sdk._fetch(`/internal/programmableVoice/transcription/${id}`, 'PUT', params);
399
+ const result = await this.sdk._fetch(
400
+ `/internal/programmableVoice/transcription/${id}`,
401
+ 'PUT',
402
+ params,
403
+ );
359
404
  return result;
360
405
  }
361
406
 
@@ -372,7 +417,11 @@ export class TranscriptionService {
372
417
  body: messageData,
373
418
  };
374
419
 
375
- const result = await this.sdk._fetch(`/internal/programmableVoice/transcription/${id}`, 'POST', params);
420
+ const result = await this.sdk._fetch(
421
+ `/internal/programmableVoice/transcription/${id}`,
422
+ 'POST',
423
+ params,
424
+ );
376
425
  return result;
377
426
  }
378
- }
427
+ }
@@ -14,7 +14,7 @@ export class InternalServersService {
14
14
  podName,
15
15
  namespace,
16
16
  K8S_SERVICE_NAME,
17
- K8S_DEPLOYMENT_TYPE
17
+ K8S_DEPLOYMENT_TYPE,
18
18
  }) {
19
19
  this.sdk.validateParams(
20
20
  { type, region },
@@ -40,7 +40,8 @@ export class InternalServersService {
40
40
  if (podName) serverData.podName = podName;
41
41
  if (namespace) serverData.namespace = namespace;
42
42
  if (K8S_SERVICE_NAME) serverData.K8S_SERVICE_NAME = K8S_SERVICE_NAME;
43
- if (K8S_DEPLOYMENT_TYPE) serverData.K8S_DEPLOYMENT_TYPE = K8S_DEPLOYMENT_TYPE;
43
+ if (K8S_DEPLOYMENT_TYPE)
44
+ serverData.K8S_DEPLOYMENT_TYPE = K8S_DEPLOYMENT_TYPE;
44
45
 
45
46
  const params = {
46
47
  body: serverData,
@@ -63,9 +64,18 @@ export class InternalServersService {
63
64
 
64
65
  // Validate status if provided
65
66
  if (status) {
66
- const validStatuses = ['booting', 'ready', 'maintenance', 'error', 'stopped', 'stopping'];
67
+ const validStatuses = [
68
+ 'booting',
69
+ 'ready',
70
+ 'maintenance',
71
+ 'error',
72
+ 'stopped',
73
+ 'stopping',
74
+ ];
67
75
  if (!validStatuses.includes(status)) {
68
- throw new Error(`Invalid status. Must be one of: ${validStatuses.join(', ')}`);
76
+ throw new Error(
77
+ `Invalid status. Must be one of: ${validStatuses.join(', ')}`,
78
+ );
69
79
  }
70
80
  }
71
81
 
@@ -78,7 +88,11 @@ export class InternalServersService {
78
88
  body: updateData,
79
89
  };
80
90
 
81
- const result = await this.sdk._fetch(`/internal/servers/${id}`, 'PUT', params);
91
+ const result = await this.sdk._fetch(
92
+ `/internal/servers/${id}`,
93
+ 'PUT',
94
+ params,
95
+ );
82
96
  return result;
83
97
  }
84
98
 
@@ -102,7 +116,10 @@ export class InternalServersService {
102
116
  },
103
117
  );
104
118
 
105
- const result = await this.sdk._fetch(`/internal/servers/${id}/shutdownCheck`, 'GET');
119
+ const result = await this.sdk._fetch(
120
+ `/internal/servers/${id}/shutdownCheck`,
121
+ 'GET',
122
+ );
106
123
  return result;
107
124
  }
108
125
  }
@@ -124,7 +141,11 @@ export class AwsServersService {
124
141
  body: assignmentData,
125
142
  };
126
143
 
127
- const result = await this.sdk._fetch('/internal/servers/aws/assignElasticIp', 'POST', params);
144
+ const result = await this.sdk._fetch(
145
+ '/internal/servers/aws/assignElasticIp',
146
+ 'POST',
147
+ params,
148
+ );
128
149
  return result;
129
150
  }
130
- }
151
+ }
package/services/sip.js CHANGED
@@ -246,4 +246,4 @@ export class InternalSipService {
246
246
  );
247
247
  return result;
248
248
  }
249
- }
249
+ }
@@ -13,7 +13,7 @@ export class InternalSocketService {
13
13
  serverId,
14
14
  clientIp,
15
15
  clientOs,
16
- clientBrowser
16
+ clientBrowser,
17
17
  }) {
18
18
  this.sdk.validateParams(
19
19
  { socketId, accountCode, accountId, serverId },
@@ -43,7 +43,11 @@ export class InternalSocketService {
43
43
  body: connectionData,
44
44
  };
45
45
 
46
- const result = await this.sdk._fetch('/internal/socket/connection', 'POST', params);
46
+ const result = await this.sdk._fetch(
47
+ '/internal/socket/connection',
48
+ 'POST',
49
+ params,
50
+ );
47
51
  return result;
48
52
  }
49
53
 
@@ -69,7 +73,11 @@ export class InternalSocketService {
69
73
  body: updateData,
70
74
  };
71
75
 
72
- const result = await this.sdk._fetch(`/internal/socket/connection/${id}`, 'PUT', params);
76
+ const result = await this.sdk._fetch(
77
+ `/internal/socket/connection/${id}`,
78
+ 'PUT',
79
+ params,
80
+ );
73
81
  return result;
74
82
  }
75
83
 
@@ -81,7 +89,10 @@ export class InternalSocketService {
81
89
  },
82
90
  );
83
91
 
84
- const result = await this.sdk._fetch(`/internal/socket/connection/${id}`, 'DELETE');
92
+ const result = await this.sdk._fetch(
93
+ `/internal/socket/connection/${id}`,
94
+ 'DELETE',
95
+ );
85
96
  return result;
86
97
  }
87
98
 
@@ -97,7 +108,11 @@ export class InternalSocketService {
97
108
  body: { serverId },
98
109
  };
99
110
 
100
- const result = await this.sdk._fetch('/internal/socket/connection/byServerId', 'DELETE', params);
111
+ const result = await this.sdk._fetch(
112
+ '/internal/socket/connection/byServerId',
113
+ 'DELETE',
114
+ params,
115
+ );
101
116
  return result;
102
117
  }
103
- }
118
+ }