@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/browser.js CHANGED
@@ -7714,6 +7714,549 @@ function bytesToBase643(bytes) {
7714
7714
  return btoa(binary);
7715
7715
  }
7716
7716
 
7717
+ // src/operations/calendar.ts
7718
+ var calendar_exports = {};
7719
+ __export(calendar_exports, {
7720
+ ACCOUNT_VENDOR: () => ACCOUNT_VENDOR,
7721
+ PublicBookingError: () => PublicBookingError,
7722
+ addHolidayCalendar: () => addHolidayCalendar,
7723
+ bookPublicSlot: () => bookPublicSlot,
7724
+ cancelPublicBooking: () => cancelPublicBooking,
7725
+ connectCalDavAccount: () => connectCalDavAccount,
7726
+ connectOAuthAccount: () => connectOAuthAccount,
7727
+ createAppPassword: () => createAppPassword,
7728
+ createCalendar: () => createCalendar,
7729
+ createEvent: () => createEvent,
7730
+ createFeed: () => createFeed,
7731
+ createRoom: () => createRoom,
7732
+ decideCounter: () => decideCounter,
7733
+ deleteBookingPage: () => deleteBookingPage,
7734
+ deleteCalendar: () => deleteCalendar,
7735
+ deleteEvent: () => deleteEvent,
7736
+ disconnectAccount: () => disconnectAccount,
7737
+ ensureCalendarUnlocked: () => ensureCalendarUnlocked,
7738
+ eventIcs: () => eventIcs,
7739
+ exportCalendarIcs: () => exportCalendarIcs,
7740
+ findTime: () => findTime,
7741
+ getCalendarSettings: () => getCalendarSettings,
7742
+ getEvent: () => getEvent,
7743
+ getFreeBusy: () => getFreeBusy,
7744
+ getPublicBookingPage: () => getPublicBookingPage,
7745
+ importCalendarIcs: () => importCalendarIcs,
7746
+ listAccounts: () => listAccounts,
7747
+ listAppPasswords: () => listAppPasswords,
7748
+ listBookingPages: () => listBookingPages,
7749
+ listCalDavProfiles: () => listCalDavProfiles,
7750
+ listCalendars: () => listCalendars,
7751
+ listEvents: () => listEvents,
7752
+ listHolidayCountries: () => listHolidayCountries,
7753
+ listInvitations: () => listInvitations,
7754
+ listOverlays: () => listOverlays,
7755
+ listRooms: () => listRooms,
7756
+ listShares: () => listShares,
7757
+ lookupEventByUid: () => lookupEventByUid,
7758
+ lookupPeopleKeys: () => lookupPeopleKeys,
7759
+ moveEvent: () => moveEvent,
7760
+ publishCalendarToAccount: () => publishCalendarToAccount,
7761
+ putBookingPage: () => putBookingPage,
7762
+ putCalendarSettings: () => putCalendarSettings,
7763
+ refreshCalendar: () => refreshCalendar,
7764
+ respondToEvent: () => respondToEvent,
7765
+ revokeAppPassword: () => revokeAppPassword,
7766
+ shareCalendar: () => shareCalendar,
7767
+ splitAppPasswords: () => splitAppPasswords,
7768
+ subscribeCalendar: () => subscribeCalendar,
7769
+ syncAccount: () => syncAccount,
7770
+ unlockCalendarKeys: () => unlockCalendarKeys,
7771
+ unshareCalendar: () => unshareCalendar,
7772
+ updateAccount: () => updateAccount,
7773
+ updateCalendar: () => updateCalendar,
7774
+ updateEvent: () => updateEvent
7775
+ });
7776
+ var ACCOUNT_VENDOR = {
7777
+ google: "google_calendar",
7778
+ microsoft: "microsoft"
7779
+ };
7780
+ function take(result, what) {
7781
+ if (result.error !== void 0 || !result.response.ok) {
7782
+ const status = result.response.status;
7783
+ throw new ArbiApiError(
7784
+ apiErrorDetail(result.error) ?? `${what} failed (${status})`,
7785
+ result.error,
7786
+ status
7787
+ );
7788
+ }
7789
+ return result.data;
7790
+ }
7791
+ async function unlockCalendarKeys(client, keys) {
7792
+ await initSodium();
7793
+ const keypair = encryptionKeypairFromSigningKey(keys.signingPrivateKey);
7794
+ try {
7795
+ const page = take(await client.fetch.GET("/v1/calendar/keys"), "Reading the calendar keys");
7796
+ const sealed = {};
7797
+ for (const [id, wrapped] of Object.entries(page?.keys ?? {})) {
7798
+ const key = sealedBoxDecrypt(wrapped, keypair.secretKey);
7799
+ try {
7800
+ sealed[id] = await sealKeyForSession(key, keys.serverSessionKey);
7801
+ } finally {
7802
+ key.fill(0);
7803
+ }
7804
+ }
7805
+ if (Object.keys(sealed).length)
7806
+ take(
7807
+ await client.fetch.POST("/v1/calendar/session-keys", { body: { keys: sealed } }),
7808
+ "Unlocking the calendar"
7809
+ );
7810
+ } finally {
7811
+ keypair.secretKey.fill(0);
7812
+ }
7813
+ }
7814
+ var unlockStates = /* @__PURE__ */ new WeakMap();
7815
+ function unlockState(keys) {
7816
+ let state = unlockStates.get(keys.serverSessionKey);
7817
+ if (!state) {
7818
+ state = { done: false, running: null, attemptedLocked: /* @__PURE__ */ new Set() };
7819
+ unlockStates.set(keys.serverSessionKey, state);
7820
+ }
7821
+ return state;
7822
+ }
7823
+ async function ensureCalendarUnlocked(client, keys, force = false) {
7824
+ if (!keys) return;
7825
+ const state = unlockState(keys);
7826
+ if (!force && state.done) return;
7827
+ state.running ??= unlockCalendarKeys(client, keys).then(() => {
7828
+ state.done = true;
7829
+ }).finally(() => {
7830
+ state.running = null;
7831
+ });
7832
+ try {
7833
+ await state.running;
7834
+ } catch (err) {
7835
+ console.warn("Calendar keys could not be unlocked", err);
7836
+ }
7837
+ }
7838
+ var calPath = (calId) => ({ params: { path: { cal_id: calId } } });
7839
+ var evtPath = (evtId) => ({ path: { evt_id: evtId } });
7840
+ async function getCalendarSettings(client) {
7841
+ return take(await client.fetch.GET("/v1/calendar/settings"), "Loading calendar settings");
7842
+ }
7843
+ async function putCalendarSettings(client, body) {
7844
+ return take(
7845
+ await client.fetch.PUT("/v1/calendar/settings", { body }),
7846
+ "Saving calendar settings"
7847
+ );
7848
+ }
7849
+ async function listCalendars(client, keys) {
7850
+ const read = async () => take(await client.fetch.GET("/v1/calendar/calendars"), "Loading calendars");
7851
+ const calendars = await read();
7852
+ if (!keys) return calendars;
7853
+ const state = unlockState(keys);
7854
+ const fresh = calendars.filter((c2) => c2.locked && !state.attemptedLocked.has(c2.id));
7855
+ if (!fresh.length) return calendars;
7856
+ for (const c2 of fresh) state.attemptedLocked.add(c2.id);
7857
+ await ensureCalendarUnlocked(client, keys, true);
7858
+ return read();
7859
+ }
7860
+ async function createCalendar(client, body) {
7861
+ return take(
7862
+ await client.fetch.POST("/v1/calendar/calendars", { body }),
7863
+ "Creating the calendar"
7864
+ );
7865
+ }
7866
+ async function updateCalendar(client, calId, body) {
7867
+ return take(
7868
+ await client.fetch.PATCH("/v1/calendar/calendars/{cal_id}", { ...calPath(calId), body }),
7869
+ "Saving the calendar"
7870
+ );
7871
+ }
7872
+ async function deleteCalendar(client, calId) {
7873
+ take(
7874
+ await client.fetch.DELETE("/v1/calendar/calendars/{cal_id}", calPath(calId)),
7875
+ "Deleting the calendar"
7876
+ );
7877
+ }
7878
+ async function exportCalendarIcs(client, calId) {
7879
+ return take(
7880
+ await client.fetch.GET("/v1/calendar/calendars/{cal_id}/export.ics", {
7881
+ ...calPath(calId),
7882
+ parseAs: "blob"
7883
+ }),
7884
+ "Exporting the calendar"
7885
+ );
7886
+ }
7887
+ async function importCalendarIcs(client, ics, calendarId) {
7888
+ return take(
7889
+ await client.fetch.POST("/v1/calendar/import", {
7890
+ body: { ics, calendar_id: calendarId ?? null }
7891
+ }),
7892
+ "Importing"
7893
+ );
7894
+ }
7895
+ async function listEvents(client, { start, end, calendars }) {
7896
+ return take(
7897
+ await client.fetch.GET("/v1/calendar/events", {
7898
+ params: {
7899
+ query: { start, end, calendars: calendars?.length ? calendars.join(",") : void 0 }
7900
+ }
7901
+ }),
7902
+ "Loading events"
7903
+ );
7904
+ }
7905
+ async function getEvent(client, evtId, recurrenceId) {
7906
+ return take(
7907
+ await client.fetch.GET("/v1/calendar/events/{evt_id}", {
7908
+ params: { ...evtPath(evtId), query: { recurrence_id: recurrenceId ?? void 0 } }
7909
+ }),
7910
+ "Loading the event"
7911
+ );
7912
+ }
7913
+ async function createEvent(client, body) {
7914
+ return take(
7915
+ await client.fetch.POST("/v1/calendar/events", { body }),
7916
+ "Saving the event"
7917
+ );
7918
+ }
7919
+ async function updateEvent(client, target, body) {
7920
+ return take(
7921
+ await client.fetch.PATCH("/v1/calendar/events/{evt_id}", {
7922
+ params: {
7923
+ ...evtPath(target.id),
7924
+ query: { scope: target.scope, recurrence_id: target.recurrence_id ?? void 0 }
7925
+ },
7926
+ body
7927
+ }),
7928
+ "Saving the event"
7929
+ );
7930
+ }
7931
+ async function deleteEvent(client, target) {
7932
+ take(
7933
+ await client.fetch.DELETE("/v1/calendar/events/{evt_id}", {
7934
+ params: {
7935
+ ...evtPath(target.id),
7936
+ query: {
7937
+ scope: target.scope,
7938
+ recurrence_id: target.recurrence_id ?? void 0,
7939
+ notify: target.notify
7940
+ }
7941
+ }
7942
+ }),
7943
+ "Deleting the event"
7944
+ );
7945
+ }
7946
+ async function moveEvent(client, evtId, calendarId) {
7947
+ return take(
7948
+ await client.fetch.POST("/v1/calendar/events/{evt_id}/move", {
7949
+ params: evtPath(evtId),
7950
+ body: { calendar_id: calendarId }
7951
+ }),
7952
+ "Moving the event"
7953
+ );
7954
+ }
7955
+ async function respondToEvent(client, { id, ...body }) {
7956
+ return take(
7957
+ await client.fetch.POST("/v1/calendar/events/{evt_id}/respond", {
7958
+ params: evtPath(id),
7959
+ body: { scope: "all", notify: true, ...body }
7960
+ }),
7961
+ "Sending your response"
7962
+ );
7963
+ }
7964
+ async function eventIcs(client, evtId) {
7965
+ return take(
7966
+ await client.fetch.GET("/v1/calendar/events/{evt_id}/ics", {
7967
+ params: evtPath(evtId),
7968
+ parseAs: "blob"
7969
+ }),
7970
+ "Downloading the event"
7971
+ );
7972
+ }
7973
+ async function lookupEventByUid(client, uid) {
7974
+ try {
7975
+ return take(
7976
+ await client.fetch.GET("/v1/calendar/lookup", { params: { query: { uid } } }),
7977
+ "Looking up the event"
7978
+ );
7979
+ } catch (err) {
7980
+ if (err instanceof ArbiApiError && err.status === 404) return null;
7981
+ throw err;
7982
+ }
7983
+ }
7984
+ async function listOverlays(client, range, layers) {
7985
+ return take(
7986
+ await client.fetch.GET("/v1/calendar/overlays", {
7987
+ params: { query: { start: range.start, end: range.end, layers: layers.join(",") } }
7988
+ }),
7989
+ "Loading the overlays"
7990
+ );
7991
+ }
7992
+ async function listShares(client, calId) {
7993
+ return take(
7994
+ await client.fetch.GET("/v1/calendar/calendars/{cal_id}/shares", calPath(calId)),
7995
+ "Loading the shares"
7996
+ );
7997
+ }
7998
+ async function shareCalendar(client, calId, grantee, role) {
7999
+ return take(
8000
+ await client.fetch.PUT("/v1/calendar/calendars/{cal_id}/shares/{grantee}", {
8001
+ params: { path: { cal_id: calId, grantee } },
8002
+ body: { role }
8003
+ }),
8004
+ "Sharing the calendar"
8005
+ );
8006
+ }
8007
+ async function unshareCalendar(client, calId, grantee) {
8008
+ take(
8009
+ await client.fetch.DELETE("/v1/calendar/calendars/{cal_id}/shares/{grantee}", {
8010
+ params: { path: { cal_id: calId, grantee } }
8011
+ }),
8012
+ "Removing the share"
8013
+ );
8014
+ }
8015
+ async function subscribeCalendar(client, body) {
8016
+ return take(
8017
+ await client.fetch.POST("/v1/calendar/subscriptions", {
8018
+ body
8019
+ }),
8020
+ "Subscribing"
8021
+ );
8022
+ }
8023
+ async function refreshCalendar(client, calId) {
8024
+ return take(
8025
+ await client.fetch.POST("/v1/calendar/calendars/{cal_id}/refresh", calPath(calId)),
8026
+ "Refreshing the calendar"
8027
+ );
8028
+ }
8029
+ async function listHolidayCountries(client) {
8030
+ return take(
8031
+ await client.fetch.GET("/v1/calendar/holidays/countries"),
8032
+ "Loading holiday countries"
8033
+ );
8034
+ }
8035
+ async function addHolidayCalendar(client, body) {
8036
+ return take(
8037
+ await client.fetch.POST("/v1/calendar/holidays", {
8038
+ body
8039
+ }),
8040
+ "Adding holidays"
8041
+ );
8042
+ }
8043
+ async function createRoom(client, body) {
8044
+ return take(
8045
+ await client.fetch.POST("/v1/calendar/rooms", { body }),
8046
+ "Adding the room"
8047
+ );
8048
+ }
8049
+ async function listRooms(client, q2 = {}) {
8050
+ return take(
8051
+ await client.fetch.GET("/v1/calendar/rooms", {
8052
+ params: {
8053
+ query: {
8054
+ start: q2.start,
8055
+ end: q2.end,
8056
+ min_capacity: q2.min_capacity || void 0,
8057
+ feature: q2.feature?.length ? q2.feature : void 0,
8058
+ building: q2.building || void 0
8059
+ }
8060
+ }
8061
+ }),
8062
+ "Loading rooms"
8063
+ );
8064
+ }
8065
+ async function getFreeBusy(client, body) {
8066
+ return take(await client.fetch.POST("/v1/calendar/freebusy", { body }), "Loading free/busy");
8067
+ }
8068
+ async function findTime(client, body) {
8069
+ return take(
8070
+ await client.fetch.POST("/v1/calendar/find-time", {
8071
+ body
8072
+ }),
8073
+ "Finding a time"
8074
+ );
8075
+ }
8076
+ async function listInvitations(client) {
8077
+ return take(await client.fetch.GET("/v1/calendar/invitations"), "Loading invitations");
8078
+ }
8079
+ async function decideCounter(client, itpId, accept, comment) {
8080
+ return take(
8081
+ await client.fetch.POST("/v1/calendar/invitations/{itp_id}/decide", {
8082
+ params: { path: { itp_id: itpId } },
8083
+ body: { accept, comment: comment ?? null }
8084
+ }),
8085
+ "Answering the proposal"
8086
+ );
8087
+ }
8088
+ async function lookupPeopleKeys(client, body) {
8089
+ return take(
8090
+ await client.fetch.POST("/v1/calendar/people/keys", {
8091
+ body
8092
+ }),
8093
+ "Looking up people"
8094
+ );
8095
+ }
8096
+ var accPath = (accId) => ({ params: { path: { acc_id: accId } } });
8097
+ async function listAccounts(client) {
8098
+ return take(await client.fetch.GET("/v1/calendar/accounts"), "Loading calendar accounts");
8099
+ }
8100
+ async function listCalDavProfiles(client) {
8101
+ return take(await client.fetch.GET("/v1/calendar/caldav/profiles"), "Loading CalDAV servers");
8102
+ }
8103
+ async function connectOAuthAccount(client, kind, backgroundSync = false) {
8104
+ return take(
8105
+ await client.fetch.POST("/v1/calendar/accounts/{kind}", {
8106
+ params: { path: { kind } },
8107
+ body: { background_sync: backgroundSync }
8108
+ }),
8109
+ "Connecting the account"
8110
+ );
8111
+ }
8112
+ async function connectCalDavAccount(client, body) {
8113
+ return take(
8114
+ await client.fetch.POST("/v1/calendar/accounts", {
8115
+ body: {
8116
+ profile_id: body.profile_id || null,
8117
+ url: body.url?.trim() || null,
8118
+ username: body.username.trim(),
8119
+ password: body.password,
8120
+ background_sync: !!body.background_sync
8121
+ }
8122
+ }),
8123
+ "Connecting the account"
8124
+ );
8125
+ }
8126
+ async function updateAccount(client, accId, backgroundSync) {
8127
+ return take(
8128
+ await client.fetch.PATCH("/v1/calendar/accounts/{acc_id}", {
8129
+ ...accPath(accId),
8130
+ body: { background_sync: backgroundSync }
8131
+ }),
8132
+ "Saving the account"
8133
+ );
8134
+ }
8135
+ async function syncAccount(client, accId) {
8136
+ return take(
8137
+ await client.fetch.POST("/v1/calendar/accounts/{acc_id}/sync", accPath(accId)),
8138
+ "Syncing the account"
8139
+ );
8140
+ }
8141
+ async function disconnectAccount(client, accId) {
8142
+ take(
8143
+ await client.fetch.DELETE("/v1/calendar/accounts/{acc_id}", accPath(accId)),
8144
+ "Disconnecting the account"
8145
+ );
8146
+ }
8147
+ async function publishCalendarToAccount(client, accId, calendarId) {
8148
+ return take(
8149
+ await client.fetch.POST("/v1/calendar/accounts/{acc_id}/publish", {
8150
+ params: { path: { acc_id: accId }, query: { calendar_id: calendarId } }
8151
+ }),
8152
+ "Publishing the calendar"
8153
+ );
8154
+ }
8155
+ async function listAppPasswords(client) {
8156
+ return take(await client.fetch.GET("/v1/calendar/app-passwords"), "Loading app passwords");
8157
+ }
8158
+ async function createAppPassword(client, body) {
8159
+ return take(
8160
+ await client.fetch.POST("/v1/calendar/app-passwords", {
8161
+ body: {
8162
+ label: body.label.trim(),
8163
+ calendar_ids: body.calendar_ids?.length ? body.calendar_ids : null
8164
+ }
8165
+ }),
8166
+ "Creating the app password"
8167
+ );
8168
+ }
8169
+ async function createFeed(client, body) {
8170
+ return take(
8171
+ await client.fetch.POST("/v1/calendar/feeds", {
8172
+ body: {
8173
+ calendar_id: body.calendar_id,
8174
+ level: body.level,
8175
+ label: body.label?.trim() || (body.level === "full" ? "Feed" : "Free/busy feed")
8176
+ }
8177
+ }),
8178
+ "Creating the feed"
8179
+ );
8180
+ }
8181
+ async function revokeAppPassword(client, apwId) {
8182
+ take(
8183
+ await client.fetch.DELETE("/v1/calendar/app-passwords/{apw_id}", {
8184
+ params: { path: { apw_id: apwId } }
8185
+ }),
8186
+ "Revoking"
8187
+ );
8188
+ }
8189
+ function splitAppPasswords(rows) {
8190
+ return {
8191
+ devices: rows.filter((r2) => r2.kind === "dav"),
8192
+ feeds: rows.filter((r2) => r2.kind === "feed" || r2.kind === "freebusy")
8193
+ };
8194
+ }
8195
+ async function listBookingPages(client) {
8196
+ return take(await client.fetch.GET("/v1/calendar/booking-pages"), "Loading booking pages");
8197
+ }
8198
+ async function putBookingPage(client, body) {
8199
+ return take(
8200
+ await client.fetch.PUT("/v1/calendar/booking-pages/{slug}", {
8201
+ params: { path: { slug: body.slug } },
8202
+ body
8203
+ }),
8204
+ "Saving the booking page"
8205
+ );
8206
+ }
8207
+ async function deleteBookingPage(client, slug) {
8208
+ take(
8209
+ await client.fetch.DELETE("/v1/calendar/booking-pages/{slug}", {
8210
+ params: { path: { slug } }
8211
+ }),
8212
+ "Deleting the booking page"
8213
+ );
8214
+ }
8215
+ var PublicBookingError = class extends Error {
8216
+ constructor(message, status) {
8217
+ super(message);
8218
+ this.status = status;
8219
+ this.name = "PublicBookingError";
8220
+ }
8221
+ status;
8222
+ };
8223
+ async function bookingError(res) {
8224
+ const body = await res.json().catch(() => null);
8225
+ return new PublicBookingError(
8226
+ apiErrorDetail(body) ?? `Request failed (${res.status})`,
8227
+ res.status
8228
+ );
8229
+ }
8230
+ var bookPath = (baseUrl, slug) => `${baseUrl}/v1/calendar/book/${encodeURIComponent(slug)}`;
8231
+ async function getPublicBookingPage(baseUrl, slug, opts = {}, signal) {
8232
+ const q2 = new URLSearchParams();
8233
+ if (opts.duration) q2.set("duration", String(opts.duration));
8234
+ if (opts.start) q2.set("start", opts.start);
8235
+ if (opts.days) q2.set("days", String(opts.days));
8236
+ const qs = q2.toString();
8237
+ const res = await fetch(`${bookPath(baseUrl, slug)}${qs ? `?${qs}` : ""}`, {
8238
+ headers: { Accept: "application/json" },
8239
+ signal
8240
+ });
8241
+ if (!res.ok) throw await bookingError(res);
8242
+ return await res.json();
8243
+ }
8244
+ async function bookPublicSlot(baseUrl, slug, body) {
8245
+ const res = await fetch(bookPath(baseUrl, slug), {
8246
+ method: "POST",
8247
+ headers: { "Content-Type": "application/json", Accept: "application/json" },
8248
+ body: JSON.stringify({ ...body, note: body.note?.trim() || null })
8249
+ });
8250
+ if (!res.ok) throw await bookingError(res);
8251
+ return await res.json();
8252
+ }
8253
+ async function cancelPublicBooking(baseUrl, slug, token) {
8254
+ const res = await fetch(`${bookPath(baseUrl, slug)}/cancel?token=${encodeURIComponent(token)}`, {
8255
+ method: "POST"
8256
+ });
8257
+ if (!res.ok) throw await bookingError(res);
8258
+ }
8259
+
7717
8260
  // src/arbi.ts
