@arbidocs/sdk 0.4.138 → 0.4.140

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.js CHANGED
@@ -8304,6 +8304,549 @@ function bytesToBase643(bytes) {
8304
8304
  return btoa(binary);
8305
8305
  }
8306
8306
 
8307
+ // src/operations/calendar.ts
8308
+ var calendar_exports = {};
8309
+ __export(calendar_exports, {
8310
+ ACCOUNT_VENDOR: () => ACCOUNT_VENDOR,
8311
+ PublicBookingError: () => PublicBookingError,
8312
+ addHolidayCalendar: () => addHolidayCalendar,
8313
+ bookPublicSlot: () => bookPublicSlot,
8314
+ cancelPublicBooking: () => cancelPublicBooking,
8315
+ connectCalDavAccount: () => connectCalDavAccount,
8316
+ connectOAuthAccount: () => connectOAuthAccount,
8317
+ createAppPassword: () => createAppPassword,
8318
+ createCalendar: () => createCalendar,
8319
+ createEvent: () => createEvent,
8320
+ createFeed: () => createFeed,
8321
+ createRoom: () => createRoom,
8322
+ decideCounter: () => decideCounter,
8323
+ deleteBookingPage: () => deleteBookingPage,
8324
+ deleteCalendar: () => deleteCalendar,
8325
+ deleteEvent: () => deleteEvent,
8326
+ disconnectAccount: () => disconnectAccount,
8327
+ ensureCalendarUnlocked: () => ensureCalendarUnlocked,
8328
+ eventIcs: () => eventIcs,
8329
+ exportCalendarIcs: () => exportCalendarIcs,
8330
+ findTime: () => findTime,
8331
+ getCalendarSettings: () => getCalendarSettings,
8332
+ getEvent: () => getEvent,
8333
+ getFreeBusy: () => getFreeBusy,
8334
+ getPublicBookingPage: () => getPublicBookingPage,
8335
+ importCalendarIcs: () => importCalendarIcs,
8336
+ listAccounts: () => listAccounts,
8337
+ listAppPasswords: () => listAppPasswords,
8338
+ listBookingPages: () => listBookingPages,
8339
+ listCalDavProfiles: () => listCalDavProfiles,
8340
+ listCalendars: () => listCalendars,
8341
+ listEvents: () => listEvents,
8342
+ listHolidayCountries: () => listHolidayCountries,
8343
+ listInvitations: () => listInvitations,
8344
+ listOverlays: () => listOverlays,
8345
+ listRooms: () => listRooms,
8346
+ listShares: () => listShares,
8347
+ lookupEventByUid: () => lookupEventByUid,
8348
+ lookupPeopleKeys: () => lookupPeopleKeys,
8349
+ moveEvent: () => moveEvent,
8350
+ publishCalendarToAccount: () => publishCalendarToAccount,
8351
+ putBookingPage: () => putBookingPage,
8352
+ putCalendarSettings: () => putCalendarSettings,
8353
+ refreshCalendar: () => refreshCalendar,
8354
+ respondToEvent: () => respondToEvent,
8355
+ revokeAppPassword: () => revokeAppPassword,
8356
+ shareCalendar: () => shareCalendar,
8357
+ splitAppPasswords: () => splitAppPasswords,
8358
+ subscribeCalendar: () => subscribeCalendar,
8359
+ syncAccount: () => syncAccount,
8360
+ unlockCalendarKeys: () => unlockCalendarKeys,
8361
+ unshareCalendar: () => unshareCalendar,
8362
+ updateAccount: () => updateAccount,
8363
+ updateCalendar: () => updateCalendar,
8364
+ updateEvent: () => updateEvent
8365
+ });
8366
+ var ACCOUNT_VENDOR = {
8367
+ google: "google_calendar",
8368
+ microsoft: "microsoft"
8369
+ };
8370
+ function take(result, what) {
8371
+ if (result.error !== void 0 || !result.response.ok) {
8372
+ const status = result.response.status;
8373
+ throw new ArbiApiError(
8374
+ apiErrorDetail(result.error) ?? `${what} failed (${status})`,
8375
+ result.error,
8376
+ status
8377
+ );
8378
+ }
8379
+ return result.data;
8380
+ }
8381
+ async function unlockCalendarKeys(client, keys) {
8382
+ await initSodium();
8383
+ const keypair = encryptionKeypairFromSigningKey(keys.signingPrivateKey);
8384
+ try {
8385
+ const page = take(await client.fetch.GET("/v1/calendar/keys"), "Reading the calendar keys");
8386
+ const sealed = {};
8387
+ for (const [id, wrapped] of Object.entries(page?.keys ?? {})) {
8388
+ const key = sealedBoxDecrypt(wrapped, keypair.secretKey);
8389
+ try {
8390
+ sealed[id] = await sealKeyForSession(key, keys.serverSessionKey);
8391
+ } finally {
8392
+ key.fill(0);
8393
+ }
8394
+ }
8395
+ if (Object.keys(sealed).length)
8396
+ take(
8397
+ await client.fetch.POST("/v1/calendar/session-keys", { body: { keys: sealed } }),
8398
+ "Unlocking the calendar"
8399
+ );
8400
+ } finally {
8401
+ keypair.secretKey.fill(0);
8402
+ }
8403
+ }
8404
+ var unlockStates = /* @__PURE__ */ new WeakMap();
8405
+ function unlockState(keys) {
8406
+ let state = unlockStates.get(keys.serverSessionKey);
8407
+ if (!state) {
8408
+ state = { done: false, running: null, attemptedLocked: /* @__PURE__ */ new Set() };
8409
+ unlockStates.set(keys.serverSessionKey, state);
8410
+ }
8411
+ return state;
8412
+ }
8413
+ async function ensureCalendarUnlocked(client, keys, force = false) {
8414
+ if (!keys) return;
8415
+ const state = unlockState(keys);
8416
+ if (!force && state.done) return;
8417
+ state.running ??= unlockCalendarKeys(client, keys).then(() => {
8418
+ state.done = true;
8419
+ }).finally(() => {
8420
+ state.running = null;
8421
+ });
8422
+ try {
8423
+ await state.running;
8424
+ } catch (err) {
8425
+ console.warn("Calendar keys could not be unlocked", err);
8426
+ }
8427
+ }
8428
+ var calPath = (calId) => ({ params: { path: { cal_id: calId } } });
8429
+ var evtPath = (evtId) => ({ path: { evt_id: evtId } });
8430
+ async function getCalendarSettings(client) {
8431
+ return take(await client.fetch.GET("/v1/calendar/settings"), "Loading calendar settings");
8432
+ }
8433
+ async function putCalendarSettings(client, body) {
8434
+ return take(
8435
+ await client.fetch.PUT("/v1/calendar/settings", { body }),
8436
+ "Saving calendar settings"
8437
+ );
8438
+ }
8439
+ async function listCalendars(client, keys) {
8440
+ const read = async () => take(await client.fetch.GET("/v1/calendar/calendars"), "Loading calendars");
8441
+ const calendars = await read();
8442
+ if (!keys) return calendars;
8443
+ const state = unlockState(keys);
8444
+ const fresh = calendars.filter((c2) => c2.locked && !state.attemptedLocked.has(c2.id));
8445
+ if (!fresh.length) return calendars;
8446
+ for (const c2 of fresh) state.attemptedLocked.add(c2.id);
8447
+ await ensureCalendarUnlocked(client, keys, true);
8448
+ return read();
8449
+ }
8450
+ async function createCalendar(client, body) {
8451
+ return take(
8452
+ await client.fetch.POST("/v1/calendar/calendars", { body }),
8453
+ "Creating the calendar"
8454
+ );
8455
+ }
8456
+ async function updateCalendar(client, calId, body) {
8457
+ return take(
8458
+ await client.fetch.PATCH("/v1/calendar/calendars/{cal_id}", { ...calPath(calId), body }),
8459
+ "Saving the calendar"
8460
+ );
8461
+ }
8462
+ async function deleteCalendar(client, calId) {
8463
+ take(
8464
+ await client.fetch.DELETE("/v1/calendar/calendars/{cal_id}", calPath(calId)),
8465
+ "Deleting the calendar"
8466
+ );
8467
+ }
8468
+ async function exportCalendarIcs(client, calId) {
8469
+ return take(
8470
+ await client.fetch.GET("/v1/calendar/calendars/{cal_id}/export.ics", {
8471
+ ...calPath(calId),
8472
+ parseAs: "blob"
8473
+ }),
8474
+ "Exporting the calendar"
8475
+ );
8476
+ }
8477
+ async function importCalendarIcs(client, ics, calendarId) {
8478
+ return take(
8479
+ await client.fetch.POST("/v1/calendar/import", {
8480
+ body: { ics, calendar_id: calendarId ?? null }
8481
+ }),
8482
+ "Importing"
8483
+ );
8484
+ }
8485
+ async function listEvents(client, { start, end, calendars }) {
8486
+ return take(
8487
+ await client.fetch.GET("/v1/calendar/events", {
8488
+ params: {
8489
+ query: { start, end, calendars: calendars?.length ? calendars.join(",") : void 0 }
8490
+ }
8491
+ }),
8492
+ "Loading events"
8493
+ );
8494
+ }
8495
+ async function getEvent(client, evtId, recurrenceId) {
8496
+ return take(
8497
+ await client.fetch.GET("/v1/calendar/events/{evt_id}", {
8498
+ params: { ...evtPath(evtId), query: { recurrence_id: recurrenceId ?? void 0 } }
8499
+ }),
8500
+ "Loading the event"
8501
+ );
8502
+ }
8503
+ async function createEvent(client, body) {
8504
+ return take(
8505
+ await client.fetch.POST("/v1/calendar/events", { body }),
8506
+ "Saving the event"
8507
+ );
8508
+ }
8509
+ async function updateEvent(client, target, body) {
8510
+ return take(
8511
+ await client.fetch.PATCH("/v1/calendar/events/{evt_id}", {
8512
+ params: {
8513
+ ...evtPath(target.id),
8514
+ query: { scope: target.scope, recurrence_id: target.recurrence_id ?? void 0 }
8515
+ },
8516
+ body
8517
+ }),
8518
+ "Saving the event"
8519
+ );
8520
+ }
8521
+ async function deleteEvent(client, target) {
8522
+ take(
8523
+ await client.fetch.DELETE("/v1/calendar/events/{evt_id}", {
8524
+ params: {
8525
+ ...evtPath(target.id),
8526
+ query: {
8527
+ scope: target.scope,
8528
+ recurrence_id: target.recurrence_id ?? void 0,
8529
+ notify: target.notify
8530
+ }
8531
+ }
8532
+ }),
8533
+ "Deleting the event"
8534
+ );
8535
+ }
8536
+ async function moveEvent(client, evtId, calendarId) {
8537
+ return take(
8538
+ await client.fetch.POST("/v1/calendar/events/{evt_id}/move", {
8539
+ params: evtPath(evtId),
8540
+ body: { calendar_id: calendarId }
8541
+ }),
8542
+ "Moving the event"
8543
+ );
8544
+ }
8545
+ async function respondToEvent(client, { id, ...body }) {
8546
+ return take(
8547
+ await client.fetch.POST("/v1/calendar/events/{evt_id}/respond", {
8548
+ params: evtPath(id),
8549
+ body: { scope: "all", notify: true, ...body }
8550
+ }),
8551
+ "Sending your response"
8552
+ );
8553
+ }
8554
+ async function eventIcs(client, evtId) {
8555
+ return take(
8556
+ await client.fetch.GET("/v1/calendar/events/{evt_id}/ics", {
8557
+ params: evtPath(evtId),
8558
+ parseAs: "blob"
8559
+ }),
8560
+ "Downloading the event"
8561
+ );
8562
+ }
8563
+ async function lookupEventByUid(client, uid) {
8564
+ try {
8565
+ return take(
8566
+ await client.fetch.GET("/v1/calendar/lookup", { params: { query: { uid } } }),
8567
+ "Looking up the event"
8568
+ );
8569
+ } catch (err) {
8570
+ if (err instanceof ArbiApiError && err.status === 404) return null;
8571
+ throw err;
8572
+ }
8573
+ }
8574
+ async function listOverlays(client, range, layers) {
8575
+ return take(
8576
+ await client.fetch.GET("/v1/calendar/overlays", {
8577
+ params: { query: { start: range.start, end: range.end, layers: layers.join(",") } }
8578
+ }),
8579
+ "Loading the overlays"
8580
+ );
8581
+ }
8582
+ async function listShares(client, calId) {
8583
+ return take(
8584
+ await client.fetch.GET("/v1/calendar/calendars/{cal_id}/shares", calPath(calId)),
8585
+ "Loading the shares"
8586
+ );
8587
+ }
8588
+ async function shareCalendar(client, calId, grantee, role) {
8589
+ return take(
8590
+ await client.fetch.PUT("/v1/calendar/calendars/{cal_id}/shares/{grantee}", {
8591
+ params: { path: { cal_id: calId, grantee } },
8592
+ body: { role }
8593
+ }),
8594
+ "Sharing the calendar"
8595
+ );
8596
+ }
8597
+ async function unshareCalendar(client, calId, grantee) {
8598
+ take(
8599
+ await client.fetch.DELETE("/v1/calendar/calendars/{cal_id}/shares/{grantee}", {
8600
+ params: { path: { cal_id: calId, grantee } }
8601
+ }),
8602
+ "Removing the share"
8603
+ );
8604
+ }
8605
+ async function subscribeCalendar(client, body) {
8606
+ return take(
8607
+ await client.fetch.POST("/v1/calendar/subscriptions", {
8608
+ body
8609
+ }),
8610
+ "Subscribing"
8611
+ );
8612
+ }
8613
+ async function refreshCalendar(client, calId) {
8614
+ return take(
8615
+ await client.fetch.POST("/v1/calendar/calendars/{cal_id}/refresh", calPath(calId)),
8616
+ "Refreshing the calendar"
8617
+ );
8618
+ }
8619
+ async function listHolidayCountries(client) {
8620
+ return take(
8621
+ await client.fetch.GET("/v1/calendar/holidays/countries"),
8622
+ "Loading holiday countries"
8623
+ );
8624
+ }
8625
+ async function addHolidayCalendar(client, body) {
8626
+ return take(
8627
+ await client.fetch.POST("/v1/calendar/holidays", {
8628
+ body
8629
+ }),
8630
+ "Adding holidays"
8631
+ );
8632
+ }
8633
+ async function createRoom(client, body) {
8634
+ return take(
8635
+ await client.fetch.POST("/v1/calendar/rooms", { body }),
8636
+ "Adding the room"
8637
+ );
8638
+ }
8639
+ async function listRooms(client, q2 = {}) {
8640
+ return take(
8641
+ await client.fetch.GET("/v1/calendar/rooms", {
8642
+ params: {
8643
+ query: {
8644
+ start: q2.start,
8645
+ end: q2.end,
8646
+ min_capacity: q2.min_capacity || void 0,
8647
+ feature: q2.feature?.length ? q2.feature : void 0,
8648
+ building: q2.building || void 0
8649
+ }
8650
+ }
8651
+ }),
8652
+ "Loading rooms"
8653
+ );
8654
+ }
8655
+ async function getFreeBusy(client, body) {
8656
+ return take(await client.fetch.POST("/v1/calendar/freebusy", { body }), "Loading free/busy");
8657
+ }
8658
+ async function findTime(client, body) {
8659
+ return take(
8660
+ await client.fetch.POST("/v1/calendar/find-time", {
8661
+ body
8662
+ }),
8663
+ "Finding a time"
8664
+ );
8665
+ }
8666
+ async function listInvitations(client) {
8667
+ return take(await client.fetch.GET("/v1/calendar/invitations"), "Loading invitations");
8668
+ }
8669
+ async function decideCounter(client, itpId, accept, comment) {
8670
+ return take(
8671
+ await client.fetch.POST("/v1/calendar/invitations/{itp_id}/decide", {
8672
+ params: { path: { itp_id: itpId } },
8673
+ body: { accept, comment: comment ?? null }
8674
+ }),
8675
+ "Answering the proposal"
8676
+ );
8677
+ }
8678
+ async function lookupPeopleKeys(client, body) {
8679
+ return take(
8680
+ await client.fetch.POST("/v1/calendar/people/keys", {
8681
+ body
8682
+ }),
8683
+ "Looking up people"
8684
+ );
8685
+ }
8686
+ var accPath = (accId) => ({ params: { path: { acc_id: accId } } });
8687
+ async function listAccounts(client) {
8688
+ return take(await client.fetch.GET("/v1/calendar/accounts"), "Loading calendar accounts");
8689
+ }
8690
+ async function listCalDavProfiles(client) {
8691
+ return take(await client.fetch.GET("/v1/calendar/caldav/profiles"), "Loading CalDAV servers");
8692
+ }
8693
+ async function connectOAuthAccount(client, kind, backgroundSync = false) {
8694
+ return take(
8695
+ await client.fetch.POST("/v1/calendar/accounts/{kind}", {
8696
+ params: { path: { kind } },
8697
+ body: { background_sync: backgroundSync }
8698
+ }),
8699
+ "Connecting the account"
8700
+ );
8701
+ }
8702
+ async function connectCalDavAccount(client, body) {
8703
+ return take(
8704
+ await client.fetch.POST("/v1/calendar/accounts", {
8705
+ body: {
8706
+ profile_id: body.profile_id || null,
8707
+ url: body.url?.trim() || null,
8708
+ username: body.username.trim(),
8709
+ password: body.password,
8710
+ background_sync: !!body.background_sync
8711
+ }
8712
+ }),
8713
+ "Connecting the account"
8714
+ );
8715
+ }
8716
+ async function updateAccount(client, accId, backgroundSync) {
8717
+ return take(
8718
+ await client.fetch.PATCH("/v1/calendar/accounts/{acc_id}", {
8719
+ ...accPath(accId),
8720
+ body: { background_sync: backgroundSync }
8721
+ }),
8722
+ "Saving the account"
8723
+ );
8724
+ }
8725
+ async function syncAccount(client, accId) {
8726
+ return take(
8727
+ await client.fetch.POST("/v1/calendar/accounts/{acc_id}/sync", accPath(accId)),
8728
+ "Syncing the account"
8729
+ );
8730
+ }
8731
+ async function disconnectAccount(client, accId) {
8732
+ take(
8733
+ await client.fetch.DELETE("/v1/calendar/accounts/{acc_id}", accPath(accId)),
8734
+ "Disconnecting the account"
8735
+ );
8736
+ }
8737
+ async function publishCalendarToAccount(client, accId, calendarId) {
8738
+ return take(
8739
+ await client.fetch.POST("/v1/calendar/accounts/{acc_id}/publish", {
8740
+ params: { path: { acc_id: accId }, query: { calendar_id: calendarId } }
8741
+ }),
8742
+ "Publishing the calendar"
8743
+ );
8744
+ }
8745
+ async function listAppPasswords(client) {
8746
+ return take(await client.fetch.GET("/v1/calendar/app-passwords"), "Loading app passwords");
8747
+ }
8748
+ async function createAppPassword(client, body) {
8749
+ return take(
8750
+ await client.fetch.POST("/v1/calendar/app-passwords", {
8751
+ body: {
8752
+ label: body.label.trim(),
8753
+ calendar_ids: body.calendar_ids?.length ? body.calendar_ids : null
8754
+ }
8755
+ }),
8756
+ "Creating the app password"
8757
+ );
8758
+ }
8759
+ async function createFeed(client, body) {
8760
+ return take(
8761
+ await client.fetch.POST("/v1/calendar/feeds", {
8762
+ body: {
8763
+ calendar_id: body.calendar_id,
8764
+ level: body.level,
8765
+ label: body.label?.trim() || (body.level === "full" ? "Feed" : "Free/busy feed")
8766
+ }
8767
+ }),
8768
+ "Creating the feed"
8769
+ );
8770
+ }
8771
+ async function revokeAppPassword(client, apwId) {
8772
+ take(
8773
+ await client.fetch.DELETE("/v1/calendar/app-passwords/{apw_id}", {
8774
+ params: { path: { apw_id: apwId } }
8775
+ }),
8776
+ "Revoking"
8777
+ );
8778
+ }
8779
+ function splitAppPasswords(rows) {
8780
+ return {
8781
+ devices: rows.filter((r2) => r2.kind === "dav"),
8782
+ feeds: rows.filter((r2) => r2.kind === "feed" || r2.kind === "freebusy")
8783
+ };
8784
+ }
8785
+ async function listBookingPages(client) {
8786
+ return take(await client.fetch.GET("/v1/calendar/booking-pages"), "Loading booking pages");
8787
+ }
8788
+ async function putBookingPage(client, body) {
8789
+ return take(
8790
+ await client.fetch.PUT("/v1/calendar/booking-pages/{slug}", {
8791
+ params: { path: { slug: body.slug } },
8792
+ body
8793
+ }),
8794
+ "Saving the booking page"
8795
+ );
8796
+ }
8797
+ async function deleteBookingPage(client, slug) {
8798
+ take(
8799
+ await client.fetch.DELETE("/v1/calendar/booking-pages/{slug}", {
8800
+ params: { path: { slug } }
8801
+ }),
8802
+ "Deleting the booking page"
8803
+ );
8804
+ }
8805
+ var PublicBookingError = class extends Error {
8806
+ constructor(message, status) {
8807
+ super(message);
8808
+ this.status = status;
8809
+ this.name = "PublicBookingError";
8810
+ }
8811
+ status;
8812
+ };
8813
+ async function bookingError(res) {
8814
+ const body = await res.json().catch(() => null);
8815
+ return new PublicBookingError(
8816
+ apiErrorDetail(body) ?? `Request failed (${res.status})`,
8817
+ res.status
8818
+ );
8819
+ }
8820
+ var bookPath = (baseUrl, slug) => `${baseUrl}/v1/calendar/book/${encodeURIComponent(slug)}`;
8821
+ async function getPublicBookingPage(baseUrl, slug, opts = {}, signal) {
8822
+ const q2 = new URLSearchParams();
8823
+ if (opts.duration) q2.set("duration", String(opts.duration));
8824
+ if (opts.start) q2.set("start", opts.start);
8825
+ if (opts.days) q2.set("days", String(opts.days));
8826
+ const qs = q2.toString();
8827
+ const res = await fetch(`${bookPath(baseUrl, slug)}${qs ? `?${qs}` : ""}`, {
8828
+ headers: { Accept: "application/json" },
8829
+ signal
8830
+ });
8831
+ if (!res.ok) throw await bookingError(res);
8832
+ return await res.json();
8833
+ }
8834
+ async function bookPublicSlot(baseUrl, slug, body) {
8835
+ const res = await fetch(bookPath(baseUrl, slug), {
8836
+ method: "POST",
8837
+ headers: { "Content-Type": "application/json", Accept: "application/json" },
8838
+ body: JSON.stringify({ ...body, note: body.note?.trim() || null })
8839
+ });
8840
+ if (!res.ok) throw await bookingError(res);
8841
+ return await res.json();
8842
+ }
8843
+ async function cancelPublicBooking(baseUrl, slug, token) {
8844
+ const res = await fetch(`${bookPath(baseUrl, slug)}/cancel?token=${encodeURIComponent(token)}`, {
8845
+ method: "POST"
8846
+ });
8847
+ if (!res.ok) throw await bookingError(res);
8848
+ }
8849
+
8307
8850
  // src/arbi.ts
