posthog-js-lite 2.6.1 → 2.6.2
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/CHANGELOG.md +4 -0
- package/lib/index.cjs.js +51 -38
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +51 -38
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/vendor/uuidv7.d.ts +179 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/index.cjs.js
CHANGED
|
@@ -685,6 +685,8 @@ var SimpleEventEmitter = /** @class */ (function () {
|
|
|
685
685
|
return SimpleEventEmitter;
|
|
686
686
|
}());
|
|
687
687
|
|
|
688
|
+
// vendor from: https://github.com/LiosK/uuidv7/blob/f30b7a7faff73afbce0b27a46c638310f96912ba/src/index.ts
|
|
689
|
+
// https://github.com/LiosK/uuidv7#license
|
|
688
690
|
/**
|
|
689
691
|
* uuidv7: An experimental implementation of the proposed UUID Version 7
|
|
690
692
|
*
|
|
@@ -1032,43 +1034,51 @@ var V7Generator = /** @class */ (function () {
|
|
|
1032
1034
|
};
|
|
1033
1035
|
return V7Generator;
|
|
1034
1036
|
}());
|
|
1037
|
+
/** A global flag to force use of cryptographically strong RNG. */
|
|
1038
|
+
// declare const UUIDV7_DENY_WEAK_RNG: boolean;
|
|
1035
1039
|
/** Returns the default random number generator available in the environment. */
|
|
1036
1040
|
var getDefaultRandom = function () {
|
|
1037
|
-
//
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
this.buffer = new Uint32Array(8);
|
|
1061
|
-
this.cursor = 0xffff;
|
|
1062
|
-
}
|
|
1063
|
-
BufferedCryptoRandom.prototype.nextUint32 = function () {
|
|
1064
|
-
if (this.cursor >= this.buffer.length) {
|
|
1065
|
-
crypto.getRandomValues(this.buffer);
|
|
1066
|
-
this.cursor = 0;
|
|
1067
|
-
}
|
|
1068
|
-
return this.buffer[this.cursor++];
|
|
1041
|
+
// fix: crypto isn't available in react-native, always use Math.random
|
|
1042
|
+
// // detect Web Crypto API
|
|
1043
|
+
// if (
|
|
1044
|
+
// typeof crypto !== "undefined" &&
|
|
1045
|
+
// typeof crypto.getRandomValues !== "undefined"
|
|
1046
|
+
// ) {
|
|
1047
|
+
// return new BufferedCryptoRandom();
|
|
1048
|
+
// } else {
|
|
1049
|
+
// // fall back on Math.random() unless the flag is set to true
|
|
1050
|
+
// if (typeof UUIDV7_DENY_WEAK_RNG !== "undefined" && UUIDV7_DENY_WEAK_RNG) {
|
|
1051
|
+
// throw new Error("no cryptographically strong RNG available");
|
|
1052
|
+
// }
|
|
1053
|
+
// return {
|
|
1054
|
+
// nextUint32: (): number =>
|
|
1055
|
+
// Math.trunc(Math.random() * 0x1_0000) * 0x1_0000 +
|
|
1056
|
+
// Math.trunc(Math.random() * 0x1_0000),
|
|
1057
|
+
// };
|
|
1058
|
+
// }
|
|
1059
|
+
return {
|
|
1060
|
+
nextUint32: function () {
|
|
1061
|
+
return Math.trunc(Math.random() * 65536) * 65536 +
|
|
1062
|
+
Math.trunc(Math.random() * 65536);
|
|
1063
|
+
},
|
|
1069
1064
|
};
|
|
1070
|
-
|
|
1071
|
-
|
|
1065
|
+
};
|
|
1066
|
+
// /**
|
|
1067
|
+
// * Wraps `crypto.getRandomValues()` to enable buffering; this uses a small
|
|
1068
|
+
// * buffer by default to avoid both unbearable throughput decline in some
|
|
1069
|
+
// * environments and the waste of time and space for unused values.
|
|
1070
|
+
// */
|
|
1071
|
+
// class BufferedCryptoRandom {
|
|
1072
|
+
// private readonly buffer = new Uint32Array(8);
|
|
1073
|
+
// private cursor = 0xffff;
|
|
1074
|
+
// nextUint32(): number {
|
|
1075
|
+
// if (this.cursor >= this.buffer.length) {
|
|
1076
|
+
// crypto.getRandomValues(this.buffer);
|
|
1077
|
+
// this.cursor = 0;
|
|
1078
|
+
// }
|
|
1079
|
+
// return this.buffer[this.cursor++];
|
|
1080
|
+
// }
|
|
1081
|
+
// }
|
|
1072
1082
|
var defaultGenerator;
|
|
1073
1083
|
/**
|
|
1074
1084
|
* Generates a UUIDv7 string.
|
|
@@ -1078,7 +1088,9 @@ var defaultGenerator;
|
|
|
1078
1088
|
*/
|
|
1079
1089
|
var uuidv7 = function () { return uuidv7obj().toString(); };
|
|
1080
1090
|
/** Generates a UUIDv7 object. */
|
|
1081
|
-
var uuidv7obj = function () {
|
|
1091
|
+
var uuidv7obj = function () {
|
|
1092
|
+
return (defaultGenerator || (defaultGenerator = new V7Generator())).generate();
|
|
1093
|
+
};
|
|
1082
1094
|
|
|
1083
1095
|
var PostHogFetchHttpError = /** @class */ (function (_super) {
|
|
1084
1096
|
__extends(PostHogFetchHttpError, _super);
|
|
@@ -1475,7 +1487,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
1475
1487
|
return ctrl.signal;
|
|
1476
1488
|
});
|
|
1477
1489
|
return [4 /*yield*/, retriable(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1478
|
-
var res, e_1;
|
|
1490
|
+
var res, e_1, isNoCors;
|
|
1479
1491
|
return __generator(this, function (_a) {
|
|
1480
1492
|
switch (_a.label) {
|
|
1481
1493
|
case 0:
|
|
@@ -1492,7 +1504,8 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
1492
1504
|
// fetch will only throw on network errors or on timeouts
|
|
1493
1505
|
throw new PostHogFetchNetworkError(e_1);
|
|
1494
1506
|
case 4:
|
|
1495
|
-
|
|
1507
|
+
isNoCors = options.mode === 'no-cors';
|
|
1508
|
+
if (!isNoCors && (res.status < 200 || res.status >= 400)) {
|
|
1496
1509
|
throw new PostHogFetchHttpError(res);
|
|
1497
1510
|
}
|
|
1498
1511
|
return [2 /*return*/, res];
|
|
@@ -1975,7 +1988,7 @@ var PostHogCore = /** @class */ (function (_super) {
|
|
|
1975
1988
|
return PostHogCore;
|
|
1976
1989
|
}(PostHogCoreStateless));
|
|
1977
1990
|
|
|
1978
|
-
var version = "2.6.
|
|
1991
|
+
var version = "2.6.2";
|
|
1979
1992
|
|
|
1980
1993
|
function getContext(window) {
|
|
1981
1994
|
var context = {};
|