@unicitylabs/sphere-sdk 0.15.0 → 0.16.0-dev.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.
Files changed (50) hide show
  1. package/README.md +15 -5
  2. package/dist/connect/index.cjs +26 -25
  3. package/dist/connect/index.cjs.map +1 -1
  4. package/dist/connect/index.d.cts +4 -0
  5. package/dist/connect/index.d.ts +4 -0
  6. package/dist/connect/index.js +26 -25
  7. package/dist/connect/index.js.map +1 -1
  8. package/dist/core/index.cjs +728 -227
  9. package/dist/core/index.cjs.map +1 -1
  10. package/dist/core/index.d.cts +174 -23
  11. package/dist/core/index.d.ts +174 -23
  12. package/dist/core/index.js +728 -226
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/impl/browser/connect/index.cjs +16 -25
  15. package/dist/impl/browser/connect/index.cjs.map +1 -1
  16. package/dist/impl/browser/connect/index.js +16 -25
  17. package/dist/impl/browser/connect/index.js.map +1 -1
  18. package/dist/impl/browser/index.cjs +333 -506
  19. package/dist/impl/browser/index.cjs.map +1 -1
  20. package/dist/impl/browser/index.js +333 -506
  21. package/dist/impl/browser/index.js.map +1 -1
  22. package/dist/impl/nodejs/connect/index.cjs +15 -24
  23. package/dist/impl/nodejs/connect/index.cjs.map +1 -1
  24. package/dist/impl/nodejs/connect/index.js +15 -24
  25. package/dist/impl/nodejs/connect/index.js.map +1 -1
  26. package/dist/impl/nodejs/index.cjs +300 -571
  27. package/dist/impl/nodejs/index.cjs.map +1 -1
  28. package/dist/impl/nodejs/index.d.cts +92 -15
  29. package/dist/impl/nodejs/index.d.ts +92 -15
  30. package/dist/impl/nodejs/index.js +300 -571
  31. package/dist/impl/nodejs/index.js.map +1 -1
  32. package/dist/impl/shared/wallet-api/index.d.cts +54 -2
  33. package/dist/impl/shared/wallet-api/index.d.ts +54 -2
  34. package/dist/index.cjs +730 -227
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +229 -110
  37. package/dist/index.d.ts +229 -110
  38. package/dist/index.js +730 -226
  39. package/dist/index.js.map +1 -1
  40. package/dist/modules/payments-v2/index.cjs +11 -7
  41. package/dist/modules/payments-v2/index.cjs.map +1 -1
  42. package/dist/modules/payments-v2/index.d.cts +56 -3
  43. package/dist/modules/payments-v2/index.d.ts +56 -3
  44. package/dist/modules/payments-v2/index.js +11 -7
  45. package/dist/modules/payments-v2/index.js.map +1 -1
  46. package/dist/token-engine/index.cjs +46 -0
  47. package/dist/token-engine/index.cjs.map +1 -1
  48. package/dist/token-engine/index.js +46 -0
  49. package/dist/token-engine/index.js.map +1 -1
  50. package/package.json +1 -1
@@ -1498,12 +1498,58 @@ var SphereTokenEngine = class {
1498
1498
 
1499
1499
  // token-engine/factory.ts
1500
1500
  var DEFAULT_VERIFICATION_POOL_SIZE = 4;
1501
+ function disposedError() {
1502
+ return new SphereError(
1503
+ "Verification worker pool disposed \u2014 the in-flight verification was cancelled",
1504
+ "MODULE_DESTROYED"
1505
+ );
1506
+ }
1501
1507
  var ConfiguredWorkerTokenVerifier = class extends import_WorkerTokenVerifier.WorkerTokenVerifier {
1502
1508
  constructor(spawn, poolSize) {
1503
1509
  super(poolSize);
1504
1510
  this.spawn = spawn;
1505
1511
  }
1512
+ disposed = false;
1513
+ /** One rejector per IN-FLIGHT verify(), dropped on settle; empty when idle. */
1514
+ cancellations = /* @__PURE__ */ new Set();
1515
+ /** Verifications awaiting a verdict — back to 0 whenever the verifier is idle. */
1516
+ get pendingCancellations() {
1517
+ return this.cancellations.size;
1518
+ }
1519
+ /** Rejects (see the class note) if `dispose()` lands before the pool answers. */
1520
+ verify(...args) {
1521
+ if (this.disposed) return Promise.reject(disposedError());
1522
+ const verdict = super.verify(...args);
1523
+ return new Promise((resolve, reject) => {
1524
+ const cancel = () => reject(disposedError());
1525
+ this.cancellations.add(cancel);
1526
+ if (this.disposed) {
1527
+ this.cancellations.delete(cancel);
1528
+ cancel();
1529
+ }
1530
+ void verdict.then(
1531
+ (result) => {
1532
+ this.cancellations.delete(cancel);
1533
+ resolve(result);
1534
+ },
1535
+ (error) => {
1536
+ this.cancellations.delete(cancel);
1537
+ reject(error);
1538
+ }
1539
+ );
1540
+ });
1541
+ }
1542
+ /** Idempotent — Sphere.setOracleApiKey disposes the replaced engine twice (facade + caller). */
1543
+ dispose() {
1544
+ if (this.disposed) return;
1545
+ this.disposed = true;
1546
+ super.dispose();
1547
+ const cancelling = [...this.cancellations];
1548
+ this.cancellations.clear();
1549
+ for (const cancel of cancelling) cancel();
1550
+ }
1506
1551
  createWorker() {
1552
+ if (this.disposed) throw disposedError();
1507
1553
  return this.spawn();
1508
1554
  }
1509
1555
  };