@bsv/wallet-toolbox-client 2.6.2 → 2.6.3
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/out/index.client.cjs +25 -18
- package/out/index.client.cjs.map +1 -1
- package/out/index.client.d.cts +2 -0
- package/out/index.client.d.cts.map +1 -1
- package/out/index.client.d.mts +2 -0
- package/out/index.client.d.mts.map +1 -1
- package/out/index.client.mjs +25 -18
- package/out/index.client.mjs.map +1 -1
- package/package.json +1 -1
package/out/index.client.cjs
CHANGED
|
@@ -32136,15 +32136,11 @@ var WalletPermissionsManager = class WalletPermissionsManager {
|
|
|
32136
32136
|
},
|
|
32137
32137
|
expiry
|
|
32138
32138
|
});
|
|
32139
|
-
|
|
32140
|
-
|
|
32141
|
-
for (const req of [...created, ...renewed]) this.markRecentGrant(req);
|
|
32142
|
-
for (const p of matching.pending) p.resolve(true);
|
|
32139
|
+
await this.persistPermissionGrant(toCreate, toRenew);
|
|
32140
|
+
this.settleActiveGrant(params.requestID, matching, "resolve", true);
|
|
32143
32141
|
} catch (error) {
|
|
32144
|
-
|
|
32142
|
+
this.settleActiveGrant(params.requestID, matching, "reject", error);
|
|
32145
32143
|
throw error;
|
|
32146
|
-
} finally {
|
|
32147
|
-
this.activeRequests.delete(params.requestID);
|
|
32148
32144
|
}
|
|
32149
32145
|
}
|
|
32150
32146
|
/**
|
|
@@ -32169,6 +32165,15 @@ var WalletPermissionsManager = class WalletPermissionsManager {
|
|
|
32169
32165
|
for (const p of matching.pending) p.reject(err);
|
|
32170
32166
|
this.activeRequests.delete(requestID);
|
|
32171
32167
|
}
|
|
32168
|
+
settleActiveGrant(requestID, matching, method, value) {
|
|
32169
|
+
for (const pending of matching.pending) pending[method](value);
|
|
32170
|
+
this.activeRequests.delete(requestID);
|
|
32171
|
+
}
|
|
32172
|
+
async persistPermissionGrant(toCreate, toRenew) {
|
|
32173
|
+
const created = await this.createPermissionTokensBestEffort(toCreate, true);
|
|
32174
|
+
const renewed = await this.renewPermissionTokensBestEffort(toRenew, true);
|
|
32175
|
+
for (const request of [...created, ...renewed]) this.markRecentGrant(request);
|
|
32176
|
+
}
|
|
32172
32177
|
async denyGroupedPermission(requestID) {
|
|
32173
32178
|
this.denyActiveRequest(requestID);
|
|
32174
32179
|
}
|
|
@@ -32226,11 +32231,13 @@ var WalletPermissionsManager = class WalletPermissionsManager {
|
|
|
32226
32231
|
expiry
|
|
32227
32232
|
});
|
|
32228
32233
|
}
|
|
32229
|
-
|
|
32230
|
-
|
|
32231
|
-
|
|
32232
|
-
|
|
32233
|
-
|
|
32234
|
+
try {
|
|
32235
|
+
await this.persistPermissionGrant(toCreate, toRenew);
|
|
32236
|
+
this.settleActiveGrant(params.requestID, matching, "resolve", true);
|
|
32237
|
+
} catch (error) {
|
|
32238
|
+
this.settleActiveGrant(params.requestID, matching, "reject", error);
|
|
32239
|
+
throw error;
|
|
32240
|
+
}
|
|
32234
32241
|
}
|
|
32235
32242
|
async denyCounterpartyPermission(requestID) {
|
|
32236
32243
|
this.denyActiveRequest(requestID);
|
|
@@ -33472,12 +33479,12 @@ var WalletPermissionsManager = class WalletPermissionsManager {
|
|
|
33472
33479
|
await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, async () => await worker()));
|
|
33473
33480
|
return results;
|
|
33474
33481
|
}
|
|
33475
|
-
async runBestEffortBatches(items, chunkSize, runChunk) {
|
|
33482
|
+
async runBestEffortBatches(items, chunkSize, runChunk, strict = false) {
|
|
33476
33483
|
if (items.length === 0) return [];
|
|
33477
33484
|
const out = [];
|
|
33478
33485
|
for (let i = 0; i < items.length; i += chunkSize) {
|
|
33479
33486
|
const chunk = items.slice(i, i + chunkSize);
|
|
33480
|
-
out.push(...await this.runBestEffortChunk(chunk, runChunk));
|
|
33487
|
+
out.push(...strict ? await runChunk(chunk) : await this.runBestEffortChunk(chunk, runChunk));
|
|
33481
33488
|
}
|
|
33482
33489
|
return out;
|
|
33483
33490
|
}
|
|
@@ -33513,7 +33520,7 @@ var WalletPermissionsManager = class WalletPermissionsManager {
|
|
|
33513
33520
|
}
|
|
33514
33521
|
};
|
|
33515
33522
|
}
|
|
33516
|
-
async createPermissionTokensBestEffort(items) {
|
|
33523
|
+
async createPermissionTokensBestEffort(items, strict = false) {
|
|
33517
33524
|
return await this.runBestEffortBatches(items, 25, async (chunk) => {
|
|
33518
33525
|
const built = await this.mapWithConcurrency(chunk, 8, async (c) => await this.buildPermissionOutput(c.request, c.expiry, c.amount));
|
|
33519
33526
|
await this.createAction({
|
|
@@ -33522,9 +33529,9 @@ var WalletPermissionsManager = class WalletPermissionsManager {
|
|
|
33522
33529
|
options: { acceptDelayedBroadcast: true }
|
|
33523
33530
|
}, this.adminOriginator);
|
|
33524
33531
|
return built.map((b) => b.request);
|
|
33525
|
-
});
|
|
33532
|
+
}, strict);
|
|
33526
33533
|
}
|
|
33527
|
-
async renewPermissionTokensBestEffort(items) {
|
|
33534
|
+
async renewPermissionTokensBestEffort(items, strict = false) {
|
|
33528
33535
|
return await this.runBestEffortBatches(items, 15, async (chunk) => {
|
|
33529
33536
|
const built = await this.mapWithConcurrency(chunk, 8, async (c) => await this.buildPermissionOutput(c.request, c.expiry, c.amount));
|
|
33530
33537
|
const inputBeef = new _bsv_sdk.Beef();
|
|
@@ -33558,7 +33565,7 @@ var WalletPermissionsManager = class WalletPermissionsManager {
|
|
|
33558
33565
|
});
|
|
33559
33566
|
if (!txid) throw new Error("Failed to finalize renewal transaction");
|
|
33560
33567
|
return built.map((b) => b.request);
|
|
33561
|
-
});
|
|
33568
|
+
}, strict);
|
|
33562
33569
|
}
|
|
33563
33570
|
async coalescePermissionTokens(oldTokens, newScript, opts) {
|
|
33564
33571
|
if (!oldTokens?.length) throw new Error("No permission tokens to coalesce");
|