@lightsparkdev/core 1.2.7 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,10 +63,12 @@ __export(utils_exports, {
63
63
  isNode: () => isNode,
64
64
  isNumber: () => isNumber,
65
65
  isObject: () => isObject2,
66
+ isRecord: () => isRecord,
66
67
  isSDKCurrencyAmount: () => isSDKCurrencyAmount,
67
68
  isTest: () => isTest,
68
69
  isType: () => isType,
69
70
  isUint8Array: () => isUint8Array,
71
+ isUmaCurrencyAmount: () => isUmaCurrencyAmount,
70
72
  linearInterpolate: () => linearInterpolate,
71
73
  localeToCurrencyCode: () => localeToCurrencyCode,
72
74
  localeToCurrencySymbol: () => localeToCurrencySymbol,
@@ -492,6 +494,7 @@ var CurrencyUnit = {
492
494
  USD: "USD",
493
495
  MXN: "MXN",
494
496
  PHP: "PHP",
497
+ EUR: "EUR",
495
498
  Bitcoin: "BITCOIN",
496
499
  Microbitcoin: "MICROBITCOIN",
497
500
  Millibitcoin: "MILLIBITCOIN",
@@ -512,7 +515,8 @@ var standardUnitConversionObj = {
512
515
  /* Converting between two different fiat types is not currently supported */
513
516
  [CurrencyUnit.USD]: (v) => v,
514
517
  [CurrencyUnit.MXN]: (v) => v,
515
- [CurrencyUnit.PHP]: (v) => v
518
+ [CurrencyUnit.PHP]: (v) => v,
519
+ [CurrencyUnit.EUR]: (v) => v
516
520
  };
517
521
  var toBitcoinConversion = (v, unitsPerBtc = 1) => round(v * unitsPerBtc);
518
522
  var toMicrobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e6 * unitsPerBtc);
@@ -530,7 +534,8 @@ var CONVERSION_MAP = {
530
534
  [CurrencyUnit.SATOSHI]: (v) => v * 1e8,
531
535
  [CurrencyUnit.USD]: toBitcoinConversion,
532
536
  [CurrencyUnit.MXN]: toBitcoinConversion,
533
- [CurrencyUnit.PHP]: toBitcoinConversion
537
+ [CurrencyUnit.PHP]: toBitcoinConversion,
538
+ [CurrencyUnit.EUR]: toBitcoinConversion
534
539
  },
535
540
  [CurrencyUnit.MICROBITCOIN]: {
536
541
  [CurrencyUnit.BITCOIN]: (v) => v / 1e6,
@@ -541,7 +546,8 @@ var CONVERSION_MAP = {
541
546
  [CurrencyUnit.SATOSHI]: (v) => v * 100,
542
547
  [CurrencyUnit.USD]: toMicrobitcoinConversion,
543
548
  [CurrencyUnit.MXN]: toMicrobitcoinConversion,
544
- [CurrencyUnit.PHP]: toMicrobitcoinConversion
549
+ [CurrencyUnit.PHP]: toMicrobitcoinConversion,
550
+ [CurrencyUnit.EUR]: toMicrobitcoinConversion
545
551
  },
546
552
  [CurrencyUnit.MILLIBITCOIN]: {
547
553
  [CurrencyUnit.BITCOIN]: (v) => v / 1e3,
@@ -552,7 +558,8 @@ var CONVERSION_MAP = {
552
558
  [CurrencyUnit.SATOSHI]: (v) => v * 1e5,
553
559
  [CurrencyUnit.USD]: toMillibitcoinConversion,
554
560
  [CurrencyUnit.MXN]: toMillibitcoinConversion,
555
- [CurrencyUnit.PHP]: toMillibitcoinConversion
561
+ [CurrencyUnit.PHP]: toMillibitcoinConversion,
562
+ [CurrencyUnit.EUR]: toMillibitcoinConversion
556
563
  },
557
564
  [CurrencyUnit.MILLISATOSHI]: {
558
565
  [CurrencyUnit.BITCOIN]: (v) => v / 1e11,
@@ -563,7 +570,8 @@ var CONVERSION_MAP = {
563
570
  [CurrencyUnit.SATOSHI]: (v) => v / 1e3,
564
571
  [CurrencyUnit.USD]: toMillisatoshiConversion,
565
572
  [CurrencyUnit.MXN]: toMillisatoshiConversion,
566
- [CurrencyUnit.PHP]: toMillisatoshiConversion
573
+ [CurrencyUnit.PHP]: toMillisatoshiConversion,
574
+ [CurrencyUnit.EUR]: toMillisatoshiConversion
567
575
  },
568
576
  [CurrencyUnit.NANOBITCOIN]: {
569
577
  [CurrencyUnit.BITCOIN]: (v) => v / 1e9,
@@ -574,7 +582,8 @@ var CONVERSION_MAP = {
574
582
  [CurrencyUnit.SATOSHI]: (v) => v / 10,
575
583
  [CurrencyUnit.USD]: toNanobitcoinConversion,
576
584
  [CurrencyUnit.MXN]: toNanobitcoinConversion,
577
- [CurrencyUnit.PHP]: toNanobitcoinConversion
585
+ [CurrencyUnit.PHP]: toNanobitcoinConversion,
586
+ [CurrencyUnit.EUR]: toNanobitcoinConversion
578
587
  },
579
588
  [CurrencyUnit.SATOSHI]: {
580
589
  [CurrencyUnit.BITCOIN]: (v) => v / 1e8,
@@ -585,11 +594,13 @@ var CONVERSION_MAP = {
585
594
  [CurrencyUnit.SATOSHI]: (v) => v,
586
595
  [CurrencyUnit.USD]: toSatoshiConversion,
587
596
  [CurrencyUnit.MXN]: toSatoshiConversion,
588
- [CurrencyUnit.PHP]: toSatoshiConversion
597
+ [CurrencyUnit.PHP]: toSatoshiConversion,
598
+ [CurrencyUnit.EUR]: toSatoshiConversion
589
599
  },
590
600
  [CurrencyUnit.USD]: standardUnitConversionObj,
591
601
  [CurrencyUnit.MXN]: standardUnitConversionObj,
592
- [CurrencyUnit.PHP]: standardUnitConversionObj
602
+ [CurrencyUnit.PHP]: standardUnitConversionObj,
603
+ [CurrencyUnit.EUR]: standardUnitConversionObj
593
604
  };
594
605
  function convertCurrencyAmountValue(fromUnit, toUnit, amount, unitsPerBtc = 1) {
595
606
  if (fromUnit === CurrencyUnit.FUTURE_VALUE || toUnit === CurrencyUnit.FUTURE_VALUE) {
@@ -623,6 +634,9 @@ var convertCurrencyAmount = (from, toUnit) => {
623
634
  function isCurrencyAmountInputObj(arg) {
624
635
  return typeof arg === "object" && arg !== null && "value" in arg && (typeof arg.value === "number" || typeof arg.value === "string" || arg.value === null) && "unit" in arg && typeof arg.unit === "string";
625
636
  }
637
+ function isUmaCurrencyAmount(arg) {
638
+ return typeof arg === "object" && arg !== null && "value" in arg && typeof arg.value === "number" && "currency" in arg && typeof arg.currency === "object" && typeof arg.currency.code === "string" && typeof arg.currency.symbol === "string" && typeof arg.currency.name === "string" && typeof arg.currency.decimals === "number";
639
+ }
626
640
  function isDeprecatedCurrencyAmountObj(arg) {
627
641
  return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
628
642
  }
@@ -669,6 +683,7 @@ function convertCurrencyAmountValues(fromUnit, amount, unitsPerBtc = 1, conversi
669
683
  usd: CurrencyUnit.USD,
670
684
  mxn: CurrencyUnit.MXN,
671
685
  php: CurrencyUnit.PHP,
686
+ eur: CurrencyUnit.EUR,
672
687
  mibtc: CurrencyUnit.MICROBITCOIN,
673
688
  mlbtc: CurrencyUnit.MILLIBITCOIN,
674
689
  nbtc: CurrencyUnit.NANOBITCOIN
@@ -707,7 +722,7 @@ function getPreferredConversionOverride(currencyAmountArg) {
707
722
  function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
708
723
  const { value, unit } = getCurrencyAmount(currencyAmountArg);
709
724
  const conversionOverride = getPreferredConversionOverride(currencyAmountArg);
710
- const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
725
+ const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc, eur } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
711
726
  const mapWithCurrencyUnits = {
712
727
  [CurrencyUnit.BITCOIN]: btc,
713
728
  [CurrencyUnit.SATOSHI]: sats,
@@ -715,6 +730,7 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
715
730
  [CurrencyUnit.USD]: usd,
716
731
  [CurrencyUnit.MXN]: mxn,
717
732
  [CurrencyUnit.PHP]: php,
733
+ [CurrencyUnit.EUR]: eur,
718
734
  [CurrencyUnit.MICROBITCOIN]: mibtc,
719
735
  [CurrencyUnit.MILLIBITCOIN]: mlbtc,
720
736
  [CurrencyUnit.NANOBITCOIN]: nbtc,
@@ -756,6 +772,10 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
756
772
  value: php,
757
773
  unit: CurrencyUnit.PHP
758
774
  }),
775
+ [CurrencyUnit.EUR]: formatCurrencyStr({
776
+ value: eur,
777
+ unit: CurrencyUnit.EUR
778
+ }),
759
779
  [CurrencyUnit.FUTURE_VALUE]: "-"
760
780
  }
761
781
  };
@@ -820,6 +840,8 @@ var abbrCurrencyUnit = (unit) => {
820
840
  return "MXN";
821
841
  case CurrencyUnit.PHP:
822
842
  return "PHP";
843
+ case CurrencyUnit.EUR:
844
+ return "EUR";
823
845
  }
824
846
  return "Unsupported CurrencyUnit";
825
847
  };
@@ -835,16 +857,27 @@ function formatCurrencyStr(amount, options) {
835
857
  ...defaultOptions,
836
858
  ...options
837
859
  };
838
- const currencyAmount = getCurrencyAmount(amount);
839
- let { value: num } = currencyAmount;
840
- const { unit } = currencyAmount;
841
- const centCurrencies = [
842
- CurrencyUnit.USD,
843
- CurrencyUnit.MXN,
844
- CurrencyUnit.PHP
845
- ];
846
- if (centCurrencies.includes(unit)) {
847
- num = num / 100;
860
+ let num;
861
+ let unit;
862
+ if (isUmaCurrencyAmount(amount)) {
863
+ num = amount.value;
864
+ unit = amount.currency.code;
865
+ if (amount.currency.decimals > 0) {
866
+ num = amount.value / Math.pow(10, amount.currency.decimals);
867
+ }
868
+ } else {
869
+ const currencyAmount = getCurrencyAmount(amount);
870
+ num = currencyAmount.value;
871
+ unit = currencyAmount.unit;
872
+ const centCurrencies = [
873
+ CurrencyUnit.USD,
874
+ CurrencyUnit.MXN,
875
+ CurrencyUnit.PHP,
876
+ CurrencyUnit.EUR
877
+ ];
878
+ if (centCurrencies.includes(unit)) {
879
+ num = num / 100;
880
+ }
848
881
  }
849
882
  function getDefaultMaxFractionDigits(defaultDigits, fullPrecisionDigits) {
850
883
  let digits = defaultDigits;
@@ -857,21 +890,22 @@ function formatCurrencyStr(amount, options) {
857
890
  }
858
891
  return digits;
859
892
  }
860
- const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI ? "\uE902" : "";
893
+ const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI || unit === abbrCurrencyUnit(CurrencyUnit.SATOSHI) ? "\uE902" : "";
861
894
  const currentLocale = getCurrentLocale();
862
- let formattedStr = "";
863
- switch (unit) {
864
- case CurrencyUnit.MXN:
865
- case CurrencyUnit.USD:
866
- case CurrencyUnit.PHP:
867
- formattedStr = num.toLocaleString(currentLocale, {
895
+ function isFormattableFiatCurrencyCode(currencyCode) {
896
+ try {
897
+ new Intl.NumberFormat(currentLocale, {
868
898
  style: "currency",
869
- currency: unit,
870
- currencyDisplay: "narrowSymbol",
871
- notation: compact ? "compact" : void 0,
872
- maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
899
+ currency: currencyCode
873
900
  });
874
- break;
901
+ return true;
902
+ } catch (e) {
903
+ return false;
904
+ }
905
+ }
906
+ let formattedStr = "";
907
+ let forceAppendUnits = false;
908
+ switch (unit) {
875
909
  case CurrencyUnit.BITCOIN:
876
910
  formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
877
911
  notation: compact ? "compact" : void 0,
@@ -879,6 +913,7 @@ function formatCurrencyStr(amount, options) {
879
913
  })}`;
880
914
  break;
881
915
  case CurrencyUnit.SATOSHI:
916
+ case abbrCurrencyUnit(CurrencyUnit.SATOSHI):
882
917
  formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
883
918
  notation: compact ? "compact" : void 0,
884
919
  maximumFractionDigits: getDefaultMaxFractionDigits(0, 3)
@@ -888,21 +923,35 @@ function formatCurrencyStr(amount, options) {
888
923
  case CurrencyUnit.MICROBITCOIN:
889
924
  case CurrencyUnit.MILLIBITCOIN:
890
925
  case CurrencyUnit.NANOBITCOIN:
891
- default:
892
926
  formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
893
927
  notation: compact ? "compact" : void 0,
894
928
  maximumFractionDigits: getDefaultMaxFractionDigits(0, 0)
895
929
  })}`;
930
+ break;
931
+ default:
932
+ if (isFormattableFiatCurrencyCode(unit)) {
933
+ formattedStr = num.toLocaleString(currentLocale, {
934
+ style: "currency",
935
+ currency: unit,
936
+ currencyDisplay: "narrowSymbol",
937
+ notation: compact ? "compact" : void 0,
938
+ maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
939
+ });
940
+ } else {
941
+ formattedStr = `${num}`;
942
+ forceAppendUnits = true;
943
+ }
944
+ break;
896
945
  }
897
- if (options?.appendUnits) {
946
+ if (options?.appendUnits || forceAppendUnits) {
898
947
  const localeCurrencyCode = localeToCurrencyCode(currentLocale);
899
- if (unit === localeCurrencyCode && !options.appendUnits.showForCurrentLocaleUnit) {
948
+ if (unit === localeCurrencyCode && options?.appendUnits && !options.appendUnits.showForCurrentLocaleUnit) {
900
949
  return formattedStr;
901
950
  }
902
- const unitStr = abbrCurrencyUnit(unit);
903
- const unitSuffix = options.appendUnits.plural && num > 1 ? "s" : "";
951
+ const unitStr = isUmaCurrencyAmount(amount) ? amount.currency.code : abbrCurrencyUnit(unit);
952
+ const unitSuffix = options?.appendUnits?.plural && num > 1 ? "s" : "";
904
953
  const unitStrWithSuffix = `${unitStr}${unitSuffix}`;
905
- formattedStr += ` ${options.appendUnits.lowercase ? unitStrWithSuffix.toLowerCase() : unitStrWithSuffix}`;
954
+ formattedStr += ` ${options?.appendUnits?.lowercase ? unitStrWithSuffix.toLowerCase() : unitStrWithSuffix}`;
906
955
  }
907
956
  return formattedStr;
908
957
  }
@@ -1127,6 +1176,9 @@ var isType = (typename) => (node) => {
1127
1176
  function notNullUndefined(value) {
1128
1177
  return value !== null && value !== void 0;
1129
1178
  }
1179
+ function isRecord(value) {
1180
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1181
+ }
1130
1182
  // Annotate the CommonJS export names for ESM import in node:
1131
1183
  0 && (module.exports = {
1132
1184
  CurrencyUnit,
@@ -1162,10 +1214,12 @@ function notNullUndefined(value) {
1162
1214
  isNode,
1163
1215
  isNumber,
1164
1216
  isObject,
1217
+ isRecord,
1165
1218
  isSDKCurrencyAmount,
1166
1219
  isTest,
1167
1220
  isType,
1168
1221
  isUint8Array,
1222
+ isUmaCurrencyAmount,
1169
1223
  linearInterpolate,
1170
1224
  localeToCurrencyCode,
1171
1225
  localeToCurrencySymbol,
@@ -1 +1 @@
1
- export { A as AppendUnitsOptions, a7 as ById, ah as Complete, n as CurrencyAmountArg, k as CurrencyAmountInputObj, l as CurrencyAmountObj, m as CurrencyAmountPreferenceObj, R as CurrencyCodes, Q as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, aa as DeepPartial, D as DeprecatedCurrencyAmountObj, a6 as ExpandRecursively, ab as JSONLiteral, ad as JSONObject, ac as JSONType, a5 as Maybe, ae as NN, a8 as OmitTypename, ag as PartialBy, ai as RequiredKeys, S as SDKCurrencyAmountType, x as abbrCurrencyUnit, b as b64decode, a as b64encode, M as bytesToHex, Y as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, P as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, X as deleteLocalStorageItem, e as ensureArray, L as errorToJSON, y as formatCurrencyStr, t as getCurrencyAmount, O as getCurrentLocale, J as getErrorMsg, V as getLocalStorageBoolean, U as getLocalStorageConfigItem, N as hexToBytes, E as isBrowser, o as isCurrencyAmountInputObj, q as isCurrencyAmountObj, r as isCurrencyAmountPreferenceObj, w as isCurrencyMap, p as isDeprecatedCurrencyAmountObj, H as isError, K as isErrorMsg, I as isErrorWithMessage, F as isNode, $ as isNumber, a4 as isObject, s as isSDKCurrencyAmount, G as isTest, a9 as isType, a3 as isUint8Array, Z as linearInterpolate, T as localeToCurrencyCode, B as localeToCurrencySymbol, a2 as lsidToUUID, v as mapCurrencyAmount, af as notNullUndefined, a0 as pollUntil, _ as round, z as separateCurrencyStrParts, W as setLocalStorageBoolean, a1 as sleep, u as urlsafe_b64decode } from '../index-r0bUxDu_.cjs';
1
+ export { A as AppendUnitsOptions, aa as ById, al as Complete, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, V as CurrencyCodes, T as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, ae as DeepPartial, D as DeprecatedCurrencyAmountObj, a9 as ExpandRecursively, ad as ExtractByTypename, af as JSONLiteral, ah as JSONObject, ag as JSONType, a8 as Maybe, ai as NN, ab as OmitTypename, ak as PartialBy, am as RequiredKeys, S as SDKCurrencyAmountType, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, O as bytesToHex, $ as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, R as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, _ as deleteLocalStorageItem, e as ensureArray, N as errorToJSON, B as formatCurrencyStr, w as getCurrencyAmount, Q as getCurrentLocale, L as getErrorMsg, Y as getLocalStorageBoolean, X as getLocalStorageConfigItem, P as hexToBytes, G as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, J as isError, M as isErrorMsg, K as isErrorWithMessage, H as isNode, a2 as isNumber, a7 as isObject, an as isRecord, v as isSDKCurrencyAmount, I as isTest, ac as isType, a6 as isUint8Array, q as isUmaCurrencyAmount, a0 as linearInterpolate, W as localeToCurrencyCode, F as localeToCurrencySymbol, a5 as lsidToUUID, x as mapCurrencyAmount, aj as notNullUndefined, a3 as pollUntil, a1 as round, E as separateCurrencyStrParts, Z as setLocalStorageBoolean, a4 as sleep, u as urlsafe_b64decode } from '../index-C7dqDM91.cjs';
@@ -1 +1 @@
1
- export { A as AppendUnitsOptions, a7 as ById, ah as Complete, n as CurrencyAmountArg, k as CurrencyAmountInputObj, l as CurrencyAmountObj, m as CurrencyAmountPreferenceObj, R as CurrencyCodes, Q as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, aa as DeepPartial, D as DeprecatedCurrencyAmountObj, a6 as ExpandRecursively, ab as JSONLiteral, ad as JSONObject, ac as JSONType, a5 as Maybe, ae as NN, a8 as OmitTypename, ag as PartialBy, ai as RequiredKeys, S as SDKCurrencyAmountType, x as abbrCurrencyUnit, b as b64decode, a as b64encode, M as bytesToHex, Y as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, P as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, X as deleteLocalStorageItem, e as ensureArray, L as errorToJSON, y as formatCurrencyStr, t as getCurrencyAmount, O as getCurrentLocale, J as getErrorMsg, V as getLocalStorageBoolean, U as getLocalStorageConfigItem, N as hexToBytes, E as isBrowser, o as isCurrencyAmountInputObj, q as isCurrencyAmountObj, r as isCurrencyAmountPreferenceObj, w as isCurrencyMap, p as isDeprecatedCurrencyAmountObj, H as isError, K as isErrorMsg, I as isErrorWithMessage, F as isNode, $ as isNumber, a4 as isObject, s as isSDKCurrencyAmount, G as isTest, a9 as isType, a3 as isUint8Array, Z as linearInterpolate, T as localeToCurrencyCode, B as localeToCurrencySymbol, a2 as lsidToUUID, v as mapCurrencyAmount, af as notNullUndefined, a0 as pollUntil, _ as round, z as separateCurrencyStrParts, W as setLocalStorageBoolean, a1 as sleep, u as urlsafe_b64decode } from '../index-r0bUxDu_.js';
1
+ export { A as AppendUnitsOptions, aa as ById, al as Complete, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, V as CurrencyCodes, T as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, ae as DeepPartial, D as DeprecatedCurrencyAmountObj, a9 as ExpandRecursively, ad as ExtractByTypename, af as JSONLiteral, ah as JSONObject, ag as JSONType, a8 as Maybe, ai as NN, ab as OmitTypename, ak as PartialBy, am as RequiredKeys, S as SDKCurrencyAmountType, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, O as bytesToHex, $ as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, R as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, _ as deleteLocalStorageItem, e as ensureArray, N as errorToJSON, B as formatCurrencyStr, w as getCurrencyAmount, Q as getCurrentLocale, L as getErrorMsg, Y as getLocalStorageBoolean, X as getLocalStorageConfigItem, P as hexToBytes, G as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, J as isError, M as isErrorMsg, K as isErrorWithMessage, H as isNode, a2 as isNumber, a7 as isObject, an as isRecord, v as isSDKCurrencyAmount, I as isTest, ac as isType, a6 as isUint8Array, q as isUmaCurrencyAmount, a0 as linearInterpolate, W as localeToCurrencyCode, F as localeToCurrencySymbol, a5 as lsidToUUID, x as mapCurrencyAmount, aj as notNullUndefined, a3 as pollUntil, a1 as round, E as separateCurrencyStrParts, Z as setLocalStorageBoolean, a4 as sleep, u as urlsafe_b64decode } from '../index-C7dqDM91.js';
@@ -32,10 +32,12 @@ import {
32
32
  isNode,
33
33
  isNumber,
34
34
  isObject,
35
+ isRecord,
35
36
  isSDKCurrencyAmount,
36
37
  isTest,
37
38
  isType,
38
39
  isUint8Array,
40
+ isUmaCurrencyAmount,
39
41
  linearInterpolate,
40
42
  localeToCurrencyCode,
41
43
  localeToCurrencySymbol,
@@ -48,7 +50,7 @@ import {
48
50
  setLocalStorageBoolean,
49
51
  sleep,
50
52
  urlsafe_b64decode
51
- } from "../chunk-NY4EJZNK.js";
53
+ } from "../chunk-23SS5EX2.js";
52
54
  export {
53
55
  CurrencyUnit,
54
56
  abbrCurrencyUnit,
@@ -83,10 +85,12 @@ export {
83
85
  isNode,
84
86
  isNumber,
85
87
  isObject,
88
+ isRecord,
86
89
  isSDKCurrencyAmount,
87
90
  isTest,
88
91
  isType,
89
92
  isUint8Array,
93
+ isUmaCurrencyAmount,
90
94
  linearInterpolate,
91
95
  localeToCurrencyCode,
92
96
  localeToCurrencySymbol,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/core",
3
- "version": "1.2.7",
3
+ "version": "1.3.0",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -19,32 +19,17 @@
19
19
  "url": "https://github.com/lightsparkdev/js-sdk/issues"
20
20
  },
21
21
  "type": "module",
22
- "main": "./dist/index.js",
22
+ "main": "./dist/index.cjs",
23
23
  "module": "./dist/index.js",
24
24
  "types": "./dist/index.d.ts",
25
25
  "exports": {
26
26
  ".": {
27
- "types": "./dist/index.d.ts",
28
- "import": {
29
- "types": "./dist/index.d.ts",
30
- "default": "./dist/index.js"
31
- },
32
- "require": {
33
- "types": "./dist/index.d.ts",
34
- "default": "./dist/index.cjs"
35
- }
27
+ "import": "./dist/index.js",
28
+ "require": "./dist/index.cjs"
36
29
  },
37
30
  "./utils": {
38
- "types": "./dist/utils/index.d.ts",
39
- "import": {
40
- "types": "./dist/utils/index.d.ts",
41
- "default": "./dist/utils/index.js"
42
- },
43
- "module": "./dist/utils/index.js",
44
- "require": {
45
- "types": "./dist/utils/index.d.ts",
46
- "default": "./dist/utils/index.cjs"
47
- }
31
+ "import": "./dist/utils/index.js",
32
+ "require": "./dist/utils/index.cjs"
48
33
  }
49
34
  },
50
35
  "browser": {
@@ -65,6 +50,7 @@
65
50
  "lint:fix": "eslint --fix .",
66
51
  "lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
67
52
  "lint": "eslint .",
53
+ "package-types": "yarn attw --pack .",
68
54
  "postversion": "yarn build",
69
55
  "test": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail src/**/tests/**/*.test.ts",
70
56
  "types:watch": "tsc-absolute --watch",
@@ -81,6 +67,7 @@
81
67
  "zen-observable-ts": "^1.1.0"
82
68
  },
83
69
  "devDependencies": {
70
+ "@arethetypeswrong/cli": "^0.17.4",
84
71
  "@lightsparkdev/eslint-config": "*",
85
72
  "@lightsparkdev/tsconfig": "0.0.1",
86
73
  "@types/crypto-js": "^4.1.1",
@@ -15,6 +15,7 @@ import StubAuthProvider from "../auth/StubAuthProvider.js";
15
15
  import type { CryptoInterface } from "../crypto/crypto.js";
16
16
  import { DefaultCrypto, LightsparkSigningException } from "../crypto/crypto.js";
17
17
  import type NodeKeyCache from "../crypto/NodeKeyCache.js";
18
+ import type { SigningKey } from "../crypto/SigningKey.js";
18
19
  import LightsparkException from "../LightsparkException.js";
19
20
  import { logger } from "../Logger.js";
20
21
  import { b64encode } from "../utils/base64.js";
@@ -40,6 +41,8 @@ class Requester {
40
41
  private readonly authProvider: AuthProvider = new StubAuthProvider(),
41
42
  private readonly baseUrl: string = DEFAULT_BASE_URL,
42
43
  private readonly cryptoImpl: CryptoInterface = DefaultCrypto,
44
+ private readonly signingKey?: SigningKey,
45
+ private readonly fetchImpl: typeof fetch = fetch,
43
46
  ) {
44
47
  let websocketImpl;
45
48
  if (typeof WebSocket === "undefined" && typeof window === "undefined") {
@@ -188,7 +191,7 @@ class Requester {
188
191
  variables,
189
192
  headers,
190
193
  });
191
- const response = await fetch(url, {
194
+ const response = await this.fetchImpl(url, {
192
195
  method: "POST",
193
196
  headers,
194
197
  body: bodyData,
@@ -248,7 +251,7 @@ class Requester {
248
251
  expires_at: expiration,
249
252
  };
250
253
 
251
- const key = this.nodeKeyCache.getKey(signingNodeId);
254
+ const key = this.signingKey ?? this.nodeKeyCache.getKey(signingNodeId);
252
255
  if (!key) {
253
256
  throw new LightsparkSigningException(
254
257
  "Missing node of encrypted_signing_private_key",