@sparkvault/sdk-js 15.18.0 → 16.0.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/dist/index.cjs +8 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +8 -5
- package/dist/index.mjs.map +1 -1
- 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
|
}
|
|
@@ -28349,7 +28352,7 @@ class SparkVault {
|
|
|
28349
28352
|
}
|
|
28350
28353
|
/** Get the SDK version */
|
|
28351
28354
|
static get version() {
|
|
28352
|
-
return '
|
|
28355
|
+
return '16.0.0';
|
|
28353
28356
|
}
|
|
28354
28357
|
}
|
|
28355
28358
|
if (typeof window !== 'undefined') {
|