|
| 1 | +/* eslint-disable */ |
| 2 | +/* prettier-ignore */ |
| 3 | + |
| 4 | +/* auto-generated by NAPI-RS */ |
| 5 | + |
| 6 | +const __nodeFs= require('node:fs') |
| 7 | +const __nodePath = require('node:path') |
| 8 | +const { WASI: __nodeWASI } = require('node:wasi') |
| 9 | +const { Worker } = require('node:worker_threads') |
| 10 | + |
| 11 | +const { |
| 12 | + instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync, |
| 13 | + getDefaultContext: __emnapiGetDefaultContext, |
| 14 | +} = require('@napi-rs/wasm-runtime') |
| 15 | + |
| 16 | +const __wasi = new __nodeWASI({ |
| 17 | + version: 'preview1', |
| 18 | + env: process.env, |
| 19 | + preopens: { |
| 20 | + '/': '/' |
| 21 | + } |
| 22 | +}) |
| 23 | + |
| 24 | +const __emnapiContext = __emnapiGetDefaultContext() |
| 25 | + |
| 26 | +const __sharedMemory = new WebAssembly.Memory({ |
| 27 | + initial: 1024, |
| 28 | + maximum: 10240, |
| 29 | + shared: true, |
| 30 | +}) |
| 31 | + |
| 32 | +let __wasmFilePath = __nodePath.join(__dirname, 'jsonwebtoken.wasm32-wasi.wasm') |
| 33 | + |
| 34 | +if (!__nodeFs.existsSync(__wasmFilePath)) { |
| 35 | + try { |
| 36 | + __wasmFilePath = __nodePath.resolve('@node-rs/jsonwebtoken-wasm32-wasi') |
| 37 | + } catch { |
| 38 | + throw new Error('Cannot find jsonwebtoken.wasm32-wasi.wasm file, and @node-rs/jsonwebtoken-wasm32-wasi package is not installed.') |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), { |
| 43 | + context: __emnapiContext, |
| 44 | + asyncWorkPoolSize: (function() { |
| 45 | + const threadsSizeFromEnv = Number(process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ?? process.env.UV_THREADPOOL_SIZE) |
| 46 | + // NaN > 0 is false |
| 47 | + if (threadsSizeFromEnv > 0) { |
| 48 | + return threadsSizeFromEnv |
| 49 | + } else { |
| 50 | + return 4 |
| 51 | + } |
| 52 | + })(), |
| 53 | + wasi: __wasi, |
| 54 | + onCreateWorker() { |
| 55 | + return new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), { |
| 56 | + env: process.env, |
| 57 | + execArgv: ['--experimental-wasi-unstable-preview1'], |
| 58 | + }) |
| 59 | + }, |
| 60 | + overwriteImports(importObject) { |
| 61 | + importObject.env = { |
| 62 | + ...importObject.env, |
| 63 | + ...importObject.napi, |
| 64 | + ...importObject.emnapi, |
| 65 | + memory: __sharedMemory, |
| 66 | + } |
| 67 | + return importObject |
| 68 | + }, |
| 69 | + beforeInit({ instance }) { |
| 70 | + __napi_rs_initialize_modules(instance) |
| 71 | + } |
| 72 | +}) |
| 73 | + |
| 74 | +function __napi_rs_initialize_modules(__napiInstance) { |
| 75 | + __napiInstance.exports['__napi_register__Algorithm_0']?.() |
| 76 | + __napiInstance.exports['__napi_register__decode_header_1']?.() |
| 77 | + __napiInstance.exports['__napi_register__Header_struct_2']?.() |
| 78 | + __napiInstance.exports['__napi_register__SignTask_impl_3']?.() |
| 79 | + __napiInstance.exports['__napi_register__sign_4']?.() |
| 80 | + __napiInstance.exports['__napi_register__sign_sync_5']?.() |
| 81 | + __napiInstance.exports['__napi_register__Validation_struct_6']?.() |
| 82 | + __napiInstance.exports['__napi_register__VerifyTask_impl_7']?.() |
| 83 | + __napiInstance.exports['__napi_register__verify_8']?.() |
| 84 | + __napiInstance.exports['__napi_register__verify_sync_9']?.() |
| 85 | +} |
| 86 | +module.exports.Algorithm = __napiModule.exports.Algorithm |
| 87 | +module.exports.decodeHeader = __napiModule.exports.decodeHeader |
| 88 | +module.exports.sign = __napiModule.exports.sign |
| 89 | +module.exports.signSync = __napiModule.exports.signSync |
| 90 | +module.exports.verify = __napiModule.exports.verify |
| 91 | +module.exports.verifySync = __napiModule.exports.verifySync |
0 commit comments