@decartai/sdk 0.0.62 → 0.0.63

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.
@@ -16,11 +16,6 @@ declare const realTimeClientInitialStateSchema: z.ZodObject<{
16
16
  image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Blob, Blob>, z.ZodCustom<File, File>, z.ZodString]>>;
17
17
  }, z.core.$strip>;
18
18
  type OnRemoteStreamFn = (stream: MediaStream) => void;
19
- type OnStatusFn = (status: string) => void;
20
- type OnQueuePositionFn = (data: {
21
- position: number;
22
- queueSize: number;
23
- }) => void;
24
19
  type RealTimeClientInitialState = z.infer<typeof realTimeClientInitialStateSchema>;
25
20
  declare const realTimeClientConnectOptionsSchema: z.ZodObject<{
26
21
  model: z.ZodObject<{
@@ -30,7 +25,7 @@ declare const realTimeClientConnectOptionsSchema: z.ZodObject<{
30
25
  fps: z.ZodNumber;
31
26
  width: z.ZodNumber;
32
27
  height: z.ZodNumber;
33
- inputSchema: z.ZodAny;
28
+ inputSchema: z.ZodOptional<z.ZodAny>;
34
29
  }, z.core.$strip>;
35
30
  onRemoteStream: z.ZodCustom<OnRemoteStreamFn, OnRemoteStreamFn>;
36
31
  initialState: z.ZodOptional<z.ZodObject<{
@@ -41,8 +36,6 @@ declare const realTimeClientConnectOptionsSchema: z.ZodObject<{
41
36
  image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Blob, Blob>, z.ZodCustom<File, File>, z.ZodString]>>;
42
37
  }, z.core.$strip>>;
43
38
  customizeOffer: z.ZodOptional<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>, z.core.$InferInnerFunctionTypeAsync<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>>;
44
- onStatus: z.ZodOptional<z.ZodCustom<OnStatusFn, OnStatusFn>>;
45
- onQueuePosition: z.ZodOptional<z.ZodCustom<OnQueuePositionFn, OnQueuePositionFn>>;
46
39
  }, z.core.$strip>;
47
40
  type RealTimeClientConnectOptions = Omit<z.infer<typeof realTimeClientConnectOptionsSchema>, "model"> & {
48
41
  model: ModelDefinition | CustomModelDefinition;
@@ -53,11 +46,6 @@ type Events = {
53
46
  generationTick: {
54
47
  seconds: number;
55
48
  };
56
- status: string;
57
- queuePosition: {
58
- position: number;
59
- queueSize: number;
60
- };
61
49
  diagnostic: DiagnosticEvent;
62
50
  stats: WebRTCStats;
63
51
  };
@@ -57,9 +57,7 @@ const realTimeClientConnectOptionsSchema = z.object({
57
57
  model: modelDefinitionSchema,
58
58
  onRemoteStream: z.custom((val) => typeof val === "function", { message: "onRemoteStream must be a function" }),
59
59
  initialState: realTimeClientInitialStateSchema.optional(),
60
- customizeOffer: createAsyncFunctionSchema(z.function()).optional(),
61
- onStatus: z.custom((val) => typeof val === "function", { message: "onStatus must be a function" }).optional(),
62
- onQueuePosition: z.custom((val) => typeof val === "function", { message: "onQueuePosition must be a function" }).optional()
60
+ customizeOffer: createAsyncFunctionSchema(z.function()).optional()
63
61
  });
64
62
  const createRealTimeClient = (opts) => {
65
63
  const { baseUrl, apiKey, integration, logger } = opts;
@@ -67,7 +65,7 @@ const createRealTimeClient = (opts) => {
67
65
  const parsedOptions = realTimeClientConnectOptionsSchema.safeParse(options);
68
66
  if (!parsedOptions.success) throw parsedOptions.error;
69
67
  const isAvatarLive = options.model.name === "live_avatar" || options.model.name === "live-avatar";
70
- const { onRemoteStream, initialState, onStatus, onQueuePosition } = parsedOptions.data;
68
+ const { onRemoteStream, initialState } = parsedOptions.data;
71
69
  let audioStreamManager;
72
70
  let inputStream;
73
71
  if (isAvatarLive && !stream) {
@@ -157,19 +155,6 @@ const createRealTimeClient = (opts) => {
157
155
  emitOrBuffer("generationTick", { seconds: msg.seconds });
158
156
  };
159
157
  manager.getWebsocketMessageEmitter().on("generationTick", tickListener);
160
- const wsEmitter = manager.getWebsocketMessageEmitter();
161
- wsEmitter.on("status", (msg) => {
162
- emitOrBuffer("status", msg.status);
163
- onStatus?.(msg.status);
164
- });
165
- wsEmitter.on("queuePosition", (msg) => {
166
- const data = {
167
- position: msg.position,
168
- queueSize: msg.queue_size
169
- };
170
- emitOrBuffer("queuePosition", data);
171
- onQueuePosition?.(data);
172
- });
173
158
  await manager.connect(inputStream);
174
159
  const methods = realtimeMethods(manager, imageToBase64);
175
160
  let statsCollector = null;
@@ -183,14 +183,6 @@ var WebRTCConnection = class {
183
183
  this.websocketMessagesEmitter.emit("sessionId", msg);
184
184
  return;
185
185
  }
186
- if (msg.type === "status") {
187
- this.websocketMessagesEmitter.emit("status", msg);
188
- return;
189
- }
190
- if (msg.type === "queue_position") {
191
- this.websocketMessagesEmitter.emit("queuePosition", msg);
192
- return;
193
- }
194
186
  if (!this.pc) return;
195
187
  switch (msg.type) {
196
188
  case "ready": {
@@ -172,7 +172,7 @@ const modelDefinitionSchema = z.object({
172
172
  fps: z.number().min(1),
173
173
  width: z.number().min(1),
174
174
  height: z.number().min(1),
175
- inputSchema: z.any()
175
+ inputSchema: z.any().optional()
176
176
  });
177
177
  const _models = {
178
178
  realtime: {
@@ -9,6 +9,13 @@ type CreateTokenOptions = {
9
9
  expiresIn?: number;
10
10
  /** Restrict which models this token can access (max 20 items). */
11
11
  allowedModels?: (Model | (string & {}))[];
12
+ /**
13
+ * Restrict which web origins this token can be used from (max 20 items).
14
+ * Each entry must be a full origin including scheme, e.g. `https://example.com`.
15
+ * Enforced on realtime sessions by matching the WebSocket `Origin` header
16
+ * verbatim. Defense-in-depth — only effective for browser-based clients.
17
+ */
18
+ allowedOrigins?: string[];
12
19
  /** Operational limits for the token. */
13
20
  constraints?: {
14
21
  realtime?: {
@@ -19,9 +26,10 @@ type CreateTokenOptions = {
19
26
  type CreateTokenResponse = {
20
27
  apiKey: string;
21
28
  expiresAt: string;
22
- /** Present when `allowedModels` was set on the request. */
29
+ /** Present when `allowedModels` and/or `allowedOrigins` were set on the request. */
23
30
  permissions?: {
24
- models: (Model | (string & {}))[];
31
+ models?: (Model | (string & {}))[];
32
+ origins?: string[];
25
33
  } | null;
26
34
  /** Present when `constraints` was set on the request. */
27
35
  constraints?: {
@@ -45,10 +53,11 @@ type TokensClient = {
45
53
  * // With metadata:
46
54
  * const token = await client.tokens.create({ metadata: { role: "viewer" } });
47
55
  *
48
- * // With expiry, model restrictions, and constraints:
56
+ * // With expiry, model restrictions, origin restrictions, and constraints:
49
57
  * const token = await client.tokens.create({
50
58
  * expiresIn: 300,
51
59
  * allowedModels: ["lucy-pro-v2v", "lucy-restyle-v2v"],
60
+ * allowedOrigins: ["https://example.com"],
52
61
  * constraints: { realtime: { maxSessionDuration: 120 } },
53
62
  * });
54
63
  * ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decartai/sdk",
3
- "version": "0.0.62",
3
+ "version": "0.0.63",
4
4
  "description": "Decart's JavaScript SDK",
5
5
  "type": "module",
6
6
  "license": "MIT",