@lightsparkdev/core 1.0.20 → 1.0.22

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/dist/index.cjs CHANGED
@@ -67,7 +67,6 @@ __export(src_exports, {
67
67
  getLocalStorageConfigItem: () => getLocalStorageConfigItem,
68
68
  hexToBytes: () => hexToBytes,
69
69
  isBrowser: () => isBrowser,
70
- isCurrencyAmount: () => isCurrencyAmount,
71
70
  isCurrencyAmountObj: () => isCurrencyAmountObj,
72
71
  isCurrencyMap: () => isCurrencyMap,
73
72
  isError: () => isError,
@@ -75,6 +74,7 @@ __export(src_exports, {
75
74
  isErrorWithMessage: () => isErrorWithMessage,
76
75
  isNode: () => isNode,
77
76
  isNumber: () => isNumber,
77
+ isSDKCurrencyAmount: () => isSDKCurrencyAmount,
78
78
  isTest: () => isTest,
79
79
  isType: () => isType,
80
80
  isUint8Array: () => isUint8Array,
@@ -83,6 +83,7 @@ __export(src_exports, {
83
83
  localeToCurrencySymbol: () => localeToCurrencySymbol,
84
84
  lsidToUUID: () => lsidToUUID,
85
85
  mapCurrencyAmount: () => mapCurrencyAmount,
86
+ notNullUndefined: () => notNullUndefined,
86
87
  pollUntil: () => pollUntil,
87
88
  round: () => round,
88
89
  separateCurrencyStrParts: () => separateCurrencyStrParts,
@@ -452,8 +453,10 @@ var serializeSigningKey = async (key, format) => {
452
453
  );
453
454
  };
454
455
  var getNonce = async () => {
455
- const nonceSt = await getRandomValues32(new Uint32Array(1));
456
- 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);
457
460
  };
458
461
  var sign = async (keyOrAlias, data) => {
459
462
  if (typeof keyOrAlias === "string") {
@@ -833,102 +836,108 @@ function isNumber(value) {
833
836
 
834
837
  // src/utils/currency.ts
835
838
  var defaultCurrencyCode = "USD";
836
- var CurrencyUnit = /* @__PURE__ */ ((CurrencyUnit2) => {
837
- CurrencyUnit2["FUTURE_VALUE"] = "FUTURE_VALUE";
838
- CurrencyUnit2["BITCOIN"] = "BITCOIN";
839
- CurrencyUnit2["SATOSHI"] = "SATOSHI";
840
- CurrencyUnit2["MILLISATOSHI"] = "MILLISATOSHI";
841
- CurrencyUnit2["USD"] = "USD";
842
- CurrencyUnit2["NANOBITCOIN"] = "NANOBITCOIN";
843
- CurrencyUnit2["MICROBITCOIN"] = "MICROBITCOIN";
844
- CurrencyUnit2["MILLIBITCOIN"] = "MILLIBITCOIN";
845
- return CurrencyUnit2;
846
- })(CurrencyUnit || {});
839
+ var CurrencyUnit = {
840
+ FUTURE_VALUE: "FUTURE_VALUE",
841
+ BITCOIN: "BITCOIN",
842
+ SATOSHI: "SATOSHI",
843
+ MILLISATOSHI: "MILLISATOSHI",
844
+ USD: "USD",
845
+ NANOBITCOIN: "NANOBITCOIN",
846
+ MICROBITCOIN: "MICROBITCOIN",
847
+ MILLIBITCOIN: "MILLIBITCOIN",
848
+ Bitcoin: "BITCOIN",
849
+ Microbitcoin: "MICROBITCOIN",
850
+ Millibitcoin: "MILLIBITCOIN",
851
+ Millisatoshi: "MILLISATOSHI",
852
+ Nanobitcoin: "NANOBITCOIN",
853
+ Satoshi: "SATOSHI",
854
+ Usd: "USD"
855
+ };
847
856
  var CONVERSION_MAP = {
848
- ["BITCOIN" /* BITCOIN */]: {
849
- ["BITCOIN" /* BITCOIN */]: (v) => v,
850
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v * 1e6,
851
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => v * 1e3,
852
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e11,
853
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 1e9,
854
- ["SATOSHI" /* SATOSHI */]: (v) => v * 1e8,
855
- ["USD" /* USD */]: (v, centsPerBtc = 1) => (
857
+ [CurrencyUnit.BITCOIN]: {
858
+ [CurrencyUnit.BITCOIN]: (v) => v,
859
+ [CurrencyUnit.MICROBITCOIN]: (v) => v * 1e6,
860
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v * 1e3,
861
+ [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e11,
862
+ [CurrencyUnit.NANOBITCOIN]: (v) => v * 1e9,
863
+ [CurrencyUnit.SATOSHI]: (v) => v * 1e8,
864
+ [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
856
865
  /* Round without decimals since we're returning cents: */
857
866
  round(v * centsPerBtc, 2)
858
867
  )
859
868
  },
860
- ["MICROBITCOIN" /* MICROBITCOIN */]: {
861
- ["BITCOIN" /* BITCOIN */]: (v) => v / 1e6,
862
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v,
863
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => v / 1e3,
864
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e5,
865
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 1e3,
866
- ["SATOSHI" /* SATOSHI */]: (v) => v * 100,
867
- ["USD" /* USD */]: (v, centsPerBtc = 1) => (
869
+ [CurrencyUnit.MICROBITCOIN]: {
870
+ [CurrencyUnit.BITCOIN]: (v) => v / 1e6,
871
+ [CurrencyUnit.MICROBITCOIN]: (v) => v,
872
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v / 1e3,
873
+ [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e5,
874
+ [CurrencyUnit.NANOBITCOIN]: (v) => v * 1e3,
875
+ [CurrencyUnit.SATOSHI]: (v) => v * 100,
876
+ [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
868
877
  /* Round without decimals since we're returning cents: */
869
878
  round(v / 1e6 * centsPerBtc)
870
879
  )
871
880
  },
872
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: {
873
- ["BITCOIN" /* BITCOIN */]: (v) => v / 1e3,
874
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v * 1e3,
875
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => v,
876
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e8,
877
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 1e6,
878
- ["SATOSHI" /* SATOSHI */]: (v) => v * 1e5,
879
- ["USD" /* USD */]: (v, centsPerBtc = 1) => (
881
+ [CurrencyUnit.MILLIBITCOIN]: {
882
+ [CurrencyUnit.BITCOIN]: (v) => v / 1e3,
883
+ [CurrencyUnit.MICROBITCOIN]: (v) => v * 1e3,
884
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v,
885
+ [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e8,
886
+ [CurrencyUnit.NANOBITCOIN]: (v) => v * 1e6,
887
+ [CurrencyUnit.SATOSHI]: (v) => v * 1e5,
888
+ [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
880
889
  /* Round without decimals since we're returning cents: */
881
890
  round(v / 1e3 * centsPerBtc)
882
891
  )
883
892
  },
884
- ["MILLISATOSHI" /* MILLISATOSHI */]: {
885
- ["BITCOIN" /* BITCOIN */]: (v) => v / 1e11,
886
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v / 1e5,
887
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => v / 1e8,
888
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v,
889
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v / 100,
890
- ["SATOSHI" /* SATOSHI */]: (v) => v / 1e3,
891
- ["USD" /* USD */]: (v, centsPerBtc = 1) => (
893
+ [CurrencyUnit.MILLISATOSHI]: {
894
+ [CurrencyUnit.BITCOIN]: (v) => v / 1e11,
895
+ [CurrencyUnit.MICROBITCOIN]: (v) => v / 1e5,
896
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v / 1e8,
897
+ [CurrencyUnit.MILLISATOSHI]: (v) => v,
898
+ [CurrencyUnit.NANOBITCOIN]: (v) => v / 100,
899
+ [CurrencyUnit.SATOSHI]: (v) => v / 1e3,
900
+ [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
892
901
  /* Round without decimals since we're returning cents: */
893
902
  round(v / 1e11 * centsPerBtc)
894
903
  )
895
904
  },
896
- ["NANOBITCOIN" /* NANOBITCOIN */]: {
897
- ["BITCOIN" /* BITCOIN */]: (v) => v / 1e9,
898
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v / 1e3,
899
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => v / 1e6,
900
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 100,
901
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v,
902
- ["SATOSHI" /* SATOSHI */]: (v) => v / 10,
903
- ["USD" /* USD */]: (v, centsPerBtc = 1) => (
905
+ [CurrencyUnit.NANOBITCOIN]: {
906
+ [CurrencyUnit.BITCOIN]: (v) => v / 1e9,
907
+ [CurrencyUnit.MICROBITCOIN]: (v) => v / 1e3,
908
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v / 1e6,
909
+ [CurrencyUnit.MILLISATOSHI]: (v) => v * 100,
910
+ [CurrencyUnit.NANOBITCOIN]: (v) => v,
911
+ [CurrencyUnit.SATOSHI]: (v) => v / 10,
912
+ [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
904
913
  /* Round without decimals since we're returning cents: */
905
914
  round(v / 1e9 * centsPerBtc)
906
915
  )
907
916
  },
908
- ["SATOSHI" /* SATOSHI */]: {
909
- ["BITCOIN" /* BITCOIN */]: (v) => v / 1e8,
910
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v / 100,
911
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => v / 1e5,
912
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e3,
913
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 10,
914
- ["SATOSHI" /* SATOSHI */]: (v) => v,
915
- ["USD" /* USD */]: (v, centsPerBtc = 1) => (
917
+ [CurrencyUnit.SATOSHI]: {
918
+ [CurrencyUnit.BITCOIN]: (v) => v / 1e8,
919
+ [CurrencyUnit.MICROBITCOIN]: (v) => v / 100,
920
+ [CurrencyUnit.MILLIBITCOIN]: (v) => v / 1e5,
921
+ [CurrencyUnit.MILLISATOSHI]: (v) => v * 1e3,
922
+ [CurrencyUnit.NANOBITCOIN]: (v) => v * 10,
923
+ [CurrencyUnit.SATOSHI]: (v) => v,
924
+ [CurrencyUnit.USD]: (v, centsPerBtc = 1) => (
916
925
  /* Round without decimals since we're returning cents: */
917
926
  round(v / 1e8 * centsPerBtc)
918
927
  )
919
928
  },
920
- ["USD" /* USD */]: {
921
- ["BITCOIN" /* BITCOIN */]: (v, centsPerBtc = 1) => v / centsPerBtc,
922
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e6,
923
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e3,
924
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e11,
925
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e9,
926
- ["SATOSHI" /* SATOSHI */]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e8,
927
- ["USD" /* USD */]: (v) => v
929
+ [CurrencyUnit.USD]: {
930
+ [CurrencyUnit.BITCOIN]: (v, centsPerBtc = 1) => v / centsPerBtc,
931
+ [CurrencyUnit.MICROBITCOIN]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e6,
932
+ [CurrencyUnit.MILLIBITCOIN]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e3,
933
+ [CurrencyUnit.MILLISATOSHI]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e11,
934
+ [CurrencyUnit.NANOBITCOIN]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e9,
935
+ [CurrencyUnit.SATOSHI]: (v, centsPerBtc = 1) => v / centsPerBtc * 1e8,
936
+ [CurrencyUnit.USD]: (v) => v
928
937
  }
929
938
  };
930
939
  function convertCurrencyAmountValue(fromUnit, toUnit, amount, centsPerBtc = 1) {
931
- if (fromUnit === "FUTURE_VALUE" /* FUTURE_VALUE */ || toUnit === "FUTURE_VALUE" /* FUTURE_VALUE */) {
940
+ if (fromUnit === CurrencyUnit.FUTURE_VALUE || toUnit === CurrencyUnit.FUTURE_VALUE) {
932
941
  throw new LightsparkException_default("CurrencyError", `Unsupported CurrencyUnit.`);
933
942
  }
934
943
  if (fromUnit === toUnit) {
@@ -959,8 +968,9 @@ var convertCurrencyAmount = (from, toUnit) => {
959
968
  function isCurrencyAmountObj(arg) {
960
969
  return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
961
970
  }
962
- function isCurrencyAmount(arg) {
963
- return typeof arg === "object" && arg !== null && "originalValue" in arg && "originalUnit" in arg && "preferredCurrencyUnit" in arg && "preferredCurrencyValueRounded" in arg && "preferredCurrencyValueApprox" in arg;
971
+ function isSDKCurrencyAmount(arg) {
972
+ return typeof arg === "object" && arg !== null && /* We can expect all SDK CurrencyAmount types to always have these exact properties: */
973
+ "originalValue" in arg && "originalUnit" in arg && "preferredCurrencyUnit" in arg && "preferredCurrencyValueRounded" in arg && "preferredCurrencyValueApprox" in arg;
964
974
  }
965
975
  function asNumber(value) {
966
976
  if (typeof value === "string") {
@@ -971,67 +981,67 @@ function asNumber(value) {
971
981
  function getCurrencyAmount(currencyAmountArg) {
972
982
  let value = 0;
973
983
  let unit = void 0;
974
- if (isCurrencyAmountObj(currencyAmountArg)) {
975
- value = asNumber(currencyAmountArg.value);
976
- unit = currencyAmountArg.unit;
977
- } else if (isCurrencyAmount(currencyAmountArg)) {
984
+ if (isSDKCurrencyAmount(currencyAmountArg)) {
978
985
  value = currencyAmountArg.originalValue;
979
986
  unit = currencyAmountArg.originalUnit;
987
+ } else if (isCurrencyAmountObj(currencyAmountArg)) {
988
+ value = asNumber(currencyAmountArg.value);
989
+ unit = currencyAmountArg.unit;
980
990
  }
981
991
  return {
982
992
  value: asNumber(value),
983
- unit: unit || "SATOSHI" /* SATOSHI */
993
+ unit: unit || CurrencyUnit.SATOSHI
984
994
  };
985
995
  }
986
996
  function mapCurrencyAmount(currencyAmountArg, centsPerBtc = 1) {
987
997
  const { value, unit } = getCurrencyAmount(currencyAmountArg);
988
998
  const convert = convertCurrencyAmountValue;
989
- const sats = convert(unit, "SATOSHI" /* SATOSHI */, value, centsPerBtc);
990
- const btc = convert(unit, "BITCOIN" /* BITCOIN */, value, centsPerBtc);
991
- const msats = convert(unit, "MILLISATOSHI" /* MILLISATOSHI */, value, centsPerBtc);
992
- const usd = convert(unit, "USD" /* USD */, value, centsPerBtc);
993
- const mibtc = convert(unit, "MICROBITCOIN" /* MICROBITCOIN */, value, centsPerBtc);
994
- const mlbtc = convert(unit, "MILLIBITCOIN" /* MILLIBITCOIN */, value, centsPerBtc);
995
- const nbtc = convert(unit, "NANOBITCOIN" /* NANOBITCOIN */, value, centsPerBtc);
999
+ const sats = convert(unit, CurrencyUnit.SATOSHI, value, centsPerBtc);
1000
+ const btc = convert(unit, CurrencyUnit.BITCOIN, value, centsPerBtc);
1001
+ const msats = convert(unit, CurrencyUnit.MILLISATOSHI, value, centsPerBtc);
1002
+ const usd = convert(unit, CurrencyUnit.USD, value, centsPerBtc);
1003
+ const mibtc = convert(unit, CurrencyUnit.MICROBITCOIN, value, centsPerBtc);
1004
+ const mlbtc = convert(unit, CurrencyUnit.MILLIBITCOIN, value, centsPerBtc);
1005
+ const nbtc = convert(unit, CurrencyUnit.NANOBITCOIN, value, centsPerBtc);
996
1006
  const mapWithCurrencyUnits = {
997
- ["BITCOIN" /* BITCOIN */]: btc,
998
- ["SATOSHI" /* SATOSHI */]: sats,
999
- ["MILLISATOSHI" /* MILLISATOSHI */]: msats,
1000
- ["USD" /* USD */]: usd,
1001
- ["MICROBITCOIN" /* MICROBITCOIN */]: mibtc,
1002
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: mlbtc,
1003
- ["NANOBITCOIN" /* NANOBITCOIN */]: nbtc,
1004
- ["FUTURE_VALUE" /* FUTURE_VALUE */]: NaN,
1007
+ [CurrencyUnit.BITCOIN]: btc,
1008
+ [CurrencyUnit.SATOSHI]: sats,
1009
+ [CurrencyUnit.MILLISATOSHI]: msats,
1010
+ [CurrencyUnit.USD]: usd,
1011
+ [CurrencyUnit.MICROBITCOIN]: mibtc,
1012
+ [CurrencyUnit.MILLIBITCOIN]: mlbtc,
1013
+ [CurrencyUnit.NANOBITCOIN]: nbtc,
1014
+ [CurrencyUnit.FUTURE_VALUE]: NaN,
1005
1015
  formatted: {
1006
- ["BITCOIN" /* BITCOIN */]: formatCurrencyStr({
1016
+ [CurrencyUnit.BITCOIN]: formatCurrencyStr({
1007
1017
  value: btc,
1008
- unit: "BITCOIN" /* BITCOIN */
1018
+ unit: CurrencyUnit.BITCOIN
1009
1019
  }),
1010
- ["SATOSHI" /* SATOSHI */]: formatCurrencyStr({
1020
+ [CurrencyUnit.SATOSHI]: formatCurrencyStr({
1011
1021
  value: sats,
1012
- unit: "SATOSHI" /* SATOSHI */
1022
+ unit: CurrencyUnit.SATOSHI
1013
1023
  }),
1014
- ["MILLISATOSHI" /* MILLISATOSHI */]: formatCurrencyStr({
1024
+ [CurrencyUnit.MILLISATOSHI]: formatCurrencyStr({
1015
1025
  value: msats,
1016
- unit: "MILLISATOSHI" /* MILLISATOSHI */
1026
+ unit: CurrencyUnit.MILLISATOSHI
1017
1027
  }),
1018
- ["MICROBITCOIN" /* MICROBITCOIN */]: formatCurrencyStr({
1028
+ [CurrencyUnit.MICROBITCOIN]: formatCurrencyStr({
1019
1029
  value: mibtc,
1020
- unit: "MICROBITCOIN" /* MICROBITCOIN */
1030
+ unit: CurrencyUnit.MICROBITCOIN
1021
1031
  }),
1022
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: formatCurrencyStr({
1032
+ [CurrencyUnit.MILLIBITCOIN]: formatCurrencyStr({
1023
1033
  value: mlbtc,
1024
- unit: "MILLIBITCOIN" /* MILLIBITCOIN */
1034
+ unit: CurrencyUnit.MILLIBITCOIN
1025
1035
  }),
1026
- ["NANOBITCOIN" /* NANOBITCOIN */]: formatCurrencyStr({
1036
+ [CurrencyUnit.NANOBITCOIN]: formatCurrencyStr({
1027
1037
  value: nbtc,
1028
- unit: "NANOBITCOIN" /* NANOBITCOIN */
1038
+ unit: CurrencyUnit.NANOBITCOIN
1029
1039
  }),
1030
- ["USD" /* USD */]: formatCurrencyStr({
1040
+ [CurrencyUnit.USD]: formatCurrencyStr({
1031
1041
  value: usd,
1032
- unit: "USD" /* USD */
1042
+ unit: CurrencyUnit.USD
1033
1043
  }),
1034
- ["FUTURE_VALUE" /* FUTURE_VALUE */]: "-"
1044
+ [CurrencyUnit.FUTURE_VALUE]: "-"
1035
1045
  }
1036
1046
  };
1037
1047
  return {
@@ -1069,9 +1079,9 @@ function mapCurrencyAmount(currencyAmountArg, centsPerBtc = 1) {
1069
1079
  },
1070
1080
  formatted: {
1071
1081
  ...mapWithCurrencyUnits.formatted,
1072
- btc: mapWithCurrencyUnits.formatted["BITCOIN" /* BITCOIN */],
1073
- sats: mapWithCurrencyUnits.formatted["SATOSHI" /* SATOSHI */],
1074
- msats: mapWithCurrencyUnits.formatted["MILLISATOSHI" /* MILLISATOSHI */]
1082
+ btc: mapWithCurrencyUnits.formatted[CurrencyUnit.BITCOIN],
1083
+ sats: mapWithCurrencyUnits.formatted[CurrencyUnit.SATOSHI],
1084
+ msats: mapWithCurrencyUnits.formatted[CurrencyUnit.MILLISATOSHI]
1075
1085
  },
1076
1086
  type: "CurrencyMap"
1077
1087
  };
@@ -1079,13 +1089,13 @@ function mapCurrencyAmount(currencyAmountArg, centsPerBtc = 1) {
1079
1089
  var isCurrencyMap = (currencyMap) => typeof currencyMap === "object" && currencyMap !== null && "type" in currencyMap && typeof currencyMap.type === "string" && currencyMap.type === "CurrencyMap";
1080
1090
  var abbrCurrencyUnit = (unit) => {
1081
1091
  switch (unit) {
1082
- case "BITCOIN" /* BITCOIN */:
1092
+ case CurrencyUnit.BITCOIN:
1083
1093
  return "BTC";
1084
- case "SATOSHI" /* SATOSHI */:
1094
+ case CurrencyUnit.SATOSHI:
1085
1095
  return "SAT";
1086
- case "MILLISATOSHI" /* MILLISATOSHI */:
1096
+ case CurrencyUnit.MILLISATOSHI:
1087
1097
  return "MSAT";
1088
- case "USD" /* USD */:
1098
+ case CurrencyUnit.USD:
1089
1099
  return "USD";
1090
1100
  }
1091
1101
  return "Unsupported CurrencyUnit";
@@ -1094,33 +1104,33 @@ function formatCurrencyStr(amount, maxFractionDigits, compact, showBtcSymbol = f
1094
1104
  const currencyAmount = getCurrencyAmount(amount);
1095
1105
  let { value: num } = currencyAmount;
1096
1106
  const { unit } = currencyAmount;
1097
- if (unit === "USD" /* USD */) {
1107
+ if (unit === CurrencyUnit.USD) {
1098
1108
  num = num / 100;
1099
1109
  }
1100
1110
  function getDefaultMaxFractionDigits(defaultDigits) {
1101
1111
  return typeof maxFractionDigits === "undefined" ? compact ? 1 : defaultDigits : maxFractionDigits;
1102
1112
  }
1103
- const symbol = !showBtcSymbol ? "" : unit === "BITCOIN" /* BITCOIN */ ? "\uE903" : unit === "SATOSHI" /* SATOSHI */ ? "\uE902" : "";
1113
+ const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI ? "\uE902" : "";
1104
1114
  const currentLocale = getCurrentLocale();
1105
1115
  switch (unit) {
1106
- case "BITCOIN" /* BITCOIN */:
1116
+ case CurrencyUnit.BITCOIN:
1107
1117
  return `${symbol}${num.toLocaleString(currentLocale, {
1108
1118
  notation: compact ? "compact" : void 0,
1109
1119
  maximumFractionDigits: getDefaultMaxFractionDigits(4),
1110
1120
  ...options
1111
1121
  })}`;
1112
- case "MILLISATOSHI" /* MILLISATOSHI */:
1113
- case "SATOSHI" /* SATOSHI */:
1114
- case "MICROBITCOIN" /* MICROBITCOIN */:
1115
- case "MILLIBITCOIN" /* MILLIBITCOIN */:
1116
- case "NANOBITCOIN" /* NANOBITCOIN */:
1122
+ case CurrencyUnit.MILLISATOSHI:
1123
+ case CurrencyUnit.SATOSHI:
1124
+ case CurrencyUnit.MICROBITCOIN:
1125
+ case CurrencyUnit.MILLIBITCOIN:
1126
+ case CurrencyUnit.NANOBITCOIN:
1117
1127
  default:
1118
1128
  return `${symbol}${num.toLocaleString(currentLocale, {
1119
1129
  notation: compact ? "compact" : void 0,
1120
1130
  maximumFractionDigits: getDefaultMaxFractionDigits(0),
1121
1131
  ...options
1122
1132
  })}`;
1123
- case "USD" /* USD */:
1133
+ case CurrencyUnit.USD:
1124
1134
  return num.toLocaleString(currentLocale, {
1125
1135
  style: "currency",
1126
1136
  currency: defaultCurrencyCode,
@@ -1344,6 +1354,9 @@ function isUint8Array(variable) {
1344
1354
  var isType = (typename) => (node) => {
1345
1355
  return node?.__typename === typename;
1346
1356
  };
1357
+ function notNullUndefined(value) {
1358
+ return value !== null && value !== void 0;
1359
+ }
1347
1360
 
1348
1361
  // src/crypto/SigningKey.ts
1349
1362
  function isAlias(key) {
@@ -1672,7 +1685,6 @@ var Requester_default = Requester;
1672
1685
  getLocalStorageConfigItem,
1673
1686
  hexToBytes,
1674
1687
  isBrowser,
1675
- isCurrencyAmount,
1676
1688
  isCurrencyAmountObj,
1677
1689
  isCurrencyMap,
1678
1690
  isError,
@@ -1680,6 +1692,7 @@ var Requester_default = Requester;
1680
1692
  isErrorWithMessage,
1681
1693
  isNode,
1682
1694
  isNumber,
1695
+ isSDKCurrencyAmount,
1683
1696
  isTest,
1684
1697
  isType,
1685
1698
  isUint8Array,
@@ -1688,6 +1701,7 @@ var Requester_default = Requester;
1688
1701
  localeToCurrencySymbol,
1689
1702
  lsidToUUID,
1690
1703
  mapCurrencyAmount,
1704
+ notNullUndefined,
1691
1705
  pollUntil,
1692
1706
  round,
1693
1707
  separateCurrencyStrParts,
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
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, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-324f8ba4.js';
1
+ export { Z as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a0 as DeepPartial, Y as ExpandRecursively, a1 as JSONLiteral, a3 as JSONObject, a2 as JSONType, X as Maybe, a4 as NN, _ as OmitTypename, S as SDKCurrencyAmountType, 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, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, m as isSDKCurrencyAmount, w as isTest, $ as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a5 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from './index-9ecb1570.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 { 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, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-324f8ba4.js';
1
+ export { Z as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a0 as DeepPartial, Y as ExpandRecursively, a1 as JSONLiteral, a3 as JSONObject, a2 as JSONType, X as Maybe, a4 as NN, _ as OmitTypename, S as SDKCurrencyAmountType, 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, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, m as isSDKCurrencyAmount, w as isTest, $ as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a5 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from './index-9ecb1570.js';
2
2
  import { Observable } from 'zen-observable-ts';
3
3
 
4
4
  declare class LightsparkException extends Error {
package/dist/index.js CHANGED
@@ -20,7 +20,6 @@ import {
20
20
  getLocalStorageConfigItem,
21
21
  hexToBytes,
22
22
  isBrowser,
23
- isCurrencyAmount,
24
23
  isCurrencyAmountObj,
25
24
  isCurrencyMap,
26
25
  isError,
@@ -28,6 +27,7 @@ import {
28
27
  isErrorWithMessage,
29
28
  isNode,
30
29
  isNumber,
30
+ isSDKCurrencyAmount,
31
31
  isTest,
32
32
  isType,
33
33
  isUint8Array,
@@ -36,13 +36,14 @@ import {
36
36
  localeToCurrencySymbol,
37
37
  lsidToUUID,
38
38
  mapCurrencyAmount,
39
+ notNullUndefined,
39
40
  pollUntil,
40
41
  round,
41
42
  separateCurrencyStrParts,
42
43
  setLocalStorageBoolean,
43
44
  sleep,
44
45
  urlsafe_b64decode
45
- } from "./chunk-ZPGGNCAE.js";
46
+ } from "./chunk-RC2KOZKZ.js";
46
47
 
47
48
  // src/Logger.ts
48
49
  var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
@@ -342,8 +343,10 @@ var serializeSigningKey = async (key, format) => {
342
343
  );
343
344
  };
344
345
  var getNonce = async () => {
345
- const nonceSt = await getRandomValues32(new Uint32Array(1));
346
- 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);
347
350
  };
348
351
  var sign = async (keyOrAlias, data) => {
349
352
  if (typeof keyOrAlias === "string") {
@@ -715,7 +718,6 @@ export {
715
718
  getLocalStorageConfigItem,
716
719
  hexToBytes,
717
720
  isBrowser,
718
- isCurrencyAmount,
719
721
  isCurrencyAmountObj,
720
722
  isCurrencyMap,
721
723
  isError,
@@ -723,6 +725,7 @@ export {
723
725
  isErrorWithMessage,
724
726
  isNode,
725
727
  isNumber,
728
+ isSDKCurrencyAmount,
726
729
  isTest,
727
730
  isType,
728
731
  isUint8Array,
@@ -731,6 +734,7 @@ export {
731
734
  localeToCurrencySymbol,
732
735
  lsidToUUID,
733
736
  mapCurrencyAmount,
737
+ notNullUndefined,
734
738
  pollUntil,
735
739
  round,
736
740
  separateCurrencyStrParts,