7718
8261
  function tokenExpiresWithin(token, seconds) {
7719
8262
  const payload = token?.split(".")[1];
@@ -8351,11 +8894,13 @@ var Arbi = class {
8351
8894
  assistantMode
8352
8895
  )
8353
8896
  };
8354
- /** Persisted notifications also arrive on the normal workspace WebSocket. */
8897
+ /** Persisted notifications (both the ones you received and the ones you sent), newest first;
8898
+ * new ones also arrive on the normal workspace WebSocket. */
8355
8899
  notifications = {
8356
- list: async (type) => {
8900
+ list: async (options = {}) => {
8901
+ const { type, limit = 100, offset } = options;
8357
8902
  const { data, error } = await this.requireClient().fetch.GET("/v1/notifications/", {
8358
- params: { query: { ...type ? { type } : {}, limit: 100 } }
8903
+ params: { query: { ...type ? { type } : {}, limit, ...offset ? { offset } : {} } }
8359
8904
  });
8360
8905
  if (error) throw new ArbiError("Could not load notifications");
8361
8906
  return data || [];
@@ -8366,6 +8911,11 @@ var Arbi = class {
8366
8911
  body: { updates: ids.map((external_id) => ({ external_id, read: true })) }
8367
8912
  });
8368
8913
  if (error) throw new ArbiError("Could not mark notifications read");
8914
+ },
8915
+ /** Delete notifications for yourself (sender or recipient). */
8916
+ delete: async (ids) => {
8917
+ if (!ids.length) return;
8918
+ await deleteNotifications(this.requireClient(), ids);
8369
8919
  }
8370
8920
  };
