@lightsparkdev/core 1.0.11 → 1.0.13

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.13
4
+
5
+ ### Patch Changes
6
+
7
+ - da1e0b2: - export secp256k1 signatures to DER format
8
+
9
+ ## 1.0.12
10
+
11
+ ### Patch Changes
12
+
13
+ - 35513da: Upgrade dependencies
14
+
3
15
  ## 1.0.11
4
16
 
5
17
  ### Patch Changes
@@ -728,6 +728,38 @@ var isErrorMsg = (e, msg) => {
728
728
  }
729
729
  return false;
730
730
  };
731
+ function errorToJSON(err) {
732
+ if (typeof err === "object" && err !== null && "toJSON" in err && typeof err.toJSON === "function") {
733
+ return err.toJSON();
734
+ }
735
+ return JSON.parse(
736
+ JSON.stringify(err, Object.getOwnPropertyNames(err))
737
+ );
738
+ }
739
+
740
+ // src/utils/localStorage.ts
741
+ function getLocalStorageConfigItem(key) {
742
+ return getLocalStorageBoolean(key);
743
+ }
744
+ function getLocalStorageBoolean(key) {
745
+ try {
746
+ return localStorage.getItem(key) === "1";
747
+ } catch (e) {
748
+ return false;
749
+ }
750
+ }
751
+ function setLocalStorageBoolean(key, value) {
752
+ try {
753
+ localStorage.setItem(key, value ? "1" : "0");
754
+ } catch (e) {
755
+ }
756
+ }
757
+ var deleteLocalStorageItem = (key) => {
758
+ try {
759
+ localStorage.removeItem(key);
760
+ } catch (e) {
761
+ }
762
+ };
731
763
 
732
764
  // ../../node_modules/lodash-es/_freeGlobal.js
