@sparkvault/sdk-js 15.11.4 → 15.11.6

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.d.ts CHANGED
@@ -453,7 +453,12 @@ declare class IdentityModule {
453
453
  *
454
454
  * @example
455
455
  * const result = await sv.products.identity.signIn();
456
- * console.log(result.token, result.identity);
456
+ * // Your backend verifies the token before it grants access; never log it.
457
+ * await fetch('/api/auth/login', {
458
+ * method: 'POST',
459
+ * headers: { 'Content-Type': 'application/json' },
460
+ * body: JSON.stringify({ token: result.token }),
461
+ * });
457
462
  */
458
463
  signIn(options?: SignInOptions): Promise<SignInResult>;
459
464
  /**
@@ -3581,8 +3586,19 @@ interface HelpDeskTicketDetail extends HelpDeskTimeline {
3581
3586
  ticket: HelpDeskTicket;
3582
3587
  }
3583
3588
  interface HelpDeskReplyOptions {
3589
+ /** Help desk safe markup, not HTML. */
3584
3590
  body: string;
3585
3591
  attachments?: string[];
3592
+ /**
3593
+ * The id the reply is sent under (`HelpDeskClient.newReplyId()`), named once
3594
+ * per composed reply and sent with every send of it while its words and
3595
+ * files stand unchanged, whatever an earlier send answered (a lost
3596
+ * response, a refusal): a reply an earlier send posted is answered with
3597
+ * that reply instead of being posted again. Name a changed reply anew.
3598
+ * Without one the help desk names the reply itself, so a reply sent again
3599
+ * posts again.
3600
+ */
3601
+ eventId?: string;
3586
3602
  }
3587
3603
  interface HelpDeskReplyCreated {
3588
3604
  event_id: string;
@@ -3755,7 +3771,9 @@ declare class HelpDeskClient {
3755
3771
  response?: string;
3756
3772
  }): Promise<HelpDeskTicketDetail>;
3757
3773
  listEvents(number: number, cursor?: string): Promise<HelpDeskTimeline>;
3758
- /** Replies have no client idempotency key: reconcile an uncertain response before retrying. */
3774
+ /** A new id for one composed reply, sent as `HelpDeskReplyOptions.eventId` with every send of it while it stands unchanged. */
3775
+ newReplyId(): string;
3776
+ /** A reply sent under an `eventId` an earlier send of it posted answers that reply, posting nothing again. */
3759
3777
  replyToTicket(number: number, options: HelpDeskReplyOptions, context?: HelpDeskRequestContext): Promise<HelpDeskReplyCreated>;
3760
3778
  resolveTicket(number: number, context?: HelpDeskRequestContext): Promise<void>;
3761
3779
  muteTicket(number: number, muted: boolean, context?: HelpDeskRequestContext): Promise<void>;
