@sparkvault/sdk-js 15.3.3 → 15.5.0

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 CHANGED
@@ -134,6 +134,31 @@ app.post('/api/auth/login', async (req, res) => {
134
134
 
135
135
  `products.identity`, `products.helpDesk`, `vaults.upload` and `health` send neither a Core JWT nor an `apiKey`. Help Desk uses only a desk customer session (`hdt_`), with cookies omitted. The upload widget needs the vault's Embedded Upload Widget setting enabled, with or without a `token`: it opens by reading the vault's upload info, a request that carries no VAT and is refused while the setting is off. The other modules call the Core API with a Core JWT (`accessToken` or `getAccessToken`) or, server-side, an `apiKey`; `notify` needs a SparkVault user's session JWT. Configuration, errors and TypeScript: the [reference](https://sparkvault.com/api/docs/sdk-js/#configuration-options).
136
136
 
137
+ ## Notify projects
138
+
139
+ Use a named project for each separately operated product, brand or notification
140
+ service. Categories remain topics inside that project. Existing calls on
141
+ `sv.products.notify` continue to address Default.
142
+
143
+ ```typescript
144
+ // Use an API key restricted to this project for a product integration.
145
+ const payroll = sv.products.notify.project('ntp_…');
146
+ await payroll.sendSecureMessage({
147
+ recipients: [{ id: 'employee_42', email: 'pat@example.com' }],
148
+ title: 'Your payslip is ready',
149
+ content: { payload: payslipPdfBase64, contentType: 'application/pdf' }
150
+ });
151
+ const history = await payroll.listSends({ limit: 20 });
152
+ ```
153
+
154
+ `notify.projects.list/create/get/update/archive` manage project details under a
155
+ company credential; a newly created project is a free draft. Configure and
156
+ activate its plan in the console before sending. Programmatic plan changes use
157
+ `previewSubscription`, `subscribe` and `cancelSubscription` with an interactive
158
+ company-administrator session; an API key cannot authorize spending. Quote
159
+ amounts are exact decimal strings and should be repeated without floating-point
160
+ conversion. A first subscription can return a `checkout_url` for hosted payment.
161
+
137
162
  ## Help Desk
138
163
 
139
164
  Create one KB-first support widget after the page body is ready:
@@ -258,6 +283,12 @@ its bytes again. A full ticket-status page remains in the hosted customer portal
258
283
 
259
284
  For a custom UI, use the same customer API without injecting markup:
260
285
 
286
+ Each desk is discovered from its own hostname and checked against the SDK's
287
+ configured company account. Add `deskId` to `connect`, `mountForm`, `openForm`,
288
+ or `attach` to pin an expected desk, for example
289
+ `{ host: 'subscribers.example.com', deskId: 'hdd_0123456789abcdef0123456789abcdef' }`.
290
+ Separate clients keep their customer sessions and ticket requests in their own desks.
291
+
261
292
  ```typescript
262
293
  const desk = await sv.products.helpDesk.connect({ host: 'support.example.com' });
263
294
  const challenge = await desk.startPin(email);
package/dist/errors.d.ts CHANGED
@@ -76,7 +76,8 @@ export declare class QuotaExceededError extends SparkVaultError {
76
76
  constructor(message: string, details?: Record<string, unknown>, retryAfterMs?: number | null, serviceCode?: string);
77
77
  }
78
78
  /**
79
- * Notify subscription gate (403 NOTIFY_SUBSCRIPTION_REQUIRED) — the account
79
+ * Notify subscription gate (403 NOTIFY_SUBSCRIPTION_REQUIRED or
80
+ * NOTIFY_PROJECT_SUBSCRIPTION_REQUIRED) — the account or selected project
80
81
  * does not hold Notify and attempted a send that names no accepted send's
81
82
  * `sendId` (a replay of an accepted send, the same request under its `sendId`,
82
83
  * is answered with the stored send), or a config save that selects a new
package/dist/index.cjs CHANGED
@@ -865,7 +865,8 @@ class QuotaExceededError extends SparkVaultError {
865
865
  }
866
866
  }
867
867
  /**
868
- * Notify subscription gate (403 NOTIFY_SUBSCRIPTION_REQUIRED) — the account
868
+ * Notify subscription gate (403 NOTIFY_SUBSCRIPTION_REQUIRED or
869
+ * NOTIFY_PROJECT_SUBSCRIPTION_REQUIRED) — the account or selected project
869
870
  * does not hold Notify and attempted a send that names no accepted send's
870
871
  * `sendId` (a replay of an accepted send, the same request under its `sendId`,
871
872
  * is answered with the stored send), or a config save that selects a new
@@ -1027,6 +1028,7 @@ const RESOURCE_ID_PREFIXES = Object.freeze({
1027
1028
  ingot: 'ing',
1028
1029
  invite: 'inv',
1029
1030
  notification: 'ntf',
1031
+ notifyProject: 'ntp',
1030
1032
  requester: 'hrq',
1031
1033
  routingRule: 'hdr',
1032
1034
  savedReply: 'hds',
@@ -1669,7 +1671,7 @@ class HttpClient {
1669
1671
  // A Notify send, or a config save selecting a new sending domain, refused
1670
1672
  // because the account does not hold Notify is a billing gate, not a
1671
1673
  // credential problem — give it its own catchable type.
1672
- if (code === 'NOTIFY_SUBSCRIPTION_REQUIRED') {
1674
+ if (code === 'NOTIFY_SUBSCRIPTION_REQUIRED' || code === 'NOTIFY_PROJECT_SUBSCRIPTION_REQUIRED') {
1673
1675
  return new NotifySubscriptionRequiredError(message, details, retryAfterMs, code);
1674
1676
  }
1675
1677
  return new AuthorizationError(message, details, retryAfterMs, code);
@@ -11599,6 +11601,67 @@ function mergePresetSend(preset, args) {
11599
11601
  return merged;
11600
11602
  }
11601
11603
 
11604
+ /** Reject malformed project paths before a credentialed request leaves. */
11605
+ function requireNotifyProjectId(projectId) {
11606
+ if (projectId === 'default' || isResourceIdOf('notifyProject', projectId))
11607
+ return projectId;
11608
+ throw new ValidationError('projectId must be a Notify project id or "default"', {
11609
+ field: 'projectId', received: projectId,
11610
+ });
11611
+ }
11612
+ /** Company-level project management. Creation saves a draft and charges nothing. */
11613
+ class NotifyProjectsModule {
11614
+ constructor(http) {
11615
+ this.http = http;
11616
+ }
11617
+ async list() {
11618
+ const response = await this.http.get(apiPath `/v1/products/notify/projects`);
11619
+ return response.data;
11620
+ }
11621
+ async create(options) {
11622
+ const response = await this.http.post(apiPath `/v1/products/notify/projects`, options);
11623
+ return response.data;
11624
+ }
11625
+ async get(projectId) {
11626
+ const id = requireNotifyProjectId(projectId);
11627
+ const response = await this.http.get(apiPath `/v1/products/notify/projects/${id}`);
11628
+ return response.data;
11629
+ }
11630
+ async update(projectId, options) {
11631
+ const id = requireNotifyProjectId(projectId);
11632
+ const response = await this.http.put(apiPath `/v1/products/notify/projects/${id}`, options);
11633
+ return response.data;
11634
+ }
11635
+ /** Archive after its paid plan has ended; Default cannot be archived. */
11636
+ async archive(projectId) {
11637
+ const id = requireNotifyProjectId(projectId);
11638
+ const response = await this.http.post(apiPath `/v1/products/notify/projects/${id}/archive`, {});
11639
+ return response.data;
11640
+ }
11641
+ /** Quote a named project's plan. Requires an interactive company-admin session. */
11642
+ async previewSubscription(projectId, options) {
11643
+ const id = requireNotifyProjectId(projectId);
11644
+ const response = await this.http.post(apiPath `/v1/products/notify/projects/${id}/subscription/preview`, { notifications_per_month: options.notificationsPerMonth });
11645
+ return response.data;
11646
+ }
11647
+ /** Purchase the reviewed plan on the company's invoice; an API key cannot authorize spending. */
11648
+ async subscribe(projectId, options) {
11649
+ const id = requireNotifyProjectId(projectId);
11650
+ const response = await this.http.post(apiPath `/v1/products/notify/projects/${id}/subscription`, {
11651
+ notifications_per_month: options.notificationsPerMonth,
11652
+ quoted_amount_due_now_usd: options.quotedAmountDueNowUsd,
11653
+ proration_date: options.prorationDate,
11654
+ });
11655
+ return response.data;
11656
+ }
11657
+ /** End a named project's plan at its paid period deadline; retained history stays readable. */
11658
+ async cancelSubscription(projectId) {
11659
+ const id = requireNotifyProjectId(projectId);
11660
+ const response = await this.http.delete(apiPath `/v1/products/notify/projects/${id}/subscription`);
11661
+ return response.data;
11662
+ }
11663
+ }
11664
+
11602
11665
  /**
11603
11666
  * Notify Product Module — the TENANT (sender) surface.
11604
11667
  *
@@ -11684,8 +11747,25 @@ function buildNotifyPresetSend(preset, options) {
11684
11747
  return mergePresetSend(bundle, options);
11685
11748
  }
11686
11749
  class NotifyProductModule {
11687
- constructor(http) {
11750
+ constructor(http, projectId) {
11688
11751
  this.http = http;
11752
+ this.projectId = projectId === undefined ? undefined : requireNotifyProjectId(projectId);
11753
+ this.projects = new NotifyProjectsModule(http);
11754
+ }
11755
+ /**
11756
+ * Bind every send, read and setting to one project. The original module keeps
11757
+ * addressing Default for existing integrations; this never changes global state.
11758
+ */
11759
+ project(projectId) {
11760
+ return new NotifyProductModule(this.http, requireNotifyProjectId(projectId));
11761
+ }
11762
+ /** Compose two already-validated paths; project selection never enters a body. */
11763
+ path(literals, ...values) {
11764
+ const path = apiPath(literals, ...values);
11765
+ if (this.projectId === undefined)
11766
+ return path;
11767
+ const project = apiPath `/v1/products/notify/projects/${this.projectId}`;
11768
+ return `${project}${path.slice('/v1/products/notify'.length)}`;
11689
11769
  }
11690
11770
  // ── Send ────────────────────────────────────────────────────────────────────
11691
11771
  /**
@@ -11754,7 +11834,7 @@ class NotifyProductModule {
11754
11834
  if (options.ingot && (!options.ingot.vault?.id || !options.ingot.vault.vatToken)) {
11755
11835
  throw new ValidationError('An ingot send requires its vault unsealed with sv.vaults.unseal (ingot.vault): only a key holder may send a vault file', { field: 'ingot.vault' });
11756
11836
  }
11757
- const response = await this.http.post(apiPath `/v1/products/notify/send`, toSendBody(options), { vat: options.ingot?.vault.vatToken });
11837
+ const response = await this.http.post(this.path `/v1/products/notify/send`, toSendBody(options), { vat: options.ingot?.vault.vatToken });
11758
11838
  return response.data;
11759
11839
  }
11760
11840
  /**
@@ -11844,7 +11924,7 @@ class NotifyProductModule {
11844
11924
  */
11845
11925
  async getInbox(options) {
11846
11926
  requireRecipientId(options?.recipientId);
11847
- const response = await this.http.get(apiPath `/v1/products/notify/inbox`, {
11927
+ const response = await this.http.get(this.path `/v1/products/notify/inbox`, {
11848
11928
  query: {
11849
11929
  recipient_id: options.recipientId,
11850
11930
  state: options.state,
@@ -11882,7 +11962,7 @@ class NotifyProductModule {
11882
11962
  received: options.state,
11883
11963
  });
11884
11964
  }
11885
- const response = await this.http.post(apiPath `/v1/products/notify/inbox/${id}/state`, { recipient_id: options.recipientId, created_at: options.createdAt, state: options.state });
11965
+ const response = await this.http.post(this.path `/v1/products/notify/inbox/${id}/state`, { recipient_id: options.recipientId, created_at: options.createdAt, state: options.state });
11886
11966
  return response.data;
11887
11967
  }
11888
11968
  /**
@@ -11903,7 +11983,7 @@ class NotifyProductModule {
11903
11983
  if (!BULK_MARK_STATES$1.includes(options.state)) {
11904
11984
  throw new ValidationError(`state must be one of ${BULK_MARK_STATES$1.join(', ')} (archive per-row instead)`, { field: 'state', received: options.state });
11905
11985
  }
11906
- const response = await this.http.post(apiPath `/v1/products/notify/inbox/state`, {
11986
+ const response = await this.http.post(this.path `/v1/products/notify/inbox/state`, {
11907
11987
  recipient_id: options.recipientId,
11908
11988
  state: options.state,
11909
11989
  cursor: options.cursor,
@@ -11934,7 +12014,7 @@ class NotifyProductModule {
11934
12014
  * } while (cursor);
11935
12015
  */
11936
12016
  async listSends(options = {}) {
11937
- const response = await this.http.get(apiPath `/v1/products/notify/sends`, {
12017
+ const response = await this.http.get(this.path `/v1/products/notify/sends`, {
11938
12018
  query: { limit: options.limit, cursor: options.cursor },
11939
12019
  });
11940
12020
  return response.data;
@@ -11980,7 +12060,7 @@ class NotifyProductModule {
11980
12060
  received: options.mode,
11981
12061
  });
11982
12062
  }
11983
- const response = await this.http.post(apiPath `/v1/products/notify/sends/${sendId}/recall`, { recipient_ids: options.recipientIds, mode: options.mode });
12063
+ const response = await this.http.post(this.path `/v1/products/notify/sends/${sendId}/recall`, { recipient_ids: options.recipientIds, mode: options.mode });
11984
12064
  return response.data;
11985
12065
  }
11986
12066
  // ── Status & receipts ───────────────────────────────────────────────────────
@@ -11994,7 +12074,7 @@ class NotifyProductModule {
11994
12074
  */
11995
12075
  async getSendStatus(sendId) {
11996
12076
  requireSendId(sendId);
11997
- const response = await this.http.get(apiPath `/v1/products/notify/sends/${sendId}/status`);
12077
+ const response = await this.http.get(this.path `/v1/products/notify/sends/${sendId}/status`);
11998
12078
  return response.data;
11999
12079
  }
12000
12080
  /**
@@ -12008,7 +12088,7 @@ class NotifyProductModule {
12008
12088
  * const { receipts, cursor } = await sv.products.notify.listReceipts({ interaction: 'approve' });
12009
12089
  */
12010
12090
  async listReceipts(options = {}) {
12011
- const response = await this.http.get(apiPath `/v1/products/notify/receipts`, {
12091
+ const response = await this.http.get(this.path `/v1/products/notify/receipts`, {
12012
12092
  query: {
12013
12093
  limit: options.limit,
12014
12094
  cursor: options.cursor,
@@ -12034,7 +12114,7 @@ class NotifyProductModule {
12034
12114
  */
12035
12115
  async getSendReceipts(sendId, options = {}) {
12036
12116
  requireSendId(sendId);
12037
- const response = await this.http.get(apiPath `/v1/products/notify/sends/${sendId}/receipts`, { query: { cursor: options.cursor } });
12117
+ const response = await this.http.get(this.path `/v1/products/notify/sends/${sendId}/receipts`, { query: { cursor: options.cursor } });
12038
12118
  return response.data;
12039
12119
  }
12040
12120
  // ── Config ──────────────────────────────────────────────────────────────────
@@ -12047,7 +12127,7 @@ class NotifyProductModule {
12047
12127
  * const { effective, overrides } = await sv.products.notify.getConfig();
12048
12128
  */
12049
12129
  async getConfig() {
12050
- const response = await this.http.get(apiPath `/v1/products/notify/config`);
12130
+ const response = await this.http.get(this.path `/v1/products/notify/config`);
12051
12131
  return response.data;
12052
12132
  }
12053
12133
  /**
@@ -12096,7 +12176,7 @@ class NotifyProductModule {
12096
12176
  if (!patch || typeof patch !== 'object' || Array.isArray(patch)) {
12097
12177
  throw new ValidationError('config patch must be an object');
12098
12178
  }
12099
- const response = await this.http.put(apiPath `/v1/products/notify/config`, patch);
12179
+ const response = await this.http.put(this.path `/v1/products/notify/config`, patch);
12100
12180
  return response.data;
12101
12181
  }
12102
12182
  /**
@@ -12126,7 +12206,7 @@ class NotifyProductModule {
12126
12206
  if (!NOTIFY_DESTINATION_KINDS.includes(kind)) {
12127
12207
  throw new ValidationError(`kind must be one of ${NOTIFY_DESTINATION_KINDS.join(', ')}`);
12128
12208
  }
12129
- const response = await this.http.post(apiPath `/v1/products/notify/destinations/${kind}/test`);
12209
+ const response = await this.http.post(this.path `/v1/products/notify/destinations/${kind}/test`);
12130
12210
  return response.data;
12131
12211
  }
12132
12212
  /**
@@ -12155,7 +12235,7 @@ class NotifyProductModule {
12155
12235
  * if (sender.state === 'handle_required') promptForHandle();
12156
12236
  */
12157
12237
  async getEmailSender() {
12158
- const response = await this.http.get(apiPath `/v1/products/notify/email-sender`);
12238
+ const response = await this.http.get(this.path `/v1/products/notify/email-sender`);
12159
12239
  return response.data;
12160
12240
  }
12161
12241
  }
@@ -12208,6 +12288,11 @@ function requireSendId(sendId) {
12208
12288
  }
12209
12289
  }
12210
12290
 
12291
+ /** The original desk uses its account ID; additional desks have their own ID. */
12292
+ function validHelpDeskId(value) {
12293
+ return typeof value === 'string' && (isResourceIdOf('account', value) || /^hdd_[0-9a-f]{32}$/.test(value));
12294
+ }
12295
+
12211
12296
  /**
12212
12297
  * Ingot access logs: which of an ingot's audit events are accesses, and how one
12213
12298
  * audit entry reads as an access. Both SDKs read
@@ -14971,7 +15056,9 @@ function mapInvitation(wire) {
14971
15056
  /** The native support ceremony. Identity receipts stay inside the first-party window. */
14972
15057
  const VALUE = /^[A-Za-z0-9_-]{43}$/;
14973
15058
  /** Open synchronously inside the user's gesture, before preparing the server challenge. */
14974
- function openWidgetIdentity(options, prepare, ready, redeem) {
15059
+ function openWidgetIdentity(options, prepare, ready, redeem, deskId) {
15060
+ if (!validHelpDeskId(deskId))
15061
+ return Promise.reject(new ValidationError('Support sign-in requires a valid desk.'));
14975
15062
  if (typeof window === 'undefined')
14976
15063
  return Promise.reject(new ValidationError('Support sign-in requires a browser.'));
14977
15064
  if (options.signal?.aborted)
@@ -15042,8 +15129,7 @@ function openWidgetIdentity(options, prepare, ready, redeem) {
15042
15129
  const url = new URL(value.sign_in_url);
15043
15130
  if (!VALUE.test(value.challenge_id) || !VALUE.test(value.verifier) || !VALUE.test(value.state) || !Number.isSafeInteger(value.expires_at) ||
15044
15131
  url.protocol !== 'https:' || url.origin !== 'https://auth.sv' || url.username || url.password || url.search || url.hash ||
15045
- !/^\/help-desk\/acc_[0-9a-f]{32}\/[A-Za-z0-9_-]{43}$/.test(url.pathname) ||
15046
- !url.pathname.endsWith(`/${value.challenge_id}`))
15132
+ url.pathname !== `/help-desk/${deskId}/${value.challenge_id}`)
15047
15133
  throw new SparkVaultError('The support sign-in address is invalid.', 'HELP_DESK_INVALID_RESPONSE');
15048
15134
  challenge = value;
15049
15135
  firstPartyOrigin = url.origin;
@@ -15192,6 +15278,9 @@ class HelpDeskClient {
15192
15278
  /** Discover a desk by its configured host, before any customer credentials are sent. */
15193
15279
  static async connect(config, options) {
15194
15280
  const host = hostname(options?.host);
15281
+ if (options.deskId !== undefined && !validHelpDeskId(options.deskId)) {
15282
+ throw new ValidationError('deskId must be a Help Desk ID', { field: 'deskId' });
15283
+ }
15195
15284
  if (options.getSessionToken !== undefined && typeof options.getSessionToken !== 'function') {
15196
15285
  throw new ValidationError('getSessionToken must be a function', { field: 'getSessionToken' });
15197
15286
  }
@@ -15211,7 +15300,11 @@ class HelpDeskClient {
15211
15300
  if (data?.kind === 'moved') {
15212
15301
  throw new SparkVaultError('This help desk has moved. Connect using its current host.', 'HELP_DESK_MOVED', 409, { movedTo: data.moved_to });
15213
15302
  }
15214
- if (data?.kind !== 'desk' || !isResourceIdOf('account', data.desk_id) || data.desk_id !== config.accountId || data.portal_client !== CLIENT) {
15303
+ const originalDesk = data?.kind === 'desk' && isResourceIdOf('account', data.desk_id);
15304
+ const ownerId = data?.kind === 'desk' ? data.account_id ?? (originalDesk ? data.desk_id : null) : null;
15305
+ if (data?.kind !== 'desk' || !validHelpDeskId(data.desk_id) || ownerId !== config.accountId ||
15306
+ (originalDesk && data.desk_id !== config.accountId) ||
15307
+ (options.deskId !== undefined && options.deskId !== data.desk_id) || data.portal_client !== CLIENT) {
15215
15308
  throw new SparkVaultError('The help desk lookup did not identify this account\'s desk.', 'HELP_DESK_INVALID_RESPONSE');
15216
15309
  }
15217
15310
  hostname(data.canonical_host);
@@ -15291,7 +15384,8 @@ class HelpDeskClient {
15291
15384
  const { data } = await this.http.request(apiPath `/v1/hd/desks`, {
15292
15385
  query: { host: this.desk.canonical_host }, headers: { 'X-SV-Client': CLIENT }, credentials: 'omit',
15293
15386
  });
15294
- if (data?.kind !== 'desk' || data.desk_id !== this.desk.desk_id || data.portal_client !== CLIENT) {
15387
+ const ownerId = data?.account_id ?? (isResourceIdOf('account', data?.desk_id) ? data.desk_id : null);
15388
+ if (data?.kind !== 'desk' || data.desk_id !== this.desk.desk_id || ownerId !== (this.desk.account_id ?? this.desk.desk_id) || data.portal_client !== CLIENT) {
15295
15389
  throw new SparkVaultError('This help desk could not refresh its access settings.', 'HELP_DESK_INVALID_RESPONSE');
15296
15390
  }
15297
15391
  if (JSON.stringify(data.ticket_access_control) !== JSON.stringify(this.currentTicketPolicy))
@@ -15551,7 +15645,7 @@ class HelpDeskClient {
15551
15645
  }
15552
15646
  this.issuedSessions.set(result, result.token);
15553
15647
  return result;
15554
- });
15648
+ }, this.desk.desk_id);
15555
15649
  }
15556
15650
  /** Choose a different support identity without logging out or changing the host website. */
15557
15651
  switchSupportAccount() {
@@ -17555,7 +17649,7 @@ function mountHelpDeskForm(client, options) {
17555
17649
  const codeHint = document.createElement('p');
17556
17650
  codeHint.id = `${code.input.id}-hint`;
17557
17651
  codeHint.className = 'svhd-file-hint';
17558
- codeHint.textContent = `It works for ${HELP_DESK_PIN_TTL_MINUTES} minutes. Not in your inbox? Look in spam for mail from ${helpDeskCodeSender(client.desk.sending_host)}.`;
17652
+ codeHint.textContent = `It works for ${HELP_DESK_PIN_TTL_MINUTES} minutes. Not in your inbox? Look in spam for mail from ${client.desk.contact_email ?? helpDeskCodeSender(client.desk.sending_host)}.`;
17559
17653
  code.input.setAttribute('aria-describedby', codeHint.id);
17560
17654
  const resend = document.createElement('button');
17561
17655
  resend.type = 'button';
@@ -18795,8 +18889,8 @@ class HelpDeskKnowledgeBaseClient {
18795
18889
  this.activeMedia = null;
18796
18890
  this.destroyed = false;
18797
18891
  this.close = new AbortController();
18798
- if (!isResourceIdOf('account', deskId))
18799
- throw new ValidationError('deskId must be a Help Desk account');
18892
+ if (!validHelpDeskId(deskId))
18893
+ throw new ValidationError('deskId must be a Help Desk ID');
18800
18894
  }
18801
18895
  getAccessHeaders() {
18802
18896
  if (this.grantDeadline !== null && this.grantDeadline <= Date.now())
@@ -20474,14 +20568,17 @@ function createHelpDeskSupport(config, options) {
20474
20568
  post: async (path, body) => {
20475
20569
  if (destroyed)
20476
20570
  throw new Error('Support is closed.');
20571
+ const deskId = client?.desk.desk_id;
20572
+ if (!deskId)
20573
+ throw new Error('Support is still loading.');
20477
20574
  const prefix = `/hd/desks/${encodeURIComponent(config.accountId)}/support`;
20478
20575
  const suffix = path.slice(prefix.length);
20479
20576
  if (!path.startsWith(prefix))
20480
20577
  throw new Error('Invalid support analytics route.');
20481
20578
  const event = /^\/attempts\/([^/]+)\/events$/.exec(suffix);
20482
- const route = suffix === '/visitor' ? apiPath `/v1/hd/desks/${config.accountId}/support/visitor`
20483
- : suffix === '/attempts' ? apiPath `/v1/hd/desks/${config.accountId}/support/attempts`
20484
- : event ? apiPath `/v1/hd/desks/${config.accountId}/support/attempts/${decodeURIComponent(event[1])}/events` : null;
20579
+ const route = suffix === '/visitor' ? apiPath `/v1/hd/desks/${deskId}/support/visitor`
20580
+ : suffix === '/attempts' ? apiPath `/v1/hd/desks/${deskId}/support/attempts`
20581
+ : event ? apiPath `/v1/hd/desks/${deskId}/support/attempts/${decodeURIComponent(event[1])}/events` : null;
20485
20582
  if (!route)
20486
20583
  throw new Error('Invalid support analytics route.');
20487
20584
  const headers = kb?.getAccessHeaders() ?? {};
@@ -25024,7 +25121,7 @@ class SparkVault {
25024
25121
  }
25025
25122
  /** Get the SDK version */
25026
25123
  static get version() {
25027
- return '15.3.3';
25124
+ return '15.5.0';
25028
25125
  }
25029
25126
  }
25030
25127
  if (typeof window !== 'undefined') {
@@ -25048,6 +25145,7 @@ exports.NOTIFY_PRESETS = NOTIFY_PRESETS;
25048
25145
  exports.NetworkError = NetworkError;
25049
25146
  exports.NotifyModule = NotifyModule;
25050
25147
  exports.NotifyProductModule = NotifyProductModule;
25148
+ exports.NotifyProjectsModule = NotifyProjectsModule;
25051
25149
  exports.NotifySubscriptionRequiredError = NotifySubscriptionRequiredError;
25052
25150
  exports.PlanRequiredError = PlanRequiredError;
25053
25151
  exports.PopupBlockedError = PopupBlockedError;