@sparkvault/sdk-js 16.5.0 → 16.6.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 +17 -8
- package/dist/index.cjs +357 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +62 -16
- package/dist/index.mjs +357 -156
- package/dist/index.mjs.map +1 -1
- package/dist/products/help-desk/client.d.ts +7 -0
- package/dist/products/help-desk/form-composer.d.ts +1 -1
- package/dist/products/help-desk/form-types.d.ts +45 -15
- package/dist/products/help-desk/form.d.ts +16 -6
- package/dist/products/help-desk/support-types.d.ts +8 -0
- package/dist/products/help-desk/widget-identity.d.ts +1 -0
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -14336,15 +14336,16 @@ Array.from({ length: 1 << BRAND_BITS.size }, (_, mask) =>
|
|
|
14336
14336
|
* API prefix, team mail aliases, the attachment ceremony's steps, the
|
|
14337
14337
|
* question a customer's new request asks before it is discarded, session,
|
|
14338
14338
|
* sign-in code (its length, lifetime, sender, resend wait, countdown and
|
|
14339
|
-
* the code step's words),
|
|
14340
|
-
*
|
|
14341
|
-
* the operator
|
|
14342
|
-
*
|
|
14343
|
-
*
|
|
14344
|
-
*
|
|
14345
|
-
*
|
|
14346
|
-
* applies where
|
|
14347
|
-
*
|
|
14339
|
+
* the code step's words), merge and pending-attachment timings, hold
|
|
14340
|
+
* presets, tag and size limits, the operator display and desk mode choices,
|
|
14341
|
+
* the operator queue's views and orders, the reply review list's views and
|
|
14342
|
+
* states, the response-time histogram's bucket edges, the sections of a
|
|
14343
|
+
* desk's settings an address names, and the messages the widget's native
|
|
14344
|
+
* sign-in posts between the website and its first-party page live here for
|
|
14345
|
+
* the same reason. So do the one rule a tag is stored by (ticketTag), which
|
|
14346
|
+
* Core applies where it stores a tag and the console applies where one is
|
|
14347
|
+
* typed, and the one rule a typed or pasted sign-in code is read by
|
|
14348
|
+
* (helpDeskPinDigits), which every sign-in form applies. So
|
|
14348
14349
|
* does the one way a client names a message it sends (newMessageId), which
|
|
14349
14350
|
* the portal, the SDK and the console's composer each send their messages
|
|
14350
14351
|
* under, and the one rule that a message sent again is the same message
|
|
@@ -14369,6 +14370,22 @@ const HELP_DESK_CLOSE_REASONS = Object.freeze(['resolved', 'duplicate', 'spam'])
|
|
|
14369
14370
|
/** The close reasons an operator's status change names: a duplicate closes by merging it into the request it repeats. */
|
|
14370
14371
|
Object.freeze(HELP_DESK_CLOSE_REASONS.filter((reason) => reason !== 'duplicate'));
|
|
14371
14372
|
|
|
14373
|
+
/**
|
|
14374
|
+
* The messages the widget's native sign-in exchanges between the website's
|
|
14375
|
+
* window (the JS SDK's openWidgetIdentity) and the first-party page it opens
|
|
14376
|
+
* on auth.sv (Core's widget-identity-page.js), each posted to the other's
|
|
14377
|
+
* exact origin: the page asks its opener for the challenge's state (`ready`),
|
|
14378
|
+
* the opener answers its own popup alone (`state`), and the page reports the
|
|
14379
|
+
* sign-in's code or its cancellation (`result`). Every message names its
|
|
14380
|
+
* challenge, and the state is never in the page's URL or its server-rendered
|
|
14381
|
+
* context, so only the window that started a challenge can complete it.
|
|
14382
|
+
*/
|
|
14383
|
+
const HELP_DESK_WIDGET_IDENTITY_MESSAGES = Object.freeze({
|
|
14384
|
+
ready: 'sparkvault:help-desk:identity-ready',
|
|
14385
|
+
state: 'sparkvault:help-desk:identity-state',
|
|
14386
|
+
result: 'sparkvault:help-desk:identity'
|
|
14387
|
+
});
|
|
14388
|
+
|
|
14372
14389
|
/**
|
|
14373
14390
|
* Mail local parts no team may take as its alias: the role mailboxes RFC 2142
|
|
14374
14391
|
* names, the addresses mail systems and their operators keep for themselves,
|
|
@@ -17588,7 +17605,17 @@ function openWidgetIdentity(options, prepare, ready, redeem, deskId) {
|
|
|
17588
17605
|
if (!challenge || event.source !== popup || event.origin !== firstPartyOrigin)
|
|
17589
17606
|
return;
|
|
17590
17607
|
const data = event.data;
|
|
17591
|
-
if (!data || data.
|
|
17608
|
+
if (!data || data.challenge_id !== challenge.challenge_id)
|
|
17609
|
+
return;
|
|
17610
|
+
// The first-party page this window opened asks for the challenge's
|
|
17611
|
+
// state, without which Core takes none of its steps: only this popup,
|
|
17612
|
+
// at the first-party origin, is ever answered, so a sign-in link opened
|
|
17613
|
+
// in any other window or browser completes nothing.
|
|
17614
|
+
if (data.type === HELP_DESK_WIDGET_IDENTITY_MESSAGES.ready) {
|
|
17615
|
+
popup.postMessage({ type: HELP_DESK_WIDGET_IDENTITY_MESSAGES.state, challenge_id: challenge.challenge_id, state: challenge.state }, event.origin);
|
|
17616
|
+
return;
|
|
17617
|
+
}
|
|
17618
|
+
if (data.type !== HELP_DESK_WIDGET_IDENTITY_MESSAGES.result || data.state !== challenge.state)
|
|
17592
17619
|
return;
|
|
17593
17620
|
if (data.cancelled === true) {
|
|
17594
17621
|
cancel();
|
|
@@ -18122,7 +18149,7 @@ class HelpDeskClient {
|
|
|
18122
18149
|
// the `federated` mark and the `federated` assurance together, never one without the other.
|
|
18123
18150
|
const customer = result?.customer;
|
|
18124
18151
|
const nativeIdentity = customer?.federated === true ? customer.assurance === 'federated' : customer?.assurance === 'identity';
|
|
18125
|
-
if (!validToken(result?.token) || !nativeIdentity || !/^hdwip_[A-Za-z0-9_-]{43}$/.test(result.identity_grant?.token)) {
|
|
18152
|
+
if (!validToken(result?.token) || !Number.isFinite(result.expires_at) || !nativeIdentity || !/^hdwip_[A-Za-z0-9_-]{43}$/.test(result.identity_grant?.token)) {
|
|
18126
18153
|
throw new SparkVaultError('The help desk returned an invalid support identity.', 'HELP_DESK_INVALID_RESPONSE');
|
|
18127
18154
|
}
|
|
18128
18155
|
this.issuedSessions.set(result, result.token);
|
|
@@ -18134,6 +18161,16 @@ class HelpDeskClient {
|
|
|
18134
18161
|
this.websiteAccountSuppressed = true;
|
|
18135
18162
|
return this.releaseSession(false);
|
|
18136
18163
|
}
|
|
18164
|
+
/**
|
|
18165
|
+
* Sign the customer out of support in this browser: revoke the session, one
|
|
18166
|
+
* a provider lent included, and keep the website's identity from signing
|
|
18167
|
+
* them back in until `useWebsiteAccount`. The session is gone here before
|
|
18168
|
+
* the revocation is answered; the host website's own sign-in is untouched.
|
|
18169
|
+
*/
|
|
18170
|
+
signOutSupport() {
|
|
18171
|
+
this.websiteAccountSuppressed = true;
|
|
18172
|
+
return this.releaseSession(true);
|
|
18173
|
+
}
|
|
18137
18174
|
/** The only operation that resumes the website's configured identity provider after an explicit switch. */
|
|
18138
18175
|
async useWebsiteAccount() {
|
|
18139
18176
|
await this.releaseSession(false);
|
|
@@ -19232,7 +19269,7 @@ function carriesFiles(event) {
|
|
|
19232
19269
|
* refusals as a picked one; the drop target shows only over the composer. A
|
|
19233
19270
|
* paste or drag of text alone stays the browser's. A file brought over the
|
|
19234
19271
|
* form is never the browser's to open in place of the unsent request: on the
|
|
19235
|
-
*
|
|
19272
|
+
* sign-in step, or while the form takes no files, it is refused outright,
|
|
19236
19273
|
* and a desk that takes no files says so when the file is dropped.
|
|
19237
19274
|
*/
|
|
19238
19275
|
function createComposer(options) {
|
|
@@ -19544,6 +19581,11 @@ function postingName(customer) {
|
|
|
19544
19581
|
return words[0];
|
|
19545
19582
|
return `${words[0]} ${Array.from(words[words.length - 1])[0]}.`;
|
|
19546
19583
|
}
|
|
19584
|
+
/** The account row's words for the customer a widget form posts as: "Posting as Alex M.", one full stop either way. */
|
|
19585
|
+
function postingAsText(customer) {
|
|
19586
|
+
const shown = postingName(customer);
|
|
19587
|
+
return `Posting as ${shown}${shown.endsWith('.') ? '' : '.'}`;
|
|
19588
|
+
}
|
|
19547
19589
|
function focusAtEnd(field, focusOptions) {
|
|
19548
19590
|
field.focus(focusOptions);
|
|
19549
19591
|
// An email field has no caret to place.
|
|
@@ -19559,6 +19601,12 @@ function textButton(text, action) {
|
|
|
19559
19601
|
button.addEventListener('click', action);
|
|
19560
19602
|
return button;
|
|
19561
19603
|
}
|
|
19604
|
+
const UNSENT_NOTE_COPY = 'Your request hasn’t been sent yet. Sign in so we know who to reply to, then we’ll send it.';
|
|
19605
|
+
const SIGN_IN_HELP_COPY = 'A secure window opens. Sign in with your email, or continue with an account you’re already signed in to.';
|
|
19606
|
+
const SIGNING_IN_COPY = 'Finish signing in using the secure window.';
|
|
19607
|
+
const SWITCHING_COPY = 'Choose an account in the secure window.';
|
|
19608
|
+
const SIGNED_OUT_COPY = 'You’re signed out of support. What you wrote is still here.';
|
|
19609
|
+
const FILES_AGAIN_COPY = 'Choose your files again before sending.';
|
|
19562
19610
|
const SIGN_IN_CANCELLED_COPY = 'Sign-in was cancelled. Your request is still here and hasn’t been sent.';
|
|
19563
19611
|
const RECOVER_STATUS_COPY = 'Sign in again to recover your saved request.';
|
|
19564
19612
|
const RECOVER_WEBSITE_COPY = 'Sign in to your website account again to recover your saved request.';
|
|
@@ -19629,7 +19677,9 @@ function companySignInUrl(value) {
|
|
|
19629
19677
|
*
|
|
19630
19678
|
* The request is a summary and optional details, in a composer that also
|
|
19631
19679
|
* takes files. A signed-out widget customer writes it as step 1 of 2; step 2
|
|
19632
|
-
* asks
|
|
19680
|
+
* asks nothing, and its one button signs them in, in the native sign-in
|
|
19681
|
+
* window, and sends it. A signed-in one can switch account or sign out
|
|
19682
|
+
* beside the request.
|
|
19633
19683
|
*/
|
|
19634
19684
|
function mountHelpDeskForm(client, options) {
|
|
19635
19685
|
const target = resolveTarget(options.target);
|
|
@@ -19724,9 +19774,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
19724
19774
|
const email = field('Email address', 'email');
|
|
19725
19775
|
const code = field('Email code', 'code');
|
|
19726
19776
|
const name = field('Your name', 'display_name');
|
|
19727
|
-
const
|
|
19728
|
-
const lastName = field('Last name (optional)', 'family_name');
|
|
19729
|
-
const fields = [subject, description, email, code, name, firstName, lastName];
|
|
19777
|
+
const fields = [subject, description, email, code, name];
|
|
19730
19778
|
// The support wizard's issue the form was last filled from, which either
|
|
19731
19779
|
// field may hold; undefined for a form filled from the host's subject and body.
|
|
19732
19780
|
let filledFrom = options.issue;
|
|
@@ -19741,10 +19789,6 @@ function mountHelpDeskForm(client, options) {
|
|
|
19741
19789
|
code.input.inputMode = 'numeric';
|
|
19742
19790
|
code.input.autocomplete = 'one-time-code';
|
|
19743
19791
|
name.input.autocomplete = 'name';
|
|
19744
|
-
firstName.input.autocomplete = 'given-name';
|
|
19745
|
-
lastName.input.autocomplete = 'family-name';
|
|
19746
|
-
firstName.input.maxLength = 100;
|
|
19747
|
-
lastName.input.maxLength = 100;
|
|
19748
19792
|
const codeHint = document.createElement('p');
|
|
19749
19793
|
codeHint.id = `${code.input.id}-hint`;
|
|
19750
19794
|
codeHint.className = 'svhd-hint';
|
|
@@ -19797,16 +19841,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
19797
19841
|
description.wrapper.insertBefore(composer.frame, description.error);
|
|
19798
19842
|
description.wrapper.insertBefore(composer.notice, description.error);
|
|
19799
19843
|
details.append(subject.wrapper, description.wrapper);
|
|
19844
|
+
// What the form asks itself: a missing name, and an emailed code's sign-in,
|
|
19845
|
+
// which the widget leaves to the secure window.
|
|
19800
19846
|
const auth = document.createElement('fieldset');
|
|
19801
19847
|
auth.className = 'svhd-auth';
|
|
19802
19848
|
auth.hidden = true;
|
|
19803
|
-
auth.append(code.wrapper, name.wrapper);
|
|
19849
|
+
auth.append(email.wrapper, code.wrapper, name.wrapper);
|
|
19804
19850
|
const widgetAccount = document.createElement('div');
|
|
19805
19851
|
widgetAccount.className = 'svhd-widget-account';
|
|
19806
19852
|
let widgetCustomer = widget?.customer ?? null;
|
|
19807
|
-
|
|
19808
|
-
const asksName = client.desk.auth_mode !== 'identity';
|
|
19809
|
-
const reply = widget ? stepHead(`${prefix}-reply-heading`, asksName ? 'Who should we reply to?' : 'Sign in to send your request', 'Step 2 of 2') : null;
|
|
19853
|
+
const signInStep = widget ? stepHead(`${prefix}-signin-heading`, 'Sign in to send your request', 'Step 2 of 2') : null;
|
|
19810
19854
|
const identity = widget ? stepContainer('identity') : null;
|
|
19811
19855
|
const recap = document.createElement('div');
|
|
19812
19856
|
recap.className = 'svhd-recap';
|
|
@@ -19816,11 +19860,13 @@ function mountHelpDeskForm(client, options) {
|
|
|
19816
19860
|
enterStep('details'); });
|
|
19817
19861
|
editRequest.setAttribute('aria-label', 'Edit your request');
|
|
19818
19862
|
const noteText = document.createTextNode('');
|
|
19819
|
-
|
|
19820
|
-
|
|
19821
|
-
|
|
19863
|
+
// What the sign-in step's button does, named on that button while the step shows.
|
|
19864
|
+
const signInHelp = document.createElement('p');
|
|
19865
|
+
signInHelp.id = `${prefix}-signin-help`;
|
|
19866
|
+
signInHelp.className = 'svhd-hint';
|
|
19867
|
+
signInHelp.textContent = SIGN_IN_HELP_COPY;
|
|
19822
19868
|
const live = createLiveRegion('svhd-live');
|
|
19823
|
-
if (identity &&
|
|
19869
|
+
if (identity && signInStep) {
|
|
19824
19870
|
form.classList.add('svhd-widget-form');
|
|
19825
19871
|
details.append(widgetAccount);
|
|
19826
19872
|
identity.hidden = true;
|
|
@@ -19835,22 +19881,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
19835
19881
|
recapLabel.textContent = 'Your request';
|
|
19836
19882
|
recapRequest.append(recapLabel, recapText);
|
|
19837
19883
|
recap.append(recapRequest, editRequest);
|
|
19838
|
-
|
|
19839
|
-
helper.id = `${email.input.id}-help`;
|
|
19840
|
-
helper.className = 'svhd-hint';
|
|
19841
|
-
helper.textContent = asksName ? 'We’ll email you a code to confirm it’s you.' : 'You’ll confirm it’s you in a secure SparkVault window.';
|
|
19842
|
-
email.input.setAttribute('aria-describedby', helper.id);
|
|
19843
|
-
identity.append(reply.head, note, recap);
|
|
19844
|
-
if (asksName) {
|
|
19845
|
-
const names = document.createElement('div');
|
|
19846
|
-
names.className = 'svhd-widget-names';
|
|
19847
|
-
names.append(firstName.wrapper, lastName.wrapper);
|
|
19848
|
-
identity.append(names);
|
|
19849
|
-
}
|
|
19850
|
-
identity.append(email.wrapper, helper);
|
|
19884
|
+
identity.append(signInStep.head, note, recap, signInHelp);
|
|
19851
19885
|
}
|
|
19852
|
-
else
|
|
19853
|
-
auth.prepend(email.wrapper);
|
|
19854
19886
|
const status = document.createElement('p');
|
|
19855
19887
|
status.className = 'svhd-status';
|
|
19856
19888
|
status.setAttribute('role', 'status');
|
|
@@ -19942,6 +19974,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
19942
19974
|
let recovery = null;
|
|
19943
19975
|
// The website gave no account back when asked for the hidden request's customer.
|
|
19944
19976
|
let websiteSignedOut = false;
|
|
19977
|
+
// The form is held while the secure window chooses another account: no send is under way.
|
|
19978
|
+
let switchingAccount = false;
|
|
19945
19979
|
function persistDraft() {
|
|
19946
19980
|
if (!options.persist || completed || destroyed)
|
|
19947
19981
|
return;
|
|
@@ -19996,9 +20030,15 @@ function mountHelpDeskForm(client, options) {
|
|
|
19996
20030
|
: 'Your saved request was restored. Review it before sending.');
|
|
19997
20031
|
return true;
|
|
19998
20032
|
}
|
|
20033
|
+
/**
|
|
20034
|
+
* The unsent text an account change carries on to the next form, and
|
|
20035
|
+
* whether the composer held files then, which stay behind. None while a
|
|
20036
|
+
* send is under way, unanswered or done: an account change must not turn an
|
|
20037
|
+
* uncertain send into a fresh request.
|
|
20038
|
+
*/
|
|
19999
20039
|
function safeComposition() {
|
|
20000
|
-
|
|
20001
|
-
|
|
20040
|
+
return pending || uncertainSubmission !== null || completed ? null
|
|
20041
|
+
: { subject: subject.input.value, body: description.input.value, hadFiles: attachments?.hasEntries === true };
|
|
20002
20042
|
}
|
|
20003
20043
|
/** What the send button reads while nothing is in flight. */
|
|
20004
20044
|
function idleLabel() {
|
|
@@ -20008,14 +20048,17 @@ function mountHelpDeskForm(client, options) {
|
|
|
20008
20048
|
return 'Verify and send request';
|
|
20009
20049
|
if (recovery === 'external_sso' && widget)
|
|
20010
20050
|
return 'Use website account';
|
|
20011
|
-
if (recovery !== null
|
|
20051
|
+
if (recovery !== null)
|
|
20012
20052
|
return 'Sign in to recover request';
|
|
20013
|
-
|
|
20053
|
+
if (widget && !widgetCustomer)
|
|
20054
|
+
return step === 'identity' ? 'Sign in and send' : 'Continue';
|
|
20055
|
+
return 'Send request';
|
|
20014
20056
|
}
|
|
20015
20057
|
/**
|
|
20016
20058
|
* The signed-in widget customer writes and sends in one step, posting as
|
|
20017
|
-
* the account named under it
|
|
20018
|
-
*
|
|
20059
|
+
* the account named under it, beside Switch account and, but for a website
|
|
20060
|
+
* account's session, which the website ends, Sign out; a signed-out one
|
|
20061
|
+
* writes the request as step 1 of 2. Either way the form shows the request.
|
|
20019
20062
|
*/
|
|
20020
20063
|
function renderWidgetIdentity() {
|
|
20021
20064
|
if (!widget)
|
|
@@ -20030,12 +20073,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
20030
20073
|
if (widgetCustomer) {
|
|
20031
20074
|
const postingAs = document.createElement('p');
|
|
20032
20075
|
postingAs.className = 'svhd-posting-as';
|
|
20033
|
-
|
|
20034
|
-
|
|
20035
|
-
|
|
20036
|
-
|
|
20037
|
-
|
|
20038
|
-
|
|
20076
|
+
// Switch account opens the sign-in window in this click: nothing may await before it.
|
|
20077
|
+
const switchButton = textButton('Switch account', () => { if (free())
|
|
20078
|
+
void switchAccount(switchButton); });
|
|
20079
|
+
postingAs.append(`${postingAsText(widgetCustomer)} `, switchButton);
|
|
20080
|
+
if (widgetCustomer.assurance !== 'external_sso') {
|
|
20081
|
+
postingAs.append(' ', textButton('Sign out', () => { if (free())
|
|
20082
|
+
widget.signOut(safeComposition()); }));
|
|
20083
|
+
}
|
|
20039
20084
|
widgetAccount.append(postingAs);
|
|
20040
20085
|
}
|
|
20041
20086
|
if (widget.useWebsiteAccount && widget.offerWebsiteAccount) {
|
|
@@ -20050,7 +20095,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20050
20095
|
* The actions and notes for where the request is. While the form hides a
|
|
20051
20096
|
* previous customer's saved request (`recovery`), nothing shows of it, nor
|
|
20052
20097
|
* says it was not sent, since it may be a send whose answer was lost: the
|
|
20053
|
-
* request step's status line says how to get it back and the
|
|
20098
|
+
* request step's status line says how to get it back and the sign-in
|
|
20054
20099
|
* step's note alone speaks there, Start a new request leaves it, and the
|
|
20055
20100
|
* account row is away. A website-account customer's request comes back only
|
|
20056
20101
|
* through that account, so Use website account is its one way on when the
|
|
@@ -20062,7 +20107,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20062
20107
|
startNew.hidden = recovery === null;
|
|
20063
20108
|
widgetAccount.hidden = recovery !== null || widgetAccount.childElementCount === 0;
|
|
20064
20109
|
recap.hidden = recovery !== null;
|
|
20065
|
-
noteText.data = recovery === 'identity' || recovery === 'email_pin' ? RECOVER_NOTE_COPY :
|
|
20110
|
+
noteText.data = recovery === 'identity' || recovery === 'email_pin' ? RECOVER_NOTE_COPY : UNSENT_NOTE_COPY;
|
|
20066
20111
|
if (recovery !== null)
|
|
20067
20112
|
message(step === 'identity' ? '' : recoveryStatus());
|
|
20068
20113
|
}
|
|
@@ -20087,15 +20132,19 @@ function mountHelpDeskForm(client, options) {
|
|
|
20087
20132
|
controller.focusEntry();
|
|
20088
20133
|
}
|
|
20089
20134
|
}
|
|
20090
|
-
/** Show one step, the request or
|
|
20135
|
+
/** Show one step, the request or its sign-in, without moving focus. */
|
|
20091
20136
|
function setStep(next) {
|
|
20092
20137
|
const changed = next !== step;
|
|
20093
20138
|
step = next;
|
|
20094
20139
|
details.hidden = next !== 'details';
|
|
20095
20140
|
if (identity)
|
|
20096
20141
|
identity.hidden = next !== 'identity';
|
|
20097
|
-
if (next === 'identity')
|
|
20142
|
+
if (next === 'identity') {
|
|
20098
20143
|
recapText.textContent = subject.input.value.trim();
|
|
20144
|
+
send.setAttribute('aria-describedby', signInHelp.id);
|
|
20145
|
+
}
|
|
20146
|
+
else
|
|
20147
|
+
send.removeAttribute('aria-describedby');
|
|
20099
20148
|
renderActions();
|
|
20100
20149
|
syncLeaveGuard();
|
|
20101
20150
|
if (changed)
|
|
@@ -20103,9 +20152,11 @@ function mountHelpDeskForm(client, options) {
|
|
|
20103
20152
|
}
|
|
20104
20153
|
/** The customer moves between the steps: the new step's heading takes focus and its place is announced. */
|
|
20105
20154
|
function enterStep(next) {
|
|
20155
|
+
// A notice speaks of the step being left; a hidden saved request's status is the next step's to set again.
|
|
20156
|
+
message('');
|
|
20106
20157
|
setStep(next);
|
|
20107
20158
|
live.announce(next === 'identity' ? 'Step 2 of 2' : 'Step 1 of 2');
|
|
20108
|
-
(next === 'identity' &&
|
|
20159
|
+
(next === 'identity' && signInStep ? signInStep.heading : heading).focus();
|
|
20109
20160
|
}
|
|
20110
20161
|
// An inline wizard, on any host page that gives a `target`, asks before that
|
|
20111
20162
|
// page unloads while the request holds unsent work: leaving would lose it.
|
|
@@ -20163,7 +20214,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20163
20214
|
* in place of anything written.
|
|
20164
20215
|
*/
|
|
20165
20216
|
function disable(disabled) {
|
|
20166
|
-
for (const input of [subject.input, description.input, email.input, code.input, name.input,
|
|
20217
|
+
for (const input of [subject.input, description.input, email.input, code.input, name.input, send, cancel, changeEmail, editRequest, startNew])
|
|
20167
20218
|
input.disabled = disabled;
|
|
20168
20219
|
const held = uncertainSubmission !== null || recovery !== null;
|
|
20169
20220
|
subject.input.readOnly = held;
|
|
@@ -20200,10 +20251,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
20200
20251
|
? 'We may already have received this request. Closing now loses the way to check it.'
|
|
20201
20252
|
: DISCARD_REQUEST_COPY.note;
|
|
20202
20253
|
}
|
|
20203
|
-
/** The field
|
|
20254
|
+
/** The field the request step asks for: the code, name or email the form asks for itself, else the summary. */
|
|
20204
20255
|
function stepField() {
|
|
20205
|
-
if (step === 'identity')
|
|
20206
|
-
return (asksName ? firstName : email).input;
|
|
20207
20256
|
const asked = auth.hidden ? undefined : [code, name, email].find((entry) => !entry.wrapper.hidden);
|
|
20208
20257
|
return (asked ?? subject).input;
|
|
20209
20258
|
}
|
|
@@ -20211,7 +20260,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20211
20260
|
// A press on the modal's backdrop leaves focus on the page body, and
|
|
20212
20261
|
// Keep editing must never hand focus back outside the dialog.
|
|
20213
20262
|
const active = document.activeElement;
|
|
20214
|
-
confirmReturn = active instanceof HTMLElement && shell.container.contains(active) ? active : stepField();
|
|
20263
|
+
confirmReturn = active instanceof HTMLElement && shell.container.contains(active) ? active : step === 'identity' ? send : stepField();
|
|
20215
20264
|
renderConfirmNote();
|
|
20216
20265
|
actions.hidden = true;
|
|
20217
20266
|
confirm.hidden = false;
|
|
@@ -20244,7 +20293,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20244
20293
|
}
|
|
20245
20294
|
/**
|
|
20246
20295
|
* Whether closing now would lose something: a send under way or
|
|
20247
|
-
* unanswered, a code step, a request moved on to
|
|
20296
|
+
* unanswered, a code step, a request moved on to its sign-in step, or
|
|
20248
20297
|
* text and files of the customer's own. The silent company sign-in the
|
|
20249
20298
|
* form runs as it opens (`authenticating`) is no work of the customer's.
|
|
20250
20299
|
*/
|
|
@@ -20346,11 +20395,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20346
20395
|
code.wrapper.hidden = true;
|
|
20347
20396
|
name.wrapper.hidden = true;
|
|
20348
20397
|
auth.hidden = true;
|
|
20349
|
-
|
|
20350
|
-
firstName.input.value = '';
|
|
20351
|
-
lastName.input.value = '';
|
|
20352
|
-
renderWidgetIdentity();
|
|
20353
|
-
}
|
|
20398
|
+
renderWidgetIdentity();
|
|
20354
20399
|
hosted.hidden = true;
|
|
20355
20400
|
draftId = null;
|
|
20356
20401
|
draftPromise = null;
|
|
@@ -20418,6 +20463,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20418
20463
|
restoredFiles = false;
|
|
20419
20464
|
generation += 1;
|
|
20420
20465
|
pending = false;
|
|
20466
|
+
switchingAccount = false;
|
|
20421
20467
|
sessionKnown = false;
|
|
20422
20468
|
if (options.widgetIdentity)
|
|
20423
20469
|
widgetCustomer = null;
|
|
@@ -20537,25 +20583,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
20537
20583
|
}
|
|
20538
20584
|
let widgetSignIn;
|
|
20539
20585
|
if (widget && !widgetCustomer) {
|
|
20540
|
-
// The request is written;
|
|
20586
|
+
// The request is written; signing in to send it is the next step, and
|
|
20541
20587
|
// nothing reaches the network before it.
|
|
20542
20588
|
if (step === 'details') {
|
|
20543
20589
|
enterStep('identity');
|
|
20544
20590
|
return;
|
|
20545
20591
|
}
|
|
20546
|
-
const givenName = asksName ? firstName.input.value.trim() : '';
|
|
20547
|
-
const familyName = asksName ? lastName.input.value.trim() : '';
|
|
20548
|
-
const emailAddress = email.input.value.trim();
|
|
20549
|
-
const invalid = asksName && !givenName ? firstName : !email.input.validity.valid || !emailAddress ? email : null;
|
|
20550
|
-
if (invalid) {
|
|
20551
|
-
setFieldError(invalid, invalid === email ? 'Enter your email address.' : 'Enter your first name.');
|
|
20552
|
-
invalid.input.focus();
|
|
20553
|
-
return;
|
|
20554
|
-
}
|
|
20555
20592
|
// Invoke in the original submit gesture, before any awaited token read:
|
|
20556
20593
|
// the Identity adapter can open its native window without a popup block.
|
|
20557
20594
|
try {
|
|
20558
|
-
widgetSignIn = widget.signIn(
|
|
20595
|
+
widgetSignIn = widget.signIn();
|
|
20559
20596
|
}
|
|
20560
20597
|
catch (failure) {
|
|
20561
20598
|
const error = failure instanceof Error ? failure : new Error('Sign-in could not be opened.');
|
|
@@ -20578,7 +20615,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20578
20615
|
authenticating = true;
|
|
20579
20616
|
authNotification = false;
|
|
20580
20617
|
setState('authenticating');
|
|
20581
|
-
message(
|
|
20618
|
+
message(SIGNING_IN_COPY);
|
|
20582
20619
|
}
|
|
20583
20620
|
let token = await tokenFor(ownGeneration);
|
|
20584
20621
|
if (!alive(ownGeneration))
|
|
@@ -20779,7 +20816,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20779
20816
|
focusAfter = code.input;
|
|
20780
20817
|
}
|
|
20781
20818
|
else if (widgetSignIn && error instanceof SparkVaultError && error.code === 'user_cancelled') {
|
|
20782
|
-
// The request stays on
|
|
20819
|
+
// The request stays on its sign-in step, ready to sign in again;
|
|
20783
20820
|
// a hidden saved request is not here to speak of, so its note alone stays.
|
|
20784
20821
|
if (recovery === null)
|
|
20785
20822
|
message(SIGN_IN_CANCELLED_COPY);
|
|
@@ -20838,6 +20875,84 @@ function mountHelpDeskForm(client, options) {
|
|
|
20838
20875
|
}
|
|
20839
20876
|
}
|
|
20840
20877
|
}
|
|
20878
|
+
/** A request this tab saved, restored as the form mounted, which a carried composition never replaces. */
|
|
20879
|
+
function holdsSavedRequest() {
|
|
20880
|
+
return restoredDraft || restoredAnonymous;
|
|
20881
|
+
}
|
|
20882
|
+
/**
|
|
20883
|
+
* What the form says of the account change it arrives from (`arrived`), once
|
|
20884
|
+
* mounting has restored any saved request: its status line, null to leave
|
|
20885
|
+
* the one mounting set, and what a screen reader hears. A restored saved
|
|
20886
|
+
* request takes the carried text's place, so its own status stands and
|
|
20887
|
+
* nothing is said of the carried request's files.
|
|
20888
|
+
*/
|
|
20889
|
+
function arrival() {
|
|
20890
|
+
const arrived = widget?.arrived;
|
|
20891
|
+
if (!arrived)
|
|
20892
|
+
return null;
|
|
20893
|
+
const placed = !holdsSavedRequest();
|
|
20894
|
+
const files = placed && arrived.droppedFiles ? ` ${FILES_AGAIN_COPY}` : '';
|
|
20895
|
+
if (arrived.from === 'signOut')
|
|
20896
|
+
return { status: placed ? `${SIGNED_OUT_COPY}${files}` : null, announcement: `${SIGNED_OUT_COPY}${files} Step 1 of 2` };
|
|
20897
|
+
if (!widgetCustomer)
|
|
20898
|
+
return null;
|
|
20899
|
+
return { status: files ? FILES_AGAIN_COPY : null, announcement: `${postingAsText(widgetCustomer)}${files}` };
|
|
20900
|
+
}
|
|
20901
|
+
/**
|
|
20902
|
+
* Switch account: the secure window's chooser opens in the customer's
|
|
20903
|
+
* click. This customer stays signed in, the request held in view, until
|
|
20904
|
+
* another account is chosen and a form for it replaces this one. Closing
|
|
20905
|
+
* the window changes nothing; any other failure says why. Either way focus
|
|
20906
|
+
* goes back to `control`.
|
|
20907
|
+
*/
|
|
20908
|
+
async function switchAccount(control) {
|
|
20909
|
+
if (!widget)
|
|
20910
|
+
return;
|
|
20911
|
+
closeConfirm(false);
|
|
20912
|
+
let switched;
|
|
20913
|
+
try {
|
|
20914
|
+
switched = widget.switchAccount(safeComposition());
|
|
20915
|
+
}
|
|
20916
|
+
catch (failure) {
|
|
20917
|
+
const error = failure instanceof Error ? failure : new Error('Sign-in could not be opened.');
|
|
20918
|
+
message(error.message, true);
|
|
20919
|
+
notify$1(options.onError, error);
|
|
20920
|
+
return;
|
|
20921
|
+
}
|
|
20922
|
+
const ownGeneration = generation;
|
|
20923
|
+
pending = true;
|
|
20924
|
+
switchingAccount = true;
|
|
20925
|
+
disable(true);
|
|
20926
|
+
setState('authenticating');
|
|
20927
|
+
message(SWITCHING_COPY);
|
|
20928
|
+
// The status line moves the actions below it.
|
|
20929
|
+
options.onScreenChange?.();
|
|
20930
|
+
try {
|
|
20931
|
+
await switched;
|
|
20932
|
+
}
|
|
20933
|
+
catch (failure) {
|
|
20934
|
+
if (!alive(ownGeneration))
|
|
20935
|
+
return;
|
|
20936
|
+
const error = failure instanceof Error ? failure : new Error('The account could not be switched.');
|
|
20937
|
+
if (error instanceof SparkVaultError && error.code === 'user_cancelled')
|
|
20938
|
+
message('');
|
|
20939
|
+
else {
|
|
20940
|
+
message(error.message, true);
|
|
20941
|
+
notify$1(options.onError, error);
|
|
20942
|
+
}
|
|
20943
|
+
}
|
|
20944
|
+
finally {
|
|
20945
|
+
if (alive(ownGeneration)) {
|
|
20946
|
+
pending = false;
|
|
20947
|
+
switchingAccount = false;
|
|
20948
|
+
setState('editing');
|
|
20949
|
+
disable(false);
|
|
20950
|
+
options.onScreenChange?.();
|
|
20951
|
+
focusAfter = control;
|
|
20952
|
+
focusSettled();
|
|
20953
|
+
}
|
|
20954
|
+
}
|
|
20955
|
+
}
|
|
20841
20956
|
/** Take a typed, pasted or autofilled code as its digits, and send it the moment the last one lands. */
|
|
20842
20957
|
function takeCode(value) {
|
|
20843
20958
|
const digits = helpDeskPinDigits(value);
|
|
@@ -20859,26 +20974,47 @@ function mountHelpDeskForm(client, options) {
|
|
|
20859
20974
|
/** The Cancel path: remove the form, then tell the host the customer closed it. */
|
|
20860
20975
|
function dismiss() {
|
|
20861
20976
|
const discardDraft = uncertainSubmission === null;
|
|
20862
|
-
|
|
20977
|
+
if (!destroyed)
|
|
20978
|
+
teardown(!discardDraft);
|
|
20863
20979
|
if (discardDraft)
|
|
20864
20980
|
forgetDraft();
|
|
20865
20981
|
notify$1(options.onCancel, undefined);
|
|
20866
20982
|
}
|
|
20983
|
+
/** Remove the form and silence it; `save` keeps its request in this tab for the customer it shows. */
|
|
20984
|
+
function teardown(save) {
|
|
20985
|
+
if (save)
|
|
20986
|
+
persistDraft();
|
|
20987
|
+
destroyed = true;
|
|
20988
|
+
generation += 1;
|
|
20989
|
+
stopResendCountdown();
|
|
20990
|
+
attachments?.destroy(completed || uncertainSubmission !== null);
|
|
20991
|
+
composer.destroy();
|
|
20992
|
+
live.destroy();
|
|
20993
|
+
unsubscribe();
|
|
20994
|
+
form.removeEventListener('submit', onSubmit);
|
|
20995
|
+
shell.destroy();
|
|
20996
|
+
setState('destroyed');
|
|
20997
|
+
}
|
|
20867
20998
|
const controller = {
|
|
20868
20999
|
destroy() {
|
|
21000
|
+
if (!destroyed)
|
|
21001
|
+
teardown(true);
|
|
21002
|
+
},
|
|
21003
|
+
leave() {
|
|
20869
21004
|
if (destroyed)
|
|
20870
21005
|
return;
|
|
20871
|
-
|
|
20872
|
-
|
|
20873
|
-
|
|
20874
|
-
|
|
20875
|
-
|
|
20876
|
-
|
|
20877
|
-
|
|
20878
|
-
|
|
20879
|
-
|
|
20880
|
-
|
|
20881
|
-
|
|
21006
|
+
const owner = draftOwner;
|
|
21007
|
+
const sending = pending && !switchingAccount;
|
|
21008
|
+
if (!owner || sending || uncertainSubmission !== null || completed || recovery !== null) {
|
|
21009
|
+
teardown(true);
|
|
21010
|
+
return;
|
|
21011
|
+
}
|
|
21012
|
+
// The request goes on with the account change: this customer's saved copy
|
|
21013
|
+
// must not come back to them over the text as edited since, nor offer the
|
|
21014
|
+
// request a second time.
|
|
21015
|
+
teardown(false);
|
|
21016
|
+
if (options.persist)
|
|
21017
|
+
removeFormDraft(client.desk.desk_id, owner.requester_id);
|
|
20882
21018
|
},
|
|
20883
21019
|
reset() {
|
|
20884
21020
|
if (destroyed || pending || uncertainSubmission)
|
|
@@ -20894,7 +21030,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20894
21030
|
},
|
|
20895
21031
|
getState: () => state,
|
|
20896
21032
|
restoreComposition(composition) {
|
|
20897
|
-
if (destroyed ||
|
|
21033
|
+
if (destroyed || holdsSavedRequest())
|
|
20898
21034
|
return;
|
|
20899
21035
|
subject.input.value = composition.subject;
|
|
20900
21036
|
description.input.value = composition.body;
|
|
@@ -20935,10 +21071,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
20935
21071
|
focusEntry(focusOptions) {
|
|
20936
21072
|
if (destroyed || form.hidden)
|
|
20937
21073
|
return false;
|
|
21074
|
+
if (step === 'identity' && signInStep) {
|
|
21075
|
+
(send.disabled ? signInStep.heading : send).focus(focusOptions);
|
|
21076
|
+
return true;
|
|
21077
|
+
}
|
|
20938
21078
|
const asked = stepField();
|
|
20939
21079
|
const entry = asked === subject.input && subject.input.value.trim() ? description.input : asked;
|
|
20940
21080
|
if (entry.disabled || entry.readOnly)
|
|
20941
|
-
|
|
21081
|
+
heading.focus(focusOptions);
|
|
20942
21082
|
else
|
|
20943
21083
|
focusAtEnd(entry, focusOptions);
|
|
20944
21084
|
return true;
|
|
@@ -20982,9 +21122,6 @@ function mountHelpDeskForm(client, options) {
|
|
|
20982
21122
|
});
|
|
20983
21123
|
send.textContent = idleLabel();
|
|
20984
21124
|
renderWidgetIdentity();
|
|
20985
|
-
// A signed-out widget customer starts on step 1 of 2 with focus in the request.
|
|
20986
|
-
if (widget && !widgetCustomer)
|
|
20987
|
-
live.announce('Step 1 of 2');
|
|
20988
21125
|
if (options.widgetIdentity?.customer) {
|
|
20989
21126
|
restoreDraft(options.widgetIdentity.customer);
|
|
20990
21127
|
disable(false);
|
|
@@ -21005,6 +21142,15 @@ function mountHelpDeskForm(client, options) {
|
|
|
21005
21142
|
restoredAnonymous = true;
|
|
21006
21143
|
}
|
|
21007
21144
|
}
|
|
21145
|
+
const arriving = arrival();
|
|
21146
|
+
if (arriving?.status)
|
|
21147
|
+
message(arriving.status);
|
|
21148
|
+
// A signed-out widget customer starts on step 1 of 2 with focus in the
|
|
21149
|
+
// request; after an account change a screen reader hears where it stands.
|
|
21150
|
+
if (arriving)
|
|
21151
|
+
live.announce(arriving.announcement);
|
|
21152
|
+
else if (widget && !widgetCustomer)
|
|
21153
|
+
live.announce('Step 1 of 2');
|
|
21008
21154
|
syncLeaveGuard();
|
|
21009
21155
|
notify$1(options.onStateChange, state);
|
|
21010
21156
|
// Native company identity starts as the form opens, never from a Connect,
|
|
@@ -23375,7 +23521,6 @@ function injectHelpDeskSupportStyles() {
|
|
|
23375
23521
|
@supports not selector(:has(*)){.svhs-contact-target .svhd-composer:focus-within{outline:2px solid var(--hd-focus,var(--hd-accent-ink,${DS.action}));outline-offset:3px}}
|
|
23376
23522
|
.svhs-panel .svhd-composer-input:focus-visible{outline:none}
|
|
23377
23523
|
.svhs-panel .svhd-composer button:focus-visible{outline-offset:-2px}
|
|
23378
|
-
.svhs-contact-target .svhd-widget-names{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px}
|
|
23379
23524
|
.svhs-contact-target .svhd-widget-form{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
23380
23525
|
/* The request fills the panel: the details step, and in it the composer and its text, take the height the fields leave. */
|
|
23381
23526
|
.svhs-contact-target .svhd-widget-form>[data-contact-step=details]{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
@@ -24726,6 +24871,13 @@ function createHelpDeskSupport(config, options) {
|
|
|
24726
24871
|
// A website-account customer's saved request the next form keeps hidden,
|
|
24727
24872
|
// asked for through the website account, which may give no account back.
|
|
24728
24873
|
let pendingRecovery = null;
|
|
24874
|
+
// The account change the next form arrives from, which it says: a Sign out
|
|
24875
|
+
// to a signed-out form, a Switch account or Use website account to the
|
|
24876
|
+
// account arrived at.
|
|
24877
|
+
let pendingArrival = null;
|
|
24878
|
+
// A chosen account's session is taking the old one's place: the host hears
|
|
24879
|
+
// the new session, never the signed-out moment between the two.
|
|
24880
|
+
let replacingSession = false;
|
|
24729
24881
|
// The issue, as written, that the held composition (the mounted form, the one
|
|
24730
24882
|
// a re-authorized form will take, or the one saved before a reload) was last
|
|
24731
24883
|
// filled from: '' for one filled from none. A form taking that composition is
|
|
@@ -24764,7 +24916,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
24764
24916
|
onBack: () => {
|
|
24765
24917
|
if (destroyed || state.navigationLocked || state.identityPending)
|
|
24766
24918
|
return;
|
|
24767
|
-
// On
|
|
24919
|
+
// On the sign-in step, Back returns to the request it is for.
|
|
24768
24920
|
if (state.stage === 'contact' && !state.ticketAccessRequired && contact?.returnToRequest())
|
|
24769
24921
|
return;
|
|
24770
24922
|
// A held form shows at once while contact still checks access behind it,
|
|
@@ -24842,7 +24994,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
24842
24994
|
throw new Error('Support is closed.');
|
|
24843
24995
|
client = answer;
|
|
24844
24996
|
stopSession = answer.subscribeSession((change) => {
|
|
24845
|
-
if (change.source === 'clear')
|
|
24997
|
+
if (change.source === 'clear' && !replacingSession)
|
|
24846
24998
|
notify(options.onSession, null);
|
|
24847
24999
|
});
|
|
24848
25000
|
kb = new HelpDeskKnowledgeBaseClient(config, answer.desk.desk_id);
|
|
@@ -24973,6 +25125,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
24973
25125
|
requestedArticle = null;
|
|
24974
25126
|
pendingComposition = null;
|
|
24975
25127
|
pendingRecovery = null;
|
|
25128
|
+
pendingArrival = null;
|
|
24976
25129
|
feedbackSequence += 1;
|
|
24977
25130
|
sourceArticleId = undefined;
|
|
24978
25131
|
if (options.persist && client)
|
|
@@ -25138,14 +25291,19 @@ function createHelpDeskSupport(config, options) {
|
|
|
25138
25291
|
if (!client || destroyed)
|
|
25139
25292
|
return;
|
|
25140
25293
|
contactCustomer = customer;
|
|
25294
|
+
anonymous = !customer;
|
|
25141
25295
|
// A customer the website gave back sees their own saved request; none keeps it hidden.
|
|
25142
25296
|
const recovering = customer ? null : pendingRecovery;
|
|
25143
25297
|
pendingRecovery = null;
|
|
25298
|
+
// A Sign out arrives only at a signed-out form, a switch only at an account's.
|
|
25299
|
+
const arrived = pendingArrival && (pendingArrival.from === 'signOut') === !customer ? pendingArrival : null;
|
|
25300
|
+
pendingArrival = null;
|
|
25144
25301
|
let activeAttempt = null;
|
|
25145
25302
|
// A ticket carries the attempt the form opened under only while it is still
|
|
25146
25303
|
// the journey's: recovery drops it with the previous customer's question.
|
|
25147
25304
|
const formAttempt = attempt;
|
|
25148
|
-
|
|
25305
|
+
// A host that keeps the session this journey proves has no website account behind it to go back to.
|
|
25306
|
+
const bridged = !options.hostKeepsSession && Boolean(options.getSessionToken || options.getIdentityAssertion || options.identityEndpoint);
|
|
25149
25307
|
contact = mountHelpDeskForm(client, {
|
|
25150
25308
|
target: view.contactTarget,
|
|
25151
25309
|
// Filled from the issue its composition came from, so text the customer
|
|
@@ -25163,13 +25321,15 @@ function createHelpDeskSupport(config, options) {
|
|
|
25163
25321
|
},
|
|
25164
25322
|
widgetIdentity: {
|
|
25165
25323
|
customer,
|
|
25166
|
-
signIn: (
|
|
25167
|
-
switchAccount
|
|
25324
|
+
signIn: () => signIn().then((session) => { contactCustomer = session.customer; return session; }),
|
|
25325
|
+
switchAccount,
|
|
25326
|
+
signOut,
|
|
25168
25327
|
...(bridged && { useWebsiteAccount: (safe, recover) => { void useWebsiteAccount(safe, recover); } }),
|
|
25169
25328
|
offerWebsiteAccount: switchedAccount,
|
|
25170
25329
|
forgetIssue,
|
|
25171
25330
|
followIssue,
|
|
25172
25331
|
...(recovering && { recovering }),
|
|
25332
|
+
...(arrived && { arrived }),
|
|
25173
25333
|
},
|
|
25174
25334
|
onScreenChange: () => view.contactScreenChanged(),
|
|
25175
25335
|
assistanceContext: () => (attempt === formAttempt ? activeAttempt?.ticketContext() : undefined),
|
|
@@ -25283,7 +25443,6 @@ function createHelpDeskSupport(config, options) {
|
|
|
25283
25443
|
if (destroyed || ownSequence !== sequence)
|
|
25284
25444
|
return;
|
|
25285
25445
|
update({ busy: false, ticketAccessRequired: false, ticketAccessMode: undefined });
|
|
25286
|
-
anonymous = !customer;
|
|
25287
25446
|
// A composition saved before a reload goes on from the issue it was filled
|
|
25288
25447
|
// from; with none carried, the form fills itself from the issue as written.
|
|
25289
25448
|
const saved = pendingComposition === null && options.persist ? readAnonymousFormDraft(active.desk.desk_id) : null;
|
|
@@ -25347,78 +25506,120 @@ function createHelpDeskSupport(config, options) {
|
|
|
25347
25506
|
notify(options.onError, error);
|
|
25348
25507
|
}
|
|
25349
25508
|
}
|
|
25350
|
-
|
|
25351
|
-
|
|
25352
|
-
|
|
25353
|
-
|
|
25354
|
-
|
|
25355
|
-
|
|
25509
|
+
/**
|
|
25510
|
+
* Forget what the leaving customer's form led to before another account, or
|
|
25511
|
+
* none, takes its place: the form itself, the articles and the help center
|
|
25512
|
+
* access it opened. Only `composition`'s unsent text goes on to the next
|
|
25513
|
+
* form, which the leaving form's saved copy then no longer stands for
|
|
25514
|
+
* (`leave`); files and uncertain sends keep their requester boundary.
|
|
25515
|
+
*/
|
|
25516
|
+
function leaveCustomer(composition) {
|
|
25517
|
+
if (composition)
|
|
25518
|
+
contact?.leave();
|
|
25519
|
+
else
|
|
25520
|
+
contact?.destroy();
|
|
25356
25521
|
contact = null;
|
|
25522
|
+
contactCustomer = null;
|
|
25357
25523
|
cancelArticleAssets?.();
|
|
25358
25524
|
cancelArticleAssets = null;
|
|
25359
|
-
pendingComposition = composition
|
|
25525
|
+
pendingComposition = composition ? { subject: composition.subject, body: composition.body } : { subject: '', body: '' };
|
|
25360
25526
|
pendingRecovery = null;
|
|
25527
|
+
pendingArrival = null;
|
|
25361
25528
|
kb?.clearAccess();
|
|
25362
25529
|
kbConfig = null;
|
|
25363
25530
|
results = [];
|
|
25364
25531
|
requestedArticle = null;
|
|
25365
25532
|
attempt = null;
|
|
25366
25533
|
sourceArticleId = undefined;
|
|
25367
|
-
|
|
25368
|
-
|
|
25369
|
-
|
|
25370
|
-
|
|
25371
|
-
|
|
25372
|
-
|
|
25373
|
-
|
|
25374
|
-
|
|
25375
|
-
|
|
25534
|
+
}
|
|
25535
|
+
/**
|
|
25536
|
+
* Switch account from the contact form: auth.sv's chooser opens in this
|
|
25537
|
+
* gesture, the current session staying current until another account's is
|
|
25538
|
+
* redeemed. A window that closes or fails rejects, nothing changed, for the
|
|
25539
|
+
* form to say so; a redeemed session takes the old one's place.
|
|
25540
|
+
*/
|
|
25541
|
+
function switchAccount(composition) {
|
|
25542
|
+
const form = contact;
|
|
25543
|
+
const policy = client?.ticketAccessPolicy;
|
|
25544
|
+
// Open synchronously in the Switch account gesture, before anything is awaited.
|
|
25545
|
+
return signIn({ selectAccount: true, employeeCompanyId: policy?.mode === 'identity' ? policy.company_id : undefined }).then((session) => {
|
|
25546
|
+
// The form that asked has left (support destroyed or the journey reset): nothing waits on this account.
|
|
25547
|
+
if (destroyed || !client || contact !== form)
|
|
25376
25548
|
return;
|
|
25377
|
-
|
|
25549
|
+
return replaceAccount(client, session, composition);
|
|
25550
|
+
});
|
|
25551
|
+
}
|
|
25552
|
+
/**
|
|
25553
|
+
* Put a chosen account's redeemed session in the old one's place: the old
|
|
25554
|
+
* one is released as `switchSupportAccount` releases it (the website's
|
|
25555
|
+
* identity suppressed, a lent session never revoked), and a form for the new
|
|
25556
|
+
* customer takes the unsent text.
|
|
25557
|
+
*/
|
|
25558
|
+
async function replaceAccount(active, session, composition) {
|
|
25559
|
+
const ownSequence = ++sequence;
|
|
25560
|
+
leaveCustomer(composition);
|
|
25561
|
+
switchedAccount = true;
|
|
25562
|
+
pendingArrival = { from: 'switch', droppedFiles: composition?.hadFiles === true };
|
|
25563
|
+
update({ stage: 'contact', busy: true, error: undefined, results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
25564
|
+
// The release clears the old session at once, before its revocation is sent.
|
|
25565
|
+
replacingSession = true;
|
|
25566
|
+
const released = active.switchSupportAccount();
|
|
25567
|
+
replacingSession = false;
|
|
25568
|
+
// A refused or lost revocation leaves the chosen account in place.
|
|
25569
|
+
void released.catch((value) => notify(options.onError, failure(value)));
|
|
25570
|
+
active.setSession(session);
|
|
25571
|
+
notify(options.onSession, session);
|
|
25572
|
+
if (active.ticketAccessPolicy?.mode === 'identity') {
|
|
25573
|
+
// Without this grant, contact's access check shows the employee gate for the chosen account.
|
|
25574
|
+
try {
|
|
25378
25575
|
notify(options.onTicketAccess, await active.unlockTicketAccess({ identityGrant: session.identity_grant.token }));
|
|
25379
|
-
if (destroyed || ownSequence !== sequence)
|
|
25380
|
-
return;
|
|
25381
|
-
active.setSession(session);
|
|
25382
|
-
notify(options.onSession, session);
|
|
25383
|
-
update({ busy: false });
|
|
25384
|
-
await showContact('direct');
|
|
25385
|
-
}
|
|
25386
|
-
catch (value) {
|
|
25387
|
-
await logout.catch(() => undefined);
|
|
25388
|
-
if (destroyed || ownSequence !== sequence)
|
|
25389
|
-
return;
|
|
25390
|
-
const error = failure(value);
|
|
25391
|
-
update({ busy: false, error: error.message });
|
|
25392
|
-
if (active.hasTicketAccess) {
|
|
25393
|
-
mountContact(composition ?? { subject: '', body: '' }, null);
|
|
25394
|
-
pendingComposition = null;
|
|
25395
25576
|
}
|
|
25396
|
-
|
|
25397
|
-
|
|
25577
|
+
catch (value) {
|
|
25578
|
+
if (!destroyed && ownSequence === sequence)
|
|
25579
|
+
notify(options.onError, failure(value));
|
|
25580
|
+
}
|
|
25398
25581
|
}
|
|
25582
|
+
if (destroyed || ownSequence !== sequence)
|
|
25583
|
+
return;
|
|
25584
|
+
await showContact('direct');
|
|
25585
|
+
}
|
|
25586
|
+
/**
|
|
25587
|
+
* Sign out of support from the contact form, without a window: the session
|
|
25588
|
+
* ends at once, even one the host lent, its revocation sent behind, and a
|
|
25589
|
+
* signed-out form takes the unsent text. A website account the customer
|
|
25590
|
+
* switched away from still stands behind it (`switchedAccount` is kept).
|
|
25591
|
+
*/
|
|
25592
|
+
function signOut(composition) {
|
|
25593
|
+
if (!client || destroyed || state.navigationLocked)
|
|
25594
|
+
return;
|
|
25595
|
+
const active = client;
|
|
25596
|
+
sequence += 1;
|
|
25597
|
+
leaveCustomer(composition);
|
|
25598
|
+
pendingArrival = { from: 'signOut', droppedFiles: composition?.hadFiles === true };
|
|
25599
|
+
update({ error: undefined, results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
25600
|
+
// The session ends here at once, and the host hears so; a refused or lost
|
|
25601
|
+
// revocation leaves this browser signed out all the same.
|
|
25602
|
+
void active.signOutSupport().catch((value) => notify(options.onError, failure(value)));
|
|
25603
|
+
// A host that keeps the session cleans up after it as its own sign-out does.
|
|
25604
|
+
const host = options.hostKeepsSession;
|
|
25605
|
+
notify(host ? () => host.onSignOut() : undefined, undefined);
|
|
25606
|
+
void showContact('direct');
|
|
25399
25607
|
}
|
|
25400
25608
|
async function useWebsiteAccount(composition, recovering = false) {
|
|
25401
25609
|
if (!client || destroyed || state.navigationLocked)
|
|
25402
25610
|
return;
|
|
25403
25611
|
const ownSequence = ++sequence;
|
|
25404
|
-
|
|
25405
|
-
contact = null;
|
|
25406
|
-
cancelArticleAssets?.();
|
|
25407
|
-
cancelArticleAssets = null;
|
|
25408
|
-
pendingComposition = composition ?? { subject: '', body: '' };
|
|
25612
|
+
leaveCustomer(composition);
|
|
25409
25613
|
pendingRecovery = recovering ? { websiteSignedOut: true } : null;
|
|
25410
|
-
kb?.clearAccess();
|
|
25411
|
-
kbConfig = null;
|
|
25412
|
-
results = [];
|
|
25413
|
-
requestedArticle = null;
|
|
25414
|
-
attempt = null;
|
|
25415
|
-
sourceArticleId = undefined;
|
|
25416
25614
|
update({ busy: true, error: undefined, results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
25417
25615
|
try {
|
|
25418
25616
|
await client.useWebsiteAccount();
|
|
25419
25617
|
if (destroyed || ownSequence !== sequence)
|
|
25420
25618
|
return;
|
|
25421
25619
|
switchedAccount = false;
|
|
25620
|
+
// The website account the form arrives at says so, as a switch does; one
|
|
25621
|
+
// the website does not give back gets none (`mountContact`).
|
|
25622
|
+
pendingArrival = { from: 'switch', droppedFiles: composition?.hadFiles === true };
|
|
25422
25623
|
update({ busy: false });
|
|
25423
25624
|
await showContact('direct');
|
|
25424
25625
|
}
|
|
@@ -25431,7 +25632,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
25431
25632
|
if (pendingRecovery)
|
|
25432
25633
|
pendingRecovery = { websiteSignedOut: false };
|
|
25433
25634
|
if (client.hasTicketAccess) {
|
|
25434
|
-
mountContact(
|
|
25635
|
+
mountContact(pendingComposition, null);
|
|
25435
25636
|
pendingComposition = null;
|
|
25436
25637
|
}
|
|
25437
25638
|
else
|
|
@@ -30244,7 +30445,7 @@ class SparkVault {
|
|
|
30244
30445
|
}
|
|
30245
30446
|
/** Get the SDK version */
|
|
30246
30447
|
static get version() {
|
|
30247
|
-
return '16.
|
|
30448
|
+
return '16.6.0';
|
|
30248
30449
|
}
|
|
30249
30450
|
}
|
|
30250
30451
|
if (typeof window !== 'undefined') {
|