8371
8921
  /** Authenticated native Word transport, with normal session recovery. */
@@ -8523,15 +9073,96 @@ var Arbi = class {
8523
9073
  generate: (tagIds, docIds) => generateDocTags(this.requireClient(), tagIds, docIds)
8524
9074
  };
8525
9075
  // ── Contacts ──────────────────────────────────────────────────────────
9076
+ // A card is sealed under its address book's key, which the calendar key bridge carries: without
9077
+ // it the server returns `card: null` and refuses card writes.
8526
9078
  contacts = {
8527
- list: () => listContacts(this.requireClient()),
9079
+ list: () => this.withCalendarKeys((c2) => listContacts(c2)),
8528
9080
  invite: (emails) => inviteContacts(this.requireClient(), emails),
8529
- create: (body) => createContact(this.requireClient(), body),
8530
- update: (contactId, card) => updateContact(this.requireClient(), contactId, card),
8531
- delete: (contactId) => deleteContact(this.requireClient(), contactId),
8532
- search: (q2) => searchContacts(this.requireClient(), q2),
9081
+ create: (body) => this.withCalendarKeys((c2) => createContact(c2, body)),
9082
+ update: (contactId, card) => this.withCalendarKeys((c2) => updateContact(c2, contactId, card)),
9083
+ delete: (contactId) => this.withCalendarKeys((c2) => deleteContact(c2, contactId)),
9084
+ search: (q2) => this.withCalendarKeys((c2) => searchContacts(c2, q2)),
8533
9085
  groupByStatus: groupContactsByStatus
8534
9086
  };
