@lightsparkdev/core 1.2.1 → 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 +8 -0
- package/dist/{chunk-YRWJVCZI.js → chunk-22DUJXVY.js} +10 -4
- package/dist/{index-b1e5d968.d.ts → index-DdZ7x9Ef.d.cts} +9 -7
- package/dist/index-DdZ7x9Ef.d.ts +244 -0
- package/dist/index.cjs +139 -118
- package/dist/index.d.cts +47 -45
- package/dist/index.d.ts +47 -45
- package/dist/index.js +120 -105
- package/dist/utils/index.cjs +8 -1
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +3 -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/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
createSha256Hash,
|
|
13
13
|
defaultCurrencyCode,
|
|
14
14
|
deleteLocalStorageItem,
|
|
15
|
+
ensureArray,
|
|
15
16
|
errorToJSON,
|
|
16
17
|
formatCurrencyStr,
|
|
17
18
|
getCurrentLocale,
|
|
@@ -44,70 +45,7 @@ import {
|
|
|
44
45
|
setLocalStorageBoolean,
|
|
45
46
|
sleep,
|
|
46
47
|
urlsafe_b64decode
|
|
47
|
-
} from "./chunk-
|
|
48
|
-
|
|
49
|
-
// src/Logger.ts
|
|
50
|
-
var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
|
|
51
|
-
LoggingLevel2[LoggingLevel2["Trace"] = 0] = "Trace";
|
|
52
|
-
LoggingLevel2[LoggingLevel2["Info"] = 1] = "Info";
|
|
53
|
-
return LoggingLevel2;
|
|
54
|
-
})(LoggingLevel || {});
|
|
55
|
-
var Logger = class {
|
|
56
|
-
context;
|
|
57
|
-
loggingEnabled = false;
|
|
58
|
-
loggingLevel = 1 /* Info */;
|
|
59
|
-
constructor(loggerContext, getLoggingEnabled) {
|
|
60
|
-
this.context = loggerContext;
|
|
61
|
-
void this.updateLoggingEnabled(getLoggingEnabled);
|
|
62
|
-
}
|
|
63
|
-
setLevel(level) {
|
|
64
|
-
this.loggingLevel = level;
|
|
65
|
-
}
|
|
66
|
-
async updateLoggingEnabled(getLoggingEnabled) {
|
|
67
|
-
if (getLoggingEnabled) {
|
|
68
|
-
this.loggingEnabled = await getLoggingEnabled();
|
|
69
|
-
} else if (isTest) {
|
|
70
|
-
this.loggingEnabled = true;
|
|
71
|
-
} else if (isBrowser) {
|
|
72
|
-
try {
|
|
73
|
-
this.loggingEnabled = getLocalStorageConfigItem(
|
|
74
|
-
ConfigKeys.LoggingEnabled
|
|
75
|
-
);
|
|
76
|
-
} catch (e) {
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (this.loggingEnabled) {
|
|
80
|
-
console.log(`[${this.context}] Logging enabled`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
trace(message, ...rest) {
|
|
84
|
-
if (this.loggingEnabled && this.loggingLevel === 0 /* Trace */) {
|
|
85
|
-
console.log(`[${this.context}] ${message}`, ...rest);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
info(message, ...rest) {
|
|
89
|
-
if (this.loggingEnabled && this.loggingLevel <= 1 /* Info */) {
|
|
90
|
-
console.log(`[${this.context}] ${message}`, ...rest);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
var logger = new Logger("@lightsparkdev/core");
|
|
95
|
-
|
|
96
|
-
// src/ServerEnvironment.ts
|
|
97
|
-
var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
|
|
98
|
-
ServerEnvironment2["PRODUCTION"] = "production";
|
|
99
|
-
ServerEnvironment2["DEV"] = "dev";
|
|
100
|
-
return ServerEnvironment2;
|
|
101
|
-
})(ServerEnvironment || {});
|
|
102
|
-
var apiDomainForEnvironment = (environment) => {
|
|
103
|
-
switch (environment) {
|
|
104
|
-
case "dev" /* DEV */:
|
|
105
|
-
return "api.dev.dev.sparkinfra.net";
|
|
106
|
-
case "production" /* PRODUCTION */:
|
|
107
|
-
return "api.lightspark.com";
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
var ServerEnvironment_default = ServerEnvironment;
|
|
48
|
+
} from "./chunk-22DUJXVY.js";
|
|
111
49
|
|
|
112
50
|
// src/auth/LightsparkAuthException.ts
|
|
113
51
|
var LightsparkAuthException = class extends LightsparkException_default {
|
|
@@ -136,12 +74,6 @@ var ConfigKeys = {
|
|
|
136
74
|
ConsoleToolsEnabled: "lightspark-console-tools-enabled"
|
|
137
75
|
};
|
|
138
76
|
|
|
139
|
-
// src/crypto/KeyOrAlias.ts
|
|
140
|
-
var KeyOrAlias = {
|
|
141
|
-
key: (key) => ({ key }),
|
|
142
|
-
alias: (alias) => ({ alias })
|
|
143
|
-
};
|
|
144
|
-
|
|
145
77
|
// src/crypto/LightsparkSigningException.ts
|
|
146
78
|
var LightsparkSigningException = class extends LightsparkException_default {
|
|
147
79
|
constructor(message, extraInfo) {
|
|
@@ -150,39 +82,6 @@ var LightsparkSigningException = class extends LightsparkException_default {
|
|
|
150
82
|
};
|
|
151
83
|
var LightsparkSigningException_default = LightsparkSigningException;
|
|
152
84
|
|
|
153
|
-
// ../../node_modules/auto-bind/index.js
|
|
154
|
-
var getAllProperties = (object) => {
|
|
155
|
-
const properties = /* @__PURE__ */ new Set();
|
|
156
|
-
do {
|
|
157
|
-
for (const key of Reflect.ownKeys(object)) {
|
|
158
|
-
properties.add([object, key]);
|
|
159
|
-
}
|
|
160
|
-
} while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
|
|
161
|
-
return properties;
|
|
162
|
-
};
|
|
163
|
-
function autoBind(self, { include, exclude } = {}) {
|
|
164
|
-
const filter = (key) => {
|
|
165
|
-
const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
166
|
-
if (include) {
|
|
167
|
-
return include.some(match);
|
|
168
|
-
}
|
|
169
|
-
if (exclude) {
|
|
170
|
-
return !exclude.some(match);
|
|
171
|
-
}
|
|
172
|
-
return true;
|
|
173
|
-
};
|
|
174
|
-
for (const [object, key] of getAllProperties(self.constructor.prototype)) {
|
|
175
|
-
if (key === "constructor" || !filter(key)) {
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
179
|
-
if (descriptor && typeof descriptor.value === "function") {
|
|
180
|
-
self[key] = self[key].bind(self);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return self;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
85
|
// src/crypto/crypto.ts
|
|
187
86
|
var getCrypto = () => {
|
|
188
87
|
let cryptoImplPromise;
|
|
@@ -203,7 +102,8 @@ var getCrypto = () => {
|
|
|
203
102
|
return array;
|
|
204
103
|
}
|
|
205
104
|
const buffer = Buffer.from(array.buffer);
|
|
206
|
-
|
|
105
|
+
const view = new Uint8Array(buffer);
|
|
106
|
+
nodeCrypto.randomFillSync(view);
|
|
207
107
|
return array;
|
|
208
108
|
}
|
|
209
109
|
});
|
|
@@ -392,6 +292,45 @@ var DefaultCrypto = {
|
|
|
392
292
|
importPrivateSigningKey
|
|
393
293
|
};
|
|
394
294
|
|
|
295
|
+
// src/crypto/KeyOrAlias.ts
|
|
296
|
+
var KeyOrAlias = {
|
|
297
|
+
key: (key) => ({ key }),
|
|
298
|
+
alias: (alias) => ({ alias })
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
// ../../node_modules/auto-bind/index.js
|
|
302
|
+
var getAllProperties = (object) => {
|
|
303
|
+
const properties = /* @__PURE__ */ new Set();
|
|
304
|
+
do {
|
|
305
|
+
for (const key of Reflect.ownKeys(object)) {
|
|
306
|
+
properties.add([object, key]);
|
|
307
|
+
}
|
|
308
|
+
} while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
|
|
309
|
+
return properties;
|
|
310
|
+
};
|
|
311
|
+
function autoBind(self, { include, exclude } = {}) {
|
|
312
|
+
const filter = (key) => {
|
|
313
|
+
const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
314
|
+
if (include) {
|
|
315
|
+
return include.some(match);
|
|
316
|
+
}
|
|
317
|
+
if (exclude) {
|
|
318
|
+
return !exclude.some(match);
|
|
319
|
+
}
|
|
320
|
+
return true;
|
|
321
|
+
};
|
|
322
|
+
for (const [object, key] of getAllProperties(self.constructor.prototype)) {
|
|
323
|
+
if (key === "constructor" || !filter(key)) {
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
327
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
328
|
+
self[key] = self[key].bind(self);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return self;
|
|
332
|
+
}
|
|
333
|
+
|
|
395
334
|
// src/crypto/SigningKey.ts
|
|
396
335
|
import secp256k1 from "secp256k1";
|
|
397
336
|
function isAlias(key) {
|
|
@@ -488,6 +427,57 @@ var NodeKeyCache = class {
|
|
|
488
427
|
};
|
|
489
428
|
var NodeKeyCache_default = NodeKeyCache;
|
|
490
429
|
|
|
430
|
+
// src/Logger.ts
|
|
431
|
+
var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
|
|
432
|
+
LoggingLevel2[LoggingLevel2["Trace"] = 0] = "Trace";
|
|
433
|
+
LoggingLevel2[LoggingLevel2["Info"] = 1] = "Info";
|
|
434
|
+
return LoggingLevel2;
|
|
435
|
+
})(LoggingLevel || {});
|
|
436
|
+
var Logger = class {
|
|
437
|
+
context;
|
|
438
|
+
loggingEnabled = false;
|
|
439
|
+
loggingLevel = 1 /* Info */;
|
|
440
|
+
constructor(loggerContext, getLoggingEnabled) {
|
|
441
|
+
this.context = loggerContext;
|
|
442
|
+
void this.updateLoggingEnabled(getLoggingEnabled);
|
|
443
|
+
}
|
|
444
|
+
setLevel(level) {
|
|
445
|
+
this.loggingLevel = level;
|
|
446
|
+
}
|
|
447
|
+
setEnabled(enabled, level = 1 /* Info */) {
|
|
448
|
+
this.loggingEnabled = enabled;
|
|
449
|
+
this.loggingLevel = level;
|
|
450
|
+
}
|
|
451
|
+
async updateLoggingEnabled(getLoggingEnabled) {
|
|
452
|
+
if (getLoggingEnabled) {
|
|
453
|
+
this.loggingEnabled = await getLoggingEnabled();
|
|
454
|
+
} else if (isTest) {
|
|
455
|
+
this.loggingEnabled = true;
|
|
456
|
+
} else if (isBrowser) {
|
|
457
|
+
try {
|
|
458
|
+
this.loggingEnabled = getLocalStorageConfigItem(
|
|
459
|
+
ConfigKeys.LoggingEnabled
|
|
460
|
+
);
|
|
461
|
+
} catch (e) {
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (this.loggingEnabled) {
|
|
465
|
+
console.log(`[${this.context}] Logging enabled`);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
trace(message, ...rest) {
|
|
469
|
+
if (this.loggingEnabled && this.loggingLevel === 0 /* Trace */) {
|
|
470
|
+
console.log(`[${this.context}] ${message}`, ...rest);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
info(message, ...rest) {
|
|
474
|
+
if (this.loggingEnabled && this.loggingLevel <= 1 /* Info */) {
|
|
475
|
+
console.log(`[${this.context}] ${message}`, ...rest);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
var logger = new Logger("@lightsparkdev/core");
|
|
480
|
+
|
|
491
481
|
// src/requester/Requester.ts
|
|
492
482
|
import dayjs from "dayjs";
|
|
493
483
|
import utc from "dayjs/plugin/utc.js";
|
|
@@ -565,6 +555,12 @@ var Requester = class {
|
|
|
565
555
|
});
|
|
566
556
|
}
|
|
567
557
|
async makeRawRequest(queryPayload, variables = {}, signingNodeId = void 0, skipAuth = false) {
|
|
558
|
+
logger.trace(`Requester.makeRawRequest args`, {
|
|
559
|
+
queryPayload,
|
|
560
|
+
variables,
|
|
561
|
+
signingNodeId,
|
|
562
|
+
skipAuth
|
|
563
|
+
});
|
|
568
564
|
const operationNameRegex = /^\s*(query|mutation|subscription)\s+(\w+)/i;
|
|
569
565
|
const operationMatch = queryPayload.match(operationNameRegex);
|
|
570
566
|
if (!operationMatch || operationMatch.length < 3) {
|
|
@@ -614,7 +610,8 @@ var Requester = class {
|
|
|
614
610
|
logger.trace(`Requester.makeRawRequest`, {
|
|
615
611
|
url,
|
|
616
612
|
operationName: operation,
|
|
617
|
-
variables
|
|
613
|
+
variables,
|
|
614
|
+
headers
|
|
618
615
|
});
|
|
619
616
|
const response = await fetch(url, {
|
|
620
617
|
method: "POST",
|
|
@@ -699,6 +696,22 @@ async function compress(data) {
|
|
|
699
696
|
return new Uint8Array(await blob.arrayBuffer());
|
|
700
697
|
}
|
|
701
698
|
var Requester_default = Requester;
|
|
699
|
+
|
|
700
|
+
// src/ServerEnvironment.ts
|
|
701
|
+
var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
|
|
702
|
+
ServerEnvironment2["PRODUCTION"] = "production";
|
|
703
|
+
ServerEnvironment2["DEV"] = "dev";
|
|
704
|
+
return ServerEnvironment2;
|
|
705
|
+
})(ServerEnvironment || {});
|
|
706
|
+
var apiDomainForEnvironment = (environment) => {
|
|
707
|
+
switch (environment) {
|
|
708
|
+
case "dev" /* DEV */:
|
|
709
|
+
return "api.dev.dev.sparkinfra.net";
|
|
710
|
+
case "production" /* PRODUCTION */:
|
|
711
|
+
return "api.lightspark.com";
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
var ServerEnvironment_default = ServerEnvironment;
|
|
702
715
|
export {
|
|
703
716
|
ConfigKeys,
|
|
704
717
|
CurrencyUnit,
|
|
@@ -729,6 +742,7 @@ export {
|
|
|
729
742
|
createSha256Hash,
|
|
730
743
|
defaultCurrencyCode,
|
|
731
744
|
deleteLocalStorageItem,
|
|
745
|
+
ensureArray,
|
|
732
746
|
errorToJSON,
|
|
733
747
|
formatCurrencyStr,
|
|
734
748
|
getCurrentLocale,
|
|
@@ -752,6 +766,7 @@ export {
|
|
|
752
766
|
linearInterpolate,
|
|
753
767
|
localeToCurrencyCode,
|
|
754
768
|
localeToCurrencySymbol,
|
|
769
|
+
logger,
|
|
755
770
|
lsidToUUID,
|
|
756
771
|
mapCurrencyAmount,
|
|
757
772
|
notNullUndefined,
|
package/dist/utils/index.cjs
CHANGED
|
@@ -42,6 +42,7 @@ __export(utils_exports, {
|
|
|
42
42
|
createSha256Hash: () => createSha256Hash,
|
|
43
43
|
defaultCurrencyCode: () => defaultCurrencyCode,
|
|
44
44
|
deleteLocalStorageItem: () => deleteLocalStorageItem,
|
|
45
|
+
ensureArray: () => ensureArray,
|
|
45
46
|
errorToJSON: () => errorToJSON,
|
|
46
47
|
formatCurrencyStr: () => formatCurrencyStr,
|
|
47
48
|
getCurrentLocale: () => getCurrentLocale,
|
|
@@ -77,6 +78,11 @@ __export(utils_exports, {
|
|
|
77
78
|
});
|
|
78
79
|
module.exports = __toCommonJS(utils_exports);
|
|
79
80
|
|
|
81
|
+
// src/utils/arrays.ts
|
|
82
|
+
function ensureArray(value) {
|
|
83
|
+
return Array.isArray(value) ? value : [value];
|
|
84
|
+
}
|
|
85
|
+
|
|
80
86
|
// src/utils/base64.ts
|
|
81
87
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
82
88
|
var Base64 = {
|
|
@@ -816,7 +822,7 @@ function localeToCurrencySymbol(locale) {
|
|
|
816
822
|
// src/utils/errors.ts
|
|
817
823
|
var isError = (e) => {
|
|
818
824
|
return Boolean(
|
|
819
|
-
typeof e === "object" && e !== null && "name" in e && typeof e.name === "string" && "message" in e && typeof e.message === "string"
|
|
825
|
+
typeof e === "object" && e !== null && "name" in e && typeof e.name === "string" && "message" in e && typeof e.message === "string"
|
|
820
826
|
);
|
|
821
827
|
};
|
|
822
828
|
var isErrorWithMessage = (e) => {
|
|
@@ -1029,6 +1035,7 @@ function notNullUndefined(value) {
|
|
|
1029
1035
|
createSha256Hash,
|
|
1030
1036
|
defaultCurrencyCode,
|
|
1031
1037
|
deleteLocalStorageItem,
|
|
1038
|
+
ensureArray,
|
|
1032
1039
|
errorToJSON,
|
|
1033
1040
|
formatCurrencyStr,
|
|
1034
1041
|
getCurrentLocale,
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { $ as ById, a9 as Complete, 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';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { $ as ById, a9 as Complete, 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';
|
package/dist/utils/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
createSha256Hash,
|
|
12
12
|
defaultCurrencyCode,
|
|
13
13
|
deleteLocalStorageItem,
|
|
14
|
+
ensureArray,
|
|
14
15
|
errorToJSON,
|
|
15
16
|
formatCurrencyStr,
|
|
16
17
|
getCurrentLocale,
|
|
@@ -43,7 +44,7 @@ import {
|
|
|
43
44
|
setLocalStorageBoolean,
|
|
44
45
|
sleep,
|
|
45
46
|
urlsafe_b64decode
|
|
46
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-22DUJXVY.js";
|
|
47
48
|
export {
|
|
48
49
|
CurrencyUnit,
|
|
49
50
|
abbrCurrencyUnit,
|
|
@@ -57,6 +58,7 @@ export {
|
|
|
57
58
|
createSha256Hash,
|
|
58
59
|
defaultCurrencyCode,
|
|
59
60
|
deleteLocalStorageItem,
|
|
61
|
+
ensureArray,
|
|
60
62
|
errorToJSON,
|
|
61
63
|
formatCurrencyStr,
|
|
62
64
|
getCurrentLocale,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightsparkdev/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Lightspark JS SDK",
|
|
5
5
|
"author": "Lightspark Inc.",
|
|
6
6
|
"keywords": [
|
|
@@ -44,8 +44,7 @@
|
|
|
44
44
|
"require": {
|
|
45
45
|
"types": "./dist/utils/index.d.ts",
|
|
46
46
|
"default": "./dist/utils/index.cjs"
|
|
47
|
-
}
|
|
48
|
-
"default": "./dist/utils/index.cjs"
|
|
47
|
+
}
|
|
49
48
|
}
|
|
50
49
|
},
|
|
51
50
|
"browser": {
|
|
@@ -59,7 +58,7 @@
|
|
|
59
58
|
"scripts": {
|
|
60
59
|
"build": "yarn tsc && tsup",
|
|
61
60
|
"build:watch": "yarn build --watch --clean=false",
|
|
62
|
-
"clean": "rm -rf
|
|
61
|
+
"clean": "rm -rf dist",
|
|
63
62
|
"dev": "yarn build -- --watch",
|
|
64
63
|
"format:fix": "prettier src --write",
|
|
65
64
|
"format": "prettier src --check",
|
|
@@ -100,8 +99,8 @@
|
|
|
100
99
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
101
100
|
"ts-jest": "^29.1.1",
|
|
102
101
|
"tsc-absolute": "^1.0.1",
|
|
103
|
-
"tsup": "^
|
|
104
|
-
"typescript": "^5.
|
|
102
|
+
"tsup": "^8.2.4",
|
|
103
|
+
"typescript": "^5.6.2"
|
|
105
104
|
},
|
|
106
105
|
"engines": {
|
|
107
106
|
"node": ">=18"
|
package/src/Logger.ts
CHANGED
|
@@ -22,6 +22,11 @@ export class Logger {
|
|
|
22
22
|
this.loggingLevel = level;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
public setEnabled(enabled: boolean, level: LoggingLevel = LoggingLevel.Info) {
|
|
26
|
+
this.loggingEnabled = enabled;
|
|
27
|
+
this.loggingLevel = level;
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
async updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled) {
|
|
26
31
|
if (getLoggingEnabled) {
|
|
27
32
|
this.loggingEnabled = await getLoggingEnabled();
|
package/src/crypto/crypto.ts
CHANGED
package/src/crypto/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
2
|
|
|
3
|
+
export * from "./crypto.js";
|
|
3
4
|
export * from "./KeyOrAlias.js";
|
|
4
5
|
export { default as LightsparkSigningException } from "./LightsparkSigningException.js";
|
|
5
6
|
export { default as NodeKeyCache } from "./NodeKeyCache.js";
|
|
6
7
|
export * from "./SigningKey.js";
|
|
7
|
-
export * from "./crypto.js";
|
|
8
8
|
export * from "./types.js";
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
2
|
|
|
3
|
+
export * from "./auth/index.js";
|
|
4
|
+
export * from "./constants/index.js";
|
|
5
|
+
export * from "./crypto/index.js";
|
|
3
6
|
export { default as LightsparkException } from "./LightsparkException.js";
|
|
4
|
-
export { Logger, LoggingLevel } from "./Logger.js";
|
|
7
|
+
export { Logger, LoggingLevel, logger } from "./Logger.js";
|
|
8
|
+
export * from "./requester/index.js";
|
|
5
9
|
export {
|
|
6
10
|
default as ServerEnvironment,
|
|
7
11
|
apiDomainForEnvironment,
|
|
8
12
|
} from "./ServerEnvironment.js";
|
|
9
|
-
export * from "./auth/index.js";
|
|
10
|
-
export * from "./constants/index.js";
|
|
11
|
-
export * from "./crypto/index.js";
|
|
12
|
-
export * from "./requester/index.js";
|
|
13
13
|
export * from "./utils/index.js";
|
|
@@ -118,6 +118,13 @@ class Requester {
|
|
|
118
118
|
skipAuth: boolean = false,
|
|
119
119
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any -- LIG-3400 */
|
|
120
120
|
): Promise<any> {
|
|
121
|
+
logger.trace(`Requester.makeRawRequest args`, {
|
|
122
|
+
queryPayload,
|
|
123
|
+
variables,
|
|
124
|
+
signingNodeId,
|
|
125
|
+
skipAuth,
|
|
126
|
+
});
|
|
127
|
+
|
|
121
128
|
const operationNameRegex = /^\s*(query|mutation|subscription)\s+(\w+)/i;
|
|
122
129
|
const operationMatch = queryPayload.match(operationNameRegex);
|
|
123
130
|
if (!operationMatch || operationMatch.length < 3) {
|
|
@@ -179,10 +186,11 @@ class Requester {
|
|
|
179
186
|
url,
|
|
180
187
|
operationName: operation,
|
|
181
188
|
variables,
|
|
189
|
+
headers,
|
|
182
190
|
});
|
|
183
191
|
const response = await fetch(url, {
|
|
184
192
|
method: "POST",
|
|
185
|
-
headers
|
|
193
|
+
headers,
|
|
186
194
|
body: bodyData,
|
|
187
195
|
});
|
|
188
196
|
if (!response.ok) {
|
package/src/utils/errors.ts
CHANGED
|
@@ -7,9 +7,7 @@ export const isError = (e: unknown): e is Error => {
|
|
|
7
7
|
"name" in e &&
|
|
8
8
|
typeof e.name === "string" &&
|
|
9
9
|
"message" in e &&
|
|
10
|
-
typeof e.message === "string"
|
|
11
|
-
"stack" in e &&
|
|
12
|
-
(!e.stack || typeof e.stack === "string"),
|
|
10
|
+
typeof e.message === "string",
|
|
13
11
|
);
|
|
14
12
|
};
|
|
15
13
|
|
package/src/utils/index.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
2
|
|
|
3
|
+
export * from "./arrays.js";
|
|
3
4
|
export * from "./base64.js";
|
|
4
5
|
export * from "./createHash.js";
|
|
5
6
|
export * from "./currency.js";
|
|
6
7
|
export * from "./environment.js";
|
|
7
8
|
export * from "./errors.js";
|
|
8
9
|
export * from "./hex.js";
|
|
9
|
-
export * from "./localStorage.js";
|
|
10
10
|
export * from "./locale.js";
|
|
11
11
|
export * from "./localeToCurrencyCodes.js";
|
|
12
|
+
export * from "./localStorage.js";
|
|
12
13
|
export * from "./numbers.js";
|
|
13
14
|
export * from "./pollUntil.js";
|
|
14
15
|
export * from "./sleep.js";
|