diff --git a/.github/scripts/libmongocrypt.mjs b/.github/scripts/libmongocrypt.mjs index b933ca6..00bb205 100644 --- a/.github/scripts/libmongocrypt.mjs +++ b/.github/scripts/libmongocrypt.mjs @@ -2,7 +2,7 @@ import util from 'node:util'; import process from 'node:process'; -import fs from 'node:fs/promises'; +import fs, { readFile } from 'node:fs/promises'; import child_process from 'node:child_process'; import events from 'node:events'; import path from 'node:path'; @@ -189,9 +189,17 @@ async function buildBindings(args, pkg) { await run('npm', ['run', 'prepare']); if (process.platform === 'darwin' && process.arch === 'arm64') { + // @ts-ignore + const { + binary: { + napi_versions: [ + napiVersion + ] + } + } = JSON.parse(await readFile(resolveRoot('package.json'), 'utf-8')); // The "arm64" build is actually a universal binary - const armTar = `mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-arm64.tar.gz`; - const x64Tar = `mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-x64.tar.gz`; + const armTar = `mongodb-client-encryption-v${pkg.version}-napi-v${napiVersion}-darwin-arm64.tar.gz`; + const x64Tar = `mongodb-client-encryption-v${pkg.version}-napi-v${napiVersion}-darwin-x64.tar.gz`; await fs.copyFile(resolveRoot('prebuilds', armTar), resolveRoot('prebuilds', x64Tar)); } } diff --git a/addon/mongocrypt.h b/addon/mongocrypt.h index 2fa074f..e161c5c 100644 --- a/addon/mongocrypt.h +++ b/addon/mongocrypt.h @@ -1,13 +1,7 @@ #ifndef NODE_MONGOCRYPT_H #define NODE_MONGOCRYPT_H -// We generally only target N-API version 4, but the instance data -// feature is only available in N-API version 6. However, it is -// available in all Node.js versions that have N-API version 4 -// as an experimental feature (that has not been changed since then). -#define NAPI_VERSION 6 -#define NAPI_EXPERIMENTAL -#define NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT +#define NAPI_VERSION 9 #include diff --git a/package-lock.json b/package-lock.json index 1c861b3..af97d5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "node-addon-api": "^4.3.0", + "node-addon-api": "^8.5.0", "prebuild-install": "^7.1.3" }, "devDependencies": { @@ -5157,9 +5157,13 @@ } }, "node_modules/node-addon-api": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.3.0.tgz", - "integrity": "sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==" + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.5.0.tgz", + "integrity": "sha512-/bRZty2mXUIFY/xU5HLvveNHlswNJej+RnxBjOMkidWfwZzgTbPG1E3K5TOxRLOR+5hX7bSofy8yf1hZevMS8A==", + "license": "MIT", + "engines": { + "node": "^18 || ^20 || >= 21" + } }, "node_modules/node-api-headers": { "version": "1.1.0", diff --git a/package.json b/package.json index ffe6f47..7a934fd 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "gypfile": true, "mongodb:libmongocrypt": "1.15.1", "dependencies": { - "node-addon-api": "^4.3.0", + "node-addon-api": "^8.5.0", "prebuild-install": "^7.1.3" }, "devDependencies": { @@ -80,7 +80,7 @@ }, "binary": { "napi_versions": [ - 4 + 9 ] }, "repository": { @@ -96,4 +96,4 @@ "moduleResolution": "node" } } -} \ No newline at end of file +} diff --git a/test/bundling/webpack/install_ce.cjs b/test/bundling/webpack/install_ce.cjs index 57e83fa..1f91987 100644 --- a/test/bundling/webpack/install_ce.cjs +++ b/test/bundling/webpack/install_ce.cjs @@ -1,5 +1,3 @@ -'use strict'; - const { execSync } = require('node:child_process'); const { readFileSync } = require('node:fs'); const { resolve } = require('node:path'); @@ -19,6 +17,6 @@ console.log(`mongodb-client-encryption Version: ${ceVersion}`); xtrace('npm pack --pack-destination test/bundling/webpack', { cwd: ceRoot }); -xtrace(`npm install --no-save mongodb-client-encryption-${ceVersion}.tgz`); +xtrace(`npm install --ignore-scripts --no-save mongodb-client-encryption-${ceVersion}.tgz`); console.log('mongodb-client-encryption installed!');