@sparkvault/sdk-js 16.5.1 → 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 +320 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +61 -16
- package/dist/index.mjs +320 -146
- 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/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -18149,7 +18149,7 @@ class HelpDeskClient {
|
|
|
18149
18149
|
// the `federated` mark and the `federated` assurance together, never one without the other.
|
|
18150
18150
|
const customer = result?.customer;
|
|
18151
18151
|
const nativeIdentity = customer?.federated === true ? customer.assurance === 'federated' : customer?.assurance === 'identity';
|
|
18152
|
-
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)) {
|
|
18153
18153
|
throw new SparkVaultError('The help desk returned an invalid support identity.', 'HELP_DESK_INVALID_RESPONSE');
|
|
18154
18154
|
}
|
|
18155
18155
|
this.issuedSessions.set(result, result.token);
|
|
@@ -18161,6 +18161,16 @@ class HelpDeskClient {
|
|
|
18161
18161
|
this.websiteAccountSuppressed = true;
|
|
18162
18162
|
return this.releaseSession(false);
|
|
18163
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
|
+
}
|
|
18164
18174
|
/** The only operation that resumes the website's configured identity provider after an explicit switch. */
|
|
18165
18175
|
async useWebsiteAccount() {
|
|
18166
18176
|
await this.releaseSession(false);
|
|
@@ -19259,7 +19269,7 @@ function carriesFiles(event) {
|
|
|
19259
19269
|
* refusals as a picked one; the drop target shows only over the composer. A
|
|
19260
19270
|
* paste or drag of text alone stays the browser's. A file brought over the
|
|
19261
19271
|
* form is never the browser's to open in place of the unsent request: on the
|
|
19262
|
-
*
|
|
19272
|
+
* sign-in step, or while the form takes no files, it is refused outright,
|
|
19263
19273
|
* and a desk that takes no files says so when the file is dropped.
|
|
19264
19274
|
*/
|
|
19265
19275
|
function createComposer(options) {
|
|
@@ -19571,6 +19581,11 @@ function postingName(customer) {
|
|
|
19571
19581
|
return words[0];
|
|
19572
19582
|
return `${words[0]} ${Array.from(words[words.length - 1])[0]}.`;
|
|
19573
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
|
+
}
|
|
19574
19589
|
function focusAtEnd(field, focusOptions) {
|
|
19575
19590
|
field.focus(focusOptions);
|
|
19576
19591
|
// An email field has no caret to place.
|
|
@@ -19586,6 +19601,12 @@ function textButton(text, action) {
|
|
|
19586
19601
|
button.addEventListener('click', action);
|
|
19587
19602
|
return button;
|
|
19588
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.';
|
|
19589
19610
|
const SIGN_IN_CANCELLED_COPY = 'Sign-in was cancelled. Your request is still here and hasn’t been sent.';
|
|
19590
19611
|
const RECOVER_STATUS_COPY = 'Sign in again to recover your saved request.';
|
|
19591
19612
|
const RECOVER_WEBSITE_COPY = 'Sign in to your website account again to recover your saved request.';
|
|
@@ -19656,7 +19677,9 @@ function companySignInUrl(value) {
|
|
|
19656
19677
|
*
|
|
19657
19678
|
* The request is a summary and optional details, in a composer that also
|
|
19658
19679
|
* takes files. A signed-out widget customer writes it as step 1 of 2; step 2
|
|
19659
|
-
* 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.
|
|
19660
19683
|
*/
|
|
19661
19684
|
function mountHelpDeskForm(client, options) {
|
|
19662
19685
|
const target = resolveTarget(options.target);
|
|
@@ -19751,9 +19774,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
19751
19774
|
const email = field('Email address', 'email');
|
|
19752
19775
|
const code = field('Email code', 'code');
|
|
19753
19776
|
const name = field('Your name', 'display_name');
|
|
19754
|
-
const
|
|
19755
|
-
const lastName = field('Last name (optional)', 'family_name');
|
|
19756
|
-
const fields = [subject, description, email, code, name, firstName, lastName];
|
|
19777
|
+
const fields = [subject, description, email, code, name];
|
|
19757
19778
|
// The support wizard's issue the form was last filled from, which either
|
|
19758
19779
|
// field may hold; undefined for a form filled from the host's subject and body.
|
|
19759
19780
|
let filledFrom = options.issue;
|
|
@@ -19768,10 +19789,6 @@ function mountHelpDeskForm(client, options) {
|
|
|
19768
19789
|
code.input.inputMode = 'numeric';
|
|
19769
19790
|
code.input.autocomplete = 'one-time-code';
|
|
19770
19791
|
name.input.autocomplete = 'name';
|
|
19771
|
-
firstName.input.autocomplete = 'given-name';
|
|
19772
|
-
lastName.input.autocomplete = 'family-name';
|
|
19773
|
-
firstName.input.maxLength = 100;
|
|
19774
|
-
lastName.input.maxLength = 100;
|
|
19775
19792
|
const codeHint = document.createElement('p');
|
|
19776
19793
|
codeHint.id = `${code.input.id}-hint`;
|
|
19777
19794
|
codeHint.className = 'svhd-hint';
|
|
@@ -19824,16 +19841,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
19824
19841
|
description.wrapper.insertBefore(composer.frame, description.error);
|
|
19825
19842
|
description.wrapper.insertBefore(composer.notice, description.error);
|
|
19826
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.
|
|
19827
19846
|
const auth = document.createElement('fieldset');
|
|
19828
19847
|
auth.className = 'svhd-auth';
|
|
19829
19848
|
auth.hidden = true;
|
|
19830
|
-
auth.append(code.wrapper, name.wrapper);
|
|
19849
|
+
auth.append(email.wrapper, code.wrapper, name.wrapper);
|
|
19831
19850
|
const widgetAccount = document.createElement('div');
|
|
19832
19851
|
widgetAccount.className = 'svhd-widget-account';
|
|
19833
19852
|
let widgetCustomer = widget?.customer ?? null;
|
|
19834
|
-
|
|
19835
|
-
const asksName = client.desk.auth_mode !== 'identity';
|
|
19836
|
-
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;
|
|
19837
19854
|
const identity = widget ? stepContainer('identity') : null;
|
|
19838
19855
|
const recap = document.createElement('div');
|
|
19839
19856
|
recap.className = 'svhd-recap';
|
|
@@ -19843,11 +19860,13 @@ function mountHelpDeskForm(client, options) {
|
|
|
19843
19860
|
enterStep('details'); });
|
|
19844
19861
|
editRequest.setAttribute('aria-label', 'Edit your request');
|
|
19845
19862
|
const noteText = document.createTextNode('');
|
|
19846
|
-
|
|
19847
|
-
|
|
19848
|
-
|
|
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;
|
|
19849
19868
|
const live = createLiveRegion('svhd-live');
|
|
19850
|
-
if (identity &&
|
|
19869
|
+
if (identity && signInStep) {
|
|
19851
19870
|
form.classList.add('svhd-widget-form');
|
|
19852
19871
|
details.append(widgetAccount);
|
|
19853
19872
|
identity.hidden = true;
|
|
@@ -19862,22 +19881,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
19862
19881
|
recapLabel.textContent = 'Your request';
|
|
19863
19882
|
recapRequest.append(recapLabel, recapText);
|
|
19864
19883
|
recap.append(recapRequest, editRequest);
|
|
19865
|
-
|
|
19866
|
-
helper.id = `${email.input.id}-help`;
|
|
19867
|
-
helper.className = 'svhd-hint';
|
|
19868
|
-
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.';
|
|
19869
|
-
email.input.setAttribute('aria-describedby', helper.id);
|
|
19870
|
-
identity.append(reply.head, note, recap);
|
|
19871
|
-
if (asksName) {
|
|
19872
|
-
const names = document.createElement('div');
|
|
19873
|
-
names.className = 'svhd-widget-names';
|
|
19874
|
-
names.append(firstName.wrapper, lastName.wrapper);
|
|
19875
|
-
identity.append(names);
|
|
19876
|
-
}
|
|
19877
|
-
identity.append(email.wrapper, helper);
|
|
19884
|
+
identity.append(signInStep.head, note, recap, signInHelp);
|
|
19878
19885
|
}
|
|
19879
|
-
else
|
|
19880
|
-
auth.prepend(email.wrapper);
|
|
19881
19886
|
const status = document.createElement('p');
|
|
19882
19887
|
status.className = 'svhd-status';
|
|
19883
19888
|
status.setAttribute('role', 'status');
|
|
@@ -19969,6 +19974,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
19969
19974
|
let recovery = null;
|
|
19970
19975
|
// The website gave no account back when asked for the hidden request's customer.
|
|
19971
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;
|
|
19972
19979
|
function persistDraft() {
|
|
19973
19980
|
if (!options.persist || completed || destroyed)
|
|
19974
19981
|
return;
|
|
@@ -20023,9 +20030,15 @@ function mountHelpDeskForm(client, options) {
|
|
|
20023
20030
|
: 'Your saved request was restored. Review it before sending.');
|
|
20024
20031
|
return true;
|
|
20025
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
|
+
*/
|
|
20026
20039
|
function safeComposition() {
|
|
20027
|
-
|
|
20028
|
-
|
|
20040
|
+
return pending || uncertainSubmission !== null || completed ? null
|
|
20041
|
+
: { subject: subject.input.value, body: description.input.value, hadFiles: attachments?.hasEntries === true };
|
|
20029
20042
|
}
|
|
20030
20043
|
/** What the send button reads while nothing is in flight. */
|
|
20031
20044
|
function idleLabel() {
|
|
@@ -20035,14 +20048,17 @@ function mountHelpDeskForm(client, options) {
|
|
|
20035
20048
|
return 'Verify and send request';
|
|
20036
20049
|
if (recovery === 'external_sso' && widget)
|
|
20037
20050
|
return 'Use website account';
|
|
20038
|
-
if (recovery !== null
|
|
20051
|
+
if (recovery !== null)
|
|
20039
20052
|
return 'Sign in to recover request';
|
|
20040
|
-
|
|
20053
|
+
if (widget && !widgetCustomer)
|
|
20054
|
+
return step === 'identity' ? 'Sign in and send' : 'Continue';
|
|
20055
|
+
return 'Send request';
|
|
20041
20056
|
}
|
|
20042
20057
|
/**
|
|
20043
20058
|
* The signed-in widget customer writes and sends in one step, posting as
|
|
20044
|
-
* the account named under it
|
|
20045
|
-
*
|
|
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.
|
|
20046
20062
|
*/
|
|
20047
20063
|
function renderWidgetIdentity() {
|
|
20048
20064
|
if (!widget)
|
|
@@ -20057,12 +20073,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
20057
20073
|
if (widgetCustomer) {
|
|
20058
20074
|
const postingAs = document.createElement('p');
|
|
20059
20075
|
postingAs.className = 'svhd-posting-as';
|
|
20060
|
-
|
|
20061
|
-
|
|
20062
|
-
|
|
20063
|
-
|
|
20064
|
-
|
|
20065
|
-
|
|
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
|
+
}
|
|
20066
20084
|
widgetAccount.append(postingAs);
|
|
20067
20085
|
}
|
|
20068
20086
|
if (widget.useWebsiteAccount && widget.offerWebsiteAccount) {
|
|
@@ -20077,7 +20095,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20077
20095
|
* The actions and notes for where the request is. While the form hides a
|
|
20078
20096
|
* previous customer's saved request (`recovery`), nothing shows of it, nor
|
|
20079
20097
|
* says it was not sent, since it may be a send whose answer was lost: the
|
|
20080
|
-
* 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
|
|
20081
20099
|
* step's note alone speaks there, Start a new request leaves it, and the
|
|
20082
20100
|
* account row is away. A website-account customer's request comes back only
|
|
20083
20101
|
* through that account, so Use website account is its one way on when the
|
|
@@ -20089,7 +20107,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20089
20107
|
startNew.hidden = recovery === null;
|
|
20090
20108
|
widgetAccount.hidden = recovery !== null || widgetAccount.childElementCount === 0;
|
|
20091
20109
|
recap.hidden = recovery !== null;
|
|
20092
|
-
noteText.data = recovery === 'identity' || recovery === 'email_pin' ? RECOVER_NOTE_COPY :
|
|
20110
|
+
noteText.data = recovery === 'identity' || recovery === 'email_pin' ? RECOVER_NOTE_COPY : UNSENT_NOTE_COPY;
|
|
20093
20111
|
if (recovery !== null)
|
|
20094
20112
|
message(step === 'identity' ? '' : recoveryStatus());
|
|
20095
20113
|
}
|
|
@@ -20114,15 +20132,19 @@ function mountHelpDeskForm(client, options) {
|
|
|
20114
20132
|
controller.focusEntry();
|
|
20115
20133
|
}
|
|
20116
20134
|
}
|
|
20117
|
-
/** Show one step, the request or
|
|
20135
|
+
/** Show one step, the request or its sign-in, without moving focus. */
|
|
20118
20136
|
function setStep(next) {
|
|
20119
20137
|
const changed = next !== step;
|
|
20120
20138
|
step = next;
|
|
20121
20139
|
details.hidden = next !== 'details';
|
|
20122
20140
|
if (identity)
|
|
20123
20141
|
identity.hidden = next !== 'identity';
|
|
20124
|
-
if (next === 'identity')
|
|
20142
|
+
if (next === 'identity') {
|
|
20125
20143
|
recapText.textContent = subject.input.value.trim();
|
|
20144
|
+
send.setAttribute('aria-describedby', signInHelp.id);
|
|
20145
|
+
}
|
|
20146
|
+
else
|
|
20147
|
+
send.removeAttribute('aria-describedby');
|
|
20126
20148
|
renderActions();
|
|
20127
20149
|
syncLeaveGuard();
|
|
20128
20150
|
if (changed)
|
|
@@ -20130,9 +20152,11 @@ function mountHelpDeskForm(client, options) {
|
|
|
20130
20152
|
}
|
|
20131
20153
|
/** The customer moves between the steps: the new step's heading takes focus and its place is announced. */
|
|
20132
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('');
|
|
20133
20157
|
setStep(next);
|
|
20134
20158
|
live.announce(next === 'identity' ? 'Step 2 of 2' : 'Step 1 of 2');
|
|
20135
|
-
(next === 'identity' &&
|
|
20159
|
+
(next === 'identity' && signInStep ? signInStep.heading : heading).focus();
|
|
20136
20160
|
}
|
|
20137
20161
|
// An inline wizard, on any host page that gives a `target`, asks before that
|
|
20138
20162
|
// page unloads while the request holds unsent work: leaving would lose it.
|
|
@@ -20190,7 +20214,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20190
20214
|
* in place of anything written.
|
|
20191
20215
|
*/
|
|
20192
20216
|
function disable(disabled) {
|
|
20193
|
-
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])
|
|
20194
20218
|
input.disabled = disabled;
|
|
20195
20219
|
const held = uncertainSubmission !== null || recovery !== null;
|
|
20196
20220
|
subject.input.readOnly = held;
|
|
@@ -20227,10 +20251,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
20227
20251
|
? 'We may already have received this request. Closing now loses the way to check it.'
|
|
20228
20252
|
: DISCARD_REQUEST_COPY.note;
|
|
20229
20253
|
}
|
|
20230
|
-
/** The field
|
|
20254
|
+
/** The field the request step asks for: the code, name or email the form asks for itself, else the summary. */
|
|
20231
20255
|
function stepField() {
|
|
20232
|
-
if (step === 'identity')
|
|
20233
|
-
return (asksName ? firstName : email).input;
|
|
20234
20256
|
const asked = auth.hidden ? undefined : [code, name, email].find((entry) => !entry.wrapper.hidden);
|
|
20235
20257
|
return (asked ?? subject).input;
|
|
20236
20258
|
}
|
|
@@ -20238,7 +20260,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20238
20260
|
// A press on the modal's backdrop leaves focus on the page body, and
|
|
20239
20261
|
// Keep editing must never hand focus back outside the dialog.
|
|
20240
20262
|
const active = document.activeElement;
|
|
20241
|
-
confirmReturn = active instanceof HTMLElement && shell.container.contains(active) ? active : stepField();
|
|
20263
|
+
confirmReturn = active instanceof HTMLElement && shell.container.contains(active) ? active : step === 'identity' ? send : stepField();
|
|
20242
20264
|
renderConfirmNote();
|
|
20243
20265
|
actions.hidden = true;
|
|
20244
20266
|
confirm.hidden = false;
|
|
@@ -20271,7 +20293,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20271
20293
|
}
|
|
20272
20294
|
/**
|
|
20273
20295
|
* Whether closing now would lose something: a send under way or
|
|
20274
|
-
* unanswered, a code step, a request moved on to
|
|
20296
|
+
* unanswered, a code step, a request moved on to its sign-in step, or
|
|
20275
20297
|
* text and files of the customer's own. The silent company sign-in the
|
|
20276
20298
|
* form runs as it opens (`authenticating`) is no work of the customer's.
|
|
20277
20299
|
*/
|
|
@@ -20373,11 +20395,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20373
20395
|
code.wrapper.hidden = true;
|
|
20374
20396
|
name.wrapper.hidden = true;
|
|
20375
20397
|
auth.hidden = true;
|
|
20376
|
-
|
|
20377
|
-
firstName.input.value = '';
|
|
20378
|
-
lastName.input.value = '';
|
|
20379
|
-
renderWidgetIdentity();
|
|
20380
|
-
}
|
|
20398
|
+
renderWidgetIdentity();
|
|
20381
20399
|
hosted.hidden = true;
|
|
20382
20400
|
draftId = null;
|
|
20383
20401
|
draftPromise = null;
|
|
@@ -20445,6 +20463,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20445
20463
|
restoredFiles = false;
|
|
20446
20464
|
generation += 1;
|
|
20447
20465
|
pending = false;
|
|
20466
|
+
switchingAccount = false;
|
|
20448
20467
|
sessionKnown = false;
|
|
20449
20468
|
if (options.widgetIdentity)
|
|
20450
20469
|
widgetCustomer = null;
|
|
@@ -20564,25 +20583,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
20564
20583
|
}
|
|
20565
20584
|
let widgetSignIn;
|
|
20566
20585
|
if (widget && !widgetCustomer) {
|
|
20567
|
-
// The request is written;
|
|
20586
|
+
// The request is written; signing in to send it is the next step, and
|
|
20568
20587
|
// nothing reaches the network before it.
|
|
20569
20588
|
if (step === 'details') {
|
|
20570
20589
|
enterStep('identity');
|
|
20571
20590
|
return;
|
|
20572
20591
|
}
|
|
20573
|
-
const givenName = asksName ? firstName.input.value.trim() : '';
|
|
20574
|
-
const familyName = asksName ? lastName.input.value.trim() : '';
|
|
20575
|
-
const emailAddress = email.input.value.trim();
|
|
20576
|
-
const invalid = asksName && !givenName ? firstName : !email.input.validity.valid || !emailAddress ? email : null;
|
|
20577
|
-
if (invalid) {
|
|
20578
|
-
setFieldError(invalid, invalid === email ? 'Enter your email address.' : 'Enter your first name.');
|
|
20579
|
-
invalid.input.focus();
|
|
20580
|
-
return;
|
|
20581
|
-
}
|
|
20582
20592
|
// Invoke in the original submit gesture, before any awaited token read:
|
|
20583
20593
|
// the Identity adapter can open its native window without a popup block.
|
|
20584
20594
|
try {
|
|
20585
|
-
widgetSignIn = widget.signIn(
|
|
20595
|
+
widgetSignIn = widget.signIn();
|
|
20586
20596
|
}
|
|
20587
20597
|
catch (failure) {
|
|
20588
20598
|
const error = failure instanceof Error ? failure : new Error('Sign-in could not be opened.');
|
|
@@ -20605,7 +20615,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20605
20615
|
authenticating = true;
|
|
20606
20616
|
authNotification = false;
|
|
20607
20617
|
setState('authenticating');
|
|
20608
|
-
message(
|
|
20618
|
+
message(SIGNING_IN_COPY);
|
|
20609
20619
|
}
|
|
20610
20620
|
let token = await tokenFor(ownGeneration);
|
|
20611
20621
|
if (!alive(ownGeneration))
|
|
@@ -20806,7 +20816,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20806
20816
|
focusAfter = code.input;
|
|
20807
20817
|
}
|
|
20808
20818
|
else if (widgetSignIn && error instanceof SparkVaultError && error.code === 'user_cancelled') {
|
|
20809
|
-
// The request stays on
|
|
20819
|
+
// The request stays on its sign-in step, ready to sign in again;
|
|
20810
20820
|
// a hidden saved request is not here to speak of, so its note alone stays.
|
|
20811
20821
|
if (recovery === null)
|
|
20812
20822
|
message(SIGN_IN_CANCELLED_COPY);
|
|
@@ -20865,6 +20875,84 @@ function mountHelpDeskForm(client, options) {
|
|
|
20865
20875
|
}
|
|
20866
20876
|
}
|
|
20867
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
|
+
}
|
|
20868
20956
|
/** Take a typed, pasted or autofilled code as its digits, and send it the moment the last one lands. */
|
|
20869
20957
|
function takeCode(value) {
|
|
20870
20958
|
const digits = helpDeskPinDigits(value);
|
|
@@ -20886,26 +20974,47 @@ function mountHelpDeskForm(client, options) {
|
|
|
20886
20974
|
/** The Cancel path: remove the form, then tell the host the customer closed it. */
|
|
20887
20975
|
function dismiss() {
|
|
20888
20976
|
const discardDraft = uncertainSubmission === null;
|
|
20889
|
-
|
|
20977
|
+
if (!destroyed)
|
|
20978
|
+
teardown(!discardDraft);
|
|
20890
20979
|
if (discardDraft)
|
|
20891
20980
|
forgetDraft();
|
|
20892
20981
|
notify$1(options.onCancel, undefined);
|
|
20893
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
|
+
}
|
|
20894
20998
|
const controller = {
|
|
20895
20999
|
destroy() {
|
|
21000
|
+
if (!destroyed)
|
|
21001
|
+
teardown(true);
|
|
21002
|
+
},
|
|
21003
|
+
leave() {
|
|
20896
21004
|
if (destroyed)
|
|
20897
21005
|
return;
|
|
20898
|
-
|
|
20899
|
-
|
|
20900
|
-
|
|
20901
|
-
|
|
20902
|
-
|
|
20903
|
-
|
|
20904
|
-
|
|
20905
|
-
|
|
20906
|
-
|
|
20907
|
-
|
|
20908
|
-
|
|
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);
|
|
20909
21018
|
},
|
|
20910
21019
|
reset() {
|
|
20911
21020
|
if (destroyed || pending || uncertainSubmission)
|
|
@@ -20921,7 +21030,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20921
21030
|
},
|
|
20922
21031
|
getState: () => state,
|
|
20923
21032
|
restoreComposition(composition) {
|
|
20924
|
-
if (destroyed ||
|
|
21033
|
+
if (destroyed || holdsSavedRequest())
|
|
20925
21034
|
return;
|
|
20926
21035
|
subject.input.value = composition.subject;
|
|
20927
21036
|
description.input.value = composition.body;
|
|
@@ -20962,10 +21071,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
20962
21071
|
focusEntry(focusOptions) {
|
|
20963
21072
|
if (destroyed || form.hidden)
|
|
20964
21073
|
return false;
|
|
21074
|
+
if (step === 'identity' && signInStep) {
|
|
21075
|
+
(send.disabled ? signInStep.heading : send).focus(focusOptions);
|
|
21076
|
+
return true;
|
|
21077
|
+
}
|
|
20965
21078
|
const asked = stepField();
|
|
20966
21079
|
const entry = asked === subject.input && subject.input.value.trim() ? description.input : asked;
|
|
20967
21080
|
if (entry.disabled || entry.readOnly)
|
|
20968
|
-
|
|
21081
|
+
heading.focus(focusOptions);
|
|
20969
21082
|
else
|
|
20970
21083
|
focusAtEnd(entry, focusOptions);
|
|
20971
21084
|
return true;
|
|
@@ -21009,9 +21122,6 @@ function mountHelpDeskForm(client, options) {
|
|
|
21009
21122
|
});
|
|
21010
21123
|
send.textContent = idleLabel();
|
|
21011
21124
|
renderWidgetIdentity();
|
|
21012
|
-
// A signed-out widget customer starts on step 1 of 2 with focus in the request.
|
|
21013
|
-
if (widget && !widgetCustomer)
|
|
21014
|
-
live.announce('Step 1 of 2');
|
|
21015
21125
|
if (options.widgetIdentity?.customer) {
|
|
21016
21126
|
restoreDraft(options.widgetIdentity.customer);
|
|
21017
21127
|
disable(false);
|
|
@@ -21032,6 +21142,15 @@ function mountHelpDeskForm(client, options) {
|
|
|
21032
21142
|
restoredAnonymous = true;
|
|
21033
21143
|
}
|
|
21034
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');
|
|
21035
21154
|
syncLeaveGuard();
|
|
21036
21155
|
notify$1(options.onStateChange, state);
|
|
21037
21156
|
// Native company identity starts as the form opens, never from a Connect,
|
|
@@ -23402,7 +23521,6 @@ function injectHelpDeskSupportStyles() {
|
|
|
23402
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}}
|
|
23403
23522
|
.svhs-panel .svhd-composer-input:focus-visible{outline:none}
|
|
23404
23523
|
.svhs-panel .svhd-composer button:focus-visible{outline-offset:-2px}
|
|
23405
|
-
.svhs-contact-target .svhd-widget-names{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px}
|
|
23406
23524
|
.svhs-contact-target .svhd-widget-form{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
23407
23525
|
/* The request fills the panel: the details step, and in it the composer and its text, take the height the fields leave. */
|
|
23408
23526
|
.svhs-contact-target .svhd-widget-form>[data-contact-step=details]{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
@@ -24753,6 +24871,13 @@ function createHelpDeskSupport(config, options) {
|
|
|
24753
24871
|
// A website-account customer's saved request the next form keeps hidden,
|
|
24754
24872
|
// asked for through the website account, which may give no account back.
|
|
24755
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;
|
|
24756
24881
|
// The issue, as written, that the held composition (the mounted form, the one
|
|
24757
24882
|
// a re-authorized form will take, or the one saved before a reload) was last
|
|
24758
24883
|
// filled from: '' for one filled from none. A form taking that composition is
|
|
@@ -24791,7 +24916,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
24791
24916
|
onBack: () => {
|
|
24792
24917
|
if (destroyed || state.navigationLocked || state.identityPending)
|
|
24793
24918
|
return;
|
|
24794
|
-
// On
|
|
24919
|
+
// On the sign-in step, Back returns to the request it is for.
|
|
24795
24920
|
if (state.stage === 'contact' && !state.ticketAccessRequired && contact?.returnToRequest())
|
|
24796
24921
|
return;
|
|
24797
24922
|
// A held form shows at once while contact still checks access behind it,
|
|
@@ -24869,7 +24994,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
24869
24994
|
throw new Error('Support is closed.');
|
|
24870
24995
|
client = answer;
|
|
24871
24996
|
stopSession = answer.subscribeSession((change) => {
|
|
24872
|
-
if (change.source === 'clear')
|
|
24997
|
+
if (change.source === 'clear' && !replacingSession)
|
|
24873
24998
|
notify(options.onSession, null);
|
|
24874
24999
|
});
|
|
24875
25000
|
kb = new HelpDeskKnowledgeBaseClient(config, answer.desk.desk_id);
|
|
@@ -25000,6 +25125,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
25000
25125
|
requestedArticle = null;
|
|
25001
25126
|
pendingComposition = null;
|
|
25002
25127
|
pendingRecovery = null;
|
|
25128
|
+
pendingArrival = null;
|
|
25003
25129
|
feedbackSequence += 1;
|
|
25004
25130
|
sourceArticleId = undefined;
|
|
25005
25131
|
if (options.persist && client)
|
|
@@ -25165,14 +25291,19 @@ function createHelpDeskSupport(config, options) {
|
|
|
25165
25291
|
if (!client || destroyed)
|
|
25166
25292
|
return;
|
|
25167
25293
|
contactCustomer = customer;
|
|
25294
|
+
anonymous = !customer;
|
|
25168
25295
|
// A customer the website gave back sees their own saved request; none keeps it hidden.
|
|
25169
25296
|
const recovering = customer ? null : pendingRecovery;
|
|
25170
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;
|
|
25171
25301
|
let activeAttempt = null;
|
|
25172
25302
|
// A ticket carries the attempt the form opened under only while it is still
|
|
25173
25303
|
// the journey's: recovery drops it with the previous customer's question.
|
|
25174
25304
|
const formAttempt = attempt;
|
|
25175
|
-
|
|
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);
|
|
25176
25307
|
contact = mountHelpDeskForm(client, {
|
|
25177
25308
|
target: view.contactTarget,
|
|
25178
25309
|
// Filled from the issue its composition came from, so text the customer
|
|
@@ -25190,13 +25321,15 @@ function createHelpDeskSupport(config, options) {
|
|
|
25190
25321
|
},
|
|
25191
25322
|
widgetIdentity: {
|
|
25192
25323
|
customer,
|
|
25193
|
-
signIn: (
|
|
25194
|
-
switchAccount
|
|
25324
|
+
signIn: () => signIn().then((session) => { contactCustomer = session.customer; return session; }),
|
|
25325
|
+
switchAccount,
|
|
25326
|
+
signOut,
|
|
25195
25327
|
...(bridged && { useWebsiteAccount: (safe, recover) => { void useWebsiteAccount(safe, recover); } }),
|
|
25196
25328
|
offerWebsiteAccount: switchedAccount,
|
|
25197
25329
|
forgetIssue,
|
|
25198
25330
|
followIssue,
|
|
25199
25331
|
...(recovering && { recovering }),
|
|
25332
|
+
...(arrived && { arrived }),
|
|
25200
25333
|
},
|
|
25201
25334
|
onScreenChange: () => view.contactScreenChanged(),
|
|
25202
25335
|
assistanceContext: () => (attempt === formAttempt ? activeAttempt?.ticketContext() : undefined),
|
|
@@ -25310,7 +25443,6 @@ function createHelpDeskSupport(config, options) {
|
|
|
25310
25443
|
if (destroyed || ownSequence !== sequence)
|
|
25311
25444
|
return;
|
|
25312
25445
|
update({ busy: false, ticketAccessRequired: false, ticketAccessMode: undefined });
|
|
25313
|
-
anonymous = !customer;
|
|
25314
25446
|
// A composition saved before a reload goes on from the issue it was filled
|
|
25315
25447
|
// from; with none carried, the form fills itself from the issue as written.
|
|
25316
25448
|
const saved = pendingComposition === null && options.persist ? readAnonymousFormDraft(active.desk.desk_id) : null;
|
|
@@ -25374,78 +25506,120 @@ function createHelpDeskSupport(config, options) {
|
|
|
25374
25506
|
notify(options.onError, error);
|
|
25375
25507
|
}
|
|
25376
25508
|
}
|
|
25377
|
-
|
|
25378
|
-
|
|
25379
|
-
|
|
25380
|
-
|
|
25381
|
-
|
|
25382
|
-
|
|
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();
|
|
25383
25521
|
contact = null;
|
|
25522
|
+
contactCustomer = null;
|
|
25384
25523
|
cancelArticleAssets?.();
|
|
25385
25524
|
cancelArticleAssets = null;
|
|
25386
|
-
pendingComposition = composition
|
|
25525
|
+
pendingComposition = composition ? { subject: composition.subject, body: composition.body } : { subject: '', body: '' };
|
|
25387
25526
|
pendingRecovery = null;
|
|
25527
|
+
pendingArrival = null;
|
|
25388
25528
|
kb?.clearAccess();
|
|
25389
25529
|
kbConfig = null;
|
|
25390
25530
|
results = [];
|
|
25391
25531
|
requestedArticle = null;
|
|
25392
25532
|
attempt = null;
|
|
25393
25533
|
sourceArticleId = undefined;
|
|
25394
|
-
|
|
25395
|
-
|
|
25396
|
-
|
|
25397
|
-
|
|
25398
|
-
|
|
25399
|
-
|
|
25400
|
-
|
|
25401
|
-
|
|
25402
|
-
|
|
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)
|
|
25403
25548
|
return;
|
|
25404
|
-
|
|
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 {
|
|
25405
25575
|
notify(options.onTicketAccess, await active.unlockTicketAccess({ identityGrant: session.identity_grant.token }));
|
|
25406
|
-
if (destroyed || ownSequence !== sequence)
|
|
25407
|
-
return;
|
|
25408
|
-
active.setSession(session);
|
|
25409
|
-
notify(options.onSession, session);
|
|
25410
|
-
update({ busy: false });
|
|
25411
|
-
await showContact('direct');
|
|
25412
|
-
}
|
|
25413
|
-
catch (value) {
|
|
25414
|
-
await logout.catch(() => undefined);
|
|
25415
|
-
if (destroyed || ownSequence !== sequence)
|
|
25416
|
-
return;
|
|
25417
|
-
const error = failure(value);
|
|
25418
|
-
update({ busy: false, error: error.message });
|
|
25419
|
-
if (active.hasTicketAccess) {
|
|
25420
|
-
mountContact(composition ?? { subject: '', body: '' }, null);
|
|
25421
|
-
pendingComposition = null;
|
|
25422
25576
|
}
|
|
25423
|
-
|
|
25424
|
-
|
|
25577
|
+
catch (value) {
|
|
25578
|
+
if (!destroyed && ownSequence === sequence)
|
|
25579
|
+
notify(options.onError, failure(value));
|
|
25580
|
+
}
|
|
25425
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');
|
|
25426
25607
|
}
|
|
25427
25608
|
async function useWebsiteAccount(composition, recovering = false) {
|
|
25428
25609
|
if (!client || destroyed || state.navigationLocked)
|
|
25429
25610
|
return;
|
|
25430
25611
|
const ownSequence = ++sequence;
|
|
25431
|
-
|
|
25432
|
-
contact = null;
|
|
25433
|
-
cancelArticleAssets?.();
|
|
25434
|
-
cancelArticleAssets = null;
|
|
25435
|
-
pendingComposition = composition ?? { subject: '', body: '' };
|
|
25612
|
+
leaveCustomer(composition);
|
|
25436
25613
|
pendingRecovery = recovering ? { websiteSignedOut: true } : null;
|
|
25437
|
-
kb?.clearAccess();
|
|
25438
|
-
kbConfig = null;
|
|
25439
|
-
results = [];
|
|
25440
|
-
requestedArticle = null;
|
|
25441
|
-
attempt = null;
|
|
25442
|
-
sourceArticleId = undefined;
|
|
25443
25614
|
update({ busy: true, error: undefined, results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
25444
25615
|
try {
|
|
25445
25616
|
await client.useWebsiteAccount();
|
|
25446
25617
|
if (destroyed || ownSequence !== sequence)
|
|
25447
25618
|
return;
|
|
25448
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 };
|
|
25449
25623
|
update({ busy: false });
|
|
25450
25624
|
await showContact('direct');
|
|
25451
25625
|
}
|
|
@@ -25458,7 +25632,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
25458
25632
|
if (pendingRecovery)
|
|
25459
25633
|
pendingRecovery = { websiteSignedOut: false };
|
|
25460
25634
|
if (client.hasTicketAccess) {
|
|
25461
|
-
mountContact(
|
|
25635
|
+
mountContact(pendingComposition, null);
|
|
25462
25636
|
pendingComposition = null;
|
|
25463
25637
|
}
|
|
25464
25638
|
else
|
|
@@ -30271,7 +30445,7 @@ class SparkVault {
|
|
|
30271
30445
|
}
|
|
30272
30446
|
/** Get the SDK version */
|
|
30273
30447
|
static get version() {
|
|
30274
|
-
return '16.
|
|
30448
|
+
return '16.6.0';
|
|
30275
30449
|
}
|
|
30276
30450
|
}
|
|
30277
30451
|
if (typeof window !== 'undefined') {
|