@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.cjs
CHANGED
|
@@ -18153,7 +18153,7 @@ class HelpDeskClient {
|
|
|
18153
18153
|
// the `federated` mark and the `federated` assurance together, never one without the other.
|
|
18154
18154
|
const customer = result?.customer;
|
|
18155
18155
|
const nativeIdentity = customer?.federated === true ? customer.assurance === 'federated' : customer?.assurance === 'identity';
|
|
18156
|
-
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)) {
|
|
18157
18157
|
throw new SparkVaultError('The help desk returned an invalid support identity.', 'HELP_DESK_INVALID_RESPONSE');
|
|
18158
18158
|
}
|
|
18159
18159
|
this.issuedSessions.set(result, result.token);
|
|
@@ -18165,6 +18165,16 @@ class HelpDeskClient {
|
|
|
18165
18165
|
this.websiteAccountSuppressed = true;
|
|
18166
18166
|
return this.releaseSession(false);
|
|
18167
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
|
+
}
|
|
18168
18178
|
/** The only operation that resumes the website's configured identity provider after an explicit switch. */
|
|
18169
18179
|
async useWebsiteAccount() {
|
|
18170
18180
|
await this.releaseSession(false);
|
|
@@ -19263,7 +19273,7 @@ function carriesFiles(event) {
|
|
|
19263
19273
|
* refusals as a picked one; the drop target shows only over the composer. A
|
|
19264
19274
|
* paste or drag of text alone stays the browser's. A file brought over the
|
|
19265
19275
|
* form is never the browser's to open in place of the unsent request: on the
|
|
19266
|
-
*
|
|
19276
|
+
* sign-in step, or while the form takes no files, it is refused outright,
|
|
19267
19277
|
* and a desk that takes no files says so when the file is dropped.
|
|
19268
19278
|
*/
|
|
19269
19279
|
function createComposer(options) {
|
|
@@ -19575,6 +19585,11 @@ function postingName(customer) {
|
|
|
19575
19585
|
return words[0];
|
|
19576
19586
|
return `${words[0]} ${Array.from(words[words.length - 1])[0]}.`;
|
|
19577
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
|
+
}
|
|
19578
19593
|
function focusAtEnd(field, focusOptions) {
|
|
19579
19594
|
field.focus(focusOptions);
|
|
19580
19595
|
// An email field has no caret to place.
|
|
@@ -19590,6 +19605,12 @@ function textButton(text, action) {
|
|
|
19590
19605
|
button.addEventListener('click', action);
|
|
19591
19606
|
return button;
|
|
19592
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.';
|
|
19593
19614
|
const SIGN_IN_CANCELLED_COPY = 'Sign-in was cancelled. Your request is still here and hasn’t been sent.';
|
|
19594
19615
|
const RECOVER_STATUS_COPY = 'Sign in again to recover your saved request.';
|
|
19595
19616
|
const RECOVER_WEBSITE_COPY = 'Sign in to your website account again to recover your saved request.';
|
|
@@ -19660,7 +19681,9 @@ function companySignInUrl(value) {
|
|
|
19660
19681
|
*
|
|
19661
19682
|
* The request is a summary and optional details, in a composer that also
|
|
19662
19683
|
* takes files. A signed-out widget customer writes it as step 1 of 2; step 2
|
|
19663
|
-
* 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.
|
|
19664
19687
|
*/
|
|
19665
19688
|
function mountHelpDeskForm(client, options) {
|
|
19666
19689
|
const target = resolveTarget(options.target);
|
|
@@ -19755,9 +19778,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
19755
19778
|
const email = field('Email address', 'email');
|
|
19756
19779
|
const code = field('Email code', 'code');
|
|
19757
19780
|
const name = field('Your name', 'display_name');
|
|
19758
|
-
const
|
|
19759
|
-
const lastName = field('Last name (optional)', 'family_name');
|
|
19760
|
-
const fields = [subject, description, email, code, name, firstName, lastName];
|
|
19781
|
+
const fields = [subject, description, email, code, name];
|
|
19761
19782
|
// The support wizard's issue the form was last filled from, which either
|
|
19762
19783
|
// field may hold; undefined for a form filled from the host's subject and body.
|
|
19763
19784
|
let filledFrom = options.issue;
|
|
@@ -19772,10 +19793,6 @@ function mountHelpDeskForm(client, options) {
|
|
|
19772
19793
|
code.input.inputMode = 'numeric';
|
|
19773
19794
|
code.input.autocomplete = 'one-time-code';
|
|
19774
19795
|
name.input.autocomplete = 'name';
|
|
19775
|
-
firstName.input.autocomplete = 'given-name';
|
|
19776
|
-
lastName.input.autocomplete = 'family-name';
|
|
19777
|
-
firstName.input.maxLength = 100;
|
|
19778
|
-
lastName.input.maxLength = 100;
|
|
19779
19796
|
const codeHint = document.createElement('p');
|
|
19780
19797
|
codeHint.id = `${code.input.id}-hint`;
|
|
19781
19798
|
codeHint.className = 'svhd-hint';
|
|
@@ -19828,16 +19845,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
19828
19845
|
description.wrapper.insertBefore(composer.frame, description.error);
|
|
19829
19846
|
description.wrapper.insertBefore(composer.notice, description.error);
|
|
19830
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.
|
|
19831
19850
|
const auth = document.createElement('fieldset');
|
|
19832
19851
|
auth.className = 'svhd-auth';
|
|
19833
19852
|
auth.hidden = true;
|
|
19834
|
-
auth.append(code.wrapper, name.wrapper);
|
|
19853
|
+
auth.append(email.wrapper, code.wrapper, name.wrapper);
|
|
19835
19854
|
const widgetAccount = document.createElement('div');
|
|
19836
19855
|
widgetAccount.className = 'svhd-widget-account';
|
|
19837
19856
|
let widgetCustomer = widget?.customer ?? null;
|
|
19838
|
-
|
|
19839
|
-
const asksName = client.desk.auth_mode !== 'identity';
|
|
19840
|
-
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;
|
|
19841
19858
|
const identity = widget ? stepContainer('identity') : null;
|
|
19842
19859
|
const recap = document.createElement('div');
|
|
19843
19860
|
recap.className = 'svhd-recap';
|
|
@@ -19847,11 +19864,13 @@ function mountHelpDeskForm(client, options) {
|
|
|
19847
19864
|
enterStep('details'); });
|
|
19848
19865
|
editRequest.setAttribute('aria-label', 'Edit your request');
|
|
19849
19866
|
const noteText = document.createTextNode('');
|
|
19850
|
-
|
|
19851
|
-
|
|
19852
|
-
|
|
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;
|
|
19853
19872
|
const live = createLiveRegion('svhd-live');
|
|
19854
|
-
if (identity &&
|
|
19873
|
+
if (identity && signInStep) {
|
|
19855
19874
|
form.classList.add('svhd-widget-form');
|
|
19856
19875
|
details.append(widgetAccount);
|
|
19857
19876
|
identity.hidden = true;
|
|
@@ -19866,22 +19885,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
19866
19885
|
recapLabel.textContent = 'Your request';
|
|
19867
19886
|
recapRequest.append(recapLabel, recapText);
|
|
19868
19887
|
recap.append(recapRequest, editRequest);
|
|
19869
|
-
|
|
19870
|
-
helper.id = `${email.input.id}-help`;
|
|
19871
|
-
helper.className = 'svhd-hint';
|
|
19872
|
-
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.';
|
|
19873
|
-
email.input.setAttribute('aria-describedby', helper.id);
|
|
19874
|
-
identity.append(reply.head, note, recap);
|
|
19875
|
-
if (asksName) {
|
|
19876
|
-
const names = document.createElement('div');
|
|
19877
|
-
names.className = 'svhd-widget-names';
|
|
19878
|
-
names.append(firstName.wrapper, lastName.wrapper);
|
|
19879
|
-
identity.append(names);
|
|
19880
|
-
}
|
|
19881
|
-
identity.append(email.wrapper, helper);
|
|
19888
|
+
identity.append(signInStep.head, note, recap, signInHelp);
|
|
19882
19889
|
}
|
|
19883
|
-
else
|
|
19884
|
-
auth.prepend(email.wrapper);
|
|
19885
19890
|
const status = document.createElement('p');
|
|
19886
19891
|
status.className = 'svhd-status';
|
|
19887
19892
|
status.setAttribute('role', 'status');
|
|
@@ -19973,6 +19978,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
19973
19978
|
let recovery = null;
|
|
19974
19979
|
// The website gave no account back when asked for the hidden request's customer.
|
|
19975
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;
|
|
19976
19983
|
function persistDraft() {
|
|
19977
19984
|
if (!options.persist || completed || destroyed)
|
|
19978
19985
|
return;
|
|
@@ -20027,9 +20034,15 @@ function mountHelpDeskForm(client, options) {
|
|
|
20027
20034
|
: 'Your saved request was restored. Review it before sending.');
|
|
20028
20035
|
return true;
|
|
20029
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
|
+
*/
|
|
20030
20043
|
function safeComposition() {
|
|
20031
|
-
|
|
20032
|
-
|
|
20044
|
+
return pending || uncertainSubmission !== null || completed ? null
|
|
20045
|
+
: { subject: subject.input.value, body: description.input.value, hadFiles: attachments?.hasEntries === true };
|
|
20033
20046
|
}
|
|
20034
20047
|
/** What the send button reads while nothing is in flight. */
|
|
20035
20048
|
function idleLabel() {
|
|
@@ -20039,14 +20052,17 @@ function mountHelpDeskForm(client, options) {
|
|
|
20039
20052
|
return 'Verify and send request';
|
|
20040
20053
|
if (recovery === 'external_sso' && widget)
|
|
20041
20054
|
return 'Use website account';
|
|
20042
|
-
if (recovery !== null
|
|
20055
|
+
if (recovery !== null)
|
|
20043
20056
|
return 'Sign in to recover request';
|
|
20044
|
-
|
|
20057
|
+
if (widget && !widgetCustomer)
|
|
20058
|
+
return step === 'identity' ? 'Sign in and send' : 'Continue';
|
|
20059
|
+
return 'Send request';
|
|
20045
20060
|
}
|
|
20046
20061
|
/**
|
|
20047
20062
|
* The signed-in widget customer writes and sends in one step, posting as
|
|
20048
|
-
* the account named under it
|
|
20049
|
-
*
|
|
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.
|
|
20050
20066
|
*/
|
|
20051
20067
|
function renderWidgetIdentity() {
|
|
20052
20068
|
if (!widget)
|
|
@@ -20061,12 +20077,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
20061
20077
|
if (widgetCustomer) {
|
|
20062
20078
|
const postingAs = document.createElement('p');
|
|
20063
20079
|
postingAs.className = 'svhd-posting-as';
|
|
20064
|
-
|
|
20065
|
-
|
|
20066
|
-
|
|
20067
|
-
|
|
20068
|
-
|
|
20069
|
-
|
|
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
|
+
}
|
|
20070
20088
|
widgetAccount.append(postingAs);
|
|
20071
20089
|
}
|
|
20072
20090
|
if (widget.useWebsiteAccount && widget.offerWebsiteAccount) {
|
|
@@ -20081,7 +20099,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20081
20099
|
* The actions and notes for where the request is. While the form hides a
|
|
20082
20100
|
* previous customer's saved request (`recovery`), nothing shows of it, nor
|
|
20083
20101
|
* says it was not sent, since it may be a send whose answer was lost: the
|
|
20084
|
-
* 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
|
|
20085
20103
|
* step's note alone speaks there, Start a new request leaves it, and the
|
|
20086
20104
|
* account row is away. A website-account customer's request comes back only
|
|
20087
20105
|
* through that account, so Use website account is its one way on when the
|
|
@@ -20093,7 +20111,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20093
20111
|
startNew.hidden = recovery === null;
|
|
20094
20112
|
widgetAccount.hidden = recovery !== null || widgetAccount.childElementCount === 0;
|
|
20095
20113
|
recap.hidden = recovery !== null;
|
|
20096
|
-
noteText.data = recovery === 'identity' || recovery === 'email_pin' ? RECOVER_NOTE_COPY :
|
|
20114
|
+
noteText.data = recovery === 'identity' || recovery === 'email_pin' ? RECOVER_NOTE_COPY : UNSENT_NOTE_COPY;
|
|
20097
20115
|
if (recovery !== null)
|
|
20098
20116
|
message(step === 'identity' ? '' : recoveryStatus());
|
|
20099
20117
|
}
|
|
@@ -20118,15 +20136,19 @@ function mountHelpDeskForm(client, options) {
|
|
|
20118
20136
|
controller.focusEntry();
|
|
20119
20137
|
}
|
|
20120
20138
|
}
|
|
20121
|
-
/** Show one step, the request or
|
|
20139
|
+
/** Show one step, the request or its sign-in, without moving focus. */
|
|
20122
20140
|
function setStep(next) {
|
|
20123
20141
|
const changed = next !== step;
|
|
20124
20142
|
step = next;
|
|
20125
20143
|
details.hidden = next !== 'details';
|
|
20126
20144
|
if (identity)
|
|
20127
20145
|
identity.hidden = next !== 'identity';
|
|
20128
|
-
if (next === 'identity')
|
|
20146
|
+
if (next === 'identity') {
|
|
20129
20147
|
recapText.textContent = subject.input.value.trim();
|
|
20148
|
+
send.setAttribute('aria-describedby', signInHelp.id);
|
|
20149
|
+
}
|
|
20150
|
+
else
|
|
20151
|
+
send.removeAttribute('aria-describedby');
|
|
20130
20152
|
renderActions();
|
|
20131
20153
|
syncLeaveGuard();
|
|
20132
20154
|
if (changed)
|
|
@@ -20134,9 +20156,11 @@ function mountHelpDeskForm(client, options) {
|
|
|
20134
20156
|
}
|
|
20135
20157
|
/** The customer moves between the steps: the new step's heading takes focus and its place is announced. */
|
|
20136
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('');
|
|
20137
20161
|
setStep(next);
|
|
20138
20162
|
live.announce(next === 'identity' ? 'Step 2 of 2' : 'Step 1 of 2');
|
|
20139
|
-
(next === 'identity' &&
|
|
20163
|
+
(next === 'identity' && signInStep ? signInStep.heading : heading).focus();
|
|
20140
20164
|
}
|
|
20141
20165
|
// An inline wizard, on any host page that gives a `target`, asks before that
|
|
20142
20166
|
// page unloads while the request holds unsent work: leaving would lose it.
|
|
@@ -20194,7 +20218,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20194
20218
|
* in place of anything written.
|
|
20195
20219
|
*/
|
|
20196
20220
|
function disable(disabled) {
|
|
20197
|
-
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])
|
|
20198
20222
|
input.disabled = disabled;
|
|
20199
20223
|
const held = uncertainSubmission !== null || recovery !== null;
|
|
20200
20224
|
subject.input.readOnly = held;
|
|
@@ -20231,10 +20255,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
20231
20255
|
? 'We may already have received this request. Closing now loses the way to check it.'
|
|
20232
20256
|
: DISCARD_REQUEST_COPY.note;
|
|
20233
20257
|
}
|
|
20234
|
-
/** The field
|
|
20258
|
+
/** The field the request step asks for: the code, name or email the form asks for itself, else the summary. */
|
|
20235
20259
|
function stepField() {
|
|
20236
|
-
if (step === 'identity')
|
|
20237
|
-
return (asksName ? firstName : email).input;
|
|
20238
20260
|
const asked = auth.hidden ? undefined : [code, name, email].find((entry) => !entry.wrapper.hidden);
|
|
20239
20261
|
return (asked ?? subject).input;
|
|
20240
20262
|
}
|
|
@@ -20242,7 +20264,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20242
20264
|
// A press on the modal's backdrop leaves focus on the page body, and
|
|
20243
20265
|
// Keep editing must never hand focus back outside the dialog.
|
|
20244
20266
|
const active = document.activeElement;
|
|
20245
|
-
confirmReturn = active instanceof HTMLElement && shell.container.contains(active) ? active : stepField();
|
|
20267
|
+
confirmReturn = active instanceof HTMLElement && shell.container.contains(active) ? active : step === 'identity' ? send : stepField();
|
|
20246
20268
|
renderConfirmNote();
|
|
20247
20269
|
actions.hidden = true;
|
|
20248
20270
|
confirm.hidden = false;
|
|
@@ -20275,7 +20297,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20275
20297
|
}
|
|
20276
20298
|
/**
|
|
20277
20299
|
* Whether closing now would lose something: a send under way or
|
|
20278
|
-
* unanswered, a code step, a request moved on to
|
|
20300
|
+
* unanswered, a code step, a request moved on to its sign-in step, or
|
|
20279
20301
|
* text and files of the customer's own. The silent company sign-in the
|
|
20280
20302
|
* form runs as it opens (`authenticating`) is no work of the customer's.
|
|
20281
20303
|
*/
|
|
@@ -20377,11 +20399,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20377
20399
|
code.wrapper.hidden = true;
|
|
20378
20400
|
name.wrapper.hidden = true;
|
|
20379
20401
|
auth.hidden = true;
|
|
20380
|
-
|
|
20381
|
-
firstName.input.value = '';
|
|
20382
|
-
lastName.input.value = '';
|
|
20383
|
-
renderWidgetIdentity();
|
|
20384
|
-
}
|
|
20402
|
+
renderWidgetIdentity();
|
|
20385
20403
|
hosted.hidden = true;
|
|
20386
20404
|
draftId = null;
|
|
20387
20405
|
draftPromise = null;
|
|
@@ -20449,6 +20467,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20449
20467
|
restoredFiles = false;
|
|
20450
20468
|
generation += 1;
|
|
20451
20469
|
pending = false;
|
|
20470
|
+
switchingAccount = false;
|
|
20452
20471
|
sessionKnown = false;
|
|
20453
20472
|
if (options.widgetIdentity)
|
|
20454
20473
|
widgetCustomer = null;
|
|
@@ -20568,25 +20587,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
20568
20587
|
}
|
|
20569
20588
|
let widgetSignIn;
|
|
20570
20589
|
if (widget && !widgetCustomer) {
|
|
20571
|
-
// The request is written;
|
|
20590
|
+
// The request is written; signing in to send it is the next step, and
|
|
20572
20591
|
// nothing reaches the network before it.
|
|
20573
20592
|
if (step === 'details') {
|
|
20574
20593
|
enterStep('identity');
|
|
20575
20594
|
return;
|
|
20576
20595
|
}
|
|
20577
|
-
const givenName = asksName ? firstName.input.value.trim() : '';
|
|
20578
|
-
const familyName = asksName ? lastName.input.value.trim() : '';
|
|
20579
|
-
const emailAddress = email.input.value.trim();
|
|
20580
|
-
const invalid = asksName && !givenName ? firstName : !email.input.validity.valid || !emailAddress ? email : null;
|
|
20581
|
-
if (invalid) {
|
|
20582
|
-
setFieldError(invalid, invalid === email ? 'Enter your email address.' : 'Enter your first name.');
|
|
20583
|
-
invalid.input.focus();
|
|
20584
|
-
return;
|
|
20585
|
-
}
|
|
20586
20596
|
// Invoke in the original submit gesture, before any awaited token read:
|
|
20587
20597
|
// the Identity adapter can open its native window without a popup block.
|
|
20588
20598
|
try {
|
|
20589
|
-
widgetSignIn = widget.signIn(
|
|
20599
|
+
widgetSignIn = widget.signIn();
|
|
20590
20600
|
}
|
|
20591
20601
|
catch (failure) {
|
|
20592
20602
|
const error = failure instanceof Error ? failure : new Error('Sign-in could not be opened.');
|
|
@@ -20609,7 +20619,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20609
20619
|
authenticating = true;
|
|
20610
20620
|
authNotification = false;
|
|
20611
20621
|
setState('authenticating');
|
|
20612
|
-
message(
|
|
20622
|
+
message(SIGNING_IN_COPY);
|
|
20613
20623
|
}
|
|
20614
20624
|
let token = await tokenFor(ownGeneration);
|
|
20615
20625
|
if (!alive(ownGeneration))
|
|
@@ -20810,7 +20820,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20810
20820
|
focusAfter = code.input;
|
|
20811
20821
|
}
|
|
20812
20822
|
else if (widgetSignIn && error instanceof SparkVaultError && error.code === 'user_cancelled') {
|
|
20813
|
-
// The request stays on
|
|
20823
|
+
// The request stays on its sign-in step, ready to sign in again;
|
|
20814
20824
|
// a hidden saved request is not here to speak of, so its note alone stays.
|
|
20815
20825
|
if (recovery === null)
|
|
20816
20826
|
message(SIGN_IN_CANCELLED_COPY);
|
|
@@ -20869,6 +20879,84 @@ function mountHelpDeskForm(client, options) {
|
|
|
20869
20879
|
}
|
|
20870
20880
|
}
|
|
20871
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
|
+
}
|
|
20872
20960
|
/** Take a typed, pasted or autofilled code as its digits, and send it the moment the last one lands. */
|
|
20873
20961
|
function takeCode(value) {
|
|
20874
20962
|
const digits = helpDeskPinDigits(value);
|
|
@@ -20890,26 +20978,47 @@ function mountHelpDeskForm(client, options) {
|
|
|
20890
20978
|
/** The Cancel path: remove the form, then tell the host the customer closed it. */
|
|
20891
20979
|
function dismiss() {
|
|
20892
20980
|
const discardDraft = uncertainSubmission === null;
|
|
20893
|
-
|
|
20981
|
+
if (!destroyed)
|
|
20982
|
+
teardown(!discardDraft);
|
|
20894
20983
|
if (discardDraft)
|
|
20895
20984
|
forgetDraft();
|
|
20896
20985
|
notify$1(options.onCancel, undefined);
|
|
20897
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
|
+
}
|
|
20898
21002
|
const controller = {
|
|
20899
21003
|
destroy() {
|
|
21004
|
+
if (!destroyed)
|
|
21005
|
+
teardown(true);
|
|
21006
|
+
},
|
|
21007
|
+
leave() {
|
|
20900
21008
|
if (destroyed)
|
|
20901
21009
|
return;
|
|
20902
|
-
|
|
20903
|
-
|
|
20904
|
-
|
|
20905
|
-
|
|
20906
|
-
|
|
20907
|
-
|
|
20908
|
-
|
|
20909
|
-
|
|
20910
|
-
|
|
20911
|
-
|
|
20912
|
-
|
|
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);
|
|
20913
21022
|
},
|
|
20914
21023
|
reset() {
|
|
20915
21024
|
if (destroyed || pending || uncertainSubmission)
|
|
@@ -20925,7 +21034,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20925
21034
|
},
|
|
20926
21035
|
getState: () => state,
|
|
20927
21036
|
restoreComposition(composition) {
|
|
20928
|
-
if (destroyed ||
|
|
21037
|
+
if (destroyed || holdsSavedRequest())
|
|
20929
21038
|
return;
|
|
20930
21039
|
subject.input.value = composition.subject;
|
|
20931
21040
|
description.input.value = composition.body;
|
|
@@ -20966,10 +21075,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
20966
21075
|
focusEntry(focusOptions) {
|
|
20967
21076
|
if (destroyed || form.hidden)
|
|
20968
21077
|
return false;
|
|
21078
|
+
if (step === 'identity' && signInStep) {
|
|
21079
|
+
(send.disabled ? signInStep.heading : send).focus(focusOptions);
|
|
21080
|
+
return true;
|
|
21081
|
+
}
|
|
20969
21082
|
const asked = stepField();
|
|
20970
21083
|
const entry = asked === subject.input && subject.input.value.trim() ? description.input : asked;
|
|
20971
21084
|
if (entry.disabled || entry.readOnly)
|
|
20972
|
-
|
|
21085
|
+
heading.focus(focusOptions);
|
|
20973
21086
|
else
|
|
20974
21087
|
focusAtEnd(entry, focusOptions);
|
|
20975
21088
|
return true;
|
|
@@ -21013,9 +21126,6 @@ function mountHelpDeskForm(client, options) {
|
|
|
21013
21126
|
});
|
|
21014
21127
|
send.textContent = idleLabel();
|
|
21015
21128
|
renderWidgetIdentity();
|
|
21016
|
-
// A signed-out widget customer starts on step 1 of 2 with focus in the request.
|
|
21017
|
-
if (widget && !widgetCustomer)
|
|
21018
|
-
live.announce('Step 1 of 2');
|
|
21019
21129
|
if (options.widgetIdentity?.customer) {
|
|
21020
21130
|
restoreDraft(options.widgetIdentity.customer);
|
|
21021
21131
|
disable(false);
|
|
@@ -21036,6 +21146,15 @@ function mountHelpDeskForm(client, options) {
|
|
|
21036
21146
|
restoredAnonymous = true;
|
|
21037
21147
|
}
|
|
21038
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');
|
|
21039
21158
|
syncLeaveGuard();
|
|
21040
21159
|
notify$1(options.onStateChange, state);
|
|
21041
21160
|
// Native company identity starts as the form opens, never from a Connect,
|
|
@@ -23406,7 +23525,6 @@ function injectHelpDeskSupportStyles() {
|
|
|
23406
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}}
|
|
23407
23526
|
.svhs-panel .svhd-composer-input:focus-visible{outline:none}
|
|
23408
23527
|
.svhs-panel .svhd-composer button:focus-visible{outline-offset:-2px}
|
|
23409
|
-
.svhs-contact-target .svhd-widget-names{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px}
|
|
23410
23528
|
.svhs-contact-target .svhd-widget-form{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
23411
23529
|
/* The request fills the panel: the details step, and in it the composer and its text, take the height the fields leave. */
|
|
23412
23530
|
.svhs-contact-target .svhd-widget-form>[data-contact-step=details]{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
@@ -24757,6 +24875,13 @@ function createHelpDeskSupport(config, options) {
|
|
|
24757
24875
|
// A website-account customer's saved request the next form keeps hidden,
|
|
24758
24876
|
// asked for through the website account, which may give no account back.
|
|
24759
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;
|
|
24760
24885
|
// The issue, as written, that the held composition (the mounted form, the one
|
|
24761
24886
|
// a re-authorized form will take, or the one saved before a reload) was last
|
|
24762
24887
|
// filled from: '' for one filled from none. A form taking that composition is
|
|
@@ -24795,7 +24920,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
24795
24920
|
onBack: () => {
|
|
24796
24921
|
if (destroyed || state.navigationLocked || state.identityPending)
|
|
24797
24922
|
return;
|
|
24798
|
-
// On
|
|
24923
|
+
// On the sign-in step, Back returns to the request it is for.
|
|
24799
24924
|
if (state.stage === 'contact' && !state.ticketAccessRequired && contact?.returnToRequest())
|
|
24800
24925
|
return;
|
|
24801
24926
|
// A held form shows at once while contact still checks access behind it,
|
|
@@ -24873,7 +24998,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
24873
24998
|
throw new Error('Support is closed.');
|
|
24874
24999
|
client = answer;
|
|
24875
25000
|
stopSession = answer.subscribeSession((change) => {
|
|
24876
|
-
if (change.source === 'clear')
|
|
25001
|
+
if (change.source === 'clear' && !replacingSession)
|
|
24877
25002
|
notify(options.onSession, null);
|
|
24878
25003
|
});
|
|
24879
25004
|
kb = new HelpDeskKnowledgeBaseClient(config, answer.desk.desk_id);
|
|
@@ -25004,6 +25129,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
25004
25129
|
requestedArticle = null;
|
|
25005
25130
|
pendingComposition = null;
|
|
25006
25131
|
pendingRecovery = null;
|
|
25132
|
+
pendingArrival = null;
|
|
25007
25133
|
feedbackSequence += 1;
|
|
25008
25134
|
sourceArticleId = undefined;
|
|
25009
25135
|
if (options.persist && client)
|
|
@@ -25169,14 +25295,19 @@ function createHelpDeskSupport(config, options) {
|
|
|
25169
25295
|
if (!client || destroyed)
|
|
25170
25296
|
return;
|
|
25171
25297
|
contactCustomer = customer;
|
|
25298
|
+
anonymous = !customer;
|
|
25172
25299
|
// A customer the website gave back sees their own saved request; none keeps it hidden.
|
|
25173
25300
|
const recovering = customer ? null : pendingRecovery;
|
|
25174
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;
|
|
25175
25305
|
let activeAttempt = null;
|
|
25176
25306
|
// A ticket carries the attempt the form opened under only while it is still
|
|
25177
25307
|
// the journey's: recovery drops it with the previous customer's question.
|
|
25178
25308
|
const formAttempt = attempt;
|
|
25179
|
-
|
|
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);
|
|
25180
25311
|
contact = mountHelpDeskForm(client, {
|
|
25181
25312
|
target: view.contactTarget,
|
|
25182
25313
|
// Filled from the issue its composition came from, so text the customer
|
|
@@ -25194,13 +25325,15 @@ function createHelpDeskSupport(config, options) {
|
|
|
25194
25325
|
},
|
|
25195
25326
|
widgetIdentity: {
|
|
25196
25327
|
customer,
|
|
25197
|
-
signIn: (
|
|
25198
|
-
switchAccount
|
|
25328
|
+
signIn: () => signIn().then((session) => { contactCustomer = session.customer; return session; }),
|
|
25329
|
+
switchAccount,
|
|
25330
|
+
signOut,
|
|
25199
25331
|
...(bridged && { useWebsiteAccount: (safe, recover) => { void useWebsiteAccount(safe, recover); } }),
|
|
25200
25332
|
offerWebsiteAccount: switchedAccount,
|
|
25201
25333
|
forgetIssue,
|
|
25202
25334
|
followIssue,
|
|
25203
25335
|
...(recovering && { recovering }),
|
|
25336
|
+
...(arrived && { arrived }),
|
|
25204
25337
|
},
|
|
25205
25338
|
onScreenChange: () => view.contactScreenChanged(),
|
|
25206
25339
|
assistanceContext: () => (attempt === formAttempt ? activeAttempt?.ticketContext() : undefined),
|
|
@@ -25314,7 +25447,6 @@ function createHelpDeskSupport(config, options) {
|
|
|
25314
25447
|
if (destroyed || ownSequence !== sequence)
|
|
25315
25448
|
return;
|
|
25316
25449
|
update({ busy: false, ticketAccessRequired: false, ticketAccessMode: undefined });
|
|
25317
|
-
anonymous = !customer;
|
|
25318
25450
|
// A composition saved before a reload goes on from the issue it was filled
|
|
25319
25451
|
// from; with none carried, the form fills itself from the issue as written.
|
|
25320
25452
|
const saved = pendingComposition === null && options.persist ? readAnonymousFormDraft(active.desk.desk_id) : null;
|
|
@@ -25378,78 +25510,120 @@ function createHelpDeskSupport(config, options) {
|
|
|
25378
25510
|
notify(options.onError, error);
|
|
25379
25511
|
}
|
|
25380
25512
|
}
|
|
25381
|
-
|
|
25382
|
-
|
|
25383
|
-
|
|
25384
|
-
|
|
25385
|
-
|
|
25386
|
-
|
|
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();
|
|
25387
25525
|
contact = null;
|
|
25526
|
+
contactCustomer = null;
|
|
25388
25527
|
cancelArticleAssets?.();
|
|
25389
25528
|
cancelArticleAssets = null;
|
|
25390
|
-
pendingComposition = composition
|
|
25529
|
+
pendingComposition = composition ? { subject: composition.subject, body: composition.body } : { subject: '', body: '' };
|
|
25391
25530
|
pendingRecovery = null;
|
|
25531
|
+
pendingArrival = null;
|
|
25392
25532
|
kb?.clearAccess();
|
|
25393
25533
|
kbConfig = null;
|
|
25394
25534
|
results = [];
|
|
25395
25535
|
requestedArticle = null;
|
|
25396
25536
|
attempt = null;
|
|
25397
25537
|
sourceArticleId = undefined;
|
|
25398
|
-
|
|
25399
|
-
|
|
25400
|
-
|
|
25401
|
-
|
|
25402
|
-
|
|
25403
|
-
|
|
25404
|
-
|
|
25405
|
-
|
|
25406
|
-
|
|
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)
|
|
25407
25552
|
return;
|
|
25408
|
-
|
|
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 {
|
|
25409
25579
|
notify(options.onTicketAccess, await active.unlockTicketAccess({ identityGrant: session.identity_grant.token }));
|
|
25410
|
-
if (destroyed || ownSequence !== sequence)
|
|
25411
|
-
return;
|
|
25412
|
-
active.setSession(session);
|
|
25413
|
-
notify(options.onSession, session);
|
|
25414
|
-
update({ busy: false });
|
|
25415
|
-
await showContact('direct');
|
|
25416
|
-
}
|
|
25417
|
-
catch (value) {
|
|
25418
|
-
await logout.catch(() => undefined);
|
|
25419
|
-
if (destroyed || ownSequence !== sequence)
|
|
25420
|
-
return;
|
|
25421
|
-
const error = failure(value);
|
|
25422
|
-
update({ busy: false, error: error.message });
|
|
25423
|
-
if (active.hasTicketAccess) {
|
|
25424
|
-
mountContact(composition ?? { subject: '', body: '' }, null);
|
|
25425
|
-
pendingComposition = null;
|
|
25426
25580
|
}
|
|
25427
|
-
|
|
25428
|
-
|
|
25581
|
+
catch (value) {
|
|
25582
|
+
if (!destroyed && ownSequence === sequence)
|
|
25583
|
+
notify(options.onError, failure(value));
|
|
25584
|
+
}
|
|
25429
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');
|
|
25430
25611
|
}
|
|
25431
25612
|
async function useWebsiteAccount(composition, recovering = false) {
|
|
25432
25613
|
if (!client || destroyed || state.navigationLocked)
|
|
25433
25614
|
return;
|
|
25434
25615
|
const ownSequence = ++sequence;
|
|
25435
|
-
|
|
25436
|
-
contact = null;
|
|
25437
|
-
cancelArticleAssets?.();
|
|
25438
|
-
cancelArticleAssets = null;
|
|
25439
|
-
pendingComposition = composition ?? { subject: '', body: '' };
|
|
25616
|
+
leaveCustomer(composition);
|
|
25440
25617
|
pendingRecovery = recovering ? { websiteSignedOut: true } : null;
|
|
25441
|
-
kb?.clearAccess();
|
|
25442
|
-
kbConfig = null;
|
|
25443
|
-
results = [];
|
|
25444
|
-
requestedArticle = null;
|
|
25445
|
-
attempt = null;
|
|
25446
|
-
sourceArticleId = undefined;
|
|
25447
25618
|
update({ busy: true, error: undefined, results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
25448
25619
|
try {
|
|
25449
25620
|
await client.useWebsiteAccount();
|
|
25450
25621
|
if (destroyed || ownSequence !== sequence)
|
|
25451
25622
|
return;
|
|
25452
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 };
|
|
25453
25627
|
update({ busy: false });
|
|
25454
25628
|
await showContact('direct');
|
|
25455
25629
|
}
|
|
@@ -25462,7 +25636,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
25462
25636
|
if (pendingRecovery)
|
|
25463
25637
|
pendingRecovery = { websiteSignedOut: false };
|
|
25464
25638
|
if (client.hasTicketAccess) {
|
|
25465
|
-
mountContact(
|
|
25639
|
+
mountContact(pendingComposition, null);
|
|
25466
25640
|
pendingComposition = null;
|
|
25467
25641
|
}
|
|
25468
25642
|
else
|
|
@@ -30275,7 +30449,7 @@ class SparkVault {
|
|
|
30275
30449
|
}
|
|
30276
30450
|
/** Get the SDK version */
|
|
30277
30451
|
static get version() {
|
|
30278
|
-
return '16.
|
|
30452
|
+
return '16.6.0';
|
|
30279
30453
|
}
|
|
30280
30454
|
}
|
|
30281
30455
|
if (typeof window !== 'undefined') {
|