@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.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,
|
|
@@ -27,6 +28,7 @@ import {
|
|
|
27
28
|
isErrorWithMessage,
|
|
28
29
|
isNode,
|
|
29
30
|
isNumber,
|
|
31
|
+
isObject,
|
|
30
32
|
isSDKCurrencyAmount,
|
|
31
33
|
isTest,
|
|
32
34
|
isType,
|
|
@@ -43,70 +45,7 @@ import {
|
|
|
43
45
|
setLocalStorageBoolean,
|
|
44
46
|
sleep,
|
|
45
47
|
urlsafe_b64decode
|
|
46
|
-
} from "./chunk-
|
|
47
|
-
|
|
48
|
-
// src/Logger.ts
|
|
49
|
-
var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
|
|
50
|
-
LoggingLevel2[LoggingLevel2["Trace"] = 0] = "Trace";
|
|
51
|
-
LoggingLevel2[LoggingLevel2["Info"] = 1] = "Info";
|
|
52
|
-
return LoggingLevel2;
|
|
53
|
-
})(LoggingLevel || {});
|
|
54
|
-
var Logger = class {
|
|
55
|
-
context;
|
|
56
|
-
loggingEnabled = false;
|
|
57
|
-
loggingLevel = 1 /* Info */;
|
|
58
|
-
constructor(loggerContext, getLoggingEnabled) {
|
|
59
|
-
this.context = loggerContext;
|
|
60
|
-
void this.updateLoggingEnabled(getLoggingEnabled);
|
|
61
|
-
}
|
|
62
|
-
setLevel(level) {
|
|
63
|
-
this.loggingLevel = level;
|
|
64
|
-
}
|
|
65
|
-
async updateLoggingEnabled(getLoggingEnabled) {
|
|
66
|
-
if (getLoggingEnabled) {
|
|
67
|
-
this.loggingEnabled = await getLoggingEnabled();
|
|
68
|
-
} else if (isTest) {
|
|
69
|
-
this.loggingEnabled = true;
|
|
70
|
-
} else if (isBrowser) {
|
|
71
|
-
try {
|
|
72
|
-
this.loggingEnabled = getLocalStorageConfigItem(
|
|
73
|
-
ConfigKeys.LoggingEnabled
|
|
74
|
-
);
|
|
75
|
-
} catch (e) {
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (this.loggingEnabled) {
|
|
79
|
-
console.log(`[${this.context}] Logging enabled`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
trace(message, ...rest) {
|
|
83
|
-
if (this.loggingEnabled && this.loggingLevel === 0 /* Trace */) {
|
|
84
|
-
console.log(`[${this.context}] ${message}`, ...rest);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
info(message, ...rest) {
|
|
88
|
-
if (this.loggingEnabled && this.loggingLevel <= 1 /* Info */) {
|
|
89
|
-
console.log(`[${this.context}] ${message}`, ...rest);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
var logger = new Logger("@lightsparkdev/core");
|
|
94
|
-
|
|
95
|
-
// src/ServerEnvironment.ts
|
|
96
|
-
var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
|
|
97
|
-
ServerEnvironment2["PRODUCTION"] = "production";
|
|
98
|
-
ServerEnvironment2["DEV"] = "dev";
|
|
99
|
-
return ServerEnvironment2;
|
|
100
|
-
})(ServerEnvironment || {});
|
|
101
|
-
var apiDomainForEnvironment = (environment) => {
|
|
102
|
-
switch (environment) {
|
|
103
|
-
case "dev" /* DEV */:
|
|
104
|
-
return "api.dev.dev.sparkinfra.net";
|
|
105
|
-
case "production" /* PRODUCTION */:
|
|
106
|
-
return "api.lightspark.com";
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var ServerEnvironment_default = ServerEnvironment;
|
|
48
|
+
} from "./chunk-22DUJXVY.js";
|
|
110
49
|
|
|
111
50
|
// src/auth/LightsparkAuthException.ts
|
|
112
51
|
var LightsparkAuthException = class extends LightsparkException_default {
|
|
@@ -135,12 +74,6 @@ var ConfigKeys = {
|
|
|
135
74
|
ConsoleToolsEnabled: "lightspark-console-tools-enabled"
|
|
136
75
|
};
|
|
137
76
|
|
|
138
|
-
// src/crypto/KeyOrAlias.ts
|
|
139
|
-
var KeyOrAlias = {
|
|
140
|
-
key: (key) => ({ key }),
|
|
141
|
-
alias: (alias) => ({ alias })
|
|
142
|
-
};
|
|
143
|
-
|
|
144
77
|
// src/crypto/LightsparkSigningException.ts
|
|
145
78
|
var LightsparkSigningException = class extends LightsparkException_default {
|
|
146
79
|
constructor(message, extraInfo) {
|
|
@@ -149,39 +82,6 @@ var LightsparkSigningException = class extends LightsparkException_default {
|
|
|
149
82
|
};
|
|
150
83
|
var LightsparkSigningException_default = LightsparkSigningException;
|
|
151
84
|
|
|
152
|
-
// ../../node_modules/auto-bind/index.js
|
|
153
|
-
var getAllProperties = (object) => {
|
|
154
|
-
const properties = /* @__PURE__ */ new Set();
|
|
155
|
-
do {
|
|
156
|
-
for (const key of Reflect.ownKeys(object)) {
|
|
157
|
-
properties.add([object, key]);
|
|
158
|
-
}
|
|
159
|
-
} while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
|
|
160
|
-
return properties;
|
|
161
|
-
};
|
|
162
|
-
function autoBind(self, { include, exclude } = {}) {
|
|
163
|
-
const filter = (key) => {
|
|
164
|
-
const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
165
|
-
if (include) {
|
|
166
|
-
return include.some(match);
|
|
167
|
-
}
|
|
168
|
-
if (exclude) {
|
|
169
|
-
return !exclude.some(match);
|
|
170
|
-
}
|
|
171
|
-
return true;
|
|
172
|
-
};
|
|
173
|
-
for (const [object, key] of getAllProperties(self.constructor.prototype)) {
|
|
174
|
-
if (key === "constructor" || !filter(key)) {
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
178
|
-
if (descriptor && typeof descriptor.value === "function") {
|
|
179
|
-
self[key] = self[key].bind(self);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return self;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
85
|
// src/crypto/crypto.ts
|
|
186
86
|
var getCrypto = () => {
|
|
187
87
|
let cryptoImplPromise;
|
|
@@ -202,7 +102,8 @@ var getCrypto = () => {
|
|
|
202
102
|
return array;
|
|
203
103
|
}
|
|
204
104
|
const buffer = Buffer.from(array.buffer);
|
|
205
|
-
|
|
105
|
+
const view = new Uint8Array(buffer);
|
|
106
|
+
nodeCrypto.randomFillSync(view);
|
|
206
107
|
return array;
|
|
207
108
|
}
|
|
208
109
|
});
|
|
@@ -391,6 +292,45 @@ var DefaultCrypto = {
|
|
|
391
292
|
importPrivateSigningKey
|
|
392
293
|
};
|
|
393
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
|
+
|
|
394
334
|
// src/crypto/SigningKey.ts
|
|
395
335
|
import secp256k1 from "secp256k1";
|
|
396
336
|
function isAlias(key) {
|
|
@@ -487,6 +427,57 @@ var NodeKeyCache = class {
|
|
|
487
427
|
};
|
|
488
428
|
var NodeKeyCache_default = NodeKeyCache;
|
|
489
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
|
+
|
|
490
481
|
// src/requester/Requester.ts
|
|
491
482
|
import dayjs from "dayjs";
|
|
492
483
|
import utc from "dayjs/plugin/utc.js";
|
|
@@ -564,6 +555,12 @@ var Requester = class {
|
|
|
564
555
|
});
|
|
565
556
|
}
|
|
566
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
|
+
});
|
|
567
564
|
const operationNameRegex = /^\s*(query|mutation|subscription)\s+(\w+)/i;
|
|
568
565
|
const operationMatch = queryPayload.match(operationNameRegex);
|
|
569
566
|
if (!operationMatch || operationMatch.length < 3) {
|
|
@@ -613,7 +610,8 @@ var Requester = class {
|
|
|
613
610
|
logger.trace(`Requester.makeRawRequest`, {
|
|
614
611
|
url,
|
|
615
612
|
operationName: operation,
|
|
616
|
-
variables
|
|
613
|
+
variables,
|
|
614
|
+
headers
|
|
617
615
|
});
|
|
618
616
|
const response = await fetch(url, {
|
|
619
617
|
method: "POST",
|
|
@@ -698,6 +696,22 @@ async function compress(data) {
|
|
|
698
696
|
return new Uint8Array(await blob.arrayBuffer());
|
|
699
697
|
}
|
|
700
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;
|
|
701
715
|
export {
|
|
702
716
|
ConfigKeys,
|
|
703
717
|
CurrencyUnit,
|
|
@@ -728,6 +742,7 @@ export {
|
|
|
728
742
|
createSha256Hash,
|
|
729
743
|
defaultCurrencyCode,
|
|
730
744
|
deleteLocalStorageItem,
|
|
745
|
+
ensureArray,
|
|
731
746
|
errorToJSON,
|
|
732
747
|
formatCurrencyStr,
|
|
733
748
|
getCurrentLocale,
|
|
@@ -743,6 +758,7 @@ export {
|
|
|
743
758
|
isErrorWithMessage,
|
|
744
759
|
isNode,
|
|
745
760
|
isNumber,
|
|
761
|
+
isObject,
|
|
746
762
|
isSDKCurrencyAmount,
|
|
747
763
|
isTest,
|
|
748
764
|
isType,
|
|
@@ -750,6 +766,7 @@ export {
|
|
|
750
766
|
linearInterpolate,
|
|
751
767
|
localeToCurrencyCode,
|
|
752
768
|
localeToCurrencySymbol,
|
|
769
|
+
logger,
|
|
753
770
|
lsidToUUID,
|
|
754
771
|
mapCurrencyAmount,
|
|
755
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,
|
|
@@ -57,6 +58,7 @@ __export(utils_exports, {
|
|
|
57
58
|
isErrorWithMessage: () => isErrorWithMessage,
|
|
58
59
|
isNode: () => isNode,
|
|
59
60
|
isNumber: () => isNumber,
|
|
61
|
+
isObject: () => isObject2,
|
|
60
62
|
isSDKCurrencyAmount: () => isSDKCurrencyAmount,
|
|
61
63
|
isTest: () => isTest,
|
|
62
64
|
isType: () => isType,
|
|
@@ -76,6 +78,11 @@ __export(utils_exports, {
|
|
|
76
78
|
});
|
|
77
79
|
module.exports = __toCommonJS(utils_exports);
|
|
78
80
|
|
|
81
|
+
// src/utils/arrays.ts
|
|
82
|
+
function ensureArray(value) {
|
|
83
|
+
return Array.isArray(value) ? value : [value];
|
|
84
|
+
}
|
|
85
|
+
|
|
79
86
|
// src/utils/base64.ts
|
|
80
87
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
81
88
|
var Base64 = {
|
|
@@ -815,7 +822,7 @@ function localeToCurrencySymbol(locale) {
|
|
|
815
822
|
// src/utils/errors.ts
|
|
816
823
|
var isError = (e) => {
|
|
817
824
|
return Boolean(
|
|
818
|
-
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"
|
|
819
826
|
);
|
|
820
827
|
};
|
|
821
828
|
var isErrorWithMessage = (e) => {
|
|
@@ -999,8 +1006,12 @@ function lsidToUUID(lsid) {
|
|
|
999
1006
|
}
|
|
1000
1007
|
|
|
1001
1008
|
// src/utils/typeGuards.ts
|
|
1002
|
-
function isUint8Array(
|
|
1003
|
-
return
|
|
1009
|
+
function isUint8Array(value) {
|
|
1010
|
+
return value instanceof Uint8Array;
|
|
1011
|
+
}
|
|
1012
|
+
function isObject2(value) {
|
|
1013
|
+
const type = typeof value;
|
|
1014
|
+
return value != null && (type == "object" || type == "function");
|
|
1004
1015
|
}
|
|
1005
1016
|
|
|
1006
1017
|
// src/utils/types.ts
|
|
@@ -1024,6 +1035,7 @@ function notNullUndefined(value) {
|
|
|
1024
1035
|
createSha256Hash,
|
|
1025
1036
|
defaultCurrencyCode,
|
|
1026
1037
|
deleteLocalStorageItem,
|
|
1038
|
+
ensureArray,
|
|
1027
1039
|
errorToJSON,
|
|
1028
1040
|
formatCurrencyStr,
|
|
1029
1041
|
getCurrentLocale,
|
|
@@ -1039,6 +1051,7 @@ function notNullUndefined(value) {
|
|
|
1039
1051
|
isErrorWithMessage,
|
|
1040
1052
|
isNode,
|
|
1041
1053
|
isNumber,
|
|
1054
|
+
isObject,
|
|
1042
1055
|
isSDKCurrencyAmount,
|
|
1043
1056
|
isTest,
|
|
1044
1057
|
isType,
|
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,
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
isErrorWithMessage,
|
|
27
28
|
isNode,
|
|
28
29
|
isNumber,
|
|
30
|
+
isObject,
|
|
29
31
|
isSDKCurrencyAmount,
|
|
30
32
|
isTest,
|
|
31
33
|
isType,
|
|
@@ -42,7 +44,7 @@ import {
|
|
|
42
44
|
setLocalStorageBoolean,
|
|
43
45
|
sleep,
|
|
44
46
|
urlsafe_b64decode
|
|
45
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-22DUJXVY.js";
|
|
46
48
|
export {
|
|
47
49
|
CurrencyUnit,
|
|
48
50
|
abbrCurrencyUnit,
|
|
@@ -56,6 +58,7 @@ export {
|
|
|
56
58
|
createSha256Hash,
|
|
57
59
|
defaultCurrencyCode,
|
|
58
60
|
deleteLocalStorageItem,
|
|
61
|
+
ensureArray,
|
|
59
62
|
errorToJSON,
|
|
60
63
|
formatCurrencyStr,
|
|
61
64
|
getCurrentLocale,
|
|
@@ -71,6 +74,7 @@ export {
|
|
|
71
74
|
isErrorWithMessage,
|
|
72
75
|
isNode,
|
|
73
76
|
isNumber,
|
|
77
|
+
isObject,
|
|
74
78
|
isSDKCurrencyAmount,
|
|
75
79
|
isTest,
|
|
76
80
|
isType,
|
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";
|
package/src/utils/typeGuards.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
export function isUint8Array(
|
|
2
|
-
return
|
|
1
|
+
export function isUint8Array(value: unknown): value is Uint8Array {
|
|
2
|
+
return value instanceof Uint8Array;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function isObject(value: unknown): value is Record<string, unknown> {
|
|
6
|
+
const type = typeof value;
|
|
7
|
+
return value != null && (type == "object" || type == "function");
|
|
3
8
|
}
|