@lightsparkdev/core 1.2.1 → 1.2.3
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 +14 -0
- package/dist/{chunk-YRWJVCZI.js → chunk-ZU7NVHMW.js} +25 -5
- package/dist/{index-b1e5d968.d.ts → index-DWJjMhfr.d.cts} +23 -9
- package/dist/index-DWJjMhfr.d.ts +256 -0
- package/dist/index.cjs +156 -119
- package/dist/index.d.cts +47 -45
- package/dist/index.d.ts +47 -45
- package/dist/index.js +124 -105
- package/dist/utils/index.cjs +25 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +7 -1
- package/package.json +5 -6
- package/src/Logger.ts +5 -0
- package/src/crypto/crypto.ts +2 -1
- package/src/crypto/index.ts +1 -1
- package/src/index.ts +5 -5
- package/src/requester/Requester.ts +9 -1
- package/src/utils/arrays.ts +3 -0
- package/src/utils/currency.ts +50 -2
- package/src/utils/errors.ts +1 -3
- package/src/utils/index.ts +2 -1
package/dist/index.cjs
CHANGED
|
@@ -59,6 +59,7 @@ __export(src_exports, {
|
|
|
59
59
|
createSha256Hash: () => createSha256Hash,
|
|
60
60
|
defaultCurrencyCode: () => defaultCurrencyCode,
|
|
61
61
|
deleteLocalStorageItem: () => deleteLocalStorageItem,
|
|
62
|
+
ensureArray: () => ensureArray,
|
|
62
63
|
errorToJSON: () => errorToJSON,
|
|
63
64
|
formatCurrencyStr: () => formatCurrencyStr,
|
|
64
65
|
getCurrentLocale: () => getCurrentLocale,
|
|
@@ -68,7 +69,9 @@ __export(src_exports, {
|
|
|
68
69
|
hexToBytes: () => hexToBytes,
|
|
69
70
|
isBrowser: () => isBrowser,
|
|
70
71
|
isCurrencyAmountObj: () => isCurrencyAmountObj,
|
|
72
|
+
isCurrencyAmountPreferenceObj: () => isCurrencyAmountPreferenceObj,
|
|
71
73
|
isCurrencyMap: () => isCurrencyMap,
|
|
74
|
+
isDeprecatedCurrencyAmountObj: () => isDeprecatedCurrencyAmountObj,
|
|
72
75
|
isError: () => isError,
|
|
73
76
|
isErrorMsg: () => isErrorMsg,
|
|
74
77
|
isErrorWithMessage: () => isErrorWithMessage,
|
|
@@ -82,6 +85,7 @@ __export(src_exports, {
|
|
|
82
85
|
linearInterpolate: () => linearInterpolate,
|
|
83
86
|
localeToCurrencyCode: () => localeToCurrencyCode,
|
|
84
87
|
localeToCurrencySymbol: () => localeToCurrencySymbol,
|
|
88
|
+
logger: () => logger,
|
|
85
89
|
lsidToUUID: () => lsidToUUID,
|
|
86
90
|
mapCurrencyAmount: () => mapCurrencyAmount,
|
|
87
91
|
notNullUndefined: () => notNullUndefined,
|
|
@@ -108,74 +112,6 @@ var LightsparkException = class extends Error {
|
|
|
108
112
|
};
|
|
109
113
|
var LightsparkException_default = LightsparkException;
|
|
110
114
|
|
|
111
|
-
// src/utils/environment.ts
|
|
112
|
-
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
113
|
-
var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
114
|
-
var isTest = isNode && process.env.NODE_ENV === "test";
|
|
115
|
-
|
|
116
|
-
// src/Logger.ts
|
|
117
|
-
var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
|
|
118
|
-
LoggingLevel2[LoggingLevel2["Trace"] = 0] = "Trace";
|
|
119
|
-
LoggingLevel2[LoggingLevel2["Info"] = 1] = "Info";
|
|
120
|
-
return LoggingLevel2;
|
|
121
|
-
})(LoggingLevel || {});
|
|
122
|
-
var Logger = class {
|
|
123
|
-
context;
|
|
124
|
-
loggingEnabled = false;
|
|
125
|
-
loggingLevel = 1 /* Info */;
|
|
126
|
-
constructor(loggerContext, getLoggingEnabled) {
|
|
127
|
-
this.context = loggerContext;
|
|
128
|
-
void this.updateLoggingEnabled(getLoggingEnabled);
|
|
129
|
-
}
|
|
130
|
-
setLevel(level) {
|
|
131
|
-
this.loggingLevel = level;
|
|
132
|
-
}
|
|
133
|
-
async updateLoggingEnabled(getLoggingEnabled) {
|
|
134
|
-
if (getLoggingEnabled) {
|
|
135
|
-
this.loggingEnabled = await getLoggingEnabled();
|
|
136
|
-
} else if (isTest) {
|
|
137
|
-
this.loggingEnabled = true;
|
|
138
|
-
} else if (isBrowser) {
|
|
139
|
-
try {
|
|
140
|
-
this.loggingEnabled = getLocalStorageConfigItem(
|
|
141
|
-
ConfigKeys.LoggingEnabled
|
|
142
|
-
);
|
|
143
|
-
} catch (e) {
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (this.loggingEnabled) {
|
|
147
|
-
console.log(`[${this.context}] Logging enabled`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
trace(message, ...rest) {
|
|
151
|
-
if (this.loggingEnabled && this.loggingLevel === 0 /* Trace */) {
|
|
152
|
-
console.log(`[${this.context}] ${message}`, ...rest);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
info(message, ...rest) {
|
|
156
|
-
if (this.loggingEnabled && this.loggingLevel <= 1 /* Info */) {
|
|
157
|
-
console.log(`[${this.context}] ${message}`, ...rest);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
var logger = new Logger("@lightsparkdev/core");
|
|
162
|
-
|
|
163
|
-
// src/ServerEnvironment.ts
|
|
164
|
-
var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
|
|
165
|
-
ServerEnvironment2["PRODUCTION"] = "production";
|
|
166
|
-
ServerEnvironment2["DEV"] = "dev";
|
|
167
|
-
return ServerEnvironment2;
|
|
168
|
-
})(ServerEnvironment || {});
|
|
169
|
-
var apiDomainForEnvironment = (environment) => {
|
|
170
|
-
switch (environment) {
|
|
171
|
-
case "dev" /* DEV */:
|
|
172
|
-
return "api.dev.dev.sparkinfra.net";
|
|
173
|
-
case "production" /* PRODUCTION */:
|
|
174
|
-
return "api.lightspark.com";
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
var ServerEnvironment_default = ServerEnvironment;
|
|
178
|
-
|
|
179
115
|
// src/auth/LightsparkAuthException.ts
|
|
180
116
|
var LightsparkAuthException = class extends LightsparkException_default {
|
|
181
117
|
constructor(message, extraInfo) {
|
|
@@ -203,53 +139,6 @@ var ConfigKeys = {
|
|
|
203
139
|
ConsoleToolsEnabled: "lightspark-console-tools-enabled"
|
|
204
140
|
};
|
|
205
141
|
|
|
206
|
-
// src/crypto/KeyOrAlias.ts
|
|
207
|
-
var KeyOrAlias = {
|
|
208
|
-
key: (key) => ({ key }),
|
|
209
|
-
alias: (alias) => ({ alias })
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
// src/crypto/LightsparkSigningException.ts
|
|
213
|
-
var LightsparkSigningException = class extends LightsparkException_default {
|
|
214
|
-
constructor(message, extraInfo) {
|
|
215
|
-
super("SigningException", message, extraInfo);
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
var LightsparkSigningException_default = LightsparkSigningException;
|
|
219
|
-
|
|
220
|
-
// ../../node_modules/auto-bind/index.js
|
|
221
|
-
var getAllProperties = (object) => {
|
|
222
|
-
const properties = /* @__PURE__ */ new Set();
|
|
223
|
-
do {
|
|
224
|
-
for (const key of Reflect.ownKeys(object)) {
|
|
225
|
-
properties.add([object, key]);
|
|
226
|
-
}
|
|
227
|
-
} while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
|
|
228
|
-
return properties;
|
|
229
|
-
};
|
|
230
|
-
function autoBind(self2, { include, exclude } = {}) {
|
|
231
|
-
const filter = (key) => {
|
|
232
|
-
const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
233
|
-
if (include) {
|
|
234
|
-
return include.some(match);
|
|
235
|
-
}
|
|
236
|
-
if (exclude) {
|
|
237
|
-
return !exclude.some(match);
|
|
238
|
-
}
|
|
239
|
-
return true;
|
|
240
|
-
};
|
|
241
|
-
for (const [object, key] of getAllProperties(self2.constructor.prototype)) {
|
|
242
|
-
if (key === "constructor" || !filter(key)) {
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
246
|
-
if (descriptor && typeof descriptor.value === "function") {
|
|
247
|
-
self2[key] = self2[key].bind(self2);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return self2;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
142
|
// src/utils/base64.ts
|
|
254
143
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
255
144
|
var Base64 = {
|
|
@@ -293,6 +182,14 @@ var b64encode = (data) => {
|
|
|
293
182
|
);
|
|
294
183
|
};
|
|
295
184
|
|
|
185
|
+
// src/crypto/LightsparkSigningException.ts
|
|
186
|
+
var LightsparkSigningException = class extends LightsparkException_default {
|
|
187
|
+
constructor(message, extraInfo) {
|
|
188
|
+
super("SigningException", message, extraInfo);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
var LightsparkSigningException_default = LightsparkSigningException;
|
|
192
|
+
|
|
296
193
|
// src/crypto/crypto.ts
|
|
297
194
|
var getCrypto = () => {
|
|
298
195
|
let cryptoImplPromise;
|
|
@@ -313,7 +210,8 @@ var getCrypto = () => {
|
|
|
313
210
|
return array;
|
|
314
211
|
}
|
|
315
212
|
const buffer = Buffer.from(array.buffer);
|
|
316
|
-
|
|
213
|
+
const view = new Uint8Array(buffer);
|
|
214
|
+
nodeCrypto.randomFillSync(view);
|
|
317
215
|
return array;
|
|
318
216
|
}
|
|
319
217
|
});
|
|
@@ -502,9 +400,58 @@ var DefaultCrypto = {
|
|
|
502
400
|
importPrivateSigningKey
|
|
503
401
|
};
|
|
504
402
|
|
|
403
|
+
// src/crypto/KeyOrAlias.ts
|
|
404
|
+
var KeyOrAlias = {
|
|
405
|
+
key: (key) => ({ key }),
|
|
406
|
+
alias: (alias) => ({ alias })
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
// ../../node_modules/auto-bind/index.js
|
|
410
|
+
var getAllProperties = (object) => {
|
|
411
|
+
const properties = /* @__PURE__ */ new Set();
|
|
412
|
+
do {
|
|
413
|
+
for (const key of Reflect.ownKeys(object)) {
|
|
414
|
+
properties.add([object, key]);
|
|
415
|
+
}
|
|
416
|
+
} while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
|
|
417
|
+
return properties;
|
|
418
|
+
};
|
|
419
|
+
function autoBind(self2, { include, exclude } = {}) {
|
|
420
|
+
const filter = (key) => {
|
|
421
|
+
const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
422
|
+
if (include) {
|
|
423
|
+
return include.some(match);
|
|
424
|
+
}
|
|
425
|
+
if (exclude) {
|
|
426
|
+
return !exclude.some(match);
|
|
427
|
+
}
|
|
428
|
+
return true;
|
|
429
|
+
};
|
|
430
|
+
for (const [object, key] of getAllProperties(self2.constructor.prototype)) {
|
|
431
|
+
if (key === "constructor" || !filter(key)) {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
435
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
436
|
+
self2[key] = self2[key].bind(self2);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return self2;
|
|
440
|
+
}
|
|
441
|
+
|
|
505
442
|
// src/crypto/SigningKey.ts
|
|
506
443
|
var import_secp256k1 = __toESM(require("secp256k1"), 1);
|
|
507
444
|
|
|
445
|
+
// src/utils/arrays.ts
|
|
446
|
+
function ensureArray(value) {
|
|
447
|
+
return Array.isArray(value) ? value : [value];
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// src/utils/environment.ts
|
|
451
|
+
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
452
|
+
var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
453
|
+
var isTest = isNode && process.env.NODE_ENV === "test";
|
|
454
|
+
|
|
508
455
|
// src/utils/hex.ts
|
|
509
456
|
var bytesToHex = (bytes) => {
|
|
510
457
|
return bytes.reduce((acc, byte) => {
|
|
@@ -966,9 +913,15 @@ var convertCurrencyAmount = (from, toUnit) => {
|
|
|
966
913
|
preferredCurrencyValueRounded: value
|
|
967
914
|
};
|
|
968
915
|
};
|
|
969
|
-
function
|
|
916
|
+
function isDeprecatedCurrencyAmountObj(arg) {
|
|
970
917
|
return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
|
|
971
918
|
}
|
|
919
|
+
function isCurrencyAmountObj(arg) {
|
|
920
|
+
return typeof arg === "object" && arg !== null && "original_value" in arg && "original_unit" in arg;
|
|
921
|
+
}
|
|
922
|
+
function isCurrencyAmountPreferenceObj(arg) {
|
|
923
|
+
return typeof arg === "object" && arg !== null && "preferred_currency_unit" in arg && "preferred_currency_value_rounded" in arg;
|
|
924
|
+
}
|
|
972
925
|
function isSDKCurrencyAmount(arg) {
|
|
973
926
|
return typeof arg === "object" && arg !== null && /* We can expect all SDK CurrencyAmount types to always have these exact properties: */
|
|
974
927
|
"originalValue" in arg && "originalUnit" in arg && "preferredCurrencyUnit" in arg && "preferredCurrencyValueRounded" in arg && "preferredCurrencyValueApprox" in arg;
|
|
@@ -985,7 +938,13 @@ function getCurrencyAmount(currencyAmountArg) {
|
|
|
985
938
|
if (isSDKCurrencyAmount(currencyAmountArg)) {
|
|
986
939
|
value = currencyAmountArg.originalValue;
|
|
987
940
|
unit = currencyAmountArg.originalUnit;
|
|
941
|
+
} else if (isCurrencyAmountPreferenceObj(currencyAmountArg)) {
|
|
942
|
+
value = asNumber(currencyAmountArg.preferred_currency_value_rounded);
|
|
943
|
+
unit = currencyAmountArg.preferred_currency_unit;
|
|
988
944
|
} else if (isCurrencyAmountObj(currencyAmountArg)) {
|
|
945
|
+
value = asNumber(currencyAmountArg.original_value);
|
|
946
|
+
unit = currencyAmountArg.original_unit;
|
|
947
|
+
} else if (isDeprecatedCurrencyAmountObj(currencyAmountArg)) {
|
|
989
948
|
value = asNumber(currencyAmountArg.value);
|
|
990
949
|
unit = currencyAmountArg.unit;
|
|
991
950
|
}
|
|
@@ -1182,7 +1141,7 @@ function localeToCurrencySymbol(locale) {
|
|
|
1182
1141
|
// src/utils/errors.ts
|
|
1183
1142
|
var isError = (e) => {
|
|
1184
1143
|
return Boolean(
|
|
1185
|
-
typeof e === "object" && e !== null && "name" in e && typeof e.name === "string" && "message" in e && typeof e.message === "string"
|
|
1144
|
+
typeof e === "object" && e !== null && "name" in e && typeof e.name === "string" && "message" in e && typeof e.message === "string"
|
|
1186
1145
|
);
|
|
1187
1146
|
};
|
|
1188
1147
|
var isErrorWithMessage = (e) => {
|
|
@@ -1477,6 +1436,57 @@ var NodeKeyCache = class {
|
|
|
1477
1436
|
};
|
|
1478
1437
|
var NodeKeyCache_default = NodeKeyCache;
|
|
1479
1438
|
|
|
1439
|
+
// src/Logger.ts
|
|
1440
|
+
var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
|
|
1441
|
+
LoggingLevel2[LoggingLevel2["Trace"] = 0] = "Trace";
|
|
1442
|
+
LoggingLevel2[LoggingLevel2["Info"] = 1] = "Info";
|
|
1443
|
+
return LoggingLevel2;
|
|
1444
|
+
})(LoggingLevel || {});
|
|
1445
|
+
var Logger = class {
|
|
1446
|
+
context;
|
|
1447
|
+
loggingEnabled = false;
|
|
1448
|
+
loggingLevel = 1 /* Info */;
|
|
1449
|
+
constructor(loggerContext, getLoggingEnabled) {
|
|
1450
|
+
this.context = loggerContext;
|
|
1451
|
+
void this.updateLoggingEnabled(getLoggingEnabled);
|
|
1452
|
+
}
|
|
1453
|
+
setLevel(level) {
|
|
1454
|
+
this.loggingLevel = level;
|
|
1455
|
+
}
|
|
1456
|
+
setEnabled(enabled, level = 1 /* Info */) {
|
|
1457
|
+
this.loggingEnabled = enabled;
|
|
1458
|
+
this.loggingLevel = level;
|
|
1459
|
+
}
|
|
1460
|
+
async updateLoggingEnabled(getLoggingEnabled) {
|
|
1461
|
+
if (getLoggingEnabled) {
|
|
1462
|
+
this.loggingEnabled = await getLoggingEnabled();
|
|
1463
|
+
} else if (isTest) {
|
|
1464
|
+
this.loggingEnabled = true;
|
|
1465
|
+
} else if (isBrowser) {
|
|
1466
|
+
try {
|
|
1467
|
+
this.loggingEnabled = getLocalStorageConfigItem(
|
|
1468
|
+
ConfigKeys.LoggingEnabled
|
|
1469
|
+
);
|
|
1470
|
+
} catch (e) {
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
if (this.loggingEnabled) {
|
|
1474
|
+
console.log(`[${this.context}] Logging enabled`);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
trace(message, ...rest) {
|
|
1478
|
+
if (this.loggingEnabled && this.loggingLevel === 0 /* Trace */) {
|
|
1479
|
+
console.log(`[${this.context}] ${message}`, ...rest);
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
info(message, ...rest) {
|
|
1483
|
+
if (this.loggingEnabled && this.loggingLevel <= 1 /* Info */) {
|
|
1484
|
+
console.log(`[${this.context}] ${message}`, ...rest);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1488
|
+
var logger = new Logger("@lightsparkdev/core");
|
|
1489
|
+
|
|
1480
1490
|
// src/requester/Requester.ts
|
|
1481
1491
|
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
1482
1492
|
var import_utc = __toESM(require("dayjs/plugin/utc.js"), 1);
|
|
@@ -1554,6 +1564,12 @@ var Requester = class {
|
|
|
1554
1564
|
});
|
|
1555
1565
|
}
|
|
1556
1566
|
async makeRawRequest(queryPayload, variables = {}, signingNodeId = void 0, skipAuth = false) {
|
|
1567
|
+
logger.trace(`Requester.makeRawRequest args`, {
|
|
1568
|
+
queryPayload,
|
|
1569
|
+
variables,
|
|
1570
|
+
signingNodeId,
|
|
1571
|
+
skipAuth
|
|
1572
|
+
});
|
|
1557
1573
|
const operationNameRegex = /^\s*(query|mutation|subscription)\s+(\w+)/i;
|
|
1558
1574
|
const operationMatch = queryPayload.match(operationNameRegex);
|
|
1559
1575
|
if (!operationMatch || operationMatch.length < 3) {
|
|
@@ -1603,7 +1619,8 @@ var Requester = class {
|
|
|
1603
1619
|
logger.trace(`Requester.makeRawRequest`, {
|
|
1604
1620
|
url,
|
|
1605
1621
|
operationName: operation,
|
|
1606
|
-
variables
|
|
1622
|
+
variables,
|
|
1623
|
+
headers
|
|
1607
1624
|
});
|
|
1608
1625
|
const response = await fetch(url, {
|
|
1609
1626
|
method: "POST",
|
|
@@ -1688,6 +1705,22 @@ async function compress(data) {
|
|
|
1688
1705
|
return new Uint8Array(await blob.arrayBuffer());
|
|
1689
1706
|
}
|
|
1690
1707
|
var Requester_default = Requester;
|
|
1708
|
+
|
|
1709
|
+
// src/ServerEnvironment.ts
|
|
1710
|
+
var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
|
|
1711
|
+
ServerEnvironment2["PRODUCTION"] = "production";
|
|
1712
|
+
ServerEnvironment2["DEV"] = "dev";
|
|
1713
|
+
return ServerEnvironment2;
|
|
1714
|
+
})(ServerEnvironment || {});
|
|
1715
|
+
var apiDomainForEnvironment = (environment) => {
|
|
1716
|
+
switch (environment) {
|
|
1717
|
+
case "dev" /* DEV */:
|
|
1718
|
+
return "api.dev.dev.sparkinfra.net";
|
|
1719
|
+
case "production" /* PRODUCTION */:
|
|
1720
|
+
return "api.lightspark.com";
|
|
1721
|
+
}
|
|
1722
|
+
};
|
|
1723
|
+
var ServerEnvironment_default = ServerEnvironment;
|
|
1691
1724
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1692
1725
|
0 && (module.exports = {
|
|
1693
1726
|
ConfigKeys,
|
|
@@ -1719,6 +1752,7 @@ var Requester_default = Requester;
|
|
|
1719
1752
|
createSha256Hash,
|
|
1720
1753
|
defaultCurrencyCode,
|
|
1721
1754
|
deleteLocalStorageItem,
|
|
1755
|
+
ensureArray,
|
|
1722
1756
|
errorToJSON,
|
|
1723
1757
|
formatCurrencyStr,
|
|
1724
1758
|
getCurrentLocale,
|
|
@@ -1728,7 +1762,9 @@ var Requester_default = Requester;
|
|
|
1728
1762
|
hexToBytes,
|
|
1729
1763
|
isBrowser,
|
|
1730
1764
|
isCurrencyAmountObj,
|
|
1765
|
+
isCurrencyAmountPreferenceObj,
|
|
1731
1766
|
isCurrencyMap,
|
|
1767
|
+
isDeprecatedCurrencyAmountObj,
|
|
1732
1768
|
isError,
|
|
1733
1769
|
isErrorMsg,
|
|
1734
1770
|
isErrorWithMessage,
|
|
@@ -1742,6 +1778,7 @@ var Requester_default = Requester;
|
|
|
1742
1778
|
linearInterpolate,
|
|
1743
1779
|
localeToCurrencyCode,
|
|
1744
1780
|
localeToCurrencySymbol,
|
|
1781
|
+
logger,
|
|
1745
1782
|
lsidToUUID,
|
|
1746
1783
|
mapCurrencyAmount,
|
|
1747
1784
|
notNullUndefined,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a3 as ById, ad as Complete, C as ConfigKeys, m as CurrencyAmountArg, k as CurrencyAmountObj, l as CurrencyAmountPreferenceObj, N as CurrencyCodes, M as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, a6 as DeepPartial, D as DeprecatedCurrencyAmountObj, a2 as ExpandRecursively, a7 as JSONLiteral, a9 as JSONObject, a8 as JSONType, a1 as Maybe, aa as NN, a4 as OmitTypename, ac as PartialBy, S as SDKCurrencyAmountType, t as abbrCurrencyUnit, b as b64decode, a as b64encode, I as bytesToHex, U as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, L as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, T as deleteLocalStorageItem, e as ensureArray, H as errorToJSON, v as formatCurrencyStr, K as getCurrentLocale, F as getErrorMsg, Q as getLocalStorageBoolean, P as getLocalStorageConfigItem, J as hexToBytes, y as isBrowser, o as isCurrencyAmountObj, p as isCurrencyAmountPreferenceObj, s as isCurrencyMap, n as isDeprecatedCurrencyAmountObj, B as isError, G as isErrorMsg, E as isErrorWithMessage, z as isNode, X as isNumber, a0 as isObject, q as isSDKCurrencyAmount, A as isTest, a5 as isType, $ as isUint8Array, V as linearInterpolate, O as localeToCurrencyCode, x as localeToCurrencySymbol, _ as lsidToUUID, r as mapCurrencyAmount, ab as notNullUndefined, Y as pollUntil, W as round, w as separateCurrencyStrParts, R as setLocalStorageBoolean, Z as sleep, u as urlsafe_b64decode } from './index-DWJjMhfr.cjs';
|
|
2
2
|
import { Observable } from 'zen-observable-ts';
|
|
3
3
|
|
|
4
|
-
declare class LightsparkException extends Error {
|
|
5
|
-
code: string;
|
|
6
|
-
message: string;
|
|
7
|
-
extraInfo: Record<string, unknown> | undefined;
|
|
8
|
-
constructor(code: string, message: string, extraInfo?: Record<string, unknown>);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
|
|
12
|
-
declare enum LoggingLevel {
|
|
13
|
-
Trace = 0,
|
|
14
|
-
Info = 1
|
|
15
|
-
}
|
|
16
|
-
declare class Logger {
|
|
17
|
-
context: string;
|
|
18
|
-
loggingEnabled: boolean;
|
|
19
|
-
loggingLevel: LoggingLevel;
|
|
20
|
-
constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
|
|
21
|
-
setLevel(level: LoggingLevel): void;
|
|
22
|
-
updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
|
|
23
|
-
trace(message: string, ...rest: unknown[]): void;
|
|
24
|
-
info(message: string, ...rest: unknown[]): void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare enum ServerEnvironment {
|
|
28
|
-
PRODUCTION = "production",
|
|
29
|
-
DEV = "dev"
|
|
30
|
-
}
|
|
31
|
-
declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
|
|
32
|
-
|
|
33
4
|
type Headers = Record<string, string>;
|
|
34
5
|
type WsConnectionParams = Record<string, unknown>;
|
|
35
6
|
interface AuthProvider {
|
|
@@ -38,6 +9,13 @@ interface AuthProvider {
|
|
|
38
9
|
addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
|
|
39
10
|
}
|
|
40
11
|
|
|
12
|
+
declare class LightsparkException extends Error {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
extraInfo: Record<string, unknown> | undefined;
|
|
16
|
+
constructor(code: string, message: string, extraInfo?: Record<string, unknown>);
|
|
17
|
+
}
|
|
18
|
+
|
|
41
19
|
declare class LightsparkAuthException extends LightsparkException {
|
|
42
20
|
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
43
21
|
}
|
|
@@ -48,20 +26,6 @@ declare class StubAuthProvider implements AuthProvider {
|
|
|
48
26
|
addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
|
|
49
27
|
}
|
|
50
28
|
|
|
51
|
-
type OnlyKey = {
|
|
52
|
-
key: string;
|
|
53
|
-
alias?: never;
|
|
54
|
-
};
|
|
55
|
-
type OnlyAlias = {
|
|
56
|
-
key?: never;
|
|
57
|
-
alias: string;
|
|
58
|
-
};
|
|
59
|
-
type KeyOrAliasType = OnlyKey | OnlyAlias;
|
|
60
|
-
declare const KeyOrAlias: {
|
|
61
|
-
key: (key: string) => OnlyKey;
|
|
62
|
-
alias: (alias: string) => OnlyAlias;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
29
|
declare class LightsparkSigningException extends LightsparkException {
|
|
66
30
|
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
67
31
|
}
|
|
@@ -89,6 +53,20 @@ declare const DefaultCrypto: {
|
|
|
89
53
|
importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
|
|
90
54
|
};
|
|
91
55
|
|
|
56
|
+
type OnlyKey = {
|
|
57
|
+
key: string;
|
|
58
|
+
alias?: never;
|
|
59
|
+
};
|
|
60
|
+
type OnlyAlias = {
|
|
61
|
+
key?: never;
|
|
62
|
+
alias: string;
|
|
63
|
+
};
|
|
64
|
+
type KeyOrAliasType = OnlyKey | OnlyAlias;
|
|
65
|
+
declare const KeyOrAlias: {
|
|
66
|
+
key: (key: string) => OnlyKey;
|
|
67
|
+
alias: (alias: string) => OnlyAlias;
|
|
68
|
+
};
|
|
69
|
+
|
|
92
70
|
interface Alias {
|
|
93
71
|
alias: string;
|
|
94
72
|
}
|
|
@@ -124,6 +102,24 @@ declare class NodeKeyCache {
|
|
|
124
102
|
private stripPemTags;
|
|
125
103
|
}
|
|
126
104
|
|
|
105
|
+
type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
|
|
106
|
+
declare enum LoggingLevel {
|
|
107
|
+
Trace = 0,
|
|
108
|
+
Info = 1
|
|
109
|
+
}
|
|
110
|
+
declare class Logger {
|
|
111
|
+
context: string;
|
|
112
|
+
loggingEnabled: boolean;
|
|
113
|
+
loggingLevel: LoggingLevel;
|
|
114
|
+
constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
|
|
115
|
+
setLevel(level: LoggingLevel): void;
|
|
116
|
+
setEnabled(enabled: boolean, level?: LoggingLevel): void;
|
|
117
|
+
updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
|
|
118
|
+
trace(message: string, ...rest: unknown[]): void;
|
|
119
|
+
info(message: string, ...rest: unknown[]): void;
|
|
120
|
+
}
|
|
121
|
+
declare const logger: Logger;
|
|
122
|
+
|
|
127
123
|
type Query<T> = {
|
|
128
124
|
/** The string representation of the query payload for graphQL. **/
|
|
129
125
|
queryPayload: string;
|
|
@@ -165,4 +161,10 @@ declare class Requester {
|
|
|
165
161
|
private addSigningDataIfNeeded;
|
|
166
162
|
}
|
|
167
163
|
|
|
168
|
-
|
|
164
|
+
declare enum ServerEnvironment {
|
|
165
|
+
PRODUCTION = "production",
|
|
166
|
+
DEV = "dev"
|
|
167
|
+
}
|
|
168
|
+
declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
|
|
169
|
+
|
|
170
|
+
export { type AuthProvider, type CryptoInterface, DefaultCrypto, type GeneratedKeyPair, KeyOrAlias, type KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, LoggingLevel, NodeKeyCache, type Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, logger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a3 as ById, ad as Complete, C as ConfigKeys, m as CurrencyAmountArg, k as CurrencyAmountObj, l as CurrencyAmountPreferenceObj, N as CurrencyCodes, M as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, a6 as DeepPartial, D as DeprecatedCurrencyAmountObj, a2 as ExpandRecursively, a7 as JSONLiteral, a9 as JSONObject, a8 as JSONType, a1 as Maybe, aa as NN, a4 as OmitTypename, ac as PartialBy, S as SDKCurrencyAmountType, t as abbrCurrencyUnit, b as b64decode, a as b64encode, I as bytesToHex, U as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, L as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, T as deleteLocalStorageItem, e as ensureArray, H as errorToJSON, v as formatCurrencyStr, K as getCurrentLocale, F as getErrorMsg, Q as getLocalStorageBoolean, P as getLocalStorageConfigItem, J as hexToBytes, y as isBrowser, o as isCurrencyAmountObj, p as isCurrencyAmountPreferenceObj, s as isCurrencyMap, n as isDeprecatedCurrencyAmountObj, B as isError, G as isErrorMsg, E as isErrorWithMessage, z as isNode, X as isNumber, a0 as isObject, q as isSDKCurrencyAmount, A as isTest, a5 as isType, $ as isUint8Array, V as linearInterpolate, O as localeToCurrencyCode, x as localeToCurrencySymbol, _ as lsidToUUID, r as mapCurrencyAmount, ab as notNullUndefined, Y as pollUntil, W as round, w as separateCurrencyStrParts, R as setLocalStorageBoolean, Z as sleep, u as urlsafe_b64decode } from './index-DWJjMhfr.js';
|
|
2
2
|
import { Observable } from 'zen-observable-ts';
|
|
3
3
|
|
|
4
|
-
declare class LightsparkException extends Error {
|
|
5
|
-
code: string;
|
|
6
|
-
message: string;
|
|
7
|
-
extraInfo: Record<string, unknown> | undefined;
|
|
8
|
-
constructor(code: string, message: string, extraInfo?: Record<string, unknown>);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
|
|
12
|
-
declare enum LoggingLevel {
|
|
13
|
-
Trace = 0,
|
|
14
|
-
Info = 1
|
|
15
|
-
}
|
|
16
|
-
declare class Logger {
|
|
17
|
-
context: string;
|
|
18
|
-
loggingEnabled: boolean;
|
|
19
|
-
loggingLevel: LoggingLevel;
|
|
20
|
-
constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
|
|
21
|
-
setLevel(level: LoggingLevel): void;
|
|
22
|
-
updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
|
|
23
|
-
trace(message: string, ...rest: unknown[]): void;
|
|
24
|
-
info(message: string, ...rest: unknown[]): void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare enum ServerEnvironment {
|
|
28
|
-
PRODUCTION = "production",
|
|
29
|
-
DEV = "dev"
|
|
30
|
-
}
|
|
31
|
-
declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
|
|
32
|
-
|
|
33
4
|
type Headers = Record<string, string>;
|
|
34
5
|
type WsConnectionParams = Record<string, unknown>;
|
|
35
6
|
interface AuthProvider {
|
|
@@ -38,6 +9,13 @@ interface AuthProvider {
|
|
|
38
9
|
addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
|
|
39
10
|
}
|
|
40
11
|
|
|
12
|
+
declare class LightsparkException extends Error {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
extraInfo: Record<string, unknown> | undefined;
|
|
16
|
+
constructor(code: string, message: string, extraInfo?: Record<string, unknown>);
|
|
17
|
+
}
|
|
18
|
+
|
|
41
19
|
declare class LightsparkAuthException extends LightsparkException {
|
|
42
20
|
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
43
21
|
}
|
|
@@ -48,20 +26,6 @@ declare class StubAuthProvider implements AuthProvider {
|
|
|
48
26
|
addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
|
|
49
27
|
}
|
|
50
28
|
|
|
51
|
-
type OnlyKey = {
|
|
52
|
-
key: string;
|
|
53
|
-
alias?: never;
|
|
54
|
-
};
|
|
55
|
-
type OnlyAlias = {
|
|
56
|
-
key?: never;
|
|
57
|
-
alias: string;
|
|
58
|
-
};
|
|
59
|
-
type KeyOrAliasType = OnlyKey | OnlyAlias;
|
|
60
|
-
declare const KeyOrAlias: {
|
|
61
|
-
key: (key: string) => OnlyKey;
|
|
62
|
-
alias: (alias: string) => OnlyAlias;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
29
|
declare class LightsparkSigningException extends LightsparkException {
|
|
66
30
|
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
67
31
|
}
|
|
@@ -89,6 +53,20 @@ declare const DefaultCrypto: {
|
|
|
89
53
|
importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
|
|
90
54
|
};
|
|
91
55
|
|
|
56
|
+
type OnlyKey = {
|
|
57
|
+
key: string;
|
|
58
|
+
alias?: never;
|
|
59
|
+
};
|
|
60
|
+
type OnlyAlias = {
|
|
61
|
+
key?: never;
|
|
62
|
+
alias: string;
|
|
63
|
+
};
|
|
64
|
+
type KeyOrAliasType = OnlyKey | OnlyAlias;
|
|
65
|
+
declare const KeyOrAlias: {
|
|
66
|
+
key: (key: string) => OnlyKey;
|
|
67
|
+
alias: (alias: string) => OnlyAlias;
|
|
68
|
+
};
|
|
69
|
+
|
|
92
70
|
interface Alias {
|
|
93
71
|
alias: string;
|
|
94
72
|
}
|
|
@@ -124,6 +102,24 @@ declare class NodeKeyCache {
|
|
|
124
102
|
private stripPemTags;
|
|
125
103
|
}
|
|
126
104
|
|
|
105
|
+
type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
|
|
106
|
+
declare enum LoggingLevel {
|
|
107
|
+
Trace = 0,
|
|
108
|
+
Info = 1
|
|
109
|
+
}
|
|
110
|
+
declare class Logger {
|
|
111
|
+
context: string;
|
|
112
|
+
loggingEnabled: boolean;
|
|
113
|
+
loggingLevel: LoggingLevel;
|
|
114
|
+
constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
|
|
115
|
+
setLevel(level: LoggingLevel): void;
|
|
116
|
+
setEnabled(enabled: boolean, level?: LoggingLevel): void;
|
|
117
|
+
updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
|
|
118
|
+
trace(message: string, ...rest: unknown[]): void;
|
|
119
|
+
info(message: string, ...rest: unknown[]): void;
|
|
120
|
+
}
|
|
121
|
+
declare const logger: Logger;
|
|
122
|
+
|
|
127
123
|
type Query<T> = {
|
|
128
124
|
/** The string representation of the query payload for graphQL. **/
|
|
129
125
|
queryPayload: string;
|
|
@@ -165,4 +161,10 @@ declare class Requester {
|
|
|
165
161
|
private addSigningDataIfNeeded;
|
|
166
162
|
}
|
|
167
163
|
|
|
168
|
-
|
|
164
|
+
declare enum ServerEnvironment {
|
|
165
|
+
PRODUCTION = "production",
|
|
166
|
+
DEV = "dev"
|
|
167
|
+
}
|
|
168
|
+
declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
|
|
169
|
+
|
|
170
|
+
export { type AuthProvider, type CryptoInterface, DefaultCrypto, type GeneratedKeyPair, KeyOrAlias, type KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, LoggingLevel, NodeKeyCache, type Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, logger };
|