8308
8851
  function tokenExpiresWithin(token, seconds) {
8309
8852
  const payload = token?.split(".")[1];
@@ -8941,11 +9484,13 @@ var Arbi = class {
8941
9484
  assistantMode
8942
9485
  )
8943
9486
  };
8944
- /** Persisted notifications also arrive on the normal workspace WebSocket. */
9487
+ /** Persisted notifications (both the ones you received and the ones you sent), newest first;
9488
+ * new ones also arrive on the normal workspace WebSocket. */
8945
9489
  notifications = {
8946
- list: async (type) => {
9490
+ list: async (options = {}) => {
9491
+ const { type, limit = 100, offset } = options;
8947
9492
  const { data, error } = await this.requireClient().fetch.GET("/v1/notifications/", {
8948
- params: { query: { ...type ? { type } : {}, limit: 100 } }
9493
+ params: { query: { ...type ? { type } : {}, limit, ...offset ? { offset } : {} } }
8949
9494
  });
8950
9495
  if (error) throw new ArbiError("Could not load notifications");
8951
9496
  return data || [];
@@ -8956,6 +9501,11 @@ var Arbi = class {
8956
9501
  body: { updates: ids.map((external_id) => ({ external_id, read: true })) }
8957
9502
  });
8958
9503
  if (error) throw new ArbiError("Could not mark notifications read");
9504
+ },
9505
+ /** Delete notifications for yourself (sender or recipient). */
9506
+ delete: async (ids) => {
9507
+ if (!ids.length) return;
9508
+ await deleteNotifications(this.requireClient(), ids);
8959
9509
  }
8960
9510
  };