@@ -4661,7 +4679,9 @@ declare class VaultsModule {
4661
4679
  *
4662
4680
  * @example
4663
4681
  * const vault = await sv.vaults.create({ name: 'My Vault' });
4664
- * console.log('Save this VMK:', vault.vmk);
4682
+ * // Returned once and never again: hand the VMK to the person who keeps it,
4683
+ * // or to your own secret store. Never log it.
4684
+ * await yourSecretStore.put(`vmk/${vault.id}`, vault.vmk);
4665
4685
  */
4666
4686
  create(options: CreateVaultOptions): Promise<Vault>;
4667
4687
  /**
@@ -4674,7 +4694,9 @@ declare class VaultsModule {
4674
4694
  * @example
4675
4695
  * const unsealed = await sv.vaults.unseal('vlt_abc', vmk);
4676
4696
  * const delegated = await sv.vaults.unseal('vlt_abc', 'dvak_...');
4677
- * console.log('Token:', unsealed.vatToken);
4697
+ * // The unsealed vault carries its VAT: hand it to the ingot and folder
4698
+ * // calls, never to a log.
4699
+ * const page = await sv.ingots.list(unsealed);
4678
4700
  */
4679
4701
  unseal(vaultId: string, key: string, options?: UnsealVaultOptions): Promise<UnsealedVault>;
4680
4702
  /**
package/dist/index.mjs CHANGED
@@ -10861,7 +10861,12 @@ class IdentityModule {
10861
10861
  *
10862
10862
  * @example
10863
10863
  * const result = await sv.products.identity.signIn();
10864
- * console.log(result.token, result.identity);
10864
+ * // Your backend verifies the token before it grants access; never log it.
10865
+ * await fetch('/api/auth/login', {
10866
+ * method: 'POST',
10867
+ * headers: { 'Content-Type': 'application/json' },
10868
+ * body: JSON.stringify({ token: result.token }),
10869
+ * });
10865
10870
  */
10866
10871
  async signIn(options = {}) {
10867
10872
  return this.runFlow(options);
@@ -13094,9 +13099,14 @@ Array.from({ length: 1 << BRAND_BITS.size }, (_, mask) =>
13094
13099
  * histogram's bucket edges live here for the same reason. So do the one rule a tag is stored by
13095
13100
  * (ticketTag), which Core applies where it stores a tag and the console
13096
13101
  * applies where one is typed, and the one rule a typed or pasted sign-in
13097
- * code is read by (helpDeskPinDigits), which every sign-in form applies.
13102
+ * code is read by (helpDeskPinDigits), which every sign-in form applies. So
13103
+ * does the one way a client names a message it sends (newMessageId), which
13104
+ * the portal, the SDK and the console's composer each send their messages
13105
+ * under, and the one rule that a message sent again is the same message
13106
+ * (sameMessage), which keeps its name.
13098
13107
  *
13099
- * BROWSER-SAFE: data and pure functions; its imports are the platform's label
13108
+ * BROWSER-SAFE: data and pure functions, and newMessageId's count of the ids
13109
+ * its page named; its imports are the platform's label
13100
13110
  * rule a tag is built on (./display-text.js), the mail products whose fixed
13101
13111
  * From local parts no team alias may take (./mail-products.js) and the brand
13102
13112
  * rule no team alias may read as (./organization-name.js).
@@ -13207,6 +13217,30 @@ function helpDeskCountdown(seconds) {
13207
13217
  return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, '0')}`;
13208
13218
  }
13209
13219
 
13220
+ /** How many message ids this page has named (newMessageId). */
13221
+ let messagesNamed = 0;
13222
+
13223
+ /**
13224
+ * A new id for a message its client sends: a customer's reply from the
13225
+ * portal or the SDK (`event_id`), a trainee's reply held for review
13226
+ * (`review_id`). The client names a message once and sends every retry of it
13227
+ * under the same id, so a send whose answer was lost and is made again is
13228
+ * answered with what the first send wrote instead of writing it twice.
13229
+ *
13230
+ * Counted, never drawn (docs/CONVENTIONS.md → Randomness: it only has to
13231
+ * differ): the page's time origin, the time it is named and the page's count
13232
+ * of the ids it named, so no two of one author's messages share one. The
13233
+ * server keeps a ticket's ids apart: one another record of the ticket holds
13234
+ * is refused.
13235
+ *
13236
+ * @returns {string} An id of a message event (`@sparkvault/app-sdk/ids` `ticketEvent`)
13237
+ */
13238
+ function newMessageId() {
13239
+ messagesNamed += 1;
13240
+ const origin = Math.round((globalThis.performance?.timeOrigin ?? 0) * 1000);
13241
+ return `hdev_m${origin.toString(36)}-${Date.now().toString(36)}-${messagesNamed.toString(36)}`;
13242
+ }
13243
+
13210
13244
  /**
13211
13245
  * Why a customer's file is refused by the desk's upload allowance per
13212
13246
  * customer (`customer_upload_limit_bytes`), as the 402 QUOTA_EXCEEDED that
@@ -16319,7 +16353,7 @@ function hostname(value) {
16319
16353
  }
16320
16354
  function resource(kind, value, field) {
16321
16355
  if (!isResourceIdOf(kind, value))
16322
- throw new ValidationError(`${field} must be a help desk ${kind} ID`, { field });
16356
+ throw new ValidationError(`${field} must be a help desk ${kind === 'ticketEvent' ? 'message' : kind} ID`, { field });
16323
16357
  return value;
16324
16358
  }
16325
16359
  function requestNumber(value) {
@@ -16791,9 +16825,14 @@ class HelpDeskClient {
16791
16825
  listEvents(number, cursor) {
16792
16826
  return this.send('GET', apiPath `/v1/hd/desks/${this.desk.desk_id}/tickets/${requestNumber(number)}/events`, undefined, { cursor });
16793
16827
  }
16794
- /** Replies have no client idempotency key: reconcile an uncertain response before retrying. */
16828
+ /** A new id for one composed reply, sent as `HelpDeskReplyOptions.eventId` with every send of it while it stands unchanged. */
16829
+ newReplyId() { return newMessageId(); }
16830
+ /** A reply sent under an `eventId` an earlier send of it posted answers that reply, posting nothing again. */
16795
16831
  replyToTicket(number, options, context) {
16796
- return this.send('POST', apiPath `/v1/hd/desks/${this.desk.desk_id}/tickets/${requestNumber(number)}/replies`, { body: options.body, attachments: options.attachments ?? [] }, undefined, true, context);
16832
+ const eventId = options.eventId === undefined ? undefined : resource('ticketEvent', options.eventId, 'eventId');
16833
+ return this.send('POST', apiPath `/v1/hd/desks/${this.desk.desk_id}/tickets/${requestNumber(number)}/replies`, {
16834
+ body: options.body, attachments: options.attachments ?? [], ...(eventId && { event_id: eventId }),
16835
+ }, undefined, true, context);
16797
16836
  }
16798
16837
  resolveTicket(number, context) { return this.send('POST', apiPath `/v1/hd/desks/${this.desk.desk_id}/tickets/${requestNumber(number)}/resolve`, undefined, undefined, true, context); }
16799
16838
  muteTicket(number, muted, context) { return this.send('PUT', apiPath `/v1/hd/desks/${this.desk.desk_id}/tickets/${requestNumber(number)}/mute`, { muted }, undefined, true, context); }
@@ -24914,7 +24953,9 @@ class VaultsModule {
24914
24953
  *
24915
24954
  * @example
24916
24955
  * const vault = await sv.vaults.create({ name: 'My Vault' });
24917
- * console.log('Save this VMK:', vault.vmk);
24956
+ * // Returned once and never again: hand the VMK to the person who keeps it,
24957
+ * // or to your own secret store. Never log it.
24958
+ * await yourSecretStore.put(`vmk/${vault.id}`, vault.vmk);
24918
24959
  */
24919
24960
  async create(options) {
24920
24961
  this.validateCreateOptions(options);
@@ -24938,7 +24979,9 @@ class VaultsModule {
24938
24979
  * @example
24939
24980
  * const unsealed = await sv.vaults.unseal('vlt_abc', vmk);
24940
24981
  * const delegated = await sv.vaults.unseal('vlt_abc', 'dvak_...');
24941
- * console.log('Token:', unsealed.vatToken);
24982
+ * // The unsealed vault carries its VAT: hand it to the ingot and folder
24983
+ * // calls, never to a log.
24984
+ * const page = await sv.ingots.list(unsealed);
24942
24985
  */
24943
24986
  async unseal(vaultId, key, options = {}) {
24944
24987
  const id = requireResourceId(vaultId, 'vaultId');
@@ -26135,7 +26178,7 @@ class SparkVault {
26135
26178
  }
26136
26179
  /** Get the SDK version */
26137
26180
  static get version() {
26138
- return '15.11.4';
26181
+ return '15.11.6';
26139
26182
  }
26140
26183
  }
26141
26184
  if (typeof window !== 'undefined') {