@lightsparkdev/core 1.0.18 → 1.0.21

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @lightsparkdev/core
2
2
 
3
+ ## 1.0.21
4
+
5
+ ### Patch Changes
6
+
7
+ - 15d0720: - Consolidate type utils from ui to core
8
+ - 15d0720: - Use 64 bit nonces
9
+
10
+ ## 1.0.20
11
+
12
+ ### Patch Changes
13
+
14
+ - b47bc60: - Add lsidToUUID util
15
+
16
+ ## 1.0.19
17
+
18
+ ### Patch Changes
19
+
20
+ - 330f913: - Ensure tsup properly bundles ESM-only auto-bind and lodash dependencies for CJS support
21
+
3
22
  ## 1.0.18
4
23
 
5
24
  ### Patch Changes
@@ -768,8 +768,83 @@ var deleteLocalStorageItem = (key) => {
768
768
  }
769
769
  };
770
770
 
771
- // src/utils/pollUntil.ts
772
- import { isFunction } from "lodash-es";
771
+ // ../../node_modules/lodash-es/_freeGlobal.js
772
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
773
+ var freeGlobal_default = freeGlobal;
774
+
775
+ // ../../node_modules/lodash-es/_root.js
776
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
777
+ var root = freeGlobal_default || freeSelf || Function("return this")();
778
+ var root_default = root;
779
+
780
+ // ../../node_modules/lodash-es/_Symbol.js
781
+ var Symbol = root_default.Symbol;
782
+ var Symbol_default = Symbol;
783
+
784
+ // ../../node_modules/lodash-es/_getRawTag.js
785
+ var objectProto = Object.prototype;
786
+ var hasOwnProperty = objectProto.hasOwnProperty;
787
+ var nativeObjectToString = objectProto.toString;
788
+ var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
789
+ function getRawTag(value) {
790
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
791
+ try {
792
+ value[symToStringTag] = void 0;
793
+ var unmasked = true;
794
+ } catch (e) {
795
+ }
796
+ var result = nativeObjectToString.call(value);
797
+ if (unmasked) {
798
+ if (isOwn) {
799
+ value[symToStringTag] = tag;
800
+ } else {
801
+ delete value[symToStringTag];
802
+ }
803
+ }
804
+ return result;
805
+ }
806
+ var getRawTag_default = getRawTag;
807
+
808
+ // ../../node_modules/lodash-es/_objectToString.js
809
+ var objectProto2 = Object.prototype;
810
+ var nativeObjectToString2 = objectProto2.toString;
811
+ function objectToString(value) {
812
+ return nativeObjectToString2.call(value);
813
+ }
814
+ var objectToString_default = objectToString;
815
+
816
+ // ../../node_modules/lodash-es/_baseGetTag.js
817
+ var nullTag = "[object Null]";
818
+ var undefinedTag = "[object Undefined]";
819
+ var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
820
+ function baseGetTag(value) {
821
+ if (value == null) {
822
+ return value === void 0 ? undefinedTag : nullTag;
823
+ }
824
+ return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
825
+ }
826
+ var baseGetTag_default = baseGetTag;
827
+
828
+ // ../../node_modules/lodash-es/isObject.js
829
+ function isObject(value) {
830
+ var type = typeof value;
831
+ return value != null && (type == "object" || type == "function");
832
+ }
833
+ var isObject_default = isObject;
834
+
835
+ // ../../node_modules/lodash-es/isFunction.js
836
+ var asyncTag = "[object AsyncFunction]";
837
+ var funcTag = "[object Function]";
838
+ var genTag = "[object GeneratorFunction]";
839
+ var proxyTag = "[object Proxy]";
840
+ function isFunction(value) {
841
+ if (!isObject_default(value)) {
842
+ return false;
843
+ }
844
+ var tag = baseGetTag_default(value);
845
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
846
+ }
847
+ var isFunction_default = isFunction;
773
848
 
774
849
  // src/utils/sleep.ts
