@lightsparkdev/core 1.0.3 → 1.0.5

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
@@ -57,7 +57,10 @@ __export(src_exports, {
57
57
  isErrorMsg: () => isErrorMsg,
58
58
  isErrorWithMessage: () => isErrorWithMessage,
59
59
  isNode: () => isNode,
60
+ isTest: () => isTest,
60
61
  isType: () => isType,
62
+ pollUntil: () => pollUntil,
63
+ sleep: () => sleep,
61
64
  urlsafe_b64decode: () => urlsafe_b64decode
62
65
  });
63
66
  module.exports = __toCommonJS(src_exports);
@@ -363,6 +366,266 @@ var import_auto_bind = __toESM(require("auto-bind"), 1);
363
366
 
364
367
  // src/crypto/SigningKey.ts
365
368
  var import_secp256k1 = __toESM(require("secp256k1"), 1);
369
+
370
+ // src/utils/environment.ts
371
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
372
+ var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
373
+ var isTest = isNode && process.env.NODE_ENV === "test";
374
+
375
+ // src/utils/hex.ts
376
+ var bytesToHex = (bytes) => {
377
+ return bytes.reduce((acc, byte) => {
378
+ return acc += ("0" + byte.toString(16)).slice(-2);
379
+ }, "");
380
+ };
381
+ var hexToBytes = (hex) => {
382
+ const bytes = [];
383
+ for (let c = 0; c < hex.length; c += 2) {
384
+ bytes.push(parseInt(hex.substr(c, 2), 16));
385
+ }
386
+ return Uint8Array.from(bytes);
387
+ };
388
+
389
+ // src/utils/createHash.ts
390
+ async function createSha256Hash(data, asHex) {
391
+ if (isBrowser) {
392
+ const source = typeof data === "string" ? new TextEncoder().encode(data) : data;
393
+ const buffer = await window.crypto.subtle.digest("SHA-256", source);
394
+ const arr = new Uint8Array(buffer);
395
+ if (asHex) {
396
+ return bytesToHex(arr);
397
+ }
398
+ return arr;
399
+ } else {
400
+ const { createHash } = await import("crypto");
401
+ if (asHex) {
402
+ const hexStr = createHash("sha256").update(data).digest("hex");
403
+ return hexStr;
404
+ }
405
+ const buffer = createHash("sha256").update(data).digest();
406
+ return new Uint8Array(buffer);
407
+ }
408
+ }
409
+
410
+ // src/utils/currency.ts
411
+ var CONVERSION_MAP = {
412
+ ["BITCOIN" /* BITCOIN */]: {
413
+ ["BITCOIN" /* BITCOIN */]: (v) => v,
414
+ ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v * 1e6,
415
+ ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => v * 1e3,
416
+ ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e11,
417
+ ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 1e9,
418
+ ["SATOSHI" /* SATOSHI */]: (v) => v * 1e8
419
+ },
420
+ ["MICROBITCOIN" /* MICROBITCOIN */]: {
421
+ ["BITCOIN" /* BITCOIN */]: (v) => Math.round(v / 1e6),
422
+ ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v,
423
+ ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => Math.round(v / 1e3),
424
+ ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e5,
425
+ ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 1e3,
426
+ ["SATOSHI" /* SATOSHI */]: (v) => v * 100
427
+ },
428
+ ["MILLIBITCOIN" /* MILLIBITCOIN */]: {
429
+ ["BITCOIN" /* BITCOIN */]: (v) => Math.round(v / 1e3),
430
+ ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v * 1e3,
431
+ ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => v,
432
+ ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e8,
433
+ ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 1e6,
434
+ ["SATOSHI" /* SATOSHI */]: (v) => v * 1e5
435
+ },
436
+ ["MILLISATOSHI" /* MILLISATOSHI */]: {
437
+ ["BITCOIN" /* BITCOIN */]: (v) => Math.round(v / 1e11),
438
+ ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => Math.round(v / 1e5),
439
+ ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => Math.round(v / 1e8),
440
+ ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v,
441
+ ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => Math.round(v / 100),
442
+ ["SATOSHI" /* SATOSHI */]: (v) => Math.round(v / 1e3)
443
+ },
444
+ ["NANOBITCOIN" /* NANOBITCOIN */]: {
445
+ ["BITCOIN" /* BITCOIN */]: (v) => Math.round(v / 1e9),
446
+ ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => Math.round(v / 1e3),
447
+ ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => Math.round(v / 1e6),
448
+ ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 100,
449
+ ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v,
450
+ ["SATOSHI" /* SATOSHI */]: (v) => Math.round(v / 10)
451
+ },
452
+ ["SATOSHI" /* SATOSHI */]: {
453
+ ["BITCOIN" /* BITCOIN */]: (v) => Math.round(v / 1e8),
454
+ ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => Math.round(v / 100),
455
+ ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => Math.round(v / 1e5),
456
+ ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e3,
457
+ ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 10,
458
+ ["SATOSHI" /* SATOSHI */]: (v) => v
459
+ }
460
+ };
461
+ var convertCurrencyAmount = (from, toUnit) => {
462
+ if (from.originalUnit === "FUTURE_VALUE" /* FUTURE_VALUE */ || from.originalUnit === "USD" /* USD */ || toUnit === "FUTURE_VALUE" /* FUTURE_VALUE */ || toUnit === "USD" /* USD */) {
463
+ throw new LightsparkException_default("CurrencyError", `Unsupported CurrencyUnit.`);
464
+ }
465
+ const conversionFn = CONVERSION_MAP[from.originalUnit][toUnit];
466
+ if (!conversionFn) {
467
+ throw new LightsparkException_default(
468
+ "CurrencyError",
469
+ `Cannot convert from ${from.originalUnit} to ${toUnit}`
470
+ );
471
+ }
472
+ return {
473
+ ...from,
474
+ preferredCurrencyUnit: toUnit,
475
+ preferredCurrencyValueApprox: conversionFn(from.originalValue),
476
+ preferredCurrencyValueRounded: conversionFn(from.originalValue)
477
+ };
478
+ };
479
+
480
+ // src/utils/errors.ts
481
+ var isError = (e) => {
482
+ return Boolean(
483
+ 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")
484
+ );
485
+ };
486
+ var isErrorWithMessage = (e) => {
487
+ return Boolean(
488
+ typeof e === "object" && e !== null && "message" in e && typeof e.message === "string"
489
+ );
490
+ };
491
+ var getErrorMsg = (e) => {
492
+ return isErrorWithMessage(e) ? e.message : "Unknown error";
493
+ };
494
+ var isErrorMsg = (e, msg) => {
495
+ if (isError(e)) {
496
+ return e.message === msg;
497
+ }
498
+ return false;
499
+ };
500
+
501
+ // ../../node_modules/lodash-es/_freeGlobal.js
502
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
503
+ var freeGlobal_default = freeGlobal;
504
+
505
+ // ../../node_modules/lodash-es/_root.js
506
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
507
+ var root = freeGlobal_default || freeSelf || Function("return this")();
508
+ var root_default = root;
509
+
510
+ // ../../node_modules/lodash-es/_Symbol.js
511
+ var Symbol2 = root_default.Symbol;
512
+ var Symbol_default = Symbol2;
513
+
514
+ // ../../node_modules/lodash-es/_getRawTag.js
515
+ var objectProto = Object.prototype;
516
+ var hasOwnProperty = objectProto.hasOwnProperty;
517
+ var nativeObjectToString = objectProto.toString;
518
+ var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
519
+ function getRawTag(value) {
520
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
521
+ try {
522
+ value[symToStringTag] = void 0;
523
+ var unmasked = true;
524
+ } catch (e) {
525
+ }
526
+ var result = nativeObjectToString.call(value);
527
+ if (unmasked) {
528
+ if (isOwn) {
529
+ value[symToStringTag] = tag;
530
+ } else {
531
+ delete value[symToStringTag];
532
+ }
533
+ }
534
+ return result;
535
+ }
536
+ var getRawTag_default = getRawTag;
537
+
538
+ // ../../node_modules/lodash-es/_objectToString.js
539
+ var objectProto2 = Object.prototype;
540
+ var nativeObjectToString2 = objectProto2.toString;
541
+ function objectToString(value) {
542
+ return nativeObjectToString2.call(value);
543
+ }
544
+ var objectToString_default = objectToString;
545
+
546
+ // ../../node_modules/lodash-es/_baseGetTag.js
547
+ var nullTag = "[object Null]";
548
+ var undefinedTag = "[object Undefined]";
549
+ var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
550
+ function baseGetTag(value) {
551
+ if (value == null) {
552
+ return value === void 0 ? undefinedTag : nullTag;
553
+ }
554
+ return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
555
+ }
556
+ var baseGetTag_default = baseGetTag;
557
+
558
+ // ../../node_modules/lodash-es/isObject.js
559
+ function isObject(value) {
560
+ var type = typeof value;
561
+ return value != null && (type == "object" || type == "function");
562
+ }
563
+ var isObject_default = isObject;
564
+
565
+ // ../../node_modules/lodash-es/isFunction.js
566
+ var asyncTag = "[object AsyncFunction]";
567
+ var funcTag = "[object Function]";
568
+ var genTag = "[object GeneratorFunction]";
569
+ var proxyTag = "[object Proxy]";
570
+ function isFunction(value) {
571
+ if (!isObject_default(value)) {
572
+ return false;
573
+ }
574
+ var tag = baseGetTag_default(value);
575
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
576
+ }
577
+ var isFunction_default = isFunction;
578
+
579
+ // src/utils/sleep.ts
580
+ function sleep(ms) {
581
+ return new Promise((resolve) => setTimeout(resolve, ms));
582
+ }
583
+
584
+ // src/utils/pollUntil.ts
585
+ function getDefaultMaxPollsError() {
586
+ return new Error("pollUntil: Max polls reached");
587
+ }
588
+ function pollUntil(asyncFn, getValue, maxPolls = 60, pollIntervalMs = 500, ignoreErrors = false, getMaxPollsError = getDefaultMaxPollsError) {
589
+ return new Promise((resolve, reject) => {
590
+ let polls = 0;
591
+ let stopPolling = false;
592
+ (async function() {
593
+ while (!stopPolling) {
594
+ polls += 1;
595
+ if (polls > maxPolls) {
596
+ stopPolling = true;
597
+ const maxPollsError = getMaxPollsError(maxPolls);
598
+ reject(maxPollsError);
599
+ break;
600
+ }
601
+ try {
602
+ const asyncResult = await asyncFn();
603
+ const result = getValue(asyncResult, {
604
+ stopPolling: false,
605
+ value: null
606
+ });
607
+ if (result.stopPolling) {
608
+ stopPolling = true;
609
+ resolve(result.value);
610
+ }
611
+ } catch (e) {
612
+ if (!ignoreErrors || isFunction_default(ignoreErrors) && !ignoreErrors(e)) {
613
+ stopPolling = true;
614
+ reject(e);
615
+ }
616
+ }
617
+ await sleep(pollIntervalMs);
618
+ }
619
+ })();
620
+ });
621
+ }
622
+
623
+ // src/utils/types.ts
624
+ var isType = (typename) => (node) => {
625
+ return node?.__typename === typename;
626
+ };
627
+
628
+ // src/crypto/SigningKey.ts
366
629
  function isAlias(key) {
367
630
  return "alias" in key;
368
631
  }
