@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/dist/index.cjs CHANGED
@@ -59,6 +59,7 @@ __export(src_exports, {
59
59
  createSha256Hash: () => createSha256Hash,
60
60
  defaultCurrencyCode: () => defaultCurrencyCode,
61
61
  deleteLocalStorageItem: () => deleteLocalStorageItem,
62
+ ensureArray: () => ensureArray,
62
63
  errorToJSON: () => errorToJSON,
63
64
  formatCurrencyStr: () => formatCurrencyStr,
64
65
  getCurrentLocale: () => getCurrentLocale,
@@ -82,6 +83,7 @@ __export(src_exports, {
82
83
  linearInterpolate: () => linearInterpolate,
83
84
  localeToCurrencyCode: () => localeToCurrencyCode,
84
85
  localeToCurrencySymbol: () => localeToCurrencySymbol,
86
+ logger: () => logger,
85
87
  lsidToUUID: () => lsidToUUID,
86
88
  mapCurrencyAmount: () => mapCurrencyAmount,
87
89
  notNullUndefined: () => notNullUndefined,
@@ -108,74 +110,6 @@ var LightsparkException = class extends Error {
108
110
  };
109
111
  var LightsparkException_default = LightsparkException;
110
112
 
111
- // src/utils/environment.ts
112
- var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
113
- var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
114
- var isTest = isNode && process.env.NODE_ENV === "test";
115
-
116
- // src/Logger.ts
117
- var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
118
- LoggingLevel2[LoggingLevel2["Trace"] = 0] = "Trace";
119
- LoggingLevel2[LoggingLevel2["Info"] = 1] = "Info";
120
- return LoggingLevel2;
121
- })(LoggingLevel || {});
122
- var Logger = class {
123
- context;
124
- loggingEnabled = false;
125
- loggingLevel = 1 /* Info */;
126
- constructor(loggerContext, getLoggingEnabled) {
127
- this.context = loggerContext;
128
- void this.updateLoggingEnabled(getLoggingEnabled);
129
- }
130
- setLevel(level) {
131
- this.loggingLevel = level;
132
- }
133
- async updateLoggingEnabled(getLoggingEnabled) {
134
- if (getLoggingEnabled) {
135
- this.loggingEnabled = await getLoggingEnabled();
136
- } else if (isTest) {
137
- this.loggingEnabled = true;
138
- } else if (isBrowser) {
139
- try {
140
- this.loggingEnabled = getLocalStorageConfigItem(
141
- ConfigKeys.LoggingEnabled
142
- );
143
- } catch (e) {
144
- }
145
- }
146
- if (this.loggingEnabled) {
147
- console.log(`[${this.context}] Logging enabled`);
148
- }
149
- }
150
- trace(message, ...rest) {
151
- if (this.loggingEnabled && this.loggingLevel === 0 /* Trace */) {
152
- console.log(`[${this.context}] ${message}`, ...rest);
153
- }
154
- }
155
- info(message, ...rest) {
156
- if (this.loggingEnabled && this.loggingLevel <= 1 /* Info */) {
157
- console.log(`[${this.context}] ${message}`, ...rest);
158
- }
159
- }
160
- };
161
- var logger = new Logger("@lightsparkdev/core");
162
-
163
- // src/ServerEnvironment.ts
164
- var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
165
- ServerEnvironment2["PRODUCTION"] = "production";
166
- ServerEnvironment2["DEV"] = "dev";
167
- return ServerEnvironment2;
168
- })(ServerEnvironment || {});
169
- var apiDomainForEnvironment = (environment) => {
170
- switch (environment) {
171
- case "dev" /* DEV */:
172
- return "api.dev.dev.sparkinfra.net";
173
- case "production" /* PRODUCTION */:
174
- return "api.lightspark.com";
175
- }
176
- };
177
- var ServerEnvironment_default = ServerEnvironment;
178
-
179
113
  // src/auth/LightsparkAuthException.ts
