pb-mapper 0.7.0 → 0.8.0
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 +84 -54
- package/index.d.ts +89 -3
- package/index.js +54 -54
- package/package.json +9 -6
- package/pb-mapper.win32-x64-msvc.node +0 -0
package/README.md
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript/JavaScript bindings for [pb-mapper](https://github.com/acking-you/pb-mapper),
|
|
4
4
|
built with Node-API (napi-rs). Publish a private TCP/UDP service with `register`
|
|
5
|
-
and reach it on a local port with `connect
|
|
6
|
-
|
|
5
|
+
and reach it on a local port with `connect`. Every connection goes peer to peer
|
|
6
|
+
over QUIC when the networks allow it and falls back to the relay before any
|
|
7
|
+
byte is sent when they do not. Reconnection and recovery are automatic.
|
|
7
8
|
|
|
8
9
|
```bash
|
|
9
10
|
npm install pb-mapper
|
|
10
11
|
```
|
|
11
12
|
|
|
12
|
-
The package ships prebuilt native addons for 64-bit glibc Linux,
|
|
13
|
-
Windows. It supports Node.js 18+ and Bun 1.1+.
|
|
14
|
-
load Node-API addons.
|
|
13
|
+
The package ships prebuilt native addons for 64-bit glibc Linux (x64, arm64),
|
|
14
|
+
macOS (x64, arm64) and Windows x64. It supports Node.js 18+ and Bun 1.1+.
|
|
15
|
+
Browsers and edge runtimes cannot load Node-API addons.
|
|
15
16
|
|
|
16
17
|
```ts
|
|
17
18
|
import { Client } from "pb-mapper";
|
|
@@ -22,72 +23,101 @@ const client = new Client({
|
|
|
22
23
|
keepAlive: true,
|
|
23
24
|
});
|
|
24
25
|
|
|
26
|
+
// Publish a local service...
|
|
25
27
|
const reg = await client.register({
|
|
26
|
-
key: "
|
|
27
|
-
localAddr: "127.0.0.1:8080",
|
|
28
|
-
transport: "tcp",
|
|
28
|
+
key: "web", localAddr: "127.0.0.1:8080", transport: "tcp",
|
|
29
29
|
});
|
|
30
30
|
await reg.waitReady();
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
32
|
+
// ...and reach it on a local port, direct first.
|
|
33
|
+
const conn = await client.connect({
|
|
34
|
+
key: "web", localAddr: "127.0.0.1:9090", transport: "tcp",
|
|
35
|
+
});
|
|
36
|
+
await conn.waitReady();
|
|
35
37
|
|
|
38
|
+
await conn.stop();
|
|
36
39
|
await reg.stop();
|
|
37
40
|
```
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
## Paths
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
`register` allows direct sessions and `connect` uses `path: "auto"` by
|
|
45
|
+
default: try UDP hole punching and mutually authenticated QUIC, and fall back
|
|
46
|
+
to the relay if setup fails before commit. After commit a failed connection
|
|
47
|
+
closes and is never replayed onto the relay. After a fallback, the tunnel sends
|
|
48
|
+
its next connections straight to the relay for a while (10 s doubling to 5 min,
|
|
49
|
+
cleared by a direct success or `notifyNetworkChange()`).
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
To stay on the relay, register with `allowDirect: false` or connect with
|
|
52
|
+
`path: "relay-only"`. Established direct connections survive coordinator loss
|
|
53
|
+
and credential revocation; local `stop()` closes them.
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
## Listening for changes
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// Resolves on every status change; once the tunnel settles as "stopped" or
|
|
59
|
+
// "failed:<reason>", every call resolves at once, which ends the loop.
|
|
60
|
+
let status = conn.status();
|
|
61
|
+
while (status !== "stopped" && !status.startsWith("failed")) {
|
|
62
|
+
status = await conn.nextStatus();
|
|
63
|
+
console.log("status:", status);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
54
66
|
|
|
55
|
-
|
|
56
|
-
application heartbeats. This is a publisher SDK policy, not a relay protocol
|
|
57
|
-
change: existing compatible relays and subscribers do not need an upgrade.
|
|
67
|
+
`diagnostics()` is a credential-free snapshot for dashboards and logs:
|
|
58
68
|
|
|
59
|
-
|
|
69
|
+
- `events`: the last 16 of `relay_ready`, `relay_failed`, `network_changed`,
|
|
70
|
+
`direct_established` and `direct_fallback`, each with a `seq` so a poller
|
|
71
|
+
can print only new ones, plus `latencyMs`, `failure`, `retryInMs`,
|
|
72
|
+
`setupMs` or `stage` as they apply;
|
|
73
|
+
- `direct`: sessions per path, active sessions, fallbacks, and the attempt in
|
|
74
|
+
flight with its stage (`negotiating`, `discovering`, `punching`,
|
|
75
|
+
`committing`);
|
|
76
|
+
- recovery counters: attempts, consecutive failures, setup latency, next retry.
|
|
60
77
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
`client.notifyNetworkChange()` wakes pending recovery after a host network/resume
|
|
64
|
-
notification; healthy forwarding stays open. Workers retry initial DNS failures,
|
|
65
|
-
refresh relay addresses through the OS resolver, and share bounded setup capacity.
|
|
66
|
-
See [recovery design](../docs/weak-network-recovery.md) for bounds and limitations.
|
|
78
|
+
Call `client.notifyNetworkChange()` from the host's network-change or resume
|
|
79
|
+
notification: waiting retries start at once and direct is tried again.
|
|
67
80
|
|
|
68
|
-
|
|
81
|
+
## Credentials and the relay
|
|
69
82
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
`"relay-only"` is the default, so existing calls keep the relay protocol.
|
|
83
|
+
With the administrator key, `client.admin()` manages temporary `pbmt1_`
|
|
84
|
+
credentials and inspects the relay:
|
|
73
85
|
|
|
74
86
|
```ts
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
await conn.waitReady();
|
|
82
|
-
console.log(conn.diagnostics().direct); // populated after path selection
|
|
83
|
-
console.log(JSON.parse(await client.sessionsJson()));
|
|
84
|
-
await conn.stop();
|
|
85
|
-
await reg.stop();
|
|
87
|
+
const admin = client.admin();
|
|
88
|
+
const issued = await admin.issueKey(3600, "agent-session"); // ttl in seconds
|
|
89
|
+
await admin.renewKey(issued.keyId, 7200);
|
|
90
|
+
console.log(await admin.listKeys(), await admin.listServices(), await admin.listConnections());
|
|
91
|
+
await admin.revokeKey(issued.keyId); // live relay connections close
|
|
86
92
|
```
|
|
87
93
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
Every credential has its own namespace: `client.listKeys()`, `serviceStatus()`,
|
|
95
|
+
`sessionsJson()` and `remoteId()` only ever see that namespace.
|
|
96
|
+
|
|
97
|
+
## Examples
|
|
98
|
+
|
|
99
|
+
Runnable scripts in [`examples/`](examples) read `PB_MAPPER_SERVER` and
|
|
100
|
+
`MSG_HEADER_KEY`:
|
|
101
|
+
|
|
102
|
+
| Script | Shows |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| [`register.mjs`](examples/register.mjs) | Publish a TCP or UDP service, optionally relay-only |
|
|
105
|
+
| [`connect.mjs`](examples/connect.mjs) | Reach it, listen with `nextStatus()`, print new events |
|
|
106
|
+
| [`admin.mjs`](examples/admin.mjs) | The credential lifecycle and the relay inventory |
|
|
107
|
+
| [`remote-control.mjs`](examples/remote-control.mjs) | One scoped credential per agent session, revoked at the end |
|
|
108
|
+
|
|
109
|
+
## TCP idle connection reclamation
|
|
110
|
+
|
|
111
|
+
`client.registerWithIdleTimeout(request, idleTimeoutMs)` reclaims abandoned
|
|
112
|
+
data connections on the publishing device. The timeout is a non-negative safe
|
|
113
|
+
integer in milliseconds; zero disables it. Traffic in either direction resets
|
|
114
|
+
the deadline. UDP is rejected. Choose a deadline longer than the service's
|
|
115
|
+
legitimate quiet periods, or use application heartbeats.
|
|
116
|
+
|
|
117
|
+
## Building from source
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
bun install
|
|
121
|
+
bun run build:release # LTO + strip
|
|
122
|
+
bun test # smoke + e2e (e2e needs `cargo build --bin pb-mapper`)
|
|
123
|
+
```
|
package/index.d.ts
CHANGED
|
@@ -59,8 +59,23 @@ export declare class Connection {
|
|
|
59
59
|
* `stopped`, or `failed:<reason>`.
|
|
60
60
|
*/
|
|
61
61
|
status(): string
|
|
62
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* Inspect the running SDK version, failure phase, bounded setup
|
|
64
|
+
* load, the direct attempt in flight, and recent events.
|
|
65
|
+
*/
|
|
63
66
|
diagnostics(): JsTunnelDiagnostics
|
|
67
|
+
/**
|
|
68
|
+
* Resolves with the next status this tunnel reports, rendered as
|
|
69
|
+
* `status()` renders it: an event listener for status changes.
|
|
70
|
+
*
|
|
71
|
+
* Each handle keeps its own position, so a change that happens
|
|
72
|
+
* between two calls is returned by the next one rather than
|
|
73
|
+
* missed. Once the tunnel settles as `stopped` or
|
|
74
|
+
* `failed:<reason>`, every call resolves at once with that final
|
|
75
|
+
* status, which is what ends a listening loop. Rejects after
|
|
76
|
+
* `timeoutMs` without a change.
|
|
77
|
+
*/
|
|
78
|
+
nextStatus(timeoutMs?: number | undefined | null): Promise<string>
|
|
64
79
|
/**
|
|
65
80
|
* Resolves once the tunnel is connected, and rejects if it fails or
|
|
66
81
|
* is stopped first.
|
|
@@ -83,8 +98,23 @@ export declare class Registration {
|
|
|
83
98
|
* `stopped`, or `failed:<reason>`.
|
|
84
99
|
*/
|
|
85
100
|
status(): string
|
|
86
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Inspect the running SDK version, failure phase, bounded setup
|
|
103
|
+
* load, the direct attempt in flight, and recent events.
|
|
104
|
+
*/
|
|
87
105
|
diagnostics(): JsTunnelDiagnostics
|
|
106
|
+
/**
|
|
107
|
+
* Resolves with the next status this tunnel reports, rendered as
|
|
108
|
+
* `status()` renders it: an event listener for status changes.
|
|
109
|
+
*
|
|
110
|
+
* Each handle keeps its own position, so a change that happens
|
|
111
|
+
* between two calls is returned by the next one rather than
|
|
112
|
+
* missed. Once the tunnel settles as `stopped` or
|
|
113
|
+
* `failed:<reason>`, every call resolves at once with that final
|
|
114
|
+
* status, which is what ends a listening loop. Rejects after
|
|
115
|
+
* `timeoutMs` without a change.
|
|
116
|
+
*/
|
|
117
|
+
nextStatus(timeoutMs?: number | undefined | null): Promise<string>
|
|
88
118
|
/**
|
|
89
119
|
* Resolves once the tunnel is connected, and rejects if it fails or
|
|
90
120
|
* is stopped first.
|
|
@@ -138,13 +168,28 @@ export interface JsConnectionInfo {
|
|
|
138
168
|
}
|
|
139
169
|
|
|
140
170
|
export interface JsConnectRequest {
|
|
141
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* "auto" (default): direct first, relay fallback before any byte is sent.
|
|
173
|
+
* "relay-only": always use the relay.
|
|
174
|
+
*/
|
|
142
175
|
path?: string
|
|
143
176
|
key: string
|
|
144
177
|
localAddr: string
|
|
145
178
|
transport: string
|
|
146
179
|
}
|
|
147
180
|
|
|
181
|
+
/** The direct attempt a tunnel is making right now. */
|
|
182
|
+
export interface JsDirectAttempt {
|
|
183
|
+
/**
|
|
184
|
+
* `negotiating`, `discovering`, `punching` or `committing`. Every stage
|
|
185
|
+
* before `committing` can still fall back to the relay.
|
|
186
|
+
*/
|
|
187
|
+
stage: string
|
|
188
|
+
elapsedMs: number
|
|
189
|
+
/** Attempts in flight, this one included. */
|
|
190
|
+
inFlight: number
|
|
191
|
+
}
|
|
192
|
+
|
|
148
193
|
export interface JsIssuedKey {
|
|
149
194
|
keyId: number
|
|
150
195
|
state: string
|
|
@@ -170,9 +215,15 @@ export interface JsPathDiagnostics {
|
|
|
170
215
|
activeRelay: number
|
|
171
216
|
fallbacks: number
|
|
172
217
|
lastFallback?: string
|
|
218
|
+
/** The direct attempt in flight, if any. */
|
|
219
|
+
attempt?: JsDirectAttempt
|
|
173
220
|
}
|
|
174
221
|
|
|
175
222
|
export interface JsRegisterRequest {
|
|
223
|
+
/**
|
|
224
|
+
* Accept direct sessions from authorized consumers (default `true`).
|
|
225
|
+
* `false` keeps every session to this service on the relay.
|
|
226
|
+
*/
|
|
176
227
|
allowDirect?: boolean
|
|
177
228
|
key: string
|
|
178
229
|
localAddr: string
|
|
@@ -218,4 +269,39 @@ export interface JsTunnelDiagnostics {
|
|
|
218
269
|
networkGeneration: number
|
|
219
270
|
activeControlSetups: number
|
|
220
271
|
activeDataSetups: number
|
|
272
|
+
/** Recent history, oldest first; at most 16 entries. */
|
|
273
|
+
events: Array<JsTunnelEvent>
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* One entry of a tunnel's recent history. Consecutive repeats fold into one
|
|
278
|
+
* entry, counted by `repeats`.
|
|
279
|
+
*/
|
|
280
|
+
export interface JsTunnelEvent {
|
|
281
|
+
/**
|
|
282
|
+
* Increases with every recorded event, a fold included: remember the
|
|
283
|
+
* highest one handled to tell which entries are new.
|
|
284
|
+
*/
|
|
285
|
+
seq: number
|
|
286
|
+
/** Time since the latest occurrence. */
|
|
287
|
+
ageMs: number
|
|
288
|
+
repeats: number
|
|
289
|
+
/**
|
|
290
|
+
* `relay_ready`, `relay_failed`, `network_changed`, `direct_established`
|
|
291
|
+
* or `direct_fallback`.
|
|
292
|
+
*/
|
|
293
|
+
kind: string
|
|
294
|
+
/** `relay_ready`: setup latency of the answering relay. */
|
|
295
|
+
latencyMs?: number
|
|
296
|
+
/**
|
|
297
|
+
* `relay_failed`: `dns`, `transport`, `timeout`, `service_unavailable`,
|
|
298
|
+
* `rejected` or `network_changed`.
|
|
299
|
+
*/
|
|
300
|
+
failure?: string
|
|
301
|
+
/** `relay_failed`: delay before the next attempt. */
|
|
302
|
+
retryInMs?: number
|
|
303
|
+
/** `direct_established`: time from the first request to the open path. */
|
|
304
|
+
setupMs?: number
|
|
305
|
+
/** `direct_fallback`: the stage the attempt left for the relay. */
|
|
306
|
+
stage?: string
|
|
221
307
|
}
|
package/index.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('pb-mapper-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('pb-mapper-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '0.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
80
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('pb-mapper-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '0.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
96
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('pb-mapper-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '0.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
117
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('pb-mapper-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '0.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
133
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('pb-mapper-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '0.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
150
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('pb-mapper-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '0.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
166
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('pb-mapper-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '0.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
185
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('pb-mapper-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '0.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
201
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('pb-mapper-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '0.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
217
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('pb-mapper-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '0.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
237
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('pb-mapper-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '0.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
253
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('pb-mapper-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '0.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
274
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('pb-mapper-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '0.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
290
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('pb-mapper-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '0.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
308
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('pb-mapper-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '0.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
324
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('pb-mapper-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '0.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
342
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('pb-mapper-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '0.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
358
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('pb-mapper-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '0.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
376
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('pb-mapper-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '0.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
392
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('pb-mapper-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '0.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
410
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('pb-mapper-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '0.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
426
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('pb-mapper-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '0.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
443
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('pb-mapper-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '0.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
459
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('pb-mapper-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '0.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
479
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('pb-mapper-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '0.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
495
|
+
if (bindingPackageVersion !== '0.8.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.8.0 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('pb-mapper-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('pb-mapper-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '0.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
511
|
+
if (bindingPackageVersion !== '0.8.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.8.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
|
@@ -648,8 +648,8 @@ if (!nativeBinding || forceWasi) {
|
|
|
648
648
|
if (!candidateFailed) {
|
|
649
649
|
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
650
650
|
const bindingPackageVersion = require('pb-mapper-wasm32-wasi/package.json').version
|
|
651
|
-
if (bindingPackageVersion !== '0.
|
|
652
|
-
throw new Error(`WASI binding package version mismatch, expected 0.
|
|
651
|
+
if (bindingPackageVersion !== '0.8.0') {
|
|
652
|
+
throw new Error(`WASI binding package version mismatch, expected 0.8.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
655
|
wasiBinding = require('pb-mapper-wasm32-wasi')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pb-mapper",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Node-API client for pb-mapper:
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Node-API client for pb-mapper: peer-to-peer tunnels to private TCP/UDP services with automatic relay fallback",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
25
25
|
"tunnel",
|
|
26
|
+
"p2p",
|
|
27
|
+
"nat-traversal",
|
|
28
|
+
"quic",
|
|
26
29
|
"tcp",
|
|
27
30
|
"udp",
|
|
28
31
|
"napi-rs",
|
|
@@ -56,10 +59,10 @@
|
|
|
56
59
|
"@napi-rs/cli": "^3.3.0"
|
|
57
60
|
},
|
|
58
61
|
"optionalDependencies": {
|
|
59
|
-
"pb-mapper-darwin-arm64": "0.
|
|
60
|
-
"pb-mapper-darwin-x64": "0.
|
|
61
|
-
"pb-mapper-linux-arm64-gnu": "0.
|
|
62
|
-
"pb-mapper-linux-x64-gnu": "0.
|
|
62
|
+
"pb-mapper-darwin-arm64": "0.8.0",
|
|
63
|
+
"pb-mapper-darwin-x64": "0.8.0",
|
|
64
|
+
"pb-mapper-linux-arm64-gnu": "0.8.0",
|
|
65
|
+
"pb-mapper-linux-x64-gnu": "0.8.0"
|
|
63
66
|
},
|
|
64
67
|
"engines": {
|
|
65
68
|
"node": ">= 18",
|
|
Binary file
|