@@ -468,6 +731,8 @@ var Logger = class {
468
731
  async updateLoggingEnabled(getLoggingEnabled) {
469
732
  if (getLoggingEnabled) {
470
733
  this.loggingEnabled = await getLoggingEnabled();
734
+ } else if (isTest) {
735
+ this.loggingEnabled = true;
471
736
  } else if (isBrowser) {
472
737
  try {
473
738
  this.loggingEnabled = localStorage.getItem("lightspark-logging-enabled") === "1";
@@ -493,12 +758,6 @@ var import_utc = __toESM(require("dayjs/plugin/utc.js"), 1);
493
758
  var import_graphql_ws = require("graphql-ws");
494
759
  var import_ws = __toESM(require("ws"), 1);
495
760
  var import_zen_observable_ts = require("zen-observable-ts");
496
-
497
- // src/utils/environment.ts
498
- var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
499
- var isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
500
-
501
- // src/requester/Requester.ts
502
761
  var DEFAULT_BASE_URL = "api.lightspark.com";
503
762
  var LIGHTSPARK_BETA_HEADER_KEY = "X-Lightspark-Beta";
504
763
  var LIGHTSPARK_BETA_HEADER_VALUE = "z2h0BBYxTA83cjW7fi8QwWtBPCzkQKiemcuhKY08LOo";
@@ -537,13 +796,14 @@ var Requester = class {
537
796
  return query.constructObject(data);
538
797
  }
539
798
  subscribe(queryPayload, variables = {}) {
540
- logger.info(`Requester.subscribe params`, queryPayload, variables);
799
+ logger.info(`Requester.subscribe variables`, variables);
541
800
  const operationNameRegex = /^\s*(query|mutation|subscription)\s+(\w+)/i;
542
801
  const operationMatch = queryPayload.match(operationNameRegex);
543
802
  if (!operationMatch || operationMatch.length < 3) {
544
803
  throw new LightsparkException_default("InvalidQuery", "Invalid query payload");
545
804
  }
546
805
  const operationType = operationMatch[1];
806
+ logger.info(`Requester.subscribe operationType`, operationType);
547
807
  if (operationType == "mutation") {
548
808
  throw new LightsparkException_default(
549
809
  "InvalidQuery",
@@ -561,7 +821,6 @@ var Requester = class {
561
821
  variables,
562
822
  operationName: operation
563
823
  };
564
- logger.info(`Requester.subscribe bodyData`, bodyData);
565
824
  return new import_zen_observable_ts.Observable((observer) => {
566
825
  logger.info(`Requester.subscribe observer`, observer);
567
826
  return this.wsClient.subscribe(bodyData, {
@@ -697,127 +956,6 @@ var apiDomainForEnvironment = (environment) => {
697
956
  }
698
957
  };
699
958
  var ServerEnvironment_default = ServerEnvironment;
700
-
701
- // src/utils/createHash.ts
702
- var createSha256Hash = async (data) => {
703
- if (isBrowser) {
704
- return new Uint8Array(await window.crypto.subtle.digest("SHA-256", data));
705
- } else {
706
- const { createHash } = await import("crypto");
707
- const buffer = createHash("sha256").update(data).digest();
708
- return new Uint8Array(buffer);
709
- }
710
- };
711
-
712
- // src/utils/currency.ts
713
- var CONVERSION_MAP = {
714
- ["BITCOIN" /* BITCOIN */]: {
715
- ["BITCOIN" /* BITCOIN */]: (v) => v,
716
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v * 1e6,
717
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => v * 1e3,
718
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e11,
719
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 1e9,
720
- ["SATOSHI" /* SATOSHI */]: (v) => v * 1e8
721
- },
722
- ["MICROBITCOIN" /* MICROBITCOIN */]: {
723
- ["BITCOIN" /* BITCOIN */]: (v) => Math.round(v / 1e6),
724
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v,
725
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => Math.round(v / 1e3),
726
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e5,
727
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 1e3,
728
- ["SATOSHI" /* SATOSHI */]: (v) => v * 100
729
- },
730
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: {
731
- ["BITCOIN" /* BITCOIN */]: (v) => Math.round(v / 1e3),
732
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => v * 1e3,
733
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => v,
734
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e8,
735
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 1e6,
736
- ["SATOSHI" /* SATOSHI */]: (v) => v * 1e5
737
- },
738
- ["MILLISATOSHI" /* MILLISATOSHI */]: {
739
- ["BITCOIN" /* BITCOIN */]: (v) => Math.round(v / 1e11),
740
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => Math.round(v / 1e5),
741
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => Math.round(v / 1e8),
742
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v,
743
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => Math.round(v / 100),
744
- ["SATOSHI" /* SATOSHI */]: (v) => Math.round(v / 1e3)
745
- },
746
- ["NANOBITCOIN" /* NANOBITCOIN */]: {
747
- ["BITCOIN" /* BITCOIN */]: (v) => Math.round(v / 1e9),
748
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => Math.round(v / 1e3),
749
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => Math.round(v / 1e6),
750
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 100,
751
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v,
752
- ["SATOSHI" /* SATOSHI */]: (v) => Math.round(v / 10)
753
- },
754
- ["SATOSHI" /* SATOSHI */]: {
755
- ["BITCOIN" /* BITCOIN */]: (v) => Math.round(v / 1e8),
756
- ["MICROBITCOIN" /* MICROBITCOIN */]: (v) => Math.round(v / 100),
757
- ["MILLIBITCOIN" /* MILLIBITCOIN */]: (v) => Math.round(v / 1e5),
758
- ["MILLISATOSHI" /* MILLISATOSHI */]: (v) => v * 1e3,
759
- ["NANOBITCOIN" /* NANOBITCOIN */]: (v) => v * 10,
760
- ["SATOSHI" /* SATOSHI */]: (v) => v
761
- }
762
- };
763
- var convertCurrencyAmount = (from, toUnit) => {
764
- if (from.originalUnit === "FUTURE_VALUE" /* FUTURE_VALUE */ || from.originalUnit === "USD" /* USD */ || toUnit === "FUTURE_VALUE" /* FUTURE_VALUE */ || toUnit === "USD" /* USD */) {
765
- throw new LightsparkException_default("CurrencyError", `Unsupported CurrencyUnit.`);
766
- }
767
- const conversionFn = CONVERSION_MAP[from.originalUnit][toUnit];
768
- if (!conversionFn) {
769
- throw new LightsparkException_default(
770
- "CurrencyError",
771
- `Cannot convert from ${from.originalUnit} to ${toUnit}`
772
- );
773
- }
774
- return {
775
- ...from,
776
- preferredCurrencyUnit: toUnit,
777
- preferredCurrencyValueApprox: conversionFn(from.originalValue),
778
- preferredCurrencyValueRounded: conversionFn(from.originalValue)
779
- };
780
- };
781
-
782
- // src/utils/errors.ts
783
- var isError = (e) => {
784
- return Boolean(
785
- 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")
786
- );
787
- };
788
- var isErrorWithMessage = (e) => {
789
- return Boolean(
790
- typeof e === "object" && e !== null && "message" in e && typeof e.message === "string"
791
- );
792
- };
793
- var getErrorMsg = (e) => {
794
- return isErrorWithMessage(e) ? e.message : "Unknown error";
795
- };
796
- var isErrorMsg = (e, msg) => {
797
- if (isError(e)) {
798
- return e.message === msg;
799
- }
800
- return false;
801
- };
802
-
803
- // src/utils/hex.ts
804
- var bytesToHex = (bytes) => {
805
- return bytes.reduce((acc, byte) => {
806
- return acc += ("0" + byte.toString(16)).slice(-2);
807
- }, "");
808
- };
809
- var hexToBytes = (hex) => {
810
- const bytes = [];
811
- for (let c = 0; c < hex.length; c += 2) {
812
- bytes.push(parseInt(hex.substr(c, 2), 16));
813
- }
814
- return Uint8Array.from(bytes);
815
- };
816
-
817
- // src/utils/types.ts
818
- var isType = (typename) => (node) => {
819
- return node?.__typename === typename;
820
- };
821
959
  // Annotate the CommonJS export names for ESM import in node:
822
960
  0 && (module.exports = {
823
961
  DefaultCrypto,
@@ -847,6 +985,22 @@ var isType = (typename) => (node) => {
847
985
  isErrorMsg,
848
986
  isErrorWithMessage,
849
987
  isNode,
988
+ isTest,
850
989
  isType,
990
+ pollUntil,
991
+ sleep,
851
992
  urlsafe_b64decode
852
993
  });
994
+ /*! Bundled license information:
995
+
996
+ lodash-es/lodash.js:
997
+ (**
998
+ * @license
999
+ * Lodash (Custom Build) <https://lodash.com/>
1000
+ * Build: `lodash modularize exports="es" -o ./`
1001
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
1002
+ * Released under MIT license <https://lodash.com/license>
1003
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1004
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1005
+ *)
1006
+ */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Observable } from 'zen-observable-ts';
2
+ export { ById, ExpandRecursively, Maybe, OmitTypename, b64decode, b64encode, bytesToHex, convertCurrencyAmount, createSha256Hash, getErrorMsg, hexToBytes, isBrowser, isError, isErrorMsg, isErrorWithMessage, isNode, isTest, isType, pollUntil, sleep, urlsafe_b64decode } from './utils/index.js';
2
3
 
3
4
  type Headers = Record<string, string>;
4
5
  type WsConnectionParams = Record<string, unknown>;
@@ -154,80 +155,4 @@ declare enum ServerEnvironment {
154
155
  }
155
156
  declare const apiDomainForEnvironment: (environment: ServerEnvironment) => string;
156
157
 
157
- declare const b64decode: (encoded: string) => Uint8Array;
158
- declare const urlsafe_b64decode: (encoded: string) => Uint8Array;
159
- declare const b64encode: (data: ArrayBuffer) => string;
160
-
161
- declare const createSha256Hash: (data: Uint8Array) => Promise<Uint8Array>;
162
-
163
- /** Represents the value and unit for an amount of currency. **/
164
- type CurrencyAmount = {
165
- /** The original numeric value for this CurrencyAmount. **/
166
- originalValue: number;
167
- /** The original unit of currency for this CurrencyAmount. **/
168
- originalUnit: CurrencyUnit;
169
- /** The unit of user's preferred currency. **/
170
- preferredCurrencyUnit: CurrencyUnit;
171
- /**
172
- * The rounded numeric value for this CurrencyAmount in the very base level of user's preferred
173
- * currency. For example, for USD, the value will be in cents.
174
- **/
175
- preferredCurrencyValueRounded: number;
176
- /**
177
- * The approximate float value for this CurrencyAmount in the very base level of user's preferred
178
- * currency. For example, for USD, the value will be in cents.
179
- **/
180
- preferredCurrencyValueApprox: number;
181
- };
182
- declare enum CurrencyUnit {
183
- /**
184
- * This is an enum value that represents values that could be added in the future.
185
- * Clients should support unknown values as more of them could be added without notice.
186
- */
187
- FUTURE_VALUE = "FUTURE_VALUE",
188
- /** Bitcoin is the cryptocurrency native to the Bitcoin network. It is used as the native medium for value transfer for the Lightning Network. **/
189
- BITCOIN = "BITCOIN",
190
- /** 0.00000001 (10e-8) Bitcoin or one hundred millionth of a Bitcoin. This is the unit most commonly used in Lightning transactions. **/
191
- SATOSHI = "SATOSHI",
192
- /** 0.001 Satoshi, or 10e-11 Bitcoin. We recommend using the Satoshi unit instead when possible. **/
193
- MILLISATOSHI = "MILLISATOSHI",
194
- /** United States Dollar. **/
195
- USD = "USD",
196
- /** 0.000000001 (10e-9) Bitcoin or a billionth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
197
- NANOBITCOIN = "NANOBITCOIN",
198
- /** 0.000001 (10e-6) Bitcoin or a millionth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
199
- MICROBITCOIN = "MICROBITCOIN",
200
- /** 0.001 (10e-3) Bitcoin or a thousandth of a Bitcoin. We recommend using the Satoshi unit instead when possible. **/
201
- MILLIBITCOIN = "MILLIBITCOIN"
202
- }
203
- declare const convertCurrencyAmount: (from: CurrencyAmount, toUnit: CurrencyUnit) => CurrencyAmount;
204
-
205
- declare const isBrowser: boolean;
206
- declare const isNode: boolean;
207
-
208
- declare const isError: (e: unknown) => e is Error;
209
- type ErrorWithMessage = {
210
- message: string;
211
- };
212
- declare const isErrorWithMessage: (e: unknown) => e is ErrorWithMessage;
213
- declare const getErrorMsg: (e: unknown) => string;
214
- declare const isErrorMsg: (e: unknown, msg: string) => boolean;
215
-
216
- declare const bytesToHex: (bytes: Uint8Array) => string;
217
- declare const hexToBytes: (hex: string) => Uint8Array;
218
-
219
- type Maybe<T> = T | null | undefined;
220
- type ExpandRecursively<T> = T extends object ? T extends infer O ? {
221
- [K in keyof O]: ExpandRecursively<O[K]>;
222
- } : never : T;
223
- type ById<T> = {
224
- [id: string]: T;
225
- };
226
- type OmitTypename<T> = Omit<T, "__typename">;
227
- declare const isType: <T extends string>(typename: T) => <N extends {
228
- __typename: string;
229
- }>(node: N | null | undefined) => node is Extract<N, {
230
- __typename: T;
231
- }>;
232
-
233
- export { AuthProvider, ById, CryptoInterface, DefaultCrypto, ExpandRecursively, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, Maybe, NodeKeyCache, OmitTypename, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment, b64decode, b64encode, bytesToHex, convertCurrencyAmount, createSha256Hash, getErrorMsg, hexToBytes, isBrowser, isError, isErrorMsg, isErrorWithMessage, isNode, isType, urlsafe_b64decode };
158
+ export { AuthProvider, CryptoInterface, DefaultCrypto, GeneratedKeyPair, KeyOrAlias, KeyOrAliasType, LightsparkAuthException, LightsparkException, LightsparkSigningException, Logger, NodeKeyCache, Query, RSASigningKey, Requester, Secp256k1SigningKey, ServerEnvironment, SigningKey, SigningKeyType, StubAuthProvider, apiDomainForEnvironment };