733
765
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
@@ -889,6 +921,11 @@ export {
889
921
  isErrorWithMessage,
890
922
  getErrorMsg,
891
923
  isErrorMsg,
924
+ errorToJSON,
925
+ getLocalStorageConfigItem,
926
+ getLocalStorageBoolean,
927
+ setLocalStorageBoolean,
928
+ deleteLocalStorageItem,
892
929
  sleep,
893
930
  pollUntil,
894
931
  isType
@@ -0,0 +1,271 @@
1
+ declare const ConfigKeys: {
2
+ readonly LoggingEnabled: "lightspark-logging-enabled";
3
+ readonly ConsoleToolsEnabled: "lightspark-console-tools-enabled";
4
+ };
5
+ type ConfigKeys = (typeof ConfigKeys)[keyof typeof ConfigKeys];
6
+
7
+ declare const b64decode: (encoded: string) => Uint8Array;
8
+ declare const urlsafe_b64decode: (encoded: string) => Uint8Array;
9
+ declare const b64encode: (data: ArrayBuffer) => string;
10
+
11
+ type SourceData = Uint8Array | string;
12
+ declare function createSha256Hash(data: SourceData): Promise<Uint8Array>;
13
+ declare function createSha256Hash(data: SourceData, asHex: true): Promise<string>;
14
+
15
+ declare const defaultCurrencyCode = "USD";
16
+ /**
17
+ * This enum identifies the unit of currency associated with a CurrencyAmount.
18
+ * *
19
+ */
20
+ declare enum CurrencyUnit {
21
+ /**
22
+ * This is an enum value that represents values that could be added in the
23
+ * future. Clients should support unknown values as more of them could be
24
+ * added without notice.
25
+ */
26
+ FUTURE_VALUE = "FUTURE_VALUE",
27
+ /**
28
+ * Bitcoin is the cryptocurrency native to the Bitcoin network.
29
+ * It is used as the native medium for value transfer for the Lightning
30
+ * Network. *
31
+ */
32
+ BITCOIN = "BITCOIN",
33
+ /**
34
+ * 0.00000001 (10e-8) Bitcoin or one hundred millionth of a Bitcoin.
35
+ * This is the unit most commonly used in Lightning transactions.
36
+ * *
37
+ */
38
+ SATOSHI = "SATOSHI",
39
+ /**
40
+ * 0.001 Satoshi, or 10e-11 Bitcoin. We recommend using the Satoshi unit
41
+ * instead when possible. *
42
+ */
43
+ MILLISATOSHI = "MILLISATOSHI",
44
+ /** United States Dollar. **/
45
+ USD = "USD",
46
+ /**
47
+ * 0.000000001 (10e-9) Bitcoin or a billionth of a Bitcoin.
48
+ * We recommend using the Satoshi unit instead when possible.
49
+ * *
50
+ */
51
+ NANOBITCOIN = "NANOBITCOIN",
52
+ /**
53
+ * 0.000001 (10e-6) Bitcoin or a millionth of a Bitcoin.
54
+ * We recommend using the Satoshi unit instead when possible.
55
+ * *
56
+ */
57
+ MICROBITCOIN = "MICROBITCOIN",
58
+ /**
59
+ * 0.001 (10e-3) Bitcoin or a thousandth of a Bitcoin.
60
+ * We recommend using the Satoshi unit instead when possible.
61
+ * *
62
+ */
63
+ MILLIBITCOIN = "MILLIBITCOIN"
64
+ }
65
+ /** This object represents the value and unit for an amount of currency. **/
66
+ type CurrencyAmountType = {
67
+ /** The original numeric value for this CurrencyAmount. **/
68
+ originalValue: number;
69
+ /** The original unit of currency for this CurrencyAmount. **/
70
+ originalUnit: CurrencyUnit;
71
+ /** The unit of user's preferred currency. **/
72
+ preferredCurrencyUnit: CurrencyUnit;
73
+ /**
74
+ * The rounded numeric value for this CurrencyAmount in the very base level
75
+ * of user's preferred currency. For example, for USD, the value will be in
76
+ * cents.
77
+ **/
78
+ preferredCurrencyValueRounded: number;
79
+ /**
80
+ * The approximate float value for this CurrencyAmount in the very base level
81
+ * of user's preferred currency. For example, for USD, the value will be in
82
+ * cents.
83
+ **/
84
+ preferredCurrencyValueApprox: number;
85
+ };
86
+ declare function convertCurrencyAmountValue(fromUnit: CurrencyUnit, toUnit: CurrencyUnit, amount: number, centsPerBtc?: number): number;
87
+ declare const convertCurrencyAmount: (from: CurrencyAmountType, toUnit: CurrencyUnit) => CurrencyAmountType;
88
+ type CurrencyMap = {
89
+ sats: number;
90
+ msats: number;
91
+ btc: number;
92
+ [CurrencyUnit.BITCOIN]: number;
93
+ [CurrencyUnit.SATOSHI]: number;
94
+ [CurrencyUnit.MILLISATOSHI]: number;
95
+ [CurrencyUnit.MICROBITCOIN]: number;
96
+ [CurrencyUnit.MILLIBITCOIN]: number;
97
+ [CurrencyUnit.NANOBITCOIN]: number;
98
+ [CurrencyUnit.USD]: number;
99
+ [CurrencyUnit.FUTURE_VALUE]: number;
100
+ formatted: {
101
+ sats: string;
102
+ msats: string;
103
+ btc: string;
104
+ [CurrencyUnit.BITCOIN]: string;
105
+ [CurrencyUnit.SATOSHI]: string;
106
+ [CurrencyUnit.MILLISATOSHI]: string;
107
+ [CurrencyUnit.MILLIBITCOIN]: string;
108
+ [CurrencyUnit.MICROBITCOIN]: string;
109
+ [CurrencyUnit.NANOBITCOIN]: string;
110
+ [CurrencyUnit.USD]: string;
111
+ [CurrencyUnit.FUTURE_VALUE]: string;
112
+ };
113
+ isZero: boolean;
114
+ isLessThan: (other: CurrencyMap | CurrencyAmountObj | number) => boolean;
115
+ isGreaterThan: (other: CurrencyMap | CurrencyAmountObj | number) => boolean;
116
+ isEqualTo: (other: CurrencyMap | CurrencyAmountObj | number) => boolean;
117
+ type: "CurrencyMap";
118
+ };
119
+ type CurrencyAmountObj = {
120
+ value?: number | string | null;
121
+ unit?: CurrencyUnit;
122
+ __typename?: "CurrencyAmount";
123
+ };
124
+ type CurrencyAmountArg = CurrencyAmountObj | CurrencyAmountType | undefined | null;
125
+ declare function isCurrencyAmountObj(arg: unknown): arg is CurrencyAmountObj;
126
+ declare function isCurrencyAmount(arg: unknown): arg is CurrencyAmountType;
127
+ declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, centsPerBtc?: number): CurrencyMap;
128
+ declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
129
+ declare const abbrCurrencyUnit: (unit: CurrencyUnit) => "USD" | "BTC" | "SAT" | "MSAT" | "Unsupported CurrencyUnit";
130
+ declare function formatCurrencyStr(amount: CurrencyAmountArg, maxFractionDigits?: number, compact?: boolean, showBtcSymbol?: boolean, options?: Intl.NumberFormatOptions): string;
131
+ declare function separateCurrencyStrParts(currencyStr: string): {
132
+ symbol: string;
133
+ amount: string;
134
+ };
135
+ declare function localeToCurrencySymbol(locale: string): string;
136
+
137
+ declare const isBrowser: boolean;
138
+ declare const isNode: boolean;
139
+ declare const isTest: boolean;
140
+
141
+ type Maybe<T> = T | null | undefined;
142
+ type ExpandRecursively<T> = T extends object ? T extends infer O ? {
143
+ [K in keyof O]: ExpandRecursively<O[K]>;
144
+ } : never : T;
145
+ type ById<T> = {
146
+ [id: string]: T;
147
+ };
148
+ type OmitTypename<T> = Omit<T, "__typename">;
149
+ declare const isType: <T extends string>(typename: T) => <N extends {
150
+ __typename: string;
151
+ }>(node: N | null | undefined) => node is Extract<N, {
152
+ __typename: T;
153
+ }>;
154
+ type DeepPartial<T> = T extends object ? {
155
+ [P in keyof T]?: DeepPartial<T[P]>;
156
+ } : T;
157
+ type JSONLiteral = string | number | boolean | null;
158
+ type JSONType = JSONLiteral | JSONType[] | {
159
+ [key: string]: JSONType;
160
+ };
161
+ type JSONObject = {
162
+ [key: string]: JSONType;
163
+ };
164
+
165
+ declare const isError: (e: unknown) => e is Error;
166
+ type ErrorWithMessage = {
167
+ message: string;
168
+ };
169
+ declare const isErrorWithMessage: (e: unknown) => e is ErrorWithMessage;
170
+ declare const getErrorMsg: (e: unknown) => string;
171
+ declare const isErrorMsg: (e: unknown, msg: string) => boolean;
172
+ declare function errorToJSON(err: unknown): JSONType;
173
+
174
+ declare const bytesToHex: (bytes: Uint8Array) => string;
175
+ declare const hexToBytes: (hex: string) => Uint8Array;
176
+
177
+ declare function getLocalStorageConfigItem(key: ConfigKeys): boolean;
178
+ declare function getLocalStorageBoolean(key: string): boolean;
179
+ declare function setLocalStorageBoolean(key: string, value: boolean): void;
180
+ declare const deleteLocalStorageItem: (key: string) => void;
181
+
182
+ declare function getCurrentLocale(): string;
183
+
184
+ declare const countryCodesToCurrencyCodes: {
185
+ readonly AD: "EUR";
186
+ readonly AR: "ARS";
187
+ readonly AS: "USD";
188
+ readonly AT: "EUR";
189
+ readonly AU: "AUD";
190
+ readonly AX: "EUR";
191
+ readonly BE: "EUR";
192
+ readonly BL: "EUR";
193
+ readonly BQ: "USD";
194
+ readonly BR: "BRL";
195
+ readonly CA: "CAD";
196
+ readonly CO: "COP";
197
+ readonly CY: "EUR";
198
+ readonly DE: "EUR";
199
+ readonly EC: "USD";
200
+ readonly EE: "EUR";
201
+ readonly ES: "EUR";
202
+ readonly FI: "EUR";
203
+ readonly FM: "USD";
204
+ readonly FR: "EUR";
205
+ readonly GB: "GBP";
206
+ readonly GF: "EUR";
207
+ readonly GG: "GBP";
208
+ readonly GP: "EUR";
209
+ readonly GR: "EUR";
210
+ readonly GS: "GBP";
211
+ readonly GU: "USD";
212
+ readonly IE: "EUR";
213
+ readonly IM: "GBP";
214
+ readonly IN: "INR";
215
+ readonly IO: "USD";
216
+ readonly IT: "EUR";
217
+ readonly JE: "GBP";
218
+ readonly LT: "EUR";
219
+ readonly LU: "EUR";
220
+ readonly LV: "EUR";
221
+ readonly MC: "EUR";
222
+ readonly ME: "EUR";
223
+ readonly MF: "EUR";
224
+ readonly MH: "USD";
225
+ readonly MP: "USD";
226
+ readonly MQ: "EUR";
227
+ readonly MT: "EUR";
228
+ readonly MX: "MXN";
229
+ readonly NF: "AUD";
230
+ readonly NL: "EUR";
231
+ readonly NR: "AUD";
232
+ readonly PM: "EUR";
233
+ readonly PR: "USD";
234
+ readonly PT: "EUR";
235
+ readonly PW: "USD";
236
+ readonly RE: "EUR";
237
+ readonly SI: "EUR";
238
+ readonly SK: "EUR";
239
+ readonly SM: "EUR";
240
+ readonly TC: "USD";
241
+ readonly TF: "EUR";
242
+ readonly TL: "USD";
243
+ readonly TV: "AUD";
244
+ readonly UM: "USD";
245
+ readonly US: "USD";
246
+ readonly VA: "EUR";
247
+ readonly VG: "USD";
248
+ readonly VI: "USD";
249
+ readonly YT: "EUR";
250
+ };
251
+ type CurrencyLocales = keyof typeof countryCodesToCurrencyCodes;
252
+ type CurrencyCodes = (typeof countryCodesToCurrencyCodes)[CurrencyLocales];
253
+ declare function localeToCurrencyCode(locale: string): CurrencyCodes;
254
+
255
+ declare function clamp(val: number, min: number, max: number): number;
256
+ declare function linearInterpolate(value: number, fromRangeStart: number, fromRangeEnd: number, toRangeStart: number, toRangeEnd: number): number;
257
+ declare function round(num: number, decimalPlaces?: number): number;
258
+ declare function isNumber(value: unknown): value is number;
259
+
260
+ type GetValueResult<T> = {
261
+ stopPolling: boolean;
262
+ value: null | T;
263
+ };
264
+ declare function pollUntil<D extends () => Promise<unknown>, T>(asyncFn: D, getValue: (data: Awaited<ReturnType<D>>, response: {
265
+ stopPolling: boolean;
266
+ value: null | T;
267
+ }) => GetValueResult<T>, maxPolls?: number, pollIntervalMs?: number, ignoreErrors?: boolean | ((e: unknown) => boolean), getMaxPollsError?: (maxPolls: number) => Error): Promise<T>;
268
+
269
+ declare function sleep(ms: number): Promise<unknown>;
270
+
271
+ export { JSONType as $, isErrorMsg as A, errorToJSON as B, ConfigKeys as C, bytesToHex as D, hexToBytes as E, getLocalStorageConfigItem as F, getLocalStorageBoolean as G, setLocalStorageBoolean as H, deleteLocalStorageItem as I, getCurrentLocale as J, countryCodesToCurrencyCodes as K, CurrencyLocales as L, CurrencyCodes as M, localeToCurrencyCode as N, clamp as O, linearInterpolate as P, round as Q, isNumber as R, pollUntil as S, sleep as T, Maybe as U, ExpandRecursively as V, ById as W, OmitTypename as X, isType as Y, DeepPartial as Z, JSONLiteral as _, b64encode as a, JSONObject as a0, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, CurrencyUnit as e, CurrencyAmountType as f, convertCurrencyAmountValue as g, convertCurrencyAmount as h, CurrencyMap as i, CurrencyAmountObj as j, CurrencyAmountArg as k, isCurrencyAmountObj as l, isCurrencyAmount as m, mapCurrencyAmount as n, isCurrencyMap as o, abbrCurrencyUnit as p, formatCurrencyStr as q, localeToCurrencySymbol as r, separateCurrencyStrParts as s, isBrowser as t, urlsafe_b64decode as u, isNode as v, isTest as w, isError as x, isErrorWithMessage as y, getErrorMsg as z };
package/dist/index.cjs CHANGED
@@ -57,9 +57,12 @@ __export(src_exports, {
57
57
  countryCodesToCurrencyCodes: () => countryCodesToCurrencyCodes,
58
58
  createSha256Hash: () => createSha256Hash,
59
59
  defaultCurrencyCode: () => defaultCurrencyCode,
60
+ deleteLocalStorageItem: () => deleteLocalStorageItem,
61
+ errorToJSON: () => errorToJSON,
60
62
  formatCurrencyStr: () => formatCurrencyStr,
61
63
  getCurrentLocale: () => getCurrentLocale,
62
64
  getErrorMsg: () => getErrorMsg,
65
+ getLocalStorageBoolean: () => getLocalStorageBoolean,
63
66
  getLocalStorageConfigItem: () => getLocalStorageConfigItem,
64
67
  hexToBytes: () => hexToBytes,
65
68
  isBrowser: () => isBrowser,
@@ -80,6 +83,7 @@ __export(src_exports, {
80
83
  pollUntil: () => pollUntil,
81
84
  round: () => round,
82
85
  separateCurrencyStrParts: () => separateCurrencyStrParts,
86
+ setLocalStorageBoolean: () => setLocalStorageBoolean,
83
87
  sleep: () => sleep,
84
88
  urlsafe_b64decode: () => urlsafe_b64decode
85
89
  });
@@ -174,18 +178,11 @@ var StubAuthProvider = class {
174
178
  }
175
179
  };
176
180
 
177
- // src/constants/localStorage.ts
181
+ // src/constants/index.ts
178
182
  var ConfigKeys = {
179
183
  LoggingEnabled: "lightspark-logging-enabled",
180
184
  ConsoleToolsEnabled: "lightspark-console-tools-enabled"
181
185
  };
182
- var getLocalStorageConfigItem = (key) => {
183
- try {
184
- return localStorage.getItem(key) === "1";
185
- } catch (e) {
186
- return false;
187
- }
188
- };
189
186
 
190
187
  // src/crypto/KeyOrAlias.ts
191
188
  var KeyOrAlias = {
@@ -1125,6 +1122,38 @@ var isErrorMsg = (e, msg) => {
1125
1122
  }
1126
1123
  return false;
1127
1124
  };
1125
+ function errorToJSON(err) {
1126
+ if (typeof err === "object" && err !== null && "toJSON" in err && typeof err.toJSON === "function") {
1127
+ return err.toJSON();
1128
+ }
1129
+ return JSON.parse(
1130
+ JSON.stringify(err, Object.getOwnPropertyNames(err))
1131
+ );
1132
+ }
1133
+
1134
+ // src/utils/localStorage.ts
1135
+ function getLocalStorageConfigItem(key) {
1136
+ return getLocalStorageBoolean(key);
1137
+ }
1138
+ function getLocalStorageBoolean(key) {
1139
+ try {
1140
+ return localStorage.getItem(key) === "1";
1141
+ } catch (e) {
1142
+ return false;
1143
+ }
1144
+ }
1145
+ function setLocalStorageBoolean(key, value) {
1146
+ try {
1147
+ localStorage.setItem(key, value ? "1" : "0");
1148
+ } catch (e) {
1149
+ }
1150
+ }
1151
+ var deleteLocalStorageItem = (key) => {
1152
+ try {
1153
+ localStorage.removeItem(key);
1154
+ } catch (e) {
1155
+ }
1156
+ };
1128
1157
 
1129
1158
  // ../../node_modules/lodash-es/_freeGlobal.js
1130
1159
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
@@ -1282,7 +1311,7 @@ var Secp256k1SigningKey = class extends SigningKey {
1282
1311
  const keyBytes = new Uint8Array(hexToBytes(this.privateKey));
1283
1312
  const hash = await createSha256Hash(data);
1284
1313
  const signResult = import_secp256k1.default.ecdsaSign(hash, keyBytes);
1285
- return signResult.signature;
1314
+ return import_secp256k1.default.signatureExport(signResult.signature);
1286
1315
  }
1287
1316
  };