9087
+ // ── Calendar ──────────────────────────────────────────────────────────
9088
+ /** The keys the calendar unlock needs; `null` before login (calendars then read as locked). */
9089
+ calendarKeys() {
9090
+ const login = this.loginResult;
9091
+ return login ? { signingPrivateKey: login.signingPrivateKey, serverSessionKey: login.serverSessionKey } : null;
9092
+ }
9093
+ /** Run `op` once this server session holds the calendar keys (unlocked once per session). */
9094
+ async withCalendarKeys(op) {
9095
+ const client = this.requireClient();
9096
+ await ensureCalendarUnlocked(client, this.calendarKeys());
9097
+ return op(client);
9098
+ }
9099
+ /**
9100
+ * The native calendar (`/v1/calendar`). Every content call first bridges the user's calendar
9101
+ * keys to the server session (once per session; see `calendarOps.ensureCalendarUnlocked`).
9102
+ */
9103
+ calendar = {
9104
+ /** Bridge the calendar keys now; `force` again (keys that arrived since: a share, an invite). */
9105
+ unlock: (force = false) => ensureCalendarUnlocked(this.requireClient(), this.calendarKeys(), force),
9106
+ getSettings: () => this.withCalendarKeys((c2) => getCalendarSettings(c2)),
9107
+ putSettings: (body) => this.withCalendarKeys((c2) => putCalendarSettings(c2, body)),
9108
+ listCalendars: () => this.withCalendarKeys((c2) => listCalendars(c2, this.calendarKeys())),
9109
+ createCalendar: (body) => this.withCalendarKeys((c2) => createCalendar(c2, body)),
9110
+ updateCalendar: (calId, body) => this.withCalendarKeys((c2) => updateCalendar(c2, calId, body)),
9111
+ deleteCalendar: (calId) => this.withCalendarKeys((c2) => deleteCalendar(c2, calId)),
9112
+ exportCalendar: (calId) => this.withCalendarKeys((c2) => exportCalendarIcs(c2, calId)),
9113
+ importIcs: (ics, calendarId) => this.withCalendarKeys((c2) => importCalendarIcs(c2, ics, calendarId)),
9114
+ listEvents: (params) => this.withCalendarKeys((c2) => listEvents(c2, params)),
9115
+ getEvent: (evtId, recurrenceId) => this.withCalendarKeys((c2) => getEvent(c2, evtId, recurrenceId)),
9116
+ createEvent: (body) => this.withCalendarKeys((c2) => createEvent(c2, body)),
9117
+ updateEvent: (target, body) => this.withCalendarKeys((c2) => updateEvent(c2, target, body)),
9118
+ deleteEvent: (target) => this.withCalendarKeys((c2) => deleteEvent(c2, target)),
9119
+ moveEvent: (evtId, calendarId) => this.withCalendarKeys((c2) => moveEvent(c2, evtId, calendarId)),
9120
+ respond: (params) => this.withCalendarKeys((c2) => respondToEvent(c2, params)),
9121
+ eventIcs: (evtId) => this.withCalendarKeys((c2) => eventIcs(c2, evtId)),
9122
+ lookupByUid: (uid) => this.withCalendarKeys((c2) => lookupEventByUid(c2, uid)),
9123
+ /** The open workspace's overlay layers (not sealed: no unlock). */
9124
+ listOverlays: (range, layers) => listOverlays(this.requireClient(), range, layers),
9125
+ listShares: (calId) => this.withCalendarKeys((c2) => listShares(c2, calId)),
9126
+ share: (calId, grantee, role) => this.withCalendarKeys((c2) => shareCalendar(c2, calId, grantee, role)),
9127
+ /** Remove a grantee; the key it rotates is bridged again. */
9128
+ unshare: async (calId, grantee) => {
9129
+ await this.withCalendarKeys((c2) => unshareCalendar(c2, calId, grantee));
9130
+ await this.calendar.unlock(true);
9131
+ },
9132
+ subscribe: (body) => this.withCalendarKeys((c2) => subscribeCalendar(c2, body)),
9133
+ refresh: (calId) => this.withCalendarKeys((c2) => refreshCalendar(c2, calId)),
9134
+ listHolidayCountries: () => this.withCalendarKeys((c2) => listHolidayCountries(c2)),
9135
+ addHolidays: (body) => this.withCalendarKeys((c2) => addHolidayCalendar(c2, body)),
9136
+ createRoom: (body) => this.withCalendarKeys((c2) => createRoom(c2, body)),
9137
+ listRooms: (query) => this.withCalendarKeys((c2) => listRooms(c2, query)),
9138
+ freeBusy: (body) => this.withCalendarKeys((c2) => getFreeBusy(c2, body)),
9139
+ findTime: (body) => this.withCalendarKeys((c2) => findTime(c2, body)),
9140
+ /**
9141
+ * Invitations and proposals waiting for me. A new one arrives with its own key: bridge again
9142
+ * first, or an open tab would not see it until it reloaded.
9143
+ */
9144
+ listInvitations: async () => {
9145
+ await this.calendar.unlock(true);
9146
+ return listInvitations(this.requireClient());
9147
+ },
9148
+ decideCounter: (itpId, accept, comment) => this.withCalendarKeys((c2) => decideCounter(c2, itpId, accept, comment)),
9149
+ peopleKeys: (body) => this.withCalendarKeys((c2) => lookupPeopleKeys(c2, body)),
9150
+ listAccounts: () => this.withCalendarKeys((c2) => listAccounts(c2)),
9151
+ listCalDavProfiles: () => this.withCalendarKeys((c2) => listCalDavProfiles(c2)),
9152
+ connectOAuthAccount: (kind, backgroundSync = false) => this.withCalendarKeys((c2) => connectOAuthAccount(c2, kind, backgroundSync)),
9153
+ connectCalDavAccount: (body) => this.withCalendarKeys((c2) => connectCalDavAccount(c2, body)),
9154
+ updateAccount: (accId, backgroundSync) => this.withCalendarKeys((c2) => updateAccount(c2, accId, backgroundSync)),
9155
+ syncAccount: (accId) => this.withCalendarKeys((c2) => syncAccount(c2, accId)),
9156
+ disconnectAccount: (accId) => this.withCalendarKeys((c2) => disconnectAccount(c2, accId)),
9157
+ publishToAccount: (accId, calendarId) => this.withCalendarKeys((c2) => publishCalendarToAccount(c2, accId, calendarId)),
9158
+ listAppPasswords: () => this.withCalendarKeys((c2) => listAppPasswords(c2)),
9159
+ createAppPassword: (body) => this.withCalendarKeys((c2) => createAppPassword(c2, body)),
9160
+ createFeed: (body) => this.withCalendarKeys((c2) => createFeed(c2, body)),
9161
+ revokeAppPassword: (apwId) => this.withCalendarKeys((c2) => revokeAppPassword(c2, apwId)),
9162
+ listBookingPages: () => this.withCalendarKeys((c2) => listBookingPages(c2)),
9163
+ putBookingPage: (body) => this.withCalendarKeys((c2) => putBookingPage(c2, body)),
9164
+ deleteBookingPage: (slug) => this.withCalendarKeys((c2) => deleteBookingPage(c2, slug))
9165
+ };
8535
9166
  // ── Chats (direct + group) ────────────────────────────────────────────