180
114
  var LightsparkAuthException = class extends LightsparkException_default {
181
115
  constructor(message, extraInfo) {
@@ -203,53 +137,6 @@ var ConfigKeys = {
203
137
  ConsoleToolsEnabled: "lightspark-console-tools-enabled"
204
138
  };
205
139
 
206
- // src/crypto/KeyOrAlias.ts
207
- var KeyOrAlias = {
208
- key: (key) => ({ key }),
209
- alias: (alias) => ({ alias })
210
- };
211
-
212
- // src/crypto/LightsparkSigningException.ts
213
- var LightsparkSigningException = class extends LightsparkException_default {
214
- constructor(message, extraInfo) {
215
- super("SigningException", message, extraInfo);
216
- }
217
- };
218
- var LightsparkSigningException_default = LightsparkSigningException;
219
-
220
- // ../../node_modules/auto-bind/index.js
221
- var getAllProperties = (object) => {
222
- const properties = /* @__PURE__ */ new Set();
223
- do {
224
- for (const key of Reflect.ownKeys(object)) {
225
- properties.add([object, key]);
226
- }
227
- } while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
228
- return properties;
229
- };
230
- function autoBind(self2, { include, exclude } = {}) {
231
- const filter = (key) => {
232
- const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
233
- if (include) {
234
- return include.some(match);
235
- }
236
- if (exclude) {
237
- return !exclude.some(match);
238
- }
239
- return true;
240
- };
241
- for (const [object, key] of getAllProperties(self2.constructor.prototype)) {
242
- if (key === "constructor" || !filter(key)) {
243
- continue;
244
- }
245
- const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
246
- if (descriptor && typeof descriptor.value === "function") {
247
- self2[key] = self2[key].bind(self2);
248
- }
249
- }
250
- return self2;
251
- }
252
-
253
140
  // src/utils/base64.ts
254
141
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
255
142
  var Base64 = {
@@ -293,6 +180,14 @@ var b64encode = (data) => {
293
180
  );
294
181
  };
295
182
 
183
+ // src/crypto/LightsparkSigningException.ts
184
+ var LightsparkSigningException = class extends LightsparkException_default {
185
+ constructor(message, extraInfo) {
186
+ super("SigningException", message, extraInfo);
187
+ }
188
+ };
189
+ var LightsparkSigningException_default = LightsparkSigningException;
190
+
296
191
  // src/crypto/crypto.ts
297
192
  var getCrypto = () => {
298
193
  let cryptoImplPromise;
@@ -313,7 +208,8 @@ var getCrypto = () => {
313
208
  return array;
314
209
  }
315
210
  const buffer = Buffer.from(array.buffer);
316
- nodeCrypto.randomFillSync(buffer);
211
+ const view = new Uint8Array(buffer);
212
+ nodeCrypto.randomFillSync(view);
317
213
  return array;
318
214
  }
319
215
  });
@@ -502,9 +398,58 @@ var DefaultCrypto = {
502
398
  importPrivateSigningKey
503
399
  };
504
400
 
401
+ // src/crypto/KeyOrAlias.ts
402
+ var KeyOrAlias = {
403
+ key: (key) => ({ key }),
404
+ alias: (alias) => ({ alias })
405
+ };
406
+
407
+ // ../../node_modules/auto-bind/index.js
408
+ var getAllProperties = (object) => {
409
+ const properties = /* @__PURE__ */ new Set();
410
+ do {
411
+ for (const key of Reflect.ownKeys(object)) {
412
+ properties.add([object, key]);
413
+ }
414
+ } while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
415
+ return properties;
416
+ };
417
+ function autoBind(self2, { include, exclude } = {}) {
418
+ const filter = (key) => {
419
+ const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
420
+ if (include) {
421
+ return include.some(match);
422
+ }
423
+ if (exclude) {
424
+ return !exclude.some(match);
425
+ }
426
+ return true;
427
+ };
428
+ for (const [object, key] of getAllProperties(self2.constructor.prototype)) {
429
+ if (key === "constructor" || !filter(key)) {
430
+ continue;
431
+ }
432
+ const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
433
+ if (descriptor && typeof descriptor.value === "function") {
434
+ self2[key] = self2[key].bind(self2);
435
+ }
436
+ }
437
+ return self2;
438
+ }
439
+
505
440
  // src/crypto/SigningKey.ts
