@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.
- package/README.md +15 -5
- package/dist/connect/index.cjs +26 -25
- 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 +26 -25
- package/dist/connect/index.js.map +1 -1
- package/dist/core/index.cjs +728 -227
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +174 -23
- package/dist/core/index.d.ts +174 -23
- package/dist/core/index.js +728 -226
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs +16 -25
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.js +16 -25
- package/dist/impl/browser/connect/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +333 -506
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +333 -506
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/connect/index.cjs +15 -24
- package/dist/impl/nodejs/connect/index.cjs.map +1 -1
- package/dist/impl/nodejs/connect/index.js +15 -24
- package/dist/impl/nodejs/connect/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +300 -571
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +92 -15
- package/dist/impl/nodejs/index.d.ts +92 -15
- package/dist/impl/nodejs/index.js +300 -571
- 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 +730 -227
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +229 -110
- package/dist/index.d.ts +229 -110
- package/dist/index.js +730 -226
- 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
|
@@ -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
|
};
|