775
850
  function sleep(ms) {
@@ -804,7 +879,7 @@ async function pollUntil(asyncFn, getValue, maxPolls = 60, pollIntervalMs = 500,
804
879
  stopPolling = true;
805
880
  }
806
881
  } catch (e) {
807
- if (!ignoreErrors || isFunction(ignoreErrors) && !ignoreErrors(e)) {
882
+ if (!ignoreErrors || isFunction_default(ignoreErrors) && !ignoreErrors(e)) {
808
883
  stopPolling = true;
809
884
  throw e;
810
885
  }
@@ -814,10 +889,23 @@ async function pollUntil(asyncFn, getValue, maxPolls = 60, pollIntervalMs = 500,
814
889
  return result.value;
815
890
  }
816
891
 
892
+ // src/utils/strings.ts
893
+ function lsidToUUID(lsid) {
894
+ return lsid.replace(/^[^:]+:(.*)$/, "$1");
895
+ }
896
+
897
+ // src/utils/typeGuards.ts
898
+ function isUint8Array(variable) {
899
+ return variable instanceof Uint8Array;
900
+ }
901
+
817
902
  // src/utils/types.ts
818
903
  var isType = (typename) => (node) => {
819
904
  return node?.__typename === typename;
820
905
  };
906
+ function notNullUndefined(value) {
907
+ return value !== null && value !== void 0;
908
+ }
821
909
 
822
910
  export {
823
911
  LightsparkException_default,
@@ -860,5 +948,21 @@ export {
860
948
  deleteLocalStorageItem,
861
949
  sleep,
862
950
  pollUntil,
863
- isType
951
+ lsidToUUID,
952
+ isUint8Array,
953
+ isType,
954
+ notNullUndefined
864
955
  };
956
+ /*! Bundled license information:
957
+
958
+ lodash-es/lodash.js:
959
+ (**
960
+ * @license
961
+ * Lodash (Custom Build) <https://lodash.com/>
962
+ * Build: `lodash modularize exports="es" -o ./`
963
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
964
+ * Released under MIT license <https://lodash.com/license>
965
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
966
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
967
+ *)
968
+ */
@@ -162,6 +162,7 @@ type JSONObject = {
162
162
  [key: string]: JSONType;
163
163
  };
164
164
  type NN<T> = NonNullable<T>;
165
+ declare function notNullUndefined<TValue>(value: TValue | null | undefined): value is TValue;
165
166
 
166
167
  declare const isError: (e: unknown) => e is Error;
167
168
  type ErrorWithMessage = {
@@ -269,4 +270,8 @@ declare function pollUntil<D extends () => Promise<unknown>, T>(asyncFn: D, getV
269
270
 
270
271
  declare function sleep(ms: number): Promise<unknown>;
271
272
 
272
- export { JSONType as $, isErrorMsg as A, errorToJSON as B, ConfigKeys as C, bytesToHex as D, hexToBytes as E, getLocalStorageConfigItem as F, getLocalStorageBoolean as G, setLocalStorageBoolean as H, deleteLocalStorageItem as I, getCurrentLocale as J, countryCodesToCurrencyCodes as K, CurrencyLocales as L, CurrencyCodes as M, localeToCurrencyCode as N, clamp as O, linearInterpolate as P, round as Q, isNumber as R, pollUntil as S, sleep as T, Maybe as U, ExpandRecursively as V, ById as W, OmitTypename as X, isType as Y, DeepPartial as Z, JSONLiteral as _, b64encode as a, JSONObject as a0, NN as a1, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, CurrencyUnit as e, CurrencyAmountType as f, convertCurrencyAmountValue as g, convertCurrencyAmount as h, CurrencyMap as i, CurrencyAmountObj as j, CurrencyAmountArg as k, isCurrencyAmountObj as l, isCurrencyAmount as m, mapCurrencyAmount as n, isCurrencyMap as o, abbrCurrencyUnit as p, formatCurrencyStr as q, localeToCurrencySymbol as r, separateCurrencyStrParts as s, isBrowser as t, urlsafe_b64decode as u, isNode as v, isTest as w, isError as x, isErrorWithMessage as y, getErrorMsg as z };
273
+ declare function lsidToUUID(lsid: string): string;
274
+
275
+ declare function isUint8Array(variable: unknown): variable is Uint8Array;
276
+
277
+ export { DeepPartial as $, isErrorMsg as A, errorToJSON as B, ConfigKeys as C, bytesToHex as D, hexToBytes as E, getLocalStorageConfigItem as F, getLocalStorageBoolean as G, setLocalStorageBoolean as H, deleteLocalStorageItem as I, getCurrentLocale as J, countryCodesToCurrencyCodes as K, CurrencyLocales as L, CurrencyCodes as M, localeToCurrencyCode as N, clamp as O, linearInterpolate as P, round as Q, isNumber as R, pollUntil as S, sleep as T, lsidToUUID as U, isUint8Array as V, Maybe as W, ExpandRecursively as X, ById as Y, OmitTypename as Z, isType as _, b64encode as a, JSONLiteral as a0, JSONType as a1, JSONObject as a2, NN as a3, notNullUndefined as a4, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, CurrencyUnit as e, CurrencyAmountType as f, convertCurrencyAmountValue as g, convertCurrencyAmount as h, CurrencyMap as i, CurrencyAmountObj as j, CurrencyAmountArg as k, isCurrencyAmountObj as l, isCurrencyAmount as m, mapCurrencyAmount as n, isCurrencyMap as o, abbrCurrencyUnit as p, formatCurrencyStr as q, localeToCurrencySymbol as r, separateCurrencyStrParts as s, isBrowser as t, urlsafe_b64decode as u, isNode as v, isTest as w, isError as x, isErrorWithMessage as y, getErrorMsg as z };
package/dist/index.cjs CHANGED
@@ -77,10 +77,13 @@ __export(src_exports, {
77
77
  isNumber: () => isNumber,
78
78
  isTest: () => isTest,
79
79
  isType: () => isType,
80
+ isUint8Array: () => isUint8Array,
80
81
  linearInterpolate: () => linearInterpolate,
81
82
  localeToCurrencyCode: () => localeToCurrencyCode,
82
83
  localeToCurrencySymbol: () => localeToCurrencySymbol,
84
+ lsidToUUID: () => lsidToUUID,
83
85
  mapCurrencyAmount: () => mapCurrencyAmount,
86
+ notNullUndefined: () => notNullUndefined,
84
87
  pollUntil: () => pollUntil,
85
88
  round: () => round,
86
89
  separateCurrencyStrParts: () => separateCurrencyStrParts,
@@ -213,8 +216,38 @@ var LightsparkSigningException = class extends LightsparkException_default {
213
216
  };
214
217
  var LightsparkSigningException_default = LightsparkSigningException;
215
218
 
216
- // src/crypto/NodeKeyCache.ts
217
- var import_auto_bind = __toESM(require("auto-bind"), 1);
219
+ // ../../node_modules/auto-bind/index.js
220
+ var getAllProperties = (object) => {
221
+ const properties = /* @__PURE__ */ new Set();
222
+ do {
223
+ for (const key of Reflect.ownKeys(object)) {
224
+ properties.add([object, key]);
225
+ }
226
+ } while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
227
+ return properties;
228
+ };
229
+ function autoBind(self2, { include, exclude } = {}) {
230
+ const filter = (key) => {
231
+ const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
232
+ if (include) {
233
+ return include.some(match);
234
+ }
235
+ if (exclude) {
236
+ return !exclude.some(match);
237
+ }
238
+ return true;
239
+ };
240
+ for (const [object, key] of getAllProperties(self2.constructor.prototype)) {
241
+ if (key === "constructor" || !filter(key)) {
242
+ continue;
243
+ }
244
+ const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
245
+ if (descriptor && typeof descriptor.value === "function") {
246
+ self2[key] = self2[key].bind(self2);
247
+ }
248
+ }
249
+ return self2;
250
+ }
218
251
 
219
252
  // src/utils/base64.ts
220
253
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
@@ -420,8 +453,10 @@ var serializeSigningKey = async (key, format) => {
420
453
  );
421
454
  };
422
455
  var getNonce = async () => {
423
- const nonceSt = await getRandomValues32(new Uint32Array(1));
424
- return Number(nonceSt);
456
+ const nonceSt = await getRandomValues32(new Uint32Array(2));
457
+ const [upper, lower] = nonceSt;
458
+ const nonce = BigInt(upper) << 32n | BigInt(lower);
459
+ return Number(nonce);
425
460
  };
426
461
  var sign = async (keyOrAlias, data) => {
427
462
  if (typeof keyOrAlias === "string") {
@@ -1177,8 +1212,83 @@ var deleteLocalStorageItem = (key) => {
1177
1212
  }
1178
1213
  };
1179
1214
 
1180
- // src/utils/pollUntil.ts
1181
- var import_lodash_es = require("lodash-es");
1215
+ // ../../node_modules/lodash-es/_freeGlobal.js
1216
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
1217
+ var freeGlobal_default = freeGlobal;
1218
+
1219
+ // ../../node_modules/lodash-es/_root.js
1220
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
1221
+ var root = freeGlobal_default || freeSelf || Function("return this")();
1222
+ var root_default = root;
1223
+
1224
+ // ../../node_modules/lodash-es/_Symbol.js
1225
+ var Symbol2 = root_default.Symbol;
1226
+ var Symbol_default = Symbol2;
1227
+
1228
+ // ../../node_modules/lodash-es/_getRawTag.js
1229
+ var objectProto = Object.prototype;
1230
+ var hasOwnProperty = objectProto.hasOwnProperty;
1231
+ var nativeObjectToString = objectProto.toString;
1232
+ var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
1233
+ function getRawTag(value) {
1234
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
1235
+ try {
1236
+ value[symToStringTag] = void 0;
1237
+ var unmasked = true;
1238
+ } catch (e) {
1239
+ }
1240
+ var result = nativeObjectToString.call(value);
1241
+ if (unmasked) {
1242
+ if (isOwn) {
1243
+ value[symToStringTag] = tag;
1244
+ } else {
1245
+ delete value[symToStringTag];
1246
+ }
1247
+ }
1248
+ return result;
1249
+ }
1250
+ var getRawTag_default = getRawTag;
1251
+
1252
+ // ../../node_modules/lodash-es/_objectToString.js
1253
+ var objectProto2 = Object.prototype;
1254
+ var nativeObjectToString2 = objectProto2.toString;
1255
+ function objectToString(value) {
1256
+ return nativeObjectToString2.call(value);
1257
+ }
1258
+ var objectToString_default = objectToString;
1259
+
1260
+ // ../../node_modules/lodash-es/_baseGetTag.js
1261
+ var nullTag = "[object Null]";
1262
+ var undefinedTag = "[object Undefined]";
1263
+ var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
1264
+ function baseGetTag(value) {
1265
+ if (value == null) {
1266
+ return value === void 0 ? undefinedTag : nullTag;
1267
+ }
1268
+ return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
1269
+ }
1270
+ var baseGetTag_default = baseGetTag;
1271
+
1272
+ // ../../node_modules/lodash-es/isObject.js
1273
+ function isObject(value) {
1274
+ var type = typeof value;
1275
+ return value != null && (type == "object" || type == "function");
1276
+ }
1277
+ var isObject_default = isObject;
1278
+
1279
+ // ../../node_modules/lodash-es/isFunction.js
1280
+ var asyncTag = "[object AsyncFunction]";
1281
+ var funcTag = "[object Function]";
1282
+ var genTag = "[object GeneratorFunction]";
1283
+ var proxyTag = "[object Proxy]";
1284
+ function isFunction(value) {
1285
+ if (!isObject_default(value)) {
1286
+ return false;
1287
+ }
1288
+ var tag = baseGetTag_default(value);
1289
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
1290
+ }
1291
+ var isFunction_default = isFunction;
1182
1292
 
1183
1293
  // src/utils/sleep.ts
1184
1294
  function sleep(ms) {
@@ -1213,7 +1323,7 @@ async function pollUntil(asyncFn, getValue, maxPolls = 60, pollIntervalMs = 500,
1213
1323
  stopPolling = true;
1214
1324
  }
1215
1325
  } catch (e) {
1216
- if (!ignoreErrors || (0, import_lodash_es.isFunction)(ignoreErrors) && !ignoreErrors(e)) {
1326
+ if (!ignoreErrors || isFunction_default(ignoreErrors) && !ignoreErrors(e)) {
1217
1327
  stopPolling = true;
1218
1328
  throw e;
1219
1329
  }
@@ -1223,10 +1333,23 @@ async function pollUntil(asyncFn, getValue, maxPolls = 60, pollIntervalMs = 500,
1223
1333
  return result.value;
1224
1334
  }
1225
1335
 
1336
+ // src/utils/strings.ts
1337
+ function lsidToUUID(lsid) {
1338
+ return lsid.replace(/^[^:]+:(.*)$/, "$1");
1339
+ }
1340
+
1341
+ // src/utils/typeGuards.ts
1342
+ function isUint8Array(variable) {
1343
+ return variable instanceof Uint8Array;
1344
+ }
1345
+
1226
1346
  // src/utils/types.ts
1227
1347
  var isType = (typename) => (node) => {
1228
1348
  return node?.__typename === typename;
1229
1349
  };
1350
+ function notNullUndefined(value) {
1351
+ return value !== null && value !== void 0;
1352
+ }
1230
1353
 
1231
1354
  // src/crypto/SigningKey.ts
1232
1355
  function isAlias(key) {
@@ -1274,7 +1397,7 @@ var NodeKeyCache = class {
1274
1397
  constructor(cryptoImpl = DefaultCrypto) {
1275
1398
  this.cryptoImpl = cryptoImpl;
1276
1399
  this.idToKey = /* @__PURE__ */ new Map();
1277
- (0, import_auto_bind.default)(this);
1400
+ autoBind(this);
1278
1401
  }
1279
1402
  idToKey;
1280
1403
  async loadKey(id, keyOrAlias, signingKeyType) {
@@ -1324,7 +1447,6 @@ var NodeKeyCache = class {
1324
1447
  var NodeKeyCache_default = NodeKeyCache;
1325
1448
 
1326
1449
  // src/requester/Requester.ts
1327
- var import_auto_bind2 = __toESM(require("auto-bind"), 1);
1328
1450
  var import_dayjs = __toESM(require("dayjs"), 1);
1329
1451
  var import_utc = __toESM(require("dayjs/plugin/utc.js"), 1);
1330
1452
  var import_graphql_ws = require("graphql-ws");
@@ -1353,7 +1475,7 @@ var Requester = class {
1353
1475
  connectionParams: () => authProvider.addWsConnectionParams({}),
1354
1476
  webSocketImpl: websocketImpl
1355
1477
  });
1356
- (0, import_auto_bind2.default)(this);
1478
+ autoBind(this);
1357
1479
  }
1358
1480
  wsClient;
1359
1481
  async executeQuery(query) {
@@ -1566,10 +1688,13 @@ var Requester_default = Requester;
1566
1688
  isNumber,
1567
1689
  isTest,
1568
1690
  isType,
1691
+ isUint8Array,
1569
1692
  linearInterpolate,
1570
1693
  localeToCurrencyCode,
1571
1694
  localeToCurrencySymbol,
1695
+ lsidToUUID,
1572
1696
  mapCurrencyAmount,
1697
+ notNullUndefined,
1573
1698
  pollUntil,
1574
1699
  round,
1575
1700
  separateCurrencyStrParts,
@@ -1577,3 +1702,16 @@ var Requester_default = Requester;
1577
1702
  sleep,
1578
1703
  urlsafe_b64decode
1579
1704
  });
1705
+ /*! Bundled license information:
1706
+
1707
+ lodash-es/lodash.js:
1708
+ (**
1709
+ * @license
1710
+ * Lodash (Custom Build) <https://lodash.com/>
1711
+ * Build: `lodash modularize exports="es" -o ./`
1712
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
1713
+ * Released under MIT license <https://lodash.com/license>
1714
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1715
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1716
+ *)
1717
+ */
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { W as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, a1 as NN, X as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-2708d41b.js';
1
+ export { Y as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, a4 as notNullUndefined, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-9e41ffe5.js';
2
2
  import { Observable } from 'zen-observable-ts';
3
3
 
4
4
  declare class LightsparkException extends Error {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { W as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, a1 as NN, X as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-2708d41b.js';
1
+ export { Y as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, a4 as notNullUndefined, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-9e41ffe5.js';
2
2
  import { Observable } from 'zen-observable-ts';
3
3
 
4
4
  declare class LightsparkException extends Error {
package/dist/index.js CHANGED
@@ -30,17 +30,20 @@ import {
30
30
  isNumber,
31
31
  isTest,
32
32
  isType,
33
+ isUint8Array,
33
34
  linearInterpolate,
34
35
  localeToCurrencyCode,
35
36
  localeToCurrencySymbol,
37
+ lsidToUUID,
36
38
  mapCurrencyAmount,
39
+ notNullUndefined,
37
40
  pollUntil,
38
41
  round,
39
42
  separateCurrencyStrParts,
40
43
  setLocalStorageBoolean,
41
44
  sleep,
42
45
  urlsafe_b64decode
43
- } from "./chunk-XPHRCMJA.js";
46
+ } from "./chunk-Y3FWNVYS.js";
44
47
 
45
48
  // src/Logger.ts
46
49
  var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
@@ -146,8 +149,38 @@ var LightsparkSigningException = class extends LightsparkException_default {
146
149
  };
147
150
  var LightsparkSigningException_default = LightsparkSigningException;
148
151
 
149
- // src/crypto/NodeKeyCache.ts
150
- import autoBind from "auto-bind";
152
+ // ../../node_modules/auto-bind/index.js
153
+ var getAllProperties = (object) => {
154
+ const properties = /* @__PURE__ */ new Set();
155
+ do {
156
+ for (const key of Reflect.ownKeys(object)) {
157
+ properties.add([object, key]);
158
+ }
159
+ } while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
160
+ return properties;
161
+ };
162
+ function autoBind(self, { include, exclude } = {}) {
163
+ const filter = (key) => {
164
+ const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
165
+ if (include) {
166
+ return include.some(match);
167
+ }
168
+ if (exclude) {
169
+ return !exclude.some(match);
170
+ }
171
+ return true;
172
+ };
173
+ for (const [object, key] of getAllProperties(self.constructor.prototype)) {
174
+ if (key === "constructor" || !filter(key)) {
175
+ continue;
176
+ }
177
+ const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
178
+ if (descriptor && typeof descriptor.value === "function") {
179
+ self[key] = self[key].bind(self);
180
+ }
181
+ }
182
+ return self;
183
+ }
151
184
 
152
185
  // src/crypto/crypto.ts
153
186
  var getCrypto = () => {
@@ -310,8 +343,10 @@ var serializeSigningKey = async (key, format) => {
310
343
  );
311
344
  };
312
345
  var getNonce = async () => {
313
- const nonceSt = await getRandomValues32(new Uint32Array(1));
314
- return Number(nonceSt);
346
+ const nonceSt = await getRandomValues32(new Uint32Array(2));
347
+ const [upper, lower] = nonceSt;
348
+ const nonce = BigInt(upper) << 32n | BigInt(lower);
349
+ return Number(nonce);
315
350
  };
316
351
  var sign = async (keyOrAlias, data) => {
317
352
  if (typeof keyOrAlias === "string") {
@@ -453,7 +488,6 @@ var NodeKeyCache = class {
453
488
  var NodeKeyCache_default = NodeKeyCache;
454
489
 
455
490
  // src/requester/Requester.ts
456
- import autoBind2 from "auto-bind";
457
491
  import dayjs from "dayjs";
458
492
  import utc from "dayjs/plugin/utc.js";
459
493
  import { createClient } from "graphql-ws";
@@ -482,7 +516,7 @@ var Requester = class {
482
516
  connectionParams: () => authProvider.addWsConnectionParams({}),
483
517
  webSocketImpl: websocketImpl
484
518
  });
485
- autoBind2(this);
519
+ autoBind(this);
486
520
  }
487
521
  wsClient;
488
522
  async executeQuery(query) {
@@ -694,10 +728,13 @@ export {
694
728
  isNumber,
695
729
  isTest,
696
730
  isType,
731
+ isUint8Array,
697
732
  linearInterpolate,
698
733
  localeToCurrencyCode,
699
734
  localeToCurrencySymbol,
735
+ lsidToUUID,
700
736
  mapCurrencyAmount,
737
+ notNullUndefined,
701
738
  pollUntil,
702
739
  round,
703
740
  separateCurrencyStrParts,
@@ -60,10 +60,13 @@ __export(utils_exports, {
60
60
  isNumber: () => isNumber,
61
61
  isTest: () => isTest,
62
62
  isType: () => isType,
63
+ isUint8Array: () => isUint8Array,
63
64
  linearInterpolate: () => linearInterpolate,
64
65
  localeToCurrencyCode: () => localeToCurrencyCode,
65
66
  localeToCurrencySymbol: () => localeToCurrencySymbol,
67
+ lsidToUUID: () => lsidToUUID,
66
68
  mapCurrencyAmount: () => mapCurrencyAmount,
69
+ notNullUndefined: () => notNullUndefined,
67
70
  pollUntil: () => pollUntil,
68
71
  round: () => round,
69
72
  separateCurrencyStrParts: () => separateCurrencyStrParts,
@@ -843,8 +846,83 @@ var deleteLocalStorageItem = (key) => {
843
846
  }
844
847
  };
845
848
 
846
- // src/utils/pollUntil.ts
847
- var import_lodash_es = require("lodash-es");
849
+ // ../../node_modules/lodash-es/_freeGlobal.js
850
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
851
+ var freeGlobal_default = freeGlobal;
852
+
853
+ // ../../node_modules/lodash-es/_root.js
854
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
855
+ var root = freeGlobal_default || freeSelf || Function("return this")();
856
+ var root_default = root;
857
+
858
+ // ../../node_modules/lodash-es/_Symbol.js
859
+ var Symbol2 = root_default.Symbol;
860
+ var Symbol_default = Symbol2;
861
+
862
+ // ../../node_modules/lodash-es/_getRawTag.js
863
+ var objectProto = Object.prototype;
864
+ var hasOwnProperty = objectProto.hasOwnProperty;
865
+ var nativeObjectToString = objectProto.toString;
866
+ var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
867
+ function getRawTag(value) {
868
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
869
+ try {
870
+ value[symToStringTag] = void 0;
871
+ var unmasked = true;
872
+ } catch (e) {
873
+ }
874
+ var result = nativeObjectToString.call(value);
875
+ if (unmasked) {
876
+ if (isOwn) {
877
+ value[symToStringTag] = tag;
878
+ } else {
879
+ delete value[symToStringTag];
880
+ }
881
+ }
882
+ return result;
883
+ }
884
+ var getRawTag_default = getRawTag;
885
+
886
+ // ../../node_modules/lodash-es/_objectToString.js
887
+ var objectProto2 = Object.prototype;
888
+ var nativeObjectToString2 = objectProto2.toString;
889
+ function objectToString(value) {
890
+ return nativeObjectToString2.call(value);
891
+ }
892
+ var objectToString_default = objectToString;
893
+
894
+ // ../../node_modules/lodash-es/_baseGetTag.js
895
+ var nullTag = "[object Null]";
896
+ var undefinedTag = "[object Undefined]";
897
+ var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
898
+ function baseGetTag(value) {
899
+ if (value == null) {
900
+ return value === void 0 ? undefinedTag : nullTag;
901
+ }
902
+ return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
903
+ }
904
+ var baseGetTag_default = baseGetTag;
905
+
906
+ // ../../node_modules/lodash-es/isObject.js
907
+ function isObject(value) {
908
+ var type = typeof value;
909
+ return value != null && (type == "object" || type == "function");
910
+ }
911
+ var isObject_default = isObject;
912
+
913
+ // ../../node_modules/lodash-es/isFunction.js
914
+ var asyncTag = "[object AsyncFunction]";
915
+ var funcTag = "[object Function]";
916
+ var genTag = "[object GeneratorFunction]";
917
+ var proxyTag = "[object Proxy]";
918
+ function isFunction(value) {
919
+ if (!isObject_default(value)) {
920
+ return false;
921
+ }
922
+ var tag = baseGetTag_default(value);
923
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
924
+ }
925
+ var isFunction_default = isFunction;
848
926
 
849
927
  // src/utils/sleep.ts
850
928
  function sleep(ms) {
@@ -879,7 +957,7 @@ async function pollUntil(asyncFn, getValue, maxPolls = 60, pollIntervalMs = 500,
879
957
  stopPolling = true;
880
958
  }
881
959
  } catch (e) {
882
- if (!ignoreErrors || (0, import_lodash_es.isFunction)(ignoreErrors) && !ignoreErrors(e)) {
960
+ if (!ignoreErrors || isFunction_default(ignoreErrors) && !ignoreErrors(e)) {
883
961
  stopPolling = true;
884
962
  throw e;
885
963
  }
@@ -889,10 +967,23 @@ async function pollUntil(asyncFn, getValue, maxPolls = 60, pollIntervalMs = 500,
889
967
  return result.value;
890
968
  }
891
969
 
970
+ // src/utils/strings.ts
971
+ function lsidToUUID(lsid) {
972
+ return lsid.replace(/^[^:]+:(.*)$/, "$1");
973
+ }
974
+
975
+ // src/utils/typeGuards.ts
976
+ function isUint8Array(variable) {
977
+ return variable instanceof Uint8Array;
978
+ }
979
+
892
980
  // src/utils/types.ts
893
981
  var isType = (typename) => (node) => {
894
982
  return node?.__typename === typename;
895
983
  };
984
+ function notNullUndefined(value) {
985
+ return value !== null && value !== void 0;
986
+ }
896
987
  // Annotate the CommonJS export names for ESM import in node:
897
988
  0 && (module.exports = {
898
989
  CurrencyUnit,
@@ -925,10 +1016,13 @@ var isType = (typename) => (node) => {
925
1016
  isNumber,
926
1017
  isTest,
927
1018
  isType,
1019
+ isUint8Array,
928
1020
  linearInterpolate,
929
1021
  localeToCurrencyCode,
930
1022
  localeToCurrencySymbol,
1023
+ lsidToUUID,
931
1024
  mapCurrencyAmount,
1025
+ notNullUndefined,
932
1026
  pollUntil,
933
1027
  round,
934
1028
  separateCurrencyStrParts,
@@ -936,3 +1030,16 @@ var isType = (typename) => (node) => {
936
1030
  sleep,
937
1031
  urlsafe_b64decode
938
1032
  });
1033
+ /*! Bundled license information:
1034
+
1035
+ lodash-es/lodash.js:
1036
+ (**
1037
+ * @license
1038
+ * Lodash (Custom Build) <https://lodash.com/>
1039
+ * Build: `lodash modularize exports="es" -o ./`
1040
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
1041
+ * Released under MIT license <https://lodash.com/license>
1042
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1043
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1044
+ *)
1045
+ */
@@ -1 +1 @@
1
- export { W as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, a1 as NN, X as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-2708d41b.js';
1
+ export { Y as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, a4 as notNullUndefined, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-9e41ffe5.js';
@@ -1 +1 @@
1
- export { W as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, a1 as NN, X as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-2708d41b.js';
1
+ export { Y as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, $ as DeepPartial, X as ExpandRecursively, a0 as JSONLiteral, a2 as JSONObject, a1 as JSONType, W as Maybe, a3 as NN, Z as OmitTypename, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, _ as isType, V as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, U as lsidToUUID, n as mapCurrencyAmount, a4 as notNullUndefined, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-9e41ffe5.js';
@@ -29,17 +29,20 @@ import {
29
29
  isNumber,
30
30
  isTest,
31
31
  isType,
32
+ isUint8Array,
32
33
  linearInterpolate,
33
34
  localeToCurrencyCode,
34
35
  localeToCurrencySymbol,
36
+ lsidToUUID,
35
37
  mapCurrencyAmount,
38
+ notNullUndefined,
36
39
  pollUntil,
37
40
  round,
38
41
  separateCurrencyStrParts,
39
42
  setLocalStorageBoolean,
40
43
  sleep,
41
44
  urlsafe_b64decode
42
- } from "../chunk-XPHRCMJA.js";
45
+ } from "../chunk-Y3FWNVYS.js";
43
46
  export {
44
47
  CurrencyUnit,
45
48
  abbrCurrencyUnit,
@@ -71,10 +74,13 @@ export {
71
74
  isNumber,
72
75
  isTest,
73
76
  isType,
77
+ isUint8Array,
74
78
  linearInterpolate,
75
79
  localeToCurrencyCode,
76
80
  localeToCurrencySymbol,
81
+ lsidToUUID,
77
82
  mapCurrencyAmount,
83
+ notNullUndefined,
78
84
  pollUntil,
79
85
  round,
80
86
  separateCurrencyStrParts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/core",
3
- "version": "1.0.18",
3
+ "version": "1.0.21",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -73,12 +73,10 @@
73
73
  },
74
74
  "license": "Apache-2.0",
75
75
  "dependencies": {
76
- "auto-bind": "^5.0.1",
77
76
  "crypto-browserify": "^3.12.0",
78
77
  "dayjs": "^1.11.7",
79
78
  "graphql": "^16.6.0",
80
79
  "graphql-ws": "^5.11.3",
81
- "lodash-es": "^4.17.21",
82
80
  "secp256k1": "^5.0.0",
83
81
  "text-encoding": "^0.7.0",
84
82
  "ws": "^8.12.1",
@@ -93,9 +91,11 @@
93
91
  "@types/secp256k1": "^4.0.3",
94
92
  "@types/text-encoding": "^0.0.36",
95
93
  "@types/ws": "^8.5.4",
94
+ "auto-bind": "^5.0.1",
96
95
  "eslint": "^8.3.0",
97
96
  "eslint-watch": "^8.0.0",
98
97
  "jest": "^29.6.2",
98
+ "lodash-es": "^4.17.21",
99
99
  "prettier": "3.0.3",
100
100
  "prettier-plugin-organize-imports": "^3.2.4",
101
101
  "ts-jest": "^29.1.1",
@@ -226,8 +226,12 @@ const serializeSigningKey = async (
226
226
  };
227
227
 
228
228
  const getNonce = async () => {
229
- const nonceSt = await getRandomValues32(new Uint32Array(1));
230
- return Number(nonceSt);
229
+ const nonceSt = await getRandomValues32(new Uint32Array(2));
230
+ const [upper, lower] = nonceSt;
231
+ const nonce = (BigInt(upper) << 32n) | BigInt(lower);
232
+ // Note: We lose some precision here going from bigint to number
233
+ // because js numbers are floats, but it's ok.
234
+ return Number(nonce);
231
235
  };
232
236
 
233
237
  const sign = async (
@@ -18,4 +18,9 @@ describe("Crypto tests", () => {
18
18
  expect(serializedKeypair.privateKey).not.toBeNull();
19
19
  expect(serializedKeypair.publicKey).not.toBeNull();
20
20
  }, 60_000);
21
+
22
+ test("should generate a valid nonce", async () => {
23
+ const nonce = await DefaultCrypto.getNonce();
24
+ expect(nonce).toBeGreaterThan(0);
25
+ }, 10_000);
21
26
  });
@@ -12,4 +12,6 @@ export * from "./localeToCurrencyCodes.js";
12
12
  export * from "./numbers.js";
13
13
  export * from "./pollUntil.js";
14
14
  export * from "./sleep.js";
15
+ export * from "./strings.js";
16
+ export * from "./typeGuards.js";
15
17
  export * from "./types.js";
@@ -0,0 +1,3 @@
1
+ export function lsidToUUID(lsid: string) {
2
+ return lsid.replace(/^[^:]+:(.*)$/, "$1");
3
+ }
@@ -0,0 +1,3 @@
1
+ export function isUint8Array(variable: unknown): variable is Uint8Array {
2
+ return variable instanceof Uint8Array;
3
+ }
@@ -33,3 +33,9 @@ export type JSONType = JSONLiteral | JSONType[] | { [key: string]: JSONType };
33
33
  export type JSONObject = { [key: string]: JSONType };
34
34
 
35
35
  export type NN<T> = NonNullable<T>;
36
+
37
+ export function notNullUndefined<TValue>(
38
+ value: TValue | null | undefined,
39
+ ): value is TValue {
40
+ return value !== null && value !== undefined;
41
+ }