@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
@@ -1463,12 +1463,58 @@ var SphereTokenEngine = class {
1463
1463
 
1464
1464
  // token-engine/factory.ts
1465
1465
  var DEFAULT_VERIFICATION_POOL_SIZE = 4;
1466
+ function disposedError() {
1467
+ return new SphereError(
1468
+ "Verification worker pool disposed \u2014 the in-flight verification was cancelled",
1469
+ "MODULE_DESTROYED"
1470
+ );
1471
+ }
1466
1472
  var ConfiguredWorkerTokenVerifier = class extends WorkerTokenVerifier {
1467
1473
  constructor(spawn, poolSize) {
1468
1474
  super(poolSize);
1469
1475
  this.spawn = spawn;
1470
1476
  }
1477
+ disposed = false;
1478
+ /** One rejector per IN-FLIGHT verify(), dropped on settle; empty when idle. */
1479
+ cancellations = /* @__PURE__ */ new Set();
1480
+ /** Verifications awaiting a verdict — back to 0 whenever the verifier is idle. */
1481
+ get pendingCancellations() {
1482
+ return this.cancellations.size;
1483
+ }
1484
+ /** Rejects (see the class note) if `dispose()` lands before the pool answers. */
1485
+ verify(...args) {
1486
+ if (this.disposed) return Promise.reject(disposedError());
1487
+ const verdict = super.verify(...args);
1488
+ return new Promise((resolve, reject) => {
1489
+ const cancel = () => reject(disposedError());
1490
+ this.cancellations.add(cancel);
1491
+ if (this.disposed) {
1492
+ this.cancellations.delete(cancel);
1493
+ cancel();
1494
+ }
1495
+ void verdict.then(
1496
+ (result) => {
1497
+ this.cancellations.delete(cancel);
1498
+ resolve(result);
1499
+ },
1500
+ (error) => {
1501
+ this.cancellations.delete(cancel);
1502
+ reject(error);
1503
+ }
1504
+ );
1505
+ });
1506
+ }
1507
+ /** Idempotent — Sphere.setOracleApiKey disposes the replaced engine twice (facade + caller). */
1508
+ dispose() {
1509
+ if (this.disposed) return;
1510
+ this.disposed = true;
1511
+ super.dispose();
1512
+ const cancelling = [...this.cancellations];
1513
+ this.cancellations.clear();
1514
+ for (const cancel of cancelling) cancel();
1515
+ }
1471
1516
  createWorker() {
1517
+ if (this.disposed) throw disposedError();
1472
1518
  return this.spawn();
1473
1519
  }
1474
1520
  };