@sparkvault/sdk-js 16.12.1 → 17.0.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/README.md CHANGED
@@ -413,14 +413,32 @@ without another login. Anonymous visitors continue to a second step that asks
413
413
  nothing: **Sign in and send** opens the native auth.SV Identity window, which
414
414
  offers the accounts already signed in on the browser or a fresh sign-in, before
415
415
  the request is sent. An inline (`target`) wizard asks before its page is left
416
- with an unsent request. “Switch account” changes only the support account, once
417
- the window answers with one (closing it changes nothing); “Sign out” ends the
416
+ with an unsent request. "Switch account" changes only the support account, once
417
+ the window answers with one (closing it changes nothing); "Sign out" ends the
418
418
  support session without a window and revokes it, even a session the host lent
419
419
  through `getSessionToken`, so a host that lends one must drop it when
420
420
  `onSession` reports `null`. The host website's own login is untouched. Both
421
- suppress website sign-in until “Use website account” is chosen, which is
421
+ suppress website sign-in until "Use website account" is chosen, which is
422
422
  offered once the visitor has switched away from the website account; a Sign
423
- out alone does not offer it. Switch account, Sign out and Use website account
423
+ out alone does not offer it. Use website account releases the switched-to
424
+ session at once, its revocation going behind as a switch's does (a refused or
425
+ lost one reaches `onError`), and reports once, through `onSession`, the
426
+ session the website's identity signs support back in with, or `null` when it
427
+ gives none back, never a signed-out moment between. Past a ticket password or
428
+ employee gate, which the return asks again, it reports nothing at the return
429
+ and then at support's next session lookup: contact's once the gate opens, or a
430
+ reopened support's at the question (`persist`), which asks the website while
431
+ the gate still stands; an employee gate that finds no website account reports
432
+ the employee session it installs instead. A host that lends its own
433
+ session through `getSessionToken` hears nothing, as support goes back to the
434
+ session it lends; one that lends back a switched-to session it kept from
435
+ `onSession` lends none, since support revoked it (the client refuses every
436
+ bearer it let go of, through `getSessionToken` and `setSession` alike), and
437
+ hears `null` once so that it drops it. Headless, `returnToWebsiteAccount()` returns `released` and
438
+ `resumed`, which settle apart. A session the secure window redeems that
439
+ support does not keep (the sign-in was cancelled or support closed while it
440
+ finished, or it served only as an employee proof: a help center's, or a
441
+ ticket gate's while another session stands) is revoked at once. Switch account, Sign out and Use website account
424
442
  each carry idle, unsent summary and details to the next form and remove the
425
443
  previous account's saved copy of the request. Files stay behind: the next form
426
444
  asks for them again, unless Use website account finds no website account. A
@@ -506,6 +524,14 @@ Each desk is discovered from its own hostname and checked against the SDK's
506
524
  configured company account. Add `deskId` to `connect`, `mountForm`, `openForm`,
507
525
  or `attach` to pin an expected desk, for example
508
526
  `{ host: 'subscribers.example.com', deskId: 'hdd_0123456789abcdef0123456789abcdef' }`.
527
+ A page that already holds the desk lookup's answer for its host
528
+ (`GET /v1/hd/desks?host=`), as the hosted portal does, passes it as `desk` to
529
+ any of these or to `createSupport`: the SDK checks it as it checks its own
530
+ lookup's answer, and connecting does not look the desk up again (each contact
531
+ opening still refreshes the desk's ticket access policy through the same
532
+ lookup). `host` is then checked
533
+ as a host name but not compared with the desk, which serves hosts its answer
534
+ does not list (its handle host besides a custom `canonical_host`).
509
535
  Separate clients keep their customer sessions and ticket requests in their own desks.
510
536
 
511
537
  ```typescript
@@ -591,7 +617,29 @@ requester/session without a second login, consent or auth.SV account. Even a
591
617
  verified host email stays contact metadata: host proofs never claim native
592
618
  ticket history or create/link a global SVID. The support widget's optional
593
619
  auth.SV account switch opens a separate native requester and leaves the website
594
- signed in; only “Use website account” resumes the host provider.
620
+ signed in; only "Use website account" resumes the host provider.
621
+
622
+ A custom UI that offers Use website account calls `returnToWebsiteAccount()`.
623
+ The session in use is released at once and the website's identity resumed;
624
+ `released` settles with the revocation apart from the return, and a refused or
625
+ lost one leaves the return made, so handle it:
626
+
627
+ ```typescript
628
+ const { released, resumed } = desk.returnToWebsiteAccount();
629
+ released.catch(reportError); // The return is made either way.
630
+ const session = await resumed; // null for none, a lent session, or a ticket gate still standing.
631
+ ```
632
+
633
+ While a ticket gate stands, `resumed` is null without asking the website: once
634
+ the gate opens, a company host signs back in with `authenticate()` and a host
635
+ that lends its session reads it with `getSessionToken()`. A session the
636
+ client's own `signInWidgetIdentity()` redeemed that the UI does not install
637
+ ends with `discardSession(session)`, a logout carrying only that bearer. One
638
+ Core opened for the client that reaches no one (an invalid answer, a customer
639
+ changed while it was opened, a sign-in that had ended) the client revokes
640
+ itself, reporting a refused or lost revocation to `connect`'s
641
+ `onDiscardError`; the widget and the SDK's forms report those through their
642
+ own `onError`.
595
643
 
596
644
  A host can also supply an existing server-issued desk session through
597
645
  `getSessionToken` or `onAuthRequired`; never construct a session from browser