8961
9511
  /** Authenticated native Word transport, with normal session recovery. */
@@ -9113,15 +9663,96 @@ var Arbi = class {
9113
9663
  generate: (tagIds, docIds) => generateDocTags(this.requireClient(), tagIds, docIds)
9114
9664
  };
9115
9665
  // ── Contacts ──────────────────────────────────────────────────────────
9666
+ // A card is sealed under its address book's key, which the calendar key bridge carries: without
9667
+ // it the server returns `card: null` and refuses card writes.
9116
9668
  contacts = {
9117
- list: () => listContacts(this.requireClient()),
9669
+ list: () => this.withCalendarKeys((c2) => listContacts(c2)),
9118
9670
  invite: (emails) => inviteContacts(this.requireClient(), emails),
9119
- create: (body) => createContact(this.requireClient(), body),
9120
- update: (contactId, card) => updateContact(this.requireClient(), contactId, card),
9121
- delete: (contactId) => deleteContact(this.requireClient(), contactId),
9122
- search: (q2) => searchContacts(this.requireClient(), q2),
9671
+ create: (body) => this.withCalendarKeys((c2) => createContact(c2, body)),
9672
+ update: (contactId, card) => this.withCalendarKeys((c2) => updateContact(c2, contactId, card)),
9673
+ delete: (contactId) => this.withCalendarKeys((c2) => deleteContact(c2, contactId)),
9674
+ search: (q2) => this.withCalendarKeys((c2) => searchContacts(c2, q2)),
9123
9675
  groupByStatus: groupContactsByStatus
9124
9676
  };
