@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.cjs
CHANGED
|
@@ -14340,15 +14340,16 @@ Array.from({ length: 1 << BRAND_BITS.size }, (_, mask) =>
|
|
|
14340
14340
|
* API prefix, team mail aliases, the attachment ceremony's steps, the
|
|
14341
14341
|
* question a customer's new request asks before it is discarded, session,
|
|
14342
14342
|
* sign-in code (its length, lifetime, sender, resend wait, countdown and
|
|
14343
|
-
* the code step's words),
|
|
14344
|
-
*
|
|
14345
|
-
* the operator
|
|
14346
|
-
*
|
|
14347
|
-
*
|
|
14348
|
-
*
|
|
14349
|
-
*
|
|
14350
|
-
* applies where
|
|
14351
|
-
*
|
|
14343
|
+
* the code step's words), merge and pending-attachment timings, hold
|
|
14344
|
+
* presets, tag and size limits, the operator display and desk mode choices,
|
|
14345
|
+
* the operator queue's views and orders, the reply review list's views and
|
|
14346
|
+
* states, the response-time histogram's bucket edges, the sections of a
|
|
14347
|
+
* desk's settings an address names, and the messages the widget's native
|
|
14348
|
+
* sign-in posts between the website and its first-party page live here for
|
|
14349
|
+
* the same reason. So do the one rule a tag is stored by (ticketTag), which
|
|
14350
|
+
* Core applies where it stores a tag and the console applies where one is
|
|
14351
|
+
* typed, and the one rule a typed or pasted sign-in code is read by
|
|
14352
|
+
* (helpDeskPinDigits), which every sign-in form applies. So
|
|
14352
14353
|
* does the one way a client names a message it sends (newMessageId), which
|
|
14353
14354
|
* the portal, the SDK and the console's composer each send their messages
|
|
14354
14355
|
* under, and the one rule that a message sent again is the same message
|
|
@@ -14373,6 +14374,22 @@ const HELP_DESK_CLOSE_REASONS = Object.freeze(['resolved', 'duplicate', 'spam'])
|
|
|
14373
14374
|
/** The close reasons an operator's status change names: a duplicate closes by merging it into the request it repeats. */
|
|
14374
14375
|
Object.freeze(HELP_DESK_CLOSE_REASONS.filter((reason) => reason !== 'duplicate'));
|
|
14375
14376
|
|
|
14377
|
+
/**
|
|
14378
|
+
* The messages the widget's native sign-in exchanges between the website's
|
|
14379
|
+
* window (the JS SDK's openWidgetIdentity) and the first-party page it opens
|
|
14380
|
+
* on auth.sv (Core's widget-identity-page.js), each posted to the other's
|
|
14381
|
+
* exact origin: the page asks its opener for the challenge's state (`ready`),
|
|
14382
|
+
* the opener answers its own popup alone (`state`), and the page reports the
|
|
14383
|
+
* sign-in's code or its cancellation (`result`). Every message names its
|
|
14384
|
+
* challenge, and the state is never in the page's URL or its server-rendered
|
|
14385
|
+
* context, so only the window that started a challenge can complete it.
|
|
14386
|
+
*/
|
|
14387
|
+
const HELP_DESK_WIDGET_IDENTITY_MESSAGES = Object.freeze({
|
|
14388
|
+
ready: 'sparkvault:help-desk:identity-ready',
|
|
14389
|
+
state: 'sparkvault:help-desk:identity-state',
|
|
14390
|
+
result: 'sparkvault:help-desk:identity'
|
|
14391
|
+
});
|
|
14392
|
+
|
|
14376
14393
|
/**
|
|
14377
14394
|
* Mail local parts no team may take as its alias: the role mailboxes RFC 2142
|
|
14378
14395
|
* names, the addresses mail systems and their operators keep for themselves,
|
|
@@ -17592,7 +17609,17 @@ function openWidgetIdentity(options, prepare, ready, redeem, deskId) {
|
|
|
17592
17609
|
if (!challenge || event.source !== popup || event.origin !== firstPartyOrigin)
|
|
17593
17610
|
return;
|
|
17594
17611
|
const data = event.data;
|
|
17595
|
-
if (!data || data.
|
|
17612
|
+
if (!data || data.challenge_id !== challenge.challenge_id)
|
|
17613
|
+
return;
|
|
17614
|
+
// The first-party page this window opened asks for the challenge's
|
|
17615
|
+
// state, without which Core takes none of its steps: only this popup,
|
|
17616
|
+
// at the first-party origin, is ever answered, so a sign-in link opened
|
|
17617
|
+
// in any other window or browser completes nothing.
|
|
17618
|
+
if (data.type === HELP_DESK_WIDGET_IDENTITY_MESSAGES.ready) {
|
|
17619
|
+
popup.postMessage({ type: HELP_DESK_WIDGET_IDENTITY_MESSAGES.state, challenge_id: challenge.challenge_id, state: challenge.state }, event.origin);
|
|
17620
|
+
return;
|
|
17621
|
+
}
|
|
17622
|
+
if (data.type !== HELP_DESK_WIDGET_IDENTITY_MESSAGES.result || data.state !== challenge.state)
|
|
17596
17623
|
return;
|
|
17597
17624
|
if (data.cancelled === true) {
|
|
17598
17625
|
cancel();
|
|
@@ -18126,7 +18153,7 @@ class HelpDeskClient {
|
|
|
18126
18153
|
// the `federated` mark and the `federated` assurance together, never one without the other.
|
|
18127
18154
|
const customer = result?.customer;
|
|
18128
18155
|
const nativeIdentity = customer?.federated === true ? customer.assurance === 'federated' : customer?.assurance === 'identity';
|
|
18129
|
-
if (!validToken(result?.token) || !nativeIdentity || !/^hdwip_[A-Za-z0-9_-]{43}$/.test(result.identity_grant?.token)) {
|
|
18156
|
+
if (!validToken(result?.token) || !Number.isFinite(result.expires_at) || !nativeIdentity || !/^hdwip_[A-Za-z0-9_-]{43}$/.test(result.identity_grant?.token)) {
|
|
18130
18157
|
throw new SparkVaultError('The help desk returned an invalid support identity.', 'HELP_DESK_INVALID_RESPONSE');
|
|
18131
18158
|
}
|
|
18132
18159
|
this.issuedSessions.set(result, result.token);
|
|
@@ -18138,6 +18165,16 @@ class HelpDeskClient {
|
|
|
18138
18165
|
this.websiteAccountSuppressed = true;
|
|
18139
18166
|
return this.releaseSession(false);
|
|
18140
18167
|
}
|
|
18168
|
+
/**
|
|
18169
|
+
* Sign the customer out of support in this browser: revoke the session, one
|
|
18170
|
+
* a provider lent included, and keep the website's identity from signing
|
|
18171
|
+
* them back in until `useWebsiteAccount`. The session is gone here before
|
|
18172
|
+
* the revocation is answered; the host website's own sign-in is untouched.
|
|
18173
|
+
*/
|
|
18174
|
+
signOutSupport() {
|
|
18175
|
+
this.websiteAccountSuppressed = true;
|
|
18176
|
+
return this.releaseSession(true);
|
|
18177
|
+
}
|
|
18141
18178
|
/** The only operation that resumes the website's configured identity provider after an explicit switch. */
|
|
18142
18179
|
async useWebsiteAccount() {
|
|
18143
18180
|
await this.releaseSession(false);
|
|
@@ -19236,7 +19273,7 @@ function carriesFiles(event) {
|
|
|
19236
19273
|
* refusals as a picked one; the drop target shows only over the composer. A
|
|
19237
19274
|
* paste or drag of text alone stays the browser's. A file brought over the
|
|
19238
19275
|
* form is never the browser's to open in place of the unsent request: on the
|
|
19239
|
-
*
|
|
19276
|
+
* sign-in step, or while the form takes no files, it is refused outright,
|
|
19240
19277
|
* and a desk that takes no files says so when the file is dropped.
|
|
19241
19278
|
*/
|
|
19242
19279
|
function createComposer(options) {
|
|
@@ -19548,6 +19585,11 @@ function postingName(customer) {
|
|
|
19548
19585
|
return words[0];
|
|
19549
19586
|
return `${words[0]} ${Array.from(words[words.length - 1])[0]}.`;
|
|
19550
19587
|
}
|
|
19588
|
+
/** The account row's words for the customer a widget form posts as: "Posting as Alex M.", one full stop either way. */
|
|
19589
|
+
function postingAsText(customer) {
|
|
19590
|
+
const shown = postingName(customer);
|
|
19591
|
+
return `Posting as ${shown}${shown.endsWith('.') ? '' : '.'}`;
|
|
19592
|
+
}
|
|
19551
19593
|
function focusAtEnd(field, focusOptions) {
|
|
19552
19594
|
field.focus(focusOptions);
|
|
19553
19595
|
// An email field has no caret to place.
|
|
@@ -19563,6 +19605,12 @@ function textButton(text, action) {
|
|
|
19563
19605
|
button.addEventListener('click', action);
|
|
19564
19606
|
return button;
|
|
19565
19607
|
}
|
|
19608
|
+
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.';
|
|
19609
|
+
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.';
|
|
19610
|
+
const SIGNING_IN_COPY = 'Finish signing in using the secure window.';
|
|
19611
|
+
const SWITCHING_COPY = 'Choose an account in the secure window.';
|
|
19612
|
+
const SIGNED_OUT_COPY = 'You’re signed out of support. What you wrote is still here.';
|
|
19613
|
+
const FILES_AGAIN_COPY = 'Choose your files again before sending.';
|
|
19566
19614
|
const SIGN_IN_CANCELLED_COPY = 'Sign-in was cancelled. Your request is still here and hasn’t been sent.';
|
|
19567
19615
|
const RECOVER_STATUS_COPY = 'Sign in again to recover your saved request.';
|
|
19568
19616
|
const RECOVER_WEBSITE_COPY = 'Sign in to your website account again to recover your saved request.';
|
|
@@ -19633,7 +19681,9 @@ function companySignInUrl(value) {
|
|
|
19633
19681
|
*
|
|
19634
19682
|
* The request is a summary and optional details, in a composer that also
|
|
19635
19683
|
* takes files. A signed-out widget customer writes it as step 1 of 2; step 2
|
|
19636
|
-
* asks
|
|
19684
|
+
* asks nothing, and its one button signs them in, in the native sign-in
|
|
19685
|
+
* window, and sends it. A signed-in one can switch account or sign out
|
|
19686
|
+
* beside the request.
|
|
19637
19687
|
*/
|
|
19638
19688
|
function mountHelpDeskForm(client, options) {
|
|
19639
19689
|
const target = resolveTarget(options.target);
|
|
@@ -19728,9 +19778,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
19728
19778
|
const email = field('Email address', 'email');
|
|
19729
19779
|
const code = field('Email code', 'code');
|
|
19730
19780
|
const name = field('Your name', 'display_name');
|
|
19731
|
-
const
|
|
19732
|
-
const lastName = field('Last name (optional)', 'family_name');
|
|
19733
|
-
const fields = [subject, description, email, code, name, firstName, lastName];
|
|
19781
|
+
const fields = [subject, description, email, code, name];
|
|
19734
19782
|
// The support wizard's issue the form was last filled from, which either
|
|
19735
19783
|
// field may hold; undefined for a form filled from the host's subject and body.
|
|
19736
19784
|
let filledFrom = options.issue;
|
|
@@ -19745,10 +19793,6 @@ function mountHelpDeskForm(client, options) {
|
|
|
19745
19793
|
code.input.inputMode = 'numeric';
|
|
19746
19794
|
code.input.autocomplete = 'one-time-code';
|
|
19747
19795
|
name.input.autocomplete = 'name';
|
|
19748
|
-
firstName.input.autocomplete = 'given-name';
|
|
19749
|
-
lastName.input.autocomplete = 'family-name';
|
|
19750
|
-
firstName.input.maxLength = 100;
|
|
19751
|
-
lastName.input.maxLength = 100;
|
|
19752
19796
|
const codeHint = document.createElement('p');
|
|
19753
19797
|
codeHint.id = `${code.input.id}-hint`;
|
|
19754
19798
|
codeHint.className = 'svhd-hint';
|
|
@@ -19801,16 +19845,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
19801
19845
|
description.wrapper.insertBefore(composer.frame, description.error);
|
|
19802
19846
|
description.wrapper.insertBefore(composer.notice, description.error);
|
|
19803
19847
|
details.append(subject.wrapper, description.wrapper);
|
|
19848
|
+
// What the form asks itself: a missing name, and an emailed code's sign-in,
|
|
19849
|
+
// which the widget leaves to the secure window.
|
|
19804
19850
|
const auth = document.createElement('fieldset');
|
|
19805
19851
|
auth.className = 'svhd-auth';
|
|
19806
19852
|
auth.hidden = true;
|
|
19807
|
-
auth.append(code.wrapper, name.wrapper);
|
|
19853
|
+
auth.append(email.wrapper, code.wrapper, name.wrapper);
|
|
19808
19854
|
const widgetAccount = document.createElement('div');
|
|
19809
19855
|
widgetAccount.className = 'svhd-widget-account';
|
|
19810
19856
|
let widgetCustomer = widget?.customer ?? null;
|
|
19811
|
-
|
|
19812
|
-
const asksName = client.desk.auth_mode !== 'identity';
|
|
19813
|
-
const reply = widget ? stepHead(`${prefix}-reply-heading`, asksName ? 'Who should we reply to?' : 'Sign in to send your request', 'Step 2 of 2') : null;
|
|
19857
|
+
const signInStep = widget ? stepHead(`${prefix}-signin-heading`, 'Sign in to send your request', 'Step 2 of 2') : null;
|
|
19814
19858
|
const identity = widget ? stepContainer('identity') : null;
|
|
19815
19859
|
const recap = document.createElement('div');
|
|
19816
19860
|
recap.className = 'svhd-recap';
|
|
@@ -19820,11 +19864,13 @@ function mountHelpDeskForm(client, options) {
|
|
|
19820
19864
|
enterStep('details'); });
|
|
19821
19865
|
editRequest.setAttribute('aria-label', 'Edit your request');
|
|
19822
19866
|
const noteText = document.createTextNode('');
|
|
19823
|
-
|
|
19824
|
-
|
|
19825
|
-
|
|
19867
|
+
// What the sign-in step's button does, named on that button while the step shows.
|
|
19868
|
+
const signInHelp = document.createElement('p');
|
|
19869
|
+
signInHelp.id = `${prefix}-signin-help`;
|
|
19870
|
+
signInHelp.className = 'svhd-hint';
|
|
19871
|
+
signInHelp.textContent = SIGN_IN_HELP_COPY;
|
|
19826
19872
|
const live = createLiveRegion('svhd-live');
|
|
19827
|
-
if (identity &&
|
|
19873
|
+
if (identity && signInStep) {
|
|
19828
19874
|
form.classList.add('svhd-widget-form');
|
|
19829
19875
|
details.append(widgetAccount);
|
|
19830
19876
|
identity.hidden = true;
|
|
@@ -19839,22 +19885,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
19839
19885
|
recapLabel.textContent = 'Your request';
|
|
19840
19886
|
recapRequest.append(recapLabel, recapText);
|
|
19841
19887
|
recap.append(recapRequest, editRequest);
|
|
19842
|
-
|
|
19843
|
-
helper.id = `${email.input.id}-help`;
|
|
19844
|
-
helper.className = 'svhd-hint';
|
|
19845
|
-
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.';
|
|
19846
|
-
email.input.setAttribute('aria-describedby', helper.id);
|
|
19847
|
-
identity.append(reply.head, note, recap);
|
|
19848
|
-
if (asksName) {
|
|
19849
|
-
const names = document.createElement('div');
|
|
19850
|
-
names.className = 'svhd-widget-names';
|
|
19851
|
-
names.append(firstName.wrapper, lastName.wrapper);
|
|
19852
|
-
identity.append(names);
|
|
19853
|
-
}
|
|
19854
|
-
identity.append(email.wrapper, helper);
|
|
19888
|
+
identity.append(signInStep.head, note, recap, signInHelp);
|
|
19855
19889
|
}
|
|
19856
|
-
else
|
|
19857
|
-
auth.prepend(email.wrapper);
|
|
19858
19890
|
const status = document.createElement('p');
|
|
19859
19891
|
status.className = 'svhd-status';
|
|
19860
19892
|
status.setAttribute('role', 'status');
|
|
@@ -19946,6 +19978,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
19946
19978
|
let recovery = null;
|
|
19947
19979
|
// The website gave no account back when asked for the hidden request's customer.
|
|
19948
19980
|
let websiteSignedOut = false;
|
|
19981
|
+
// The form is held while the secure window chooses another account: no send is under way.
|
|
19982
|
+
let switchingAccount = false;
|
|
19949
19983
|
function persistDraft() {
|
|
19950
19984
|
if (!options.persist || completed || destroyed)
|
|
19951
19985
|
return;
|
|
@@ -20000,9 +20034,15 @@ function mountHelpDeskForm(client, options) {
|
|
|
20000
20034
|
: 'Your saved request was restored. Review it before sending.');
|
|
20001
20035
|
return true;
|
|
20002
20036
|
}
|
|
20037
|
+
/**
|
|
20038
|
+
* The unsent text an account change carries on to the next form, and
|
|
20039
|
+
* whether the composer held files then, which stay behind. None while a
|
|
20040
|
+
* send is under way, unanswered or done: an account change must not turn an
|
|
20041
|
+
* uncertain send into a fresh request.
|
|
20042
|
+
*/
|
|
20003
20043
|
function safeComposition() {
|
|
20004
|
-
|
|
20005
|
-
|
|
20044
|
+
return pending || uncertainSubmission !== null || completed ? null
|
|
20045
|
+
: { subject: subject.input.value, body: description.input.value, hadFiles: attachments?.hasEntries === true };
|
|
20006
20046
|
}
|
|
20007
20047
|
/** What the send button reads while nothing is in flight. */
|
|
20008
20048
|
function idleLabel() {
|
|
@@ -20012,14 +20052,17 @@ function mountHelpDeskForm(client, options) {
|
|
|
20012
20052
|
return 'Verify and send request';
|
|
20013
20053
|
if (recovery === 'external_sso' && widget)
|
|
20014
20054
|
return 'Use website account';
|
|
20015
|
-
if (recovery !== null
|
|
20055
|
+
if (recovery !== null)
|
|
20016
20056
|
return 'Sign in to recover request';
|
|
20017
|
-
|
|
20057
|
+
if (widget && !widgetCustomer)
|
|
20058
|
+
return step === 'identity' ? 'Sign in and send' : 'Continue';
|
|
20059
|
+
return 'Send request';
|
|
20018
20060
|
}
|
|
20019
20061
|
/**
|
|
20020
20062
|
* The signed-in widget customer writes and sends in one step, posting as
|
|
20021
|
-
* the account named under it
|
|
20022
|
-
*
|
|
20063
|
+
* the account named under it, beside Switch account and, but for a website
|
|
20064
|
+
* account's session, which the website ends, Sign out; a signed-out one
|
|
20065
|
+
* writes the request as step 1 of 2. Either way the form shows the request.
|
|
20023
20066
|
*/
|
|
20024
20067
|
function renderWidgetIdentity() {
|
|
20025
20068
|
if (!widget)
|
|
@@ -20034,12 +20077,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
20034
20077
|
if (widgetCustomer) {
|
|
20035
20078
|
const postingAs = document.createElement('p');
|
|
20036
20079
|
postingAs.className = 'svhd-posting-as';
|
|
20037
|
-
|
|
20038
|
-
|
|
20039
|
-
|
|
20040
|
-
|
|
20041
|
-
|
|
20042
|
-
|
|
20080
|
+
// Switch account opens the sign-in window in this click: nothing may await before it.
|
|
20081
|
+
const switchButton = textButton('Switch account', () => { if (free())
|
|
20082
|
+
void switchAccount(switchButton); });
|
|
20083
|
+
postingAs.append(`${postingAsText(widgetCustomer)} `, switchButton);
|
|
20084
|
+
if (widgetCustomer.assurance !== 'external_sso') {
|
|
20085
|
+
postingAs.append(' ', textButton('Sign out', () => { if (free())
|
|
20086
|
+
widget.signOut(safeComposition()); }));
|
|
20087
|
+
}
|
|
20043
20088
|
widgetAccount.append(postingAs);
|
|
20044
20089
|
}
|
|
20045
20090
|
if (widget.useWebsiteAccount && widget.offerWebsiteAccount) {
|
|
@@ -20054,7 +20099,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20054
20099
|
* The actions and notes for where the request is. While the form hides a
|
|
20055
20100
|
* previous customer's saved request (`recovery`), nothing shows of it, nor
|
|
20056
20101
|
* says it was not sent, since it may be a send whose answer was lost: the
|
|
20057
|
-
* request step's status line says how to get it back and the
|
|
20102
|
+
* request step's status line says how to get it back and the sign-in
|
|
20058
20103
|
* step's note alone speaks there, Start a new request leaves it, and the
|
|
20059
20104
|
* account row is away. A website-account customer's request comes back only
|
|
20060
20105
|
* through that account, so Use website account is its one way on when the
|
|
@@ -20066,7 +20111,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20066
20111
|
startNew.hidden = recovery === null;
|
|
20067
20112
|
widgetAccount.hidden = recovery !== null || widgetAccount.childElementCount === 0;
|
|
20068
20113
|
recap.hidden = recovery !== null;
|
|
20069
|
-
noteText.data = recovery === 'identity' || recovery === 'email_pin' ? RECOVER_NOTE_COPY :
|
|
20114
|
+
noteText.data = recovery === 'identity' || recovery === 'email_pin' ? RECOVER_NOTE_COPY : UNSENT_NOTE_COPY;
|
|
20070
20115
|
if (recovery !== null)
|
|
20071
20116
|
message(step === 'identity' ? '' : recoveryStatus());
|
|
20072
20117
|
}
|
|
@@ -20091,15 +20136,19 @@ function mountHelpDeskForm(client, options) {
|
|
|
20091
20136
|
controller.focusEntry();
|
|
20092
20137
|
}
|
|
20093
20138
|
}
|
|
20094
|
-
/** Show one step, the request or
|
|
20139
|
+
/** Show one step, the request or its sign-in, without moving focus. */
|
|
20095
20140
|
function setStep(next) {
|
|
20096
20141
|
const changed = next !== step;
|
|
20097
20142
|
step = next;
|
|
20098
20143
|
details.hidden = next !== 'details';
|
|
20099
20144
|
if (identity)
|
|
20100
20145
|
identity.hidden = next !== 'identity';
|
|
20101
|
-
if (next === 'identity')
|
|
20146
|
+
if (next === 'identity') {
|
|
20102
20147
|
recapText.textContent = subject.input.value.trim();
|
|
20148
|
+
send.setAttribute('aria-describedby', signInHelp.id);
|
|
20149
|
+
}
|
|
20150
|
+
else
|
|
20151
|
+
send.removeAttribute('aria-describedby');
|
|
20103
20152
|
renderActions();
|
|
20104
20153
|
syncLeaveGuard();
|
|
20105
20154
|
if (changed)
|
|
@@ -20107,9 +20156,11 @@ function mountHelpDeskForm(client, options) {
|
|
|
20107
20156
|
}
|
|
20108
20157
|
/** The customer moves between the steps: the new step's heading takes focus and its place is announced. */
|
|
20109
20158
|
function enterStep(next) {
|
|
20159
|
+
// A notice speaks of the step being left; a hidden saved request's status is the next step's to set again.
|
|
20160
|
+
message('');
|
|
20110
20161
|
setStep(next);
|
|
20111
20162
|
live.announce(next === 'identity' ? 'Step 2 of 2' : 'Step 1 of 2');
|
|
20112
|
-
(next === 'identity' &&
|
|
20163
|
+
(next === 'identity' && signInStep ? signInStep.heading : heading).focus();
|
|
20113
20164
|
}
|
|
20114
20165
|
// An inline wizard, on any host page that gives a `target`, asks before that
|
|
20115
20166
|
// page unloads while the request holds unsent work: leaving would lose it.
|
|
@@ -20167,7 +20218,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20167
20218
|
* in place of anything written.
|
|
20168
20219
|
*/
|
|
20169
20220
|
function disable(disabled) {
|
|
20170
|
-
for (const input of [subject.input, description.input, email.input, code.input, name.input,
|
|
20221
|
+
for (const input of [subject.input, description.input, email.input, code.input, name.input, send, cancel, changeEmail, editRequest, startNew])
|
|
20171
20222
|
input.disabled = disabled;
|
|
20172
20223
|
const held = uncertainSubmission !== null || recovery !== null;
|
|
20173
20224
|
subject.input.readOnly = held;
|
|
@@ -20204,10 +20255,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
20204
20255
|
? 'We may already have received this request. Closing now loses the way to check it.'
|
|
20205
20256
|
: DISCARD_REQUEST_COPY.note;
|
|
20206
20257
|
}
|
|
20207
|
-
/** The field
|
|
20258
|
+
/** The field the request step asks for: the code, name or email the form asks for itself, else the summary. */
|
|
20208
20259
|
function stepField() {
|
|
20209
|
-
if (step === 'identity')
|
|
20210
|
-
return (asksName ? firstName : email).input;
|
|
20211
20260
|
const asked = auth.hidden ? undefined : [code, name, email].find((entry) => !entry.wrapper.hidden);
|
|
20212
20261
|
return (asked ?? subject).input;
|
|
20213
20262
|
}
|
|
@@ -20215,7 +20264,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20215
20264
|
// A press on the modal's backdrop leaves focus on the page body, and
|
|
20216
20265
|
// Keep editing must never hand focus back outside the dialog.
|
|
20217
20266
|
const active = document.activeElement;
|
|
20218
|
-
confirmReturn = active instanceof HTMLElement && shell.container.contains(active) ? active : stepField();
|
|
20267
|
+
confirmReturn = active instanceof HTMLElement && shell.container.contains(active) ? active : step === 'identity' ? send : stepField();
|
|
20219
20268
|
renderConfirmNote();
|
|
20220
20269
|
actions.hidden = true;
|
|
20221
20270
|
confirm.hidden = false;
|
|
@@ -20248,7 +20297,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20248
20297
|
}
|
|
20249
20298
|
/**
|
|
20250
20299
|
* Whether closing now would lose something: a send under way or
|
|
20251
|
-
* unanswered, a code step, a request moved on to
|
|
20300
|
+
* unanswered, a code step, a request moved on to its sign-in step, or
|
|
20252
20301
|
* text and files of the customer's own. The silent company sign-in the
|
|
20253
20302
|
* form runs as it opens (`authenticating`) is no work of the customer's.
|
|
20254
20303
|
*/
|
|
@@ -20350,11 +20399,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20350
20399
|
code.wrapper.hidden = true;
|
|
20351
20400
|
name.wrapper.hidden = true;
|
|
20352
20401
|
auth.hidden = true;
|
|
20353
|
-
|
|
20354
|
-
firstName.input.value = '';
|
|
20355
|
-
lastName.input.value = '';
|
|
20356
|
-
renderWidgetIdentity();
|
|
20357
|
-
}
|
|
20402
|
+
renderWidgetIdentity();
|
|
20358
20403
|
hosted.hidden = true;
|
|
20359
20404
|
draftId = null;
|
|
20360
20405
|
draftPromise = null;
|
|
@@ -20422,6 +20467,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20422
20467
|
restoredFiles = false;
|
|
20423
20468
|
generation += 1;
|
|
20424
20469
|
pending = false;
|
|
20470
|
+
switchingAccount = false;
|
|
20425
20471
|
sessionKnown = false;
|
|
20426
20472
|
if (options.widgetIdentity)
|
|
20427
20473
|
widgetCustomer = null;
|
|
@@ -20541,25 +20587,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
20541
20587
|
}
|
|
20542
20588
|
let widgetSignIn;
|
|
20543
20589
|
if (widget && !widgetCustomer) {
|
|
20544
|
-
// The request is written;
|
|
20590
|
+
// The request is written; signing in to send it is the next step, and
|
|
20545
20591
|
// nothing reaches the network before it.
|
|
20546
20592
|
if (step === 'details') {
|
|
20547
20593
|
enterStep('identity');
|
|
20548
20594
|
return;
|
|
20549
20595
|
}
|
|
20550
|
-
const givenName = asksName ? firstName.input.value.trim() : '';
|
|
20551
|
-
const familyName = asksName ? lastName.input.value.trim() : '';
|
|
20552
|
-
const emailAddress = email.input.value.trim();
|
|
20553
|
-
const invalid = asksName && !givenName ? firstName : !email.input.validity.valid || !emailAddress ? email : null;
|
|
20554
|
-
if (invalid) {
|
|
20555
|
-
setFieldError(invalid, invalid === email ? 'Enter your email address.' : 'Enter your first name.');
|
|
20556
|
-
invalid.input.focus();
|
|
20557
|
-
return;
|
|
20558
|
-
}
|
|
20559
20596
|
// Invoke in the original submit gesture, before any awaited token read:
|
|
20560
20597
|
// the Identity adapter can open its native window without a popup block.
|
|
20561
20598
|
try {
|
|
20562
|
-
widgetSignIn = widget.signIn(
|
|
20599
|
+
widgetSignIn = widget.signIn();
|
|
20563
20600
|
}
|
|
20564
20601
|
catch (failure) {
|
|
20565
20602
|
const error = failure instanceof Error ? failure : new Error('Sign-in could not be opened.');
|
|
@@ -20582,7 +20619,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20582
20619
|
authenticating = true;
|
|
20583
20620
|
authNotification = false;
|
|
20584
20621
|
setState('authenticating');
|
|
20585
|
-
message(
|
|
20622
|
+
message(SIGNING_IN_COPY);
|
|
20586
20623
|
}
|
|
20587
20624
|
let token = await tokenFor(ownGeneration);
|
|
20588
20625
|
if (!alive(ownGeneration))
|
|
@@ -20783,7 +20820,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20783
20820
|
focusAfter = code.input;
|
|
20784
20821
|
}
|
|
20785
20822
|
else if (widgetSignIn && error instanceof SparkVaultError && error.code === 'user_cancelled') {
|
|
20786
|
-
// The request stays on
|
|
20823
|
+
// The request stays on its sign-in step, ready to sign in again;
|
|
20787
20824
|
// a hidden saved request is not here to speak of, so its note alone stays.
|
|
20788
20825
|
if (recovery === null)
|
|
20789
20826
|
message(SIGN_IN_CANCELLED_COPY);
|
|
@@ -20842,6 +20879,84 @@ function mountHelpDeskForm(client, options) {
|
|
|
20842
20879
|
}
|
|
20843
20880
|
}
|
|
20844
20881
|
}
|
|
20882
|
+
/** A request this tab saved, restored as the form mounted, which a carried composition never replaces. */
|
|
20883
|
+
function holdsSavedRequest() {
|
|
20884
|
+
return restoredDraft || restoredAnonymous;
|
|
20885
|
+
}
|
|
20886
|
+
/**
|
|
20887
|
+
* What the form says of the account change it arrives from (`arrived`), once
|
|
20888
|
+
* mounting has restored any saved request: its status line, null to leave
|
|
20889
|
+
* the one mounting set, and what a screen reader hears. A restored saved
|
|
20890
|
+
* request takes the carried text's place, so its own status stands and
|
|
20891
|
+
* nothing is said of the carried request's files.
|
|
20892
|
+
*/
|
|
20893
|
+
function arrival() {
|
|
20894
|
+
const arrived = widget?.arrived;
|
|
20895
|
+
if (!arrived)
|
|
20896
|
+
return null;
|
|
20897
|
+
const placed = !holdsSavedRequest();
|
|
20898
|
+
const files = placed && arrived.droppedFiles ? ` ${FILES_AGAIN_COPY}` : '';
|
|
20899
|
+
if (arrived.from === 'signOut')
|
|
20900
|
+
return { status: placed ? `${SIGNED_OUT_COPY}${files}` : null, announcement: `${SIGNED_OUT_COPY}${files} Step 1 of 2` };
|
|
20901
|
+
if (!widgetCustomer)
|
|
20902
|
+
return null;
|
|
20903
|
+
return { status: files ? FILES_AGAIN_COPY : null, announcement: `${postingAsText(widgetCustomer)}${files}` };
|
|
20904
|
+
}
|
|
20905
|
+
/**
|
|
20906
|
+
* Switch account: the secure window's chooser opens in the customer's
|
|
20907
|
+
* click. This customer stays signed in, the request held in view, until
|
|
20908
|
+
* another account is chosen and a form for it replaces this one. Closing
|
|
20909
|
+
* the window changes nothing; any other failure says why. Either way focus
|
|
20910
|
+
* goes back to `control`.
|
|
20911
|
+
*/
|
|
20912
|
+
async function switchAccount(control) {
|
|
20913
|
+
if (!widget)
|
|
20914
|
+
return;
|
|
20915
|
+
closeConfirm(false);
|
|
20916
|
+
let switched;
|
|
20917
|
+
try {
|
|
20918
|
+
switched = widget.switchAccount(safeComposition());
|
|
20919
|
+
}
|
|
20920
|
+
catch (failure) {
|
|
20921
|
+
const error = failure instanceof Error ? failure : new Error('Sign-in could not be opened.');
|
|
20922
|
+
message(error.message, true);
|
|
20923
|
+
notify$1(options.onError, error);
|
|
20924
|
+
return;
|
|
20925
|
+
}
|
|
20926
|
+
const ownGeneration = generation;
|
|
20927
|
+
pending = true;
|
|
20928
|
+
switchingAccount = true;
|
|
20929
|
+
disable(true);
|
|
20930
|
+
setState('authenticating');
|
|
20931
|
+
message(SWITCHING_COPY);
|
|
20932
|
+
// The status line moves the actions below it.
|
|
20933
|
+
options.onScreenChange?.();
|
|
20934
|
+
try {
|
|
20935
|
+
await switched;
|
|
20936
|
+
}
|
|
20937
|
+
catch (failure) {
|
|
20938
|
+
if (!alive(ownGeneration))
|
|
20939
|
+
return;
|
|
20940
|
+
const error = failure instanceof Error ? failure : new Error('The account could not be switched.');
|
|
20941
|
+
if (error instanceof SparkVaultError && error.code === 'user_cancelled')
|
|
20942
|
+
message('');
|
|
20943
|
+
else {
|
|
20944
|
+
message(error.message, true);
|
|
20945
|
+
notify$1(options.onError, error);
|
|
20946
|
+
}
|
|
20947
|
+
}
|
|
20948
|
+
finally {
|
|
20949
|
+
if (alive(ownGeneration)) {
|
|
20950
|
+
pending = false;
|
|
20951
|
+
switchingAccount = false;
|
|
20952
|
+
setState('editing');
|
|
20953
|
+
disable(false);
|
|
20954
|
+
options.onScreenChange?.();
|
|
20955
|
+
focusAfter = control;
|
|
20956
|
+
focusSettled();
|
|
20957
|
+
}
|
|
20958
|
+
}
|
|
20959
|
+
}
|
|
20845
20960
|
/** Take a typed, pasted or autofilled code as its digits, and send it the moment the last one lands. */
|
|
20846
20961
|
function takeCode(value) {
|
|
20847
20962
|
const digits = helpDeskPinDigits(value);
|
|
@@ -20863,26 +20978,47 @@ function mountHelpDeskForm(client, options) {
|
|
|
20863
20978
|
/** The Cancel path: remove the form, then tell the host the customer closed it. */
|
|
20864
20979
|
function dismiss() {
|
|
20865
20980
|
const discardDraft = uncertainSubmission === null;
|
|
20866
|
-
|
|
20981
|
+
if (!destroyed)
|
|
20982
|
+
teardown(!discardDraft);
|
|
20867
20983
|
if (discardDraft)
|
|
20868
20984
|
forgetDraft();
|
|
20869
20985
|
notify$1(options.onCancel, undefined);
|
|
20870
20986
|
}
|
|
20987
|
+
/** Remove the form and silence it; `save` keeps its request in this tab for the customer it shows. */
|
|
20988
|
+
function teardown(save) {
|
|
20989
|
+
if (save)
|
|
20990
|
+
persistDraft();
|
|
20991
|
+
destroyed = true;
|
|
20992
|
+
generation += 1;
|
|
20993
|
+
stopResendCountdown();
|
|
20994
|
+
attachments?.destroy(completed || uncertainSubmission !== null);
|
|
20995
|
+
composer.destroy();
|
|
20996
|
+
live.destroy();
|
|
20997
|
+
unsubscribe();
|
|
20998
|
+
form.removeEventListener('submit', onSubmit);
|
|
20999
|
+
shell.destroy();
|
|
21000
|
+
setState('destroyed');
|
|
21001
|
+
}
|
|
20871
21002
|
const controller = {
|
|
20872
21003
|
destroy() {
|
|
21004
|
+
if (!destroyed)
|
|
21005
|
+
teardown(true);
|
|
21006
|
+
},
|
|
21007
|
+
leave() {
|
|
20873
21008
|
if (destroyed)
|
|
20874
21009
|
return;
|
|
20875
|
-
|
|
20876
|
-
|
|
20877
|
-
|
|
20878
|
-
|
|
20879
|
-
|
|
20880
|
-
|
|
20881
|
-
|
|
20882
|
-
|
|
20883
|
-
|
|
20884
|
-
|
|
20885
|
-
|
|
21010
|
+
const owner = draftOwner;
|
|
21011
|
+
const sending = pending && !switchingAccount;
|
|
21012
|
+
if (!owner || sending || uncertainSubmission !== null || completed || recovery !== null) {
|
|
21013
|
+
teardown(true);
|
|
21014
|
+
return;
|
|
21015
|
+
}
|
|
21016
|
+
// The request goes on with the account change: this customer's saved copy
|
|
21017
|
+
// must not come back to them over the text as edited since, nor offer the
|
|
21018
|
+
// request a second time.
|
|
21019
|
+
teardown(false);
|
|
21020
|
+
if (options.persist)
|
|
21021
|
+
removeFormDraft(client.desk.desk_id, owner.requester_id);
|
|
20886
21022
|
},
|
|
20887
21023
|
reset() {
|
|
20888
21024
|
if (destroyed || pending || uncertainSubmission)
|
|
@@ -20898,7 +21034,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20898
21034
|
},
|
|
20899
21035
|
getState: () => state,
|
|
20900
21036
|
restoreComposition(composition) {
|
|
20901
|
-
if (destroyed ||
|
|
21037
|
+
if (destroyed || holdsSavedRequest())
|
|
20902
21038
|
return;
|
|
20903
21039
|
subject.input.value = composition.subject;
|
|
20904
21040
|
description.input.value = composition.body;
|
|
@@ -20939,10 +21075,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
20939
21075
|
focusEntry(focusOptions) {
|
|
20940
21076
|
if (destroyed || form.hidden)
|
|
20941
21077
|
return false;
|
|
21078
|
+
if (step === 'identity' && signInStep) {
|
|
21079
|
+
(send.disabled ? signInStep.heading : send).focus(focusOptions);
|
|
21080
|
+
return true;
|
|
21081
|
+
}
|
|
20942
21082
|
const asked = stepField();
|
|
20943
21083
|
const entry = asked === subject.input && subject.input.value.trim() ? description.input : asked;
|
|
20944
21084
|
if (entry.disabled || entry.readOnly)
|
|
20945
|
-
|
|
21085
|
+
heading.focus(focusOptions);
|
|
20946
21086
|
else
|
|
20947
21087
|
focusAtEnd(entry, focusOptions);
|
|
20948
21088
|
return true;
|
|
@@ -20986,9 +21126,6 @@ function mountHelpDeskForm(client, options) {
|
|
|
20986
21126
|
});
|
|
20987
21127
|
send.textContent = idleLabel();
|
|
20988
21128
|
renderWidgetIdentity();
|
|
20989
|
-
// A signed-out widget customer starts on step 1 of 2 with focus in the request.
|
|
20990
|
-
if (widget && !widgetCustomer)
|
|
20991
|
-
live.announce('Step 1 of 2');
|
|
20992
21129
|
if (options.widgetIdentity?.customer) {
|
|
20993
21130
|
restoreDraft(options.widgetIdentity.customer);
|
|
20994
21131
|
disable(false);
|
|
@@ -21009,6 +21146,15 @@ function mountHelpDeskForm(client, options) {
|
|
|
21009
21146
|
restoredAnonymous = true;
|
|
21010
21147
|
}
|
|
21011
21148
|
}
|
|
21149
|
+
const arriving = arrival();
|
|
21150
|
+
if (arriving?.status)
|
|
21151
|
+
message(arriving.status);
|
|
21152
|
+
// A signed-out widget customer starts on step 1 of 2 with focus in the
|
|
21153
|
+
// request; after an account change a screen reader hears where it stands.
|
|
21154
|
+
if (arriving)
|
|
21155
|
+
live.announce(arriving.announcement);
|
|
21156
|
+
else if (widget && !widgetCustomer)
|
|
21157
|
+
live.announce('Step 1 of 2');
|
|
21012
21158
|
syncLeaveGuard();
|
|
21013
21159
|
notify$1(options.onStateChange, state);
|
|
21014
21160
|
// Native company identity starts as the form opens, never from a Connect,
|
|
@@ -23379,7 +23525,6 @@ function injectHelpDeskSupportStyles() {
|
|
|
23379
23525
|
@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}}
|
|
23380
23526
|
.svhs-panel .svhd-composer-input:focus-visible{outline:none}
|
|
23381
23527
|
.svhs-panel .svhd-composer button:focus-visible{outline-offset:-2px}
|
|
23382
|
-
.svhs-contact-target .svhd-widget-names{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px}
|
|
23383
23528
|
.svhs-contact-target .svhd-widget-form{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
23384
23529
|
/* The request fills the panel: the details step, and in it the composer and its text, take the height the fields leave. */
|
|
23385
23530
|
.svhs-contact-target .svhd-widget-form>[data-contact-step=details]{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
@@ -24730,6 +24875,13 @@ function createHelpDeskSupport(config, options) {
|
|
|
24730
24875
|
// A website-account customer's saved request the next form keeps hidden,
|
|
24731
24876
|
// asked for through the website account, which may give no account back.
|
|
24732
24877
|
let pendingRecovery = null;
|
|
24878
|
+
// The account change the next form arrives from, which it says: a Sign out
|
|
24879
|
+
// to a signed-out form, a Switch account or Use website account to the
|
|
24880
|
+
// account arrived at.
|
|
24881
|
+
let pendingArrival = null;
|
|
24882
|
+
// A chosen account's session is taking the old one's place: the host hears
|
|
24883
|
+
// the new session, never the signed-out moment between the two.
|
|
24884
|
+
let replacingSession = false;
|
|
24733
24885
|
// The issue, as written, that the held composition (the mounted form, the one
|
|
24734
24886
|
// a re-authorized form will take, or the one saved before a reload) was last
|
|
24735
24887
|
// filled from: '' for one filled from none. A form taking that composition is
|
|
@@ -24768,7 +24920,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
24768
24920
|
onBack: () => {
|
|
24769
24921
|
if (destroyed || state.navigationLocked || state.identityPending)
|
|
24770
24922
|
return;
|
|
24771
|
-
// On
|
|
24923
|
+
// On the sign-in step, Back returns to the request it is for.
|
|
24772
24924
|
if (state.stage === 'contact' && !state.ticketAccessRequired && contact?.returnToRequest())
|
|
24773
24925
|
return;
|
|
24774
24926
|
// A held form shows at once while contact still checks access behind it,
|
|
@@ -24846,7 +24998,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
24846
24998
|
throw new Error('Support is closed.');
|
|
24847
24999
|
client = answer;
|
|
24848
25000
|
stopSession = answer.subscribeSession((change) => {
|
|
24849
|
-
if (change.source === 'clear')
|
|
25001
|
+
if (change.source === 'clear' && !replacingSession)
|
|
24850
25002
|
notify(options.onSession, null);
|
|
24851
25003
|
});
|
|
24852
25004
|
kb = new HelpDeskKnowledgeBaseClient(config, answer.desk.desk_id);
|
|
@@ -24977,6 +25129,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
24977
25129
|
requestedArticle = null;
|
|
24978
25130
|
pendingComposition = null;
|
|
24979
25131
|
pendingRecovery = null;
|
|
25132
|
+
pendingArrival = null;
|
|
24980
25133
|
feedbackSequence += 1;
|
|
24981
25134
|
sourceArticleId = undefined;
|
|
24982
25135
|
if (options.persist && client)
|
|
@@ -25142,14 +25295,19 @@ function createHelpDeskSupport(config, options) {
|
|
|
25142
25295
|
if (!client || destroyed)
|
|
25143
25296
|
return;
|
|
25144
25297
|
contactCustomer = customer;
|
|
25298
|
+
anonymous = !customer;
|
|
25145
25299
|
// A customer the website gave back sees their own saved request; none keeps it hidden.
|
|
25146
25300
|
const recovering = customer ? null : pendingRecovery;
|
|
25147
25301
|
pendingRecovery = null;
|
|
25302
|
+
// A Sign out arrives only at a signed-out form, a switch only at an account's.
|
|
25303
|
+
const arrived = pendingArrival && (pendingArrival.from === 'signOut') === !customer ? pendingArrival : null;
|
|
25304
|
+
pendingArrival = null;
|
|
25148
25305
|
let activeAttempt = null;
|
|
25149
25306
|
// A ticket carries the attempt the form opened under only while it is still
|
|
25150
25307
|
// the journey's: recovery drops it with the previous customer's question.
|
|
25151
25308
|
const formAttempt = attempt;
|
|
25152
|
-
|
|
25309
|
+
// A host that keeps the session this journey proves has no website account behind it to go back to.
|
|
25310
|
+
const bridged = !options.hostKeepsSession && Boolean(options.getSessionToken || options.getIdentityAssertion || options.identityEndpoint);
|
|
25153
25311
|
contact = mountHelpDeskForm(client, {
|
|
25154
25312
|
target: view.contactTarget,
|
|
25155
25313
|
// Filled from the issue its composition came from, so text the customer
|
|
@@ -25167,13 +25325,15 @@ function createHelpDeskSupport(config, options) {
|
|
|
25167
25325
|
},
|
|
25168
25326
|
widgetIdentity: {
|
|
25169
25327
|
customer,
|
|
25170
|
-
signIn: (
|
|
25171
|
-
switchAccount
|
|
25328
|
+
signIn: () => signIn().then((session) => { contactCustomer = session.customer; return session; }),
|
|
25329
|
+
switchAccount,
|
|
25330
|
+
signOut,
|
|
25172
25331
|
...(bridged && { useWebsiteAccount: (safe, recover) => { void useWebsiteAccount(safe, recover); } }),
|
|
25173
25332
|
offerWebsiteAccount: switchedAccount,
|
|
25174
25333
|
forgetIssue,
|
|
25175
25334
|
followIssue,
|
|
25176
25335
|
...(recovering && { recovering }),
|
|
25336
|
+
...(arrived && { arrived }),
|
|
25177
25337
|
},
|
|
25178
25338
|
onScreenChange: () => view.contactScreenChanged(),
|
|
25179
25339
|
assistanceContext: () => (attempt === formAttempt ? activeAttempt?.ticketContext() : undefined),
|
|
@@ -25287,7 +25447,6 @@ function createHelpDeskSupport(config, options) {
|
|
|
25287
25447
|
if (destroyed || ownSequence !== sequence)
|
|
25288
25448
|
return;
|
|
25289
25449
|
update({ busy: false, ticketAccessRequired: false, ticketAccessMode: undefined });
|
|
25290
|
-
anonymous = !customer;
|
|
25291
25450
|
// A composition saved before a reload goes on from the issue it was filled
|
|
25292
25451
|
// from; with none carried, the form fills itself from the issue as written.
|
|
25293
25452
|
const saved = pendingComposition === null && options.persist ? readAnonymousFormDraft(active.desk.desk_id) : null;
|
|
@@ -25351,78 +25510,120 @@ function createHelpDeskSupport(config, options) {
|
|
|
25351
25510
|
notify(options.onError, error);
|
|
25352
25511
|
}
|
|
25353
25512
|
}
|
|
25354
|
-
|
|
25355
|
-
|
|
25356
|
-
|
|
25357
|
-
|
|
25358
|
-
|
|
25359
|
-
|
|
25513
|
+
/**
|
|
25514
|
+
* Forget what the leaving customer's form led to before another account, or
|
|
25515
|
+
* none, takes its place: the form itself, the articles and the help center
|
|
25516
|
+
* access it opened. Only `composition`'s unsent text goes on to the next
|
|
25517
|
+
* form, which the leaving form's saved copy then no longer stands for
|
|
25518
|
+
* (`leave`); files and uncertain sends keep their requester boundary.
|
|
25519
|
+
*/
|
|
25520
|
+
function leaveCustomer(composition) {
|
|
25521
|
+
if (composition)
|
|
25522
|
+
contact?.leave();
|
|
25523
|
+
else
|
|
25524
|
+
contact?.destroy();
|
|
25360
25525
|
contact = null;
|
|
25526
|
+
contactCustomer = null;
|
|
25361
25527
|
cancelArticleAssets?.();
|
|
25362
25528
|
cancelArticleAssets = null;
|
|
25363
|
-
pendingComposition = composition
|
|
25529
|
+
pendingComposition = composition ? { subject: composition.subject, body: composition.body } : { subject: '', body: '' };
|
|
25364
25530
|
pendingRecovery = null;
|
|
25531
|
+
pendingArrival = null;
|
|
25365
25532
|
kb?.clearAccess();
|
|
25366
25533
|
kbConfig = null;
|
|
25367
25534
|
results = [];
|
|
25368
25535
|
requestedArticle = null;
|
|
25369
25536
|
attempt = null;
|
|
25370
25537
|
sourceArticleId = undefined;
|
|
25371
|
-
|
|
25372
|
-
|
|
25373
|
-
|
|
25374
|
-
|
|
25375
|
-
|
|
25376
|
-
|
|
25377
|
-
|
|
25378
|
-
|
|
25379
|
-
|
|
25538
|
+
}
|
|
25539
|
+
/**
|
|
25540
|
+
* Switch account from the contact form: auth.sv's chooser opens in this
|
|
25541
|
+
* gesture, the current session staying current until another account's is
|
|
25542
|
+
* redeemed. A window that closes or fails rejects, nothing changed, for the
|
|
25543
|
+
* form to say so; a redeemed session takes the old one's place.
|
|
25544
|
+
*/
|
|
25545
|
+
function switchAccount(composition) {
|
|
25546
|
+
const form = contact;
|
|
25547
|
+
const policy = client?.ticketAccessPolicy;
|
|
25548
|
+
// Open synchronously in the Switch account gesture, before anything is awaited.
|
|
25549
|
+
return signIn({ selectAccount: true, employeeCompanyId: policy?.mode === 'identity' ? policy.company_id : undefined }).then((session) => {
|
|
25550
|
+
// The form that asked has left (support destroyed or the journey reset): nothing waits on this account.
|
|
25551
|
+
if (destroyed || !client || contact !== form)
|
|
25380
25552
|
return;
|
|
25381
|
-
|
|
25553
|
+
return replaceAccount(client, session, composition);
|
|
25554
|
+
});
|
|
25555
|
+
}
|
|
25556
|
+
/**
|
|
25557
|
+
* Put a chosen account's redeemed session in the old one's place: the old
|
|
25558
|
+
* one is released as `switchSupportAccount` releases it (the website's
|
|
25559
|
+
* identity suppressed, a lent session never revoked), and a form for the new
|
|
25560
|
+
* customer takes the unsent text.
|
|
25561
|
+
*/
|
|
25562
|
+
async function replaceAccount(active, session, composition) {
|
|
25563
|
+
const ownSequence = ++sequence;
|
|
25564
|
+
leaveCustomer(composition);
|
|
25565
|
+
switchedAccount = true;
|
|
25566
|
+
pendingArrival = { from: 'switch', droppedFiles: composition?.hadFiles === true };
|
|
25567
|
+
update({ stage: 'contact', busy: true, error: undefined, results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
25568
|
+
// The release clears the old session at once, before its revocation is sent.
|
|
25569
|
+
replacingSession = true;
|
|
25570
|
+
const released = active.switchSupportAccount();
|
|
25571
|
+
replacingSession = false;
|
|
25572
|
+
// A refused or lost revocation leaves the chosen account in place.
|
|
25573
|
+
void released.catch((value) => notify(options.onError, failure(value)));
|
|
25574
|
+
active.setSession(session);
|
|
25575
|
+
notify(options.onSession, session);
|
|
25576
|
+
if (active.ticketAccessPolicy?.mode === 'identity') {
|
|
25577
|
+
// Without this grant, contact's access check shows the employee gate for the chosen account.
|
|
25578
|
+
try {
|
|
25382
25579
|
notify(options.onTicketAccess, await active.unlockTicketAccess({ identityGrant: session.identity_grant.token }));
|
|
25383
|
-
if (destroyed || ownSequence !== sequence)
|
|
25384
|
-
return;
|
|
25385
|
-
active.setSession(session);
|
|
25386
|
-
notify(options.onSession, session);
|
|
25387
|
-
update({ busy: false });
|
|
25388
|
-
await showContact('direct');
|
|
25389
|
-
}
|
|
25390
|
-
catch (value) {
|
|
25391
|
-
await logout.catch(() => undefined);
|
|
25392
|
-
if (destroyed || ownSequence !== sequence)
|
|
25393
|
-
return;
|
|
25394
|
-
const error = failure(value);
|
|
25395
|
-
update({ busy: false, error: error.message });
|
|
25396
|
-
if (active.hasTicketAccess) {
|
|
25397
|
-
mountContact(composition ?? { subject: '', body: '' }, null);
|
|
25398
|
-
pendingComposition = null;
|
|
25399
25580
|
}
|
|
25400
|
-
|
|
25401
|
-
|
|
25581
|
+
catch (value) {
|
|
25582
|
+
if (!destroyed && ownSequence === sequence)
|
|
25583
|
+
notify(options.onError, failure(value));
|
|
25584
|
+
}
|
|
25402
25585
|
}
|
|
25586
|
+
if (destroyed || ownSequence !== sequence)
|
|
25587
|
+
return;
|
|
25588
|
+
await showContact('direct');
|
|
25589
|
+
}
|
|
25590
|
+
/**
|
|
25591
|
+
* Sign out of support from the contact form, without a window: the session
|
|
25592
|
+
* ends at once, even one the host lent, its revocation sent behind, and a
|
|
25593
|
+
* signed-out form takes the unsent text. A website account the customer
|
|
25594
|
+
* switched away from still stands behind it (`switchedAccount` is kept).
|
|
25595
|
+
*/
|
|
25596
|
+
function signOut(composition) {
|
|
25597
|
+
if (!client || destroyed || state.navigationLocked)
|
|
25598
|
+
return;
|
|
25599
|
+
const active = client;
|
|
25600
|
+
sequence += 1;
|
|
25601
|
+
leaveCustomer(composition);
|
|
25602
|
+
pendingArrival = { from: 'signOut', droppedFiles: composition?.hadFiles === true };
|
|
25603
|
+
update({ error: undefined, results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
25604
|
+
// The session ends here at once, and the host hears so; a refused or lost
|
|
25605
|
+
// revocation leaves this browser signed out all the same.
|
|
25606
|
+
void active.signOutSupport().catch((value) => notify(options.onError, failure(value)));
|
|
25607
|
+
// A host that keeps the session cleans up after it as its own sign-out does.
|
|
25608
|
+
const host = options.hostKeepsSession;
|
|
25609
|
+
notify(host ? () => host.onSignOut() : undefined, undefined);
|
|
25610
|
+
void showContact('direct');
|
|
25403
25611
|
}
|
|
25404
25612
|
async function useWebsiteAccount(composition, recovering = false) {
|
|
25405
25613
|
if (!client || destroyed || state.navigationLocked)
|
|
25406
25614
|
return;
|
|
25407
25615
|
const ownSequence = ++sequence;
|
|
25408
|
-
|
|
25409
|
-
contact = null;
|
|
25410
|
-
cancelArticleAssets?.();
|
|
25411
|
-
cancelArticleAssets = null;
|
|
25412
|
-
pendingComposition = composition ?? { subject: '', body: '' };
|
|
25616
|
+
leaveCustomer(composition);
|
|
25413
25617
|
pendingRecovery = recovering ? { websiteSignedOut: true } : null;
|
|
25414
|
-
kb?.clearAccess();
|
|
25415
|
-
kbConfig = null;
|
|
25416
|
-
results = [];
|
|
25417
|
-
requestedArticle = null;
|
|
25418
|
-
attempt = null;
|
|
25419
|
-
sourceArticleId = undefined;
|
|
25420
25618
|
update({ busy: true, error: undefined, results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
25421
25619
|
try {
|
|
25422
25620
|
await client.useWebsiteAccount();
|
|
25423
25621
|
if (destroyed || ownSequence !== sequence)
|
|
25424
25622
|
return;
|
|
25425
25623
|
switchedAccount = false;
|
|
25624
|
+
// The website account the form arrives at says so, as a switch does; one
|
|
25625
|
+
// the website does not give back gets none (`mountContact`).
|
|
25626
|
+
pendingArrival = { from: 'switch', droppedFiles: composition?.hadFiles === true };
|
|
25426
25627
|
update({ busy: false });
|
|
25427
25628
|
await showContact('direct');
|
|
25428
25629
|
}
|
|
@@ -25435,7 +25636,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
25435
25636
|
if (pendingRecovery)
|
|
25436
25637
|
pendingRecovery = { websiteSignedOut: false };
|
|
25437
25638
|
if (client.hasTicketAccess) {
|
|
25438
|
-
mountContact(
|
|
25639
|
+
mountContact(pendingComposition, null);
|
|
25439
25640
|
pendingComposition = null;
|
|
25440
25641
|
}
|
|
25441
25642
|
else
|
|
@@ -30248,7 +30449,7 @@ class SparkVault {
|
|
|
30248
30449
|
}
|
|
30249
30450
|
/** Get the SDK version */
|
|
30250
30451
|
static get version() {
|
|
30251
|
-
return '16.
|
|
30452
|
+
return '16.6.0';
|
|
30252
30453
|
}
|
|
30253
30454
|
}
|
|
30254
30455
|
if (typeof window !== 'undefined') {
|