@totemsdk/wots-lease 0.1.4 → 0.1.5

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 (2) hide show
  1. package/dist/local.js +2 -1
  2. package/package.json +1 -1
package/dist/local.js CHANGED
@@ -87,13 +87,14 @@ class LocalLeaseProvider {
87
87
  const ttlMs = params.ttlMs ?? 120000;
88
88
  // Atomically get the next available index AND mark it reserved in the watermark
89
89
  const indices = this.watermark.getNextIndices(treeId);
90
- await this.watermark.markUnavailable(treeId, indices, 'reserved');
90
+ // Validate device range BEFORE marking unavailable — prevents permanent index loss
91
91
  if (params.deviceId) {
92
92
  const range = this.getDeviceRange(params.deviceId);
93
93
  if (range && (indices.addressIndex < range.start || indices.addressIndex > range.end)) {
94
94
  throw new errors_js_1.DeviceRangeViolationError(indices.addressIndex, range.start, range.end);
95
95
  }
96
96
  }
97
+ await this.watermark.markUnavailable(treeId, indices, 'reserved');
97
98
  const reservationId = randomId();
98
99
  const expiresAt = Date.now() + ttlMs;
99
100
  const lease = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/wots-lease",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "WOTS key-use coordination — canonical v3 watermark, provider-based lease safety layers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",