@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.cjs
CHANGED
|
@@ -20436,9 +20436,12 @@ function getDomain(url, options) {
|
|
|
20436
20436
|
|
|
20437
20437
|
/** Anonymous correlation only: these identifiers never authorize customer access. */
|
|
20438
20438
|
|
|
20439
|
-
const VISITOR_COOKIE_DEFAULTS = Object.freeze({ enabled: true, domain_scope: 'host', cookie_name: '
|
|
20439
|
+
const VISITOR_COOKIE_DEFAULTS = Object.freeze({ enabled: true, domain_scope: 'host', cookie_name: 'hdid' });
|
|
20440
20440
|
const VISITOR_COOKIE_SECONDS = 30 * 86400;
|
|
20441
|
-
|
|
20441
|
+
// Preserve opaque cookie values (UUIDs, prefixed IDs, hex, base64, etc.) without interpreting them.
|
|
20442
|
+
// RFC 6265 cookie-octets exclude separators and control characters; bound storage and request sizes.
|
|
20443
|
+
const VISITOR_ID_MAX_LENGTH = 256;
|
|
20444
|
+
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);
|
|
20442
20445
|
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);
|
|
20443
20446
|
|
|
20444
20447
|
/** Never share a platform host's cookie between unrelated desks. PSL handles co.uk and private suffixes. */
|
|
@@ -20766,7 +20769,7 @@ function recommendKnowledgeBase(prepared, issue, { limit = 5, categoryId = null
|
|
|
20766
20769
|
].map(value => typeof value === 'function' ? value.toString() : value).join('\n') + '\nexport { prepareSearchIndex, searchKnowledgeBase, recommendKnowledgeBase };\n';
|
|
20767
20770
|
|
|
20768
20771
|
const currentVisitor = (value) => value !== null && typeof value === 'object' &&
|
|
20769
|
-
'visitor_id' in value &&
|
|
20772
|
+
'visitor_id' in value && validVisitorId(value.visitor_id) &&
|
|
20770
20773
|
'expires_at' in value && typeof value.expires_at === 'number' && Number.isSafeInteger(value.expires_at) &&
|
|
20771
20774
|
value.expires_at * 1000 > Date.now() + 60000 && value.expires_at * 1000 <= Date.now() + 31 * 86400000;
|
|
20772
20775
|
const invalid = () => new SparkVaultError('The help center returned an invalid answer. Try again.', 'KB_INVALID_RESPONSE');
|
|
@@ -20991,7 +20994,7 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
20991
20994
|
if (!currentVisitor(value))
|
|
20992
20995
|
throw invalid();
|
|
20993
20996
|
this.visitorSession = { key, value };
|
|
20994
|
-
if (settings.enabled && validVisitorCookieName(settings.cookie_name) && !cookieEndpoint) {
|
|
20997
|
+
if (settings.enabled && !candidate && validVisitorCookieName(settings.cookie_name) && !cookieEndpoint) {
|
|
20995
20998
|
try {
|
|
20996
20999
|
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}` : ''}`;
|
|
20997
21000
|
}
|
|
@@ -22078,6 +22081,7 @@ class SupportView {
|
|
|
22078
22081
|
this.live.setAttribute('role', 'status');
|
|
22079
22082
|
this.live.setAttribute('aria-live', 'polite');
|
|
22080
22083
|
const toolbar = element('header', 'svhs-toolbar');
|
|
22084
|
+
this.toolbar = toolbar;
|
|
22081
22085
|
this.back = button('svhs-back', 'Back', () => this.actions.onBack());
|
|
22082
22086
|
this.back.prepend(icon('back'));
|
|
22083
22087
|
this.close = button('svhs-icon-button', '', () => this.actions.onClose());
|
|
@@ -22097,14 +22101,17 @@ class SupportView {
|
|
|
22097
22101
|
this.identityNotice.append(element('p', 'svhs-status', 'Sign-in is open in another window.'), button('svhs-text-button', 'Cancel sign-in', () => this.actions.onCancelIdentity?.()));
|
|
22098
22102
|
this.identityNotice.hidden = true;
|
|
22099
22103
|
this.panel.append(this.identityNotice);
|
|
22100
|
-
const intro = this.screen('issue', 'How can we help?');
|
|
22104
|
+
const intro = this.screen('issue', 'How can we help?', target ? 'h1' : 'h2');
|
|
22101
22105
|
// The heading asks the question once, so it names the field too.
|
|
22102
22106
|
const issueHeading = this.headings.get('issue');
|
|
22103
22107
|
issueHeading.id = `${this.prefix}-issue-title`;
|
|
22108
|
+
const helper = element('p', 'svhs-copy', 'What is your question? Tell us what is going on.');
|
|
22109
|
+
helper.id = `${this.prefix}-issue-help`;
|
|
22104
22110
|
this.issue.id = `${this.prefix}-issue`;
|
|
22105
22111
|
this.issue.setAttribute('aria-labelledby', issueHeading.id);
|
|
22112
|
+
this.issue.setAttribute('aria-describedby', helper.id);
|
|
22106
22113
|
this.issue.name = 'support_issue';
|
|
22107
|
-
this.issue.placeholder = 'Describe
|
|
22114
|
+
this.issue.placeholder = 'Describe your question or issue';
|
|
22108
22115
|
this.issue.autocomplete = 'off';
|
|
22109
22116
|
this.issue.setAttribute('aria-describedby', `${this.prefix}-issue-error`);
|
|
22110
22117
|
this.issueError.id = `${this.prefix}-issue-error`;
|
|
@@ -22122,7 +22129,7 @@ class SupportView {
|
|
|
22122
22129
|
this.search();
|
|
22123
22130
|
}
|
|
22124
22131
|
});
|
|
22125
|
-
intro.append(this.issue, this.issueError);
|
|
22132
|
+
intro.append(helper, this.issue, this.issueError);
|
|
22126
22133
|
this.find = button('svhs-primary', 'Continue', () => this.search());
|
|
22127
22134
|
this.footer('issue', 'svhs-start-bottom').append(this.find);
|
|
22128
22135
|
const results = this.screen('results', 'These articles may help');
|
|
@@ -22135,16 +22142,14 @@ class SupportView {
|
|
|
22135
22142
|
results.prepend(queryLine);
|
|
22136
22143
|
results.append(this.resultCopy, this.resultList, this.resultStatus, this.resultError);
|
|
22137
22144
|
this.resultError.setAttribute('role', 'alert');
|
|
22138
|
-
this.contactResults = button('svhs-secondary svhs-full', '
|
|
22145
|
+
this.contactResults = button('svhs-secondary svhs-full', 'Still need help? Open a ticket', () => {
|
|
22139
22146
|
if (this.state?.busy)
|
|
22140
22147
|
return;
|
|
22141
22148
|
this.actions.onContact(['locked', 'unavailable'].includes(this.state?.kbState || '') ? 'direct' : this.state?.results?.length ? 'none_match' : 'no_results');
|
|
22142
22149
|
});
|
|
22143
22150
|
this.resultsFooter = this.footer('results');
|
|
22144
22151
|
this.resultsFooter.classList.add('svhs-results-bottom');
|
|
22145
|
-
|
|
22146
|
-
escalation.append(element('p', 'svhs-footer-title', 'Still need help?'), element('p', 'svhs-footer-copy', 'Send your question to our support team.'));
|
|
22147
|
-
this.resultsFooter.append(escalation, this.contactResults);
|
|
22152
|
+
this.resultsFooter.append(this.contactResults);
|
|
22148
22153
|
const article = this.screen('article');
|
|
22149
22154
|
article.classList.add('svhs-article-scroll');
|
|
22150
22155
|
this.articleTitle.tabIndex = -1;
|
|
@@ -22254,6 +22259,7 @@ class SupportView {
|
|
|
22254
22259
|
this.back.disabled = Boolean(next.navigationLocked || next.identityPending);
|
|
22255
22260
|
this.back.lastChild.textContent = next.stage === 'article' ? 'All answers' : next.stage === 'feedback' ? 'Keep reading' : 'Back';
|
|
22256
22261
|
this.deskName.hidden = next.stage === 'article';
|
|
22262
|
+
this.toolbar.hidden = Boolean(this.target && next.stage === 'issue');
|
|
22257
22263
|
const heading = this.headings.get(next.stage);
|
|
22258
22264
|
if (heading && !heading.id)
|
|
22259
22265
|
heading.id = `${this.prefix}-${next.stage}-title`;
|
|
@@ -22268,7 +22274,7 @@ class SupportView {
|
|
|
22268
22274
|
this.find.replaceChildren();
|
|
22269
22275
|
if (next.busy)
|
|
22270
22276
|
this.find.append(element('span', 'svhs-spinner'));
|
|
22271
|
-
this.find.append(document.createTextNode(next.busy ? 'Continuing
|
|
22277
|
+
this.find.append(document.createTextNode(next.busy ? 'Continuing...' : 'Continue'));
|
|
22272
22278
|
this.issueError.textContent = next.stage === 'issue' ? next.error || '' : '';
|
|
22273
22279
|
this.issueError.hidden = !this.issueError.textContent;
|
|
22274
22280
|
this.query.textContent = next.issue;
|
|
@@ -22429,12 +22435,12 @@ class SupportView {
|
|
|
22429
22435
|
this.hide();
|
|
22430
22436
|
this.panel.remove();
|
|
22431
22437
|
}
|
|
22432
|
-
screen(stage, title) {
|
|
22438
|
+
screen(stage, title, tag = 'h2') {
|
|
22433
22439
|
const screen = element('section', 'svhs-screen');
|
|
22434
22440
|
screen.hidden = true;
|
|
22435
22441
|
const body = element('div', 'svhs-scroll');
|
|
22436
22442
|
if (title) {
|
|
22437
|
-
const heading = element(
|
|
22443
|
+
const heading = element(tag, 'svhs-heading', title);
|
|
22438
22444
|
heading.tabIndex = -1;
|
|
22439
22445
|
body.append(heading);
|
|
22440
22446
|
this.headings.set(stage, heading);
|
|
@@ -28349,7 +28355,7 @@ class SparkVault {
|
|
|
28349
28355
|
}
|
|
28350
28356
|
/** Get the SDK version */
|
|
28351
28357
|
static get version() {
|
|
28352
|
-
return '
|
|
28358
|
+
return '16.0.1';
|
|
28353
28359
|
}
|
|
28354
28360
|
}
|
|
28355
28361
|
if (typeof window !== 'undefined') {
|