8536
9167
  /**
8537
9168
  * Build (and cache) the chat crypto context for the current session: my X25519 keypair
@@ -8784,6 +9415,6 @@ var Arbi = class {
8784
9415
  }
8785
9416
  };
8786
9417
 
8787
- export { Arbi, ArbiApiError, ArbiError, DEFAULT_AI_USD_PER_GBP, FLAT_TAG_KINDS, PlanStepsError, TAG_KINDS, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildCitationChunkData, buildFactsContextTool, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, chats_exports as chats, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, doctags_exports as doctags, documents_exports as documents, facts_exports as facts, files_exports as files, filterSkills, formatAgentStepLabel, formatFileSize, formatGbp, formatGbpPerMillionTokens, formatItemLabel, formatUserName, formatWorkspaceChoices, getErrorMessage, getRawWorkspaceKey, health_exports as health, identityErrorCode, identity_exports as identityVerification, mail_exports as mail, notifications_exports as notifications, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, 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, 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 };
9418
+ export { ACCOUNT_VENDOR, Arbi, ArbiApiError, ArbiError, DEFAULT_AI_USD_PER_GBP, FLAT_TAG_KINDS, PlanStepsError, PublicBookingError, TAG_KINDS, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, bookPublicSlot, buildCitationChunkData, 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, doctags_exports as doctags, documents_exports as documents, facts_exports as facts, files_exports as files, filterSkills, formatAgentStepLabel, formatFileSize, formatGbp, formatGbpPerMillionTokens, formatItemLabel, formatUserName, formatWorkspaceChoices, getErrorMessage, getPublicBookingPage, getRawWorkspaceKey, health_exports as health, identityErrorCode, identity_exports as identityVerification, mail_exports as mail, notifications_exports as notifications, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, 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, splitAppPasswords, 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 };
8788
9419
  //# sourceMappingURL=browser.js.map
8789
9420
  //# sourceMappingURL=browser.js.map