9677
+ // ── Calendar ──────────────────────────────────────────────────────────
9678
+ /** The keys the calendar unlock needs; `null` before login (calendars then read as locked). */
9679
+ calendarKeys() {
9680
+ const login = this.loginResult;
9681
+ return login ? { signingPrivateKey: login.signingPrivateKey, serverSessionKey: login.serverSessionKey } : null;
9682
+ }
9683
+ /** Run `op` once this server session holds the calendar keys (unlocked once per session). */
9684
+ async withCalendarKeys(op) {
9685
+ const client = this.requireClient();
9686
+ await ensureCalendarUnlocked(client, this.calendarKeys());
9687
+ return op(client);
9688
+ }
9689
+ /**
9690
+ * The native calendar (`/v1/calendar`). Every content call first bridges the user's calendar
9691
+ * keys to the server session (once per session; see `calendarOps.ensureCalendarUnlocked`).
9692
+ */
9693
+ calendar = {
9694
+ /** Bridge the calendar keys now; `force` again (keys that arrived since: a share, an invite). */
9695
+ unlock: (force = false) => ensureCalendarUnlocked(this.requireClient(), this.calendarKeys(), force),
9696
+ getSettings: () => this.withCalendarKeys((c2) => getCalendarSettings(c2)),
9697
+ putSettings: (body) => this.withCalendarKeys((c2) => putCalendarSettings(c2, body)),
9698
+ listCalendars: () => this.withCalendarKeys((c2) => listCalendars(c2, this.calendarKeys())),
9699
+ createCalendar: (body) => this.withCalendarKeys((c2) => createCalendar(c2, body)),
9700
+ updateCalendar: (calId, body) => this.withCalendarKeys((c2) => updateCalendar(c2, calId, body)),
9701
+ deleteCalendar: (calId) => this.withCalendarKeys((c2) => deleteCalendar(c2, calId)),
9702
+ exportCalendar: (calId) => this.withCalendarKeys((c2) => exportCalendarIcs(c2, calId)),
9703
+ importIcs: (ics, calendarId) => this.withCalendarKeys((c2) => importCalendarIcs(c2, ics, calendarId)),
9704
+ listEvents: (params) => this.withCalendarKeys((c2) => listEvents(c2, params)),
9705
+ getEvent: (evtId, recurrenceId) => this.withCalendarKeys((c2) => getEvent(c2, evtId, recurrenceId)),
9706
+ createEvent: (body) => this.withCalendarKeys((c2) => createEvent(c2, body)),
9707
+ updateEvent: (target, body) => this.withCalendarKeys((c2) => updateEvent(c2, target, body)),
9708
+ deleteEvent: (target) => this.withCalendarKeys((c2) => deleteEvent(c2, target)),
9709
+ moveEvent: (evtId, calendarId) => this.withCalendarKeys((c2) => moveEvent(c2, evtId, calendarId)),
9710
+ respond: (params) => this.withCalendarKeys((c2) => respondToEvent(c2, params)),
9711
+ eventIcs: (evtId) => this.withCalendarKeys((c2) => eventIcs(c2, evtId)),
9712
+ lookupByUid: (uid) => this.withCalendarKeys((c2) => lookupEventByUid(c2, uid)),
9713
+ /** The open workspace's overlay layers (not sealed: no unlock). */
9714
+ listOverlays: (range, layers) => listOverlays(this.requireClient(), range, layers),
9715
+ listShares: (calId) => this.withCalendarKeys((c2) => listShares(c2, calId)),
9716
+ share: (calId, grantee, role) => this.withCalendarKeys((c2) => shareCalendar(c2, calId, grantee, role)),
9717
+ /** Remove a grantee; the key it rotates is bridged again. */
9718
+ unshare: async (calId, grantee) => {
9719
+ await this.withCalendarKeys((c2) => unshareCalendar(c2, calId, grantee));
9720
+ await this.calendar.unlock(true);
9721
+ },
9722
+ subscribe: (body) => this.withCalendarKeys((c2) => subscribeCalendar(c2, body)),
9723
+ refresh: (calId) => this.withCalendarKeys((c2) => refreshCalendar(c2, calId)),
9724
+ listHolidayCountries: () => this.withCalendarKeys((c2) => listHolidayCountries(c2)),
9725
+ addHolidays: (body) => this.withCalendarKeys((c2) => addHolidayCalendar(c2, body)),
9726
+ createRoom: (body) => this.withCalendarKeys((c2) => createRoom(c2, body)),
9727
+ listRooms: (query) => this.withCalendarKeys((c2) => listRooms(c2, query)),
9728
+ freeBusy: (body) => this.withCalendarKeys((c2) => getFreeBusy(c2, body)),
9729
+ findTime: (body) => this.withCalendarKeys((c2) => findTime(c2, body)),
9730
+ /**
9731
+ * Invitations and proposals waiting for me. A new one arrives with its own key: bridge again
9732
+ * first, or an open tab would not see it until it reloaded.
9733
+ */
9734
+ listInvitations: async () => {
9735
+ await this.calendar.unlock(true);
9736
+ return listInvitations(this.requireClient());
9737
+ },
9738
+ decideCounter: (itpId, accept, comment) => this.withCalendarKeys((c2) => decideCounter(c2, itpId, accept, comment)),
9739
+ peopleKeys: (body) => this.withCalendarKeys((c2) => lookupPeopleKeys(c2, body)),
9740
+ listAccounts: () => this.withCalendarKeys((c2) => listAccounts(c2)),
9741
+ listCalDavProfiles: () => this.withCalendarKeys((c2) => listCalDavProfiles(c2)),
9742
+ connectOAuthAccount: (kind, backgroundSync = false) => this.withCalendarKeys((c2) => connectOAuthAccount(c2, kind, backgroundSync)),
9743
+ connectCalDavAccount: (body) => this.withCalendarKeys((c2) => connectCalDavAccount(c2, body)),
9744
+ updateAccount: (accId, backgroundSync) => this.withCalendarKeys((c2) => updateAccount(c2, accId, backgroundSync)),
9745
+ syncAccount: (accId) => this.withCalendarKeys((c2) => syncAccount(c2, accId)),
9746
+ disconnectAccount: (accId) => this.withCalendarKeys((c2) => disconnectAccount(c2, accId)),
9747
+ publishToAccount: (accId, calendarId) => this.withCalendarKeys((c2) => publishCalendarToAccount(c2, accId, calendarId)),
9748
+ listAppPasswords: () => this.withCalendarKeys((c2) => listAppPasswords(c2)),
9749
+ createAppPassword: (body) => this.withCalendarKeys((c2) => createAppPassword(c2, body)),
9750
+ createFeed: (body) => this.withCalendarKeys((c2) => createFeed(c2, body)),
9751
+ revokeAppPassword: (apwId) => this.withCalendarKeys((c2) => revokeAppPassword(c2, apwId)),
9752
+ listBookingPages: () => this.withCalendarKeys((c2) => listBookingPages(c2)),
9753
+ putBookingPage: (body) => this.withCalendarKeys((c2) => putBookingPage(c2, body)),
9754
+ deleteBookingPage: (slug) => this.withCalendarKeys((c2) => deleteBookingPage(c2, slug))
9755
+ };
9125
9756
  // ── Chats (direct + group) ────────────────────────────────────────────
