@sayna-ai/node-sdk 0.0.12 → 0.0.14
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 +42 -7
- package/dist/errors.d.ts +18 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.cjs +811 -0
- package/dist/index.cjs.map +13 -0
- package/dist/index.js +17 -4
- package/dist/index.js.map +4 -4
- package/dist/sayna-client.d.ts +34 -25
- package/dist/sayna-client.d.ts.map +1 -1
- package/dist/types.d.ts +38 -11
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -138,7 +138,7 @@ Retrieves all configured SIP webhook hooks from the runtime cache.
|
|
|
138
138
|
```typescript
|
|
139
139
|
const response = await client.getSipHooks();
|
|
140
140
|
for (const hook of response.hooks) {
|
|
141
|
-
console.log(`Host: ${hook.host}, URL: ${hook.url}`);
|
|
141
|
+
console.log(`Host: ${hook.host}, URL: ${hook.url}, Auth ID: ${hook.auth_id}`);
|
|
142
142
|
}
|
|
143
143
|
```
|
|
144
144
|
|
|
@@ -152,10 +152,11 @@ Sets or updates SIP webhook hooks in the runtime cache. Hooks with matching host
|
|
|
152
152
|
|
|
153
153
|
Each `SipHook` object contains:
|
|
154
154
|
|
|
155
|
-
| field
|
|
156
|
-
|
|
|
157
|
-
| `host`
|
|
158
|
-
| `url`
|
|
155
|
+
| field | type | description |
|
|
156
|
+
| --------- | -------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
157
|
+
| `host` | `string` | SIP domain pattern (case-insensitive). |
|
|
158
|
+
| `url` | `string` | HTTPS URL to forward webhook events to. |
|
|
159
|
+
| `auth_id` | `string` | Tenant identifier for this hook. Required but may be empty for unauthenticated mode. Treat as opaque; pass unchanged. |
|
|
159
160
|
|
|
160
161
|
**Returns**: `Promise<SipHooksResponse>` - Object containing the merged list of all configured hooks.
|
|
161
162
|
|
|
@@ -163,14 +164,48 @@ Each `SipHook` object contains:
|
|
|
163
164
|
|
|
164
165
|
```typescript
|
|
165
166
|
const response = await client.setSipHooks([
|
|
166
|
-
{
|
|
167
|
-
|
|
167
|
+
{
|
|
168
|
+
host: "example.com",
|
|
169
|
+
url: "https://webhook.example.com/events",
|
|
170
|
+
auth_id: "tenant-123",
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
host: "another.com",
|
|
174
|
+
url: "https://webhook.another.com/events",
|
|
175
|
+
auth_id: "",
|
|
176
|
+
}, // Empty for unauthenticated mode
|
|
168
177
|
]);
|
|
169
178
|
console.log("Total hooks configured:", response.hooks.length);
|
|
170
179
|
```
|
|
171
180
|
|
|
172
181
|
---
|
|
173
182
|
|
|
183
|
+
### Room Ownership and Access
|
|
184
|
+
|
|
185
|
+
When authentication is enabled, the server enforces room-level access control:
|
|
186
|
+
|
|
187
|
+
- **Room names are clean**: The SDK does not rewrite or prefix room names. Pass room names as-is.
|
|
188
|
+
- **Room listings are scoped**: `getLiveKitRooms()` returns only rooms accessible to your authenticated context.
|
|
189
|
+
- **403 on token requests**: `getLiveKitToken()` returns a 403 error if the room exists but is owned by another tenant. Do not retry with a modified room name.
|
|
190
|
+
- **404 masks access denial**: For room-scoped operations (`getLiveKitRoom()`, `removeLiveKitParticipant()`, `muteLiveKitParticipantTrack()`, `sipTransferRest()`), a 404 response can mean "not found" or "not accessible."
|
|
191
|
+
- **Inbound SIP rooms**: Rooms created by inbound SIP calls are owned by the routing configuration's `auth_id`. Access depends on your authentication context.
|
|
192
|
+
- **WebSocket errors**: Ownership/access errors during WebSocket configuration are surfaced via the error callback. Retry with the correct room name if needed.
|
|
193
|
+
|
|
194
|
+
Errors include HTTP status and endpoint information for easier debugging:
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
try {
|
|
198
|
+
await client.getLiveKitToken("some-room", "user", "user-123");
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error instanceof SaynaServerError) {
|
|
201
|
+
console.log(`Status: ${error.status}, Endpoint: ${error.endpoint}`);
|
|
202
|
+
// Status: 403, Endpoint: livekit/token
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
174
209
|
### WebSocket API Methods
|
|
175
210
|
|
|
176
211
|
These methods require an active WebSocket connection:
|
package/dist/errors.d.ts
CHANGED
|
@@ -30,9 +30,25 @@ export declare class SaynaValidationError extends SaynaError {
|
|
|
30
30
|
constructor(message: string);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Error thrown when the server returns an error.
|
|
33
|
+
* Error thrown when the server returns an error response.
|
|
34
|
+
*
|
|
35
|
+
* For REST API calls, the `status` and `endpoint` fields provide context about
|
|
36
|
+
* which request failed and with what HTTP status code. Common status codes:
|
|
37
|
+
* - 403: Access denied (e.g., room owned by another tenant on /livekit/token)
|
|
38
|
+
* - 404: Not found or not accessible (masked access denial for room-scoped operations)
|
|
39
|
+
* - 500: Internal server error
|
|
34
40
|
*/
|
|
35
41
|
export declare class SaynaServerError extends SaynaError {
|
|
36
|
-
|
|
42
|
+
/**
|
|
43
|
+
* HTTP status code returned by the server, if available.
|
|
44
|
+
* Set for REST API errors; undefined for WebSocket errors.
|
|
45
|
+
*/
|
|
46
|
+
readonly status?: number;
|
|
47
|
+
/**
|
|
48
|
+
* API endpoint that returned the error, if available.
|
|
49
|
+
* Set for REST API errors; undefined for WebSocket errors.
|
|
50
|
+
*/
|
|
51
|
+
readonly endpoint?: string;
|
|
52
|
+
constructor(message: string, status?: number, endpoint?: string);
|
|
37
53
|
}
|
|
38
54
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM;CAK5B;AAED;;GAEG;AACH,qBAAa,sBAAu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