@sparkvault/sdk-js 16.1.1 → 16.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -11612,7 +11612,7 @@ class PendingSignIn {
11612
11612
  constructor(hint) {
11613
11613
  this.hint = hint;
11614
11614
  this.at = 0;
11615
- this.live = true;
11615
+ this.ended = false;
11616
11616
  // Counts the opens and the ends of their popups, so a draw that lands after
11617
11617
  // its popup ended or was replaced is recognised and dropped.
11618
11618
  this.opens = 0;
@@ -11628,6 +11628,10 @@ class PendingSignIn {
11628
11628
  get reference() {
11629
11629
  return this.current;
11630
11630
  }
11631
+ /** False once the sign-in ended: it settled, was closed, or another replaced it. */
11632
+ get live() {
11633
+ return !this.ended;
11634
+ }
11631
11635
  /**
11632
11636
  * A popup opened, or the current one asked again for the reference it
11633
11637
  * lacks: arm the marker holding no reference, and draw this open's own.
@@ -11637,7 +11641,7 @@ class PendingSignIn {
11637
11641
  * rejects.
11638
11642
  */
11639
11643
  open(draw) {
11640
- if (!this.live)
11644
+ if (this.ended)
11641
11645
  return Promise.resolve(false);
11642
11646
  const open = ++this.opens;
11643
11647
  this.at = Date.now();
@@ -11646,7 +11650,7 @@ class PendingSignIn {
11646
11650
  if (!this.write(null))
11647
11651
  removePendingMarker();
11648
11652
  const decided = signinReferenceInTime(draw()).then((reference) => {
11649
- if (!this.live || open !== this.opens)
11653
+ if (this.ended || open !== this.opens)
11650
11654
  return false;
11651
11655
  this.current = reference !== null && this.write(reference) ? reference : null;
11652
11656
  return true;
@@ -11661,7 +11665,7 @@ class PendingSignIn {
11661
11665
  * should it land, is dropped.
11662
11666
  */
11663
11667
  retire() {
11664
- if (!this.live)
11668
+ if (this.ended)
11665
11669
  return;
11666
11670
  this.opens += 1;
11667
11671
  this.current = null;
@@ -11670,7 +11674,7 @@ class PendingSignIn {
11670
11674
  /** The sign-in settled, or another replaced it: retire the marker, and nothing this sign-in does later touches it. */
11671
11675
  end() {
11672
11676
  this.retire();
11673
- this.live = false;
11677
+ this.ended = true;
11674
11678
  }
11675
11679
  /**
11676
11680
  * The current popup's reference, waiting at most `waitMs` for an open still
@@ -12065,7 +12069,7 @@ class IdentityModule {
12065
12069
  const signinRef = await pending.referenceWithin(SIGNIN_REFERENCE.redirectWaitMs);
12066
12070
  if (signinRef === null)
12067
12071
  pending.retire();
12068
- return this.startRedirectFlow(mergedOptions, signinRef);
12072
+ return this.startRedirectFlow(mergedOptions, { signIn: pending, signinRef });
12069
12073
  },
12070
12074
  signinReference: () => pending.reference,
12071
12075
  });
@@ -12323,31 +12327,41 @@ class IdentityModule {
12323
12327
  * 'redirect'`, or a popup whose handle COOP severed. Plain sign-in carries
12324
12328
  * redirect_uri + state + PKCE challenge and returns via the fragment code;
12325
12329
  * OIDC/simple modes navigate without them (their server-rendered pages drive
12326
- * the server-validated redirect back). Either carries `signinRef`, the
12327
- * severed popup's reference; a redirect draws none of its own.
12330
+ * the server-validated redirect back). Either carries the severed popup's
12331
+ * reference; a redirect draws none of its own.
12332
+ *
12333
+ * The return leg is armed first: the check that the sign-in still runs and
12334
+ * the pending marker's removal then share one turn with the navigation, so
12335
+ * no sign-in can start or end between them.
12328
12336
  *
12329
- * @param signinRef - The reference the pending marker holds for this
12330
- * sign-in, or null for a page sent without one
12337
+ * @param severed - The popup sign-in whose severed popup this continues,
12338
+ * with the reference its marker holds for that popup (null for none), or
12339
+ * null for an explicit redirect, which carries none
12331
12340
  * @returns false when the return leg cannot be armed (no session storage or
12332
- * WebCrypto) — the caller surfaces an actionable error instead of a
12333
- * silent dead-end.
12341
+ * WebCrypto), so the caller surfaces an actionable error instead of a
12342
+ * silent dead-end, or when the severed popup's sign-in ended meanwhile.
12334
12343
  */
12335
- async startRedirectFlow(options, signinRef) {
12344
+ async startRedirectFlow(options, severed) {
12345
+ const signinRef = severed?.signinRef ?? null;
12346
+ const authContext = options.authContext;
12347
+ const handoff = authContext?.authRequestId || authContext?.simpleMode?.sessionId
12348
+ ? undefined
12349
+ : await this.armHandoffReturn();
12350
+ if (handoff === null) {
12351
+ return false;
12352
+ }
12353
+ // A popup sign-in that ended meanwhile (the bridge's ✕, close(), or a
12354
+ // signIn() that replaced it) leaves this tab where it is, and leaves
12355
+ // alone the marker of any sign-in that now runs here.
12356
+ if (severed && !severed.signIn.live) {
12357
+ return false;
12358
+ }
12336
12359
  if (signinRef === null) {
12337
12360
  // With no marker, no recovery can stand in for this page's result, so
12338
12361
  // the page needs no reference. A marker left from an earlier sign-in
12339
12362
  // would otherwise bounce on the next load in place of this one.
12340
12363
  removePendingMarker();
12341
12364
  }
12342
- const authContext = options.authContext;
12343
- if (authContext?.authRequestId || authContext?.simpleMode?.sessionId) {
12344
- window.location.assign(buildSigninUrl(this.config, options, { kind: 'redirect', signinRef }));
12345
- return true;
12346
- }
12347
- const handoff = await this.armHandoffReturn();
12348
- if (!handoff) {
12349
- return false;
12350
- }
12351
12365
  window.location.assign(buildSigninUrl(this.config, options, { kind: 'redirect', signinRef, handoff }));
12352
12366
  return true;
12353
12367
  }
@@ -14424,6 +14438,81 @@ const CUSTOMER_UPLOAD_REFUSALS = Object.freeze({
14424
14438
  UPLOADS_OFF: 'customer_uploads_off'
14425
14439
  });
14426
14440
 
14441
+ /**
14442
+ * The roles a member holds on one desk, each granted per desk to a member who
14443
+ * holds Help Desk product access (@sparkvault/app-sdk/product-access): a
14444
+ * Manager runs the desk, an Agent works its tickets, a Trainee works them
14445
+ * with every customer reply approved by a Manager first. No role is no row:
14446
+ * the member does not work the desk.
14447
+ */
14448
+ const HELP_DESK_ROLES = Object.freeze(['manager', 'agent', 'trainee']);
14449
+
14450
+ /**
14451
+ * What each role may do on its desk: the one authorization matrix Core's gates
14452
+ * enforce and the console reads to show what a member may do. Each capability
14453
+ * names the roles that hold it; `admin` true when a company admin holds it with
14454
+ * no role on the desk (an admin who holds a role holds the union); and
14455
+ * `requires_admin` true when holding it takes a company admin as well as one
14456
+ * of its roles. A role is a desk's only while its holder holds Help Desk
14457
+ * product access and is an active member; a Full License is separate and
14458
+ * still licenses every content write (working tickets, approving a reply,
14459
+ * editing the knowledge base).
14460
+ *
14461
+ * see_desk list the desk, read its settings and queues
14462
+ * view_tickets read every ticket of the desk, every queue and untriaged included
14463
+ * work_tickets notes, status, priority, tags, assignment changes, attachments, merges
14464
+ * reply send a customer reply directly (a Trainee's reply becomes a review instead)
14465
+ * submit_reply_for_approval a customer reply is held for a Manager's approval
14466
+ * open_request open a request for a customer with a first message
14467
+ * approve_replies approve or return a held reply (never one's own)
14468
+ * discard_replies end a held reply without sending it
14469
+ * delete_attachments delete a customer's or an operator's file from a ticket
14470
+ * hold_tickets be assigned, mentioned, alerted and balanced-assigned
14471
+ * configure_desk edit the desk's settings, queues, routing, alerts and knowledge base
14472
+ * configure_chat the desk's chat intake and new-ticket chat notifications
14473
+ * assign_roles choose who holds which role on the desk
14474
+ * view_analytics the desk's analytics, its CSV and the operator breakdown
14475
+ * manage_requesters block or unblock a requester
14476
+ * requester_duties export or erase a requester's data
14477
+ * legal_holds place, clear and list legal holds
14478
+ * keep_desk_saved_replies create, change and delete the desk's shared saved replies
14479
+ * keep_queue_saved_replies create a queue's saved replies, and change or delete one's own
14480
+ * keep_others_saved_replies change or delete a saved reply another member wrote
14481
+ * manage_desks create, archive and restore desks; desk capacity
14482
+ * grant_product_access give or remove a member's Help Desk product access
14483
+ *
14484
+ * A Trainee keeps no saved replies: they use every one, and their reply is
14485
+ * reviewed before it reaches a customer, so no text of theirs reaches one
14486
+ * through another operator's reply unreviewed.
14487
+ */
14488
+ const EVERY_ROLE = HELP_DESK_ROLES;
14489
+ const capability = (roles, { admin = false, requiresAdmin = false } = {}) =>
14490
+ Object.freeze({ roles: Object.freeze([...roles]), admin, requires_admin: requiresAdmin });
14491
+ Object.freeze({
14492
+ see_desk: capability(EVERY_ROLE, { admin: true }),
14493
+ view_tickets: capability(EVERY_ROLE),
14494
+ work_tickets: capability(EVERY_ROLE),
14495
+ reply: capability(['manager', 'agent']),
14496
+ submit_reply_for_approval: capability(['trainee']),
14497
+ open_request: capability(['manager', 'agent']),
14498
+ approve_replies: capability(['manager']),
14499
+ discard_replies: capability(['manager']),
14500
+ delete_attachments: capability(['manager']),
14501
+ hold_tickets: capability(EVERY_ROLE),
14502
+ configure_desk: capability(['manager'], { admin: true }),
14503
+ configure_chat: capability([], { admin: true }),
14504
+ assign_roles: capability(['manager'], { admin: true }),
14505
+ view_analytics: capability(['manager']),
14506
+ manage_requesters: capability(['manager']),
14507
+ requester_duties: capability(['manager'], { requiresAdmin: true }),
14508
+ legal_holds: capability(EVERY_ROLE, { requiresAdmin: true }),
14509
+ keep_desk_saved_replies: capability(['manager']),
14510
+ keep_queue_saved_replies: capability(['manager', 'agent']),
14511
+ keep_others_saved_replies: capability(['manager']),
14512
+ manage_desks: capability([], { admin: true }),
14513
+ grant_product_access: capability([], { admin: true })
14514
+ });
14515
+
14427
14516
  /** The longest subject, in characters. */
14428
14517
  const MAX_SUBJECT_LEN = 200;
14429
14518
 
@@ -29458,7 +29547,7 @@ class SparkVault {
29458
29547
  }
29459
29548
  /** Get the SDK version */
29460
29549
  static get version() {
29461
- return '16.1.1';
29550
+ return '16.2.1';
29462
29551
  }
29463
29552
  }
29464
29553
  if (typeof window !== 'undefined') {