@arbidocs/sdk 0.5.160 → 0.5.162

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/dist/index.cjs CHANGED
@@ -5605,7 +5605,8 @@ async function diagnoseSetup(options) {
5605
5605
  const add = (check, status, message, hint) => checks.push({ check, status, message, ...hint ? { hint } : {} });
5606
5606
  let base;
5607
5607
  try {
5608
- base = new URL(options.url);
5608
+ const browser = globalThis;
5609
+ base = new URL(options.url, browser.window?.location.origin);
5609
5610
  if (!["http:", "https:"].includes(base.protocol) || base.username || base.password || base.search || base.hash)
5610
5611
  throw new Error("Invalid API URL");
5611
5612
  } catch {
@@ -9326,6 +9327,24 @@ async function getFileContent(auth, fileId) {
9326
9327
  path: `/v1/files/${fileId}/content`
9327
9328
  });
9328
9329
  }
9330
+ async function delegateCallKey(client$1, call, key) {
9331
+ try {
9332
+ const agents = await listAgents(client$1);
9333
+ const keys = {};
9334
+ for (const agent of agents) {
9335
+ if (agent.external_id?.startsWith("agt-") && agent.encryption_public_key)
9336
+ keys[agent.external_id] = await client.sealCallKey(key, agent.encryption_public_key);
9337
+ }
9338
+ if (!Object.keys(keys).length) return true;
9339
+ const result = await client$1.fetch.POST("/v1/calls/{call_ext_id}/delegate-keys", {
9340
+ params: { path: { call_ext_id: call.external_id } },
9341
+ body: { keys, link_version: call.link_version }
9342
+ });
9343
+ return result.response.ok;
9344
+ } catch {
9345
+ return false;
9346
+ }
9347
+ }
9329
9348
 
9330
9349
  // src/operations/sessions.ts
9331
9350
  var sessions_exports = {};
@@ -11803,6 +11822,7 @@ __export(calls_exports, {
11803
11822
  knockCall: () => knockCall,
11804
11823
  listCallInviteLinks: () => listCallInviteLinks,
11805
11824
  listCallRecordings: () => listCallRecordings,
11825
+ listCalls: () => listCalls,
11806
11826
  listQuestions: () => listQuestions,
11807
11827
  muteCallParticipant: () => muteCallParticipant,
11808
11828
  pollKnock: () => pollKnock,
@@ -12042,6 +12062,9 @@ var trackPath = (callExtId, recordingExtId, trackExtId) => ({
12042
12062
  function getCallsConfig(arbi) {
12043
12063
  return unwrapCall(arbi.fetch.GET("/v1/calls/config"), "Could not read the calls config");
12044
12064
  }
12065
+ function listCalls(arbi, query2 = {}) {
12066
+ return unwrapCall(arbi.fetch.GET("/v1/calls", { params: { query: query2 } }), "Could not list calls");
12067
+ }
12045
12068
  function createCall(arbi, body) {
12046
12069
  return unwrapCall(arbi.fetch.POST("/v1/calls", { body }), "Could not create the call");
12047
12070
  }
@@ -14354,12 +14377,14 @@ var Arbi = class {
14354
14377
  /**
14355
14378
  * Calls (LiveKit): one call system for thread, chat (DM / group), contacts and scheduled calls.
14356
14379
  * Each call has one random key K made in the creator's process; the server and the media server
14357
- * only ever hold it sealed to people (or in a link's fragment). `start`, `open`, `answer` and
14380
+ * hold it sealed to people (or in a link's fragment); personal agents may receive an explicit
14381
+ * sealed management grant. `start`, `open`, `answer` and
14358
14382
  * `resetLink` do the key work and hand back K with the call; everything else moves ciphertext.
14359
14383
  */
14360
14384
  calls = {
14361
14385
  /** The deployment's calls config (`enabled`, `transcription_available`, …). */
14362
14386
  config: () => getCallsConfig(this.requireClient()),
14387
+ list: (query2) => listCalls(this.requireClient(), query2),
14363
14388
  get: (callExtId) => getCall(this.requireClient(), callExtId),
14364
14389
  /** Create a call row as is (a scheduled call's ciphertext made by the caller). */
14365
14390
  create: (body) => createCall(this.requireClient(), body),
@@ -14398,6 +14423,7 @@ var Arbi = class {
14398
14423
  const key = reused ? await this.callKeyOf(call) : fresh;
14399
14424
  if (!key) throw new ArbiError("No key for the running call on this thread");
14400
14425
  const sealedKeys = reused ? await client.sealCallKeyForPeers(key, params.invitees, me2.userExtId) : sealed;
14426
+ await delegateCallKey(client$1, call, key);
14401
14427
  return {
14402
14428
  call,
14403
14429
  key,
@@ -14417,8 +14443,11 @@ var Arbi = class {
14417
14443
  if (!key) {
14418
14444
  throw new ArbiError("Open the full call link (it carries the key) to join this call.");
14419
14445
  }
14446
+ await delegateCallKey(this.requireClient(), call, key);
14420
14447
  return { call, key, title: await this.callTitleOf(call, key) };
14421
14448
  },
14449
+ /** Seal a key I already hold to my own personal agents; never a call invitation. */
14450
+ delegateToAgents: (call, key) => delegateCallKey(this.requireClient(), call, key),
14422
14451
  /** My copy of a call's K from its row, or null. */
14423
14452
  key: (call) => this.callKeyOf(call),
14424
14453
  /** A call's title in plaintext under K; null when it has none or it does not open. */
@@ -14449,6 +14478,7 @@ var Arbi = class {
14449
14478
  sealed_keys: await client.sealCallKeyForPeers(key, invitees, me2.userExtId),
14450
14479
  title: title ? await client.encryptCallTitle(title, key) : null
14451
14480
  });
14481
+ await delegateCallKey(this.requireClient(), updated, key);
14452
14482
  return { call: updated, key };
14453
14483
  },
14454
14484
  /**