@totemsdk/wots-lease 0.1.4 → 0.1.6
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 +42 -3
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +37 -1
- package/dist/hybrid.js +27 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +9 -1
- package/dist/local.d.ts +23 -1
- package/dist/local.js +46 -3
- package/dist/onchain.d.ts +52 -0
- package/dist/onchain.js +275 -0
- package/dist/quorum.d.ts +60 -0
- package/dist/quorum.js +264 -0
- package/dist/stubs.d.ts +4 -22
- package/dist/stubs.js +7 -54
- package/dist/types.d.ts +92 -0
- package/package.json +15 -13
- package/rust/pkg/package.json +27 -0
- package/rust/pkg/wots_lease_wasm.d.ts +24 -0
- package/rust/pkg/wots_lease_wasm.js +9 -0
- package/rust/pkg/wots_lease_wasm_bg.js +547 -0
- package/rust/pkg/wots_lease_wasm_bg.wasm +0 -0
- package/rust/pkg/wots_lease_wasm_bg.wasm.d.ts +22 -0
- package/rust/pkg-node/package.json +21 -0
- package/rust/pkg-node/wots_lease_wasm.d.ts +24 -0
- package/rust/pkg-node/wots_lease_wasm.js +563 -0
- package/rust/pkg-node/wots_lease_wasm_bg.wasm +0 -0
- package/rust/pkg-node/wots_lease_wasm_bg.wasm.d.ts +22 -0
package/dist/stubs.js
CHANGED
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
* that has lease coordination enabled ({ lease: { enabled: true } }).
|
|
7
7
|
* The node exposes REST endpoints under /v1/lease/*.
|
|
8
8
|
*
|
|
9
|
-
* Layers 4–5 (P2PQuorumLeaseProvider, OnchainWatermarkProvider) —
|
|
10
|
-
*
|
|
9
|
+
* Layers 4–5 (P2PQuorumLeaseProvider, OnchainWatermarkProvider) — implemented in
|
|
10
|
+
* quorum.ts and onchain.ts; re-exported here for backward compatibility.
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
14
|
-
|
|
13
|
+
exports.PersonalLeaseNodeProvider = exports.OnchainWatermarkProvider = exports.P2PQuorumLeaseProvider = void 0;
|
|
14
|
+
var quorum_js_1 = require("./quorum.js");
|
|
15
|
+
Object.defineProperty(exports, "P2PQuorumLeaseProvider", { enumerable: true, get: function () { return quorum_js_1.P2PQuorumLeaseProvider; } });
|
|
16
|
+
var onchain_js_1 = require("./onchain.js");
|
|
17
|
+
Object.defineProperty(exports, "OnchainWatermarkProvider", { enumerable: true, get: function () { return onchain_js_1.OnchainWatermarkProvider; } });
|
|
15
18
|
/**
|
|
16
19
|
* Layer 3 — personal lookup-node lease coordinator.
|
|
17
20
|
*
|
|
@@ -104,53 +107,3 @@ class PersonalLeaseNodeProvider {
|
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
exports.PersonalLeaseNodeProvider = PersonalLeaseNodeProvider;
|
|
107
|
-
/** Layer 4 — p2p replicated lease witnesses. */
|
|
108
|
-
class P2PQuorumLeaseProvider {
|
|
109
|
-
reserveKeyUse(_params) {
|
|
110
|
-
throw new errors_js_1.P2PQuorumNotImplementedError();
|
|
111
|
-
}
|
|
112
|
-
commitKeyUse(_reservationId, _txId) {
|
|
113
|
-
throw new errors_js_1.P2PQuorumNotImplementedError();
|
|
114
|
-
}
|
|
115
|
-
burnReservation(_reservationId, _reason) {
|
|
116
|
-
throw new errors_js_1.P2PQuorumNotImplementedError();
|
|
117
|
-
}
|
|
118
|
-
getLocalWatermark(_treeId) {
|
|
119
|
-
throw new errors_js_1.P2PQuorumNotImplementedError();
|
|
120
|
-
}
|
|
121
|
-
publishWatermark(_treeId) {
|
|
122
|
-
throw new errors_js_1.P2PQuorumNotImplementedError();
|
|
123
|
-
}
|
|
124
|
-
syncLeaseJournal() {
|
|
125
|
-
throw new errors_js_1.P2PQuorumNotImplementedError();
|
|
126
|
-
}
|
|
127
|
-
verifyLeaseCertificate(_cert) {
|
|
128
|
-
throw new errors_js_1.P2PQuorumNotImplementedError();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.P2PQuorumLeaseProvider = P2PQuorumLeaseProvider;
|
|
132
|
-
/** Layer 5 — on-chain watermark coin. */
|
|
133
|
-
class OnchainWatermarkProvider {
|
|
134
|
-
reserveKeyUse(_params) {
|
|
135
|
-
throw new errors_js_1.OnchainWatermarkNotImplementedError();
|
|
136
|
-
}
|
|
137
|
-
commitKeyUse(_reservationId, _txId) {
|
|
138
|
-
throw new errors_js_1.OnchainWatermarkNotImplementedError();
|
|
139
|
-
}
|
|
140
|
-
burnReservation(_reservationId, _reason) {
|
|
141
|
-
throw new errors_js_1.OnchainWatermarkNotImplementedError();
|
|
142
|
-
}
|
|
143
|
-
getLocalWatermark(_treeId) {
|
|
144
|
-
throw new errors_js_1.OnchainWatermarkNotImplementedError();
|
|
145
|
-
}
|
|
146
|
-
publishWatermark(_treeId) {
|
|
147
|
-
throw new errors_js_1.OnchainWatermarkNotImplementedError();
|
|
148
|
-
}
|
|
149
|
-
syncLeaseJournal() {
|
|
150
|
-
throw new errors_js_1.OnchainWatermarkNotImplementedError();
|
|
151
|
-
}
|
|
152
|
-
verifyLeaseCertificate(_cert) {
|
|
153
|
-
throw new errors_js_1.OnchainWatermarkNotImplementedError();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
exports.OnchainWatermarkProvider = OnchainWatermarkProvider;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @totemsdk/wots-lease — canonical v3 watermark types and WotsLeaseProvider interface
|
|
3
3
|
*/
|
|
4
|
+
import type { LocalLeaseProvider } from './local.js';
|
|
4
5
|
export type UnavailableReason = 'reserved' | 'committed' | 'burned' | 'reserved-expired';
|
|
5
6
|
export interface SigningIndices {
|
|
6
7
|
addressIndex: number;
|
|
@@ -22,6 +23,12 @@ export interface WotsWatermarkState {
|
|
|
22
23
|
version: 3;
|
|
23
24
|
trees: Record<string, TreeWatermark>;
|
|
24
25
|
}
|
|
26
|
+
export interface QuorumAttestation {
|
|
27
|
+
peerId: string;
|
|
28
|
+
indices: SigningIndices;
|
|
29
|
+
expiresAt: number;
|
|
30
|
+
signature?: string;
|
|
31
|
+
}
|
|
25
32
|
export interface LeaseCertificate {
|
|
26
33
|
reservationId: string;
|
|
27
34
|
treeId: string;
|
|
@@ -34,6 +41,10 @@ export interface LeaseCertificate {
|
|
|
34
41
|
issuedAt: number;
|
|
35
42
|
expiresAt: number;
|
|
36
43
|
signature: string;
|
|
44
|
+
/** Layer 4 — quorum attestations collected from P2P peers. */
|
|
45
|
+
attestations?: QuorumAttestation[];
|
|
46
|
+
/** Layer 5 — content hash of the on-chain watermark TX (sha3-256 of TxPoW bytes). */
|
|
47
|
+
txpowid?: string;
|
|
37
48
|
}
|
|
38
49
|
export interface LeaseReservation {
|
|
39
50
|
reservationId: string;
|
|
@@ -105,3 +116,84 @@ export interface PersonalLeaseNodeConfig {
|
|
|
105
116
|
nodePubkey: string;
|
|
106
117
|
authToken?: string;
|
|
107
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Layer 4 — P2P quorum lease coordination.
|
|
121
|
+
*
|
|
122
|
+
* `peers` is the set of quorum members this device coordinates with. Each
|
|
123
|
+
* entry is a transport-agnostic RPC handle: the provider sends the same
|
|
124
|
+
* LEASE_RESERVE / LEASE_COMMIT / LEASE_BURN wire messages used by the
|
|
125
|
+
* lookup protocol, so any peer that speaks that protocol can participate
|
|
126
|
+
* (lookup nodes, other devices, or in-memory test peers).
|
|
127
|
+
*/
|
|
128
|
+
export interface QuorumPeer {
|
|
129
|
+
peerId: string;
|
|
130
|
+
request(message: {
|
|
131
|
+
type: 'LEASE_RESERVE' | 'LEASE_COMMIT' | 'LEASE_BURN' | 'LEASE_WATERMARK';
|
|
132
|
+
payload: Record<string, unknown>;
|
|
133
|
+
}, timeoutMs?: number): Promise<{
|
|
134
|
+
type: string;
|
|
135
|
+
payload: Record<string, unknown>;
|
|
136
|
+
}>;
|
|
137
|
+
}
|
|
138
|
+
export interface P2PQuorumLeaseProviderConfig {
|
|
139
|
+
/** Quorum members to coordinate with (excluding self). */
|
|
140
|
+
peers: QuorumPeer[];
|
|
141
|
+
/** Minimum attestations required for a reservation to be considered quorum-approved. Default: 1. */
|
|
142
|
+
minAttestations?: number;
|
|
143
|
+
/** Local provider used for the authoritative local watermark + journal. */
|
|
144
|
+
local: LocalLeaseProvider;
|
|
145
|
+
/** Timeout per peer request. Default: 5_000. */
|
|
146
|
+
requestTimeoutMs?: number;
|
|
147
|
+
/** Require quorum approval on commit as well as reserve. Default: false. */
|
|
148
|
+
requireQuorumOnCommit?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Layer 5 — on-chain watermark anchoring.
|
|
152
|
+
*
|
|
153
|
+
* `chain` is any ChainStateProvider (hosted, Minima RPC, or lookup node).
|
|
154
|
+
* The provider spends a dedicated watermark coin whose STATE(0) holds the
|
|
155
|
+
* flat watermark cursor; every publish advances it on-chain so the watermark
|
|
156
|
+
* is verifiable by third parties without trusting this device.
|
|
157
|
+
*/
|
|
158
|
+
export interface OnchainWatermarkProviderConfig {
|
|
159
|
+
/** Chain access for coin queries, proofs, and broadcasting. */
|
|
160
|
+
chain: {
|
|
161
|
+
getCoin(coinId: string): Promise<{
|
|
162
|
+
coinid: string;
|
|
163
|
+
address: string;
|
|
164
|
+
amount: string;
|
|
165
|
+
tokenid: string;
|
|
166
|
+
state?: unknown[];
|
|
167
|
+
} | null>;
|
|
168
|
+
getProof(coinId: string): Promise<{
|
|
169
|
+
data: unknown;
|
|
170
|
+
}>;
|
|
171
|
+
broadcastTxPoW(txpowHex: string): Promise<{
|
|
172
|
+
success: boolean;
|
|
173
|
+
txpowid?: string;
|
|
174
|
+
message?: string;
|
|
175
|
+
}>;
|
|
176
|
+
getTip?(): Promise<{
|
|
177
|
+
block: number;
|
|
178
|
+
}>;
|
|
179
|
+
};
|
|
180
|
+
/** Coin ID of the dedicated watermark coin. */
|
|
181
|
+
watermarkCoinId: string;
|
|
182
|
+
/** Address the watermark coin currently sits at (spending address). */
|
|
183
|
+
watermarkAddress: string;
|
|
184
|
+
/** Token ID of the watermark coin. Default: '0x00'. */
|
|
185
|
+
tokenId?: string;
|
|
186
|
+
/** Amount of the watermark coin in MIN base units. Default: '1'. */
|
|
187
|
+
amount?: string;
|
|
188
|
+
/** Local provider used for the authoritative local watermark + journal. */
|
|
189
|
+
local: LocalLeaseProvider;
|
|
190
|
+
/** Signer for the watermark coin's script (SIGNEDBY digest). */
|
|
191
|
+
signer: {
|
|
192
|
+
publicKeyDigest: string;
|
|
193
|
+
sign(message: Uint8Array): Promise<Uint8Array>;
|
|
194
|
+
};
|
|
195
|
+
/** Port holding the flat watermark cursor in the coin state. Default: 0. */
|
|
196
|
+
statePort?: number;
|
|
197
|
+
/** Minimum blocks between on-chain publishes (rate limit). Default: 1. */
|
|
198
|
+
minBlocksBetweenPublishes?: number;
|
|
199
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/wots-lease",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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",
|
|
@@ -11,20 +11,17 @@
|
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"prepare": "tsc",
|
|
17
|
-
"clean": "rm -rf dist",
|
|
18
|
-
"test": "jest --passWithNoTests"
|
|
19
|
-
},
|
|
20
14
|
"files": [
|
|
21
15
|
"dist",
|
|
16
|
+
"rust/pkg/",
|
|
17
|
+
"rust/pkg-node/",
|
|
22
18
|
"README.md",
|
|
23
19
|
"LICENSE"
|
|
24
20
|
],
|
|
25
21
|
"dependencies": {
|
|
26
|
-
"@totemsdk/
|
|
27
|
-
"@totemsdk/
|
|
22
|
+
"@totemsdk/lookup-protocol": "^0.1.6",
|
|
23
|
+
"@totemsdk/core": "^1.2.8",
|
|
24
|
+
"@totemsdk/txpow": "^0.1.7"
|
|
28
25
|
},
|
|
29
26
|
"devDependencies": {
|
|
30
27
|
"@types/jest": "^30.0.0",
|
|
@@ -48,7 +45,7 @@
|
|
|
48
45
|
"repository": {
|
|
49
46
|
"type": "git",
|
|
50
47
|
"url": "git+https://github.com/totem-sdk/totem-sdk.git",
|
|
51
|
-
"directory": "packages/
|
|
48
|
+
"directory": "packages/wots-lease"
|
|
52
49
|
},
|
|
53
50
|
"keywords": [
|
|
54
51
|
"totem",
|
|
@@ -57,7 +54,12 @@
|
|
|
57
54
|
"blockchain",
|
|
58
55
|
"quantum-resistant",
|
|
59
56
|
"wots",
|
|
60
|
-
"kissvm",
|
|
61
57
|
"utxo"
|
|
62
|
-
]
|
|
63
|
-
|
|
58
|
+
],
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "npm run build:wasm && tsc && node ../../scripts/clean-wasm-output-ignores.mjs",
|
|
61
|
+
"build:wasm": "cd rust && wasm-pack build --target bundler --out-dir pkg && wasm-pack build --target nodejs --out-dir pkg-node",
|
|
62
|
+
"clean": "rm -rf dist rust/pkg rust/pkg-node rust/target",
|
|
63
|
+
"test": "jest"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wots-lease-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Totem SDK Contributors"
|
|
6
|
+
],
|
|
7
|
+
"description": "WOTS key-use coordination — canonical v3 watermark, flat index computation, monotonicity enforcement, device keyspace partitioning (Rust/WASM)",
|
|
8
|
+
"version": "0.1.0",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/totem-sdk/totem-sdk"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"wots_lease_wasm_bg.wasm",
|
|
16
|
+
"wots_lease_wasm.js",
|
|
17
|
+
"wots_lease_wasm_bg.js",
|
|
18
|
+
"wots_lease_wasm.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"main": "wots_lease_wasm.js",
|
|
21
|
+
"homepage": "https://totem.ing",
|
|
22
|
+
"types": "wots_lease_wasm.d.ts",
|
|
23
|
+
"sideEffects": [
|
|
24
|
+
"./wots_lease_wasm.js",
|
|
25
|
+
"./snippets/*"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export function allocate_device_range_wasm(device_slot: number, device_id: string): any;
|
|
5
|
+
|
|
6
|
+
export function device_slot_for_address_index_wasm(address_index: number): number;
|
|
7
|
+
|
|
8
|
+
export function flat_index_wasm(address_index: number, l1: number, l2: number): number;
|
|
9
|
+
|
|
10
|
+
export function from_flat_index_wasm(flat: number): any;
|
|
11
|
+
|
|
12
|
+
export function get_capacity_per_tree_wasm(): number;
|
|
13
|
+
|
|
14
|
+
export function get_local_watermark_wasm(state_js: any, tree_id: string): any;
|
|
15
|
+
|
|
16
|
+
export function get_next_indices_wasm(state_js: any, tree_id: string): any;
|
|
17
|
+
|
|
18
|
+
export function init(): void;
|
|
19
|
+
|
|
20
|
+
export function is_unavailable_wasm(state_js: any, tree_id: string, indices_js: any): boolean;
|
|
21
|
+
|
|
22
|
+
export function mark_unavailable_wasm(state_js: any, tree_id: string, indices_js: any, reason: string): any;
|
|
23
|
+
|
|
24
|
+
export function new_watermark_state_wasm(): any;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./wots_lease_wasm.d.ts" */
|
|
2
|
+
import * as wasm from "./wots_lease_wasm_bg.wasm";
|
|
3
|
+
import { __wbg_set_wasm } from "./wots_lease_wasm_bg.js";
|
|
4
|
+
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
allocate_device_range_wasm, device_slot_for_address_index_wasm, flat_index_wasm, from_flat_index_wasm, get_capacity_per_tree_wasm, get_local_watermark_wasm, get_next_indices_wasm, init, is_unavailable_wasm, mark_unavailable_wasm, new_watermark_state_wasm
|
|
9
|
+
} from "./wots_lease_wasm_bg.js";
|