@unicitylabs/sphere-sdk 0.14.11-dev.8 → 0.15.0-dev.1

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.
Files changed (46) hide show
  1. package/README.md +55 -17
  2. package/dist/connect/index.cjs +10 -17
  3. package/dist/connect/index.cjs.map +1 -1
  4. package/dist/connect/index.js +10 -17
  5. package/dist/connect/index.js.map +1 -1
  6. package/dist/core/index.cjs +98 -99
  7. package/dist/core/index.cjs.map +1 -1
  8. package/dist/core/index.d.cts +5 -14
  9. package/dist/core/index.d.ts +5 -14
  10. package/dist/core/index.js +98 -99
  11. package/dist/core/index.js.map +1 -1
  12. package/dist/impl/browser/connect/index.cjs +3 -3
  13. package/dist/impl/browser/connect/index.cjs.map +1 -1
  14. package/dist/impl/browser/connect/index.js +3 -3
  15. package/dist/impl/browser/connect/index.js.map +1 -1
  16. package/dist/impl/browser/index.cjs.map +1 -1
  17. package/dist/impl/browser/index.js.map +1 -1
  18. package/dist/impl/nodejs/connect/index.cjs +2 -2
  19. package/dist/impl/nodejs/connect/index.cjs.map +1 -1
  20. package/dist/impl/nodejs/connect/index.js +2 -2
  21. package/dist/impl/nodejs/connect/index.js.map +1 -1
  22. package/dist/impl/nodejs/index.cjs.map +1 -1
  23. package/dist/impl/nodejs/index.js.map +1 -1
  24. package/dist/impl/wallet-api-v2/index.cjs +95 -1
  25. package/dist/impl/wallet-api-v2/index.cjs.map +1 -1
  26. package/dist/impl/wallet-api-v2/index.js +95 -1
  27. package/dist/impl/wallet-api-v2/index.js.map +1 -1
  28. package/dist/index.cjs +98 -99
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +6 -11
  31. package/dist/index.d.ts +6 -11
  32. package/dist/index.js +98 -99
  33. package/dist/index.js.map +1 -1
  34. package/dist/modules/payments-v2/index.cjs +149 -193
  35. package/dist/modules/payments-v2/index.cjs.map +1 -1
  36. package/dist/modules/payments-v2/index.d.cts +8 -5
  37. package/dist/modules/payments-v2/index.d.ts +8 -5
  38. package/dist/modules/payments-v2/index.js +146 -192
  39. package/dist/modules/payments-v2/index.js.map +1 -1
  40. package/dist/token-engine/index.cjs +43 -57
  41. package/dist/token-engine/index.cjs.map +1 -1
  42. package/dist/token-engine/index.d.cts +0 -4
  43. package/dist/token-engine/index.d.ts +0 -4
  44. package/dist/token-engine/index.js +43 -57
  45. package/dist/token-engine/index.js.map +1 -1
  46. package/package.json +2 -2
@@ -689,6 +689,98 @@ var WalletApiV2Client = class {
689
689
  }
690
690
  };
691
691
 
692
+ // core/logger.ts
693
+ var LOGGER_KEY = "__sphere_sdk_logger__";
694
+ function getState() {
695
+ const g = globalThis;
696
+ if (!g[LOGGER_KEY]) {
697
+ g[LOGGER_KEY] = { debug: false, tags: {}, handler: null };
698
+ }
699
+ return g[LOGGER_KEY];
700
+ }
701
+ function isEnabled(tag) {
702
+ const state = getState();
703
+ if (tag in state.tags) return state.tags[tag];
704
+ return state.debug;
705
+ }
706
+ var logger = {
707
+ /**
708
+ * Configure the logger. Can be called multiple times (last write wins).
709
+ * Typically called by createBrowserProviders(), createNodeProviders(), or Sphere.init().
710
+ */
711
+ configure(config) {
712
+ const state = getState();
713
+ if (config.debug !== void 0) state.debug = config.debug;
714
+ if (config.handler !== void 0) state.handler = config.handler;
715
+ },
716
+ /**
717
+ * Enable/disable debug logging for a specific tag.
718
+ * Per-tag setting overrides the global debug flag.
719
+ *
720
+ * @example
721
+ * ```ts
722
+ * logger.setTagDebug('Nostr', true); // enable only Nostr logs
723
+ * logger.setTagDebug('Nostr', false); // disable Nostr logs even if global debug=true
724
+ * ```
725
+ */
726
+ setTagDebug(tag, enabled) {
727
+ getState().tags[tag] = enabled;
728
+ },
729
+ /**
730
+ * Clear per-tag override, falling back to global debug flag.
731
+ */
732
+ clearTagDebug(tag) {
733
+ delete getState().tags[tag];
734
+ },
735
+ /** Returns true if debug mode is enabled for the given tag (or globally). */
736
+ isDebugEnabled(tag) {
737
+ if (tag) return isEnabled(tag);
738
+ return getState().debug;
739
+ },
740
+ /**
741
+ * Debug-level log. Only shown when debug is enabled (globally or for this tag).
742
+ * Use for detailed operational information.
743
+ */
744
+ debug(tag, message, ...args) {
745
+ if (!isEnabled(tag)) return;
746
+ const state = getState();
747
+ if (state.handler) {
748
+ state.handler("debug", tag, message, ...args);
749
+ } else {
750
+ console.log(`[${tag}]`, message, ...args);
751
+ }
752
+ },
753
+ /**
754
+ * Warning-level log. ALWAYS shown regardless of debug flag.
755
+ * Use for important but non-critical issues (timeouts, retries, degraded state).
756
+ */
757
+ warn(tag, message, ...args) {
758
+ const state = getState();
759
+ if (state.handler) {
760
+ state.handler("warn", tag, message, ...args);
761
+ } else {
762
+ console.warn(`[${tag}]`, message, ...args);
763
+ }
764
+ },
765
+ /**
766
+ * Error-level log. ALWAYS shown regardless of debug flag.
767
+ * Use for critical failures that should never be silenced.
768
+ */
769
+ error(tag, message, ...args) {
770
+ const state = getState();
771
+ if (state.handler) {
772
+ state.handler("error", tag, message, ...args);
773
+ } else {
774
+ console.error(`[${tag}]`, message, ...args);
775
+ }
776
+ },
777
+ /** Reset all logger state (debug flag, tags, handler). Primarily for tests. */
778
+ reset() {
779
+ const g = globalThis;
780
+ delete g[LOGGER_KEY];
781
+ }
782
+ };
783
+
692
784
  // modules/payments-v2/stores.ts
693
785
  var STORE_KEYS = {
694
786
  intentBackstop: "intents",
@@ -4250,7 +4342,9 @@ var WalletApiDeliveryPort = class {
4250
4342
  await this.settleClaims(acks, settled, outcomes);
4251
4343
  await this.settleRejects(acks, settled);
4252
4344
  } catch (err) {
4253
- await this.addSeenAll(settled).catch(() => void 0);
4345
+ await this.addSeenAll(settled).catch((seenErr) => {
4346
+ logger.warn("WalletApiDelivery", `seen-set write failed for ${String(settled.length)} committed acks:`, seenErr);
4347
+ });
4254
4348
  throw asRetryable(err);
4255
4349
  }
4256
4350
  await this.addSeenAll(settled);