From 6adba1b3a7858ad3dc2cfcac524c47942a7d7109 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Mon, 2 Dec 2024 11:20:02 -0700 Subject: [PATCH 1/3] remove dependency on bindings --- lib/kerberos.js | 10 +++++++++- package-lock.json | 14 -------------- package.json | 3 +-- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/kerberos.js b/lib/kerberos.js index f203d891..2079e318 100644 --- a/lib/kerberos.js +++ b/lib/kerberos.js @@ -1,6 +1,14 @@ 'use strict'; -const kerberos = require('bindings')('kerberos'); +function load() { + try { + return require('../build/Release/kerberos.node'); + } catch { + return require('../build/Debug/kerberos.node'); + } +} + +const kerberos = load(); const KerberosClient = kerberos.KerberosClient; const KerberosServer = kerberos.KerberosServer; const defineOperation = require('./util').defineOperation; diff --git a/package-lock.json b/package-lock.json index cf3a27a9..3309dd1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "bindings": "^1.5.0", "node-addon-api": "^6.1.0", "prebuild-install": "^7.1.2" }, @@ -861,14 +860,6 @@ "node": ">=8" } }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, "node_modules/bl": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.1.tgz", @@ -2272,11 +2263,6 @@ "node": ">=10" } }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", diff --git a/package.json b/package.json index 671e66c7..6f428fc4 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "url": "https://jira.mongodb.org/projects/NODE/issues/" }, "dependencies": { - "bindings": "^1.5.0", "node-addon-api": "^6.1.0", "prebuild-install": "^7.1.2" }, @@ -74,4 +73,4 @@ }, "license": "Apache-2.0", "readmeFilename": "README.md" -} +} \ No newline at end of file From 48da2dea746b45cb237a7c4e73dbde282c51cff5 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Mon, 2 Dec 2024 11:33:31 -0700 Subject: [PATCH 2/3] fix defineOperation tests --- test/defineOperation_tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/defineOperation_tests.js b/test/defineOperation_tests.js index 8c0bad70..b80fe81c 100644 --- a/test/defineOperation_tests.js +++ b/test/defineOperation_tests.js @@ -1,5 +1,5 @@ 'use strict'; -const kerberos = require('bindings')('kerberos'); +const kerberos = require('../lib/kerberos'); const defineOperation = require('../lib/util').defineOperation; const expect = require('chai').expect; @@ -16,7 +16,7 @@ describe('defineOperation', () => { }); it('should validate optional parameters, with valid parameters after', function () { - expect(() => testMethod('llamas', false, true, () => {})).to.throw( + expect(() => testMethod('llamas', false, true, () => { })).to.throw( /Invalid type for parameter `optionalString`/ ); }); From 854548fe273621926170dfee070632878036c885 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Mon, 2 Dec 2024 11:44:30 -0700 Subject: [PATCH 3/3] fix tests --- lib/kerberos.js | 14 ++++---------- lib/util.js | 13 ++++++++++--- test/defineOperation_tests.js | 5 ++++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/kerberos.js b/lib/kerberos.js index 2079e318..b1fdcce7 100644 --- a/lib/kerberos.js +++ b/lib/kerberos.js @@ -1,17 +1,11 @@ 'use strict'; -function load() { - try { - return require('../build/Release/kerberos.node'); - } catch { - return require('../build/Debug/kerberos.node'); - } -} - -const kerberos = load(); +const { loadBindings, defineOperation } = require('./util'); + + +const kerberos = loadBindings(); const KerberosClient = kerberos.KerberosClient; const KerberosServer = kerberos.KerberosServer; -const defineOperation = require('./util').defineOperation; // GSS Flags const GSS_C_DELEG_FLAG = 1; diff --git a/lib/util.js b/lib/util.js index 945c87ff..36042610 100644 --- a/lib/util.js +++ b/lib/util.js @@ -19,8 +19,7 @@ function validateParameter(parameter, specs, specIndex) { } throw new TypeError( - `Invalid type for parameter \`${spec.name}\`, expected \`${ - spec.type + `Invalid type for parameter \`${spec.name}\`, expected \`${spec.type }\` but found \`${typeof parameter}\`` ); } @@ -81,4 +80,12 @@ function defineOperation(fn, paramDefs) { }; } -module.exports = { defineOperation, validateParameter }; +function loadBindings() { + try { + return require('../build/Release/kerberos.node'); + } catch { + return require('../build/Debug/kerberos.node'); + } +} + +module.exports = { defineOperation, validateParameter, loadBindings }; diff --git a/test/defineOperation_tests.js b/test/defineOperation_tests.js index b80fe81c..3ce41cfa 100644 --- a/test/defineOperation_tests.js +++ b/test/defineOperation_tests.js @@ -1,5 +1,8 @@ 'use strict'; -const kerberos = require('../lib/kerberos'); + +const { loadBindings } = require('../lib/util'); + +const kerberos = loadBindings(); const defineOperation = require('../lib/util').defineOperation; const expect = require('chai').expect;