@lightsparkdev/core 1.0.7 → 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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @lightsparkdev/core
2
2
 
3
+ ## 1.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 0d43a39: Add common config enum for app reference
8
+
9
+ ## 1.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - a59d636: Remove crypto as dep - available directly in Node
14
+
3
15
  ## 1.0.7
4
16
 
5
17
  ### Patch Changes
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 = localStorage.getItem("lightspark-logging-enabled") === "1";
1314
+ this.loggingEnabled = getLocalStorageConfigItem(
1315
+ ConfigKeys.LoggingEnabled
1316
+ );
1300
1317
  } catch (e) {
1301
1318
  }
1302
1319
  }
@@ -1433,7 +1450,12 @@ var Requester = class {
1433
1450
  if (!urlWithProtocol.startsWith("https://") && !urlWithProtocol.startsWith("http://")) {
1434
1451
  urlWithProtocol = `https://${urlWithProtocol}`;
1435
1452
  }
1436
- const response = await fetch(`${urlWithProtocol}/${this.schemaEndpoint}`, {
1453
+ const url = `${urlWithProtocol}/${this.schemaEndpoint}`;
1454
+ logger.info(`Requester.makeRawRequest`, {
1455
+ url,
1456
+ variables
1457
+ });
1458
+ const response = await fetch(url, {
1437
1459
  method: "POST",
1438
1460
  headers,
1439
1461
  body: JSON.stringify(bodyData)
@@ -1519,6 +1541,7 @@ var apiDomainForEnvironment = (environment) => {
1519
1541
  var ServerEnvironment_default = ServerEnvironment;
1520
1542
  // Annotate the CommonJS export names for ESM import in node:
1521
1543
  0 && (module.exports = {
1544
+ ConfigKeys,
1522
1545
  CurrencyUnit,
1523
1546
  DefaultCrypto,
1524
1547
  KeyOrAlias,
@@ -1548,6 +1571,7 @@ var ServerEnvironment_default = ServerEnvironment;
1548
1571
  formatCurrencyStr,
1549
1572
  getCurrentLocale,
1550
1573
  getErrorMsg,
1574
+ getLocalStorageConfigItem,
1551
1575
  hexToBytes,
1552
1576
  isBrowser,
1553
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 = localStorage.getItem("lightspark-logging-enabled") === "1";
406
+ this.loggingEnabled = getLocalStorageConfigItem(
407
+ ConfigKeys.LoggingEnabled
408
+ );
394
409
  } catch (e) {
395
410
  }
396
411
  }
@@ -527,7 +542,12 @@ var Requester = class {
527
542
  if (!urlWithProtocol.startsWith("https://") && !urlWithProtocol.startsWith("http://")) {
528
543
  urlWithProtocol = `https://${urlWithProtocol}`;
529
544
  }
530
- const response = await fetch(`${urlWithProtocol}/${this.schemaEndpoint}`, {
545
+ const url = `${urlWithProtocol}/${this.schemaEndpoint}`;
546
+ logger.info(`Requester.makeRawRequest`, {
547
+ url,
548
+ variables
549
+ });
550
+ const response = await fetch(url, {
531
551
  method: "POST",
532
552
  headers,
533
553
  body: JSON.stringify(bodyData)
@@ -612,6 +632,7 @@ var apiDomainForEnvironment = (environment) => {
612
632
  };
613
633
  var ServerEnvironment_default = ServerEnvironment;
614
634
  export {
635
+ ConfigKeys,
615
636
  CurrencyUnit,
616
637
  DefaultCrypto,
617
638
  KeyOrAlias,
@@ -641,6 +662,7 @@ export {
641
662
  formatCurrencyStr,
642
663
  getCurrentLocale,
643
664
  getErrorMsg,
665
+ getLocalStorageConfigItem,
644
666
  hexToBytes,
645
667
  isBrowser,
646
668
  isCurrencyAmount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/core",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -77,7 +77,6 @@
77
77
  "license": "Apache-2.0",
78
78
  "dependencies": {
79
79
  "auto-bind": "^5.0.1",
80
- "crypto": "^1.0.1",
81
80
  "crypto-browserify": "^3.12.0",
82
81
  "dayjs": "^1.11.7",
83
82
  "graphql": "^16.6.0",
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
- localStorage.getItem("lightspark-logging-enabled") === "1";
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";
@@ -161,7 +161,14 @@ class Requester {
161
161
  ) {
162
162
  urlWithProtocol = `https://${urlWithProtocol}`;
163
163
  }
164
- const response = await fetch(`${urlWithProtocol}/${this.schemaEndpoint}`, {
164
+
165
+ const url = `${urlWithProtocol}/${this.schemaEndpoint}`;
166
+
167
+ logger.info(`Requester.makeRawRequest`, {
168
+ url,
169
+ variables,
170
+ });
171
+ const response = await fetch(url, {
165
172
  method: "POST",
166
173
  headers: headers,
167
174
  body: JSON.stringify(bodyData),