@nickderobertis/allowlister-remote-plugin 0.2.3

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 ADDED
@@ -0,0 +1,13 @@
1
+ # @nickderobertis/allowlister-remote-plugin
2
+
3
+ Installs the native `allowlister-remote-plugin` binary used by allowlister to
4
+ send dynamic approval requests to the remote approval PWA.
5
+
6
+ ```console
7
+ npm install -g @nickderobertis/allowlister-remote-plugin
8
+ allowlister-remote-plugin --version
9
+ ```
10
+
11
+ Configure allowlister to run `allowlister-remote-plugin --server-url <url>` as a
12
+ dynamic plugin command. The package includes the release-built native binary for
13
+ the current platform.
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from "node:child_process";
4
+ import { existsSync, realpathSync } from "node:fs";
5
+ import { dirname, join } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const supportedPlatforms = new Map([
9
+ ["darwin-arm64", "darwin-arm64/allowlister-remote-plugin"],
10
+ ["linux-x64", "linux-x64/allowlister-remote-plugin"],
11
+ ["win32-x64", "win32-x64/allowlister-remote-plugin.exe"],
12
+ ]);
13
+
14
+ export function nativeBinaryPath(platform = process.platform, arch = process.arch) {
15
+ const relativePath = supportedPlatforms.get(`${platform}-${arch}`);
16
+ if (!relativePath) {
17
+ throw new Error(`Unsupported platform: ${platform}-${arch}`);
18
+ }
19
+
20
+ return join(dirname(fileURLToPath(import.meta.url)), "..", "vendor", relativePath);
21
+ }
22
+
23
+ function main() {
24
+ const binary = nativeBinaryPath();
25
+
26
+ if (!existsSync(binary)) {
27
+ console.error(
28
+ `Missing native allowlister-remote-plugin binary for ${process.platform}-${process.arch}.`,
29
+ );
30
+ process.exit(1);
31
+ }
32
+
33
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
34
+
35
+ if (result.error) {
36
+ console.error(result.error.message);
37
+ process.exit(1);
38
+ }
39
+
40
+ process.exit(result.status ?? 1);
41
+ }
42
+
43
+ function isMainModule() {
44
+ if (!process.argv[1]) {
45
+ return false;
46
+ }
47
+
48
+ return realpathSync(process.argv[1]) === fileURLToPath(import.meta.url);
49
+ }
50
+
51
+ if (isMainModule()) {
52
+ main();
53
+ }
@@ -0,0 +1,15 @@
1
+ import assert from "node:assert/strict";
2
+ import { join } from "node:path";
3
+ import { nativeBinaryPath } from "./allowlister-remote-plugin.js";
4
+
5
+ assert.ok(
6
+ nativeBinaryPath("linux", "x64").endsWith(
7
+ join("vendor", "linux-x64", "allowlister-remote-plugin"),
8
+ ),
9
+ );
10
+ assert.ok(
11
+ nativeBinaryPath("win32", "x64").endsWith(
12
+ join("vendor", "win32-x64", "allowlister-remote-plugin.exe"),
13
+ ),
14
+ );
15
+ assert.throws(() => nativeBinaryPath("sunos", "x64"), /Unsupported platform: sunos-x64/);
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@nickderobertis/allowlister-remote-plugin",
3
+ "version": "0.2.3",
4
+ "description": "npm installer for the allowlister remote dynamic approval plugin",
5
+ "type": "module",
6
+ "license": "UNLICENSED",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/nickderobertis/allowlister-remote.git"
10
+ },
11
+ "bin": {
12
+ "allowlister-remote-plugin": "bin/allowlister-remote-plugin.js"
13
+ },
14
+ "files": [
15
+ "README.md",
16
+ "bin/",
17
+ "vendor/"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public",
21
+ "provenance": true
22
+ },
23
+ "engines": {
24
+ "node": ">=20"
25
+ }
26
+ }