@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.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: '_hc_id' });
20435
+ const VISITOR_COOKIE_DEFAULTS = Object.freeze({ enabled: true, domain_scope: 'host', cookie_name: 'hdid' });
20436
20436
  const VISITOR_COOKIE_SECONDS = 30 * 86400;
20437
- const validVisitorId = (value) => typeof value === 'string' && /^[a-f0-9]{64}$/.test(value);
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 && typeof value.visitor_id === 'string' && /^[a-f0-9]{64}$/.test(value.visitor_id) &&
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
  }
@@ -28345,7 +28348,7 @@ class SparkVault {
28345
28348
  }
28346
28349
  /** Get the SDK version */
28347
28350
  static get version() {
28348
- return '15.18.0';
28351
+ return '16.0.0';
28349
28352
  }
28350
28353
  }
28351
28354
  if (typeof window !== 'undefined') {