506
441
  var import_secp256k1 = __toESM(require("secp256k1"), 1);
507
442
 
443
+ // src/utils/arrays.ts
444
+ function ensureArray(value) {
445
+ return Array.isArray(value) ? value : [value];
446
+ }
447
+
448
+ // src/utils/environment.ts
449
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
450
+ var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
451
+ var isTest = isNode && process.env.NODE_ENV === "test";
452
+
508
453
  // src/utils/hex.ts
509
454
  var bytesToHex = (bytes) => {
510
455
  return bytes.reduce((acc, byte) => {
@@ -1182,7 +1127,7 @@ function localeToCurrencySymbol(locale) {
1182
1127
  // src/utils/errors.ts
1183
1128
  var isError = (e) => {
1184
1129
  return Boolean(
1185
- typeof e === "object" && e !== null && "name" in e && typeof e.name === "string" && "message" in e && typeof e.message === "string" && "stack" in e && (!e.stack || typeof e.stack === "string")
1130
+ typeof e === "object" && e !== null && "name" in e && typeof e.name === "string" && "message" in e && typeof e.message === "string"
1186
1131
  );
1187
1132
  };
1188
1133
  var isErrorWithMessage = (e) => {
@@ -1477,6 +1422,57 @@ var NodeKeyCache = class {
1477
1422
  };
1478
1423
  var NodeKeyCache_default = NodeKeyCache;
1479
1424
 
1425
+ // src/Logger.ts
1426
+ var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
1427
+ LoggingLevel2[LoggingLevel2["Trace"] = 0] = "Trace";
1428
+ LoggingLevel2[LoggingLevel2["Info"] = 1] = "Info";
1429
+ return LoggingLevel2;
1430
+ })(LoggingLevel || {});
1431
+ var Logger = class {
1432
+ context;
1433
+ loggingEnabled = false;
1434
+ loggingLevel = 1 /* Info */;
1435
+ constructor(loggerContext, getLoggingEnabled) {
1436
+ this.context = loggerContext;
1437
+ void this.updateLoggingEnabled(getLoggingEnabled);
1438
+ }
1439
+ setLevel(level) {
1440
+ this.loggingLevel = level;
1441
+ }
1442
+ setEnabled(enabled, level = 1 /* Info */) {
1443
+ this.loggingEnabled = enabled;
1444
+ this.loggingLevel = level;
1445
+ }
1446
+ async updateLoggingEnabled(getLoggingEnabled) {
1447
+ if (getLoggingEnabled) {
1448
+ this.loggingEnabled = await getLoggingEnabled();
1449
+ } else if (isTest) {
1450
+ this.loggingEnabled = true;
1451
+ } else if (isBrowser) {
1452
+ try {
1453
+ this.loggingEnabled = getLocalStorageConfigItem(
1454
+ ConfigKeys.LoggingEnabled
1455
+ );
1456
+ } catch (e) {
1457
+ }
1458
+ }
1459
+ if (this.loggingEnabled) {
1460
+ console.log(`[${this.context}] Logging enabled`);
1461
+ }
1462
+ }
1463
+ trace(message, ...rest) {
1464
+ if (this.loggingEnabled && this.loggingLevel === 0 /* Trace */) {
1465
+ console.log(`[${this.context}] ${message}`, ...rest);
1466
+ }
1467
+ }
1468
+ info(message, ...rest) {
1469
+ if (this.loggingEnabled && this.loggingLevel <= 1 /* Info */) {
1470
+ console.log(`[${this.context}] ${message}`, ...rest);
1471
+ }
1472
+ }
1473
+ };
1474
+ var logger = new Logger("@lightsparkdev/core");
1475
+
1480
1476
  // src/requester/Requester.ts
1481
1477
  var import_dayjs = __toESM(require("dayjs"), 1);
1482
1478
  var import_utc = __toESM(require("dayjs/plugin/utc.js"), 1);
@@ -1554,6 +1550,12 @@ var Requester = class {
1554
1550
  });
1555
1551
  }
1556
1552
  async makeRawRequest(queryPayload, variables = {}, signingNodeId = void 0, skipAuth = false) {
1553
+ logger.trace(`Requester.makeRawRequest args`, {
1554
+ queryPayload,
1555
+ variables,
1556
+ signingNodeId,
1557
+ skipAuth
1558
+ });
1557
1559
  const operationNameRegex = /^\s*(query|mutation|subscription)\s+(\w+)/i;
1558
1560
  const operationMatch = queryPayload.match(operationNameRegex);
1559
1561
  if (!operationMatch || operationMatch.length < 3) {
@@ -1603,7 +1605,8 @@ var Requester = class {
1603
1605
  logger.trace(`Requester.makeRawRequest`, {
1604
1606
  url,
1605
1607
  operationName: operation,
1606
- variables
1608
+ variables,
1609
+ headers
1607
1610
  });
1608
1611
  const response = await fetch(url, {
1609
1612
  method: "POST",
@@ -1688,6 +1691,22 @@ async function compress(data) {
1688
1691
  return new Uint8Array(await blob.arrayBuffer());
1689
1692
  }
1690
1693
  var Requester_default = Requester;
1694
+
1695
+ // src/ServerEnvironment.ts
1696
+ var ServerEnvironment = /* @__PURE__ */ ((ServerEnvironment2) => {
1697
+ ServerEnvironment2["PRODUCTION"] = "production";
1698
+ ServerEnvironment2["DEV"] = "dev";
1699
+ return ServerEnvironment2;
1700
+ })(ServerEnvironment || {});
1701
+ var apiDomainForEnvironment = (environment) => {
1702
+ switch (environment) {
1703
+ case "dev" /* DEV */:
1704
+ return "api.dev.dev.sparkinfra.net";
1705
+ case "production" /* PRODUCTION */:
1706
+ return "api.lightspark.com";
1707
+ }
1708
+ };
1709
+ var ServerEnvironment_default = ServerEnvironment;
1691
1710
  // Annotate the CommonJS export names for ESM import in node:
1692
1711
  0 && (module.exports = {
1693
1712
  ConfigKeys,
@@ -1719,6 +1738,7 @@ var Requester_default = Requester;
1719
1738
  createSha256Hash,
1720
1739
  defaultCurrencyCode,
1721
1740
  deleteLocalStorageItem,
1741
+ ensureArray,
1722
1742
  errorToJSON,
1723
1743
  formatCurrencyStr,
1724
1744
  getCurrentLocale,
@@ -1742,6 +1762,7 @@ var Requester_default = Requester;
1742
1762
  linearInterpolate,
1743
1763
  localeToCurrencyCode,
1744
1764
  localeToCurrencySymbol,
1765
+ logger,
1745
1766
  lsidToUUID,
1746
1767
  mapCurrencyAmount,
1747
1768
  notNullUndefined,
package/dist/index.d.cts CHANGED
@@ -1,35 +1,6 @@
1
- export { _ as ById, a8 as Complete, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a1 as DeepPartial, Z as ExpandRecursively, a2 as JSONLiteral, a4 as JSONObject, a3 as JSONType, Y as Maybe, a5 as NN, $ as OmitTypename, a7 as PartialBy, S as SDKCurrencyAmountType, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, X as isObject, m as isSDKCurrencyAmount, w as isTest, a0 as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a6 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from './index-b1e5d968.js';
1
+ export { $ as ById, a9 as Complete, C as ConfigKeys, 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';
2
2
  import { Observable } from 'zen-observable-ts';
3
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 enum LoggingLevel {
13
- Trace = 0,
14
- Info = 1
15
- }
16
- declare class Logger {
17
- context: string;
18
- loggingEnabled: boolean;
19
- loggingLevel: LoggingLevel;
20
- constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
21
- setLevel(level: LoggingLevel): void;
22
- updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
23
- trace(message: string, ...rest: unknown[]): void;
24
- info(message: string, ...rest: unknown[]): void;
25
- }
26
-
27
- declare enum ServerEnvironment {
28
- PRODUCTION = "production",
29
- DEV = "dev"
30
- }
31
- declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
32
-
33
4
  type Headers = Record<string, string>;
34
5
  type WsConnectionParams = Record<string, unknown>;
35
6
  interface AuthProvider {
@@ -38,6 +9,13 @@ interface AuthProvider {
38
9
  addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
39
10
  }
40
11
 
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
+
41
19
  declare class LightsparkAuthException extends LightsparkException {
42
20
  constructor(message: string, extraInfo?: Record<string, unknown>);
43
21
  }
@@ -48,20 +26,6 @@ declare class StubAuthProvider implements AuthProvider {
48
26
  addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
49
27
  }
50
28
 
51
- type OnlyKey = {
52
- key: string;
53
- alias?: never;
54
- };
55
- type OnlyAlias = {
56
- key?: never;
57
- alias: string;
58
- };
59
- type KeyOrAliasType = OnlyKey | OnlyAlias;
60
- declare const KeyOrAlias: {
61
- key: (key: string) => OnlyKey;
62
- alias: (alias: string) => OnlyAlias;
63
- };
64
-
65
29
  declare class LightsparkSigningException extends LightsparkException {
66
30
  constructor(message: string, extraInfo?: Record<string, unknown>);
67
31
  }
@@ -89,6 +53,20 @@ declare const DefaultCrypto: {
89
53
  importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
90
54
  };
91
55
 
56
+ type OnlyKey = {
57
+ key: string;
58
+ alias?: never;
59
+ };
60
+ type OnlyAlias = {
61
+ key?: never;
62
+ alias: string;
63
+ };
64
+ type KeyOrAliasType = OnlyKey | OnlyAlias;
65
+ declare const KeyOrAlias: {
66
+ key: (key: string) => OnlyKey;
67
+ alias: (alias: string) => OnlyAlias;
68
+ };
69
+
92
70
  interface Alias {
93
71
  alias: string;
94
72
  }
@@ -124,6 +102,24 @@ declare class NodeKeyCache {
124
102
  private stripPemTags;
125
103
  }
126
104
 
105
+ type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
106
+ declare enum LoggingLevel {
107
+ Trace = 0,
108
+ Info = 1
109
+ }
110
+ declare class Logger {
111
+ context: string;
112
+ loggingEnabled: boolean;
113
+ loggingLevel: LoggingLevel;
114
+ constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
115
+ setLevel(level: LoggingLevel): void;
116
+ setEnabled(enabled: boolean, level?: LoggingLevel): void;
117
+ updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
118
+ trace(message: string, ...rest: unknown[]): void;
119
+ info(message: string, ...rest: unknown[]): void;
120
+ }
121
+ declare const logger: Logger;
122
+
127
123
  type Query<T> = {
128
124
  /** The string representation of the query payload for graphQL. **/
129
125
  queryPayload: string;
@@ -165,4 +161,10 @@ declare class Requester {
165
161
  private addSigningDataIfNeeded;
166
162
  }
167
163
 
168
- export { AuthProvider, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, LoggingLevel, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment };
164
+ declare enum ServerEnvironment {
165
+ PRODUCTION = "production",
166
+ DEV = "dev"
167
+ }
168
+ declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
169
+
170
+ export { type AuthProvider, type CryptoInterface, DefaultCrypto, type GeneratedKeyPair, KeyOrAlias, type KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, LoggingLevel, NodeKeyCache, type Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, logger };
package/dist/index.d.ts CHANGED
@@ -1,35 +1,6 @@
1
- export { _ as ById, a8 as Complete, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a1 as DeepPartial, Z as ExpandRecursively, a2 as JSONLiteral, a4 as JSONObject, a3 as JSONType, Y as Maybe, a5 as NN, $ as OmitTypename, a7 as PartialBy, S as SDKCurrencyAmountType, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, X as isObject, m as isSDKCurrencyAmount, w as isTest, a0 as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a6 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from './index-b1e5d968.js';
1
+ export { $ as ById, a9 as Complete, C as ConfigKeys, 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';
2
2
  import { Observable } from 'zen-observable-ts';
3
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 enum LoggingLevel {
13
- Trace = 0,
14
- Info = 1
15
- }
16
- declare class Logger {
17
- context: string;
18
- loggingEnabled: boolean;
19
- loggingLevel: LoggingLevel;
20
- constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
21
- setLevel(level: LoggingLevel): void;
22
- updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
23
- trace(message: string, ...rest: unknown[]): void;
24
- info(message: string, ...rest: unknown[]): void;
25
- }
26
-
27
- declare enum ServerEnvironment {
28
- PRODUCTION = "production",
29
- DEV = "dev"
30
- }
31
- declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
32
-
33
4
  type Headers = Record<string, string>;
34
5
  type WsConnectionParams = Record<string, unknown>;
35
6
  interface AuthProvider {
@@ -38,6 +9,13 @@ interface AuthProvider {
38
9
  addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
39
10
  }
40
11
 
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
+
41
19
  declare class LightsparkAuthException extends LightsparkException {
42
20
  constructor(message: string, extraInfo?: Record<string, unknown>);
43
21
  }
@@ -48,20 +26,6 @@ declare class StubAuthProvider implements AuthProvider {
48
26
  addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
49
27
  }
50
28
 
51
- type OnlyKey = {
52
- key: string;
53
- alias?: never;
54
- };
55
- type OnlyAlias = {
56
- key?: never;
57
- alias: string;
58
- };
59
- type KeyOrAliasType = OnlyKey | OnlyAlias;
60
- declare const KeyOrAlias: {
61
- key: (key: string) => OnlyKey;
62
- alias: (alias: string) => OnlyAlias;
63
- };
64
-
65
29
  declare class LightsparkSigningException extends LightsparkException {
66
30
  constructor(message: string, extraInfo?: Record<string, unknown>);
67
31
  }
@@ -89,6 +53,20 @@ declare const DefaultCrypto: {
89
53
  importPrivateSigningKey: (keyData: Uint8Array) => Promise<CryptoKey | string>;
90
54
  };
91
55
 
56
+ type OnlyKey = {
57
+ key: string;
58
+ alias?: never;
59
+ };
60
+ type OnlyAlias = {
61
+ key?: never;
62
+ alias: string;
63
+ };
64
+ type KeyOrAliasType = OnlyKey | OnlyAlias;
65
+ declare const KeyOrAlias: {
66
+ key: (key: string) => OnlyKey;
67
+ alias: (alias: string) => OnlyAlias;
68
+ };
69
+
92
70
  interface Alias {
93
71
  alias: string;
94
72
  }
@@ -124,6 +102,24 @@ declare class NodeKeyCache {
124
102
  private stripPemTags;
125
103
  }
126
104
 
105
+ type GetLoggingEnabled = (() => Promise<boolean> | boolean) | undefined;
106
+ declare enum LoggingLevel {
107
+ Trace = 0,
108
+ Info = 1
109
+ }
110
+ declare class Logger {
111
+ context: string;
112
+ loggingEnabled: boolean;
113
+ loggingLevel: LoggingLevel;
114
+ constructor(loggerContext: string, getLoggingEnabled?: GetLoggingEnabled);
115
+ setLevel(level: LoggingLevel): void;
116
+ setEnabled(enabled: boolean, level?: LoggingLevel): void;
117
+ updateLoggingEnabled(getLoggingEnabled: GetLoggingEnabled): Promise<void>;
118
+ trace(message: string, ...rest: unknown[]): void;
119
+ info(message: string, ...rest: unknown[]): void;
120
+ }
121
+ declare const logger: Logger;
122
+
127
123
  type Query<T> = {
128
124
  /** The string representation of the query payload for graphQL. **/
129
125
  queryPayload: string;
@@ -165,4 +161,10 @@ declare class Requester {
165
161
  private addSigningDataIfNeeded;
166
162
  }
167
163
 
168
- export { AuthProvider, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, LoggingLevel, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment };
164
+ declare enum ServerEnvironment {
165
+ PRODUCTION = "production",
166
+ DEV = "dev"
167
+ }
168
+ declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
169
+
170
+ export { type AuthProvider, type CryptoInterface, DefaultCrypto, type GeneratedKeyPair, KeyOrAlias, type KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, LoggingLevel, NodeKeyCache, type Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, logger };