@lightsparkdev/core 1.0.8 → 1.0.9
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 +6 -0
- package/dist/index.cjs +20 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +18 -1
- package/package.json +1 -1
- package/src/Logger.ts +4 -2
- package/src/constants/index.ts +1 -0
- package/src/constants/localStorage.ts +13 -0
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
ConfigKeys: () => ConfigKeys,
|
|
33
34
|
CurrencyUnit: () => CurrencyUnit,
|
|
34
35
|
DefaultCrypto: () => DefaultCrypto,
|
|
35
36
|
KeyOrAlias: () => KeyOrAlias,
|
|
@@ -59,6 +60,7 @@ __export(src_exports, {
|
|
|
59
60
|
formatCurrencyStr: () => formatCurrencyStr,
|
|
60
61
|
getCurrentLocale: () => getCurrentLocale,
|
|
61
62
|
getErrorMsg: () => getErrorMsg,
|
|
63
|
+
getLocalStorageConfigItem: () => getLocalStorageConfigItem,
|
|
62
64
|
hexToBytes: () => hexToBytes,
|
|
63
65
|
isBrowser: () => isBrowser,
|
|
64
66
|
isCurrencyAmount: () => isCurrencyAmount,
|
|
@@ -118,6 +120,19 @@ var StubAuthProvider = class {
|
|
|
118
120
|
}
|
|
119
121
|
};
|
|
120
122
|
|
|
123
|
+
// src/constants/localStorage.ts
|
|
124
|
+
var ConfigKeys = {
|
|
125
|
+
LoggingEnabled: "lightspark-logging-enabled",
|
|
126
|
+
ConsoleToolsEnabled: "lightspark-console-tools-enabled"
|
|
127
|
+
};
|
|
128
|
+
var getLocalStorageConfigItem = (key) => {
|
|
129
|
+
try {
|
|
130
|
+
return localStorage.getItem(key) === "1";
|
|
131
|
+
} catch (e) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
121
136
|
// src/utils/base64.ts
|
|
122
137
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
123
138
|
var Base64 = {
|
|
@@ -1296,7 +1311,9 @@ var Logger = class {
|
|
|
1296
1311
|
this.loggingEnabled = true;
|
|
1297
1312
|
} else if (isBrowser) {
|
|
1298
1313
|
try {
|
|
1299
|
-
this.loggingEnabled =
|
|
1314
|
+
this.loggingEnabled = getLocalStorageConfigItem(
|
|
1315
|
+
ConfigKeys.LoggingEnabled
|
|
1316
|
+
);
|
|
1300
1317
|
} catch (e) {
|
|
1301
1318
|
}
|
|
1302
1319
|
}
|
|
@@ -1524,6 +1541,7 @@ var apiDomainForEnvironment = (environment) => {
|
|
|
1524
1541
|
var ServerEnvironment_default = ServerEnvironment;
|
|
1525
1542
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1526
1543
|
0 && (module.exports = {
|
|
1544
|
+
ConfigKeys,
|
|
1527
1545
|
CurrencyUnit,
|
|
1528
1546
|
DefaultCrypto,
|
|
1529
1547
|
KeyOrAlias,
|
|
@@ -1553,6 +1571,7 @@ var ServerEnvironment_default = ServerEnvironment;
|
|
|
1553
1571
|
formatCurrencyStr,
|
|
1554
1572
|
getCurrentLocale,
|
|
1555
1573
|
getErrorMsg,
|
|
1574
|
+
getLocalStorageConfigItem,
|
|
1556
1575
|
hexToBytes,
|
|
1557
1576
|
isBrowser,
|
|
1558
1577
|
isCurrencyAmount,
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,13 @@ declare class StubAuthProvider implements AuthProvider {
|
|
|
26
26
|
addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
declare const ConfigKeys: {
|
|
30
|
+
readonly LoggingEnabled: "lightspark-logging-enabled";
|
|
31
|
+
readonly ConsoleToolsEnabled: "lightspark-console-tools-enabled";
|
|
32
|
+
};
|
|
33
|
+
type ConfigKeys = (typeof ConfigKeys)[keyof typeof ConfigKeys];
|
|
34
|
+
declare const getLocalStorageConfigItem: (key: ConfigKeys) => boolean;
|
|
35
|
+
|
|
29
36
|
declare class LightsparkSigningException extends LightsparkException {
|
|
30
37
|
constructor(message: string, extraInfo?: Record<string, unknown>);
|
|
31
38
|
}
|
|
@@ -155,4 +162,4 @@ declare enum ServerEnvironment {
|
|
|
155
162
|
}
|
|
156
163
|
declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
|
|
157
164
|
|
|
158
|
-
export { AuthProvider, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment };
|
|
165
|
+
export { AuthProvider, ConfigKeys, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, getLocalStorageConfigItem };
|
package/dist/index.js
CHANGED
|
@@ -58,6 +58,19 @@ var StubAuthProvider = class {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
// src/constants/localStorage.ts
|
|
62
|
+
var ConfigKeys = {
|
|
63
|
+
LoggingEnabled: "lightspark-logging-enabled",
|
|
64
|
+
ConsoleToolsEnabled: "lightspark-console-tools-enabled"
|
|
65
|
+
};
|
|
66
|
+
var getLocalStorageConfigItem = (key) => {
|
|
67
|
+
try {
|
|
68
|
+
return localStorage.getItem(key) === "1";
|
|
69
|
+
} catch (e) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
61
74
|
// src/crypto/LightsparkSigningException.ts
|
|
62
75
|
var LightsparkSigningException = class extends LightsparkException_default {
|
|
63
76
|
constructor(message, extraInfo) {
|
|
@@ -390,7 +403,9 @@ var Logger = class {
|
|
|
390
403
|
this.loggingEnabled = true;
|
|
391
404
|
} else if (isBrowser) {
|
|
392
405
|
try {
|
|
393
|
-
this.loggingEnabled =
|
|
406
|
+
this.loggingEnabled = getLocalStorageConfigItem(
|
|
407
|
+
ConfigKeys.LoggingEnabled
|
|
408
|
+
);
|
|
394
409
|
} catch (e) {
|
|
395
410
|
}
|
|
396
411
|
}
|
|
@@ -617,6 +632,7 @@ var apiDomainForEnvironment = (environment) => {
|
|
|
617
632
|
};
|
|
618
633
|
var ServerEnvironment_default = ServerEnvironment;
|
|
619
634
|
export {
|
|
635
|
+
ConfigKeys,
|
|
620
636
|
CurrencyUnit,
|
|
621
637
|
DefaultCrypto,
|
|
622
638
|
KeyOrAlias,
|
|
@@ -646,6 +662,7 @@ export {
|
|
|
646
662
|
formatCurrencyStr,
|
|
647
663
|
getCurrentLocale,
|
|
648
664
|
getErrorMsg,
|
|
665
|
+
getLocalStorageConfigItem,
|
|
649
666
|
hexToBytes,
|
|
650
667
|
isBrowser,
|
|
651
668
|
isCurrencyAmount,
|
package/package.json
CHANGED
package/src/Logger.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConfigKeys, getLocalStorageConfigItem } from "./index.js";
|
|
1
2
|
import { isBrowser, isTest } from "./utils/environment.js";
|
|
2
3
|
|
|
3
4
|
type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
|
|
@@ -18,8 +19,9 @@ export class Logger {
|
|
|
18
19
|
this.loggingEnabled = true;
|
|
19
20
|
} else if (isBrowser) {
|
|
20
21
|
try {
|
|
21
|
-
this.loggingEnabled =
|
|
22
|
-
|
|
22
|
+
this.loggingEnabled = getLocalStorageConfigItem(
|
|
23
|
+
ConfigKeys.LoggingEnabled,
|
|
24
|
+
);
|
|
23
25
|
} catch (e) {
|
|
24
26
|
/* ignore */
|
|
25
27
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./localStorage.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const ConfigKeys = {
|
|
2
|
+
LoggingEnabled: "lightspark-logging-enabled",
|
|
3
|
+
ConsoleToolsEnabled: "lightspark-console-tools-enabled",
|
|
4
|
+
} as const;
|
|
5
|
+
export type ConfigKeys = (typeof ConfigKeys)[keyof typeof ConfigKeys];
|
|
6
|
+
|
|
7
|
+
export const getLocalStorageConfigItem = (key: ConfigKeys) => {
|
|
8
|
+
try {
|
|
9
|
+
return localStorage.getItem(key) === "1";
|
|
10
|
+
} catch (e) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
2
|
|
|
3
3
|
export * from "./auth/index.js";
|
|
4
|
+
export * from "./constants/index.js";
|
|
4
5
|
export * from "./crypto/index.js";
|
|
5
6
|
export { default as LightsparkException } from "./LightsparkException.js";
|
|
6
7
|
export { Logger } from "./Logger.js";
|