@sparkvault/sdk-js 15.18.0 → 16.0.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/dist/index.cjs +21 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +21 -15
- package/dist/index.mjs.map +1 -1
- package/dist/products/help-desk/support-view.d.ts +1 -0
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -20432,9 +20432,12 @@ function getDomain(url, options) {
|
|
|
20432
20432
|
|
|
20433
20433
|
/** Anonymous correlation only: these identifiers never authorize customer access. */
|
|
20434
20434
|
|
|
20435
|
-
const VISITOR_COOKIE_DEFAULTS = Object.freeze({ enabled: true, domain_scope: 'host', cookie_name: '
|
|
20435
|
+
const VISITOR_COOKIE_DEFAULTS = Object.freeze({ enabled: true, domain_scope: 'host', cookie_name: 'hdid' });
|
|
20436
20436
|
const VISITOR_COOKIE_SECONDS = 30 * 86400;
|
|
20437
|
-
|
|
20437
|
+
// Preserve opaque cookie values (UUIDs, prefixed IDs, hex, base64, etc.) without interpreting them.
|
|
20438
|
+
// RFC 6265 cookie-octets exclude separators and control characters; bound storage and request sizes.
|
|
20439
|
+
const VISITOR_ID_MAX_LENGTH = 256;
|
|
20440
|
+
const validVisitorId = (value) => typeof value === 'string' && value.length > 0 && value.length <= VISITOR_ID_MAX_LENGTH && /^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]+$/.test(value);
|
|
20438
20441
|
const validVisitorCookieName = (value) => typeof value === 'string' && /^[a-zA-Z_][a-zA-Z0-9_.-]{0,63}$/.test(value) && !/^(?:__Host-|__Secure-|__sv|sv_|auth)/i.test(value);
|
|
20439
20442
|
|
|
20440
20443
|
/** Never share a platform host's cookie between unrelated desks. PSL handles co.uk and private suffixes. */
|
|
@@ -20762,7 +20765,7 @@ function recommendKnowledgeBase(prepared, issue, { limit = 5, categoryId = null
|
|
|
20762
20765
|
].map(value => typeof value === 'function' ? value.toString() : value).join('\n') + '\nexport { prepareSearchIndex, searchKnowledgeBase, recommendKnowledgeBase };\n';
|
|
20763
20766
|
|
|
20764
20767
|
const currentVisitor = (value) => value !== null && typeof value === 'object' &&
|
|
20765
|
-
'visitor_id' in value &&
|
|
20768
|
+
'visitor_id' in value && validVisitorId(value.visitor_id) &&
|
|
20766
20769
|
'expires_at' in value && typeof value.expires_at === 'number' && Number.isSafeInteger(value.expires_at) &&
|
|
20767
20770
|
value.expires_at * 1000 > Date.now() + 60000 && value.expires_at * 1000 <= Date.now() + 31 * 86400000;
|
|
20768
20771
|
const invalid = () => new SparkVaultError('The help center returned an invalid answer. Try again.', 'KB_INVALID_RESPONSE');
|
|
@@ -20987,7 +20990,7 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
20987
20990
|
if (!currentVisitor(value))
|
|
20988
20991
|
throw invalid();
|
|
20989
20992
|
this.visitorSession = { key, value };
|
|
20990
|
-
if (settings.enabled && validVisitorCookieName(settings.cookie_name) && !cookieEndpoint) {
|
|
20993
|
+
if (settings.enabled && !candidate && validVisitorCookieName(settings.cookie_name) && !cookieEndpoint) {
|
|
20991
20994
|
try {
|
|
20992
20995
|
document.cookie = `${settings.cookie_name}=${value.visitor_id}; Path=/; Max-Age=${VISITOR_COOKIE_SECONDS}; Secure; SameSite=Lax${settings.domain_scope === 'parent' && parent && parent === canonicalParent ? `; Domain=${parent}` : ''}`;
|
|
20993
20996
|
}
|
|
@@ -22074,6 +22077,7 @@ class SupportView {
|
|
|
22074
22077
|
this.live.setAttribute('role', 'status');
|
|
22075
22078
|
this.live.setAttribute('aria-live', 'polite');
|
|
22076
22079
|
const toolbar = element('header', 'svhs-toolbar');
|
|
22080
|
+
this.toolbar = toolbar;
|
|
22077
22081
|
this.back = button('svhs-back', 'Back', () => this.actions.onBack());
|
|
22078
22082
|
this.back.prepend(icon('back'));
|
|
22079
22083
|
this.close = button('svhs-icon-button', '', () => this.actions.onClose());
|
|
@@ -22093,14 +22097,17 @@ class SupportView {
|
|
|
22093
22097
|
this.identityNotice.append(element('p', 'svhs-status', 'Sign-in is open in another window.'), button('svhs-text-button', 'Cancel sign-in', () => this.actions.onCancelIdentity?.()));
|
|
22094
22098
|
this.identityNotice.hidden = true;
|
|
22095
22099
|
this.panel.append(this.identityNotice);
|
|
22096
|
-
const intro = this.screen('issue', 'How can we help?');
|
|
22100
|
+
const intro = this.screen('issue', 'How can we help?', target ? 'h1' : 'h2');
|
|
22097
22101
|
// The heading asks the question once, so it names the field too.
|
|
22098
22102
|
const issueHeading = this.headings.get('issue');
|
|
22099
22103
|
issueHeading.id = `${this.prefix}-issue-title`;
|
|
22104
|
+
const helper = element('p', 'svhs-copy', 'What is your question? Tell us what is going on.');
|
|
22105
|
+
helper.id = `${this.prefix}-issue-help`;
|
|
22100
22106
|
this.issue.id = `${this.prefix}-issue`;
|
|
22101
22107
|
this.issue.setAttribute('aria-labelledby', issueHeading.id);
|
|
22108
|
+
this.issue.setAttribute('aria-describedby', helper.id);
|
|
22102
22109
|
this.issue.name = 'support_issue';
|
|
22103
|
-
this.issue.placeholder = 'Describe
|
|
22110
|
+
this.issue.placeholder = 'Describe your question or issue';
|
|
22104
22111
|
this.issue.autocomplete = 'off';
|
|
22105
22112
|
this.issue.setAttribute('aria-describedby', `${this.prefix}-issue-error`);
|
|
22106
22113
|
this.issueError.id = `${this.prefix}-issue-error`;
|
|
@@ -22118,7 +22125,7 @@ class SupportView {
|
|
|
22118
22125
|
this.search();
|
|
22119
22126
|
}
|
|
22120
22127
|
});
|
|
22121
|
-
intro.append(this.issue, this.issueError);
|
|
22128
|
+
intro.append(helper, this.issue, this.issueError);
|
|
22122
22129
|
this.find = button('svhs-primary', 'Continue', () => this.search());
|
|
22123
22130
|
this.footer('issue', 'svhs-start-bottom').append(this.find);
|
|
22124
22131
|
const results = this.screen('results', 'These articles may help');
|
|
@@ -22131,16 +22138,14 @@ class SupportView {
|
|
|
22131
22138
|
results.prepend(queryLine);
|
|
22132
22139
|
results.append(this.resultCopy, this.resultList, this.resultStatus, this.resultError);
|
|
22133
22140
|
this.resultError.setAttribute('role', 'alert');
|
|
22134
|
-
this.contactResults = button('svhs-secondary svhs-full', '
|
|
22141
|
+
this.contactResults = button('svhs-secondary svhs-full', 'Still need help? Open a ticket', () => {
|
|
22135
22142
|
if (this.state?.busy)
|
|
22136
22143
|
return;
|
|
22137
22144
|
this.actions.onContact(['locked', 'unavailable'].includes(this.state?.kbState || '') ? 'direct' : this.state?.results?.length ? 'none_match' : 'no_results');
|
|
22138
22145
|
});
|
|
22139
22146
|
this.resultsFooter = this.footer('results');
|
|
22140
22147
|
this.resultsFooter.classList.add('svhs-results-bottom');
|
|
22141
|
-
|
|
22142
|
-
escalation.append(element('p', 'svhs-footer-title', 'Still need help?'), element('p', 'svhs-footer-copy', 'Send your question to our support team.'));
|
|
22143
|
-
this.resultsFooter.append(escalation, this.contactResults);
|
|
22148
|
+
this.resultsFooter.append(this.contactResults);
|
|
22144
22149
|
const article = this.screen('article');
|
|
22145
22150
|
article.classList.add('svhs-article-scroll');
|
|
22146
22151
|
this.articleTitle.tabIndex = -1;
|
|
@@ -22250,6 +22255,7 @@ class SupportView {
|
|
|
22250
22255
|
this.back.disabled = Boolean(next.navigationLocked || next.identityPending);
|
|
22251
22256
|
this.back.lastChild.textContent = next.stage === 'article' ? 'All answers' : next.stage === 'feedback' ? 'Keep reading' : 'Back';
|
|
22252
22257
|
this.deskName.hidden = next.stage === 'article';
|
|
22258
|
+
this.toolbar.hidden = Boolean(this.target && next.stage === 'issue');
|
|
22253
22259
|
const heading = this.headings.get(next.stage);
|
|
22254
22260
|
if (heading && !heading.id)
|
|
22255
22261
|
heading.id = `${this.prefix}-${next.stage}-title`;
|
|
@@ -22264,7 +22270,7 @@ class SupportView {
|
|
|
22264
22270
|
this.find.replaceChildren();
|
|
22265
22271
|
if (next.busy)
|
|
22266
22272
|
this.find.append(element('span', 'svhs-spinner'));
|
|
22267
|
-
this.find.append(document.createTextNode(next.busy ? 'Continuing
|
|
22273
|
+
this.find.append(document.createTextNode(next.busy ? 'Continuing...' : 'Continue'));
|
|
22268
22274
|
this.issueError.textContent = next.stage === 'issue' ? next.error || '' : '';
|
|
22269
22275
|
this.issueError.hidden = !this.issueError.textContent;
|
|
22270
22276
|
this.query.textContent = next.issue;
|
|
@@ -22425,12 +22431,12 @@ class SupportView {
|
|
|
22425
22431
|
this.hide();
|
|
22426
22432
|
this.panel.remove();
|
|
22427
22433
|
}
|
|
22428
|
-
screen(stage, title) {
|
|
22434
|
+
screen(stage, title, tag = 'h2') {
|
|
22429
22435
|
const screen = element('section', 'svhs-screen');
|
|
22430
22436
|
screen.hidden = true;
|
|
22431
22437
|
const body = element('div', 'svhs-scroll');
|
|
22432
22438
|
if (title) {
|
|
22433
|
-
const heading = element(
|
|
22439
|
+
const heading = element(tag, 'svhs-heading', title);
|
|
22434
22440
|
heading.tabIndex = -1;
|
|
22435
22441
|
body.append(heading);
|
|
22436
22442
|
this.headings.set(stage, heading);
|
|
@@ -28345,7 +28351,7 @@ class SparkVault {
|
|
|
28345
28351
|
}
|
|
28346
28352
|
/** Get the SDK version */
|
|
28347
28353
|
static get version() {
|
|
28348
|
-
return '
|
|
28354
|
+
return '16.0.1';
|
|
28349
28355
|
}
|
|
28350
28356
|
}
|
|
28351
28357
|
if (typeof window !== 'undefined') {
|