@lightsparkdev/core 1.0.10 → 1.0.12
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 +12 -0
- package/dist/{chunk-MAZP7ETK.js → chunk-BYCLLNFL.js} +12 -3
- package/dist/index.cjs +91 -72
- package/dist/index.d.cts +43 -39
- package/dist/index.d.ts +43 -39
- package/dist/index.js +70 -60
- package/dist/utils/index.cjs +10 -0
- package/dist/utils/index.d.cts +68 -31
- package/dist/utils/index.d.ts +68 -31
- package/dist/utils/index.js +3 -1
- package/package.json +3 -3
- package/src/constants/localStorage.ts +5 -0
- package/src/crypto/crypto.ts +1 -2
- package/src/crypto/index.ts +1 -1
- package/src/crypto/tests/crypto.test.ts +1 -1
- package/src/index.ts +5 -5
- package/src/requester/Query.ts +4 -1
- package/src/requester/Requester.ts +1 -0
- package/src/utils/currency.ts +56 -18
- package/src/utils/errors.ts +16 -0
- package/src/utils/localeToCurrencyCodes.ts +3 -1
- package/src/utils/types.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -728,6 +728,14 @@ var isErrorMsg = (e, msg) => {
|
|
|
728
728
|
}
|
|
729
729
|
return false;
|
|
730
730
|
};
|
|
731
|
+
function errorToJSON(err) {
|
|
732
|
+
if (typeof err === "object" && err !== null && "toJSON" in err && typeof err.toJSON === "function") {
|
|
733
|
+
return err.toJSON();
|
|
734
|
+
}
|
|
735
|
+
return JSON.parse(
|
|
736
|
+
JSON.stringify(err, Object.getOwnPropertyNames(err))
|
|
737
|
+
);
|
|
738
|
+
}
|
|
731
739
|
|
|
732
740
|
// ../../node_modules/lodash-es/_freeGlobal.js
|
|
733
741
|
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
@@ -857,12 +865,12 @@ var isType = (typename) => (node) => {
|
|
|
857
865
|
|
|
858
866
|
export {
|
|
859
867
|
LightsparkException_default,
|
|
860
|
-
b64decode,
|
|
861
|
-
urlsafe_b64decode,
|
|
862
|
-
b64encode,
|
|
863
868
|
isBrowser,
|
|
864
869
|
isNode,
|
|
865
870
|
isTest,
|
|
871
|
+
b64decode,
|
|
872
|
+
urlsafe_b64decode,
|
|
873
|
+
b64encode,
|
|
866
874
|
bytesToHex,
|
|
867
875
|
hexToBytes,
|
|
868
876
|
createSha256Hash,
|
|
@@ -889,6 +897,7 @@ export {
|
|
|
889
897
|
isErrorWithMessage,
|
|
890
898
|
getErrorMsg,
|
|
891
899
|
isErrorMsg,
|
|
900
|
+
errorToJSON,
|
|
892
901
|
sleep,
|
|
893
902
|
pollUntil,
|
|
894
903
|
isType
|
package/dist/index.cjs
CHANGED
|
@@ -57,9 +57,11 @@ __export(src_exports, {
|
|
|
57
57
|
countryCodesToCurrencyCodes: () => countryCodesToCurrencyCodes,
|
|
58
58
|
createSha256Hash: () => createSha256Hash,
|
|
59
59
|
defaultCurrencyCode: () => defaultCurrencyCode,
|
|
60
|
+
errorToJSON: () => errorToJSON,
|
|
60
61
|
formatCurrencyStr: () => formatCurrencyStr,
|
|
61
62
|
getCurrentLocale: () => getCurrentLocale,
|
|
62
63
|
getErrorMsg: () => getErrorMsg,
|
|
64
|
+
getLocalStorageBoolean: () => getLocalStorageBoolean,
|
|
63
65
|
getLocalStorageConfigItem: () => getLocalStorageConfigItem,
|
|
64
66
|
hexToBytes: () => hexToBytes,
|
|
65
67
|
isBrowser: () => isBrowser,
|
|
@@ -99,6 +101,60 @@ var LightsparkException = class extends Error {
|
|
|
99
101
|
};
|
|
100
102
|
var LightsparkException_default = LightsparkException;
|
|
101
103
|
|
|
104
|
+
// src/utils/environment.ts
|
|
105
|
+
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
106
|
+
var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
107
|
+
var isTest = isNode && process.env.NODE_ENV === "test";
|
|
108
|
+
|
|
109
|
+
// src/Logger.ts
|
|
110
|
+
var Logger = class {
|
|
111
|
+
context;
|
|
112
|
+
loggingEnabled = false;
|
|
113
|
+
constructor(loggerContext, getLoggingEnabled) {
|
|
114
|
+
this.context = loggerContext;
|
|
115
|
+
void this.updateLoggingEnabled(getLoggingEnabled);
|
|
116
|
+
}
|
|
117
|
+
async updateLoggingEnabled(getLoggingEnabled) {
|
|
118
|
+
if (getLoggingEnabled) {
|
|
119
|
+
this.loggingEnabled = await getLoggingEnabled();
|
|
120
|
+
} else if (isTest) {
|
|
121
|
+
this.loggingEnabled = true;
|
|
122
|
+
} else if (isBrowser) {
|
|
123
|
+
try {
|
|
124
|
+
this.loggingEnabled = getLocalStorageConfigItem(
|
|
125
|
+
ConfigKeys.LoggingEnabled
|
|
126
|
+
);
|
|
127
|
+
} catch (e) {
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (this.loggingEnabled) {
|
|
131
|
+
console.log(`[${this.context}] Logging enabled`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
info(message, ...rest) {
|
|
135
|
+
if (this.loggingEnabled) {
|
|
136
|
+
console.log(`[${this.context}] ${message}`, ...rest);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var logger = new Logger("@lightsparkdev/core");
|
|
141
|
+
|
|
142
|
+
// src/ServerEnvironment.ts
|
|
143
|
+
var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
|
|
144
|
+
ServerEnvironment2["PRODUCTION"] = "production";
|
|
145
|
+
ServerEnvironment2["DEV"] = "dev";
|
|
146
|
+
return ServerEnvironment2;
|
|
147
|
+
})(ServerEnvironment || {});
|
|
148
|
+
var apiDomainForEnvironment = (environment) => {
|
|
149
|
+
switch (environment) {
|
|
150
|
+
case "dev" /* DEV */:
|
|
151
|
+
return "api.dev.dev.sparkinfra.net";
|
|
152
|
+
case "production" /* PRODUCTION */:
|
|
153
|
+
return "api.lightspark.com";
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var ServerEnvironment_default = ServerEnvironment;
|
|
157
|
+
|
|
102
158
|
// src/auth/LightsparkAuthException.ts
|
|
103
159
|
var LightsparkAuthException = class extends LightsparkException_default {
|
|
104
160
|
constructor(message, extraInfo) {
|
|
@@ -126,6 +182,9 @@ var ConfigKeys = {
|
|
|
126
182
|
ConsoleToolsEnabled: "lightspark-console-tools-enabled"
|
|
127
183
|
};
|
|
128
184
|
var getLocalStorageConfigItem = (key) => {
|
|
185
|
+
return getLocalStorageBoolean(key);
|
|
186
|
+
};
|
|
187
|
+
var getLocalStorageBoolean = (key) => {
|
|
129
188
|
try {
|
|
130
189
|
return localStorage.getItem(key) === "1";
|
|
131
190
|
} catch (e) {
|
|
@@ -133,6 +192,23 @@ var getLocalStorageConfigItem = (key) => {
|
|
|
133
192
|
}
|
|
134
193
|
};
|
|
135
194
|
|
|
195
|
+
// src/crypto/KeyOrAlias.ts
|
|
196
|
+
var KeyOrAlias = {
|
|
197
|
+
key: (key) => ({ key }),
|
|
198
|
+
alias: (alias) => ({ alias })
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// src/crypto/LightsparkSigningException.ts
|
|
202
|
+
var LightsparkSigningException = class extends LightsparkException_default {
|
|
203
|
+
constructor(message, extraInfo) {
|
|
204
|
+
super("SigningException", message, extraInfo);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
var LightsparkSigningException_default = LightsparkSigningException;
|
|
208
|
+
|
|
209
|
+
// src/crypto/NodeKeyCache.ts
|
|
210
|
+
var import_auto_bind = __toESM(require("auto-bind"), 1);
|
|
211
|
+
|
|
136
212
|
// src/utils/base64.ts
|
|
137
213
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
138
214
|
var Base64 = {
|
|
@@ -176,14 +252,6 @@ var b64encode = (data) => {
|
|
|
176
252
|
);
|
|
177
253
|
};
|
|
178
254
|
|
|
179
|
-
// src/crypto/LightsparkSigningException.ts
|
|
180
|
-
var LightsparkSigningException = class extends LightsparkException_default {
|
|
181
|
-
constructor(message, extraInfo) {
|
|
182
|
-
super("SigningException", message, extraInfo);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
var LightsparkSigningException_default = LightsparkSigningException;
|
|
186
|
-
|
|
187
255
|
// src/crypto/crypto.ts
|
|
188
256
|
var getCrypto = () => {
|
|
189
257
|
let cryptoImplPromise;
|
|
@@ -278,7 +346,10 @@ var decrypt = async (header_json, ciphertext, password) => {
|
|
|
278
346
|
const salt = decoded.slice(decoded.length - 8, decoded.length);
|
|
279
347
|
const nonce = decoded.slice(0, 12);
|
|
280
348
|
const cipherText = decoded.slice(12, decoded.length - 8);
|
|
281
|
-
const [
|
|
349
|
+
const [
|
|
350
|
+
key
|
|
351
|
+
/* , _iv */
|
|
352
|
+
] = await deriveKey(
|
|
282
353
|
password,
|
|
283
354
|
salt,
|
|
284
355
|
header.i,
|
|
@@ -388,23 +459,9 @@ var DefaultCrypto = {
|
|
|
388
459
|
importPrivateSigningKey
|
|
389
460
|
};
|
|
390
461
|
|
|
391
|
-
// src/crypto/KeyOrAlias.ts
|
|
392
|
-
var KeyOrAlias = {
|
|
393
|
-
key: (key) => ({ key }),
|
|
394
|
-
alias: (alias) => ({ alias })
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
// src/crypto/NodeKeyCache.ts
|
|
398
|
-
var import_auto_bind = __toESM(require("auto-bind"), 1);
|
|
399
|
-
|
|
400
462
|
// src/crypto/SigningKey.ts
|
|
401
463
|
var import_secp256k1 = __toESM(require("secp256k1"), 1);
|
|
402
464
|
|
|
403
|
-
// src/utils/environment.ts
|
|
404
|
-
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
405
|
-
var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
406
|
-
var isTest = isNode && process.env.NODE_ENV === "test";
|
|
407
|
-
|
|
408
465
|
// src/utils/hex.ts
|
|
409
466
|
var bytesToHex = (bytes) => {
|
|
410
467
|
return bytes.reduce((acc, byte) => {
|
|
@@ -1073,6 +1130,14 @@ var isErrorMsg = (e, msg) => {
|
|
|
1073
1130
|
}
|
|
1074
1131
|
return false;
|
|
1075
1132
|
};
|
|
1133
|
+
function errorToJSON(err) {
|
|
1134
|
+
if (typeof err === "object" && err !== null && "toJSON" in err && typeof err.toJSON === "function") {
|
|
1135
|
+
return err.toJSON();
|
|
1136
|
+
}
|
|
1137
|
+
return JSON.parse(
|
|
1138
|
+
JSON.stringify(err, Object.getOwnPropertyNames(err))
|
|
1139
|
+
);
|
|
1140
|
+
}
|
|
1076
1141
|
|
|
1077
1142
|
// ../../node_modules/lodash-es/_freeGlobal.js
|
|
1078
1143
|
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
@@ -1295,39 +1360,6 @@ var NodeKeyCache = class {
|
|
|
1295
1360
|
};
|
|
1296
1361
|
var NodeKeyCache_default = NodeKeyCache;
|
|
1297
1362
|
|
|
1298
|
-
// src/Logger.ts
|
|
1299
|
-
var Logger = class {
|
|
1300
|
-
context;
|
|
1301
|
-
loggingEnabled = false;
|
|
1302
|
-
constructor(loggerContext, getLoggingEnabled) {
|
|
1303
|
-
this.context = loggerContext;
|
|
1304
|
-
void this.updateLoggingEnabled(getLoggingEnabled);
|
|
1305
|
-
}
|
|
1306
|
-
async updateLoggingEnabled(getLoggingEnabled) {
|
|
1307
|
-
if (getLoggingEnabled) {
|
|
1308
|
-
this.loggingEnabled = await getLoggingEnabled();
|
|
1309
|
-
} else if (isTest) {
|
|
1310
|
-
this.loggingEnabled = true;
|
|
1311
|
-
} else if (isBrowser) {
|
|
1312
|
-
try {
|
|
1313
|
-
this.loggingEnabled = getLocalStorageConfigItem(
|
|
1314
|
-
ConfigKeys.LoggingEnabled
|
|
1315
|
-
);
|
|
1316
|
-
} catch (e) {
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
if (this.loggingEnabled) {
|
|
1320
|
-
console.log(`[${this.context}] Logging enabled`);
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
info(message, ...rest) {
|
|
1324
|
-
if (this.loggingEnabled) {
|
|
1325
|
-
console.log(`[${this.context}] ${message}`, ...rest);
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
};
|
|
1329
|
-
var logger = new Logger("@lightsparkdev/core");
|
|
1330
|
-
|
|
1331
1363
|
// src/requester/Requester.ts
|
|
1332
1364
|
var import_auto_bind2 = __toESM(require("auto-bind"), 1);
|
|
1333
1365
|
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
@@ -1452,6 +1484,7 @@ var Requester = class {
|
|
|
1452
1484
|
const url = `${urlWithProtocol}/${this.schemaEndpoint}`;
|
|
1453
1485
|
logger.info(`Requester.makeRawRequest`, {
|
|
1454
1486
|
url,
|
|
1487
|
+
operationName: operation,
|
|
1455
1488
|
variables
|
|
1456
1489
|
});
|
|
1457
1490
|
const response = await fetch(url, {
|
|
@@ -1522,22 +1555,6 @@ var Requester = class {
|
|
|
1522
1555
|
}
|
|
1523
1556
|
};
|
|
1524
1557
|
var Requester_default = Requester;
|
|
1525
|
-
|
|
1526
|
-
// src/ServerEnvironment.ts
|
|
1527
|
-
var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
|
|
1528
|
-
ServerEnvironment2["PRODUCTION"] = "production";
|
|
1529
|
-
ServerEnvironment2["DEV"] = "dev";
|
|
1530
|
-
return ServerEnvironment2;
|
|
1531
|
-
})(ServerEnvironment || {});
|
|
1532
|
-
var apiDomainForEnvironment = (environment) => {
|
|
1533
|
-
switch (environment) {
|
|
1534
|
-
case "dev" /* DEV */:
|
|
1535
|
-
return "api.dev.dev.sparkinfra.net";
|
|
1536
|
-
case "production" /* PRODUCTION */:
|
|
1537
|
-
return "api.lightspark.com";
|
|
1538
|
-
}
|
|
1539
|
-
};
|
|
1540
|
-
var ServerEnvironment_default = ServerEnvironment;
|
|
1541
1558
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1542
1559
|
0 && (module.exports = {
|
|
1543
1560
|
ConfigKeys,
|
|
@@ -1567,9 +1584,11 @@ var ServerEnvironment_default = ServerEnvironment;
|
|
|
1567
1584
|
countryCodesToCurrencyCodes,
|
|
1568
1585
|
createSha256Hash,
|
|
1569
1586
|
defaultCurrencyCode,
|
|
1587
|
+
errorToJSON,
|
|
1570
1588
|
formatCurrencyStr,
|
|
1571
1589
|
getCurrentLocale,
|
|
1572
1590
|
getErrorMsg,
|
|
1591
|
+
getLocalStorageBoolean,
|
|
1573
1592
|
getLocalStorageConfigItem,
|
|
1574
1593
|
hexToBytes,
|
|
1575
1594
|
isBrowser,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import { Observable } from 'zen-observable-ts';
|
|
2
|
-
export { ById, CurrencyAmountArg, CurrencyAmountObj, CurrencyAmountType, CurrencyCodes, CurrencyLocales, CurrencyMap, CurrencyUnit, DeepPartial, ExpandRecursively, Maybe, OmitTypename, abbrCurrencyUnit, b64decode, b64encode, bytesToHex, clamp, convertCurrencyAmount, convertCurrencyAmountValue, countryCodesToCurrencyCodes, createSha256Hash, defaultCurrencyCode, formatCurrencyStr, getCurrentLocale, getErrorMsg, hexToBytes, isBrowser, isCurrencyAmount, isCurrencyAmountObj, isCurrencyMap, isError, isErrorMsg, isErrorWithMessage, isNode, isNumber, isTest, isType, linearInterpolate, localeToCurrencyCode, localeToCurrencySymbol, mapCurrencyAmount, pollUntil, round, separateCurrencyStrParts, sleep, urlsafe_b64decode } from './utils/index.cjs';
|
|
2
|
+
export { ById, CurrencyAmountArg, CurrencyAmountObj, CurrencyAmountType, CurrencyCodes, CurrencyLocales, CurrencyMap, CurrencyUnit, DeepPartial, ExpandRecursively, JSONLiteral, JSONObject, JSONType, Maybe, OmitTypename, abbrCurrencyUnit, b64decode, b64encode, bytesToHex, clamp, convertCurrencyAmount, convertCurrencyAmountValue, countryCodesToCurrencyCodes, createSha256Hash, defaultCurrencyCode, errorToJSON, formatCurrencyStr, getCurrentLocale, getErrorMsg, hexToBytes, isBrowser, isCurrencyAmount, isCurrencyAmountObj, isCurrencyMap, isError, isErrorMsg, isErrorWithMessage, isNode, isNumber, isTest, isType, linearInterpolate, localeToCurrencyCode, localeToCurrencySymbol, mapCurrencyAmount, pollUntil, round, separateCurrencyStrParts, sleep, urlsafe_b64decode } from './utils/index.cjs';
|
|
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 class Logger {
|
|
13
|
+
context: string;
|
|
14
|
+
loggingEnabled: boolean;
|
|
15
|
+
constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
|
|
16
|
+
updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
|
|
17
|
+
info(message: string, ...rest: unknown[]): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare enum ServerEnvironment {
|
|
21
|
+
PRODUCTION = "production",
|
|
22
|
+
DEV = "dev"
|
|
23
|
+
}
|
|
24
|
+
declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
|
|
3
25
|
|
|
4
26
|
type Headers = Record<string, string>;
|
|
5
27
|
type WsConnectionParams = Record<string, unknown>;
|
|
@@ -9,13 +31,6 @@ interface AuthProvider {
|
|
|
9
31
|
addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
|
|
10
32
|
}
|
|
11
33
|
|
|
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
|
-
|
|
19
34
|
declare class LightsparkAuthException extends LightsparkException {
|
|
20
35
|
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
21
36
|
}
|
|
@@ -32,6 +47,21 @@ declare const ConfigKeys: {
|
|
|
32
47
|
};
|
|
33
48
|
type ConfigKeys = (typeof ConfigKeys)[keyof typeof ConfigKeys];
|
|
34
49
|
declare const getLocalStorageConfigItem: (key: ConfigKeys) => boolean;
|
|
50
|
+
declare const getLocalStorageBoolean: (key: string) => boolean;
|
|
51
|
+
|
|
52
|
+
type OnlyKey = {
|
|
53
|
+
key: string;
|
|
54
|
+
alias?: never;
|
|
55
|
+
};
|
|
56
|
+
type OnlyAlias = {
|
|
57
|
+
key?: never;
|
|
58
|
+
alias: string;
|
|
59
|
+
};
|
|
60
|
+
type KeyOrAliasType = OnlyKey | OnlyAlias;
|
|
61
|
+
declare const KeyOrAlias: {
|
|
62
|
+
key: (key: string) => OnlyKey;
|
|
63
|
+
alias: (alias: string) => OnlyAlias;
|
|
64
|
+
};
|
|
35
65
|
|
|
36
66
|
declare class LightsparkSigningException extends LightsparkException {
|
|
37
67
|
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
@@ -60,20 +90,6 @@ declare const DefaultCrypto: {
|
|
|
60
90
|
importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
|
|
61
91
|
};
|
|
62
92
|
|
|
63
|
-
type OnlyKey = {
|
|
64
|
-
key: string;
|
|
65
|
-
alias?: never;
|
|
66
|
-
};
|
|
67
|
-
type OnlyAlias = {
|
|
68
|
-
key?: never;
|
|
69
|
-
alias: string;
|
|
70
|
-
};
|
|
71
|
-
type KeyOrAliasType = OnlyKey | OnlyAlias;
|
|
72
|
-
declare const KeyOrAlias: {
|
|
73
|
-
key: (key: string) => OnlyKey;
|
|
74
|
-
alias: (alias: string) => OnlyAlias;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
93
|
interface Alias {
|
|
78
94
|
alias: string;
|
|
79
95
|
}
|
|
@@ -109,15 +125,6 @@ declare class NodeKeyCache {
|
|
|
109
125
|
private stripPemTags;
|
|
110
126
|
}
|
|
111
127
|
|
|
112
|
-
type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
|
|
113
|
-
declare class Logger {
|
|
114
|
-
context: string;
|
|
115
|
-
loggingEnabled: boolean;
|
|
116
|
-
constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
|
|
117
|
-
updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
|
|
118
|
-
info(message: string, ...rest: unknown[]): void;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
128
|
type Query<T> = {
|
|
122
129
|
/** The string representation of the query payload for graphQL. **/
|
|
123
130
|
queryPayload: string;
|
|
@@ -125,7 +132,10 @@ type Query<T> = {
|
|
|
125
132
|
variables?: {
|
|
126
133
|
[key: string]: unknown;
|
|
127
134
|
};
|
|
128
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* The function that will be called to construct the object from the
|
|
137
|
+
* response. *
|
|
138
|
+
*/
|
|
129
139
|
constructObject: (rawData: any) => T;
|
|
130
140
|
/** The id of the node that will be used to sign the query. **/
|
|
131
141
|
signingNodeId?: string;
|
|
@@ -156,10 +166,4 @@ declare class Requester {
|
|
|
156
166
|
private addSigningDataIfNeeded;
|
|
157
167
|
}
|
|
158
168
|
|
|
159
|
-
|
|
160
|
-
PRODUCTION = "production",
|
|
161
|
-
DEV = "dev"
|
|
162
|
-
}
|
|
163
|
-
declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
|
|
164
|
-
|
|
165
|
-
export { AuthProvider, ConfigKeys, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, getLocalStorageConfigItem };
|
|
169
|
+
export { AuthProvider, ConfigKeys, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, getLocalStorageBoolean, getLocalStorageConfigItem };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import { Observable } from 'zen-observable-ts';
|
|
2
|
-
export { ById, CurrencyAmountArg, CurrencyAmountObj, CurrencyAmountType, CurrencyCodes, CurrencyLocales, CurrencyMap, CurrencyUnit, DeepPartial, ExpandRecursively, Maybe, OmitTypename, abbrCurrencyUnit, b64decode, b64encode, bytesToHex, clamp, convertCurrencyAmount, convertCurrencyAmountValue, countryCodesToCurrencyCodes, createSha256Hash, defaultCurrencyCode, formatCurrencyStr, getCurrentLocale, getErrorMsg, hexToBytes, isBrowser, isCurrencyAmount, isCurrencyAmountObj, isCurrencyMap, isError, isErrorMsg, isErrorWithMessage, isNode, isNumber, isTest, isType, linearInterpolate, localeToCurrencyCode, localeToCurrencySymbol, mapCurrencyAmount, pollUntil, round, separateCurrencyStrParts, sleep, urlsafe_b64decode } from './utils/index.js';
|
|
2
|
+
export { ById, CurrencyAmountArg, CurrencyAmountObj, CurrencyAmountType, CurrencyCodes, CurrencyLocales, CurrencyMap, CurrencyUnit, DeepPartial, ExpandRecursively, JSONLiteral, JSONObject, JSONType, Maybe, OmitTypename, abbrCurrencyUnit, b64decode, b64encode, bytesToHex, clamp, convertCurrencyAmount, convertCurrencyAmountValue, countryCodesToCurrencyCodes, createSha256Hash, defaultCurrencyCode, errorToJSON, formatCurrencyStr, getCurrentLocale, getErrorMsg, hexToBytes, isBrowser, isCurrencyAmount, isCurrencyAmountObj, isCurrencyMap, isError, isErrorMsg, isErrorWithMessage, isNode, isNumber, isTest, isType, linearInterpolate, localeToCurrencyCode, localeToCurrencySymbol, mapCurrencyAmount, pollUntil, round, separateCurrencyStrParts, sleep, urlsafe_b64decode } from './utils/index.js';
|
|
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 class Logger {
|
|
13
|
+
context: string;
|
|
14
|
+
loggingEnabled: boolean;
|
|
15
|
+
constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
|
|
16
|
+
updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
|
|
17
|
+
info(message: string, ...rest: unknown[]): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare enum ServerEnvironment {
|
|
21
|
+
PRODUCTION = "production",
|
|
22
|
+
DEV = "dev"
|
|
23
|
+
}
|
|
24
|
+
declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
|
|
3
25
|
|
|
4
26
|
type Headers = Record<string, string>;
|
|
5
27
|
type WsConnectionParams = Record<string, unknown>;
|
|
@@ -9,13 +31,6 @@ interface AuthProvider {
|
|
|
9
31
|
addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
|
|
10
32
|
}
|
|
11
33
|
|
|
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
|
-
|
|
19
34
|
declare class LightsparkAuthException extends LightsparkException {
|
|
20
35
|
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
21
36
|
}
|
|
@@ -32,6 +47,21 @@ declare const ConfigKeys: {
|
|
|
32
47
|
};
|
|
33
48
|
type ConfigKeys = (typeof ConfigKeys)[keyof typeof ConfigKeys];
|
|
34
49
|
declare const getLocalStorageConfigItem: (key: ConfigKeys) => boolean;
|
|
50
|
+
declare const getLocalStorageBoolean: (key: string) => boolean;
|
|
51
|
+
|
|
52
|
+
type OnlyKey = {
|
|
53
|
+
key: string;
|
|
54
|
+
alias?: never;
|
|
55
|
+
};
|
|
56
|
+
type OnlyAlias = {
|
|
57
|
+
key?: never;
|
|
58
|
+
alias: string;
|
|
59
|
+
};
|
|
60
|
+
type KeyOrAliasType = OnlyKey | OnlyAlias;
|
|
61
|
+
declare const KeyOrAlias: {
|
|
62
|
+
key: (key: string) => OnlyKey;
|
|
63
|
+
alias: (alias: string) => OnlyAlias;
|
|
64
|
+
};
|
|
35
65
|
|
|
36
66
|
declare class LightsparkSigningException extends LightsparkException {
|
|
37
67
|
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
@@ -60,20 +90,6 @@ declare const DefaultCrypto: {
|
|
|
60
90
|
importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
|
|
61
91
|
};
|
|
62
92
|
|
|
63
|
-
type OnlyKey = {
|
|
64
|
-
key: string;
|
|
65
|
-
alias?: never;
|
|
66
|
-
};
|
|
67
|
-
type OnlyAlias = {
|
|
68
|
-
key?: never;
|
|
69
|
-
alias: string;
|
|
70
|
-
};
|
|
71
|
-
type KeyOrAliasType = OnlyKey | OnlyAlias;
|
|
72
|
-
declare const KeyOrAlias: {
|
|
73
|
-
key: (key: string) => OnlyKey;
|
|
74
|
-
alias: (alias: string) => OnlyAlias;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
93
|
interface Alias {
|
|
78
94
|
alias: string;
|
|
79
95
|
}
|
|
@@ -109,15 +125,6 @@ declare class NodeKeyCache {
|
|
|
109
125
|
private stripPemTags;
|
|
110
126
|
}
|
|
111
127
|
|
|
112
|
-
type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
|
|
113
|
-
declare class Logger {
|
|
114
|
-
context: string;
|
|
115
|
-
loggingEnabled: boolean;
|
|
116
|
-
constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
|
|
117
|
-
updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
|
|
118
|
-
info(message: string, ...rest: unknown[]): void;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
128
|
type Query<T> = {
|
|
122
129
|
/** The string representation of the query payload for graphQL. **/
|
|
123
130
|
queryPayload: string;
|
|
@@ -125,7 +132,10 @@ type Query<T> = {
|
|
|
125
132
|
variables?: {
|
|
126
133
|
[key: string]: unknown;
|
|
127
134
|
};
|
|
128
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* The function that will be called to construct the object from the
|
|
137
|
+
* response. *
|
|
138
|
+
*/
|
|
129
139
|
constructObject: (rawData: any) => T;
|
|
130
140
|
/** The id of the node that will be used to sign the query. **/
|
|
131
141
|
signingNodeId?: string;
|
|
@@ -156,10 +166,4 @@ declare class Requester {
|
|
|
156
166
|
private addSigningDataIfNeeded;
|
|
157
167
|
}
|
|
158
168
|
|
|
159
|
-
|
|
160
|
-
PRODUCTION = "production",
|
|
161
|
-
DEV = "dev"
|
|
162
|
-
}
|
|
163
|
-
declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
|
|
164
|
-
|
|
165
|
-
export { AuthProvider, ConfigKeys, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, getLocalStorageConfigItem };
|
|
169
|
+
export { AuthProvider, ConfigKeys, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, getLocalStorageBoolean, getLocalStorageConfigItem };
|