saasco-sdk 0.1.27 → 0.1.29

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 CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  ## 🔒 Privacy
16
16
 
17
- By default Saasco is privacy friendly, using no cookies and obscuring all activity behind Anonymous IDs. However if you want to power more complex user tracking you can identify users and then all events they do will be attributed to them in your CRM. This can assist with customer support but also for things like drip campaigns and other marketing activities.
17
+ By default Saasco is privacy friendly, obscuring all activity behind Anonymous IDs. However if you want to power more complex user tracking you can identify users and then all events they do will be attributed to them in your CRM. This can assist with customer support but also for things like drip campaigns and other marketing activities.
18
18
 
19
19
  ## Getting Started
20
20
 
package/index.cjs.js CHANGED
@@ -7,7 +7,7 @@ var uuid = require('@lukeed/uuid');
7
7
  var psl = require('psl');
8
8
  var zod = require('zod');
9
9
 
10
- var version = "0.1.27";
10
+ var version = "0.1.29";
11
11
 
12
12
  const timezones = {
13
13
  'Asia/Barnaul': 'RU',
@@ -583,7 +583,11 @@ function storeData(key, value, ttl) {
583
583
  deleteCookie(fullKey);
584
584
  return;
585
585
  }
586
- setCookie(fullKey, JSON.stringify(value), ttl);
586
+ const item = {
587
+ value,
588
+ expiry: new Date().getTime() + ttl
589
+ };
590
+ setCookie(fullKey, JSON.stringify(item), ttl);
587
591
  }
588
592
  function retrieveData(key) {
589
593
  if (isServer) {
@@ -601,7 +605,12 @@ function retrieveData(key) {
601
605
  return null;
602
606
  }
603
607
  try {
604
- return JSON.parse(itemStr);
608
+ const item = JSON.parse(itemStr);
609
+ if (Date.now() > item.expiry) {
610
+ deleteCookie(fullKey);
611
+ return null;
612
+ }
613
+ return item.value;
605
614
  } catch (error) {
606
615
  // If JSON parsing fails, remove the corrupted cookie
607
616
  deleteCookie(fullKey);
package/index.esm.js CHANGED
@@ -3,7 +3,7 @@ import { v4 } from '@lukeed/uuid';
3
3
  import { isValid, parse } from 'psl';
4
4
  import { z } from 'zod';
5
5
 
6
- var version = "0.1.27";
6
+ var version = "0.1.29";
7
7
 
8
8
  const timezones = {
9
9
  'Asia/Barnaul': 'RU',
@@ -579,7 +579,11 @@ function storeData(key, value, ttl) {
579
579
  deleteCookie(fullKey);
580
580
  return;
581
581
  }
582
- setCookie(fullKey, JSON.stringify(value), ttl);
582
+ const item = {
583
+ value,
584
+ expiry: new Date().getTime() + ttl
585
+ };
586
+ setCookie(fullKey, JSON.stringify(item), ttl);
583
587
  }
584
588
  function retrieveData(key) {
585
589
  if (isServer) {
@@ -597,7 +601,12 @@ function retrieveData(key) {
597
601
  return null;
598
602
  }
599
603
  try {
600
- return JSON.parse(itemStr);
604
+ const item = JSON.parse(itemStr);
605
+ if (Date.now() > item.expiry) {
606
+ deleteCookie(fullKey);
607
+ return null;
608
+ }
609
+ return item.value;
601
610
  } catch (error) {
602
611
  // If JSON parsing fails, remove the corrupted cookie
603
612
  deleteCookie(fullKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasco-sdk",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0",
6
6
  "@lukeed/uuid": "^2.0.1",