@unicitylabs/sphere-sdk 0.15.0 → 0.16.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.
- package/README.md +15 -5
- package/dist/connect/index.cjs +14 -23
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.cts +4 -0
- package/dist/connect/index.d.ts +4 -0
- package/dist/connect/index.js +14 -23
- package/dist/connect/index.js.map +1 -1
- package/dist/core/index.cjs +726 -225
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +172 -21
- package/dist/core/index.d.ts +172 -21
- package/dist/core/index.js +726 -224
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs +14 -23
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.js +14 -23
- package/dist/impl/browser/connect/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +331 -504
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +331 -504
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/connect/index.cjs +13 -22
- package/dist/impl/nodejs/connect/index.cjs.map +1 -1
- package/dist/impl/nodejs/connect/index.js +13 -22
- package/dist/impl/nodejs/connect/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +298 -569
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +90 -13
- package/dist/impl/nodejs/index.d.ts +90 -13
- package/dist/impl/nodejs/index.js +298 -569
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/impl/shared/wallet-api/index.d.cts +54 -2
- package/dist/impl/shared/wallet-api/index.d.ts +54 -2
- package/dist/index.cjs +728 -225
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +227 -108
- package/dist/index.d.ts +227 -108
- package/dist/index.js +728 -224
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +11 -7
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.d.cts +56 -3
- package/dist/modules/payments-v2/index.d.ts +56 -3
- package/dist/modules/payments-v2/index.js +11 -7
- package/dist/modules/payments-v2/index.js.map +1 -1
- package/dist/token-engine/index.cjs +46 -0
- package/dist/token-engine/index.cjs.map +1 -1
- package/dist/token-engine/index.js +46 -0
- package/dist/token-engine/index.js.map +1 -1
- 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
|
};
|