@vibecook/truffle-native 0.1.1 → 0.3.22

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/helpers.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Resolve the sidecar binary path for the current platform.
3
+ * @returns Absolute path to the sidecar binary.
4
+ * @throws If the binary cannot be found.
5
+ */
6
+ export declare function resolveSidecarPath(): string;
7
+
8
+ /**
9
+ * Open a URL in the system's default browser.
10
+ * Works cross-platform (macOS, Linux, Windows).
11
+ */
12
+ export declare function openUrl(url: string): void;
package/helpers.js ADDED
@@ -0,0 +1,79 @@
1
+ const { execSync } = require('node:child_process');
2
+ const path = require('node:path');
3
+ const fs = require('node:fs');
4
+
5
+ /**
6
+ * Resolve the sidecar binary path for the current platform.
7
+ *
8
+ * Resolution order:
9
+ * 1. Platform-specific npm package (@vibecook/truffle-sidecar-{platform}-{arch})
10
+ * 2. Local workspace bin directories (for development)
11
+ *
12
+ * @returns {string} Absolute path to the sidecar binary.
13
+ * @throws {Error} If the binary cannot be found.
14
+ */
15
+ function resolveSidecarPath() {
16
+ const key = `${process.platform}-${process.arch}`;
17
+ const ext = process.platform === 'win32' ? '.exe' : '';
18
+ const binName = `sidecar-slim${ext}`;
19
+
20
+ // 1. Try platform-specific npm package
21
+ const platformPackages = {
22
+ 'darwin-arm64': '@vibecook/truffle-sidecar-darwin-arm64',
23
+ 'darwin-x64': '@vibecook/truffle-sidecar-darwin-x64',
24
+ 'linux-x64': '@vibecook/truffle-sidecar-linux-x64',
25
+ 'linux-arm64': '@vibecook/truffle-sidecar-linux-arm64',
26
+ 'win32-x64': '@vibecook/truffle-sidecar-win32-x64',
27
+ };
28
+ const pkg = platformPackages[key];
29
+ if (pkg) {
30
+ try {
31
+ const pkgJsonPath = require.resolve(`${pkg}/package.json`);
32
+ const binPath = path.join(path.dirname(pkgJsonPath), 'bin', binName);
33
+ if (fs.existsSync(binPath)) return binPath;
34
+ } catch {}
35
+ }
36
+
37
+ // 2. Try workspace locations (local dev)
38
+ // Walk up from this file's directory looking for packages/core/bin or packages/sidecar-slim/bin
39
+ let dir = __dirname;
40
+ for (let i = 0; i < 5; i++) {
41
+ const coreBin = path.join(dir, 'packages', 'core', 'bin', binName);
42
+ if (fs.existsSync(coreBin)) return coreBin;
43
+ const slimBin = path.join(dir, 'packages', 'sidecar-slim', 'bin', binName);
44
+ if (fs.existsSync(slimBin)) return slimBin;
45
+ const parent = path.dirname(dir);
46
+ if (parent === dir) break;
47
+ dir = parent;
48
+ }
49
+
50
+ const supported = Object.keys(platformPackages).join(', ');
51
+ throw new Error(
52
+ `Truffle sidecar binary not found for ${key}. ` +
53
+ `Supported platforms: ${supported}. ` +
54
+ `Install the platform package: npm install ${platformPackages[key] || '@vibecook/truffle-sidecar-<platform>'}`
55
+ );
56
+ }
57
+
58
+ /**
59
+ * Open a URL in the system's default browser.
60
+ * Works cross-platform (macOS, Linux, Windows).
61
+ *
62
+ * @param {string} url - The URL to open.
63
+ */
64
+ function openUrl(url) {
65
+ const platform = process.platform;
66
+ try {
67
+ if (platform === 'darwin') {
68
+ execSync(`open "${url}"`);
69
+ } else if (platform === 'win32') {
70
+ execSync(`start "" "${url}"`);
71
+ } else {
72
+ execSync(`xdg-open "${url}"`);
73
+ }
74
+ } catch {
75
+ // Silently fail — caller can handle errors via the auth event
76
+ }
77
+ }
78
+
79
+ module.exports = { resolveSidecarPath, openUrl };
package/index.d.ts CHANGED
@@ -1,312 +1,366 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
3
  /**
4
- * NapiFileTransferAdapter - Node.js wrapper for file transfer signaling.
4
+ * File transfer handle exposed to JavaScript.
5
5
  *
6
- * Handles file transfer offer/accept/reject/cancel via the mesh message bus.
7
- * Progress events use the broadcast channel (drops allowed for lag recovery).
6
+ * Obtained via `NapiNode.fileTransfer()`. Holds an `Arc<Node>` to create
7
+ * fresh `FileTransfer` handles on each method call (the Rust `FileTransfer`
8
+ * borrows `&Node`, so we can't store it across JS boundaries).
8
9
  */
