@hashiverse/hashiverse-client-nodejs 1.0.8 → 1.1.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.
Files changed (3) hide show
  1. package/index.d.ts +9 -0
  2. package/index.js +366 -107
  3. package/package.json +15 -9
package/index.d.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+
4
+ /**
5
+ * Which binding artifact the generated loader actually loaded: `'native'` for
6
+ * a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
7
+ * flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
8
+ * can point the loader at a WASI artifact this package does not build itself.
9
+ */
10
+ export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
11
+
3
12
  export declare class HashiverseClient {
4
13
  static createFromKeyphrase(opts: CreateFromKeyphraseOptions): Promise<HashiverseClient>
5
14
  static createFromStoredKey(opts: CreateFromStoredKeyOptions): Promise<HashiverseClient>
package/index.js CHANGED
@@ -1,10 +1,18 @@
1
- // prettier-ignore
2
1
  /* eslint-disable */
3
2
  // @ts-nocheck
4
3
  /* auto-generated by NAPI-RS */
5
4
 
6
- const { readFileSync } = require('node:fs')
5
+ const { readFileSync } = require('fs')
7
6
  let nativeBinding = null
7
+ // Which artifact actually loaded. The WASI fallback chain overwrites it with
8
+ // the flavor it resolved; the late native retry below leaves it alone because
9
+ // it only runs while no WASI candidate has been loaded. The take-over check
10
+ // after the load-failure block can also set it.
11
+ let __napiLoadedBindingTarget = 'native'
12
+ // What this loader's own `requireNative()` calls returned. The check after
13
+ // the load-failure block compares it with `nativeBinding` to tell a binding
14
+ // this loader loaded from one that code outside it put in its place.
15
+ let __napiRequiredNativeBinding = null
8
16
  const loadErrors = []
9
17
 
10
18
  const isMusl = () => {
@@ -33,7 +41,7 @@ const isMuslFromFilesystem = () => {
33
41
 
34
42
  const isMuslFromReport = () => {
35
43
  let report = null
36
- if (typeof process.report?.getReport === 'function') {
44
+ if (process.report && typeof process.report.getReport === 'function') {
37
45
  process.report.excludeNetwork = true
38
46
  report = process.report.getReport()
39
47
  }
@@ -63,7 +71,16 @@ const isMuslFromChildProcess = () => {
63
71
  function requireNative() {
64
72
  if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
65
73
  try {
66
- return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
74
+ const overrideBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
75
+ // The override may be a generated WASI loader, which already reports its
76
+ // own flavor. Adopt it: `module.exports` aliases this object, so claiming
77
+ // 'native' would both misreport the artifact and overwrite the loader's
78
+ // marker through the alias.
79
+ __napiLoadedBindingTarget =
80
+ overrideBinding && typeof overrideBinding.__napiBindingTarget === 'string'
81
+ ? overrideBinding.__napiBindingTarget
82
+ : 'native'
83
+ return overrideBinding
67
84
  } catch (err) {
68
85
  loadErrors.push(err)
69
86
  }
@@ -77,8 +94,8 @@ function requireNative() {
77
94
  try {
78
95
  const binding = require('@hashiverse/hashiverse-client-nodejs-android-arm64')
79
96
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
97
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
98
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
99
  }
83
100
  return binding
84
101
  } catch (e) {
@@ -93,8 +110,8 @@ function requireNative() {
93
110
  try {
94
111
  const binding = require('@hashiverse/hashiverse-client-nodejs-android-arm-eabi')
95
112
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
113
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
114
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
115
  }
99
116
  return binding
100
117
  } catch (e) {
@@ -105,38 +122,38 @@ function requireNative() {
105
122
  }
106
123
  } else if (process.platform === 'win32') {
107
124
  if (process.arch === 'x64') {
108
- if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
125
+ if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
109
126
  try {
110
- return require('./hashiverse-client-nodejs.win32-x64-gnu.node')
111
- } catch (e) {
112
- loadErrors.push(e)
113
- }
114
- try {
115
- const binding = require('@hashiverse/hashiverse-client-nodejs-win32-x64-gnu')
116
- const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
127
+ return require('./hashiverse-client-nodejs.win32-x64-gnu.node')
128
+ } catch (e) {
129
+ loadErrors.push(e)
130
+ }
131
+ try {
132
+ const binding = require('@hashiverse/hashiverse-client-nodejs-win32-x64-gnu')
133
+ const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-win32-x64-gnu/package.json').version
134
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
135
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
136
+ }
137
+ return binding
138
+ } catch (e) {
139
+ loadErrors.push(e)
119
140
  }
120
- return binding
121
- } catch (e) {
122
- loadErrors.push(e)
123
- }
124
141
  } else {
125
142
  try {
126
- return require('./hashiverse-client-nodejs.win32-x64-msvc.node')
127
- } catch (e) {
128
- loadErrors.push(e)
129
- }
130
- try {
131
- const binding = require('@hashiverse/hashiverse-client-nodejs-win32-x64-msvc')
132
- const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
143
+ return require('./hashiverse-client-nodejs.win32-x64-msvc.node')
144
+ } catch (e) {
145
+ loadErrors.push(e)
146
+ }
147
+ try {
148
+ const binding = require('@hashiverse/hashiverse-client-nodejs-win32-x64-msvc')
149
+ const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-win32-x64-msvc/package.json').version
150
+ if (bindingPackageVersion !== '1.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 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
+ }
153
+ return binding
154
+ } catch (e) {
155
+ loadErrors.push(e)
135
156
  }
136
- return binding
137
- } catch (e) {
138
- loadErrors.push(e)
139
- }
140
157
  }
141
158
  } else if (process.arch === 'ia32') {
142
159
  try {
@@ -147,8 +164,8 @@ function requireNative() {
147
164
  try {
148
165
  const binding = require('@hashiverse/hashiverse-client-nodejs-win32-ia32-msvc')
149
166
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
167
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
168
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
169
  }
153
170
  return binding
154
171
  } catch (e) {
@@ -163,8 +180,8 @@ function requireNative() {
163
180
  try {
164
181
  const binding = require('@hashiverse/hashiverse-client-nodejs-win32-arm64-msvc')
165
182
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
183
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
184
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
185
  }
169
186
  return binding
170
187
  } catch (e) {
@@ -182,8 +199,8 @@ function requireNative() {
182
199
  try {
183
200
  const binding = require('@hashiverse/hashiverse-client-nodejs-darwin-universal')
184
201
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
202
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
203
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
204
  }
188
205
  return binding
189
206
  } catch (e) {
@@ -198,8 +215,8 @@ function requireNative() {
198
215
  try {
199
216
  const binding = require('@hashiverse/hashiverse-client-nodejs-darwin-x64')
200
217
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
218
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
219
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
220
  }
204
221
  return binding
205
222
  } catch (e) {
@@ -214,8 +231,8 @@ function requireNative() {
214
231
  try {
215
232
  const binding = require('@hashiverse/hashiverse-client-nodejs-darwin-arm64')
216
233
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
234
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
235
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
236
  }
220
237
  return binding
221
238
  } catch (e) {
@@ -234,8 +251,8 @@ function requireNative() {
234
251
  try {
235
252
  const binding = require('@hashiverse/hashiverse-client-nodejs-freebsd-x64')
236
253
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
254
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
255
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
256
  }
240
257
  return binding
241
258
  } catch (e) {
@@ -250,8 +267,24 @@ function requireNative() {
250
267
  try {
251
268
  const binding = require('@hashiverse/hashiverse-client-nodejs-freebsd-arm64')
252
269
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
270
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
271
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
272
+ }
273
+ return binding
274
+ } catch (e) {
275
+ loadErrors.push(e)
276
+ }
277
+ } else if (process.arch === 'ppc64') {
278
+ try {
279
+ return require('./hashiverse-client-nodejs.freebsd-ppc64.node')
280
+ } catch (e) {
281
+ loadErrors.push(e)
282
+ }
283
+ try {
284
+ const binding = require('@hashiverse/hashiverse-client-nodejs-freebsd-ppc64')
285
+ const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-freebsd-ppc64/package.json').version
286
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
287
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
288
  }
256
289
  return binding
257
290
  } catch (e) {
@@ -271,8 +304,8 @@ function requireNative() {
271
304
  try {
272
305
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-x64-musl')
273
306
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
307
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
308
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
309
  }
277
310
  return binding
278
311
  } catch (e) {
@@ -287,8 +320,8 @@ function requireNative() {
287
320
  try {
288
321
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-x64-gnu')
289
322
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
323
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
324
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
325
  }
293
326
  return binding
294
327
  } catch (e) {
@@ -305,8 +338,8 @@ function requireNative() {
305
338
  try {
306
339
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-arm64-musl')
307
340
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
341
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
342
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
343
  }
311
344
  return binding
312
345
  } catch (e) {
@@ -321,8 +354,8 @@ function requireNative() {
321
354
  try {
322
355
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-arm64-gnu')
323
356
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
357
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
358
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
359
  }
327
360
  return binding
328
361
  } catch (e) {
@@ -339,8 +372,8 @@ function requireNative() {
339
372
  try {
340
373
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-arm-musleabihf')
341
374
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
375
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
376
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
377
  }
345
378
  return binding
346
379
  } catch (e) {
@@ -355,8 +388,8 @@ function requireNative() {
355
388
  try {
356
389
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-arm-gnueabihf')
357
390
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
391
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
392
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
393
  }
361
394
  return binding
362
395
  } catch (e) {
@@ -373,8 +406,8 @@ function requireNative() {
373
406
  try {
374
407
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-loong64-musl')
375
408
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
409
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
410
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
411
  }
379
412
  return binding
380
413
  } catch (e) {
@@ -389,8 +422,8 @@ function requireNative() {
389
422
  try {
390
423
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-loong64-gnu')
391
424
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
425
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
426
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
427
  }
395
428
  return binding
396
429
  } catch (e) {
@@ -407,8 +440,8 @@ function requireNative() {
407
440
  try {
408
441
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-riscv64-musl')
409
442
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '1.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 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
445
  }
413
446
  return binding
414
447
  } catch (e) {
@@ -423,8 +456,8 @@ function requireNative() {
423
456
  try {
424
457
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-riscv64-gnu')
425
458
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '1.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 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
461
  }
429
462
  return binding
430
463
  } catch (e) {
@@ -440,8 +473,8 @@ function requireNative() {
440
473
  try {
441
474
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-ppc64-gnu')
442
475
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
476
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
477
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
478
  }
446
479
  return binding
447
480
  } catch (e) {
@@ -456,8 +489,8 @@ function requireNative() {
456
489
  try {
457
490
  const binding = require('@hashiverse/hashiverse-client-nodejs-linux-s390x-gnu')
458
491
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
492
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
493
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
494
  }
462
495
  return binding
463
496
  } catch (e) {
@@ -476,8 +509,8 @@ function requireNative() {
476
509
  try {
477
510
  const binding = require('@hashiverse/hashiverse-client-nodejs-openharmony-arm64')
478
511
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
512
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
513
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
514
  }
482
515
  return binding
483
516
  } catch (e) {
@@ -492,8 +525,8 @@ function requireNative() {
492
525
  try {
493
526
  const binding = require('@hashiverse/hashiverse-client-nodejs-openharmony-x64')
494
527
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
528
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
529
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
530
  }
498
531
  return binding
499
532
  } catch (e) {
@@ -508,8 +541,8 @@ function requireNative() {
508
541
  try {
509
542
  const binding = require('@hashiverse/hashiverse-client-nodejs-openharmony-arm')
510
543
  const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '1.0.8' && 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 1.0.8 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
544
+ if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
545
+ throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
546
  }
514
547
  return binding
515
548
  } catch (e) {
@@ -523,58 +556,284 @@ function requireNative() {
523
556
  }
524
557
  }
525
558
 
526
- nativeBinding = requireNative()
559
+ function createLoadErrorChain(errors) {
560
+ return errors.reduce((previous, current) => {
561
+ let message
562
+ try {
563
+ message =
564
+ current && typeof current.message === 'string'
565
+ ? current.message
566
+ : String(current)
567
+ } catch {
568
+ message = 'Unknown error'
569
+ }
570
+ const error = new Error(message)
571
+ error.cause = previous
572
+ return error
573
+ }, null)
574
+ }
575
+
576
+ // NAPI_RS_FORCE_WASI is a tri-state flag:
577
+ // unset / any other value → native binding preferred, WASI is only a fallback
578
+ // 'true' → prefer WASI, but retain native as a lazy fallback
579
+ // 'error' → require WASI without initializing a native fallback
580
+ // Treating any non-empty string as truthy (the historical behavior) meant
581
+ // NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
582
+ // the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
583
+ //
584
+ // NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
585
+ // WASI loading. It never crosses into another flavor or falls back to native.
586
+ const __napiWasiFlavors = ['wasm32-wasi']
587
+ const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
588
+ const __napiWasiFlavorRequested =
589
+ typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
590
+ if (
591
+ __napiWasiFlavorRequested &&
592
+ __napiWasiFlavors.indexOf(__napiWasiFlavor) === -1
593
+ ) {
594
+ throw new Error(
595
+ 'Unsupported WASI flavor "' +
596
+ __napiWasiFlavor +
597
+ '". Available flavors: ' +
598
+ __napiWasiFlavors.join(', '),
599
+ )
600
+ }
601
+ const forceWasiError = process.env.NAPI_RS_FORCE_WASI === 'error'
602
+ const forceWasi =
603
+ process.env.NAPI_RS_FORCE_WASI === 'true' ||
604
+ forceWasiError ||
605
+ __napiWasiFlavorRequested
606
+
607
+ if (!forceWasi) {
608
+ nativeBinding = requireNative()
609
+ __napiRequiredNativeBinding = nativeBinding
610
+ }
527
611
 
528
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
612
+ if (!nativeBinding || forceWasi) {
529
613
  let wasiBinding = null
530
- let wasiBindingError = null
531
- try {
532
- wasiBinding = require('./hashiverse-client-nodejs.wasi.cjs')
533
- nativeBinding = wasiBinding
534
- } catch (err) {
535
- if (process.env.NAPI_RS_FORCE_WASI) {
536
- wasiBindingError = err
614
+ let wasiBindingLoaded = false
615
+ const wasiBindingErrors = []
616
+ const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
617
+ try {
618
+ require.resolve(specifier)
619
+ } catch (resolveError) {
620
+ if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
621
+ throw resolveError
622
+ }
623
+ if (isPackage) {
624
+ try {
625
+ require.resolve(specifier + '/package.json')
626
+ } catch (packageError) {
627
+ if (packageError && packageError.code === 'MODULE_NOT_FOUND') {
628
+ return resolveError
629
+ }
630
+ // An exports restriction proves the package exists even when its
631
+ // package.json is not public. Preserve the root resolution failure.
632
+ throw resolveError
633
+ }
634
+ // The package exists but its main/export target is broken.
635
+ throw resolveError
636
+ }
637
+ return resolveError
537
638
  }
639
+ if (localArtifacts) {
640
+ let artifactError = null
641
+ for (let i = 0; i < localArtifacts.length; i++) {
642
+ try {
643
+ require.resolve(localArtifacts[i])
644
+ return null
645
+ } catch (resolveError) {
646
+ if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
647
+ throw resolveError
648
+ }
649
+ artifactError = resolveError
650
+ }
651
+ }
652
+ return artifactError
653
+ }
654
+ return null
538
655
  }
539
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
656
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
657
+ let candidateError = null
658
+ let candidateFailed = false
540
659
  try {
541
- wasiBinding = require('@hashiverse/hashiverse-client-nodejs-wasm32-wasi')
542
- nativeBinding = wasiBinding
660
+ candidateError = __napiWasiResolveCandidate('./hashiverse-client-nodejs.wasi.cjs', false, ['./hashiverse-client-nodejs.wasm32-wasi.debug.wasm', './hashiverse-client-nodejs.wasm32-wasi.wasm'])
661
+ candidateFailed = candidateError !== null
662
+ if (!candidateFailed) {
663
+ wasiBinding = require('./hashiverse-client-nodejs.wasi.cjs')
664
+ nativeBinding = wasiBinding
665
+ __napiLoadedBindingTarget = 'wasm32-wasi'
666
+ wasiBindingLoaded = true
667
+ }
543
668
  } catch (err) {
544
- if (process.env.NAPI_RS_FORCE_WASI) {
545
- if (!wasiBindingError) {
546
- wasiBindingError = err
547
- } else {
548
- wasiBindingError.cause = err
669
+ candidateError = err
670
+ candidateFailed = true
671
+ }
672
+ if (candidateFailed) {
673
+ wasiBindingErrors.push(candidateError)
674
+ loadErrors.push(candidateError)
675
+ }
676
+ }
677
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
678
+ let candidateError = null
679
+ let candidateFailed = false
680
+ try {
681
+ candidateError = __napiWasiResolveCandidate('@hashiverse/hashiverse-client-nodejs-wasm32-wasi', true, undefined)
682
+ candidateFailed = candidateError !== null
683
+ if (!candidateFailed) {
684
+ if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
685
+ const bindingPackageVersion = require('@hashiverse/hashiverse-client-nodejs-wasm32-wasi/package.json').version
686
+ if (bindingPackageVersion !== '1.1.0') {
687
+ throw new Error(`WASI binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
688
+ }
549
689
  }
550
- loadErrors.push(err)
690
+ wasiBinding = require('@hashiverse/hashiverse-client-nodejs-wasm32-wasi')
691
+ nativeBinding = wasiBinding
692
+ __napiLoadedBindingTarget = 'wasm32-wasi'
693
+ wasiBindingLoaded = true
551
694
  }
695
+ } catch (err) {
696
+ candidateError = err
697
+ candidateFailed = true
698
+ }
699
+ if (candidateFailed) {
700
+ wasiBindingErrors.push(candidateError)
701
+ loadErrors.push(candidateError)
552
702
  }
553
703
  }
554
- if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
555
- const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
556
- error.cause = wasiBindingError
704
+ if (
705
+ !wasiBindingLoaded &&
706
+ forceWasi &&
707
+ !forceWasiError &&
708
+ !__napiWasiFlavorRequested
709
+ ) {
710
+ nativeBinding = requireNative()
711
+ __napiRequiredNativeBinding = nativeBinding
712
+ }
713
+ if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
714
+ const error = new Error(
715
+ __napiWasiFlavorRequested
716
+ ? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found'
717
+ : 'WASI binding not found and NAPI_RS_FORCE_WASI is set to error',
718
+ )
719
+ error.cause = createLoadErrorChain(wasiBindingErrors)
557
720
  throw error
558
721
  }
559
722
  }
560
723
 
561
724
  if (!nativeBinding) {
562
725
  if (loadErrors.length > 0) {
563
- throw new Error(
726
+ const error = new Error(
564
727
  `Cannot find native binding. ` +
565
728
  `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
566
729
  'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
567
- {
568
- cause: loadErrors.reduce((err, cur) => {
569
- cur.cause = err
570
- return cur
571
- }),
572
- },
573
730
  )
731
+ // assign instead of the `new Error(message, { cause })` options form,
732
+ // which Node < 16.9 silently ignores
733
+ error.cause = createLoadErrorChain(loadErrors)
734
+ throw error
574
735
  }
575
736
  throw new Error(`Failed to load native binding`)
576
737
  }
577
738
 
739
+ // A package can patch its own fallback in front of the load-failure check
740
+ // above, e.g. a WebContainer download through `napi-postinstall/fallback`.
741
+ // That fallback swaps `nativeBinding` for a generated WASI loader, which has
742
+ // already stamped its own flavor, while the target above still says 'native'.
743
+ // Take that flavor over, or the CommonJS stamp throws a conflict and the ESM
744
+ // export reports the wrong artifact. Three limits keep the conflict check:
745
+ // - only a binding this loader did not load itself, so a native addon whose
746
+ // `#[napi(module_exports)]` hook claims the name is still rejected;
747
+ // - only an own data property, read through its descriptor, so no addon
748
+ // getter runs here, and it must read back the same, as the stamp reads it;
749
+ // - only a flavor in `__napiWasiFlavors`, the ones this loader's own WASI
750
+ // chain can report ('wasm32-wasi' for a package without a WASI target).
751
+ // This is metadata and never fails a load: a throwing Proxy trap keeps 'native'.
752
+ if (
753
+ __napiLoadedBindingTarget === 'native' &&
754
+ nativeBinding !== __napiRequiredNativeBinding
755
+ ) {
756
+ try {
757
+ const __napiBindingTargetDescriptor = Object.getOwnPropertyDescriptor(
758
+ nativeBinding,
759
+ '__napiBindingTarget',
760
+ )
761
+ if (
762
+ __napiBindingTargetDescriptor &&
763
+ __napiWasiFlavors.indexOf(__napiBindingTargetDescriptor.value) !== -1 &&
764
+ nativeBinding.__napiBindingTarget === __napiBindingTargetDescriptor.value
765
+ ) {
766
+ __napiLoadedBindingTarget = __napiBindingTargetDescriptor.value
767
+ }
768
+ } catch {
769
+ // keep 'native'
770
+ }
771
+ }
772
+
773
+ function __napiStampBindingTarget(exportsObject, target) {
774
+ if (
775
+ Object.prototype.hasOwnProperty.call(exportsObject, '__napiBindingTarget')
776
+ ) {
777
+ if (exportsObject.__napiBindingTarget === target) {
778
+ // Already ours: the root entry aliases the object it loaded, so a WASI
779
+ // fallback candidate — or a `NAPI_RS_NATIVE_LIBRARY_PATH` override that
780
+ // is a generated loader — arrives already stamped with this same value.
781
+ return target
782
+ }
783
+ const error = new Error(
784
+ '`__napiBindingTarget` is reserved by the generated binding loader, but the loaded binding already exports it. Rename the export, e.g. #[napi(js_name = "...")].',
785
+ )
786
+ error.code = 'ERR_NAPI_BINDING_TARGET_CONFLICT'
787
+ throw error
788
+ }
789
+ if (!Object.isExtensible(exportsObject)) {
790
+ // A `#[napi(module_exports)]` hook may seal or freeze this object
791
+ // (`Object::seal` / `Object::freeze`). Reporting the artifact is metadata,
792
+ // never a reason to fail an otherwise successful load, so the stamp is
793
+ // skipped. What a consumer still sees then follows the entry point: the
794
+ // browser and deferred loaders declare `__napiBindingTarget` at module
795
+ // level and go on reporting it, while the CommonJS entries hand back this
796
+ // very object as `module.exports`, so there the value is absent.
797
+ return target
798
+ }
799
+ try {
800
+ // [[Define]], not [[Set]]: an ordinary assignment walks the prototype
801
+ // chain, so an inherited accessor could swallow the value or throw and
802
+ // fail an otherwise successful load. The descriptor is what a successful
803
+ // assignment would have produced.
804
+ Object.defineProperty(exportsObject, '__napiBindingTarget', {
805
+ configurable: true,
806
+ enumerable: true,
807
+ value: target,
808
+ writable: true,
809
+ })
810
+ } catch {
811
+ // Same rule as the non-extensible skip above: reporting the artifact is
812
+ // metadata, never a reason to fail an otherwise successful load. An exotic
813
+ // object (a Proxy whose defineProperty trap refuses) is skipped, not
814
+ // thrown over.
815
+ }
816
+ // The CommonJS loaders assign this return value so `cjs-module-lexer` — and
817
+ // therefore Node's CJS -> ESM named export detection — can see
818
+ // `__napiBindingTarget` statically.
819
+ return target
820
+ }
821
+ // Stamp before the alias, not after. The guard only reads `nativeBinding`
822
+ // (`hasOwnProperty` plus a comparison), which is safe against any addon
823
+ // accessor; an assignment is not, because a `#[napi(module_exports)]` hook can
824
+ // expose a getter reporting this very value and a setter that throws. So the
825
+ // assignment lands on the loader's own `module.exports`, still the original
826
+ // object here, and the alias below replaces it.
827
+ //
828
+ // The assignment is what keeps the marker a statically visible CommonJS export:
829
+ // `cjs-module-lexer` is Node's CJS -> ESM named export detection, it cannot see
830
+ // a bare call, and the later `module.exports = nativeBinding` does not undo the
831
+ // detection. The assignment itself always succeeds — its target is this
832
+ // loader's own, still extensible `module.exports` — and the alias below then
833
+ // discards the value it wrote. What a consumer reads is whatever the guard put
834
+ // on `nativeBinding`, so on a frozen binding, where the guard skips, the
835
+ // linked import resolves to `undefined`.
836
+ module.exports.__napiBindingTarget = __napiStampBindingTarget(nativeBinding, __napiLoadedBindingTarget)
578
837
  module.exports = nativeBinding
579
838
  module.exports.HashiverseClient = nativeBinding.HashiverseClient
580
839
  module.exports.convertTextToHashiverseHtml = nativeBinding.convertTextToHashiverseHtml
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashiverse/hashiverse-client-nodejs",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "description": "Native Node.js binding for the Hashiverse client — your open-source decentralized X/Twitter replacement.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -25,6 +25,12 @@
25
25
  "engines": {
26
26
  "node": ">=18"
27
27
  },
28
+ "devEngines": {
29
+ "runtime": {
30
+ "name": "node",
31
+ "version": "^22.12.0 || ^24.0.0 || >=26.0.0"
32
+ }
33
+ },
28
34
  "files": [
29
35
  "index.js",
30
36
  "index.d.ts"
@@ -49,14 +55,14 @@
49
55
  "version": "napi version"
50
56
  },
51
57
  "devDependencies": {
52
- "@napi-rs/cli": "^3.0.0",
53
- "vitest": "^2.0.0"
58
+ "@napi-rs/cli": "^3.10.9",
59
+ "vitest": "^5.0.5"
54
60
  },
55
61
  "optionalDependencies": {
56
- "@hashiverse/hashiverse-client-nodejs-linux-x64-gnu": "1.0.8",
57
- "@hashiverse/hashiverse-client-nodejs-linux-arm64-gnu": "1.0.8",
58
- "@hashiverse/hashiverse-client-nodejs-darwin-x64": "1.0.8",
59
- "@hashiverse/hashiverse-client-nodejs-darwin-arm64": "1.0.8",
60
- "@hashiverse/hashiverse-client-nodejs-win32-x64-msvc": "1.0.8"
62
+ "@hashiverse/hashiverse-client-nodejs-linux-x64-gnu": "1.1.0",
63
+ "@hashiverse/hashiverse-client-nodejs-linux-arm64-gnu": "1.1.0",
64
+ "@hashiverse/hashiverse-client-nodejs-darwin-x64": "1.1.0",
65
+ "@hashiverse/hashiverse-client-nodejs-darwin-arm64": "1.1.0",
66
+ "@hashiverse/hashiverse-client-nodejs-win32-x64-msvc": "1.1.0"
61
67
  }
62
- }
68
+ }