@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.
- package/CHANGELOG.md +27 -0
- package/dist/{chunk-NY4EJZNK.js → chunk-23SS5EX2.js} +90 -38
- package/dist/{index-r0bUxDu_.d.cts → index-C7dqDM91.d.cts} +24 -3
- package/dist/{index-r0bUxDu_.d.ts → index-C7dqDM91.d.ts} +24 -3
- package/dist/index.cjs +96 -40
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +10 -4
- package/dist/utils/index.cjs +91 -37
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +5 -1
- package/package.json +8 -21
- package/src/requester/Requester.ts +5 -2
- package/src/utils/currency.ts +112 -32
- package/src/utils/types.ts +8 -0
package/dist/index.cjs
CHANGED
|
@@ -80,10 +80,12 @@ __export(src_exports, {
|
|
|
80
80
|
isNode: () => isNode,
|
|
81
81
|
isNumber: () => isNumber,
|
|
82
82
|
isObject: () => isObject2,
|
|
83
|
+
isRecord: () => isRecord,
|
|
83
84
|
isSDKCurrencyAmount: () => isSDKCurrencyAmount,
|
|
84
85
|
isTest: () => isTest,
|
|
85
86
|
isType: () => isType,
|
|
86
87
|
isUint8Array: () => isUint8Array,
|
|
88
|
+
isUmaCurrencyAmount: () => isUmaCurrencyAmount,
|
|
87
89
|
linearInterpolate: () => linearInterpolate,
|
|
88
90
|
localeToCurrencyCode: () => localeToCurrencyCode,
|
|
89
91
|
localeToCurrencySymbol: () => localeToCurrencySymbol,
|
|
@@ -797,6 +799,7 @@ var CurrencyUnit = {
|
|
|
797
799
|
USD: "USD",
|
|
798
800
|
MXN: "MXN",
|
|
799
801
|
PHP: "PHP",
|
|
802
|
+
EUR: "EUR",
|
|
800
803
|
Bitcoin: "BITCOIN",
|
|
801
804
|
Microbitcoin: "MICROBITCOIN",
|
|
802
805
|
Millibitcoin: "MILLIBITCOIN",
|
|
@@ -817,7 +820,8 @@ var standardUnitConversionObj = {
|
|
|
817
820
|
/* Converting between two different fiat types is not currently supported */
|
|
818
821
|
[CurrencyUnit.USD]: (v) => v,
|
|
819
822
|
[CurrencyUnit.MXN]: (v) => v,
|
|
820
|
-
[CurrencyUnit.PHP]: (v) => v
|
|
823
|
+
[CurrencyUnit.PHP]: (v) => v,
|
|
824
|
+
[CurrencyUnit.EUR]: (v) => v
|
|
821
825
|
};
|
|
822
826
|
var toBitcoinConversion = (v, unitsPerBtc = 1) => round(v * unitsPerBtc);
|
|
823
827
|
var toMicrobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e6 * unitsPerBtc);
|
|
@@ -835,7 +839,8 @@ var CONVERSION_MAP = {
|
|
|
835
839
|
[CurrencyUnit.SATOSHI]: (v) => v * 1e8,
|
|
836
840
|
[CurrencyUnit.USD]: toBitcoinConversion,
|
|
837
841
|
[CurrencyUnit.MXN]: toBitcoinConversion,
|
|
838
|
-
[CurrencyUnit.PHP]: toBitcoinConversion
|
|
842
|
+
[CurrencyUnit.PHP]: toBitcoinConversion,
|
|
843
|
+
[CurrencyUnit.EUR]: toBitcoinConversion
|
|
839
844
|
},
|
|
840
845
|
[CurrencyUnit.MICROBITCOIN]: {
|
|
841
846
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e6,
|
|
@@ -846,7 +851,8 @@ var CONVERSION_MAP = {
|
|
|
846
851
|
[CurrencyUnit.SATOSHI]: (v) => v * 100,
|
|
847
852
|
[CurrencyUnit.USD]: toMicrobitcoinConversion,
|
|
848
853
|
[CurrencyUnit.MXN]: toMicrobitcoinConversion,
|
|
849
|
-
[CurrencyUnit.PHP]: toMicrobitcoinConversion
|
|
854
|
+
[CurrencyUnit.PHP]: toMicrobitcoinConversion,
|
|
855
|
+
[CurrencyUnit.EUR]: toMicrobitcoinConversion
|
|
850
856
|
},
|
|
851
857
|
[CurrencyUnit.MILLIBITCOIN]: {
|
|
852
858
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e3,
|
|
@@ -857,7 +863,8 @@ var CONVERSION_MAP = {
|
|
|
857
863
|
[CurrencyUnit.SATOSHI]: (v) => v * 1e5,
|
|
858
864
|
[CurrencyUnit.USD]: toMillibitcoinConversion,
|
|
859
865
|
[CurrencyUnit.MXN]: toMillibitcoinConversion,
|
|
860
|
-
[CurrencyUnit.PHP]: toMillibitcoinConversion
|
|
866
|
+
[CurrencyUnit.PHP]: toMillibitcoinConversion,
|
|
867
|
+
[CurrencyUnit.EUR]: toMillibitcoinConversion
|
|
861
868
|
},
|
|
862
869
|
[CurrencyUnit.MILLISATOSHI]: {
|
|
863
870
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e11,
|
|
@@ -868,7 +875,8 @@ var CONVERSION_MAP = {
|
|
|
868
875
|
[CurrencyUnit.SATOSHI]: (v) => v / 1e3,
|
|
869
876
|
[CurrencyUnit.USD]: toMillisatoshiConversion,
|
|
870
877
|
[CurrencyUnit.MXN]: toMillisatoshiConversion,
|
|
871
|
-
[CurrencyUnit.PHP]: toMillisatoshiConversion
|
|
878
|
+
[CurrencyUnit.PHP]: toMillisatoshiConversion,
|
|
879
|
+
[CurrencyUnit.EUR]: toMillisatoshiConversion
|
|
872
880
|
},
|
|
873
881
|
[CurrencyUnit.NANOBITCOIN]: {
|
|
874
882
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e9,
|
|
@@ -879,7 +887,8 @@ var CONVERSION_MAP = {
|
|
|
879
887
|
[CurrencyUnit.SATOSHI]: (v) => v / 10,
|
|
880
888
|
[CurrencyUnit.USD]: toNanobitcoinConversion,
|
|
881
889
|
[CurrencyUnit.MXN]: toNanobitcoinConversion,
|
|
882
|
-
[CurrencyUnit.PHP]: toNanobitcoinConversion
|
|
890
|
+
[CurrencyUnit.PHP]: toNanobitcoinConversion,
|
|
891
|
+
[CurrencyUnit.EUR]: toNanobitcoinConversion
|
|
883
892
|
},
|
|
884
893
|
[CurrencyUnit.SATOSHI]: {
|
|
885
894
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e8,
|
|
@@ -890,11 +899,13 @@ var CONVERSION_MAP = {
|
|
|
890
899
|
[CurrencyUnit.SATOSHI]: (v) => v,
|
|
891
900
|
[CurrencyUnit.USD]: toSatoshiConversion,
|
|
892
901
|
[CurrencyUnit.MXN]: toSatoshiConversion,
|
|
893
|
-
[CurrencyUnit.PHP]: toSatoshiConversion
|
|
902
|
+
[CurrencyUnit.PHP]: toSatoshiConversion,
|
|
903
|
+
[CurrencyUnit.EUR]: toSatoshiConversion
|
|
894
904
|
},
|
|
895
905
|
[CurrencyUnit.USD]: standardUnitConversionObj,
|
|
896
906
|
[CurrencyUnit.MXN]: standardUnitConversionObj,
|
|
897
|
-
[CurrencyUnit.PHP]: standardUnitConversionObj
|
|
907
|
+
[CurrencyUnit.PHP]: standardUnitConversionObj,
|
|
908
|
+
[CurrencyUnit.EUR]: standardUnitConversionObj
|
|
898
909
|
};
|
|
899
910
|
function convertCurrencyAmountValue(fromUnit, toUnit, amount, unitsPerBtc = 1) {
|
|
900
911
|
if (fromUnit === CurrencyUnit.FUTURE_VALUE || toUnit === CurrencyUnit.FUTURE_VALUE) {
|
|
@@ -928,6 +939,9 @@ var convertCurrencyAmount = (from, toUnit) => {
|
|
|
928
939
|
function isCurrencyAmountInputObj(arg) {
|
|
929
940
|
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";
|
|
930
941
|
}
|
|
942
|
+
function isUmaCurrencyAmount(arg) {
|
|
943
|
+
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";
|
|
944
|
+
}
|
|
931
945
|
function isDeprecatedCurrencyAmountObj(arg) {
|
|
932
946
|
return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
|
|
933
947
|
}
|
|
@@ -974,6 +988,7 @@ function convertCurrencyAmountValues(fromUnit, amount, unitsPerBtc = 1, conversi
|
|
|
974
988
|
usd: CurrencyUnit.USD,
|
|
975
989
|
mxn: CurrencyUnit.MXN,
|
|
976
990
|
php: CurrencyUnit.PHP,
|
|
991
|
+
eur: CurrencyUnit.EUR,
|
|
977
992
|
mibtc: CurrencyUnit.MICROBITCOIN,
|
|
978
993
|
mlbtc: CurrencyUnit.MILLIBITCOIN,
|
|
979
994
|
nbtc: CurrencyUnit.NANOBITCOIN
|
|
@@ -1012,7 +1027,7 @@ function getPreferredConversionOverride(currencyAmountArg) {
|
|
|
1012
1027
|
function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
|
|
1013
1028
|
const { value, unit } = getCurrencyAmount(currencyAmountArg);
|
|
1014
1029
|
const conversionOverride = getPreferredConversionOverride(currencyAmountArg);
|
|
1015
|
-
const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
|
|
1030
|
+
const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc, eur } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
|
|
1016
1031
|
const mapWithCurrencyUnits = {
|
|
1017
1032
|
[CurrencyUnit.BITCOIN]: btc,
|
|
1018
1033
|
[CurrencyUnit.SATOSHI]: sats,
|
|
@@ -1020,6 +1035,7 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
|
|
|
1020
1035
|
[CurrencyUnit.USD]: usd,
|
|
1021
1036
|
[CurrencyUnit.MXN]: mxn,
|
|
1022
1037
|
[CurrencyUnit.PHP]: php,
|
|
1038
|
+
[CurrencyUnit.EUR]: eur,
|
|
1023
1039
|
[CurrencyUnit.MICROBITCOIN]: mibtc,
|
|
1024
1040
|
[CurrencyUnit.MILLIBITCOIN]: mlbtc,
|
|
1025
1041
|
[CurrencyUnit.NANOBITCOIN]: nbtc,
|
|
@@ -1061,6 +1077,10 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
|
|
|
1061
1077
|
value: php,
|
|
1062
1078
|
unit: CurrencyUnit.PHP
|
|
1063
1079
|
}),
|
|
1080
|
+
[CurrencyUnit.EUR]: formatCurrencyStr({
|
|
1081
|
+
value: eur,
|
|
1082
|
+
unit: CurrencyUnit.EUR
|
|
1083
|
+
}),
|
|
1064
1084
|
[CurrencyUnit.FUTURE_VALUE]: "-"
|
|
1065
1085
|
}
|
|
1066
1086
|
};
|
|
@@ -1125,6 +1145,8 @@ var abbrCurrencyUnit = (unit) => {
|
|
|
1125
1145
|
return "MXN";
|
|
1126
1146
|
case CurrencyUnit.PHP:
|
|
1127
1147
|
return "PHP";
|
|
1148
|
+
case CurrencyUnit.EUR:
|
|
1149
|
+
return "EUR";
|
|
1128
1150
|
}
|
|
1129
1151
|
return "Unsupported CurrencyUnit";
|
|
1130
1152
|
};
|
|
@@ -1140,16 +1162,27 @@ function formatCurrencyStr(amount, options) {
|
|
|
1140
1162
|
...defaultOptions,
|
|
1141
1163
|
...options
|
|
1142
1164
|
};
|
|
1143
|
-
|
|
1144
|
-
let
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1165
|
+
let num;
|
|
1166
|
+
let unit;
|
|
1167
|
+
if (isUmaCurrencyAmount(amount)) {
|
|
1168
|
+
num = amount.value;
|
|
1169
|
+
unit = amount.currency.code;
|
|
1170
|
+
if (amount.currency.decimals > 0) {
|
|
1171
|
+
num = amount.value / Math.pow(10, amount.currency.decimals);
|
|
1172
|
+
}
|
|
1173
|
+
} else {
|
|
1174
|
+
const currencyAmount = getCurrencyAmount(amount);
|
|
1175
|
+
num = currencyAmount.value;
|
|
1176
|
+
unit = currencyAmount.unit;
|
|
1177
|
+
const centCurrencies = [
|
|
1178
|
+
CurrencyUnit.USD,
|
|
1179
|
+
CurrencyUnit.MXN,
|
|
1180
|
+
CurrencyUnit.PHP,
|
|
1181
|
+
CurrencyUnit.EUR
|
|
1182
|
+
];
|
|
1183
|
+
if (centCurrencies.includes(unit)) {
|
|
1184
|
+
num = num / 100;
|
|
1185
|
+
}
|
|
1153
1186
|
}
|
|
1154
1187
|
function getDefaultMaxFractionDigits(defaultDigits, fullPrecisionDigits) {
|
|
1155
1188
|
let digits = defaultDigits;
|
|
@@ -1162,21 +1195,22 @@ function formatCurrencyStr(amount, options) {
|
|
|
1162
1195
|
}
|
|
1163
1196
|
return digits;
|
|
1164
1197
|
}
|
|
1165
|
-
const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI ? "\uE902" : "";
|
|
1198
|
+
const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI || unit === abbrCurrencyUnit(CurrencyUnit.SATOSHI) ? "\uE902" : "";
|
|
1166
1199
|
const currentLocale = getCurrentLocale();
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
case CurrencyUnit.USD:
|
|
1171
|
-
case CurrencyUnit.PHP:
|
|
1172
|
-
formattedStr = num.toLocaleString(currentLocale, {
|
|
1200
|
+
function isFormattableFiatCurrencyCode(currencyCode) {
|
|
1201
|
+
try {
|
|
1202
|
+
new Intl.NumberFormat(currentLocale, {
|
|
1173
1203
|
style: "currency",
|
|
1174
|
-
currency:
|
|
1175
|
-
currencyDisplay: "narrowSymbol",
|
|
1176
|
-
notation: compact ? "compact" : void 0,
|
|
1177
|
-
maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
|
|
1204
|
+
currency: currencyCode
|
|
1178
1205
|
});
|
|
1179
|
-
|
|
1206
|
+
return true;
|
|
1207
|
+
} catch (e) {
|
|
1208
|
+
return false;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
let formattedStr = "";
|
|
1212
|
+
let forceAppendUnits = false;
|
|
1213
|
+
switch (unit) {
|
|
1180
1214
|
case CurrencyUnit.BITCOIN:
|
|
1181
1215
|
formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
|
|
1182
1216
|
notation: compact ? "compact" : void 0,
|
|
@@ -1184,6 +1218,7 @@ function formatCurrencyStr(amount, options) {
|
|
|
1184
1218
|
})}`;
|
|
1185
1219
|
break;
|
|
1186
1220
|
case CurrencyUnit.SATOSHI:
|
|
1221
|
+
case abbrCurrencyUnit(CurrencyUnit.SATOSHI):
|
|
1187
1222
|
formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
|
|
1188
1223
|
notation: compact ? "compact" : void 0,
|
|
1189
1224
|
maximumFractionDigits: getDefaultMaxFractionDigits(0, 3)
|
|
@@ -1193,21 +1228,35 @@ function formatCurrencyStr(amount, options) {
|
|
|
1193
1228
|
case CurrencyUnit.MICROBITCOIN:
|
|
1194
1229
|
case CurrencyUnit.MILLIBITCOIN:
|
|
1195
1230
|
case CurrencyUnit.NANOBITCOIN:
|
|
1196
|
-
default:
|
|
1197
1231
|
formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
|
|
1198
1232
|
notation: compact ? "compact" : void 0,
|
|
1199
1233
|
maximumFractionDigits: getDefaultMaxFractionDigits(0, 0)
|
|
1200
1234
|
})}`;
|
|
1235
|
+
break;
|
|
1236
|
+
default:
|
|
1237
|
+
if (isFormattableFiatCurrencyCode(unit)) {
|
|
1238
|
+
formattedStr = num.toLocaleString(currentLocale, {
|
|
1239
|
+
style: "currency",
|
|
1240
|
+
currency: unit,
|
|
1241
|
+
currencyDisplay: "narrowSymbol",
|
|
1242
|
+
notation: compact ? "compact" : void 0,
|
|
1243
|
+
maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
|
|
1244
|
+
});
|
|
1245
|
+
} else {
|
|
1246
|
+
formattedStr = `${num}`;
|
|
1247
|
+
forceAppendUnits = true;
|
|
1248
|
+
}
|
|
1249
|
+
break;
|
|
1201
1250
|
}
|
|
1202
|
-
if (options?.appendUnits) {
|
|
1251
|
+
if (options?.appendUnits || forceAppendUnits) {
|
|
1203
1252
|
const localeCurrencyCode = localeToCurrencyCode(currentLocale);
|
|
1204
|
-
if (unit === localeCurrencyCode && !options.appendUnits.showForCurrentLocaleUnit) {
|
|
1253
|
+
if (unit === localeCurrencyCode && options?.appendUnits && !options.appendUnits.showForCurrentLocaleUnit) {
|
|
1205
1254
|
return formattedStr;
|
|
1206
1255
|
}
|
|
1207
|
-
const unitStr = abbrCurrencyUnit(unit);
|
|
1208
|
-
const unitSuffix = options
|
|
1256
|
+
const unitStr = isUmaCurrencyAmount(amount) ? amount.currency.code : abbrCurrencyUnit(unit);
|
|
1257
|
+
const unitSuffix = options?.appendUnits?.plural && num > 1 ? "s" : "";
|
|
1209
1258
|
const unitStrWithSuffix = `${unitStr}${unitSuffix}`;
|
|
1210
|
-
formattedStr += ` ${options
|
|
1259
|
+
formattedStr += ` ${options?.appendUnits?.lowercase ? unitStrWithSuffix.toLowerCase() : unitStrWithSuffix}`;
|
|
1211
1260
|
}
|
|
1212
1261
|
return formattedStr;
|
|
1213
1262
|
}
|
|
@@ -1432,6 +1481,9 @@ var isType = (typename) => (node) => {
|
|
|
1432
1481
|
function notNullUndefined(value) {
|
|
1433
1482
|
return value !== null && value !== void 0;
|
|
1434
1483
|
}
|
|
1484
|
+
function isRecord(value) {
|
|
1485
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1486
|
+
}
|
|
1435
1487
|
|
|
1436
1488
|
// src/crypto/SigningKey.ts
|
|
1437
1489
|
function isAlias(key) {
|
|
@@ -1588,13 +1640,15 @@ var import_zen_observable_ts = require("zen-observable-ts");
|
|
|
1588
1640
|
var DEFAULT_BASE_URL = "api.lightspark.com";
|
|
1589
1641
|
import_dayjs.default.extend(import_utc.default);
|
|
1590
1642
|
var Requester = class {
|
|
1591
|
-
constructor(nodeKeyCache, schemaEndpoint, sdkUserAgent, authProvider = new StubAuthProvider(), baseUrl = DEFAULT_BASE_URL, cryptoImpl = DefaultCrypto) {
|
|
1643
|
+
constructor(nodeKeyCache, schemaEndpoint, sdkUserAgent, authProvider = new StubAuthProvider(), baseUrl = DEFAULT_BASE_URL, cryptoImpl = DefaultCrypto, signingKey, fetchImpl = fetch) {
|
|
1592
1644
|
this.nodeKeyCache = nodeKeyCache;
|
|
1593
1645
|
this.schemaEndpoint = schemaEndpoint;
|
|
1594
1646
|
this.sdkUserAgent = sdkUserAgent;
|
|
1595
1647
|
this.authProvider = authProvider;
|
|
1596
1648
|
this.baseUrl = baseUrl;
|
|
1597
1649
|
this.cryptoImpl = cryptoImpl;
|
|
1650
|
+
this.signingKey = signingKey;
|
|
1651
|
+
this.fetchImpl = fetchImpl;
|
|
1598
1652
|
let websocketImpl;
|
|
1599
1653
|
if (typeof WebSocket === "undefined" && typeof window === "undefined") {
|
|
1600
1654
|
websocketImpl = import_ws.default;
|
|
@@ -1714,7 +1768,7 @@ var Requester = class {
|
|
|
1714
1768
|
variables,
|
|
1715
1769
|
headers
|
|
1716
1770
|
});
|
|
1717
|
-
const response = await
|
|
1771
|
+
const response = await this.fetchImpl(url, {
|
|
1718
1772
|
method: "POST",
|
|
1719
1773
|
headers,
|
|
1720
1774
|
body: bodyData
|
|
@@ -1759,7 +1813,7 @@ var Requester = class {
|
|
|
1759
1813
|
nonce,
|
|
1760
1814
|
expires_at: expiration
|
|
1761
1815
|
};
|
|
1762
|
-
const key = this.nodeKeyCache.getKey(signingNodeId);
|
|
1816
|
+
const key = this.signingKey ?? this.nodeKeyCache.getKey(signingNodeId);
|
|
1763
1817
|
if (!key) {
|
|
1764
1818
|
throw new LightsparkSigningException_default(
|
|
1765
1819
|
"Missing node of encrypted_signing_private_key"
|
|
@@ -1857,10 +1911,12 @@ var ServerEnvironment_default = ServerEnvironment;
|
|
|
1857
1911
|
isNode,
|
|
1858
1912
|
isNumber,
|
|
1859
1913
|
isObject,
|
|
1914
|
+
isRecord,
|
|
1860
1915
|
isSDKCurrencyAmount,
|
|
1861
1916
|
isTest,
|
|
1862
1917
|
isType,
|
|
1863
1918
|
isUint8Array,
|
|
1919
|
+
isUmaCurrencyAmount,
|
|
1864
1920
|
linearInterpolate,
|
|
1865
1921
|
localeToCurrencyCode,
|
|
1866
1922
|
localeToCurrencySymbol,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AppendUnitsOptions,
|
|
1
|
+
export { A as AppendUnitsOptions, aa as ById, al as Complete, C as ConfigKeys, 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';
|
|
2
2
|
import { Observable } from 'zen-observable-ts';
|
|
3
3
|
|
|
4
4
|
type Headers = Record<string, string>;
|
|
@@ -145,8 +145,10 @@ declare class Requester {
|
|
|
145
145
|
private readonly authProvider;
|
|
146
146
|
private readonly baseUrl;
|
|
147
147
|
private readonly cryptoImpl;
|
|
148
|
+
private readonly signingKey?;
|
|
149
|
+
private readonly fetchImpl;
|
|
148
150
|
private readonly wsClient;
|
|
149
|
-
constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface);
|
|
151
|
+
constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface, signingKey?: SigningKey | undefined, fetchImpl?: typeof fetch);
|
|
150
152
|
executeQuery<T>(query: Query<T>): Promise<T | null>;
|
|
151
153
|
subscribe<T>(queryPayload: string, variables?: {
|
|
152
154
|
[key: string]: unknown;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AppendUnitsOptions,
|
|
1
|
+
export { A as AppendUnitsOptions, aa as ById, al as Complete, C as ConfigKeys, 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';
|
|
2
2
|
import { Observable } from 'zen-observable-ts';
|
|
3
3
|
|
|
4
4
|
type Headers = Record<string, string>;
|
|
@@ -145,8 +145,10 @@ declare class Requester {
|
|
|
145
145
|
private readonly authProvider;
|
|
146
146
|
private readonly baseUrl;
|
|
147
147
|
private readonly cryptoImpl;
|
|
148
|
+
private readonly signingKey?;
|
|
149
|
+
private readonly fetchImpl;
|
|
148
150
|
private readonly wsClient;
|
|
149
|
-
constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface);
|
|
151
|
+
constructor(nodeKeyCache: NodeKeyCache, schemaEndpoint: string, sdkUserAgent: string, authProvider?: AuthProvider, baseUrl?: string, cryptoImpl?: CryptoInterface, signingKey?: SigningKey | undefined, fetchImpl?: typeof fetch);
|
|
150
152
|
executeQuery<T>(query: Query<T>): Promise<T | null>;
|
|
151
153
|
subscribe<T>(queryPayload: string, variables?: {
|
|
152
154
|
[key: string]: unknown;
|
package/dist/index.js
CHANGED
|
@@ -33,10 +33,12 @@ import {
|
|
|
33
33
|
isNode,
|
|
34
34
|
isNumber,
|
|
35
35
|
isObject,
|
|
36
|
+
isRecord,
|
|
36
37
|
isSDKCurrencyAmount,
|
|
37
38
|
isTest,
|
|
38
39
|
isType,
|
|
39
40
|
isUint8Array,
|
|
41
|
+
isUmaCurrencyAmount,
|
|
40
42
|
linearInterpolate,
|
|
41
43
|
localeToCurrencyCode,
|
|
42
44
|
localeToCurrencySymbol,
|
|
@@ -49,7 +51,7 @@ import {
|
|
|
49
51
|
setLocalStorageBoolean,
|
|
50
52
|
sleep,
|
|
51
53
|
urlsafe_b64decode
|
|
52
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-23SS5EX2.js";
|
|
53
55
|
|
|
54
56
|
// src/auth/LightsparkAuthException.ts
|
|
55
57
|
var LightsparkAuthException = class extends LightsparkException_default {
|
|
@@ -491,13 +493,15 @@ import { Observable } from "zen-observable-ts";
|
|
|
491
493
|
var DEFAULT_BASE_URL = "api.lightspark.com";
|
|
492
494
|
dayjs.extend(utc);
|
|
493
495
|
var Requester = class {
|
|
494
|
-
constructor(nodeKeyCache, schemaEndpoint, sdkUserAgent, authProvider = new StubAuthProvider(), baseUrl = DEFAULT_BASE_URL, cryptoImpl = DefaultCrypto) {
|
|
496
|
+
constructor(nodeKeyCache, schemaEndpoint, sdkUserAgent, authProvider = new StubAuthProvider(), baseUrl = DEFAULT_BASE_URL, cryptoImpl = DefaultCrypto, signingKey, fetchImpl = fetch) {
|
|
495
497
|
this.nodeKeyCache = nodeKeyCache;
|
|
496
498
|
this.schemaEndpoint = schemaEndpoint;
|
|
497
499
|
this.sdkUserAgent = sdkUserAgent;
|
|
498
500
|
this.authProvider = authProvider;
|
|
499
501
|
this.baseUrl = baseUrl;
|
|
500
502
|
this.cryptoImpl = cryptoImpl;
|
|
503
|
+
this.signingKey = signingKey;
|
|
504
|
+
this.fetchImpl = fetchImpl;
|
|
501
505
|
let websocketImpl;
|
|
502
506
|
if (typeof WebSocket === "undefined" && typeof window === "undefined") {
|
|
503
507
|
websocketImpl = NodeWebSocket;
|
|
@@ -617,7 +621,7 @@ var Requester = class {
|
|
|
617
621
|
variables,
|
|
618
622
|
headers
|
|
619
623
|
});
|
|
620
|
-
const response = await
|
|
624
|
+
const response = await this.fetchImpl(url, {
|
|
621
625
|
method: "POST",
|
|
622
626
|
headers,
|
|
623
627
|
body: bodyData
|
|
@@ -662,7 +666,7 @@ var Requester = class {
|
|
|
662
666
|
nonce,
|
|
663
667
|
expires_at: expiration
|
|
664
668
|
};
|
|
665
|
-
const key = this.nodeKeyCache.getKey(signingNodeId);
|
|
669
|
+
const key = this.signingKey ?? this.nodeKeyCache.getKey(signingNodeId);
|
|
666
670
|
if (!key) {
|
|
667
671
|
throw new LightsparkSigningException_default(
|
|
668
672
|
"Missing node of encrypted_signing_private_key"
|
|
@@ -759,10 +763,12 @@ export {
|
|
|
759
763
|
isNode,
|
|
760
764
|
isNumber,
|
|
761
765
|
isObject,
|
|
766
|
+
isRecord,
|
|
762
767
|
isSDKCurrencyAmount,
|
|
763
768
|
isTest,
|
|
764
769
|
isType,
|
|
765
770
|
isUint8Array,
|
|
771
|
+
isUmaCurrencyAmount,
|
|
766
772
|
linearInterpolate,
|
|
767
773
|
localeToCurrencyCode,
|
|
768
774
|
localeToCurrencySymbol,
|