@lightsparkdev/core 1.2.0 → 1.2.2
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-XRYQNSG7.js → chunk-22DUJXVY.js} +17 -6
- package/dist/{index-4698c2db.d.ts → index-DdZ7x9Ef.d.cts} +11 -8
- package/dist/index-DdZ7x9Ef.d.ts +244 -0
- package/dist/index.cjs +147 -120
- package/dist/index.d.cts +47 -45
- package/dist/index.d.ts +47 -45
- package/dist/index.js +122 -105
- package/dist/utils/index.cjs +16 -3
- 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 +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/errors.ts +1 -3
- package/src/utils/index.ts +2 -1
- package/src/utils/typeGuards.ts +7 -2
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,
|
|
@@ -74,6 +75,7 @@ __export(src_exports, {
|
|
|
74
75
|
isErrorWithMessage: () => isErrorWithMessage,
|
|
75
76
|
isNode: () => isNode,
|
|
76
77
|
isNumber: () => isNumber,
|
|
78
|
+
isObject: () => isObject2,
|
|
77
79
|
isSDKCurrencyAmount: () => isSDKCurrencyAmount,
|
|
78
80
|
isTest: () => isTest,
|
|
79
81
|
isType: () => isType,
|
|
@@ -81,6 +83,7 @@ __export(src_exports, {
|
|
|
81
83
|
linearInterpolate: () => linearInterpolate,
|
|
82
84
|
localeToCurrencyCode: () => localeToCurrencyCode,
|
|
83
85
|
localeToCurrencySymbol: () => localeToCurrencySymbol,
|
|
86
|
+
logger: () => logger,
|
|
84
87
|
lsidToUUID: () => lsidToUUID,
|
|
85
88
|
mapCurrencyAmount: () => mapCurrencyAmount,
|
|
86
89
|
notNullUndefined: () => notNullUndefined,
|
|
@@ -107,74 +110,6 @@ var LightsparkException = class extends Error {
|
|
|
107
110
|
};
|
|
108
111
|
var LightsparkException_default = LightsparkException;
|
|
109
112
|
|
|
110
|
-
// src/utils/environment.ts
|
|
111
|
-
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
112
|
-
var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
113
|
-
var isTest = isNode && process.env.NODE_ENV === "test";
|
|
114
|
-
|
|
115
|
-
// src/Logger.ts
|
|
116
|
-
var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
|
|
117
|
-
LoggingLevel2[LoggingLevel2["Trace"] = 0] = "Trace";
|
|
118
|
-
LoggingLevel2[LoggingLevel2["Info"] = 1] = "Info";
|
|
119
|
-
return LoggingLevel2;
|
|
120
|
-
})(LoggingLevel || {});
|
|
121
|
-
var Logger = class {
|
|
122
|
-
context;
|
|
123
|
-
loggingEnabled = false;
|
|
124
|
-
loggingLevel = 1 /* Info */;
|
|
125
|
-
constructor(loggerContext, getLoggingEnabled) {
|
|
126
|
-
this.context = loggerContext;
|
|
127
|
-
void this.updateLoggingEnabled(getLoggingEnabled);
|
|
128
|
-
}
|
|
129
|
-
setLevel(level) {
|
|
130
|
-
this.loggingLevel = level;
|
|
131
|
-
}
|
|
132
|
-
async updateLoggingEnabled(getLoggingEnabled) {
|
|
133
|
-
if (getLoggingEnabled) {
|
|
134
|
-
this.loggingEnabled = await getLoggingEnabled();
|
|
135
|
-
} else if (isTest) {
|
|
136
|
-
this.loggingEnabled = true;
|
|
137
|
-
} else if (isBrowser) {
|
|
138
|
-
try {
|
|
139
|
-
this.loggingEnabled = getLocalStorageConfigItem(
|
|
140
|
-
ConfigKeys.LoggingEnabled
|
|
141
|
-
);
|
|
142
|
-
} catch (e) {
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
if (this.loggingEnabled) {
|
|
146
|
-
console.log(`[${this.context}] Logging enabled`);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
trace(message, ...rest) {
|
|
150
|
-
if (this.loggingEnabled && this.loggingLevel === 0 /* Trace */) {
|
|
151
|
-
console.log(`[${this.context}] ${message}`, ...rest);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
info(message, ...rest) {
|
|
155
|
-
if (this.loggingEnabled && this.loggingLevel <= 1 /* Info */) {
|
|
156
|
-
console.log(`[${this.context}] ${message}`, ...rest);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
var logger = new Logger("@lightsparkdev/core");
|
|
161
|
-
|
|
162
|
-
// src/ServerEnvironment.ts
|
|
163
|
-
var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
|
|
164
|
-
ServerEnvironment2["PRODUCTION"] = "production";
|
|
165
|
-
ServerEnvironment2["DEV"] = "dev";
|
|
166
|
-
return ServerEnvironment2;
|
|
167
|
-
})(ServerEnvironment || {});
|
|
168
|
-
var apiDomainForEnvironment = (environment) => {
|
|
169
|
-
switch (environment) {
|
|
170
|
-
case "dev" /* DEV */:
|
|
171
|
-
return "api.dev.dev.sparkinfra.net";
|
|
172
|
-
case "production" /* PRODUCTION */:
|
|
173
|
-
return "api.lightspark.com";
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
var ServerEnvironment_default = ServerEnvironment;
|
|
177
|
-
|
|
178
113
|
// src/auth/LightsparkAuthException.ts
|
|
179
114
|
var LightsparkAuthException = class extends LightsparkException_default {
|
|
180
115
|
constructor(message, extraInfo) {
|
|
@@ -202,53 +137,6 @@ var ConfigKeys = {
|
|
|
202
137
|
ConsoleToolsEnabled: "lightspark-console-tools-enabled"
|
|
203
138
|
};
|
|
204
139
|
|
|
205
|
-
// src/crypto/KeyOrAlias.ts
|
|
206
|
-
var KeyOrAlias = {
|
|
207
|
-
key: (key) => ({ key }),
|
|
208
|
-
alias: (alias) => ({ alias })
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
// src/crypto/LightsparkSigningException.ts
|
|
212
|
-
var LightsparkSigningException = class extends LightsparkException_default {
|
|
213
|
-
constructor(message, extraInfo) {
|
|
214
|
-
super("SigningException", message, extraInfo);
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
var LightsparkSigningException_default = LightsparkSigningException;
|
|
218
|
-
|
|
219
|
-
// ../../node_modules/auto-bind/index.js
|
|
220
|
-
var getAllProperties = (object) => {
|
|
221
|
-
const properties = /* @__PURE__ */ new Set();
|
|
222
|
-
do {
|
|
223
|
-
for (const key of Reflect.ownKeys(object)) {
|
|
224
|
-
properties.add([object, key]);
|
|
225
|
-
}
|
|
226
|
-
} while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
|
|
227
|
-
return properties;
|
|
228
|
-
};
|
|
229
|
-
function autoBind(self2, { include, exclude } = {}) {
|
|
230
|
-
const filter = (key) => {
|
|
231
|
-
const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
232
|
-
if (include) {
|
|
233
|
-
return include.some(match);
|
|
234
|
-
}
|
|
235
|
-
if (exclude) {
|
|
236
|
-
return !exclude.some(match);
|
|
237
|
-
}
|
|
238
|
-
return true;
|
|
239
|
-
};
|
|
240
|
-
for (const [object, key] of getAllProperties(self2.constructor.prototype)) {
|
|
241
|
-
if (key === "constructor" || !filter(key)) {
|
|
242
|
-
continue;
|
|
243
|
-
}
|
|
244
|
-
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
245
|
-
if (descriptor && typeof descriptor.value === "function") {
|
|
246
|
-
self2[key] = self2[key].bind(self2);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return self2;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
140
|
// src/utils/base64.ts
|
|
253
141
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
254
142
|
var Base64 = {
|
|
@@ -292,6 +180,14 @@ var b64encode = (data) => {
|
|
|
292
180
|
);
|
|
293
181
|
};
|
|
294
182
|
|
|
183
|
+
// src/crypto/LightsparkSigningException.ts
|
|
184
|
+
var LightsparkSigningException = class extends LightsparkException_default {
|
|
185
|
+
constructor(message, extraInfo) {
|
|
186
|
+
super("SigningException", message, extraInfo);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
var LightsparkSigningException_default = LightsparkSigningException;
|
|
190
|
+
|
|
295
191
|
// src/crypto/crypto.ts
|
|
296
192
|
var getCrypto = () => {
|
|
297
193
|
let cryptoImplPromise;
|
|
@@ -312,7 +208,8 @@ var getCrypto = () => {
|
|
|
312
208
|
return array;
|
|
313
209
|
}
|
|
314
210
|
const buffer = Buffer.from(array.buffer);
|
|
315
|
-
|
|
211
|
+
const view = new Uint8Array(buffer);
|
|
212
|
+
nodeCrypto.randomFillSync(view);
|
|
316
213
|
return array;
|
|
317
214
|
}
|
|
318
215
|
});
|
|
@@ -501,9 +398,58 @@ var DefaultCrypto = {
|
|
|
501
398
|
importPrivateSigningKey
|
|
502
399
|
};
|
|
503
400
|
|
|
401
|
+
// src/crypto/KeyOrAlias.ts
|
|
402
|
+
var KeyOrAlias = {
|
|
403
|
+
key: (key) => ({ key }),
|
|
404
|
+
alias: (alias) => ({ alias })
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// ../../node_modules/auto-bind/index.js
|
|
408
|
+
var getAllProperties = (object) => {
|
|
409
|
+
const properties = /* @__PURE__ */ new Set();
|
|
410
|
+
do {
|
|
411
|
+
for (const key of Reflect.ownKeys(object)) {
|
|
412
|
+
properties.add([object, key]);
|
|
413
|
+
}
|
|
414
|
+
} while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
|
|
415
|
+
return properties;
|
|
416
|
+
};
|
|
417
|
+
function autoBind(self2, { include, exclude } = {}) {
|
|
418
|
+
const filter = (key) => {
|
|
419
|
+
const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
420
|
+
if (include) {
|
|
421
|
+
return include.some(match);
|
|
422
|
+
}
|
|
423
|
+
if (exclude) {
|
|
424
|
+
return !exclude.some(match);
|
|
425
|
+
}
|
|
426
|
+
return true;
|
|
427
|
+
};
|
|
428
|
+
for (const [object, key] of getAllProperties(self2.constructor.prototype)) {
|
|
429
|
+
if (key === "constructor" || !filter(key)) {
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
433
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
434
|
+
self2[key] = self2[key].bind(self2);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return self2;
|
|
438
|
+
}
|
|
439
|
+
|
|
504
440
|
// src/crypto/SigningKey.ts
|
|
505
441
|
var import_secp256k1 = __toESM(require("secp256k1"), 1);
|
|
506
442
|
|
|
443
|
+
// src/utils/arrays.ts
|
|
444
|
+
function ensureArray(value) {
|
|
445
|
+
return Array.isArray(value) ? value : [value];
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// src/utils/environment.ts
|
|
449
|
+
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
450
|
+
var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
451
|
+
var isTest = isNode && process.env.NODE_ENV === "test";
|
|
452
|
+
|
|
507
453
|
// src/utils/hex.ts
|
|
508
454
|
var bytesToHex = (bytes) => {
|
|
509
455
|
return bytes.reduce((acc, byte) => {
|
|
@@ -1181,7 +1127,7 @@ function localeToCurrencySymbol(locale) {
|
|
|
1181
1127
|
// src/utils/errors.ts
|
|
1182
1128
|
var isError = (e) => {
|
|
1183
1129
|
return Boolean(
|
|
1184
|
-
typeof e === "object" && e !== null && "name" in e && typeof e.name === "string" && "message" in e && typeof e.message === "string"
|
|
1130
|
+
typeof e === "object" && e !== null && "name" in e && typeof e.name === "string" && "message" in e && typeof e.message === "string"
|
|
1185
1131
|
);
|
|
1186
1132
|
};
|
|
1187
1133
|
var isErrorWithMessage = (e) => {
|
|
@@ -1365,8 +1311,12 @@ function lsidToUUID(lsid) {
|
|
|
1365
1311
|
}
|
|
1366
1312
|
|
|
1367
1313
|
// src/utils/typeGuards.ts
|
|
1368
|
-
function isUint8Array(
|
|
1369
|
-
return
|
|
1314
|
+
function isUint8Array(value) {
|
|
1315
|
+
return value instanceof Uint8Array;
|
|
1316
|
+
}
|
|
1317
|
+
function isObject2(value) {
|
|
1318
|
+
const type = typeof value;
|
|
1319
|
+
return value != null && (type == "object" || type == "function");
|
|
1370
1320
|
}
|
|
1371
1321
|
|
|
1372
1322
|
// src/utils/types.ts
|
|
@@ -1472,6 +1422,57 @@ var NodeKeyCache = class {
|
|
|
1472
1422
|
};
|
|
1473
1423
|
var NodeKeyCache_default = NodeKeyCache;
|
|
1474
1424
|
|
|
1425
|
+
// src/Logger.ts
|
|
1426
|
+
var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
|
|
1427
|
+
LoggingLevel2[LoggingLevel2["Trace"] = 0] = "Trace";
|
|
1428
|
+
LoggingLevel2[LoggingLevel2["Info"] = 1] = "Info";
|
|
1429
|
+
return LoggingLevel2;
|
|
1430
|
+
})(LoggingLevel || {});
|
|
1431
|
+
var Logger = class {
|
|
1432
|
+
context;
|
|
1433
|
+
loggingEnabled = false;
|
|
1434
|
+
loggingLevel = 1 /* Info */;
|
|
1435
|
+
constructor(loggerContext, getLoggingEnabled) {
|
|
1436
|
+
this.context = loggerContext;
|
|
1437
|
+
void this.updateLoggingEnabled(getLoggingEnabled);
|
|
1438
|
+
}
|
|
1439
|
+
setLevel(level) {
|
|
1440
|
+
this.loggingLevel = level;
|
|
1441
|
+
}
|
|
1442
|
+
setEnabled(enabled, level = 1 /* Info */) {
|
|
1443
|
+
this.loggingEnabled = enabled;
|
|
1444
|
+
this.loggingLevel = level;
|
|
1445
|
+
}
|
|
1446
|
+
async updateLoggingEnabled(getLoggingEnabled) {
|
|
1447
|
+
if (getLoggingEnabled) {
|
|
1448
|
+
this.loggingEnabled = await getLoggingEnabled();
|
|
1449
|
+
} else if (isTest) {
|
|
1450
|
+
this.loggingEnabled = true;
|
|
1451
|
+
} else if (isBrowser) {
|
|
1452
|
+
try {
|
|
1453
|
+
this.loggingEnabled = getLocalStorageConfigItem(
|
|
1454
|
+
ConfigKeys.LoggingEnabled
|
|
1455
|
+
);
|
|
1456
|
+
} catch (e) {
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
if (this.loggingEnabled) {
|
|
1460
|
+
console.log(`[${this.context}] Logging enabled`);
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
trace(message, ...rest) {
|
|
1464
|
+
if (this.loggingEnabled && this.loggingLevel === 0 /* Trace */) {
|
|
1465
|
+
console.log(`[${this.context}] ${message}`, ...rest);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
info(message, ...rest) {
|
|
1469
|
+
if (this.loggingEnabled && this.loggingLevel <= 1 /* Info */) {
|
|
1470
|
+
console.log(`[${this.context}] ${message}`, ...rest);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
var logger = new Logger("@lightsparkdev/core");
|
|
1475
|
+
|
|
1475
1476
|
// src/requester/Requester.ts
|
|
1476
1477
|
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
1477
1478
|
var import_utc = __toESM(require("dayjs/plugin/utc.js"), 1);
|
|
@@ -1549,6 +1550,12 @@ var Requester = class {
|
|
|
1549
1550
|
});
|
|
1550
1551
|
}
|
|
1551
1552
|
async makeRawRequest(queryPayload, variables = {}, signingNodeId = void 0, skipAuth = false) {
|
|
1553
|
+
logger.trace(`Requester.makeRawRequest args`, {
|
|
1554
|
+
queryPayload,
|
|
1555
|
+
variables,
|
|
1556
|
+
signingNodeId,
|
|
1557
|
+
skipAuth
|
|
1558
|
+
});
|
|
1552
1559
|
const operationNameRegex = /^\s*(query|mutation|subscription)\s+(\w+)/i;
|
|
1553
1560
|
const operationMatch = queryPayload.match(operationNameRegex);
|
|
1554
1561
|
if (!operationMatch || operationMatch.length < 3) {
|
|
@@ -1598,7 +1605,8 @@ var Requester = class {
|
|
|
1598
1605
|
logger.trace(`Requester.makeRawRequest`, {
|
|
1599
1606
|
url,
|
|
1600
1607
|
operationName: operation,
|
|
1601
|
-
variables
|
|
1608
|
+
variables,
|
|
1609
|
+
headers
|
|
1602
1610
|
});
|
|
1603
1611
|
const response = await fetch(url, {
|
|
1604
1612
|
method: "POST",
|
|
@@ -1683,6 +1691,22 @@ async function compress(data) {
|
|
|
1683
1691
|
return new Uint8Array(await blob.arrayBuffer());
|
|
1684
1692
|
}
|
|
1685
1693
|
var Requester_default = Requester;
|
|
1694
|
+
|
|
1695
|
+
// src/ServerEnvironment.ts
|
|
1696
|
+
var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
|
|
1697
|
+
ServerEnvironment2["PRODUCTION"] = "production";
|
|
1698
|
+
ServerEnvironment2["DEV"] = "dev";
|
|
1699
|
+
return ServerEnvironment2;
|
|
1700
|
+
})(ServerEnvironment || {});
|
|
1701
|
+
var apiDomainForEnvironment = (environment) => {
|
|
1702
|
+
switch (environment) {
|
|
1703
|
+
case "dev" /* DEV */:
|
|
1704
|
+
return "api.dev.dev.sparkinfra.net";
|
|
1705
|
+
case "production" /* PRODUCTION */:
|
|
1706
|
+
return "api.lightspark.com";
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
var ServerEnvironment_default = ServerEnvironment;
|
|
1686
1710
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1687
1711
|
0 && (module.exports = {
|
|
1688
1712
|
ConfigKeys,
|
|
@@ -1714,6 +1738,7 @@ var Requester_default = Requester;
|
|
|
1714
1738
|
createSha256Hash,
|
|
1715
1739
|
defaultCurrencyCode,
|
|
1716
1740
|
deleteLocalStorageItem,
|
|
1741
|
+
ensureArray,
|
|
1717
1742
|
errorToJSON,
|
|
1718
1743
|
formatCurrencyStr,
|
|
1719
1744
|
getCurrentLocale,
|
|
@@ -1729,6 +1754,7 @@ var Requester_default = Requester;
|
|
|
1729
1754
|
isErrorWithMessage,
|
|
1730
1755
|
isNode,
|
|
1731
1756
|
isNumber,
|
|
1757
|
+
isObject,
|
|
1732
1758
|
isSDKCurrencyAmount,
|
|
1733
1759
|
isTest,
|
|
1734
1760
|
isType,
|
|
@@ -1736,6 +1762,7 @@ var Requester_default = Requester;
|
|
|
1736
1762
|
linearInterpolate,
|
|
1737
1763
|
localeToCurrencyCode,
|
|
1738
1764
|
localeToCurrencySymbol,
|
|
1765
|
+
logger,
|
|
1739
1766
|
lsidToUUID,
|
|
1740
1767
|
mapCurrencyAmount,
|
|
1741
1768
|
notNullUndefined,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { $ as ById, a9 as Complete, C as ConfigKeys, l as CurrencyAmountArg, k as CurrencyAmountObj, J as CurrencyCodes, I as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, a2 as DeepPartial, _ as ExpandRecursively, a3 as JSONLiteral, a5 as JSONObject, a4 as JSONType, Z as Maybe, a6 as NN, a0 as OmitTypename, a8 as PartialBy, S as SDKCurrencyAmountType, q as abbrCurrencyUnit, b as b64decode, a as b64encode, E as bytesToHex, P as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, H as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, O as deleteLocalStorageItem, e as ensureArray, D as errorToJSON, r as formatCurrencyStr, G as getCurrentLocale, A as getErrorMsg, M as getLocalStorageBoolean, L as getLocalStorageConfigItem, F as hexToBytes, v as isBrowser, m as isCurrencyAmountObj, p as isCurrencyMap, y as isError, B as isErrorMsg, z as isErrorWithMessage, w as isNode, T as isNumber, Y as isObject, n as isSDKCurrencyAmount, x as isTest, a1 as isType, X as isUint8Array, Q as linearInterpolate, K as localeToCurrencyCode, t as localeToCurrencySymbol, W as lsidToUUID, o as mapCurrencyAmount, a7 as notNullUndefined, U as pollUntil, R as round, s as separateCurrencyStrParts, N as setLocalStorageBoolean, V as sleep, u as urlsafe_b64decode } from './index-DdZ7x9Ef.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 { $ as ById, a9 as Complete, C as ConfigKeys, l as CurrencyAmountArg, k as CurrencyAmountObj, J as CurrencyCodes, I as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, a2 as DeepPartial, _ as ExpandRecursively, a3 as JSONLiteral, a5 as JSONObject, a4 as JSONType, Z as Maybe, a6 as NN, a0 as OmitTypename, a8 as PartialBy, S as SDKCurrencyAmountType, q as abbrCurrencyUnit, b as b64decode, a as b64encode, E as bytesToHex, P as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, H as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, O as deleteLocalStorageItem, e as ensureArray, D as errorToJSON, r as formatCurrencyStr, G as getCurrentLocale, A as getErrorMsg, M as getLocalStorageBoolean, L as getLocalStorageConfigItem, F as hexToBytes, v as isBrowser, m as isCurrencyAmountObj, p as isCurrencyMap, y as isError, B as isErrorMsg, z as isErrorWithMessage, w as isNode, T as isNumber, Y as isObject, n as isSDKCurrencyAmount, x as isTest, a1 as isType, X as isUint8Array, Q as linearInterpolate, K as localeToCurrencyCode, t as localeToCurrencySymbol, W as lsidToUUID, o as mapCurrencyAmount, a7 as notNullUndefined, U as pollUntil, R as round, s as separateCurrencyStrParts, N as setLocalStorageBoolean, V as sleep, u as urlsafe_b64decode } from './index-DdZ7x9Ef.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 };
|