9126
9757
  /**
9127
9758
  * Build (and cache) the chat crypto context for the current session: my X25519 keypair
@@ -10447,6 +11078,6 @@ async function startDmListener(options) {
10447
11078
  };
10448
11079
  }
10449
11080
 
10450
- export { Arbi, ArbiApiError, ArbiError, ArbiSessionExpiredError, ClaudeOrchestrator, DEFAULT_AI_USD_PER_GBP, DOC_TERMINAL_STATUSES, FLAT_TAG_KINDS, FileConfigStore, OpenClawOrchestrator, PlanStepsError, STEP_FIELD_OPTION_TONES, TAG_KINDS, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, agents_exports as agents, assistant_exports as assistant, authenticatedFetch, buildCitationChunkData, buildDocNameMap, buildFactsContextTool, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, chats_exports as chats, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, createDocumentWaiter, device_flow_exports as deviceFlow, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, facts_exports as facts, files_exports as files, filterSkills, firm_exports as firm, formatAgentStepLabel, formatFileSize, formatGbp, formatGbpPerMillionTokens, formatItemLabel, formatStreamSummary, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, generateNewWorkspaceKey, getErrorCode, getErrorMessage, getRawWorkspaceKey, health_exports as health, identityErrorCode, identity_exports as identityVerification, listen_exports as listen, mail_exports as mail, mail_node_exports as mailNode, notifications_exports as notifications, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, performSigningKeyLogin, performSsoDeviceFlowLogin, profile_exports as profile, projects_exports as projects, requireData, requireOk, resolveAuth, resolveCitations, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, signature_requests_exports as signatureRequests, startDmListener, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, usdToGbp, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspaces_exports as workspaces };
11081
+ export { ACCOUNT_VENDOR, Arbi, ArbiApiError, ArbiError, ArbiSessionExpiredError, ClaudeOrchestrator, DEFAULT_AI_USD_PER_GBP, DOC_TERMINAL_STATUSES, FLAT_TAG_KINDS, FileConfigStore, OpenClawOrchestrator, PlanStepsError, PublicBookingError, STEP_FIELD_OPTION_TONES, TAG_KINDS, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, agents_exports as agents, assistant_exports as assistant, authenticatedFetch, bookPublicSlot, buildCitationChunkData, buildDocNameMap, buildFactsContextTool, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, calendar_exports as calendar, cancelPublicBooking, chats_exports as chats, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, createDocumentWaiter, device_flow_exports as deviceFlow, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, facts_exports as facts, files_exports as files, filterSkills, firm_exports as firm, formatAgentStepLabel, formatFileSize, formatGbp, formatGbpPerMillionTokens, formatItemLabel, formatStreamSummary, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, generateNewWorkspaceKey, getErrorCode, getErrorMessage, getPublicBookingPage, getRawWorkspaceKey, health_exports as health, identityErrorCode, identity_exports as identityVerification, listen_exports as listen, mail_exports as mail, mail_node_exports as mailNode, notifications_exports as notifications, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, performSigningKeyLogin, performSsoDeviceFlowLogin, profile_exports as profile, projects_exports as projects, requireData, requireOk, resolveAuth, resolveCitations, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, signature_requests_exports as signatureRequests, splitAppPasswords, startDmListener, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, usdToGbp, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspaces_exports as workspaces };
10451
11082
  //# sourceMappingURL=index.js.map
10452
11083
  //# sourceMappingURL=index.js.map