@sparkvault/sdk-js 15.13.1 → 15.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -4
- package/dist/index.cjs +399 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -2
- package/dist/index.mjs +399 -70
- package/dist/index.mjs.map +1 -1
- package/dist/products/help-desk/client.d.ts +4 -1
- package/dist/products/help-desk/form-draft.d.ts +27 -0
- package/dist/products/help-desk/form-types.d.ts +4 -0
- package/dist/products/help-desk/support-types.d.ts +13 -2
- package/dist/products/help-desk/support-view.d.ts +2 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/vaults/upload/modal.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -16562,6 +16562,7 @@ class HelpDeskClient {
|
|
|
16562
16562
|
if (!/^hdapt_[A-Za-z0-9_-]{43}$/.test(result?.token) || !validLifetime(result.ttl_seconds))
|
|
16563
16563
|
throw new SparkVaultError('The help desk returned an invalid access grant.', 'HELP_DESK_INVALID_RESPONSE');
|
|
16564
16564
|
this.ticketAccess = { token: result.token, deadline: Date.now() / 1000 + result.ttl_seconds };
|
|
16565
|
+
return result;
|
|
16565
16566
|
}
|
|
16566
16567
|
/** @internal Read an installed server-proven company bearer without invoking any identity provider. */
|
|
16567
16568
|
verifiedSessionTokenFor(requesterId) {
|
|
@@ -17783,6 +17784,120 @@ function createFormAttachments(client, prefix, context) {
|
|
|
17783
17784
|
};
|
|
17784
17785
|
}
|
|
17785
17786
|
|
|
17787
|
+
const TTL_MS = 30 * 60 * 1000;
|
|
17788
|
+
const storageKey = (deskId, requesterId) => isHelpDeskId(deskId) && isResourceIdOf('requester', requesterId) ? `sv-hd-draft:${deskId}:${requesterId}:new` : null;
|
|
17789
|
+
const validBody = (value) => typeof value === 'string' && value.length <= MAX_BODY_BYTES && new TextEncoder().encode(value).length <= MAX_BODY_BYTES;
|
|
17790
|
+
const validSubject = (value) => typeof value === 'string' && value.length <= MAX_SUBJECT_LEN;
|
|
17791
|
+
/** The question before sign-in is tab-local and contains no customer identity. */
|
|
17792
|
+
function clearSupportIssue(deskId) {
|
|
17793
|
+
try {
|
|
17794
|
+
if (isHelpDeskId(deskId))
|
|
17795
|
+
sessionStorage.removeItem(`sv-hd-issue:${deskId}`);
|
|
17796
|
+
}
|
|
17797
|
+
catch { /* Storage is optional. */ }
|
|
17798
|
+
}
|
|
17799
|
+
function readSupportDraft(deskId) {
|
|
17800
|
+
if (!isHelpDeskId(deskId))
|
|
17801
|
+
return null;
|
|
17802
|
+
try {
|
|
17803
|
+
const raw = sessionStorage.getItem(`sv-hd-issue:${deskId}`);
|
|
17804
|
+
if (!raw)
|
|
17805
|
+
return null;
|
|
17806
|
+
if (raw.length > MAX_BODY_BYTES * 4)
|
|
17807
|
+
throw new Error('Invalid issue');
|
|
17808
|
+
const row = JSON.parse(raw);
|
|
17809
|
+
if (row?.desk_id !== deskId || !validBody(row.issue) || !Number.isFinite(row.expires_at) ||
|
|
17810
|
+
row.expires_at <= Date.now() || row.expires_at > Date.now() + TTL_MS ||
|
|
17811
|
+
(row.composition !== undefined && (!validSubject(row.composition?.subject) || !validBody(row.composition?.body))))
|
|
17812
|
+
throw new Error('Invalid issue');
|
|
17813
|
+
return { issue: row.issue, ...(row.composition && { composition: { subject: row.composition.subject, body: row.composition.body } }) };
|
|
17814
|
+
}
|
|
17815
|
+
catch {
|
|
17816
|
+
clearSupportIssue(deskId);
|
|
17817
|
+
return null;
|
|
17818
|
+
}
|
|
17819
|
+
}
|
|
17820
|
+
function readSupportIssue(deskId) { return readSupportDraft(deskId)?.issue ?? null; }
|
|
17821
|
+
function readAnonymousFormDraft(deskId) { return readSupportDraft(deskId)?.composition ?? null; }
|
|
17822
|
+
function writeSupportDraft(deskId, issue, composition) {
|
|
17823
|
+
try {
|
|
17824
|
+
sessionStorage.setItem(`sv-hd-issue:${deskId}`, JSON.stringify({ desk_id: deskId, issue,
|
|
17825
|
+
...(composition && { composition }), expires_at: Date.now() + TTL_MS }));
|
|
17826
|
+
}
|
|
17827
|
+
catch { /* The live wizard still keeps its composition in memory. */ }
|
|
17828
|
+
}
|
|
17829
|
+
function saveSupportIssue(deskId, issue) {
|
|
17830
|
+
if (!isHelpDeskId(deskId) || !validBody(issue))
|
|
17831
|
+
return;
|
|
17832
|
+
const composition = readAnonymousFormDraft(deskId) ?? undefined;
|
|
17833
|
+
if (!issue && !composition) {
|
|
17834
|
+
clearSupportIssue(deskId);
|
|
17835
|
+
return;
|
|
17836
|
+
}
|
|
17837
|
+
writeSupportDraft(deskId, issue, composition);
|
|
17838
|
+
}
|
|
17839
|
+
function saveAnonymousFormDraft(deskId, composition) {
|
|
17840
|
+
if (!isHelpDeskId(deskId) || !validSubject(composition.subject) || !validBody(composition.body))
|
|
17841
|
+
return;
|
|
17842
|
+
const issue = readSupportIssue(deskId) ?? '';
|
|
17843
|
+
if (!composition.subject && !composition.body && !issue) {
|
|
17844
|
+
clearSupportIssue(deskId);
|
|
17845
|
+
return;
|
|
17846
|
+
}
|
|
17847
|
+
writeSupportDraft(deskId, issue, { subject: composition.subject, body: composition.body });
|
|
17848
|
+
}
|
|
17849
|
+
function removeFormDraft(deskId, requesterId) {
|
|
17850
|
+
const key = storageKey(deskId, requesterId);
|
|
17851
|
+
try {
|
|
17852
|
+
if (key)
|
|
17853
|
+
sessionStorage.removeItem(key);
|
|
17854
|
+
}
|
|
17855
|
+
catch { /* Storage is optional. */ }
|
|
17856
|
+
}
|
|
17857
|
+
function readFormDraft(deskId, requesterId) {
|
|
17858
|
+
const key = storageKey(deskId, requesterId);
|
|
17859
|
+
if (!key)
|
|
17860
|
+
return null;
|
|
17861
|
+
try {
|
|
17862
|
+
const raw = sessionStorage.getItem(key);
|
|
17863
|
+
if (!raw)
|
|
17864
|
+
return null;
|
|
17865
|
+
if (raw.length > MAX_BODY_BYTES * 4)
|
|
17866
|
+
throw new Error('Invalid draft');
|
|
17867
|
+
const row = JSON.parse(raw);
|
|
17868
|
+
const sent = row?.uncertain;
|
|
17869
|
+
if (row?.version !== 1 || row.desk_id !== deskId || row.requester_id !== requesterId || row.kind !== 'new' ||
|
|
17870
|
+
!Number.isFinite(row.expires_at) || row.expires_at <= Date.now() || row.expires_at > Date.now() + TTL_MS ||
|
|
17871
|
+
!validSubject(row.subject) || !validBody(row.body) || (row.ticket_id !== null && !isResourceIdOf('ticket', row.ticket_id)) ||
|
|
17872
|
+
(sent !== null && (!isResourceIdOf('ticket', sent?.ticket_id) || !validSubject(sent.subject) || !validBody(sent.body) ||
|
|
17873
|
+
!Array.isArray(sent.attachments) || sent.attachments.length > MAX_ATTACHMENTS_PER_MESSAGE || sent.attachments.some((id) => !isResourceIdOf('attachment', id)))))
|
|
17874
|
+
throw new Error('Invalid draft');
|
|
17875
|
+
return { subject: row.subject, body: row.body, ticketId: row.ticket_id, hadFiles: row.had_files === true,
|
|
17876
|
+
uncertain: sent ? { ticketId: sent.ticket_id, subject: sent.subject, body: sent.body, attachments: [...sent.attachments] } : null };
|
|
17877
|
+
}
|
|
17878
|
+
catch {
|
|
17879
|
+
removeFormDraft(deskId, requesterId);
|
|
17880
|
+
return null;
|
|
17881
|
+
}
|
|
17882
|
+
}
|
|
17883
|
+
function saveFormDraft(deskId, requesterId, value) {
|
|
17884
|
+
const key = storageKey(deskId, requesterId);
|
|
17885
|
+
if (!key || !validSubject(value.subject) || !validBody(value.body))
|
|
17886
|
+
return;
|
|
17887
|
+
try {
|
|
17888
|
+
if (!value.subject && !value.body && !value.ticketId && !value.uncertain) {
|
|
17889
|
+
sessionStorage.removeItem(key);
|
|
17890
|
+
return;
|
|
17891
|
+
}
|
|
17892
|
+
const sent = value.uncertain;
|
|
17893
|
+
sessionStorage.setItem(key, JSON.stringify({ version: 1, desk_id: deskId, requester_id: requesterId, kind: 'new',
|
|
17894
|
+
expires_at: Date.now() + TTL_MS, subject: value.subject, body: value.body, ticket_id: value.ticketId,
|
|
17895
|
+
uncertain: sent ? { ticket_id: sent.ticketId, subject: sent.subject, body: sent.body, attachments: sent.attachments } : null,
|
|
17896
|
+
had_files: value.hadFiles }));
|
|
17897
|
+
}
|
|
17898
|
+
catch { /* Storage is optional; the live form keeps its composition. */ }
|
|
17899
|
+
}
|
|
17900
|
+
|
|
17786
17901
|
let formSequence = 0;
|
|
17787
17902
|
/** An absent or server-side answer cannot establish that the write was refused. */
|
|
17788
17903
|
function unknownSubmissionOutcome(error) {
|
|
@@ -18040,6 +18155,58 @@ function mountHelpDeskForm(client, options) {
|
|
|
18040
18155
|
let resendTimer = null;
|
|
18041
18156
|
let confirmReturn = null;
|
|
18042
18157
|
let done = null;
|
|
18158
|
+
let draftRequester = null;
|
|
18159
|
+
let restoredDraft = false;
|
|
18160
|
+
let restoredAnonymous = false;
|
|
18161
|
+
let restoredFiles = false;
|
|
18162
|
+
let savedDraftNeedsSignIn = false;
|
|
18163
|
+
function persistDraft() {
|
|
18164
|
+
if (!options.persist || completed || destroyed)
|
|
18165
|
+
return;
|
|
18166
|
+
if (!draftRequester) {
|
|
18167
|
+
if (!savedDraftNeedsSignIn)
|
|
18168
|
+
saveAnonymousFormDraft(client.desk.desk_id, { subject: subject.input.value, body: description.input.value });
|
|
18169
|
+
return;
|
|
18170
|
+
}
|
|
18171
|
+
saveFormDraft(client.desk.desk_id, draftRequester, {
|
|
18172
|
+
subject: subject.input.value, body: description.input.value, ticketId: draftId,
|
|
18173
|
+
uncertain: uncertainSubmission, hadFiles: restoredFiles || attachments?.hasEntries === true,
|
|
18174
|
+
});
|
|
18175
|
+
}
|
|
18176
|
+
function forgetDraft() {
|
|
18177
|
+
if (draftRequester)
|
|
18178
|
+
removeFormDraft(client.desk.desk_id, draftRequester);
|
|
18179
|
+
else if (options.persist)
|
|
18180
|
+
clearSupportIssue(client.desk.desk_id);
|
|
18181
|
+
}
|
|
18182
|
+
/** Only /me or the verified sign-in answer can select a saved requester's draft. */
|
|
18183
|
+
function restoreDraft(customer) {
|
|
18184
|
+
if (!options.persist || draftRequester === customer.requester_id)
|
|
18185
|
+
return false;
|
|
18186
|
+
savedDraftNeedsSignIn = false;
|
|
18187
|
+
draftRequester = customer.requester_id;
|
|
18188
|
+
const saved = readFormDraft(client.desk.desk_id, draftRequester);
|
|
18189
|
+
clearSupportIssue(client.desk.desk_id);
|
|
18190
|
+
if (!saved) {
|
|
18191
|
+
persistDraft();
|
|
18192
|
+
return false;
|
|
18193
|
+
}
|
|
18194
|
+
restoredDraft = true;
|
|
18195
|
+
restoredFiles = saved.hadFiles && !saved.uncertain;
|
|
18196
|
+
subject.input.value = saved.uncertain?.subject ?? saved.subject;
|
|
18197
|
+
description.input.value = saved.uncertain?.body ?? saved.body;
|
|
18198
|
+
draftId = saved.ticketId;
|
|
18199
|
+
uncertainSubmission = saved.uncertain;
|
|
18200
|
+
subject.input.readOnly = uncertainSubmission !== null;
|
|
18201
|
+
description.input.readOnly = uncertainSubmission !== null;
|
|
18202
|
+
send.textContent = uncertainSubmission ? 'Check submission' : options.widgetIdentity ? widgetCustomer ? 'Send message' : 'Continue' : 'Send request';
|
|
18203
|
+
setState(uncertainSubmission ? 'uncertain' : 'editing');
|
|
18204
|
+
message(uncertainSubmission
|
|
18205
|
+
? 'Your original request is preserved. Check submission before starting another request.'
|
|
18206
|
+
: restoredFiles ? 'Your text was restored. Choose your files again before sending; files are not saved in this browser.'
|
|
18207
|
+
: 'Your saved request was restored. Review it before sending.');
|
|
18208
|
+
return true;
|
|
18209
|
+
}
|
|
18043
18210
|
function safeComposition() {
|
|
18044
18211
|
// An account switch must not turn an uncertain send into a fresh request.
|
|
18045
18212
|
return pending || uncertainSubmission !== null || completed ? null : { subject: subject.input.value, body: description.input.value };
|
|
@@ -18092,6 +18259,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
18092
18259
|
}
|
|
18093
18260
|
function setState(next) {
|
|
18094
18261
|
state = next;
|
|
18262
|
+
persistDraft();
|
|
18095
18263
|
notify$1(options.onStateChange, next);
|
|
18096
18264
|
}
|
|
18097
18265
|
function message(text, isError = false) {
|
|
@@ -18303,6 +18471,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
18303
18471
|
draftId = null;
|
|
18304
18472
|
draftPromise = null;
|
|
18305
18473
|
uncertainSubmission = null;
|
|
18474
|
+
savedDraftNeedsSignIn = false;
|
|
18475
|
+
restoredAnonymous = false;
|
|
18306
18476
|
subject.input.readOnly = false;
|
|
18307
18477
|
description.input.readOnly = false;
|
|
18308
18478
|
completed = false;
|
|
@@ -18347,15 +18517,28 @@ function mountHelpDeskForm(client, options) {
|
|
|
18347
18517
|
attachments.element.hidden = true;
|
|
18348
18518
|
return;
|
|
18349
18519
|
}
|
|
18520
|
+
// Preserve the old request before hiding it. The next verified requester
|
|
18521
|
+
// selects only their own storage key, including after a 401 and sign-in.
|
|
18522
|
+
persistDraft();
|
|
18523
|
+
const canRecover = options.persist && draftRequester !== null && readFormDraft(client.desk.desk_id, draftRequester) !== null;
|
|
18524
|
+
draftRequester = null;
|
|
18525
|
+
restoredDraft = false;
|
|
18526
|
+
restoredFiles = false;
|
|
18350
18527
|
generation += 1;
|
|
18351
18528
|
pending = false;
|
|
18352
18529
|
sessionKnown = false;
|
|
18353
18530
|
if (options.widgetIdentity)
|
|
18354
18531
|
widgetCustomer = null;
|
|
18355
18532
|
clearComposer();
|
|
18533
|
+
savedDraftNeedsSignIn = Boolean(canRecover);
|
|
18356
18534
|
disable(false);
|
|
18357
18535
|
setState('editing');
|
|
18358
|
-
|
|
18536
|
+
if (savedDraftNeedsSignIn) {
|
|
18537
|
+
send.textContent = 'Sign in to recover request';
|
|
18538
|
+
message('Sign in again to recover your saved request. Its text stays private until your account is confirmed.');
|
|
18539
|
+
}
|
|
18540
|
+
else
|
|
18541
|
+
message('Your sign-in changed. Start a new request for the current account.');
|
|
18359
18542
|
}
|
|
18360
18543
|
const unsubscribe = client.subscribeSession(sessionChanged);
|
|
18361
18544
|
const alive = (ownGeneration) => !destroyed && generation === ownGeneration;
|
|
@@ -18387,6 +18570,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
18387
18570
|
if (!alive(ownGeneration))
|
|
18388
18571
|
throw new SparkVaultError('The help desk session changed.', 'HELP_DESK_SESSION_CHANGED', 409);
|
|
18389
18572
|
draftId = draft.ticket_id;
|
|
18573
|
+
persistDraft();
|
|
18390
18574
|
return draft.ticket_id;
|
|
18391
18575
|
});
|
|
18392
18576
|
draftPromise = operation;
|
|
@@ -18452,7 +18636,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
18452
18636
|
description.input.value = body;
|
|
18453
18637
|
}
|
|
18454
18638
|
const refused = refusal(subjectText, body);
|
|
18455
|
-
|
|
18639
|
+
const recoveringAfterSignIn = savedDraftNeedsSignIn;
|
|
18640
|
+
if (refused && !recoveringAfterSignIn) {
|
|
18456
18641
|
const [entry, text] = refused;
|
|
18457
18642
|
setFieldError(entry, text);
|
|
18458
18643
|
entry.input.focus();
|
|
@@ -18528,6 +18713,13 @@ function mountHelpDeskForm(client, options) {
|
|
|
18528
18713
|
renderWidgetIdentity();
|
|
18529
18714
|
message('');
|
|
18530
18715
|
}
|
|
18716
|
+
// The native result is Core's proof. Bind its draft before a later
|
|
18717
|
+
// profile refresh can fail and leave verified text in anonymous storage.
|
|
18718
|
+
const restored = Boolean(widgetSignIn && session && restoreDraft(session.customer));
|
|
18719
|
+
if (session)
|
|
18720
|
+
notify$1(options.onSession, session);
|
|
18721
|
+
if (restored)
|
|
18722
|
+
return;
|
|
18531
18723
|
}
|
|
18532
18724
|
if (!alive(ownGeneration))
|
|
18533
18725
|
return;
|
|
@@ -18580,6 +18772,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
18580
18772
|
dropChallenge();
|
|
18581
18773
|
subject.input.value = subjectText;
|
|
18582
18774
|
description.input.value = body;
|
|
18775
|
+
notify$1(options.onSession, verified);
|
|
18583
18776
|
}
|
|
18584
18777
|
if (!token || !alive(ownGeneration))
|
|
18585
18778
|
return;
|
|
@@ -18587,6 +18780,17 @@ function mountHelpDeskForm(client, options) {
|
|
|
18587
18780
|
if (!alive(ownGeneration) || !(await tokenFor(ownGeneration)))
|
|
18588
18781
|
return;
|
|
18589
18782
|
auth.hidden = true;
|
|
18783
|
+
// An earlier saved request, especially an uncertain send, always wins
|
|
18784
|
+
// over a newly described issue. Authentication never submits it by itself.
|
|
18785
|
+
if (restoreDraft(customer))
|
|
18786
|
+
return;
|
|
18787
|
+
if (refused && recoveringAfterSignIn) {
|
|
18788
|
+
const [entry, text] = refused;
|
|
18789
|
+
setState('editing');
|
|
18790
|
+
setFieldError(entry, text);
|
|
18791
|
+
focusAfter = entry.input;
|
|
18792
|
+
return;
|
|
18793
|
+
}
|
|
18590
18794
|
if (customer.needs_display_name) {
|
|
18591
18795
|
if (client.desk.auth_mode === 'external_sso' && customer.assurance === 'external_sso')
|
|
18592
18796
|
throw new SparkVaultError('Your company support profile could not be loaded.', 'HELP_DESK_EXTERNAL_PROFILE_INCOMPLETE', 503);
|
|
@@ -18624,12 +18828,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
18624
18828
|
return;
|
|
18625
18829
|
uncertainSubmission = { ticketId: id, subject: subjectText, body, attachments: attachments?.attachmentIds ?? [] };
|
|
18626
18830
|
}
|
|
18831
|
+
persistDraft();
|
|
18627
18832
|
attachments?.lock(true);
|
|
18628
18833
|
ticketAttempted = true;
|
|
18629
18834
|
const ticket = await client.createTicket({ ...uncertainSubmission, attachments: [...uncertainSubmission.attachments], ...options.assistanceContext?.() }, { expectedSessionToken: token });
|
|
18630
18835
|
if (!alive(ownGeneration) || !(await tokenFor(ownGeneration)))
|
|
18631
18836
|
return;
|
|
18632
18837
|
completed = true;
|
|
18838
|
+
forgetDraft();
|
|
18633
18839
|
uncertainSubmission = null;
|
|
18634
18840
|
setState('success');
|
|
18635
18841
|
if (!alive(ownGeneration))
|
|
@@ -18741,13 +18947,17 @@ function mountHelpDeskForm(client, options) {
|
|
|
18741
18947
|
};
|
|
18742
18948
|
/** The Cancel path: remove the form, then tell the host the customer closed it. */
|
|
18743
18949
|
function dismiss() {
|
|
18950
|
+
const discardDraft = uncertainSubmission === null;
|
|
18744
18951
|
controller.destroy();
|
|
18952
|
+
if (discardDraft)
|
|
18953
|
+
forgetDraft();
|
|
18745
18954
|
notify$1(options.onCancel, undefined);
|
|
18746
18955
|
}
|
|
18747
18956
|
const controller = {
|
|
18748
18957
|
destroy() {
|
|
18749
18958
|
if (destroyed)
|
|
18750
18959
|
return;
|
|
18960
|
+
persistDraft();
|
|
18751
18961
|
destroyed = true;
|
|
18752
18962
|
generation += 1;
|
|
18753
18963
|
stopResendCountdown();
|
|
@@ -18760,6 +18970,9 @@ function mountHelpDeskForm(client, options) {
|
|
|
18760
18970
|
reset() {
|
|
18761
18971
|
if (destroyed || pending || uncertainSubmission)
|
|
18762
18972
|
return;
|
|
18973
|
+
forgetDraft();
|
|
18974
|
+
restoredDraft = false;
|
|
18975
|
+
restoredFiles = false;
|
|
18763
18976
|
generation += 1;
|
|
18764
18977
|
clearComposer();
|
|
18765
18978
|
disable(false);
|
|
@@ -18768,13 +18981,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
18768
18981
|
},
|
|
18769
18982
|
getState: () => state,
|
|
18770
18983
|
restoreComposition(composition) {
|
|
18771
|
-
if (destroyed)
|
|
18984
|
+
if (destroyed || restoredDraft || restoredAnonymous)
|
|
18772
18985
|
return;
|
|
18773
18986
|
subject.input.value = composition.subject;
|
|
18774
18987
|
description.input.value = composition.body;
|
|
18988
|
+
persistDraft();
|
|
18775
18989
|
},
|
|
18776
18990
|
refill(composition) {
|
|
18777
|
-
if (destroyed || safeComposition() === null)
|
|
18991
|
+
if (destroyed || restoredDraft || safeComposition() === null)
|
|
18778
18992
|
return false;
|
|
18779
18993
|
for (const [entry, key] of [[subject, 'subject'], [description, 'body']]) {
|
|
18780
18994
|
if (!edited(entry.input, prefill[key])) {
|
|
@@ -18783,6 +18997,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
18783
18997
|
}
|
|
18784
18998
|
prefill[key] = composition[key];
|
|
18785
18999
|
}
|
|
19000
|
+
persistDraft();
|
|
18786
19001
|
return true;
|
|
18787
19002
|
},
|
|
18788
19003
|
resumeAfterAccess() {
|
|
@@ -18822,7 +19037,25 @@ function mountHelpDeskForm(client, options) {
|
|
|
18822
19037
|
keepEditing.addEventListener('click', () => closeConfirm(true));
|
|
18823
19038
|
discard.addEventListener('click', dismiss);
|
|
18824
19039
|
form.addEventListener('submit', onSubmit);
|
|
19040
|
+
form.addEventListener('input', persistDraft);
|
|
19041
|
+
form.addEventListener('change', () => {
|
|
19042
|
+
if (attachments?.hasEntries)
|
|
19043
|
+
restoredFiles = false;
|
|
19044
|
+
persistDraft();
|
|
19045
|
+
});
|
|
18825
19046
|
renderWidgetIdentity();
|
|
19047
|
+
if (options.widgetIdentity?.customer) {
|
|
19048
|
+
restoreDraft(options.widgetIdentity.customer);
|
|
19049
|
+
disable(false);
|
|
19050
|
+
}
|
|
19051
|
+
else if (options.persist) {
|
|
19052
|
+
const saved = readAnonymousFormDraft(client.desk.desk_id);
|
|
19053
|
+
if (saved) {
|
|
19054
|
+
subject.input.value = saved.subject;
|
|
19055
|
+
description.input.value = saved.body;
|
|
19056
|
+
restoredAnonymous = true;
|
|
19057
|
+
}
|
|
19058
|
+
}
|
|
18826
19059
|
notify$1(options.onStateChange, state);
|
|
18827
19060
|
// Native company identity starts as the form opens, never from a Connect,
|
|
18828
19061
|
// Allow, verification or submit gesture. Guest email is explicit desk policy.
|
|
@@ -19343,7 +19576,9 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
19343
19576
|
!['public', 'password', 'ip_allowlist', 'identity'].includes(value.access?.mode) ||
|
|
19344
19577
|
(value.available && (!/^[a-f0-9]{64}$/.test(value.release_id ?? '') || !this.canonicalOrigin(value.canonical_origin))))
|
|
19345
19578
|
throw invalid();
|
|
19346
|
-
|
|
19579
|
+
// The first config initializes an empty client. Invalidating it would
|
|
19580
|
+
// reject another initial check still in flight for this same publication.
|
|
19581
|
+
if ((this.config !== null && this.config.release_id !== value.release_id) || !value.authorized)
|
|
19347
19582
|
this.clearContent();
|
|
19348
19583
|
this.config = value;
|
|
19349
19584
|
return value;
|
|
@@ -19987,13 +20222,19 @@ function injectHelpDeskSupportStyles() {
|
|
|
19987
20222
|
.svhs-contact-target .svhd-description{min-height:160px}
|
|
19988
20223
|
.svhs-contact-target>.svhd-container{padding:24px}
|
|
19989
20224
|
.svhs-contact-target .svhd-widget-form>.svhd-actions{padding-bottom:env(safe-area-inset-bottom)}
|
|
19990
|
-
.svhs-receipt-scroll{padding-top:58px
|
|
20225
|
+
.svhs-receipt-scroll{padding-top:58px}
|
|
19991
20226
|
.svhs-panel[data-stage=receipt] .svhs-bottom{border-top:0;padding-top:8px}
|
|
19992
20227
|
.svhs-toast{right:18px;left:18px;bottom:calc(88px + var(--svhs-toast-offset,0px) + env(safe-area-inset-bottom));max-width:none}
|
|
19993
20228
|
}
|
|
19994
20229
|
@media(pointer:coarse){.svhs-icon-button{width:44px;height:44px}.svhs-back{min-height:44px}.svhs-query .svhs-text-button{min-height:44px;min-width:44px}}
|
|
19995
20230
|
@media(prefers-reduced-motion:reduce){.svhs-panel,.svhs-panel *,.sv-support-launcher{transition-duration:0s!important;animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important}}
|
|
19996
20231
|
@media(forced-colors:active){.svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:2px solid Highlight}.svhs-panel,.svhs-primary,.svhs-secondary{border:1px solid ButtonText}}
|
|
20232
|
+
.svhs-panel.svhs-page{position:static;inset:auto;z-index:auto;width:100%;height:auto;max-width:960px;max-height:none;margin:0 auto;border:1px solid ${DS.slate200};border-radius:8px;box-shadow:none;transition:none}
|
|
20233
|
+
.svhs-page .svhs-screen{flex:none}
|
|
20234
|
+
.svhs-page .svhs-scroll{flex:none;overflow:visible;overscroll-behavior:auto;scrollbar-gutter:auto}
|
|
20235
|
+
.svhs-page .svhs-contact-target,.svhs-page .svhs-contact-target>.svhd-container{min-height:0}
|
|
20236
|
+
.svhs-page .svhd-widget-form>.svhd-actions{position:static;margin:0;padding:16px 0 0}
|
|
20237
|
+
.svhs-page .svhd-widget-form>.svhd-actions>.svhd-secondary{display:inline-flex}
|
|
19997
20238
|
`;
|
|
19998
20239
|
document.head.appendChild(style);
|
|
19999
20240
|
}
|
|
@@ -20215,8 +20456,9 @@ function httpUrl(value, base = window.location.href) {
|
|
|
20215
20456
|
* so its page lock and keyboard ownership compose with the Identity dialog.
|
|
20216
20457
|
*/
|
|
20217
20458
|
class SupportView {
|
|
20218
|
-
constructor(actions) {
|
|
20459
|
+
constructor(actions, target) {
|
|
20219
20460
|
this.actions = actions;
|
|
20461
|
+
this.target = target;
|
|
20220
20462
|
this.contactTarget = element('div', 'svhs-contact-target');
|
|
20221
20463
|
this.panel = element('section', 'svhs-panel');
|
|
20222
20464
|
this.prefix = `svhs-${++sequence}`;
|
|
@@ -20260,11 +20502,13 @@ class SupportView {
|
|
|
20260
20502
|
this.toastCleanups = new Set();
|
|
20261
20503
|
this.destroyed = false;
|
|
20262
20504
|
injectHelpDeskSupportStyles();
|
|
20263
|
-
this.phoneHistory = actions.onBrowserBack && actions.onBrowserForward ? new SupportPhoneHistory({
|
|
20505
|
+
this.phoneHistory = !target && actions.onBrowserBack && actions.onBrowserForward ? new SupportPhoneHistory({
|
|
20264
20506
|
onBack: () => this.actions.onBrowserBack?.(),
|
|
20265
20507
|
onForward: () => this.actions.onBrowserForward?.(),
|
|
20266
20508
|
}) : null;
|
|
20267
20509
|
this.panel.id = `${this.prefix}-panel`;
|
|
20510
|
+
if (target)
|
|
20511
|
+
this.panel.classList.add('svhs-page');
|
|
20268
20512
|
this.panel.tabIndex = -1;
|
|
20269
20513
|
this.panel.hidden = true;
|
|
20270
20514
|
this.panel.setAttribute('aria-labelledby', `${this.prefix}-name`);
|
|
@@ -20283,7 +20527,9 @@ class SupportView {
|
|
|
20283
20527
|
this.external.rel = 'noopener noreferrer';
|
|
20284
20528
|
this.external.append(icon('external'));
|
|
20285
20529
|
const toolbarActions = element('div', 'svhs-toolbar-actions');
|
|
20286
|
-
toolbarActions.append(this.external
|
|
20530
|
+
toolbarActions.append(this.external);
|
|
20531
|
+
if (!target)
|
|
20532
|
+
toolbarActions.append(this.close);
|
|
20287
20533
|
toolbar.append(this.back, this.deskName, toolbarActions);
|
|
20288
20534
|
this.panel.append(toolbar);
|
|
20289
20535
|
this.identityNotice.append(element('p', 'svhs-status', 'Sign-in is open in another window.'), button('svhs-text-button', 'Cancel sign-in', () => this.actions.onCancelIdentity?.()));
|
|
@@ -20344,7 +20590,9 @@ class SupportView {
|
|
|
20344
20590
|
feedback.classList.add('svhs-feedback-scroll');
|
|
20345
20591
|
feedback.append(element('p', 'svhs-copy', 'Your feedback helps us improve our help articles.'));
|
|
20346
20592
|
const feedbackActions = element('div', 'svhs-feedback-actions');
|
|
20347
|
-
feedbackActions.append(button('svhs-primary', 'Yes, that helped', () => this.actions.onAnswered()), button('svhs-secondary', 'No, contact support', () => this.actions.onContact('article_not_answered'))
|
|
20593
|
+
feedbackActions.append(button('svhs-primary', 'Yes, that helped', () => this.actions.onAnswered()), button('svhs-secondary', 'No, contact support', () => this.actions.onContact('article_not_answered')));
|
|
20594
|
+
if (!target)
|
|
20595
|
+
feedbackActions.append(button('svhs-text-button', 'Not now', () => this.actions.onClose()));
|
|
20348
20596
|
feedback.append(feedbackActions);
|
|
20349
20597
|
const contact = this.screen('contact');
|
|
20350
20598
|
contact.classList.add('svhs-contact-scroll');
|
|
@@ -20368,12 +20616,16 @@ class SupportView {
|
|
|
20368
20616
|
receipt.append(this.receiptCopy, this.receiptTicket, this.receiptMessage);
|
|
20369
20617
|
this.restart = button('svhs-text-button', 'Ask another question', () => this.actions.onRestart?.());
|
|
20370
20618
|
const receiptFooter = this.footer('receipt', 'svhs-receipt-actions');
|
|
20371
|
-
|
|
20619
|
+
if (!target)
|
|
20620
|
+
receiptFooter.append(button('svhs-secondary svhs-full', 'Done', () => this.actions.onClose()));
|
|
20621
|
+
receiptFooter.append(this.restart);
|
|
20372
20622
|
this.panel.append(this.live);
|
|
20373
20623
|
this.media = typeof window.matchMedia === 'function' ? window.matchMedia('(max-width:640px)') : null;
|
|
20374
|
-
|
|
20375
|
-
|
|
20376
|
-
|
|
20624
|
+
if (!target) {
|
|
20625
|
+
this.media?.addEventListener('change', this.onMediaChange);
|
|
20626
|
+
window.visualViewport?.addEventListener('resize', this.onViewportChange);
|
|
20627
|
+
window.visualViewport?.addEventListener('scroll', this.onViewportChange);
|
|
20628
|
+
}
|
|
20377
20629
|
this.onKeydown = (event) => {
|
|
20378
20630
|
if (this.shell || !this.state?.visible || this.destroyed || event.defaultPrevented || event.isComposing || event.keyCode === 229)
|
|
20379
20631
|
return;
|
|
@@ -20386,7 +20638,8 @@ class SupportView {
|
|
|
20386
20638
|
event.preventDefault();
|
|
20387
20639
|
this.actions.onClose();
|
|
20388
20640
|
};
|
|
20389
|
-
|
|
20641
|
+
if (!target)
|
|
20642
|
+
document.addEventListener('keydown', this.onKeydown);
|
|
20390
20643
|
}
|
|
20391
20644
|
render(next) {
|
|
20392
20645
|
if (this.destroyed)
|
|
@@ -20454,7 +20707,7 @@ class SupportView {
|
|
|
20454
20707
|
this.contactTitle.parentElement.hidden = this.contactTitle.hidden && this.contactStatus.hidden && this.contactError.hidden;
|
|
20455
20708
|
const target = heading ?? this.contactTarget;
|
|
20456
20709
|
target.tabIndex = -1;
|
|
20457
|
-
target.focus({ preventScroll:
|
|
20710
|
+
target.focus({ preventScroll: !this.target });
|
|
20458
20711
|
}
|
|
20459
20712
|
/** Hydrate only the current reader's matching authorized publication assets. */
|
|
20460
20713
|
setArticleAsset(path, blobUrl) {
|
|
@@ -20880,6 +21133,13 @@ class SupportView {
|
|
|
20880
21133
|
syncPresentation() {
|
|
20881
21134
|
if (this.destroyed)
|
|
20882
21135
|
return;
|
|
21136
|
+
if (this.target) {
|
|
21137
|
+
this.panel.hidden = !this.state?.visible;
|
|
21138
|
+
if (!this.panel.isConnected || this.panel.parentElement !== this.target)
|
|
21139
|
+
this.target.append(this.panel);
|
|
21140
|
+
this.resizeIssue();
|
|
21141
|
+
return;
|
|
21142
|
+
}
|
|
20883
21143
|
this.phoneHistory?.sync(Boolean(this.state?.visible), Boolean(this.media?.matches));
|
|
20884
21144
|
const active = this.panel.contains(document.activeElement) && document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
20885
21145
|
if (!this.state?.visible) {
|
|
@@ -20938,6 +21198,8 @@ class SupportView {
|
|
|
20938
21198
|
hide() {
|
|
20939
21199
|
const wasVisible = !this.panel.hidden;
|
|
20940
21200
|
this.panel.hidden = true;
|
|
21201
|
+
if (this.target)
|
|
21202
|
+
return;
|
|
20941
21203
|
if (this.shell) {
|
|
20942
21204
|
this.panel.remove();
|
|
20943
21205
|
this.shell.destroy();
|
|
@@ -20964,12 +21226,12 @@ class SupportView {
|
|
|
20964
21226
|
if (!this.state?.visible)
|
|
20965
21227
|
return;
|
|
20966
21228
|
if (this.state.stage === 'issue') {
|
|
20967
|
-
(this.media?.matches ? this.close : this.issue).focus({ preventScroll:
|
|
21229
|
+
(!this.target && this.media?.matches ? this.close : this.issue).focus({ preventScroll: !this.target });
|
|
20968
21230
|
}
|
|
20969
21231
|
else if (this.state.stage === 'contact')
|
|
20970
21232
|
this.focusContact();
|
|
20971
21233
|
else
|
|
20972
|
-
(this.headings.get(this.state.stage) ?? this.panel).focus({ preventScroll:
|
|
21234
|
+
(this.headings.get(this.state.stage) ?? this.panel).focus({ preventScroll: !this.target });
|
|
20973
21235
|
}
|
|
20974
21236
|
}
|
|
20975
21237
|
|
|
@@ -21012,6 +21274,8 @@ function createHelpDeskSupport(config, options) {
|
|
|
21012
21274
|
let requestedArticle = null;
|
|
21013
21275
|
let articleRetrySearch = false;
|
|
21014
21276
|
let cancelArticleAssets = null;
|
|
21277
|
+
let stopSession = null;
|
|
21278
|
+
let anonymous = false;
|
|
21015
21279
|
const lifetime = new AbortController();
|
|
21016
21280
|
const bindings = new Set();
|
|
21017
21281
|
let state = { visible: false, stage: 'issue', deskName: 'Support', issue: '' };
|
|
@@ -21021,7 +21285,11 @@ function createHelpDeskSupport(config, options) {
|
|
|
21021
21285
|
}
|
|
21022
21286
|
const http = new HttpClient({ ...config, accessToken: undefined, getAccessToken: undefined, apiKey: undefined });
|
|
21023
21287
|
const view = new SupportView({
|
|
21024
|
-
onIssueChange: (issue) => {
|
|
21288
|
+
onIssueChange: (issue) => {
|
|
21289
|
+
state.issue = issue;
|
|
21290
|
+
if (options.persist && anonymous && client)
|
|
21291
|
+
saveSupportIssue(client.desk.desk_id, issue);
|
|
21292
|
+
},
|
|
21025
21293
|
onSearch: (issue) => { void search(issue); },
|
|
21026
21294
|
onContact: (reason) => { void showContact(reason); },
|
|
21027
21295
|
onOpenArticle: (id) => { void openArticle(id); },
|
|
@@ -21059,15 +21327,11 @@ function createHelpDeskSupport(config, options) {
|
|
|
21059
21327
|
if (destroyed || !state.article)
|
|
21060
21328
|
return;
|
|
21061
21329
|
void attempt?.then((active) => active?.solved());
|
|
21062
|
-
|
|
21063
|
-
minimize();
|
|
21330
|
+
resetJourney(options.target !== undefined);
|
|
21064
21331
|
view.showToast('We’re happy we could help.');
|
|
21065
|
-
state = { visible: false, stage: 'issue', deskName: state.deskName, issue: '', position: state.position };
|
|
21066
|
-
update({});
|
|
21067
21332
|
},
|
|
21068
21333
|
onRestart: () => {
|
|
21069
|
-
|
|
21070
|
-
update({ stage: 'issue', issue: '', results: [], article: undefined, receipt: undefined, error: undefined, busy: false });
|
|
21334
|
+
resetJourney(state.visible);
|
|
21071
21335
|
},
|
|
21072
21336
|
onRetry: () => {
|
|
21073
21337
|
if (state.stage === 'contact')
|
|
@@ -21084,7 +21348,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
21084
21348
|
onCancelIdentity: () => nativeIdentity?.abort(),
|
|
21085
21349
|
onBrowserBack: minimize,
|
|
21086
21350
|
onBrowserForward: () => update({ visible: true }),
|
|
21087
|
-
});
|
|
21351
|
+
}, options.target === undefined ? undefined : resolveTarget(options.target));
|
|
21088
21352
|
const launcher = (() => {
|
|
21089
21353
|
try {
|
|
21090
21354
|
return options.launcher ? createSupportLauncher(typeof options.launcher === 'object' ? options.launcher : {}, () => { void open(); }) : null;
|
|
@@ -21109,6 +21373,10 @@ function createHelpDeskSupport(config, options) {
|
|
|
21109
21373
|
if (destroyed)
|
|
21110
21374
|
throw new Error('Support is closed.');
|
|
21111
21375
|
client = answer;
|
|
21376
|
+
stopSession = answer.subscribeSession((change) => {
|
|
21377
|
+
if (change.source === 'clear')
|
|
21378
|
+
notify(options.onSession, null);
|
|
21379
|
+
});
|
|
21112
21380
|
kb = new HelpDeskKnowledgeBaseClient(config, answer.desk.desk_id);
|
|
21113
21381
|
analytics = createSupportAnalytics({
|
|
21114
21382
|
deskId: answer.desk.desk_id,
|
|
@@ -21131,7 +21399,34 @@ function createHelpDeskSupport(config, options) {
|
|
|
21131
21399
|
state.issue = input.issue;
|
|
21132
21400
|
update({ visible: true });
|
|
21133
21401
|
try {
|
|
21134
|
-
await connect();
|
|
21402
|
+
const active = await connect();
|
|
21403
|
+
if (!options.persist || destroyed || state.stage !== 'issue')
|
|
21404
|
+
return;
|
|
21405
|
+
const token = await active.getSessionToken();
|
|
21406
|
+
if (destroyed)
|
|
21407
|
+
return;
|
|
21408
|
+
anonymous = !token;
|
|
21409
|
+
if (!token) {
|
|
21410
|
+
if (!state.issue)
|
|
21411
|
+
update({ issue: readSupportIssue(active.desk.desk_id) ?? '' });
|
|
21412
|
+
if (state.issue)
|
|
21413
|
+
saveSupportIssue(active.desk.desk_id, state.issue);
|
|
21414
|
+
if (readAnonymousFormDraft(active.desk.desk_id))
|
|
21415
|
+
await showContact('direct');
|
|
21416
|
+
}
|
|
21417
|
+
else if (active.hasTicketAccess) {
|
|
21418
|
+
const customer = await active.getMe();
|
|
21419
|
+
if (destroyed || state.stage !== 'issue')
|
|
21420
|
+
return;
|
|
21421
|
+
const saved = readFormDraft(active.desk.desk_id, customer.requester_id);
|
|
21422
|
+
const composition = readAnonymousFormDraft(active.desk.desk_id);
|
|
21423
|
+
if ((saved || composition) && !state.issue) {
|
|
21424
|
+
update({ issue: saved?.body ?? readSupportIssue(active.desk.desk_id) ?? '' });
|
|
21425
|
+
await showContact('direct');
|
|
21426
|
+
}
|
|
21427
|
+
else if (!state.issue)
|
|
21428
|
+
update({ issue: readSupportIssue(active.desk.desk_id) ?? '' });
|
|
21429
|
+
}
|
|
21135
21430
|
}
|
|
21136
21431
|
catch (value) {
|
|
21137
21432
|
if (!destroyed) {
|
|
@@ -21143,7 +21438,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
21143
21438
|
}
|
|
21144
21439
|
function minimize() { update({ visible: false }); }
|
|
21145
21440
|
/** Forget a finished journey: its form and the files it authorized, any composition held for it, its suggestions and article. */
|
|
21146
|
-
function
|
|
21441
|
+
function resetJourney(visible) {
|
|
21147
21442
|
contact?.destroy();
|
|
21148
21443
|
contact = null;
|
|
21149
21444
|
contactCustomer = null;
|
|
@@ -21154,6 +21449,10 @@ function createHelpDeskSupport(config, options) {
|
|
|
21154
21449
|
results = [];
|
|
21155
21450
|
requestedArticle = null;
|
|
21156
21451
|
pendingComposition = null;
|
|
21452
|
+
if (options.persist && client)
|
|
21453
|
+
clearSupportIssue(client.desk.desk_id);
|
|
21454
|
+
update({ visible, stage: 'issue', issue: '', results: [], article: undefined, articleUrl: undefined,
|
|
21455
|
+
receipt: undefined, error: undefined, busy: false, navigationLocked: false });
|
|
21157
21456
|
}
|
|
21158
21457
|
function signIn(input = {}) {
|
|
21159
21458
|
if (!client)
|
|
@@ -21317,6 +21616,13 @@ function createHelpDeskSupport(config, options) {
|
|
|
21317
21616
|
// wrote in an earlier form and carried here stays their own.
|
|
21318
21617
|
...composeIssue(composedFrom),
|
|
21319
21618
|
attachments: options.attachments,
|
|
21619
|
+
persist: options.persist,
|
|
21620
|
+
onSession: (session) => {
|
|
21621
|
+
anonymous = false;
|
|
21622
|
+
if (options.persist)
|
|
21623
|
+
clearSupportIssue(client.desk.desk_id);
|
|
21624
|
+
notify(options.onSession, session);
|
|
21625
|
+
},
|
|
21320
21626
|
widgetIdentity: {
|
|
21321
21627
|
customer,
|
|
21322
21628
|
signIn: (input) => signIn(input).then((session) => { contactCustomer = session.customer; return session; }),
|
|
@@ -21337,7 +21643,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
21337
21643
|
});
|
|
21338
21644
|
});
|
|
21339
21645
|
},
|
|
21340
|
-
onCancel: () =>
|
|
21646
|
+
onCancel: () => resetJourney(options.target !== undefined),
|
|
21341
21647
|
onSuccess: (ticket) => receipt(ticket),
|
|
21342
21648
|
onStateChange: (next) => update({ navigationLocked: ['authenticating', 'submitting', 'uncertain'].includes(next) }),
|
|
21343
21649
|
});
|
|
@@ -21402,9 +21708,13 @@ function createHelpDeskSupport(config, options) {
|
|
|
21402
21708
|
if (destroyed || ownSequence !== sequence)
|
|
21403
21709
|
return;
|
|
21404
21710
|
update({ busy: false, ticketAccessRequired: false, ticketAccessMode: undefined });
|
|
21711
|
+
anonymous = !customer;
|
|
21712
|
+
const composition = pendingComposition ?? (options.persist ? readAnonymousFormDraft(active.desk.desk_id) : null) ?? composeIssue(state.issue);
|
|
21713
|
+
if (customer && options.persist)
|
|
21714
|
+
clearSupportIssue(active.desk.desk_id);
|
|
21405
21715
|
if (!pendingComposition)
|
|
21406
21716
|
composedFrom = state.issue.trim();
|
|
21407
|
-
mountContact(
|
|
21717
|
+
mountContact(composition, customer);
|
|
21408
21718
|
pendingComposition = null;
|
|
21409
21719
|
}
|
|
21410
21720
|
catch (value) {
|
|
@@ -21433,13 +21743,15 @@ function createHelpDeskSupport(config, options) {
|
|
|
21433
21743
|
update({ busy: true, error: undefined });
|
|
21434
21744
|
try {
|
|
21435
21745
|
if (policy?.mode === 'password')
|
|
21436
|
-
await active.unlockTicketAccess({ password });
|
|
21746
|
+
notify(options.onTicketAccess, await active.unlockTicketAccess({ password }));
|
|
21437
21747
|
else if (identity) {
|
|
21438
21748
|
const session = await identity;
|
|
21439
|
-
await active.unlockTicketAccess({ identityGrant: session.identity_grant.token });
|
|
21749
|
+
notify(options.onTicketAccess, await active.unlockTicketAccess({ identityGrant: session.identity_grant.token }));
|
|
21440
21750
|
const hostToken = await active.getSessionToken();
|
|
21441
|
-
if (!hostToken)
|
|
21751
|
+
if (!hostToken) {
|
|
21442
21752
|
active.setSession(session);
|
|
21753
|
+
notify(options.onSession, session);
|
|
21754
|
+
}
|
|
21443
21755
|
}
|
|
21444
21756
|
else
|
|
21445
21757
|
throw new Error('Connect to an approved network, then try again.');
|
|
@@ -21482,10 +21794,11 @@ function createHelpDeskSupport(config, options) {
|
|
|
21482
21794
|
if (destroyed || ownSequence !== sequence)
|
|
21483
21795
|
return;
|
|
21484
21796
|
if (active.ticketAccessPolicy?.mode === 'identity')
|
|
21485
|
-
await active.unlockTicketAccess({ identityGrant: session.identity_grant.token });
|
|
21797
|
+
notify(options.onTicketAccess, await active.unlockTicketAccess({ identityGrant: session.identity_grant.token }));
|
|
21486
21798
|
if (destroyed || ownSequence !== sequence)
|
|
21487
21799
|
return;
|
|
21488
21800
|
active.setSession(session);
|
|
21801
|
+
notify(options.onSession, session);
|
|
21489
21802
|
update({ busy: false });
|
|
21490
21803
|
await showContact('direct');
|
|
21491
21804
|
}
|
|
@@ -21582,6 +21895,8 @@ function createHelpDeskSupport(config, options) {
|
|
|
21582
21895
|
analytics?.dispose();
|
|
21583
21896
|
launcher?.destroy();
|
|
21584
21897
|
view.destroy();
|
|
21898
|
+
stopSession?.();
|
|
21899
|
+
stopSession = null;
|
|
21585
21900
|
// Only this support client is cleared; the host site's sign-in is untouched.
|
|
21586
21901
|
client?.clearTicketAccess();
|
|
21587
21902
|
client?.setSession(null);
|
|
@@ -22698,11 +23013,6 @@ function getUploadStyles() {
|
|
|
22698
23013
|
overflow: hidden;
|
|
22699
23014
|
}
|
|
22700
23015
|
|
|
22701
|
-
.svu-modal.svu-with-sidebar {
|
|
22702
|
-
max-width: 900px;
|
|
22703
|
-
flex-direction: row;
|
|
22704
|
-
}
|
|
22705
|
-
|
|
22706
23016
|
.svu-modal-main {
|
|
22707
23017
|
flex: 1;
|
|
22708
23018
|
display: flex;
|
|
@@ -23466,13 +23776,38 @@ function getUploadStyles() {
|
|
|
23466
23776
|
}
|
|
23467
23777
|
|
|
23468
23778
|
/* ========================================
|
|
23469
|
-
SECURITY
|
|
23779
|
+
ON-DEMAND SECURITY HELP
|
|
23470
23780
|
======================================== */
|
|
23471
23781
|
|
|
23782
|
+
.svu-security-help {
|
|
23783
|
+
flex-shrink: 0;
|
|
23784
|
+
border-top: 1px solid ${tokens.borderDark};
|
|
23785
|
+
}
|
|
23786
|
+
|
|
23787
|
+
.svu-security-help summary {
|
|
23788
|
+
display: flex;
|
|
23789
|
+
align-items: center;
|
|
23790
|
+
justify-content: center;
|
|
23791
|
+
width: 44px;
|
|
23792
|
+
min-height: 44px;
|
|
23793
|
+
margin-left: auto;
|
|
23794
|
+
cursor: pointer;
|
|
23795
|
+
color: ${tokens.textMutedOnDark};
|
|
23796
|
+
font-size: 16px;
|
|
23797
|
+
list-style: none;
|
|
23798
|
+
}
|
|
23799
|
+
|
|
23800
|
+
.svu-security-help summary::-webkit-details-marker { display: none; }
|
|
23801
|
+
.svu-security-help summary:focus-visible {
|
|
23802
|
+
outline: 2px solid ${tokens.textOnDark};
|
|
23803
|
+
outline-offset: -4px;
|
|
23804
|
+
}
|
|
23805
|
+
|
|
23472
23806
|
.svu-sidebar {
|
|
23473
|
-
|
|
23807
|
+
box-sizing: border-box;
|
|
23808
|
+
width: 100%;
|
|
23809
|
+
max-height: 240px;
|
|
23474
23810
|
background: ${tokens.bgDark};
|
|
23475
|
-
border-left: 1px solid ${tokens.borderDark};
|
|
23476
23811
|
color: ${tokens.textOnDark};
|
|
23477
23812
|
padding: 20px;
|
|
23478
23813
|
overflow-y: auto;
|
|
@@ -23642,20 +23977,6 @@ function getUploadStyles() {
|
|
|
23642
23977
|
RESPONSIVE
|
|
23643
23978
|
======================================== */
|
|
23644
23979
|
|
|
23645
|
-
@media (max-width: 768px) {
|
|
23646
|
-
.svu-modal.svu-with-sidebar {
|
|
23647
|
-
flex-direction: column;
|
|
23648
|
-
max-width: 480px;
|
|
23649
|
-
}
|
|
23650
|
-
|
|
23651
|
-
.svu-sidebar {
|
|
23652
|
-
width: 100%;
|
|
23653
|
-
border-left: none;
|
|
23654
|
-
border-top: 1px solid ${tokens.borderDark};
|
|
23655
|
-
max-height: 300px;
|
|
23656
|
-
}
|
|
23657
|
-
}
|
|
23658
|
-
|
|
23659
23980
|
@media (max-width: 480px) {
|
|
23660
23981
|
.svu-modal {
|
|
23661
23982
|
max-width: 100%;
|
|
@@ -23723,7 +24044,7 @@ function getUploadStyles() {
|
|
|
23723
24044
|
* Upload Modal Container
|
|
23724
24045
|
*
|
|
23725
24046
|
* Single responsibility: the upload dialog's chrome (branded header, body,
|
|
23726
|
-
* footer, and
|
|
24047
|
+
* footer, and optional security help) inside the SDK's shared
|
|
23727
24048
|
* modal shell, which owns the dialog behaviour (dismissal, scroll lock,
|
|
23728
24049
|
* focus). Does NOT handle content rendering - that's the Renderer's job.
|
|
23729
24050
|
*/
|
|
@@ -23812,25 +24133,33 @@ class UploadModalContainer {
|
|
|
23812
24133
|
this.refreshHeader();
|
|
23813
24134
|
}
|
|
23814
24135
|
/**
|
|
23815
|
-
*
|
|
23816
|
-
* the
|
|
24136
|
+
* Offer security education on demand during a transfer. Never expand it
|
|
24137
|
+
* automatically or widen the working view to accommodate explanatory copy.
|
|
23817
24138
|
*/
|
|
23818
24139
|
toggleSidebar(show) {
|
|
23819
24140
|
if (!this.shell)
|
|
23820
24141
|
return;
|
|
23821
24142
|
if (show && !this.sidebar) {
|
|
23822
|
-
this.sidebar =
|
|
23823
|
-
this.
|
|
23824
|
-
|
|
23825
|
-
|
|
23826
|
-
|
|
24143
|
+
this.sidebar = document.createElement('details');
|
|
24144
|
+
this.sidebar.className = 'svu-security-help';
|
|
24145
|
+
const summary = document.createElement('summary');
|
|
24146
|
+
summary.textContent = '?';
|
|
24147
|
+
summary.setAttribute('aria-label', 'About upload security');
|
|
24148
|
+
summary.title = 'About upload security';
|
|
24149
|
+
this.sidebar.append(summary, createSecuritySidebar(this.branding));
|
|
24150
|
+
this.sidebar.addEventListener('keydown', (event) => {
|
|
24151
|
+
if (event.key !== 'Escape' || !this.sidebar?.open)
|
|
24152
|
+
return;
|
|
24153
|
+
event.preventDefault();
|
|
24154
|
+
event.stopPropagation();
|
|
24155
|
+
this.sidebar.open = false;
|
|
24156
|
+
summary.focus();
|
|
24157
|
+
});
|
|
24158
|
+
this.body?.after(this.sidebar);
|
|
23827
24159
|
}
|
|
23828
24160
|
else if (!show && this.sidebar) {
|
|
23829
|
-
this.shell.modal.classList.remove('svu-with-sidebar');
|
|
23830
24161
|
this.sidebar.remove();
|
|
23831
24162
|
this.sidebar = null;
|
|
23832
|
-
if (this.header)
|
|
23833
|
-
this.header.style.display = '';
|
|
23834
24163
|
}
|
|
23835
24164
|
}
|
|
23836
24165
|
handleClose() {
|
|
@@ -24228,7 +24557,7 @@ class UploadRenderer {
|
|
|
24228
24557
|
return;
|
|
24229
24558
|
// Clear body
|
|
24230
24559
|
body.innerHTML = '';
|
|
24231
|
-
// The dialog darkens and
|
|
24560
|
+
// The dialog darkens and offers optional security help in the dark states;
|
|
24232
24561
|
// inline mode runs those states in its own dialog (renderInModal).
|
|
24233
24562
|
if (this.container instanceof UploadModalContainer) {
|
|
24234
24563
|
this.container.setDarkMode(isDarkState);
|
|
@@ -24314,7 +24643,7 @@ class UploadRenderer {
|
|
|
24314
24643
|
if (inlineBody?.parentElement) {
|
|
24315
24644
|
inlineBody.parentElement.style.display = 'none';
|
|
24316
24645
|
}
|
|
24317
|
-
// Set dark mode and
|
|
24646
|
+
// Set dark mode and offer security help once, closed until requested.
|
|
24318
24647
|
this.uploadModal.setDarkMode(true);
|
|
24319
24648
|
this.uploadModal.toggleSidebar(true);
|
|
24320
24649
|
this.hybridModalInitialized = true;
|
|
@@ -26329,7 +26658,7 @@ class SparkVault {
|
|
|
26329
26658
|
}
|
|
26330
26659
|
/** Get the SDK version */
|
|
26331
26660
|
static get version() {
|
|
26332
|
-
return '15.
|
|
26661
|
+
return '15.14.1';
|
|
26333
26662
|
}
|
|
26334
26663
|
}
|
|
26335
26664
|
if (typeof window !== 'undefined') {
|