9
- export declare class NapiFileTransferAdapter {
10
+ export declare class NapiFileTransfer {
10
11
  /**
11
- * Create a new FileTransferAdapter.
12
+ * Send a file to a peer.
12
13
  *
13
- * Sets up the underlying FileTransferManager and adapter with default TCP dial.
14
+ * Resolves with transfer result on success.
14
15
  */
15
- constructor(config: NapiFileTransferAdapterConfig)
16
+ sendFile(peerId: string, localPath: string, remotePath: string): Promise<NapiTransferResult>
16
17
  /**
17
- * Initiate sending a file to a target device.
18
- * Returns the transfer ID.
19
- */
20
- sendFile(targetDeviceId: string, filePath: string): Promise<string>
21
- /** Accept an incoming file transfer offer. */
22
- acceptTransfer(offer: NapiFileTransferOffer, savePath?: string | undefined | null): Promise<void>
23
- /** Reject an incoming file transfer offer. */
24
- rejectTransfer(offer: NapiFileTransferOffer, reason: string): Promise<void>
25
- /** Cancel an active transfer. */
26
- cancelTransfer(transferId: string): Promise<void>
27
- /** Get all tracked transfers. */
28
- getTransfers(): Promise<Array<NapiAdapterTransferInfo>>
29
- /**
30
- * Handle an incoming message from the mesh bus.
31
- * Call this when a file-transfer namespace message arrives.
32
- */
33
- handleBusMessage(msgType: string, payload: any): Promise<void>
34
- /**
35
- * Subscribe to adapter events (offers, progress, completed, failed, cancelled).
18
+ * Pull (download) a file from a remote peer.
36
19
  *
37
- * Only one subscriber allowed. Progress events may be dropped if the JS
38
- * handler is slow (broadcast channel). Critical events are never dropped.
20
+ * Resolves with transfer result on success.
39
21
  */
40
- onEvent(callback: (err: null | Error, event: NapiFileTransferEvent) => void): void
22
+ pullFile(peerId: string, remotePath: string, localPath: string): Promise<NapiTransferResult>
23
+ /** Auto-accept all incoming file offers, saving files to `output_dir`. */
24
+ autoAccept(outputDir: string): Promise<void>
25
+ /** Auto-reject all incoming file offers. */
26
+ autoReject(): Promise<void>
41
27
  /**
42
- * Subscribe to outgoing bus messages.
28
+ * Subscribe to incoming file offers with a callback.
29
+ *
30
+ * The callback receives a `NapiFileOffer`. Use `autoAccept()` or
31
+ * `autoReject()` for automated handling, or use `onOffer()` for
32
+ * manual inspection of offers.
33
+ * Subscribe to incoming file offers with a callback.
43
34
  *
44
- * The adapter generates outgoing messages (OFFER, ACCEPT, REJECT, CANCEL)
45
- * that must be sent via the mesh message bus. This callback delivers them
46
- * so the JS layer can relay them.
35
+ * The callback receives `(offer, responder)` call `responder.accept(path)`
36
+ * or `responder.reject(reason)` to handle the offer. If neither is called
37
+ * within 60 seconds, the offer is auto-rejected.
47
38
  */
48
- onBusMessage(callback: (err: null | Error, message: NapiBusMessage) => void): void
39
+ onOffer(callback: (offer: FileOffer, responder: NapiOfferResponder) => void): void
49
40
  /**
50
- * Start forwarding manager events to the adapter.
41
+ * Subscribe to file transfer events.
51
42
  *
52
- * The FileTransferManager emits events (progress, complete, error) that
53
- * the adapter needs to process. Call this once after construction.
43
+ * The callback receives `NapiFileTransferEvent` objects for all
44
+ * transfer lifecycle events (hashing, progress, completed, failed, etc.).
54
45
  */
55
- startManagerEvents(): void
46
+ onEvent(callback: (event: FileTransferEvent) => void): void
47
+ /** Set the maximum allowed transfer size in bytes. */
48
+ setMaxTransferSize(bytes: number): void
56
49
  }
57
50
 
58
51
  /**
59
- * NapiMeshNode - Node.js wrapper for truffle-core MeshNode.
52
+ * The main truffle node exposed to JavaScript.
60
53
  *
61
- * SAFETY: No panics in any method. All errors returned via napi::Result.
62
- * Event delivery uses ThreadsafeFunction with Blocking mode.
54
+ * Lifecycle:
55
+ * 1. `new NapiNode()` creates an empty wrapper.
56
+ * 2. `await node.start(config)` — builds and starts the underlying `Node<TailscaleProvider>`.
57
+ * 3. Use `getPeers()`, `send()`, `onPeerChange()`, etc.
58
+ * 4. `await node.stop()` — shuts down the node.
63
59
  */
64
- export declare class NapiMeshNode {
60
+ export declare class NapiNode {
61
+ /** Create a new (unstarted) NapiNode. */
62
+ constructor()
65
63
  /**
66
- * Create a new MeshNode.
64
+ * Start the node with the given configuration.
67
65
  *
68
- * The `config` parameter matches the TypeScript `MeshNodeConfig` interface.
66
+ * Resolves when the Tailscale sidecar is connected and the node is ready.
67
+ *
68
+ * # Safety
69
+ * This takes `&mut self` in an async context. The caller must ensure that
70
+ * no other calls are made on this NapiNode while `start()` is in progress.
71
+ */
72
+ start(config: NapiNodeConfig): Promise<void>
73
+ /**
74
+ * Stop the node and release all resources.
75
+ *
76
+ * # Safety
77
+ * This takes `&mut self` in an async context. The caller must ensure that
78
+ * no other calls are made on this NapiNode while `stop()` is in progress.
69
79
  */
70
- constructor(config: NapiMeshNodeConfig)
71
- /** Start the mesh node. */
72
- start(): Promise<void>
73
- /** Stop the mesh node. */
74
80
  stop(): Promise<void>
75
- /** Check if the node is running. */
76
- isRunning(): Promise<boolean>
77
- /** Get the local device info. */
78
- localDevice(): Promise<NapiBaseDevice>
79
- /** Get the local device ID. */
80
- deviceId(): Promise<string>
81
- /** Get all known devices. */
82
- devices(): Promise<Array<NapiBaseDevice>>
83
- /** Get a device by ID. */
84
- deviceById(id: string): Promise<NapiBaseDevice | null>
85
- /** Check if this node is the primary. */
86
- isPrimary(): Promise<boolean>
87
- /** Get the current primary device ID. */
88
- primaryId(): Promise<string | null>
89
- /** Get the current role as a string ("primary" or "secondary"). */
90
- role(): Promise<string>
81
+ /** Get the local node's identity. */
82
+ getLocalInfo(): NapiNodeIdentity
83
+ /** Get all known peers. */
84
+ getPeers(): Promise<Array<NapiPeer>>
85
+ /** Resolve a peer identifier (name or ID) to the canonical node ID. */
86
+ resolvePeerId(peerId: string): Promise<string>
87
+ /** Ping a peer and return latency info. */
88
+ ping(peerId: string): Promise<NapiPingResult>
89
+ /** Get health information from the network layer. */
90
+ health(): Promise<NapiHealthInfo>
91
+ /** Send a namespaced message to a specific peer. */
92
+ send(peerId: string, namespace: string, data: Buffer): Promise<void>
93
+ /** Broadcast a namespaced message to all connected peers. */
94
+ broadcast(namespace: string, data: Buffer): Promise<void>
91
95
  /**
92
- * Send a mesh envelope to a specific device.
93
- * Returns true if the message was sent successfully.
96
+ * Subscribe to peer change events.
97
+ *
98
+ * The callback receives `NapiPeerEvent` objects whenever peers
99
+ * join, leave, connect, disconnect, or update.
94
100
  */
95
- sendEnvelope(deviceId: string, namespace: string, msgType: string, payload: any): Promise<boolean>
96
- /** Broadcast a mesh envelope to all connected devices. */
97
- broadcastEnvelope(namespace: string, msgType: string, payload: any): Promise<void>
98
- /** Get the message bus for namespace-based pub/sub. */
99
- messageBus(): NapiMessageBus
100
- /** Handle tailnet peers update from the sidecar. */
101
- handleTailnetPeers(peers: Array<NapiTailnetPeer>): Promise<void>
102
- /** Set the local device as online with its Tailscale IP. */
103
- setLocalOnline(tailscaleIp: string, dnsName?: string | undefined | null): Promise<void>
101
+ onPeerChange(callback: (event: PeerEvent) => void): void
104
102
  /**
105
- * Subscribe to mesh events.
103
+ * Subscribe to messages on a specific namespace.
106
104
  *
107
- * Uses ThreadsafeFunction with Blocking mode per RFC 003:
108
- * - Critical events (device join/leave, election, errors) are never dropped
109
- * - If the JS event queue is full, Rust waits rather than dropping events
105
+ * The callback receives `NapiNamespacedMessage` objects.
106
+ */
107
+ onMessage(namespace: string, callback: (msg: NamespacedMessage) => void): void
108
+ /** Get a `NapiFileTransfer` handle for file transfer operations. */
109
+ fileTransfer(): NapiFileTransfer
110
+ /**
111
+ * Get a `NapiSyncedStore` handle for synchronized state operations.
110
112
  *
111
- * The callback receives NapiMeshEvent objects with event_type, device_id, and payload.
113
+ * Each call creates a new store instance with the given `store_id`.
114
+ * Multiple stores can coexist with different IDs.
112
115
  */
113
- onEvent(callback: (err: null | Error, event: NapiMeshEvent) => void): void
116
+ syncedStore(storeId: string): NapiSyncedStore
114
117
  }
115
118
 
116
119
  /**
117
- * NapiMessageBus - Node.js wrapper for MeshMessageBus.
120
+ * Responder for accepting or rejecting a file offer from JS.
118
121
  *
119
- * Provides namespace-based pub/sub for application-level messages.
122
+ * The responder is consumed on the first call to `accept()` or `reject()`.
123
+ * If neither is called, the offer times out after 60 seconds.
120
124
  */
121
- export declare class NapiMessageBus {
122
- /** Get all subscribed namespaces. */
123
- subscribedNamespaces(): Promise<Array<string>>
124
- /** Dispose the message bus, clearing all handlers. */
125
- dispose(): Promise<void>
125
+ export declare class NapiOfferResponder {
126
+ /** Accept the file offer, saving to the specified path. */
127
+ accept(savePath: string): Promise<void>
128
+ /** Reject the file offer with a reason. */
129
+ reject(reason: string): Promise<void>
126
130
  }
127
131
 
128
132
  /**
129
- * NapiStoreSyncAdapter - Node.js wrapper for cross-device state sync.
133
+ * Synchronized store handle exposed to JavaScript.
130
134
  *
131
- * In the JS layer, stores are registered via the SyncableStore trait.
132
- * For NAPI, we expose the adapter's lifecycle and message handling.
135
+ * Obtained via `NapiNode.syncedStore(storeId)`. Each store instance manages
136
+ * device-owned slices of JSON data that are automatically synchronized
137
+ * across the mesh.
133
138
  */
134
- export declare class NapiStoreSyncAdapter {
139
+ export declare class NapiSyncedStore {
140
+ /** Update this device's data in the store. */
141
+ set(data: any): Promise<void>
142
+ /** Get this device's current data, or `null` if `set()` hasn't been called. */
143
+ local(): Promise<any | null>
144
+ /** Get a specific peer's slice by device ID. */
145
+ get(deviceId: string): Promise<NapiSlice | null>
146
+ /** Get all slices (local + remote) as an array. */
147
+ all(): Promise<Array<NapiSlice>>
148
+ /** Get all device IDs that have data in this store. */
149
+ deviceIds(): Promise<Array<string>>
150
+ /** The store identifier. */
151
+ storeId(): string
152
+ /** Current local version number. */
153
+ version(): number
135
154
  /**
136
- * Create a new StoreSyncAdapter.
155
+ * Subscribe to store change events.
137
156
  *
138
- * Note: In the NAPI layer, stores must be registered separately.
139
- * This constructor creates the adapter with an empty store list.
157
+ * The callback receives `NapiStoreEvent` objects whenever local data
158
+ * changes, a peer's data is updated, or a peer is removed.
140
159
  */
141
- constructor(config: NapiStoreSyncConfig)
142
- /** Start syncing. */
143
- start(): Promise<void>
144
- /** Stop syncing. */
145
- stop(): Promise<void>
146
- /** Dispose the adapter. */
147
- dispose(): Promise<void>
148
- /** Handle an incoming sync message from a remote device. */
149
- handleSyncMessage(from: string | undefined | null, msgType: string, payload: any): Promise<void>
150
- /** Handle a device going offline. */
151
- handleDeviceOffline(deviceId: string): Promise<void>
152
- /** Handle a new device being discovered. */
153
- handleDeviceDiscovered(deviceId: string): Promise<void>
154
- /** Notify that a local store changed (triggers sync broadcast). */
155
- handleLocalChanged(storeId: string, slice: NapiDeviceSlice): Promise<void>
160
+ onChange(callback: (event: StoreEvent) => void): void
156
161
  /**
157
- * Subscribe to outgoing sync messages.
162
+ * Stop the store and cancel all event-forwarding tasks.
158
163
  *
159
- * The callback receives messages that should be broadcast to all devices
160
- * via the mesh message bus.
164
+ * # Safety
165
+ * This takes `&mut self` in an async context. The caller must ensure that
166
+ * no other calls are made on this NapiSyncedStore while `stop()` is in progress.
161
167
  */
162
- onOutgoing(callback: (err: null | Error, message: NapiOutgoingSyncMessage) => void): void
168
+ stop(): Promise<void>
163
169
  }
164
170
 
165
- /** Transfer info returned to JS. */
166
- export interface NapiAdapterTransferInfo {
167
- transferId: string
168
- direction: string
169
- state: string
170
- peerDeviceId: string
171
+ /** An incoming file offer from a remote peer. */
172
+ export interface NapiFileOffer {
173
+ /** Stable node ID of the sending peer. */
174
+ fromPeer: string
175
+ /** Human-readable name of the sending peer. */
176
+ fromName: string
177
+ /** File name being offered. */
171
178
  fileName: string
172
- fileSize: number
173
- bytesTransferred: number
174
- percent: number
175
- bytesPerSecond: number
176
- eta: number
177
- }
178
-
179
- /** A device in the mesh network (JS representation). */
180
- export interface NapiBaseDevice {
181
- id: string
182
- deviceType: string
183
- name: string
184
- tailscaleHostname: string
185
- tailscaleDnsName?: string
186
- tailscaleIp?: string
187
- role?: string
188
- status: string
189
- capabilities: Array<string>
190
- metadata?: any
191
- lastSeen?: number
192
- startedAt?: number
193
- os?: string
194
- latencyMs?: number
179
+ /** File size in bytes. */
180
+ size: number
181
+ /** Expected SHA-256 hash (hex). */
182
+ sha256: string
183
+ /** Suggested save path from the sender. */
184
+ suggestedPath: string
185
+ /** Unique token for this transfer. */
186
+ token: string
195
187
  }
196
188
 
197
- /** Outgoing bus message (sent from adapter to be relayed via mesh). */
198
- export interface NapiBusMessage {
199
- targetDeviceId: string
200
- messageType: string
201
- payload: string
189
+ /** Events emitted by the file transfer subsystem. */
190
+ export interface NapiFileTransferEvent {
191
+ /**
192
+ * Event type: "offer_received", "hashing", "waiting_for_accept",
193
+ * "progress", "completed", "rejected", "failed".
194
+ */
195
+ eventType: string
196
+ /** Transfer token (if applicable). */
197
+ token?: string
198
+ /** File name (if applicable). */
199
+ fileName?: string
200
+ /** Direction: "send" or "receive" (if applicable). */
201
+ direction?: string
202
+ /** Progress info (present for "progress" events). */
203
+ progress?: NapiTransferProgress
204
+ /** Offer info (present for "offer_received" events). */
205
+ offer?: NapiFileOffer
206
+ /** Bytes transferred (present for "completed" events). */
207
+ bytesTransferred?: number
208
+ /** SHA-256 hash (present for "completed" events). */
209
+ sha256?: string
210
+ /** Elapsed seconds (present for "completed" events). */
211
+ elapsedSecs?: number
212
+ /** Reason for rejection or failure. */
213
+ reason?: string
214
+ /** Bytes hashed so far (present for "hashing" events). */
215
+ bytesHashed?: number
216
+ /** Total bytes to hash (present for "hashing" events). */
217
+ totalBytes?: number
202
218
  }
203
219
 
204
- /** Device slice (JS representation). */
205
- export interface NapiDeviceSlice {
206
- deviceId: string
207
- data: any
208
- updatedAt: number
209
- version: number
220
+ /** Health information from the network layer. */
221
+ export interface NapiHealthInfo {
222
+ /** Current backend state (e.g., "Running", "NeedsLogin"). */
223
+ state: string
224
+ /** Key expiry timestamp (RFC 3339), if applicable. */
225
+ keyExpiry?: string
226
+ /** Active health warnings. */
227
+ warnings: Array<string>
228
+ /** Whether the network is fully operational. */
229
+ healthy: boolean
210
230
  }
211
231
 
212
- /** File transfer adapter configuration (JS representation). */
213
- export interface NapiFileTransferAdapterConfig {
214
- /** Local device ID. */
215
- deviceId: string
216
- /** Local address for file transfers (e.g. "host.ts.net:9417"). */
217
- localAddr: string
218
- /** Default output directory for received files. */
219
- outputDir: string
220
- /** Maximum file size in bytes. */
221
- maxFileSize?: number
222
- /** Max concurrent incoming transfers. */
223
- maxConcurrentRecv?: number
224
- /** Progress event interval in milliseconds. */
225
- progressIntervalMs?: number
226
- /** Progress event byte threshold. */
227
- progressBytes?: number
232
+ /** A message received on a specific namespace. */
233
+ export interface NapiNamespacedMessage {
234
+ /** Stable node ID of the sender. */
235
+ from: string
236
+ /** Namespace the message was sent on. */
237
+ namespace: string
238
+ /** Application-defined message type. */
239
+ msgType: string
240
+ /** Opaque JSON payload (as a JS value via serde). */
241
+ payload: any
242
+ /** Millisecond Unix timestamp from the sender, if set. */
243
+ timestamp?: number
228
244
  }
229
245
 
230
- /** File transfer event delivered to JS. */
231
- export interface NapiFileTransferEvent {
232
- eventType: string
233
- transferId?: string
234
- payload: any
246
+ /** Configuration for starting a Node. */
247
+ export interface NapiNodeConfig {
248
+ /** Human-readable node name (used as Tailscale hostname). */
249
+ name: string
250
+ /** Path to the Go sidecar binary. */
251
+ sidecarPath: string
252
+ /** Tailscale state directory. Defaults to `/tmp/truffle-{name}`. */
253
+ stateDir?: string
254
+ /** Tailscale auth key for headless authentication. */
255
+ authKey?: string
256
+ /** Whether the node is ephemeral (auto-removed from tailnet on shutdown). */
257
+ ephemeral?: boolean
258
+ /** WebSocket listen port. Defaults to 9417. */
259
+ wsPort?: number
235
260
  }
236
261
 
237
- /** File transfer offer (JS representation, for accept/reject). */
238
- export interface NapiFileTransferOffer {
239
- transferId: string
240
- senderDeviceId: string
241
- senderAddr: string
242
- fileName: string
243
- fileSize: number
244
- fileSha256: string
245
- token: string
262
+ /** Identity of the local node. */
263
+ export interface NapiNodeIdentity {
264
+ /** Stable node ID. */
265
+ id: string
266
+ /** Hostname on the network. */
267
+ hostname: string
268
+ /** Human-readable display name. */
269
+ name: string
270
+ /** DNS name on the tailnet, if available. */
271
+ dnsName?: string
272
+ /** Tailscale IP address as a string, if available. */
273
+ ip?: string
246
274
  }
247
275
 
248
- /** An incoming mesh message from a peer (JS representation). */
249
- export interface NapiIncomingMessage {
250
- from?: string
251
- connectionId: string
252
- namespace: string
253
- msgType: string
254
- payload: any
276
+ /** A peer as seen by application code. */
277
+ export interface NapiPeer {
278
+ /** Stable node ID. */
279
+ id: string
280
+ /** Human-readable name (hostname). */
281
+ name: string
282
+ /** Network IP address as a string. */
283
+ ip: string
284
+ /** Whether the peer is online (from Layer 3). */
285
+ online: boolean
286
+ /** Whether there is an active WebSocket connection. */
287
+ wsConnected: boolean
288
+ /** Connection type description (e.g., "direct" or "relay:ord"). */
289
+ connectionType: string
290
+ /** Operating system, if known. */
291
+ os?: string
292
+ /** Last time the peer was seen online (RFC 3339 string). */
293
+ lastSeen?: string
255
294
  }
256
295
 
257
- /** A mesh event delivered to JS via ThreadsafeFunction. */
258
- export interface NapiMeshEvent {
296
+ /** A peer change event delivered to JS. */
297
+ export interface NapiPeerEvent {
298
+ /** Event type: "joined", "left", "updated", "ws_connected", "ws_disconnected", "auth_required". */
259
299
  eventType: string
260
- deviceId?: string
261
- payload: any
300
+ /** Peer ID (present for peer events, empty for auth_required). */
301
+ peerId: string
302
+ /** Full peer info (present for joined/updated events). */
303
+ peer?: NapiPeer
304
+ /** Auth URL (present only for auth_required events). */
305
+ authUrl?: string
262
306
  }
263
307
 
264
- /** Configuration for creating a MeshNode. */
265
- export interface NapiMeshNodeConfig {
266
- deviceId: string
267
- deviceName: string
268
- deviceType: string
269
- hostnamePrefix: string
270
- /**
271
- * Path to the Go sidecar binary. Optional — use `resolveSidecarPath()`
272
- * from `@vibecook/truffle` for automatic platform detection.
273
- */
274
- sidecarPath?: string
275
- stateDir?: string
276
- authKey?: string
277
- preferPrimary?: boolean
278
- staticPath?: string
279
- capabilities?: Array<string>
280
- timing?: NapiMeshTimingConfig
308
+ /** Result of a network-level ping. */
309
+ export interface NapiPingResult {
310
+ /** Round-trip latency in milliseconds. */
311
+ latencyMs: number
312
+ /** Connection type description (e.g., "direct" or "relay:sfo"). */
313
+ connection: string
314
+ /** Direct peer endpoint address, if available. */
315
+ peerAddr?: string
281
316
  }
282
317
 
283
- /** Timing configuration for the mesh. */
284
- export interface NapiMeshTimingConfig {
285
- announceIntervalMs?: number
286
- discoveryTimeoutMs?: number
287
- electionTimeoutMs?: number
288
- primaryLossGraceMs?: number
289
- heartbeatPingMs?: number
290
- heartbeatTimeoutMs?: number
318
+ /** A versioned slice of data owned by a single device. */
319
+ export interface NapiSlice {
320
+ /** Device that owns this slice (stable node ID). */
321
+ deviceId: string
322
+ /** The data (JSON value). */
323
+ data: any
324
+ /** Monotonically increasing version (per-device). */
325
+ version: number
326
+ /** When this version was created (Unix milliseconds). */
327
+ updatedAt: number
291
328
  }
292
329
 
293
- /** Outgoing sync message delivered to JS for broadcasting. */
294
- export interface NapiOutgoingSyncMessage {
295
- msgType: string
296
- payload: any
330
+ /** A store change event delivered to JS. */
331
+ export interface NapiStoreEvent {
332
+ /** Event type: "local_changed", "peer_updated", "peer_removed". */
333
+ eventType: string
334
+ /** Device ID (present for peer_updated/peer_removed events). */
335
+ deviceId?: string
336
+ /** Data payload (present for local_changed/peer_updated events). */
337
+ data?: any
338
+ /** Version number (present for peer_updated events). */
339
+ version?: number
297
340
  }
298
341
 
299
- /** Store sync configuration (JS representation). */
300
- export interface NapiStoreSyncConfig {
301
- localDeviceId: string
342
+ /** Progress update for an in-flight file transfer. */
343
+ export interface NapiTransferProgress {
344
+ /** Unique token for this transfer. */
345
+ token: string
346
+ /** Direction: "send" or "receive". */
347
+ direction: string
348
+ /** File name being transferred. */
349
+ fileName: string
350
+ /** Bytes transferred so far. */
351
+ bytesTransferred: number
352
+ /** Total file size in bytes. */
353
+ totalBytes: number
354
+ /** Current transfer speed in bytes per second. */
355
+ speedBps: number
302
356
  }
303
357
 
304
- /** Tailnet peer info (JS representation). */
305
- export interface NapiTailnetPeer {
306
- id: string
307
- hostname: string
308
- dnsName: string
309
- tailscaleIps: Array<string>
310
- online: boolean
311
- os?: string
358
+ /** Result of a completed file transfer. */
359
+ export interface NapiTransferResult {
360
+ /** Number of bytes transferred. */
361
+ bytesTransferred: number
362
+ /** SHA-256 hash of the transferred file. */
363
+ sha256: string
364
+ /** Elapsed time in seconds. */
365
+ elapsedSecs: number
312
366
  }
package/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('@vibecook/truffle-native-android-arm64')
79
79
  const bindingPackageVersion = require('@vibecook/truffle-native-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('@vibecook/truffle-native-android-arm-eabi')
95
95
  const bindingPackageVersion = require('@vibecook/truffle-native-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('@vibecook/truffle-native-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('@vibecook/truffle-native-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('@vibecook/truffle-native-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('@vibecook/truffle-native-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('@vibecook/truffle-native-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('@vibecook/truffle-native-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('@vibecook/truffle-native-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('@vibecook/truffle-native-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('@vibecook/truffle-native-darwin-universal')
184
184
  const bindingPackageVersion = require('@vibecook/truffle-native-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('@vibecook/truffle-native-darwin-x64')
200
200
  const bindingPackageVersion = require('@vibecook/truffle-native-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('@vibecook/truffle-native-darwin-arm64')
216
216
  const bindingPackageVersion = require('@vibecook/truffle-native-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('@vibecook/truffle-native-freebsd-x64')
236
236
  const bindingPackageVersion = require('@vibecook/truffle-native-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('@vibecook/truffle-native-freebsd-arm64')
252
252
  const bindingPackageVersion = require('@vibecook/truffle-native-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('@vibecook/truffle-native-linux-x64-musl')
273
273
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('@vibecook/truffle-native-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('@vibecook/truffle-native-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('@vibecook/truffle-native-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('@vibecook/truffle-native-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('@vibecook/truffle-native-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('@vibecook/truffle-native-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('@vibecook/truffle-native-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('@vibecook/truffle-native-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('@vibecook/truffle-native-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('@vibecook/truffle-native-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('@vibecook/truffle-native-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('@vibecook/truffle-native-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('@vibecook/truffle-native-openharmony-arm64')
478
478
  const bindingPackageVersion = require('@vibecook/truffle-native-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('@vibecook/truffle-native-openharmony-x64')
494
494
  const bindingPackageVersion = require('@vibecook/truffle-native-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('@vibecook/truffle-native-openharmony-arm')
510
510
  const bindingPackageVersion = require('@vibecook/truffle-native-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.3.17' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.3.17 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -576,7 +576,7 @@ if (!nativeBinding) {
576
576
  }
577
577
 
578
578
  module.exports = nativeBinding
579
- module.exports.NapiFileTransferAdapter = nativeBinding.NapiFileTransferAdapter
580
- module.exports.NapiMeshNode = nativeBinding.NapiMeshNode
581
- module.exports.NapiMessageBus = nativeBinding.NapiMessageBus
582
- module.exports.NapiStoreSyncAdapter = nativeBinding.NapiStoreSyncAdapter
579
+ module.exports.NapiFileTransfer = nativeBinding.NapiFileTransfer
580
+ module.exports.NapiNode = nativeBinding.NapiNode
581
+ module.exports.NapiOfferResponder = nativeBinding.NapiOfferResponder
582
+ module.exports.NapiSyncedStore = nativeBinding.NapiSyncedStore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibecook/truffle-native",
3
- "version": "0.1.1",
3
+ "version": "0.3.22",
4
4
  "description": "Mesh networking for local-first apps, built on Tailscale (native addon)",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -34,8 +34,20 @@
34
34
  "files": [
35
35
  "index.js",
36
36
  "index.d.ts",
37
+ "helpers.js",
38
+ "helpers.d.ts",
37
39
  "*.node"
38
40
  ],
41
+ "exports": {
42
+ ".": {
43
+ "types": "./index.d.ts",
44
+ "default": "./index.js"
45
+ },
46
+ "./helpers": {
47
+ "types": "./helpers.d.ts",
48
+ "default": "./helpers.js"
49
+ }
50
+ },
39
51
  "napi": {
40
52
  "binaryName": "truffle",
41
53
  "targets": [
@@ -43,12 +55,7 @@
43
55
  "aarch64-apple-darwin",
44
56
  "x86_64-unknown-linux-gnu",
45
57
  "aarch64-unknown-linux-gnu",
46
- "x86_64-unknown-linux-musl",
47
- "aarch64-unknown-linux-musl",
48
- "aarch64-linux-android",
49
- "x86_64-pc-windows-msvc",
50
- "aarch64-pc-windows-msvc",
51
- "armv7-unknown-linux-gnueabihf"
58
+ "x86_64-pc-windows-msvc"
52
59
  ]
53
60
  },
54
61
  "devDependencies": {
@@ -59,17 +66,5 @@
59
66
  "build:debug": "napi build --platform",
60
67
  "prepublishOnly": "napi prepublish -t npm",
61
68
  "artifacts": "napi artifacts"
62
- },
63
- "optionalDependencies": {
64
- "@vibecook/truffle-native-darwin-x64": "0.1.1",
65
- "@vibecook/truffle-native-darwin-arm64": "0.1.1",
66
- "@vibecook/truffle-native-linux-x64-gnu": "0.1.1",
67
- "@vibecook/truffle-native-linux-arm64-gnu": "0.1.1",
68
- "@vibecook/truffle-native-linux-x64-musl": "0.1.1",
69
- "@vibecook/truffle-native-linux-arm64-musl": "0.1.1",
70
- "@vibecook/truffle-native-android-arm64": "0.1.1",
71
- "@vibecook/truffle-native-win32-x64-msvc": "0.1.1",
72
- "@vibecook/truffle-native-win32-arm64-msvc": "0.1.1",
73
- "@vibecook/truffle-native-linux-arm-gnueabihf": "0.1.1"
74
69
  }
75
70
  }
Binary file
Binary file
Binary file
Binary file
Binary file