saasco-sdk 0.1.38 → 0.1.40

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/index.cjs.js CHANGED
@@ -4,10 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
6
  var psl = require('psl');
7
+ var require$$0 = require('crypto');
8
+ var require$$1 = require('buffer');
7
9
  var uuid$1 = require('@lukeed/uuid');
8
10
  var zod = require('zod');
9
11
 
10
- var version = "0.1.38";
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
15
+ var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
16
+
17
+ var version = "0.1.40";
11
18
 
12
19
  const timezones = {
13
20
  'Asia/Barnaul': 'RU',
@@ -554,6 +561,533 @@ function getBrowserContext() {
554
561
  };
555
562
  }
556
563
 
564
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
565
+
566
+ var sha256 = {exports: {}};
567
+
568
+ /**
569
+ * [js-sha256]{@link https://github.com/emn178/js-sha256}
570
+ *
571
+ * @version 0.11.1
572
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
573
+ * @copyright Chen, Yi-Cyuan 2014-2025
574
+ * @license MIT
575
+ */
576
+
577
+ (function (module) {
578
+ /*jslint bitwise: true */
579
+ (function () {
580
+
581
+ var ERROR = 'input is invalid type';
582
+ var WINDOW = typeof window === 'object';
583
+ var root = WINDOW ? window : {};
584
+ if (root.JS_SHA256_NO_WINDOW) {
585
+ WINDOW = false;
586
+ }
587
+ var WEB_WORKER = !WINDOW && typeof self === 'object';
588
+ var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node && process.type != 'renderer';
589
+ if (NODE_JS) {
590
+ root = commonjsGlobal;
591
+ } else if (WEB_WORKER) {
592
+ root = self;
593
+ }
594
+ var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && 'object' === 'object' && module.exports;
595
+ var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
596
+ var HEX_CHARS = '0123456789abcdef'.split('');
597
+ var EXTRA = [-2147483648, 8388608, 32768, 128];
598
+ var SHIFT = [24, 16, 8, 0];
599
+ var K = [
600
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
601
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
602
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
603
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
604
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
605
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
606
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
607
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
608
+ ];
609
+ var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];
610
+
611
+ var blocks = [];
612
+
613
+ if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) {
614
+ Array.isArray = function (obj) {
615
+ return Object.prototype.toString.call(obj) === '[object Array]';
616
+ };
617
+ }
618
+
619
+ if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
620
+ ArrayBuffer.isView = function (obj) {
621
+ return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
622
+ };
623
+ }
624
+
625
+ var createOutputMethod = function (outputType, is224) {
626
+ return function (message) {
627
+ return new Sha256(is224, true).update(message)[outputType]();
628
+ };
629
+ };
630
+
631
+ var createMethod = function (is224) {
632
+ var method = createOutputMethod('hex', is224);
633
+ if (NODE_JS) {
634
+ method = nodeWrap(method, is224);
635
+ }
636
+ method.create = function () {
637
+ return new Sha256(is224);
638
+ };
639
+ method.update = function (message) {
640
+ return method.create().update(message);
641
+ };
642
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
643
+ var type = OUTPUT_TYPES[i];
644
+ method[type] = createOutputMethod(type, is224);
645
+ }
646
+ return method;
647
+ };
648
+
649
+ var nodeWrap = function (method, is224) {
650
+ var crypto = require$$0__default["default"];
651
+ var Buffer = require$$1__default["default"].Buffer;
652
+ var algorithm = is224 ? 'sha224' : 'sha256';
653
+ var bufferFrom;
654
+ if (Buffer.from && !root.JS_SHA256_NO_BUFFER_FROM) {
655
+ bufferFrom = Buffer.from;
656
+ } else {
657
+ bufferFrom = function (message) {
658
+ return new Buffer(message);
659
+ };
660
+ }
661
+ var nodeMethod = function (message) {
662
+ if (typeof message === 'string') {
663
+ return crypto.createHash(algorithm).update(message, 'utf8').digest('hex');
664
+ } else {
665
+ if (message === null || message === undefined) {
666
+ throw new Error(ERROR);
667
+ } else if (message.constructor === ArrayBuffer) {
668
+ message = new Uint8Array(message);
669
+ }
670
+ }
671
+ if (Array.isArray(message) || ArrayBuffer.isView(message) ||
672
+ message.constructor === Buffer) {
673
+ return crypto.createHash(algorithm).update(bufferFrom(message)).digest('hex');
674
+ } else {
675
+ return method(message);
676
+ }
677
+ };
678
+ return nodeMethod;
679
+ };
680
+
681
+ var createHmacOutputMethod = function (outputType, is224) {
682
+ return function (key, message) {
683
+ return new HmacSha256(key, is224, true).update(message)[outputType]();
684
+ };
685
+ };
686
+
687
+ var createHmacMethod = function (is224) {
688
+ var method = createHmacOutputMethod('hex', is224);
689
+ method.create = function (key) {
690
+ return new HmacSha256(key, is224);
691
+ };
692
+ method.update = function (key, message) {
693
+ return method.create(key).update(message);
694
+ };
695
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
696
+ var type = OUTPUT_TYPES[i];
697
+ method[type] = createHmacOutputMethod(type, is224);
698
+ }
699
+ return method;
700
+ };
701
+
702
+ function Sha256(is224, sharedMemory) {
703
+ if (sharedMemory) {
704
+ blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
705
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
706
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
707
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
708
+ this.blocks = blocks;
709
+ } else {
710
+ this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
711
+ }
712
+
713
+ if (is224) {
714
+ this.h0 = 0xc1059ed8;
715
+ this.h1 = 0x367cd507;
716
+ this.h2 = 0x3070dd17;
717
+ this.h3 = 0xf70e5939;
718
+ this.h4 = 0xffc00b31;
719
+ this.h5 = 0x68581511;
720
+ this.h6 = 0x64f98fa7;
721
+ this.h7 = 0xbefa4fa4;
722
+ } else { // 256
723
+ this.h0 = 0x6a09e667;
724
+ this.h1 = 0xbb67ae85;
725
+ this.h2 = 0x3c6ef372;
726
+ this.h3 = 0xa54ff53a;
727
+ this.h4 = 0x510e527f;
728
+ this.h5 = 0x9b05688c;
729
+ this.h6 = 0x1f83d9ab;
730
+ this.h7 = 0x5be0cd19;
731
+ }
732
+
733
+ this.block = this.start = this.bytes = this.hBytes = 0;
734
+ this.finalized = this.hashed = false;
735
+ this.first = true;
736
+ this.is224 = is224;
737
+ }
738
+
739
+ Sha256.prototype.update = function (message) {
740
+ if (this.finalized) {
741
+ return;
742
+ }
743
+ var notString, type = typeof message;
744
+ if (type !== 'string') {
745
+ if (type === 'object') {
746
+ if (message === null) {
747
+ throw new Error(ERROR);
748
+ } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
749
+ message = new Uint8Array(message);
750
+ } else if (!Array.isArray(message)) {
751
+ if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
752
+ throw new Error(ERROR);
753
+ }
754
+ }
755
+ } else {
756
+ throw new Error(ERROR);
757
+ }
758
+ notString = true;
759
+ }
760
+ var code, index = 0, i, length = message.length, blocks = this.blocks;
761
+ while (index < length) {
762
+ if (this.hashed) {
763
+ this.hashed = false;
764
+ blocks[0] = this.block;
765
+ this.block = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
766
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
767
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
768
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
769
+ }
770
+
771
+ if (notString) {
772
+ for (i = this.start; index < length && i < 64; ++index) {
773
+ blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3];
774
+ }
775
+ } else {
776
+ for (i = this.start; index < length && i < 64; ++index) {
777
+ code = message.charCodeAt(index);
778
+ if (code < 0x80) {
779
+ blocks[i >>> 2] |= code << SHIFT[i++ & 3];
780
+ } else if (code < 0x800) {
781
+ blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3];
782
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
783
+ } else if (code < 0xd800 || code >= 0xe000) {
784
+ blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];
785
+ blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
786
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
787
+ } else {
788
+ code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
789
+ blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];
790
+ blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];
791
+ blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
792
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
793
+ }
794
+ }
795
+ }
796
+
797
+ this.lastByteIndex = i;
798
+ this.bytes += i - this.start;
799
+ if (i >= 64) {
800
+ this.block = blocks[16];
801
+ this.start = i - 64;
802
+ this.hash();
803
+ this.hashed = true;
804
+ } else {
805
+ this.start = i;
806
+ }
807
+ }
808
+ if (this.bytes > 4294967295) {
809
+ this.hBytes += this.bytes / 4294967296 << 0;
810
+ this.bytes = this.bytes % 4294967296;
811
+ }
812
+ return this;
813
+ };
814
+
815
+ Sha256.prototype.finalize = function () {
816
+ if (this.finalized) {
817
+ return;
818
+ }
819
+ this.finalized = true;
820
+ var blocks = this.blocks, i = this.lastByteIndex;
821
+ blocks[16] = this.block;
822
+ blocks[i >>> 2] |= EXTRA[i & 3];
823
+ this.block = blocks[16];
824
+ if (i >= 56) {
825
+ if (!this.hashed) {
826
+ this.hash();
827
+ }
828
+ blocks[0] = this.block;
829
+ blocks[16] = blocks[1] = blocks[2] = blocks[3] =
830
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
831
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
832
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
833
+ }
834
+ blocks[14] = this.hBytes << 3 | this.bytes >>> 29;
835
+ blocks[15] = this.bytes << 3;
836
+ this.hash();
837
+ };
838
+
839
+ Sha256.prototype.hash = function () {
840
+ var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6,
841
+ h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc;
842
+
843
+ for (j = 16; j < 64; ++j) {
844
+ // rightrotate
845
+ t1 = blocks[j - 15];
846
+ s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3);
847
+ t1 = blocks[j - 2];
848
+ s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10);
849
+ blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0;
850
+ }
851
+
852
+ bc = b & c;
853
+ for (j = 0; j < 64; j += 4) {
854
+ if (this.first) {
855
+ if (this.is224) {
856
+ ab = 300032;
857
+ t1 = blocks[0] - 1413257819;
858
+ h = t1 - 150054599 << 0;
859
+ d = t1 + 24177077 << 0;
860
+ } else {
861
+ ab = 704751109;
862
+ t1 = blocks[0] - 210244248;
863
+ h = t1 - 1521486534 << 0;
864
+ d = t1 + 143694565 << 0;
865
+ }
866
+ this.first = false;
867
+ } else {
868
+ s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
869
+ s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
870
+ ab = a & b;
871
+ maj = ab ^ (a & c) ^ bc;
872
+ ch = (e & f) ^ (~e & g);
873
+ t1 = h + s1 + ch + K[j] + blocks[j];
874
+ t2 = s0 + maj;
875
+ h = d + t1 << 0;
876
+ d = t1 + t2 << 0;
877
+ }
878
+ s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10));
879
+ s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7));
880
+ da = d & a;
881
+ maj = da ^ (d & b) ^ ab;
882
+ ch = (h & e) ^ (~h & f);
883
+ t1 = g + s1 + ch + K[j + 1] + blocks[j + 1];
884
+ t2 = s0 + maj;
885
+ g = c + t1 << 0;
886
+ c = t1 + t2 << 0;
887
+ s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10));
888
+ s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7));
889
+ cd = c & d;
890
+ maj = cd ^ (c & a) ^ da;
891
+ ch = (g & h) ^ (~g & e);
892
+ t1 = f + s1 + ch + K[j + 2] + blocks[j + 2];
893
+ t2 = s0 + maj;
894
+ f = b + t1 << 0;
895
+ b = t1 + t2 << 0;
896
+ s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10));
897
+ s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7));
898
+ bc = b & c;
899
+ maj = bc ^ (b & d) ^ cd;
900
+ ch = (f & g) ^ (~f & h);
901
+ t1 = e + s1 + ch + K[j + 3] + blocks[j + 3];
902
+ t2 = s0 + maj;
903
+ e = a + t1 << 0;
904
+ a = t1 + t2 << 0;
905
+ this.chromeBugWorkAround = true;
906
+ }
907
+
908
+ this.h0 = this.h0 + a << 0;
909
+ this.h1 = this.h1 + b << 0;
910
+ this.h2 = this.h2 + c << 0;
911
+ this.h3 = this.h3 + d << 0;
912
+ this.h4 = this.h4 + e << 0;
913
+ this.h5 = this.h5 + f << 0;
914
+ this.h6 = this.h6 + g << 0;
915
+ this.h7 = this.h7 + h << 0;
916
+ };
917
+
918
+ Sha256.prototype.hex = function () {
919
+ this.finalize();
920
+
921
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
922
+ h6 = this.h6, h7 = this.h7;
923
+
924
+ var hex = HEX_CHARS[(h0 >>> 28) & 0x0F] + HEX_CHARS[(h0 >>> 24) & 0x0F] +
925
+ HEX_CHARS[(h0 >>> 20) & 0x0F] + HEX_CHARS[(h0 >>> 16) & 0x0F] +
926
+ HEX_CHARS[(h0 >>> 12) & 0x0F] + HEX_CHARS[(h0 >>> 8) & 0x0F] +
927
+ HEX_CHARS[(h0 >>> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
928
+ HEX_CHARS[(h1 >>> 28) & 0x0F] + HEX_CHARS[(h1 >>> 24) & 0x0F] +
929
+ HEX_CHARS[(h1 >>> 20) & 0x0F] + HEX_CHARS[(h1 >>> 16) & 0x0F] +
930
+ HEX_CHARS[(h1 >>> 12) & 0x0F] + HEX_CHARS[(h1 >>> 8) & 0x0F] +
931
+ HEX_CHARS[(h1 >>> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
932
+ HEX_CHARS[(h2 >>> 28) & 0x0F] + HEX_CHARS[(h2 >>> 24) & 0x0F] +
933
+ HEX_CHARS[(h2 >>> 20) & 0x0F] + HEX_CHARS[(h2 >>> 16) & 0x0F] +
934
+ HEX_CHARS[(h2 >>> 12) & 0x0F] + HEX_CHARS[(h2 >>> 8) & 0x0F] +
935
+ HEX_CHARS[(h2 >>> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
936
+ HEX_CHARS[(h3 >>> 28) & 0x0F] + HEX_CHARS[(h3 >>> 24) & 0x0F] +
937
+ HEX_CHARS[(h3 >>> 20) & 0x0F] + HEX_CHARS[(h3 >>> 16) & 0x0F] +
938
+ HEX_CHARS[(h3 >>> 12) & 0x0F] + HEX_CHARS[(h3 >>> 8) & 0x0F] +
939
+ HEX_CHARS[(h3 >>> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
940
+ HEX_CHARS[(h4 >>> 28) & 0x0F] + HEX_CHARS[(h4 >>> 24) & 0x0F] +
941
+ HEX_CHARS[(h4 >>> 20) & 0x0F] + HEX_CHARS[(h4 >>> 16) & 0x0F] +
942
+ HEX_CHARS[(h4 >>> 12) & 0x0F] + HEX_CHARS[(h4 >>> 8) & 0x0F] +
943
+ HEX_CHARS[(h4 >>> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] +
944
+ HEX_CHARS[(h5 >>> 28) & 0x0F] + HEX_CHARS[(h5 >>> 24) & 0x0F] +
945
+ HEX_CHARS[(h5 >>> 20) & 0x0F] + HEX_CHARS[(h5 >>> 16) & 0x0F] +
946
+ HEX_CHARS[(h5 >>> 12) & 0x0F] + HEX_CHARS[(h5 >>> 8) & 0x0F] +
947
+ HEX_CHARS[(h5 >>> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] +
948
+ HEX_CHARS[(h6 >>> 28) & 0x0F] + HEX_CHARS[(h6 >>> 24) & 0x0F] +
949
+ HEX_CHARS[(h6 >>> 20) & 0x0F] + HEX_CHARS[(h6 >>> 16) & 0x0F] +
950
+ HEX_CHARS[(h6 >>> 12) & 0x0F] + HEX_CHARS[(h6 >>> 8) & 0x0F] +
951
+ HEX_CHARS[(h6 >>> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F];
952
+ if (!this.is224) {
953
+ hex += HEX_CHARS[(h7 >>> 28) & 0x0F] + HEX_CHARS[(h7 >>> 24) & 0x0F] +
954
+ HEX_CHARS[(h7 >>> 20) & 0x0F] + HEX_CHARS[(h7 >>> 16) & 0x0F] +
955
+ HEX_CHARS[(h7 >>> 12) & 0x0F] + HEX_CHARS[(h7 >>> 8) & 0x0F] +
956
+ HEX_CHARS[(h7 >>> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F];
957
+ }
958
+ return hex;
959
+ };
960
+
961
+ Sha256.prototype.toString = Sha256.prototype.hex;
962
+
963
+ Sha256.prototype.digest = function () {
964
+ this.finalize();
965
+
966
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
967
+ h6 = this.h6, h7 = this.h7;
968
+
969
+ var arr = [
970
+ (h0 >>> 24) & 0xFF, (h0 >>> 16) & 0xFF, (h0 >>> 8) & 0xFF, h0 & 0xFF,
971
+ (h1 >>> 24) & 0xFF, (h1 >>> 16) & 0xFF, (h1 >>> 8) & 0xFF, h1 & 0xFF,
972
+ (h2 >>> 24) & 0xFF, (h2 >>> 16) & 0xFF, (h2 >>> 8) & 0xFF, h2 & 0xFF,
973
+ (h3 >>> 24) & 0xFF, (h3 >>> 16) & 0xFF, (h3 >>> 8) & 0xFF, h3 & 0xFF,
974
+ (h4 >>> 24) & 0xFF, (h4 >>> 16) & 0xFF, (h4 >>> 8) & 0xFF, h4 & 0xFF,
975
+ (h5 >>> 24) & 0xFF, (h5 >>> 16) & 0xFF, (h5 >>> 8) & 0xFF, h5 & 0xFF,
976
+ (h6 >>> 24) & 0xFF, (h6 >>> 16) & 0xFF, (h6 >>> 8) & 0xFF, h6 & 0xFF
977
+ ];
978
+ if (!this.is224) {
979
+ arr.push((h7 >>> 24) & 0xFF, (h7 >>> 16) & 0xFF, (h7 >>> 8) & 0xFF, h7 & 0xFF);
980
+ }
981
+ return arr;
982
+ };
983
+
984
+ Sha256.prototype.array = Sha256.prototype.digest;
985
+
986
+ Sha256.prototype.arrayBuffer = function () {
987
+ this.finalize();
988
+
989
+ var buffer = new ArrayBuffer(this.is224 ? 28 : 32);
990
+ var dataView = new DataView(buffer);
991
+ dataView.setUint32(0, this.h0);
992
+ dataView.setUint32(4, this.h1);
993
+ dataView.setUint32(8, this.h2);
994
+ dataView.setUint32(12, this.h3);
995
+ dataView.setUint32(16, this.h4);
996
+ dataView.setUint32(20, this.h5);
997
+ dataView.setUint32(24, this.h6);
998
+ if (!this.is224) {
999
+ dataView.setUint32(28, this.h7);
1000
+ }
1001
+ return buffer;
1002
+ };
1003
+
1004
+ function HmacSha256(key, is224, sharedMemory) {
1005
+ var i, type = typeof key;
1006
+ if (type === 'string') {
1007
+ var bytes = [], length = key.length, index = 0, code;
1008
+ for (i = 0; i < length; ++i) {
1009
+ code = key.charCodeAt(i);
1010
+ if (code < 0x80) {
1011
+ bytes[index++] = code;
1012
+ } else if (code < 0x800) {
1013
+ bytes[index++] = (0xc0 | (code >>> 6));
1014
+ bytes[index++] = (0x80 | (code & 0x3f));
1015
+ } else if (code < 0xd800 || code >= 0xe000) {
1016
+ bytes[index++] = (0xe0 | (code >>> 12));
1017
+ bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
1018
+ bytes[index++] = (0x80 | (code & 0x3f));
1019
+ } else {
1020
+ code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));
1021
+ bytes[index++] = (0xf0 | (code >>> 18));
1022
+ bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
1023
+ bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
1024
+ bytes[index++] = (0x80 | (code & 0x3f));
1025
+ }
1026
+ }
1027
+ key = bytes;
1028
+ } else {
1029
+ if (type === 'object') {
1030
+ if (key === null) {
1031
+ throw new Error(ERROR);
1032
+ } else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) {
1033
+ key = new Uint8Array(key);
1034
+ } else if (!Array.isArray(key)) {
1035
+ if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) {
1036
+ throw new Error(ERROR);
1037
+ }
1038
+ }
1039
+ } else {
1040
+ throw new Error(ERROR);
1041
+ }
1042
+ }
1043
+
1044
+ if (key.length > 64) {
1045
+ key = (new Sha256(is224, true)).update(key).array();
1046
+ }
1047
+
1048
+ var oKeyPad = [], iKeyPad = [];
1049
+ for (i = 0; i < 64; ++i) {
1050
+ var b = key[i] || 0;
1051
+ oKeyPad[i] = 0x5c ^ b;
1052
+ iKeyPad[i] = 0x36 ^ b;
1053
+ }
1054
+
1055
+ Sha256.call(this, is224, sharedMemory);
1056
+
1057
+ this.update(iKeyPad);
1058
+ this.oKeyPad = oKeyPad;
1059
+ this.inner = true;
1060
+ this.sharedMemory = sharedMemory;
1061
+ }
1062
+ HmacSha256.prototype = new Sha256();
1063
+
1064
+ HmacSha256.prototype.finalize = function () {
1065
+ Sha256.prototype.finalize.call(this);
1066
+ if (this.inner) {
1067
+ this.inner = false;
1068
+ var innerHash = this.array();
1069
+ Sha256.call(this, this.is224, this.sharedMemory);
1070
+ this.update(this.oKeyPad);
1071
+ this.update(innerHash);
1072
+ Sha256.prototype.finalize.call(this);
1073
+ }
1074
+ };
1075
+
1076
+ var exports = createMethod();
1077
+ exports.sha256 = exports;
1078
+ exports.sha224 = createMethod(true);
1079
+ exports.sha256.hmac = createHmacMethod();
1080
+ exports.sha224.hmac = createHmacMethod(true);
1081
+
1082
+ if (COMMON_JS) {
1083
+ module.exports = exports;
1084
+ } else {
1085
+ root.sha256 = exports.sha256;
1086
+ root.sha224 = exports.sha224;
1087
+ }
1088
+ })();
1089
+ }(sha256));
1090
+
557
1091
  const isBrowser$1 = typeof window !== 'undefined';
558
1092
  const isServer$1 = !isBrowser$1;
559
1093
  const standardFacebookEvents = ['AddPaymentInfo', 'AddToCart', 'AddToWishlist', 'CompleteRegistration', 'Contact', 'CustomizeProduct', 'Donate', 'FindLocation', 'InitiateCheckout', 'Lead', 'Purchase', 'Schedule', 'Search', 'StartTrial', 'SubmitApplication', 'Subscribe', 'ViewContent', 'PageView'];
@@ -626,20 +1160,20 @@ function createFacebookPixelIntegration(config) {
626
1160
  track: (eventName, properties, context) => {
627
1161
  if (!isPixelReady || !window.fbq) return;
628
1162
  const fbEventName = getFacebookEventName(eventName, config.eventMapping);
629
- // Standard Facebook events that support parameters
630
1163
  const eventsWithParams = ['Purchase', 'StartTrial', 'Subscribe'];
1164
+ const isStandardEvent = standardFacebookEvents.includes(fbEventName);
1165
+ const trackType = isStandardEvent ? 'track' : 'trackCustom';
631
1166
  if (eventsWithParams.includes(fbEventName) && properties) {
632
- // Extract standard Facebook parameters
633
1167
  const fbParams = {};
634
1168
  if (properties['value'] !== undefined) fbParams['value'] = properties['value'];
635
1169
  if (properties['currency'] !== undefined) fbParams['currency'] = properties['currency'];
636
1170
  if (properties['predicted_ltv'] !== undefined) fbParams['predicted_ltv'] = properties['predicted_ltv'];
637
- window.fbq('track', fbEventName, Object.assign(Object.assign({}, properties), fbParams));
1171
+ window.fbq(trackType, fbEventName, fbParams);
638
1172
  } else {
639
- window.fbq('track', fbEventName);
1173
+ window.fbq(trackType, fbEventName);
640
1174
  }
641
1175
  },
642
- identify: (userId, properties, context) => tslib.__awaiter(this, void 0, void 0, function* () {
1176
+ identify: (userId, properties, context) => {
643
1177
  try {
644
1178
  if (typeof window !== 'undefined' && window.fbq) {
645
1179
  const amValues = coerceMetaConversionsAmValues(Object.assign(Object.assign({}, properties || {}), userId ? {
@@ -647,7 +1181,7 @@ function createFacebookPixelIntegration(config) {
647
1181
  } : {}));
648
1182
  const am = {};
649
1183
  if (amValues.external_id) am['external_id'] = amValues.external_id;
650
- if (amValues.em) am['em'] = yield sha256Hex(amValues.em);
1184
+ if (amValues.em) am['em'] = sha256.exports.sha256(amValues.em);
651
1185
  if (amValues.fn) am['fn'] = amValues.fn;
652
1186
  if (amValues.ln) am['ln'] = amValues.ln;
653
1187
  if (amValues.ph) am['ph'] = amValues.ph;
@@ -664,7 +1198,7 @@ function createFacebookPixelIntegration(config) {
664
1198
  } catch (error) {
665
1199
  console.error('Error identifying user in Meta Pixel:', error);
666
1200
  }
667
- })
1201
+ }
668
1202
  };
669
1203
  }
670
1204
  function getFacebookEventName(eventName, eventMapping) {
@@ -673,32 +1207,6 @@ function getFacebookEventName(eventName, eventMapping) {
673
1207
  if (!eventMapping) return eventName;
674
1208
  return eventMapping[eventName] || eventName;
675
1209
  }
676
- // Legacy functions for backward compatibility (deprecated)
677
- function initializeFacebookPixel(pixelId) {
678
- var _a;
679
- console.warn('initializeFacebookPixel is deprecated. Use createFacebookPixelIntegration instead.');
680
- const integration = createFacebookPixelIntegration({
681
- pixelId
682
- });
683
- (_a = integration.init) === null || _a === void 0 ? void 0 : _a.call(integration);
684
- }
685
- function trackFacebookEvent(eventName, properties, eventMapping) {
686
- console.warn('trackFacebookEvent is deprecated. Use IntegrationManager instead.');
687
- if (isServer$1 || !window.fbq) return;
688
- const fbEventName = getFacebookEventName(eventName, eventMapping);
689
- const eventsWithParams = ['Purchase', 'StartTrial', 'Subscribe'];
690
- const isStandardEvent = standardFacebookEvents.includes(fbEventName);
691
- const trackType = isStandardEvent ? 'track' : 'trackCustom';
692
- if (eventsWithParams.includes(fbEventName) && properties) {
693
- const fbParams = {};
694
- if (properties['value'] !== undefined) fbParams['value'] = properties['value'];
695
- if (properties['currency'] !== undefined) fbParams['currency'] = properties['currency'];
696
- if (properties['predicted_ltv'] !== undefined) fbParams['predicted_ltv'] = properties['predicted_ltv'];
697
- window.fbq(trackType, fbEventName, fbParams);
698
- } else {
699
- window.fbq(trackType, fbEventName);
700
- }
701
- }
702
1210
  function coerceMetaConversionsAmValues(properties) {
703
1211
  const coerce = [{
704
1212
  key: 'em',
@@ -831,14 +1339,6 @@ function findFirstProperty(properties, keys) {
831
1339
  }
832
1340
  return null;
833
1341
  }
834
- const toHex = buf => [...new Uint8Array(buf)].map(b => b.toString(16).padStart(2, '0')).join('');
835
- function sha256Hex(input) {
836
- return tslib.__awaiter(this, void 0, void 0, function* () {
837
- const enc = new TextEncoder().encode(input);
838
- const digest = yield crypto.subtle.digest('SHA-256', enc);
839
- return toHex(digest);
840
- });
841
- }
842
1342
 
843
1343
  /* eslint-disable @typescript-eslint/no-explicit-any */
844
1344
  class AnalyticsLogger {
@@ -1633,7 +2133,5 @@ exports.Saasco = Saasco;
1633
2133
  exports.browserContextSchema = browserContextSchema;
1634
2134
  exports.createFacebookPixelIntegration = createFacebookPixelIntegration;
1635
2135
  exports.getBrowserContext = getBrowserContext;
1636
- exports.initializeFacebookPixel = initializeFacebookPixel;
1637
2136
  exports.standardFacebookEvents = standardFacebookEvents;
1638
2137
  exports.timezones = timezones;
1639
- exports.trackFacebookEvent = trackFacebookEvent;
package/index.esm.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import { __awaiter } from 'tslib';
2
2
  import { isValid, parse } from 'psl';
3
+ import require$$0 from 'crypto';
4
+ import require$$1 from 'buffer';
3
5
  import { v4 } from '@lukeed/uuid';
4
6
  import { z } from 'zod';
5
7
 
6
- var version = "0.1.38";
8
+ var version = "0.1.40";
7
9
 
8
10
  const timezones = {
9
11
  'Asia/Barnaul': 'RU',
@@ -550,6 +552,533 @@ function getBrowserContext() {
550
552
  };
551
553
  }
552
554
 
555
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
556
+
557
+ var sha256 = {exports: {}};
558
+
559
+ /**
560
+ * [js-sha256]{@link https://github.com/emn178/js-sha256}
561
+ *
562
+ * @version 0.11.1
563
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
564
+ * @copyright Chen, Yi-Cyuan 2014-2025
565
+ * @license MIT
566
+ */
567
+
568
+ (function (module) {
569
+ /*jslint bitwise: true */
570
+ (function () {
571
+
572
+ var ERROR = 'input is invalid type';
573
+ var WINDOW = typeof window === 'object';
574
+ var root = WINDOW ? window : {};
575
+ if (root.JS_SHA256_NO_WINDOW) {
576
+ WINDOW = false;
577
+ }
578
+ var WEB_WORKER = !WINDOW && typeof self === 'object';
579
+ var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node && process.type != 'renderer';
580
+ if (NODE_JS) {
581
+ root = commonjsGlobal;
582
+ } else if (WEB_WORKER) {
583
+ root = self;
584
+ }
585
+ var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && 'object' === 'object' && module.exports;
586
+ var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
587
+ var HEX_CHARS = '0123456789abcdef'.split('');
588
+ var EXTRA = [-2147483648, 8388608, 32768, 128];
589
+ var SHIFT = [24, 16, 8, 0];
590
+ var K = [
591
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
592
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
593
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
594
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
595
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
596
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
597
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
598
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
599
+ ];
600
+ var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];
601
+
602
+ var blocks = [];
603
+
604
+ if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) {
605
+ Array.isArray = function (obj) {
606
+ return Object.prototype.toString.call(obj) === '[object Array]';
607
+ };
608
+ }
609
+
610
+ if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
611
+ ArrayBuffer.isView = function (obj) {
612
+ return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
613
+ };
614
+ }
615
+
616
+ var createOutputMethod = function (outputType, is224) {
617
+ return function (message) {
618
+ return new Sha256(is224, true).update(message)[outputType]();
619
+ };
620
+ };
621
+
622
+ var createMethod = function (is224) {
623
+ var method = createOutputMethod('hex', is224);
624
+ if (NODE_JS) {
625
+ method = nodeWrap(method, is224);
626
+ }
627
+ method.create = function () {
628
+ return new Sha256(is224);
629
+ };
630
+ method.update = function (message) {
631
+ return method.create().update(message);
632
+ };
633
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
634
+ var type = OUTPUT_TYPES[i];
635
+ method[type] = createOutputMethod(type, is224);
636
+ }
637
+ return method;
638
+ };
639
+
640
+ var nodeWrap = function (method, is224) {
641
+ var crypto = require$$0;
642
+ var Buffer = require$$1.Buffer;
643
+ var algorithm = is224 ? 'sha224' : 'sha256';
644
+ var bufferFrom;
645
+ if (Buffer.from && !root.JS_SHA256_NO_BUFFER_FROM) {
646
+ bufferFrom = Buffer.from;
647
+ } else {
648
+ bufferFrom = function (message) {
649
+ return new Buffer(message);
650
+ };
651
+ }
652
+ var nodeMethod = function (message) {
653
+ if (typeof message === 'string') {
654
+ return crypto.createHash(algorithm).update(message, 'utf8').digest('hex');
655
+ } else {
656
+ if (message === null || message === undefined) {
657
+ throw new Error(ERROR);
658
+ } else if (message.constructor === ArrayBuffer) {
659
+ message = new Uint8Array(message);
660
+ }
661
+ }
662
+ if (Array.isArray(message) || ArrayBuffer.isView(message) ||
663
+ message.constructor === Buffer) {
664
+ return crypto.createHash(algorithm).update(bufferFrom(message)).digest('hex');
665
+ } else {
666
+ return method(message);
667
+ }
668
+ };
669
+ return nodeMethod;
670
+ };
671
+
672
+ var createHmacOutputMethod = function (outputType, is224) {
673
+ return function (key, message) {
674
+ return new HmacSha256(key, is224, true).update(message)[outputType]();
675
+ };
676
+ };
677
+
678
+ var createHmacMethod = function (is224) {
679
+ var method = createHmacOutputMethod('hex', is224);
680
+ method.create = function (key) {
681
+ return new HmacSha256(key, is224);
682
+ };
683
+ method.update = function (key, message) {
684
+ return method.create(key).update(message);
685
+ };
686
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
687
+ var type = OUTPUT_TYPES[i];
688
+ method[type] = createHmacOutputMethod(type, is224);
689
+ }
690
+ return method;
691
+ };
692
+
693
+ function Sha256(is224, sharedMemory) {
694
+ if (sharedMemory) {
695
+ blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
696
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
697
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
698
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
699
+ this.blocks = blocks;
700
+ } else {
701
+ this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
702
+ }
703
+
704
+ if (is224) {
705
+ this.h0 = 0xc1059ed8;
706
+ this.h1 = 0x367cd507;
707
+ this.h2 = 0x3070dd17;
708
+ this.h3 = 0xf70e5939;
709
+ this.h4 = 0xffc00b31;
710
+ this.h5 = 0x68581511;
711
+ this.h6 = 0x64f98fa7;
712
+ this.h7 = 0xbefa4fa4;
713
+ } else { // 256
714
+ this.h0 = 0x6a09e667;
715
+ this.h1 = 0xbb67ae85;
716
+ this.h2 = 0x3c6ef372;
717
+ this.h3 = 0xa54ff53a;
718
+ this.h4 = 0x510e527f;
719
+ this.h5 = 0x9b05688c;
720
+ this.h6 = 0x1f83d9ab;
721
+ this.h7 = 0x5be0cd19;
722
+ }
723
+
724
+ this.block = this.start = this.bytes = this.hBytes = 0;
725
+ this.finalized = this.hashed = false;
726
+ this.first = true;
727
+ this.is224 = is224;
728
+ }
729
+
730
+ Sha256.prototype.update = function (message) {
731
+ if (this.finalized) {
732
+ return;
733
+ }
734
+ var notString, type = typeof message;
735
+ if (type !== 'string') {
736
+ if (type === 'object') {
737
+ if (message === null) {
738
+ throw new Error(ERROR);
739
+ } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
740
+ message = new Uint8Array(message);
741
+ } else if (!Array.isArray(message)) {
742
+ if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
743
+ throw new Error(ERROR);
744
+ }
745
+ }
746
+ } else {
747
+ throw new Error(ERROR);
748
+ }
749
+ notString = true;
750
+ }
751
+ var code, index = 0, i, length = message.length, blocks = this.blocks;
752
+ while (index < length) {
753
+ if (this.hashed) {
754
+ this.hashed = false;
755
+ blocks[0] = this.block;
756
+ this.block = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
757
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
758
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
759
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
760
+ }
761
+
762
+ if (notString) {
763
+ for (i = this.start; index < length && i < 64; ++index) {
764
+ blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3];
765
+ }
766
+ } else {
767
+ for (i = this.start; index < length && i < 64; ++index) {
768
+ code = message.charCodeAt(index);
769
+ if (code < 0x80) {
770
+ blocks[i >>> 2] |= code << SHIFT[i++ & 3];
771
+ } else if (code < 0x800) {
772
+ blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3];
773
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
774
+ } else if (code < 0xd800 || code >= 0xe000) {
775
+ blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];
776
+ blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
777
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
778
+ } else {
779
+ code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
780
+ blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];
781
+ blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];
782
+ blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
783
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
784
+ }
785
+ }
786
+ }
787
+
788
+ this.lastByteIndex = i;
789
+ this.bytes += i - this.start;
790
+ if (i >= 64) {
791
+ this.block = blocks[16];
792
+ this.start = i - 64;
793
+ this.hash();
794
+ this.hashed = true;
795
+ } else {
796
+ this.start = i;
797
+ }
798
+ }
799
+ if (this.bytes > 4294967295) {
800
+ this.hBytes += this.bytes / 4294967296 << 0;
801
+ this.bytes = this.bytes % 4294967296;
802
+ }
803
+ return this;
804
+ };
805
+
806
+ Sha256.prototype.finalize = function () {
807
+ if (this.finalized) {
808
+ return;
809
+ }
810
+ this.finalized = true;
811
+ var blocks = this.blocks, i = this.lastByteIndex;
812
+ blocks[16] = this.block;
813
+ blocks[i >>> 2] |= EXTRA[i & 3];
814
+ this.block = blocks[16];
815
+ if (i >= 56) {
816
+ if (!this.hashed) {
817
+ this.hash();
818
+ }
819
+ blocks[0] = this.block;
820
+ blocks[16] = blocks[1] = blocks[2] = blocks[3] =
821
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
822
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
823
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
824
+ }
825
+ blocks[14] = this.hBytes << 3 | this.bytes >>> 29;
826
+ blocks[15] = this.bytes << 3;
827
+ this.hash();
828
+ };
829
+
830
+ Sha256.prototype.hash = function () {
831
+ var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6,
832
+ h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc;
833
+
834
+ for (j = 16; j < 64; ++j) {
835
+ // rightrotate
836
+ t1 = blocks[j - 15];
837
+ s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3);
838
+ t1 = blocks[j - 2];
839
+ s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10);
840
+ blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0;
841
+ }
842
+
843
+ bc = b & c;
844
+ for (j = 0; j < 64; j += 4) {
845
+ if (this.first) {
846
+ if (this.is224) {
847
+ ab = 300032;
848
+ t1 = blocks[0] - 1413257819;
849
+ h = t1 - 150054599 << 0;
850
+ d = t1 + 24177077 << 0;
851
+ } else {
852
+ ab = 704751109;
853
+ t1 = blocks[0] - 210244248;
854
+ h = t1 - 1521486534 << 0;
855
+ d = t1 + 143694565 << 0;
856
+ }
857
+ this.first = false;
858
+ } else {
859
+ s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
860
+ s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
861
+ ab = a & b;
862
+ maj = ab ^ (a & c) ^ bc;
863
+ ch = (e & f) ^ (~e & g);
864
+ t1 = h + s1 + ch + K[j] + blocks[j];
865
+ t2 = s0 + maj;
866
+ h = d + t1 << 0;
867
+ d = t1 + t2 << 0;
868
+ }
869
+ s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10));
870
+ s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7));
871
+ da = d & a;
872
+ maj = da ^ (d & b) ^ ab;
873
+ ch = (h & e) ^ (~h & f);
874
+ t1 = g + s1 + ch + K[j + 1] + blocks[j + 1];
875
+ t2 = s0 + maj;
876
+ g = c + t1 << 0;
877
+ c = t1 + t2 << 0;
878
+ s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10));
879
+ s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7));
880
+ cd = c & d;
881
+ maj = cd ^ (c & a) ^ da;
882
+ ch = (g & h) ^ (~g & e);
883
+ t1 = f + s1 + ch + K[j + 2] + blocks[j + 2];
884
+ t2 = s0 + maj;
885
+ f = b + t1 << 0;
886
+ b = t1 + t2 << 0;
887
+ s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10));
888
+ s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7));
889
+ bc = b & c;
890
+ maj = bc ^ (b & d) ^ cd;
891
+ ch = (f & g) ^ (~f & h);
892
+ t1 = e + s1 + ch + K[j + 3] + blocks[j + 3];
893
+ t2 = s0 + maj;
894
+ e = a + t1 << 0;
895
+ a = t1 + t2 << 0;
896
+ this.chromeBugWorkAround = true;
897
+ }
898
+
899
+ this.h0 = this.h0 + a << 0;
900
+ this.h1 = this.h1 + b << 0;
901
+ this.h2 = this.h2 + c << 0;
902
+ this.h3 = this.h3 + d << 0;
903
+ this.h4 = this.h4 + e << 0;
904
+ this.h5 = this.h5 + f << 0;
905
+ this.h6 = this.h6 + g << 0;
906
+ this.h7 = this.h7 + h << 0;
907
+ };
908
+
909
+ Sha256.prototype.hex = function () {
910
+ this.finalize();
911
+
912
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
913
+ h6 = this.h6, h7 = this.h7;
914
+
915
+ var hex = HEX_CHARS[(h0 >>> 28) & 0x0F] + HEX_CHARS[(h0 >>> 24) & 0x0F] +
916
+ HEX_CHARS[(h0 >>> 20) & 0x0F] + HEX_CHARS[(h0 >>> 16) & 0x0F] +
917
+ HEX_CHARS[(h0 >>> 12) & 0x0F] + HEX_CHARS[(h0 >>> 8) & 0x0F] +
918
+ HEX_CHARS[(h0 >>> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
919
+ HEX_CHARS[(h1 >>> 28) & 0x0F] + HEX_CHARS[(h1 >>> 24) & 0x0F] +
920
+ HEX_CHARS[(h1 >>> 20) & 0x0F] + HEX_CHARS[(h1 >>> 16) & 0x0F] +
921
+ HEX_CHARS[(h1 >>> 12) & 0x0F] + HEX_CHARS[(h1 >>> 8) & 0x0F] +
922
+ HEX_CHARS[(h1 >>> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
923
+ HEX_CHARS[(h2 >>> 28) & 0x0F] + HEX_CHARS[(h2 >>> 24) & 0x0F] +
924
+ HEX_CHARS[(h2 >>> 20) & 0x0F] + HEX_CHARS[(h2 >>> 16) & 0x0F] +
925
+ HEX_CHARS[(h2 >>> 12) & 0x0F] + HEX_CHARS[(h2 >>> 8) & 0x0F] +
926
+ HEX_CHARS[(h2 >>> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
927
+ HEX_CHARS[(h3 >>> 28) & 0x0F] + HEX_CHARS[(h3 >>> 24) & 0x0F] +
928
+ HEX_CHARS[(h3 >>> 20) & 0x0F] + HEX_CHARS[(h3 >>> 16) & 0x0F] +
929
+ HEX_CHARS[(h3 >>> 12) & 0x0F] + HEX_CHARS[(h3 >>> 8) & 0x0F] +
930
+ HEX_CHARS[(h3 >>> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
931
+ HEX_CHARS[(h4 >>> 28) & 0x0F] + HEX_CHARS[(h4 >>> 24) & 0x0F] +
932
+ HEX_CHARS[(h4 >>> 20) & 0x0F] + HEX_CHARS[(h4 >>> 16) & 0x0F] +
933
+ HEX_CHARS[(h4 >>> 12) & 0x0F] + HEX_CHARS[(h4 >>> 8) & 0x0F] +
934
+ HEX_CHARS[(h4 >>> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] +
935
+ HEX_CHARS[(h5 >>> 28) & 0x0F] + HEX_CHARS[(h5 >>> 24) & 0x0F] +
936
+ HEX_CHARS[(h5 >>> 20) & 0x0F] + HEX_CHARS[(h5 >>> 16) & 0x0F] +
937
+ HEX_CHARS[(h5 >>> 12) & 0x0F] + HEX_CHARS[(h5 >>> 8) & 0x0F] +
938
+ HEX_CHARS[(h5 >>> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] +
939
+ HEX_CHARS[(h6 >>> 28) & 0x0F] + HEX_CHARS[(h6 >>> 24) & 0x0F] +
940
+ HEX_CHARS[(h6 >>> 20) & 0x0F] + HEX_CHARS[(h6 >>> 16) & 0x0F] +
941
+ HEX_CHARS[(h6 >>> 12) & 0x0F] + HEX_CHARS[(h6 >>> 8) & 0x0F] +
942
+ HEX_CHARS[(h6 >>> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F];
943
+ if (!this.is224) {
944
+ hex += HEX_CHARS[(h7 >>> 28) & 0x0F] + HEX_CHARS[(h7 >>> 24) & 0x0F] +
945
+ HEX_CHARS[(h7 >>> 20) & 0x0F] + HEX_CHARS[(h7 >>> 16) & 0x0F] +
946
+ HEX_CHARS[(h7 >>> 12) & 0x0F] + HEX_CHARS[(h7 >>> 8) & 0x0F] +
947
+ HEX_CHARS[(h7 >>> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F];
948
+ }
949
+ return hex;
950
+ };
951
+
952
+ Sha256.prototype.toString = Sha256.prototype.hex;
953
+
954
+ Sha256.prototype.digest = function () {
955
+ this.finalize();
956
+
957
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
958
+ h6 = this.h6, h7 = this.h7;
959
+
960
+ var arr = [
961
+ (h0 >>> 24) & 0xFF, (h0 >>> 16) & 0xFF, (h0 >>> 8) & 0xFF, h0 & 0xFF,
962
+ (h1 >>> 24) & 0xFF, (h1 >>> 16) & 0xFF, (h1 >>> 8) & 0xFF, h1 & 0xFF,
963
+ (h2 >>> 24) & 0xFF, (h2 >>> 16) & 0xFF, (h2 >>> 8) & 0xFF, h2 & 0xFF,
964
+ (h3 >>> 24) & 0xFF, (h3 >>> 16) & 0xFF, (h3 >>> 8) & 0xFF, h3 & 0xFF,
965
+ (h4 >>> 24) & 0xFF, (h4 >>> 16) & 0xFF, (h4 >>> 8) & 0xFF, h4 & 0xFF,
966
+ (h5 >>> 24) & 0xFF, (h5 >>> 16) & 0xFF, (h5 >>> 8) & 0xFF, h5 & 0xFF,
967
+ (h6 >>> 24) & 0xFF, (h6 >>> 16) & 0xFF, (h6 >>> 8) & 0xFF, h6 & 0xFF
968
+ ];
969
+ if (!this.is224) {
970
+ arr.push((h7 >>> 24) & 0xFF, (h7 >>> 16) & 0xFF, (h7 >>> 8) & 0xFF, h7 & 0xFF);
971
+ }
972
+ return arr;
973
+ };
974
+
975
+ Sha256.prototype.array = Sha256.prototype.digest;
976
+
977
+ Sha256.prototype.arrayBuffer = function () {
978
+ this.finalize();
979
+
980
+ var buffer = new ArrayBuffer(this.is224 ? 28 : 32);
981
+ var dataView = new DataView(buffer);
982
+ dataView.setUint32(0, this.h0);
983
+ dataView.setUint32(4, this.h1);
984
+ dataView.setUint32(8, this.h2);
985
+ dataView.setUint32(12, this.h3);
986
+ dataView.setUint32(16, this.h4);
987
+ dataView.setUint32(20, this.h5);
988
+ dataView.setUint32(24, this.h6);
989
+ if (!this.is224) {
990
+ dataView.setUint32(28, this.h7);
991
+ }
992
+ return buffer;
993
+ };
994
+
995
+ function HmacSha256(key, is224, sharedMemory) {
996
+ var i, type = typeof key;
997
+ if (type === 'string') {
998
+ var bytes = [], length = key.length, index = 0, code;
999
+ for (i = 0; i < length; ++i) {
1000
+ code = key.charCodeAt(i);
1001
+ if (code < 0x80) {
1002
+ bytes[index++] = code;
1003
+ } else if (code < 0x800) {
1004
+ bytes[index++] = (0xc0 | (code >>> 6));
1005
+ bytes[index++] = (0x80 | (code & 0x3f));
1006
+ } else if (code < 0xd800 || code >= 0xe000) {
1007
+ bytes[index++] = (0xe0 | (code >>> 12));
1008
+ bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
1009
+ bytes[index++] = (0x80 | (code & 0x3f));
1010
+ } else {
1011
+ code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));
1012
+ bytes[index++] = (0xf0 | (code >>> 18));
1013
+ bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
1014
+ bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
1015
+ bytes[index++] = (0x80 | (code & 0x3f));
1016
+ }
1017
+ }
1018
+ key = bytes;
1019
+ } else {
1020
+ if (type === 'object') {
1021
+ if (key === null) {
1022
+ throw new Error(ERROR);
1023
+ } else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) {
1024
+ key = new Uint8Array(key);
1025
+ } else if (!Array.isArray(key)) {
1026
+ if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) {
1027
+ throw new Error(ERROR);
1028
+ }
1029
+ }
1030
+ } else {
1031
+ throw new Error(ERROR);
1032
+ }
1033
+ }
1034
+
1035
+ if (key.length > 64) {
1036
+ key = (new Sha256(is224, true)).update(key).array();
1037
+ }
1038
+
1039
+ var oKeyPad = [], iKeyPad = [];
1040
+ for (i = 0; i < 64; ++i) {
1041
+ var b = key[i] || 0;
1042
+ oKeyPad[i] = 0x5c ^ b;
1043
+ iKeyPad[i] = 0x36 ^ b;
1044
+ }
1045
+
1046
+ Sha256.call(this, is224, sharedMemory);
1047
+
1048
+ this.update(iKeyPad);
1049
+ this.oKeyPad = oKeyPad;
1050
+ this.inner = true;
1051
+ this.sharedMemory = sharedMemory;
1052
+ }
1053
+ HmacSha256.prototype = new Sha256();
1054
+
1055
+ HmacSha256.prototype.finalize = function () {
1056
+ Sha256.prototype.finalize.call(this);
1057
+ if (this.inner) {
1058
+ this.inner = false;
1059
+ var innerHash = this.array();
1060
+ Sha256.call(this, this.is224, this.sharedMemory);
1061
+ this.update(this.oKeyPad);
1062
+ this.update(innerHash);
1063
+ Sha256.prototype.finalize.call(this);
1064
+ }
1065
+ };
1066
+
1067
+ var exports = createMethod();
1068
+ exports.sha256 = exports;
1069
+ exports.sha224 = createMethod(true);
1070
+ exports.sha256.hmac = createHmacMethod();
1071
+ exports.sha224.hmac = createHmacMethod(true);
1072
+
1073
+ if (COMMON_JS) {
1074
+ module.exports = exports;
1075
+ } else {
1076
+ root.sha256 = exports.sha256;
1077
+ root.sha224 = exports.sha224;
1078
+ }
1079
+ })();
1080
+ }(sha256));
1081
+
553
1082
  const isBrowser$1 = typeof window !== 'undefined';
554
1083
  const isServer$1 = !isBrowser$1;
555
1084
  const standardFacebookEvents = ['AddPaymentInfo', 'AddToCart', 'AddToWishlist', 'CompleteRegistration', 'Contact', 'CustomizeProduct', 'Donate', 'FindLocation', 'InitiateCheckout', 'Lead', 'Purchase', 'Schedule', 'Search', 'StartTrial', 'SubmitApplication', 'Subscribe', 'ViewContent', 'PageView'];
@@ -622,20 +1151,20 @@ function createFacebookPixelIntegration(config) {
622
1151
  track: (eventName, properties, context) => {
623
1152
  if (!isPixelReady || !window.fbq) return;
624
1153
  const fbEventName = getFacebookEventName(eventName, config.eventMapping);
625
- // Standard Facebook events that support parameters
626
1154
  const eventsWithParams = ['Purchase', 'StartTrial', 'Subscribe'];
1155
+ const isStandardEvent = standardFacebookEvents.includes(fbEventName);
1156
+ const trackType = isStandardEvent ? 'track' : 'trackCustom';
627
1157
  if (eventsWithParams.includes(fbEventName) && properties) {
628
- // Extract standard Facebook parameters
629
1158
  const fbParams = {};
630
1159
  if (properties['value'] !== undefined) fbParams['value'] = properties['value'];
631
1160
  if (properties['currency'] !== undefined) fbParams['currency'] = properties['currency'];
632
1161
  if (properties['predicted_ltv'] !== undefined) fbParams['predicted_ltv'] = properties['predicted_ltv'];
633
- window.fbq('track', fbEventName, Object.assign(Object.assign({}, properties), fbParams));
1162
+ window.fbq(trackType, fbEventName, fbParams);
634
1163
  } else {
635
- window.fbq('track', fbEventName);
1164
+ window.fbq(trackType, fbEventName);
636
1165
  }
637
1166
  },
638
- identify: (userId, properties, context) => __awaiter(this, void 0, void 0, function* () {
1167
+ identify: (userId, properties, context) => {
639
1168
  try {
640
1169
  if (typeof window !== 'undefined' && window.fbq) {
641
1170
  const amValues = coerceMetaConversionsAmValues(Object.assign(Object.assign({}, properties || {}), userId ? {
@@ -643,7 +1172,7 @@ function createFacebookPixelIntegration(config) {
643
1172
  } : {}));
644
1173
  const am = {};
645
1174
  if (amValues.external_id) am['external_id'] = amValues.external_id;
646
- if (amValues.em) am['em'] = yield sha256Hex(amValues.em);
1175
+ if (amValues.em) am['em'] = sha256.exports.sha256(amValues.em);
647
1176
  if (amValues.fn) am['fn'] = amValues.fn;
648
1177
  if (amValues.ln) am['ln'] = amValues.ln;
649
1178
  if (amValues.ph) am['ph'] = amValues.ph;
@@ -660,7 +1189,7 @@ function createFacebookPixelIntegration(config) {
660
1189
  } catch (error) {
661
1190
  console.error('Error identifying user in Meta Pixel:', error);
662
1191
  }
663
- })
1192
+ }
664
1193
  };
665
1194
  }
666
1195
  function getFacebookEventName(eventName, eventMapping) {
@@ -669,32 +1198,6 @@ function getFacebookEventName(eventName, eventMapping) {
669
1198
  if (!eventMapping) return eventName;
670
1199
  return eventMapping[eventName] || eventName;
671
1200
  }
672
- // Legacy functions for backward compatibility (deprecated)
673
- function initializeFacebookPixel(pixelId) {
674
- var _a;
675
- console.warn('initializeFacebookPixel is deprecated. Use createFacebookPixelIntegration instead.');
676
- const integration = createFacebookPixelIntegration({
677
- pixelId
678
- });
679
- (_a = integration.init) === null || _a === void 0 ? void 0 : _a.call(integration);
680
- }
681
- function trackFacebookEvent(eventName, properties, eventMapping) {
682
- console.warn('trackFacebookEvent is deprecated. Use IntegrationManager instead.');
683
- if (isServer$1 || !window.fbq) return;
684
- const fbEventName = getFacebookEventName(eventName, eventMapping);
685
- const eventsWithParams = ['Purchase', 'StartTrial', 'Subscribe'];
686
- const isStandardEvent = standardFacebookEvents.includes(fbEventName);
687
- const trackType = isStandardEvent ? 'track' : 'trackCustom';
688
- if (eventsWithParams.includes(fbEventName) && properties) {
689
- const fbParams = {};
690
- if (properties['value'] !== undefined) fbParams['value'] = properties['value'];
691
- if (properties['currency'] !== undefined) fbParams['currency'] = properties['currency'];
692
- if (properties['predicted_ltv'] !== undefined) fbParams['predicted_ltv'] = properties['predicted_ltv'];
693
- window.fbq(trackType, fbEventName, fbParams);
694
- } else {
695
- window.fbq(trackType, fbEventName);
696
- }
697
- }
698
1201
  function coerceMetaConversionsAmValues(properties) {
699
1202
  const coerce = [{
700
1203
  key: 'em',
@@ -827,14 +1330,6 @@ function findFirstProperty(properties, keys) {
827
1330
  }
828
1331
  return null;
829
1332
  }
830
- const toHex = buf => [...new Uint8Array(buf)].map(b => b.toString(16).padStart(2, '0')).join('');
831
- function sha256Hex(input) {
832
- return __awaiter(this, void 0, void 0, function* () {
833
- const enc = new TextEncoder().encode(input);
834
- const digest = yield crypto.subtle.digest('SHA-256', enc);
835
- return toHex(digest);
836
- });
837
- }
838
1333
 
839
1334
  /* eslint-disable @typescript-eslint/no-explicit-any */
840
1335
  class AnalyticsLogger {
@@ -1623,4 +2118,4 @@ const browserContextSchema = z.object({
1623
2118
  $utmAdId: z.string().nullable()
1624
2119
  });
1625
2120
 
1626
- export { IntegrationManager, Logger, Saasco, browserContextSchema, createFacebookPixelIntegration, getBrowserContext, initializeFacebookPixel, standardFacebookEvents, timezones, trackFacebookEvent };
2121
+ export { IntegrationManager, Logger, Saasco, browserContextSchema, createFacebookPixelIntegration, getBrowserContext, standardFacebookEvents, timezones };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasco-sdk",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0",
6
6
  "@lukeed/uuid": "^2.0.1",
@@ -32,5 +32,3 @@ export type StandardFacebookEvent = (typeof standardFacebookEvents)[number];
32
32
  * Create a Facebook Pixel integration instance
33
33
  */
34
34
  export declare function createFacebookPixelIntegration(config: FacebookPixelConfig): Integration;
35
- export declare function initializeFacebookPixel(pixelId: string): void;
36
- export declare function trackFacebookEvent(eventName: string, properties?: Record<string, any>, eventMapping?: FacebookEventMapping): void;