1288
1317
 
@@ -1525,9 +1554,11 @@ var Requester = class {
1525
1554
  "Missing node of encrypted_signing_private_key"
1526
1555
  );
1527
1556
  }
1528
- let TextEncoderImpl = TextEncoder;
1557
+ let TextEncoderImpl;
1529
1558
  if (typeof TextEncoder === "undefined") {
1530
1559
  TextEncoderImpl = (await import("text-encoding")).TextEncoder;
1560
+ } else {
1561
+ TextEncoderImpl = TextEncoder;
1531
1562
  }
1532
1563
  const encodedPayload = new TextEncoderImpl().encode(
1533
1564
  JSON.stringify(payload)
@@ -1571,9 +1602,12 @@ var Requester_default = Requester;
1571
1602
  countryCodesToCurrencyCodes,
1572
1603
  createSha256Hash,
1573
1604
  defaultCurrencyCode,
1605
+ deleteLocalStorageItem,
1606
+ errorToJSON,
1574
1607
  formatCurrencyStr,
1575
1608
  getCurrentLocale,
1576
1609
  getErrorMsg,
1610
+ getLocalStorageBoolean,
1577
1611
  getLocalStorageConfigItem,
1578
1612
  hexToBytes,
1579
1613
  isBrowser,
@@ -1594,6 +1628,7 @@ var Requester_default = Requester;
1594
1628
  pollUntil,
1595
1629
  round,
1596
1630
  separateCurrencyStrParts,
1631
+ setLocalStorageBoolean,
1597
1632
  sleep,
1598
1633
  urlsafe_b64decode
1599
1634
  });
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
+ export { W as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, X as OmitTypename, 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, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-d0c72658.js';
1
2
  import { Observable } from 'zen-observable-ts';
2
- export { ById, CurrencyAmountArg, CurrencyAmountObj, CurrencyAmountType, CurrencyCodes, CurrencyLocales, CurrencyMap, CurrencyUnit, DeepPartial, ExpandRecursively, Maybe, OmitTypename, abbrCurrencyUnit, b64decode, b64encode, bytesToHex, clamp, convertCurrencyAmount, convertCurrencyAmountValue, countryCodesToCurrencyCodes, createSha256Hash, defaultCurrencyCode, formatCurrencyStr, getCurrentLocale, getErrorMsg, hexToBytes, isBrowser, isCurrencyAmount, isCurrencyAmountObj, isCurrencyMap, isError, isErrorMsg, isErrorWithMessage, isNode, isNumber, isTest, isType, linearInterpolate, localeToCurrencyCode, localeToCurrencySymbol, mapCurrencyAmount, pollUntil, round, separateCurrencyStrParts, sleep, urlsafe_b64decode } from './utils/index.cjs';
3
3
 
4
4
  declare class LightsparkException extends Error {
5
5
  code: string;
@@ -41,13 +41,6 @@ declare class StubAuthProvider implements AuthProvider {
41
41
  addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
42
42
  }
43
43
 
44
- declare const ConfigKeys: {
45
- readonly LoggingEnabled: "lightspark-logging-enabled";
46
- readonly ConsoleToolsEnabled: "lightspark-console-tools-enabled";
47
- };
48
- type ConfigKeys = (typeof ConfigKeys)[keyof typeof ConfigKeys];
49
- declare const getLocalStorageConfigItem: (key: ConfigKeys) => boolean;
50
-
51
44
  type OnlyKey = {
52
45
  key: string;
53
46
  alias?: never;
@@ -165,4 +158,4 @@ declare class Requester {
165
158
  private addSigningDataIfNeeded;
166
159
  }
167
160
 
168
- export { AuthProvider, ConfigKeys, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, getLocalStorageConfigItem };
161
+ export { AuthProvider, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ export { W as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, X as OmitTypename, 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, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-d0c72658.js';
1
2
  import { Observable } from 'zen-observable-ts';
2
- export { ById, CurrencyAmountArg, CurrencyAmountObj, CurrencyAmountType, CurrencyCodes, CurrencyLocales, CurrencyMap, CurrencyUnit, DeepPartial, ExpandRecursively, Maybe, OmitTypename, abbrCurrencyUnit, b64decode, b64encode, bytesToHex, clamp, convertCurrencyAmount, convertCurrencyAmountValue, countryCodesToCurrencyCodes, createSha256Hash, defaultCurrencyCode, formatCurrencyStr, getCurrentLocale, getErrorMsg, hexToBytes, isBrowser, isCurrencyAmount, isCurrencyAmountObj, isCurrencyMap, isError, isErrorMsg, isErrorWithMessage, isNode, isNumber, isTest, isType, linearInterpolate, localeToCurrencyCode, localeToCurrencySymbol, mapCurrencyAmount, pollUntil, round, separateCurrencyStrParts, sleep, urlsafe_b64decode } from './utils/index.js';
3
3
 
4
4
  declare class LightsparkException extends Error {
5
5
  code: string;
@@ -41,13 +41,6 @@ declare class StubAuthProvider implements AuthProvider {
41
41
  addWsConnectionParams(params: WsConnectionParams): Promise<WsConnectionParams>;
42
42
  }
43
43
 
44
- declare const ConfigKeys: {
45
- readonly LoggingEnabled: "lightspark-logging-enabled";
46
- readonly ConsoleToolsEnabled: "lightspark-console-tools-enabled";
47
- };
48
- type ConfigKeys = (typeof ConfigKeys)[keyof typeof ConfigKeys];
49
- declare const getLocalStorageConfigItem: (key: ConfigKeys) => boolean;
50
-
51
44
  type OnlyKey = {
52
45
  key: string;
53
46
  alias?: never;
@@ -165,4 +158,4 @@ declare class Requester {
165
158
  private addSigningDataIfNeeded;
166
159
  }
167
160
 
168
- export { AuthProvider, ConfigKeys, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, getLocalStorageConfigItem };
161
+ export { AuthProvider, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment };
package/dist/index.js CHANGED
@@ -11,9 +11,13 @@ import {
11
11
  countryCodesToCurrencyCodes,
12
12
  createSha256Hash,
13
13
  defaultCurrencyCode,
14
+ deleteLocalStorageItem,
15
+ errorToJSON,
14
16
  formatCurrencyStr,
15
17
  getCurrentLocale,
16
18
  getErrorMsg,
19
+ getLocalStorageBoolean,
20
+ getLocalStorageConfigItem,
17
21
  hexToBytes,
18
22
  isBrowser,
19
23
  isCurrencyAmount,
@@ -33,9 +37,10 @@ import {
33
37
  pollUntil,
34
38
  round,
35
39
  separateCurrencyStrParts,
40
+ setLocalStorageBoolean,
36
41
  sleep,
37
42
  urlsafe_b64decode
38
- } from "./chunk-F3XHLUGC.js";
43
+ } from "./chunk-ADJSE2YZ.js";
39
44
 
40
45
  // src/Logger.ts
41
46
  var Logger = class {
@@ -107,18 +112,11 @@ var StubAuthProvider = class {
107
112
  }
108
113
  };
109
114
 
110
- // src/constants/localStorage.ts
115
+ // src/constants/index.ts
111
116
  var ConfigKeys = {
112
117
  LoggingEnabled: "lightspark-logging-enabled",
113
118
  ConsoleToolsEnabled: "lightspark-console-tools-enabled"
114
119
  };
115
- var getLocalStorageConfigItem = (key) => {
116
- try {
117
- return localStorage.getItem(key) === "1";
118
- } catch (e) {
119
- return false;
120
- }
121
- };
122
120
 
123
121
  // src/crypto/KeyOrAlias.ts
124
122
  var KeyOrAlias = {
@@ -375,7 +373,7 @@ var Secp256k1SigningKey = class extends SigningKey {
375
373
  const keyBytes = new Uint8Array(hexToBytes(this.privateKey));
376
374
  const hash = await createSha256Hash(data);
377
375
  const signResult = secp256k1.ecdsaSign(hash, keyBytes);
378
- return signResult.signature;
376
+ return secp256k1.signatureExport(signResult.signature);
379
377
  }
380
378
  };
381
379
 
@@ -618,9 +616,11 @@ var Requester = class {
618
616
  "Missing node of encrypted_signing_private_key"
619
617
  );
620
618
  }
621
- let TextEncoderImpl = TextEncoder;
619
+ let TextEncoderImpl;
622
620
  if (typeof TextEncoder === "undefined") {
623
621
  TextEncoderImpl = (await import("text-encoding")).TextEncoder;
622
+ } else {
623
+ TextEncoderImpl = TextEncoder;
624
624
  }
625
625
  const encodedPayload = new TextEncoderImpl().encode(
626
626
  JSON.stringify(payload)
@@ -663,9 +663,12 @@ export {
663
663
  countryCodesToCurrencyCodes,
664
664
  createSha256Hash,
665
665
  defaultCurrencyCode,
666
+ deleteLocalStorageItem,
667
+ errorToJSON,
666
668
  formatCurrencyStr,
667
669
  getCurrentLocale,
668
670
  getErrorMsg,
671
+ getLocalStorageBoolean,
669
672
  getLocalStorageConfigItem,
670
673
  hexToBytes,
671
674
  isBrowser,
@@ -686,6 +689,7 @@ export {
686
689
  pollUntil,
687
690
  round,
688
691
  separateCurrencyStrParts,
692
+ setLocalStorageBoolean,
689
693
  sleep,
690
694
  urlsafe_b64decode
691
695
  };
@@ -41,9 +41,13 @@ __export(utils_exports, {
41
41
  countryCodesToCurrencyCodes: () => countryCodesToCurrencyCodes,
42
42
  createSha256Hash: () => createSha256Hash,
43
43
  defaultCurrencyCode: () => defaultCurrencyCode,
44
+ deleteLocalStorageItem: () => deleteLocalStorageItem,
45
+ errorToJSON: () => errorToJSON,
44
46
  formatCurrencyStr: () => formatCurrencyStr,
45
47
  getCurrentLocale: () => getCurrentLocale,
46
48
  getErrorMsg: () => getErrorMsg,
49
+ getLocalStorageBoolean: () => getLocalStorageBoolean,
50
+ getLocalStorageConfigItem: () => getLocalStorageConfigItem,
47
51
  hexToBytes: () => hexToBytes,
48
52
  isBrowser: () => isBrowser,
49
53
  isCurrencyAmount: () => isCurrencyAmount,
@@ -63,6 +67,7 @@ __export(utils_exports, {
63
67
  pollUntil: () => pollUntil,
64
68
  round: () => round,
65
69
  separateCurrencyStrParts: () => separateCurrencyStrParts,
70
+ setLocalStorageBoolean: () => setLocalStorageBoolean,
66
71
  sleep: () => sleep,
67
72
  urlsafe_b64decode: () => urlsafe_b64decode
68
73
  });
@@ -798,6 +803,38 @@ var isErrorMsg = (e, msg) => {
798
803
  }
799
804
  return false;
800
805
  };
806
+ function errorToJSON(err) {
807
+ if (typeof err === "object" && err !== null && "toJSON" in err && typeof err.toJSON === "function") {
808
+ return err.toJSON();
809
+ }
810
+ return JSON.parse(
811
+ JSON.stringify(err, Object.getOwnPropertyNames(err))
812
+ );
813
+ }
814
+
815
+ // src/utils/localStorage.ts
816
+ function getLocalStorageConfigItem(key) {
817
+ return getLocalStorageBoolean(key);
818
+ }
819
+ function getLocalStorageBoolean(key) {
820
+ try {
821
+ return localStorage.getItem(key) === "1";
822
+ } catch (e) {
823
+ return false;
824
+ }
825
+ }
826
+ function setLocalStorageBoolean(key, value) {
827
+ try {
828
+ localStorage.setItem(key, value ? "1" : "0");
829
+ } catch (e) {
830
+ }
831
+ }
832
+ var deleteLocalStorageItem = (key) => {
833
+ try {
834
+ localStorage.removeItem(key);
835
+ } catch (e) {
836
+ }
837
+ };
801
838
 
802
839
  // ../../node_modules/lodash-es/_freeGlobal.js
803
840
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
@@ -937,9 +974,13 @@ var isType = (typename) => (node) => {
937
974
  countryCodesToCurrencyCodes,
938
975
  createSha256Hash,
939
976
  defaultCurrencyCode,
977
+ deleteLocalStorageItem,
978
+ errorToJSON,
940
979
  formatCurrencyStr,
941
980
  getCurrentLocale,
942
981
  getErrorMsg,
982
+ getLocalStorageBoolean,
983
+ getLocalStorageConfigItem,
943
984
  hexToBytes,
944
985
  isBrowser,
945
986
  isCurrencyAmount,
@@ -959,6 +1000,7 @@ var isType = (typename) => (node) => {
959
1000
  pollUntil,
960
1001
  round,
961
1002
  separateCurrencyStrParts,
1003
+ setLocalStorageBoolean,
962
1004
  sleep,
963
1005
  urlsafe_b64decode
964
1006
  });