n8n-nodes-browser-cli 0.1.0 → 0.2.2

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 CHANGED
@@ -1,54 +1,59 @@
1
1
  # n8n-nodes-browser-cli
2
-
3
2
  An [n8n](https://n8n.io) community node that controls a **real, visible browser**
4
3
  from your workflows via [browser-cli](https://chromewebstore.google.com/detail/browser-cli/hekaebjhbhhdbmakimmaklbblbmccahp).
5
4
 
6
5
  browser-cli drives a running browser through a native-messaging host and a
7
6
  browser extension — it **cannot be installed inside the n8n container**. So this
8
- node is a thin HTTP client for the `browser-cli serve-http` gateway running on
9
- the machine that actually has the browser. n8n → HTTP → remote gateway → browser.
7
+ node speaks the `browser-cli serve` protocol **directly**: a length-framed TCP
8
+ connection authenticated with an Ed25519 key, with request/response bodies
9
+ encrypted end-to-end via an ML-KEM-768 (post-quantum) key exchange — the same
10
+ wire protocol the `browser-cli --remote` client uses.
10
11
 
11
12
  ```
12
- n8n workflow ──HTTP(S)──▶ browser-cli serve-http (remote host) ──▶ browser
13
+ n8n workflow ──TCP (Ed25519 + ML-KEM-768)──▶ browser-cli serve (remote host) ──▶ browser
13
14
  ```
14
15
 
15
- ## Remote setup (on the browser machine)
16
+ Because the payloads are end-to-end encrypted, the endpoint is safe to expose on
17
+ an untrusted network without a TLS proxy in front of it.
16
18
 
17
- Install and start the gateway where the browser runs, opening exactly the
18
- command tiers you need (it is **safe-only by default**):
19
+ ## Remote setup (on the browser machine)
20
+ Install browser-cli, register the extension, trust your n8n key, then start
21
+ `serve` opening exactly the command tiers you need (it is **safe-only by default**):
19
22
 
20
23
  ```bash
21
24
  uv tool install real-browser-cli
22
25
  browser-cli install brave # one-time: register the extension/native host
23
26
 
24
- # Expose the gateway. Open only what your workflow needs:
25
- browser-cli serve-http --host 0.0.0.0 --port 8766 --allow-read-page --allow-control
26
- ```
27
+ # On the n8n side, generate a client key and print its public key:
28
+ browser-cli auth keygen -o n8n_key.pem
27
29
 
28
- It prints a **token** copy it into the n8n credential.
30
+ # On the browser machine, trust that public key (optionally scope its policy):
31
+ browser-cli auth trust <pubkey-hex> --allow-control
29
32
 
30
- > ⚠️ The gateway speaks **plain HTTP** and sends the token in clear text. Never
31
- > expose it directly on an untrusted network. Put a TLS-terminating reverse
32
- > proxy in front and point the credential **Base URL** at the HTTPS endpoint.
33
+ # Expose the browser. Open only what your workflow needs:
34
+ browser-cli serve --host 0.0.0.0 --port 8765 \
35
+ --authorized-keys ~/.browser_cli/authorized_keys --allow-read-page --allow-control
36
+ ```
33
37
 
34
- ## n8n credential "Browser CLI API"
38
+ Paste the contents of `n8n_key.pem` into the n8n credential.
35
39
 
40
+ ## n8n credential — "Browser CLI API"
36
41
  | Field | Description |
37
42
  |-------|-------------|
38
- | Base URL | `https://browser-host.example` (proxy) or `http://127.0.0.1:8766` (loopback/tunnel) |
39
- | Token | the token printed by `serve-http` (leave empty only for `--no-auth` loopback) |
40
- | Ignore SSL Issues | enable for a self-signed reverse-proxy cert |
41
-
42
- The credential test calls `GET /health`.
43
+ | Host | host of the `serve` endpoint, e.g. `browser-host.example` |
44
+ | Port | `serve` TCP port (default `8765`) |
45
+ | Ed25519 Private Key | PKCS8 PEM from `browser-cli auth keygen` (empty only for `--no-auth` loopback) |
46
+ | Browser Alias | optional `_route` target — required if the endpoint serves multiple browsers |
47
+ | Use TLS | wrap the connection in TLS (only for a TLS-terminating proxy; the protocol is already encrypted) |
48
+ | Ignore SSL Issues | when TLS is on, accept a self-signed proxy cert |
43
49
 
44
50
  ## Operations
51
+ Every operation maps to one raw browser-cli command, each subject to the server
52
+ policy tier noted below.
45
53
 
46
- Every operation maps to one gateway route. Convenience operations are typed
47
- wrappers around `POST /command`, so each needs the matching server policy tier.
48
-
49
- | Resource | Operation | Command / route | Server flag needed |
50
- |----------|-----------|-----------------|--------------------|
51
- | Tab | List | `GET /tabs` | safe (default) |
54
+ | Resource | Operation | Command | Server flag needed |
55
+ |----------|-----------|---------|--------------------|
56
+ | Tab | List | `tabs.list` | safe (default) |
52
57
  | Tab | Open | `navigate.open` | `--allow-control` |
53
58
  | Tab | Close | `tabs.close` (ids / inactive / duplicates) | `--allow-control` |
54
59
  | Tab | Get HTML | `tabs.html` | `--allow-read-page` |
@@ -57,25 +62,24 @@ wrappers around `POST /command`, so each needs the matching server policy tier.
57
62
  | DOM | Query | `dom.query` | `--allow-read-page` |
58
63
  | DOM | Click / Type | `dom.click` / `dom.type` | `--allow-control` |
59
64
  | DOM | Eval | `dom.eval` | `--allow-dangerous` |
60
- | Client | List | `GET /clients` | safe (default) |
61
- | Command | Execute | `POST /command` (raw command + JSON args) | per command |
62
- | Gateway | Health | `GET /health` | none |
65
+ | Client | List | `clients.list` | safe (default) |
66
+ | Command | Execute | any command name + JSON args | per command |
67
+ | Gateway | Health | pings with `tabs.list` | safe (default) |
63
68
 
64
- **Command → Execute** is the escape hatch: any command string the gateway's
65
- policy allows (`tabs.query`, `session.save`, `windows.list`, …) with a JSON args
66
- object. Use it for anything the typed operations don't cover.
69
+ **Command → Execute** is the escape hatch: any command string the server policy
70
+ allows (`tabs.query`, `session.save`, `windows.list`, …) with a JSON args object.
71
+ Use it for anything the typed operations don't cover.
67
72
 
68
- > Note: the gateway returns the **raw** command result (no SDK post-processing).
73
+ > Note: `serve` returns the **raw** command result (no SDK post-processing).
69
74
  > `extract.markdown` therefore returns the page payload as the extension hands it
70
75
  > back, not the CLI's rendered Markdown. For clean text use **Extract Text**.
71
76
 
72
77
  ## Develop / build
73
-
74
78
  ```bash
75
79
  cd n8n-nodes-browser-cli
76
80
  npm install # add --ignore-scripts if a transitive native dep
77
81
  # (isolated-vm) fails to compile on your Node version
78
- npm test # pure request-mapping unit tests (node:test + esbuild)
82
+ npm test # pure unit tests: command mapping + crypto known-answer vectors
79
83
  npm run build # tsc -> dist/, copies the icon
80
84
  ```
81
85
 
@@ -83,5 +87,4 @@ Then install into n8n as a [community node](https://docs.n8n.io/integrations/com
83
87
  (`n8n-nodes-browser-cli`), or symlink `dist/` into `~/.n8n/custom` for local testing.
84
88
 
85
89
  ## License
86
-
87
90
  PolyForm Noncommercial License 1.0.0 — same as browser-cli.
@@ -1,21 +1,24 @@
1
- import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
1
+ import type { ICredentialType, INodeProperties } from 'n8n-workflow';
2
2
  /**
3
- * Credentials for a remote `browser-cli serve-http` gateway.
3
+ * Credentials for a raw `browser-cli serve` endpoint.
4
4
  *
5
- * browser-cli cannot be installed inside n8n, so the node talks to a gateway
6
- * running on the machine that actually drives the browser. Start it there with:
5
+ * browser-cli cannot be installed inside n8n, so the node talks directly to a
6
+ * `serve` instance running on the machine that drives the browser. Start it
7
+ * there and trust this client's key:
7
8
  *
8
- * browser-cli serve-http --host 0.0.0.0 --port 8766 --allow-read-page --allow-control
9
+ * browser-cli auth keygen # on the n8n side, prints a PEM
10
+ * browser-cli auth trust <pubkey> --allow-control # on the serve side
11
+ * browser-cli serve --host 0.0.0.0 --port 8765 --authorized-keys ~/.browser_cli/authorized_keys
9
12
  *
10
- * The token it prints goes into this credential. The gateway speaks plain HTTP
11
- * and sends the token in clear text, so expose it only behind a TLS-terminating
12
- * reverse proxy and point the Base URL at the HTTPS endpoint.
13
+ * The connection is authenticated with the Ed25519 private key below and the
14
+ * request/response bodies are encrypted with an ML-KEM-768 (post-quantum) key
15
+ * exchange, so it is safe to expose over an untrusted network without TLS.
16
+ * Leave the key empty only for a loopback `serve --no-auth` instance.
13
17
  */
14
18
  export declare class BrowserCliApi implements ICredentialType {
15
19
  name: string;
16
20
  displayName: string;
17
21
  documentationUrl: string;
22
+ testedBy: string;
18
23
  properties: INodeProperties[];
19
- authenticate: IAuthenticateGeneric;
20
- test: ICredentialTestRequest;
21
24
  }
@@ -2,63 +2,81 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BrowserCliApi = void 0;
4
4
  /**
5
- * Credentials for a remote `browser-cli serve-http` gateway.
5
+ * Credentials for a raw `browser-cli serve` endpoint.
6
6
  *
7
- * browser-cli cannot be installed inside n8n, so the node talks to a gateway
8
- * running on the machine that actually drives the browser. Start it there with:
7
+ * browser-cli cannot be installed inside n8n, so the node talks directly to a
8
+ * `serve` instance running on the machine that drives the browser. Start it
9
+ * there and trust this client's key:
9
10
  *
10
- * browser-cli serve-http --host 0.0.0.0 --port 8766 --allow-read-page --allow-control
11
+ * browser-cli auth keygen # on the n8n side, prints a PEM
12
+ * browser-cli auth trust <pubkey> --allow-control # on the serve side
13
+ * browser-cli serve --host 0.0.0.0 --port 8765 --authorized-keys ~/.browser_cli/authorized_keys
11
14
  *
12
- * The token it prints goes into this credential. The gateway speaks plain HTTP
13
- * and sends the token in clear text, so expose it only behind a TLS-terminating
14
- * reverse proxy and point the Base URL at the HTTPS endpoint.
15
+ * The connection is authenticated with the Ed25519 private key below and the
16
+ * request/response bodies are encrypted with an ML-KEM-768 (post-quantum) key
17
+ * exchange, so it is safe to expose over an untrusted network without TLS.
18
+ * Leave the key empty only for a loopback `serve --no-auth` instance.
15
19
  */
16
20
  class BrowserCliApi {
17
21
  constructor() {
18
22
  this.name = 'browserCliApi';
19
23
  this.displayName = 'Browser CLI API';
20
24
  this.documentationUrl = 'https://chromewebstore.google.com/detail/browser-cli/hekaebjhbhhdbmakimmaklbblbmccahp';
25
+ // The serve protocol is raw TCP, not HTTP, so the declarative HTTP test does
26
+ // not apply — testing is done by the node method of this name, which runs a
27
+ // real authenticated handshake against the endpoint.
28
+ this.testedBy = 'browserCliApiTest';
21
29
  this.properties = [
22
30
  {
23
- displayName: 'Base URL',
24
- name: 'baseUrl',
31
+ displayName: 'Host',
32
+ name: 'host',
25
33
  type: 'string',
26
- default: 'http://127.0.0.1:8766',
27
- placeholder: 'https://browser-host.example',
34
+ default: '127.0.0.1',
35
+ placeholder: 'browser-host.example',
28
36
  required: true,
29
- description: 'Base URL of the remote browser-cli serve-http gateway. Prefer an HTTPS endpoint behind a reverse proxy — the gateway itself is plain HTTP.',
37
+ description: 'Host of the remote `browser-cli serve` endpoint',
30
38
  },
31
39
  {
32
- displayName: 'Token',
33
- name: 'token',
40
+ displayName: 'Port',
41
+ name: 'port',
42
+ type: 'number',
43
+ default: 8765,
44
+ required: true,
45
+ description: 'TCP port the `serve` endpoint listens on',
46
+ },
47
+ {
48
+ displayName: 'Ed25519 Private Key',
49
+ name: 'privateKey',
50
+ type: 'string',
51
+ typeOptions: { password: true, rows: 4 },
52
+ default: '',
53
+ placeholder: '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----',
54
+ description: 'PKCS8 PEM Ed25519 private key (from `browser-cli auth keygen`) whose public key is trusted by the serve endpoint. Leave empty only for a loopback `serve --no-auth` instance.',
55
+ },
56
+ {
57
+ displayName: 'Browser Alias',
58
+ name: 'browser',
34
59
  type: 'string',
35
- typeOptions: { password: true },
36
60
  default: '',
37
- description: 'Bearer token printed by `browser-cli serve-http`. Leave empty only for a `--no-auth` loopback gateway.',
61
+ placeholder: 'main',
62
+ description: 'Optional browser alias to route to (the serve `_route` target). Required when the serve endpoint exposes multiple browser instances; leave empty for a single-browser serve.',
63
+ },
64
+ {
65
+ displayName: 'Use TLS',
66
+ name: 'tls',
67
+ type: 'boolean',
68
+ default: false,
69
+ description: 'Whether to wrap the connection in TLS. Only needed when `serve` sits behind a TLS-terminating proxy; the protocol is already end-to-end encrypted via post-quantum key exchange.',
38
70
  },
39
71
  {
40
72
  displayName: 'Ignore SSL Issues',
41
73
  name: 'allowUnauthorizedCerts',
42
74
  type: 'boolean',
43
75
  default: false,
44
- description: 'Whether to connect even when the TLS certificate cannot be verified (e.g. a self-signed reverse proxy).',
76
+ displayOptions: { show: { tls: [true] } },
77
+ description: 'Whether to connect even when the TLS certificate cannot be verified (e.g. a self-signed proxy)',
45
78
  },
46
79
  ];
47
- this.authenticate = {
48
- type: 'generic',
49
- properties: {
50
- headers: {
51
- Authorization: '=Bearer {{$credentials.token}}',
52
- },
53
- },
54
- };
55
- this.test = {
56
- request: {
57
- baseURL: '={{$credentials.baseUrl}}',
58
- url: '/health',
59
- skipSslCertificateValidation: '={{$credentials.allowUnauthorizedCerts}}',
60
- },
61
- };
62
80
  }
63
81
  }
64
82
  exports.BrowserCliApi = BrowserCliApi;
@@ -1 +1 @@
1
- {"version":3,"file":"BrowserCliApi.credentials.js","sourceRoot":"","sources":["../../credentials/BrowserCliApi.credentials.ts"],"names":[],"mappings":";;;AAOA;;;;;;;;;;;GAWG;AACH,MAAa,aAAa;IAA1B;QACE,SAAI,GAAG,eAAe,CAAC;QAEvB,gBAAW,GAAG,iBAAiB,CAAC;QAEhC,qBAAgB,GAAG,uFAAuF,CAAC;QAE3G,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,uBAAuB;gBAChC,WAAW,EAAE,8BAA8B;gBAC3C,QAAQ,EAAE,IAAI;gBACd,WAAW,EACT,4IAA4I;aAC/I;YACD;gBACE,WAAW,EAAE,OAAO;gBACpB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,WAAW,EACT,wGAAwG;aAC3G;YACD;gBACE,WAAW,EAAE,mBAAmB;gBAChC,IAAI,EAAE,wBAAwB;gBAC9B,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,KAAK;gBACd,WAAW,EAAE,yGAAyG;aACvH;SACF,CAAC;QAEF,iBAAY,GAAyB;YACnC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,aAAa,EAAE,gCAAgC;iBAChD;aACF;SACF,CAAC;QAEF,SAAI,GAA2B;YAC7B,OAAO,EAAE;gBACP,OAAO,EAAE,2BAA2B;gBACpC,GAAG,EAAE,SAAS;gBACd,4BAA4B,EAAE,0CAA0C;aACzE;SACF,CAAC;IACJ,CAAC;CAAA;AApDD,sCAoDC"}
1
+ {"version":3,"file":"BrowserCliApi.credentials.js","sourceRoot":"","sources":["../../credentials/BrowserCliApi.credentials.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAa,aAAa;IAA1B;QACE,SAAI,GAAG,eAAe,CAAC;QAEvB,gBAAW,GAAG,iBAAiB,CAAC;QAEhC,qBAAgB,GAAG,uFAAuF,CAAC;QAE3G,6EAA6E;QAC7E,4EAA4E;QAC5E,qDAAqD;QACrD,aAAQ,GAAG,mBAAmB,CAAC;QAE/B,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,MAAM;gBACnB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,WAAW;gBACpB,WAAW,EAAE,sBAAsB;gBACnC,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,iDAAiD;aAC/D;YACD;gBACE,WAAW,EAAE,MAAM;gBACnB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,0CAA0C;aACxD;YACD;gBACE,WAAW,EAAE,qBAAqB;gBAClC,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE;gBACxC,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,6DAA6D;gBAC1E,WAAW,EACT,+KAA+K;aAClL;YACD;gBACE,WAAW,EAAE,eAAe;gBAC5B,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,MAAM;gBACnB,WAAW,EACT,8KAA8K;aACjL;YACD;gBACE,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,KAAK;gBACd,WAAW,EACT,kLAAkL;aACrL;YACD;gBACE,WAAW,EAAE,mBAAmB;gBAChC,IAAI,EAAE,wBAAwB;gBAC9B,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,KAAK;gBACd,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE;gBACzC,WAAW,EAAE,gGAAgG;aAC9G;SACF,CAAC;IACJ,CAAC;CAAA;AAlED,sCAkEC"}
@@ -1,5 +1,10 @@
1
- import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
1
+ import type { ICredentialsDecrypted, ICredentialTestFunctions, IExecuteFunctions, INodeCredentialTestResult, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
2
  export declare class BrowserCli implements INodeType {
3
3
  description: INodeTypeDescription;
4
+ methods: {
5
+ credentialTest: {
6
+ browserCliApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<INodeCredentialTestResult>;
7
+ };
8
+ };
4
9
  execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
10
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BrowserCli = void 0;
4
4
  const n8n_workflow_1 = require("n8n-workflow");
5
5
  const request_1 = require("./request");
6
+ const serveClient_1 = require("./serveClient");
6
7
  /** Only show a property for the given resource/operation combinations. */
7
8
  function showFor(resource, operations) {
8
9
  return { resource: [resource], operation: operations };
@@ -16,7 +17,7 @@ class BrowserCli {
16
17
  group: ['transform'],
17
18
  version: 1,
18
19
  subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
19
- description: 'Control a remote browser through a browser-cli serve-http gateway',
20
+ description: 'Control a remote browser by talking directly to a browser-cli serve endpoint',
20
21
  defaults: { name: 'Browser CLI' },
21
22
  inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
22
23
  outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
@@ -46,7 +47,7 @@ class BrowserCli {
46
47
  noDataExpression: true,
47
48
  displayOptions: { show: { resource: ['tab'] } },
48
49
  options: [
49
- { name: 'List', value: 'list', action: 'List open tabs', description: 'GET /tabs (safe)' },
50
+ { name: 'List', value: 'list', action: 'List open tabs', description: 'tabs.list (safe)' },
50
51
  { name: 'Open', value: 'open', action: 'Open a URL in a new tab', description: 'navigate.open (needs --allow-control)' },
51
52
  { name: 'Close', value: 'close', action: 'Close tabs', description: 'tabs.close (needs --allow-control)' },
52
53
  { name: 'Get HTML', value: 'getHtml', action: 'Get a tab raw HTML', description: 'tabs.html (needs --allow-read-page)' },
@@ -93,7 +94,7 @@ class BrowserCli {
93
94
  noDataExpression: true,
94
95
  displayOptions: { show: { resource: ['client'] } },
95
96
  options: [
96
- { name: 'List', value: 'list', action: 'List connected browser clients', description: 'GET /clients (safe)' },
97
+ { name: 'List', value: 'list', action: 'List connected browser clients', description: 'clients.list (safe)' },
97
98
  ],
98
99
  default: 'list',
99
100
  },
@@ -105,7 +106,7 @@ class BrowserCli {
105
106
  noDataExpression: true,
106
107
  displayOptions: { show: { resource: ['command'] } },
107
108
  options: [
108
- { name: 'Execute', value: 'execute', action: 'Execute a raw browser-cli command', description: 'POST /command (subject to server policy)' },
109
+ { name: 'Execute', value: 'execute', action: 'Execute a raw browser-cli command', description: 'Any command name (subject to server policy)' },
109
110
  ],
110
111
  default: 'execute',
111
112
  },
@@ -117,7 +118,7 @@ class BrowserCli {
117
118
  noDataExpression: true,
118
119
  displayOptions: { show: { resource: ['gateway'] } },
119
120
  options: [
120
- { name: 'Health', value: 'health', action: 'Check gateway health', description: 'GET /health (ungated)' },
121
+ { name: 'Health', value: 'health', action: 'Check serve connectivity', description: 'Pings the endpoint with tabs.list (safe)' },
121
122
  ],
122
123
  default: 'health',
123
124
  },
@@ -229,26 +230,49 @@ class BrowserCli {
229
230
  },
230
231
  ],
231
232
  };
233
+ this.methods = {
234
+ credentialTest: {
235
+ // Runs a real authenticated handshake so "Test" in the credential UI
236
+ // reflects the actual serve protocol, not a stand-in HTTP request.
237
+ async browserCliApiTest(credential) {
238
+ const options = connectOptionsFromCredentials((credential.data ?? {}));
239
+ options.timeoutMs = 10_000;
240
+ try {
241
+ const response = await (0, serveClient_1.sendServeCommand)(options, 'clients.list', {});
242
+ if (response && response.success === false) {
243
+ const message = String(response.error ?? 'serve returned an error');
244
+ // A rejected key is a real credential failure; any other server-side
245
+ // message means the handshake + auth already succeeded.
246
+ if (/unauthorized|untrusted|invalid signature|pubkey auth required/i.test(message)) {
247
+ return { status: 'Error', message };
248
+ }
249
+ return { status: 'OK', message: `Connected and authenticated. Note: ${message.split('\n')[0]}` };
250
+ }
251
+ return { status: 'OK', message: 'Connected to browser-cli serve' };
252
+ }
253
+ catch (error) {
254
+ return { status: 'Error', message: error.message };
255
+ }
256
+ },
257
+ },
258
+ };
232
259
  }
233
260
  async execute() {
234
261
  const items = this.getInputData();
235
262
  const returnData = [];
236
- const baseUrl = String((await this.getCredentials('browserCliApi')).baseUrl || '').replace(/\/+$/, '');
263
+ const connectOptions = connectOptionsFromCredentials((await this.getCredentials('browserCliApi')));
237
264
  for (let i = 0; i < items.length; i++) {
238
265
  try {
239
266
  const resource = this.getNodeParameter('resource', i);
240
267
  const operation = this.getNodeParameter('operation', i);
241
268
  const params = collectParams(this, resource, operation, i);
242
- const request = (0, request_1.buildGatewayRequest)(resource, operation, params);
243
- const options = {
244
- method: request.method,
245
- url: `${baseUrl}${request.path}`,
246
- json: true,
247
- };
248
- if (request.body)
249
- options.body = request.body;
250
- const response = await this.helpers.httpRequestWithAuthentication.call(this, 'browserCliApi', options);
251
- const rows = Array.isArray(response) ? response : [response];
269
+ const { command, args } = (0, request_1.buildCommand)(resource, operation, params);
270
+ const response = await (0, serveClient_1.sendServeCommand)(connectOptions, command, args);
271
+ if (response && response.success === false) {
272
+ throw new Error(String(response.error || 'serve command failed'));
273
+ }
274
+ const data = response && typeof response === 'object' && 'data' in response ? response.data : response;
275
+ const rows = Array.isArray(data) ? data : [data];
252
276
  for (const row of rows) {
253
277
  returnData.push({
254
278
  json: isObject(row) ? row : { result: row },
@@ -271,6 +295,17 @@ exports.BrowserCli = BrowserCli;
271
295
  function isObject(value) {
272
296
  return typeof value === 'object' && value !== null;
273
297
  }
298
+ /** Map decrypted credential fields to serve connection options. */
299
+ function connectOptionsFromCredentials(creds) {
300
+ return {
301
+ host: String(creds.host || '127.0.0.1'),
302
+ port: Number(creds.port || 8765),
303
+ tls: Boolean(creds.tls),
304
+ rejectUnauthorized: !creds.allowUnauthorizedCerts,
305
+ privateKeyPem: creds.privateKey ? String(creds.privateKey) : null,
306
+ route: creds.browser ? String(creds.browser) : null,
307
+ };
308
+ }
274
309
  /** Read the UI fields relevant to this operation into a plain params object. */
275
310
  function collectParams(ctx, resource, operation, i) {
276
311
  const get = (name, fallback = undefined) => ctx.getNodeParameter(name, i, fallback);
@@ -1 +1 @@
1
- {"version":3,"file":"BrowserCli.node.js","sourceRoot":"","sources":["../../../nodes/BrowserCli/BrowserCli.node.ts"],"names":[],"mappings":";;;AASA,+CAAuE;AAEvE,uCAAoE;AAEpE,0EAA0E;AAC1E,SAAS,OAAO,CAAC,QAAgB,EAAE,UAAoB;IACrD,OAAO,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AACzD,CAAC;AAED,MAAa,UAAU;IAAvB;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,aAAa;YAC1B,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,qBAAqB;YAC3B,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,mEAAmE;YAChF,QAAQ,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;YACjC,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAA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MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC;QACjE,KAAK,aAAa;YAChB,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC;QACpC,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW;YACd,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC;QAC3C,KAAK,UAAU;YACb,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAClE,KAAK,UAAU;YACb,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC;QAC3D,KAAK,kBAAkB,CAAC;QACxB,KAAK,mBAAmB,CAAC;QACzB,KAAK,oBAAoB,CAAC;QAC1B,KAAK,kBAAkB,CAAC;QACxB,KAAK,sBAAsB;YACzB,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC;QAC3C;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Pure protocol + crypto for talking to a raw `browser-cli serve` endpoint.
3
+ *
4
+ * This module imports nothing from n8n and only touches Node's `crypto` plus a
5
+ * lazily-loaded ML-KEM implementation, so it can be unit-tested with a plain
6
+ * esbuild/node toolchain. The socket mechanics live in `serveClient.ts`.
7
+ *
8
+ * The wire protocol mirrors the Python client in `browser_cli/remote` and
9
+ * `browser_cli/auth`:
10
+ *
11
+ * 1. Server sends a framed `challenge` JSON: {nonce, min_client_version, pq_kex?}.
12
+ * 2. Client replies with one framed message. With a private key this is an
13
+ * Ed25519 signature over `nonce + sha256(canonical_json(msg))`, optionally
14
+ * bound to an ML-KEM-768 shared secret. When the server offers `pq_kex`
15
+ * (it always does once authorized_keys is set) the request body is also
16
+ * ChaCha20-Poly1305 encrypted under that secret.
17
+ * 3. Server replies with one framed payload, encrypted the same way.
18
+ *
19
+ * Every value the client signs must serialize byte-for-byte like Python's
20
+ * `json.dumps(sort_keys=True, separators=(",", ":"))` with `ensure_ascii=True`
21
+ * or the signature is rejected — see `canonicalJson` and `protocol.test.ts`.
22
+ */
23
+ import { type KeyObject } from 'node:crypto';
24
+ export declare const PQ_KEX_ALG = "ML-KEM-768";
25
+ export declare const PQ_TRANSPORT_ALG = "ML-KEM-768+ChaCha20Poly1305";
26
+ /** Prefix `payload` with browser-cli's 4-byte little-endian length header. */
27
+ export declare function frame(payload: Buffer): Buffer;
28
+ /** Deterministic JSON string identical to the Python signing canonicalization. */
29
+ export declare function canonicalJson(value: unknown): string;
30
+ /**
31
+ * Load a PKCS8 PEM Ed25519 private key, tolerating the two ways credential
32
+ * stores mangle it: surrounding whitespace and newlines escaped to literal `\n`.
33
+ */
34
+ export declare function loadPrivateKey(privatePem: string): KeyObject;
35
+ /** Raw 32-byte Ed25519 public key (hex) derived from a PKCS8 PEM private key. */
36
+ export declare function ed25519PublicKeyHex(privatePem: string): string;
37
+ /** Bytes signed for auth: nonce + sha256(canonical) [+ sha256(label + secret)]. */
38
+ export declare function authMessage(nonceHex: string, msg: Record<string, unknown>, pqSecret: Buffer | null): Buffer;
39
+ /** Ed25519 signature (hex) over the canonical auth payload. */
40
+ export declare function signAuth(privatePem: string, nonceHex: string, msg: Record<string, unknown>, pqSecret: Buffer | null): string;
41
+ /** Encapsulate to the server's ML-KEM public key. Returns (ciphertext hex, secret). */
42
+ export declare function pqEncapsulate(serverPublicKeyHex: string): Promise<{
43
+ ciphertextHex: string;
44
+ secret: Buffer;
45
+ }>;
46
+ /** HKDF-SHA256 with a 32-zero-byte salt (Python `salt=None`) and the given info. */
47
+ export declare function pqTransportKey(secret: Buffer, direction: string): Buffer;
48
+ export interface PqEnvelope {
49
+ alg?: string;
50
+ nonce: string;
51
+ ciphertext: string;
52
+ }
53
+ /** ChaCha20-Poly1305 encrypt an app-layer frame (ciphertext field is ct||tag). */
54
+ export declare function pqEncrypt(secret: Buffer, direction: string, plaintext: Buffer): PqEnvelope;
55
+ /** Inverse of {@link pqEncrypt}. */
56
+ export declare function pqDecrypt(secret: Buffer, direction: string, envelope: PqEnvelope): Buffer;
57
+ export interface Challenge {
58
+ type?: string;
59
+ nonce?: string;
60
+ min_client_version?: string;
61
+ pq_kex?: {
62
+ alg?: string;
63
+ public_key?: string;
64
+ };
65
+ }
66
+ export interface AuthPayload {
67
+ payload: Record<string, unknown>;
68
+ pqSecret: Buffer | null;
69
+ }
70
+ /**
71
+ * Build the single framed message a client sends in response to the challenge.
72
+ * Mirrors `browser_cli.remote.auth.build_auth_message` + `signed_payload`.
73
+ */
74
+ export declare function buildAuthPayload(baseMsg: Record<string, unknown>, challenge: Challenge, privatePem: string | null): Promise<AuthPayload>;
75
+ /** Decode a framed server response, decrypting the PQ envelope when present. */
76
+ export declare function decodeResponse(raw: Buffer, pqSecret: Buffer | null): any;
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PQ_TRANSPORT_ALG = exports.PQ_KEX_ALG = void 0;
4
+ exports.frame = frame;
5
+ exports.canonicalJson = canonicalJson;
6
+ exports.loadPrivateKey = loadPrivateKey;
7
+ exports.ed25519PublicKeyHex = ed25519PublicKeyHex;
8
+ exports.authMessage = authMessage;
9
+ exports.signAuth = signAuth;
10
+ exports.pqEncapsulate = pqEncapsulate;
11
+ exports.pqTransportKey = pqTransportKey;
12
+ exports.pqEncrypt = pqEncrypt;
13
+ exports.pqDecrypt = pqDecrypt;
14
+ exports.buildAuthPayload = buildAuthPayload;
15
+ exports.decodeResponse = decodeResponse;
16
+ /**
17
+ * Pure protocol + crypto for talking to a raw `browser-cli serve` endpoint.
18
+ *
19
+ * This module imports nothing from n8n and only touches Node's `crypto` plus a
20
+ * lazily-loaded ML-KEM implementation, so it can be unit-tested with a plain
21
+ * esbuild/node toolchain. The socket mechanics live in `serveClient.ts`.
22
+ *
23
+ * The wire protocol mirrors the Python client in `browser_cli/remote` and
24
+ * `browser_cli/auth`:
25
+ *
26
+ * 1. Server sends a framed `challenge` JSON: {nonce, min_client_version, pq_kex?}.
27
+ * 2. Client replies with one framed message. With a private key this is an
28
+ * Ed25519 signature over `nonce + sha256(canonical_json(msg))`, optionally
29
+ * bound to an ML-KEM-768 shared secret. When the server offers `pq_kex`
30
+ * (it always does once authorized_keys is set) the request body is also
31
+ * ChaCha20-Poly1305 encrypted under that secret.
32
+ * 3. Server replies with one framed payload, encrypted the same way.
33
+ *
34
+ * Every value the client signs must serialize byte-for-byte like Python's
35
+ * `json.dumps(sort_keys=True, separators=(",", ":"))` with `ensure_ascii=True`
36
+ * or the signature is rejected — see `canonicalJson` and `protocol.test.ts`.
37
+ */
38
+ const node_crypto_1 = require("node:crypto");
39
+ exports.PQ_KEX_ALG = 'ML-KEM-768';
40
+ exports.PQ_TRANSPORT_ALG = 'ML-KEM-768+ChaCha20Poly1305';
41
+ /** Auth-protocol fields that are never part of the signed canonical payload. */
42
+ const AUTH_FIELDS = new Set(['pubkey', 'sig', 'pq_kex', 'encrypted']);
43
+ // --- Framing ---------------------------------------------------------------
44
+ /** Prefix `payload` with browser-cli's 4-byte little-endian length header. */
45
+ function frame(payload) {
46
+ const header = Buffer.allocUnsafe(4);
47
+ header.writeUInt32LE(payload.length, 0);
48
+ return Buffer.concat([header, payload]);
49
+ }
50
+ // --- Canonical JSON (matches Python json.dumps sort_keys + ensure_ascii) ----
51
+ /** Deterministic JSON string identical to the Python signing canonicalization. */
52
+ function canonicalJson(value) {
53
+ return encode(value);
54
+ }
55
+ function encode(value) {
56
+ if (value === null)
57
+ return 'null';
58
+ const type = typeof value;
59
+ if (type === 'string')
60
+ return encodeString(value);
61
+ if (type === 'boolean')
62
+ return value ? 'true' : 'false';
63
+ if (type === 'number') {
64
+ const n = value;
65
+ if (!Number.isFinite(n))
66
+ throw new Error('cannot encode non-finite number');
67
+ // Integers match Python exactly; non-integers are rare in args and fall
68
+ // back to JS formatting (documented limitation, see protocol.test.ts).
69
+ return Number.isInteger(n) ? String(n) : JSON.stringify(n);
70
+ }
71
+ if (Array.isArray(value))
72
+ return '[' + value.map(encode).join(',') + ']';
73
+ if (type === 'object') {
74
+ const obj = value;
75
+ const keys = Object.keys(obj)
76
+ .filter((key) => obj[key] !== undefined)
77
+ .sort();
78
+ return '{' + keys.map((key) => encodeString(key) + ':' + encode(obj[key])).join(',') + '}';
79
+ }
80
+ throw new Error(`cannot encode value of type ${type} in canonical JSON`);
81
+ }
82
+ /** JSON-encode a string and escape every non-ASCII char as \uXXXX, like Python. */
83
+ function encodeString(str) {
84
+ return JSON.stringify(str).replace(/[€-￿]/g, (char) => '\\u' + char.charCodeAt(0).toString(16).padStart(4, '0'));
85
+ }
86
+ // --- Ed25519 ---------------------------------------------------------------
87
+ /**
88
+ * Load a PKCS8 PEM Ed25519 private key, tolerating the two ways credential
89
+ * stores mangle it: surrounding whitespace and newlines escaped to literal `\n`.
90
+ */
91
+ function loadPrivateKey(privatePem) {
92
+ let pem = (privatePem || '').trim();
93
+ // Restore real newlines if the PEM was stored with escaped ones.
94
+ if (pem.includes('\\n') && !pem.includes('\n'))
95
+ pem = pem.replace(/\\n/g, '\n');
96
+ try {
97
+ return (0, node_crypto_1.createPrivateKey)(pem);
98
+ }
99
+ catch (err) {
100
+ throw new Error('Invalid Ed25519 private key: expected a PKCS8 PEM block ' +
101
+ '("-----BEGIN PRIVATE KEY-----"), e.g. the file from `browser-cli auth keygen`. ' +
102
+ `(${err.message})`);
103
+ }
104
+ }
105
+ /** Raw 32-byte Ed25519 public key (hex) derived from a PKCS8 PEM private key. */
106
+ function ed25519PublicKeyHex(privatePem) {
107
+ const publicKey = (0, node_crypto_1.createPublicKey)(loadPrivateKey(privatePem));
108
+ const jwk = publicKey.export({ format: 'jwk' });
109
+ if (!jwk.x)
110
+ throw new Error('private key is not an Ed25519 key');
111
+ return Buffer.from(jwk.x, 'base64url').toString('hex');
112
+ }
113
+ /** Bytes signed for auth: nonce + sha256(canonical) [+ sha256(label + secret)]. */
114
+ function authMessage(nonceHex, msg, pqSecret) {
115
+ const nonce = Buffer.from(nonceHex, 'hex');
116
+ const canonical = (0, node_crypto_1.createHash)('sha256').update(canonicalJson(stripAuthFields(msg)), 'utf8').digest();
117
+ let data = Buffer.concat([nonce, canonical]);
118
+ if (pqSecret) {
119
+ const bound = (0, node_crypto_1.createHash)('sha256')
120
+ .update(Buffer.concat([Buffer.from('browser-cli ml-kem-768 v1', 'ascii'), pqSecret]))
121
+ .digest();
122
+ data = Buffer.concat([data, bound]);
123
+ }
124
+ return data;
125
+ }
126
+ /** Ed25519 signature (hex) over the canonical auth payload. */
127
+ function signAuth(privatePem, nonceHex, msg, pqSecret) {
128
+ return (0, node_crypto_1.sign)(null, authMessage(nonceHex, msg, pqSecret), loadPrivateKey(privatePem)).toString('hex');
129
+ }
130
+ function stripAuthFields(msg) {
131
+ const out = {};
132
+ for (const [key, value] of Object.entries(msg)) {
133
+ if (!AUTH_FIELDS.has(key))
134
+ out[key] = value;
135
+ }
136
+ return out;
137
+ }
138
+ // --- ML-KEM-768 transport encryption ---------------------------------------
139
+ // Node has no native ML-KEM, so load @noble/post-quantum at runtime. The
140
+ // indirection through `Function` keeps a real dynamic `import()` even after
141
+ // TypeScript downlevels this module to CommonJS (a plain `import()` would be
142
+ // rewritten to `require()` and fail on the ESM-only package).
143
+ const importEsm = new Function('specifier', 'return import(specifier)');
144
+ let mlkemPromise = null;
145
+ async function mlKem768() {
146
+ if (!mlkemPromise) {
147
+ mlkemPromise = importEsm('@noble/post-quantum/ml-kem.js').then((mod) => mod.ml_kem768);
148
+ }
149
+ return mlkemPromise;
150
+ }
151
+ /** Encapsulate to the server's ML-KEM public key. Returns (ciphertext hex, secret). */
152
+ async function pqEncapsulate(serverPublicKeyHex) {
153
+ const ml = await mlKem768();
154
+ const { cipherText, sharedSecret } = ml.encapsulate(Buffer.from(serverPublicKeyHex, 'hex'));
155
+ return { ciphertextHex: Buffer.from(cipherText).toString('hex'), secret: Buffer.from(sharedSecret) };
156
+ }
157
+ /** HKDF-SHA256 with a 32-zero-byte salt (Python `salt=None`) and the given info. */
158
+ function pqTransportKey(secret, direction) {
159
+ const salt = Buffer.alloc(32, 0);
160
+ const prk = (0, node_crypto_1.createHmac)('sha256', salt).update(secret).digest();
161
+ const info = Buffer.concat([Buffer.from(`browser-cli pq transport v1 ${direction}`, 'ascii'), Buffer.from([1])]);
162
+ return (0, node_crypto_1.createHmac)('sha256', prk).update(info).digest().subarray(0, 32);
163
+ }
164
+ /** ChaCha20-Poly1305 encrypt an app-layer frame (ciphertext field is ct||tag). */
165
+ function pqEncrypt(secret, direction, plaintext) {
166
+ const key = pqTransportKey(secret, direction);
167
+ const nonce = (0, node_crypto_1.randomBytes)(12);
168
+ const cipher = (0, node_crypto_1.createCipheriv)('chacha20-poly1305', key, nonce, { authTagLength: 16 });
169
+ const body = Buffer.concat([cipher.update(plaintext), cipher.final()]);
170
+ const tag = cipher.getAuthTag();
171
+ return {
172
+ alg: exports.PQ_TRANSPORT_ALG,
173
+ nonce: nonce.toString('hex'),
174
+ ciphertext: Buffer.concat([body, tag]).toString('hex'),
175
+ };
176
+ }
177
+ /** Inverse of {@link pqEncrypt}. */
178
+ function pqDecrypt(secret, direction, envelope) {
179
+ if (!envelope || envelope.alg !== exports.PQ_TRANSPORT_ALG) {
180
+ throw new Error('unsupported encrypted transport envelope');
181
+ }
182
+ const key = pqTransportKey(secret, direction);
183
+ const nonce = Buffer.from(envelope.nonce, 'hex');
184
+ const blob = Buffer.from(envelope.ciphertext, 'hex');
185
+ const tag = blob.subarray(blob.length - 16);
186
+ const body = blob.subarray(0, blob.length - 16);
187
+ const decipher = (0, node_crypto_1.createDecipheriv)('chacha20-poly1305', key, nonce, { authTagLength: 16 });
188
+ decipher.setAuthTag(tag);
189
+ return Buffer.concat([decipher.update(body), decipher.final()]);
190
+ }
191
+ function pqPublicKey(challenge) {
192
+ const kex = challenge.pq_kex;
193
+ if (kex && kex.alg === exports.PQ_KEX_ALG && kex.public_key)
194
+ return String(kex.public_key);
195
+ return null;
196
+ }
197
+ /**
198
+ * Build the single framed message a client sends in response to the challenge.
199
+ * Mirrors `browser_cli.remote.auth.build_auth_message` + `signed_payload`.
200
+ */
201
+ async function buildAuthPayload(baseMsg, challenge, privatePem) {
202
+ const nonceHex = challenge.type === 'challenge' ? challenge.nonce : undefined;
203
+ if (!nonceHex || !privatePem) {
204
+ // No-auth endpoint (loopback `serve --no-auth`): send the bare message.
205
+ return { payload: baseMsg, pqSecret: null };
206
+ }
207
+ const clean = stripAuthFields(baseMsg);
208
+ let secret = null;
209
+ const serverPub = pqPublicKey(challenge);
210
+ if (serverPub) {
211
+ const enc = await pqEncapsulate(serverPub);
212
+ secret = enc.secret;
213
+ clean.pq_kex = { alg: exports.PQ_KEX_ALG, ciphertext: enc.ciphertextHex };
214
+ }
215
+ const sig = signAuth(privatePem, nonceHex, clean, secret);
216
+ const pubkey = ed25519PublicKeyHex(privatePem);
217
+ if (!secret) {
218
+ return { payload: { ...clean, pubkey, sig }, pqSecret: null };
219
+ }
220
+ const encrypted = pqEncrypt(secret, 'request', Buffer.from(JSON.stringify(clean), 'utf8'));
221
+ return {
222
+ payload: {
223
+ id: clean.id,
224
+ user_agent: clean.user_agent,
225
+ pubkey,
226
+ sig,
227
+ pq_kex: clean.pq_kex,
228
+ encrypted,
229
+ },
230
+ pqSecret: secret,
231
+ };
232
+ }
233
+ /** Decode a framed server response, decrypting the PQ envelope when present. */
234
+ function decodeResponse(raw, pqSecret) {
235
+ const outer = JSON.parse(raw.toString('utf8'));
236
+ if (pqSecret && outer && typeof outer === 'object' && 'encrypted' in outer) {
237
+ return JSON.parse(pqDecrypt(pqSecret, 'response', outer.encrypted).toString('utf8'));
238
+ }
239
+ return outer;
240
+ }
241
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../nodes/BrowserCli/protocol.ts"],"names":[],"mappings":";;;AA2CA,sBAIC;AAKD,sCAEC;AAsCD,wCAaC;AAGD,kDAKC;AAGD,kCAWC;AAGD,4BAOC;AA2BD,sCAIC;AAGD,wCAKC;AASD,8BAWC;AAGD,8BAYC;AA0BD,4CAuCC;AAGD,wCAMC;AA7RD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,6CAUqB;AAER,QAAA,UAAU,GAAG,YAAY,CAAC;AAC1B,QAAA,gBAAgB,GAAG,6BAA6B,CAAC;AAE9D,gFAAgF;AAChF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;AAEtE,8EAA8E;AAE9E,8EAA8E;AAC9E,SAAgB,KAAK,CAAC,OAAe;IACnC,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,+EAA+E;AAE/E,kFAAkF;AAClF,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;IAC1B,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,YAAY,CAAC,KAAe,CAAC,CAAC;IAC5D,IAAI,IAAI,KAAK,SAAS;QAAE,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B,SAAS;SACV;QACD,QAAQ,EAAE,MAAM;KACjB,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,SAAgB,cAAc,CAAC,GAAW,EAAE,QAAuB;IACjE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,IAAI,QAAQ,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,WAAW,IAAI,KAAK,EAAE,CAAC;QAC3E,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,40 +1,25 @@
1
1
  /**
2
- * Pure request mapping for the browser-cli serve-http gateway.
2
+ * Pure (resource, operation) -> browser-cli command mapping.
3
3
  *
4
- * This module deliberately imports nothing from n8n so it can be unit-tested
5
- * with a plain TypeScript/esbuild toolchain. The node layer collects UI
6
- * parameters into a plain object and asks here for the HTTP request to make.
7
- *
8
- * The gateway only exposes four routes:
9
- * GET /health -> {ok: true} (ungated)
10
- * GET /tabs -> Tab[] (safe)
11
- * GET /clients -> Client[] (safe)
12
- * POST /command -> {result: <raw command output>}
13
- *
14
- * Every convenience operation below is just a typed wrapper around POST
15
- * /command, so what the gateway returns is the *raw* extension result for that
16
- * command (no SDK-side rendering). The command itself is still subject to the
17
- * server's --allow-* policy, so each operation lists the policy tier it needs.
4
+ * This module imports nothing from n8n so it can be unit-tested with a plain
5
+ * esbuild/node toolchain. The node layer collects UI parameters into a plain
6
+ * object and asks here for the command + args to run over the `serve` socket
7
+ * (see `serveClient.ts`). Every operation maps to one raw extension command;
8
+ * what the server returns is the *raw* command result (no SDK-side rendering),
9
+ * still subject to the server's --allow-* policy noted per operation.
18
10
  */
19
- export type HttpMethod = 'GET' | 'POST';
20
- export interface GatewayRequest {
21
- method: HttpMethod;
22
- /** Path appended to the credential base URL, e.g. "/tabs" or "/command". */
23
- path: string;
24
- /** JSON body, only present for POST /command. */
25
- body?: {
26
- command: string;
27
- args: Record<string, unknown>;
28
- };
11
+ export type CommandParams = Record<string, unknown>;
12
+ export interface BrowserCommand {
13
+ /** Raw browser-cli command name, e.g. "tabs.list" or "navigate.open". */
14
+ command: string;
15
+ /** Argument object forwarded to the command. */
16
+ args: Record<string, unknown>;
29
17
  }
30
- export type GatewayParams = Record<string, unknown>;
31
- /** Build a POST /command request for a raw browser-cli command. */
32
- export declare function commandRequest(command: string, args?: Record<string, unknown>): GatewayRequest;
33
18
  /**
34
- * Map a (resource, operation) pair plus collected parameters to a single
35
- * gateway HTTP request. Throws on an unknown pairing so the node fails loudly
19
+ * Map a (resource, operation) pair plus collected parameters to a single raw
20
+ * browser-cli command. Throws on an unknown pairing so the node fails loudly
36
21
  * rather than silently issuing a wrong call.
37
22
  */
38
- export declare function buildGatewayRequest(resource: string, operation: string, params: GatewayParams): GatewayRequest;
23
+ export declare function buildCommand(resource: string, operation: string, params: CommandParams): BrowserCommand;
39
24
  /** Accept an array, a JSON array string, or a comma/space separated list. */
40
25
  export declare function parseTabIds(value: unknown): number[];
@@ -1,30 +1,17 @@
1
1
  "use strict";
2
2
  /**
3
- * Pure request mapping for the browser-cli serve-http gateway.
3
+ * Pure (resource, operation) -> browser-cli command mapping.
4
4
  *
5
- * This module deliberately imports nothing from n8n so it can be unit-tested
6
- * with a plain TypeScript/esbuild toolchain. The node layer collects UI
7
- * parameters into a plain object and asks here for the HTTP request to make.
8
- *
9
- * The gateway only exposes four routes:
10
- * GET /health -> {ok: true} (ungated)
11
- * GET /tabs -> Tab[] (safe)
12
- * GET /clients -> Client[] (safe)
13
- * POST /command -> {result: <raw command output>}
14
- *
15
- * Every convenience operation below is just a typed wrapper around POST
16
- * /command, so what the gateway returns is the *raw* extension result for that
17
- * command (no SDK-side rendering). The command itself is still subject to the
18
- * server's --allow-* policy, so each operation lists the policy tier it needs.
5
+ * This module imports nothing from n8n so it can be unit-tested with a plain
6
+ * esbuild/node toolchain. The node layer collects UI parameters into a plain
7
+ * object and asks here for the command + args to run over the `serve` socket
8
+ * (see `serveClient.ts`). Every operation maps to one raw extension command;
9
+ * what the server returns is the *raw* command result (no SDK-side rendering),
10
+ * still subject to the server's --allow-* policy noted per operation.
19
11
  */
20
12
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.commandRequest = commandRequest;
22
- exports.buildGatewayRequest = buildGatewayRequest;
13
+ exports.buildCommand = buildCommand;
23
14
  exports.parseTabIds = parseTabIds;
24
- /** Build a POST /command request for a raw browser-cli command. */
25
- function commandRequest(command, args = {}) {
26
- return { method: 'POST', path: '/command', body: { command, args } };
27
- }
28
15
  function str(params, key) {
29
16
  const value = params[key];
30
17
  return value === undefined || value === null ? '' : String(value);
@@ -39,68 +26,61 @@ function compact(args) {
39
26
  return out;
40
27
  }
41
28
  /**
42
- * Map a (resource, operation) pair plus collected parameters to a single
43
- * gateway HTTP request. Throws on an unknown pairing so the node fails loudly
29
+ * Map a (resource, operation) pair plus collected parameters to a single raw
30
+ * browser-cli command. Throws on an unknown pairing so the node fails loudly
44
31
  * rather than silently issuing a wrong call.
45
32
  */
46
- function buildGatewayRequest(resource, operation, params) {
33
+ function buildCommand(resource, operation, params) {
47
34
  const key = `${resource}:${operation}`;
48
35
  switch (key) {
49
36
  // --- Raw escape hatch -------------------------------------------------
50
- case 'command:execute': {
51
- const command = str(params, 'command');
52
- const args = params.args ?? {};
53
- return commandRequest(command, args);
54
- }
37
+ case 'command:execute':
38
+ return { command: str(params, 'command'), args: params.args ?? {} };
55
39
  // --- Tabs -------------------------------------------------------------
56
40
  case 'tab:list':
57
- return { method: 'GET', path: '/tabs' };
41
+ return { command: 'tabs.list', args: {} };
58
42
  case 'tab:open': {
59
43
  const focus = Boolean(params.focus);
60
- return commandRequest('navigate.open', compact({
61
- url: str(params, 'url'),
62
- focus,
63
- background: !focus,
64
- }));
44
+ return { command: 'navigate.open', args: compact({ url: str(params, 'url'), focus, background: !focus }) };
65
45
  }
66
46
  case 'tab:close': {
67
47
  const mode = str(params, 'mode') || 'ids';
68
48
  if (mode === 'inactive')
69
- return commandRequest('tabs.close', { inactive: true });
49
+ return { command: 'tabs.close', args: { inactive: true } };
70
50
  if (mode === 'duplicates')
71
- return commandRequest('tabs.close', { duplicates: true });
72
- const ids = parseTabIds(params.tabIds);
73
- return commandRequest('tabs.close', { tab_ids: ids });
51
+ return { command: 'tabs.close', args: { duplicates: true } };
52
+ return { command: 'tabs.close', args: { tab_ids: parseTabIds(params.tabIds) } };
74
53
  }
75
54
  case 'tab:getHtml':
76
- return commandRequest('tabs.html', compact({ tabId: tabIdArg(params.tabId) }));
55
+ return { command: 'tabs.html', args: compact({ tabId: tabIdArg(params.tabId) }) };
77
56
  // --- Page / extraction ------------------------------------------------
78
57
  case 'page:info':
79
- return commandRequest('page.info', {});
58
+ return { command: 'page.info', args: {} };
80
59
  case 'page:extractText':
81
- return commandRequest('extract.text', compact({ selector: str(params, 'selector') }));
60
+ return { command: 'extract.text', args: compact({ selector: str(params, 'selector') }) };
82
61
  case 'page:extractLinks':
83
- return commandRequest('extract.links', compact({ selector: str(params, 'selector') }));
62
+ return { command: 'extract.links', args: compact({ selector: str(params, 'selector') }) };
84
63
  case 'page:extractImages':
85
- return commandRequest('extract.images', compact({ selector: str(params, 'selector') }));
64
+ return { command: 'extract.images', args: compact({ selector: str(params, 'selector') }) };
86
65
  case 'page:extractHtml':
87
- return commandRequest('extract.html', compact({ selector: str(params, 'selector') }));
66
+ return { command: 'extract.html', args: compact({ selector: str(params, 'selector') }) };
88
67
  case 'page:extractMarkdown':
89
- return commandRequest('extract.markdown', compact({ selector: str(params, 'selector') }));
68
+ return { command: 'extract.markdown', args: compact({ selector: str(params, 'selector') }) };
90
69
  // --- DOM --------------------------------------------------------------
91
70
  case 'dom:query':
92
- return commandRequest('dom.query', { selector: str(params, 'selector') });
71
+ return { command: 'dom.query', args: { selector: str(params, 'selector') } };
93
72
  case 'dom:click':
94
- return commandRequest('dom.click', { selector: str(params, 'selector') });
73
+ return { command: 'dom.click', args: { selector: str(params, 'selector') } };
95
74
  case 'dom:type':
96
- return commandRequest('dom.type', { selector: str(params, 'selector'), text: str(params, 'text') });
75
+ return { command: 'dom.type', args: { selector: str(params, 'selector'), text: str(params, 'text') } };
97
76
  case 'dom:eval':
98
- return commandRequest('dom.eval', compact({ code: str(params, 'code'), tabId: tabIdArg(params.tabId) }));
99
- // --- Clients / gateway ------------------------------------------------
77
+ return { command: 'dom.eval', args: compact({ code: str(params, 'code'), tabId: tabIdArg(params.tabId) }) };
78
+ // --- Clients ----------------------------------------------------------
100
79
  case 'client:list':
101
- return { method: 'GET', path: '/clients' };
80
+ return { command: 'clients.list', args: {} };
81
+ // --- Gateway: serve has no health route, so ping with a safe command --
102
82
  case 'gateway:health':
103
- return { method: 'GET', path: '/health' };
83
+ return { command: 'tabs.list', args: {} };
104
84
  default:
105
85
  throw new Error(`Unsupported operation "${operation}" for resource "${resource}"`);
106
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../nodes/BrowserCli/request.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAeH,wCAEC;AAqBD,kDAoEC;AAUD,kCAiBC;AAvHD,mEAAmE;AACnE,SAAgB,cAAc,CAAC,OAAe,EAAE,OAAgC,EAAE;IAChF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;AACvE,CAAC;AAED,SAAS,GAAG,CAAC,MAAqB,EAAE,GAAW;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAA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,CAAC;QACxB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;gBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/E,CAAC;QAAC,MAAM,CAAC;YACP,2BAA2B;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,GAAG;SACP,KAAK,CAAC,QAAQ,CAAC;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAC3B,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,18 @@
1
+ export interface ServeConnectOptions {
2
+ host: string;
3
+ port: number;
4
+ /** Wrap the TCP connection in TLS (for a serve behind a TLS-terminating proxy). */
5
+ tls?: boolean;
6
+ /** Reject self-signed / invalid certs when `tls` is on. */
7
+ rejectUnauthorized?: boolean;
8
+ /** Ed25519 PKCS8 PEM private key, or null/empty for a `--no-auth` endpoint. */
9
+ privateKeyPem?: string | null;
10
+ /** Optional `_route` target for a multi-browser serve. */
11
+ route?: string | null;
12
+ timeoutMs?: number;
13
+ }
14
+ /**
15
+ * Run a single browser-cli command against a `serve` endpoint and return the
16
+ * server's response object: `{id, success, data}` or `{id, success:false, error}`.
17
+ */
18
+ export declare function sendServeCommand(opts: ServeConnectOptions, command: string, args: Record<string, unknown>): Promise<any>;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendServeCommand = sendServeCommand;
4
+ /**
5
+ * Socket client for a raw `browser-cli serve` endpoint.
6
+ *
7
+ * One command per connection: connect, read the challenge frame, send the
8
+ * authenticated (and PQ-encrypted) request frame, read the response frame,
9
+ * close. The crypto and payload shapes live in `protocol.ts`.
10
+ */
11
+ const node_net_1 = require("node:net");
12
+ const node_tls_1 = require("node:tls");
13
+ const node_crypto_1 = require("node:crypto");
14
+ const protocol_1 = require("./protocol");
15
+ /** Version advertised to the server. Must be >= the server's PROTOCOL_MIN_CLIENT
16
+ * (0.9.0) and >= 0.9.5 so the server enforces the post-quantum handshake this
17
+ * client implements. */
18
+ const CLIENT_VERSION = '0.15.4';
19
+ const USER_AGENT = `browser-cli/${CLIENT_VERSION}`;
20
+ // Force a plain-JSON, uncompressed response so no msgpack/zstd decoder is needed.
21
+ const ACCEPT_ENCODING = { ser: ['json'], comp: [] };
22
+ const MAX_MSG_BYTES = 32 * 1024 * 1024;
23
+ const DEFAULT_TIMEOUT_MS = 30_000;
24
+ /** Reassembles browser-cli's 4-byte length-prefixed frames from a socket. */
25
+ class FrameReader {
26
+ constructor(socket) {
27
+ this.buffer = Buffer.alloc(0);
28
+ this.waiters = [];
29
+ this.failed = null;
30
+ socket.on('data', (chunk) => this.onData(chunk));
31
+ }
32
+ onData(chunk) {
33
+ this.buffer = Buffer.concat([this.buffer, chunk]);
34
+ while (this.buffer.length >= 4) {
35
+ const length = this.buffer.readUInt32LE(0);
36
+ if (length > MAX_MSG_BYTES) {
37
+ this.fail(new Error(`serve frame too large (${length} bytes)`));
38
+ return;
39
+ }
40
+ if (this.buffer.length < 4 + length)
41
+ break;
42
+ const payload = this.buffer.subarray(4, 4 + length);
43
+ this.buffer = this.buffer.subarray(4 + length);
44
+ const waiter = this.waiters.shift();
45
+ if (waiter)
46
+ waiter(Buffer.from(payload));
47
+ }
48
+ }
49
+ fail(error) {
50
+ this.failed = error;
51
+ }
52
+ /** Resolve with the next complete frame, or reject on error/EOF/timeout. */
53
+ next() {
54
+ if (this.failed)
55
+ return Promise.reject(this.failed);
56
+ return new Promise((resolve) => this.waiters.push(resolve));
57
+ }
58
+ }
59
+ function openSocket(opts) {
60
+ if (opts.tls) {
61
+ return (0, node_tls_1.connect)({
62
+ host: opts.host,
63
+ port: opts.port,
64
+ rejectUnauthorized: opts.rejectUnauthorized !== false,
65
+ // SNI must be a hostname; Node rejects an IP literal as servername.
66
+ ...((0, node_net_1.isIP)(opts.host) ? {} : { servername: opts.host }),
67
+ });
68
+ }
69
+ return (0, node_net_1.connect)({ host: opts.host, port: opts.port });
70
+ }
71
+ /**
72
+ * Run a single browser-cli command against a `serve` endpoint and return the
73
+ * server's response object: `{id, success, data}` or `{id, success:false, error}`.
74
+ */
75
+ async function sendServeCommand(opts, command, args) {
76
+ const socket = openSocket(opts);
77
+ socket.setNoDelay(true);
78
+ const reader = new FrameReader(socket);
79
+ const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
80
+ return new Promise((resolve, reject) => {
81
+ let settled = false;
82
+ const finish = (fn) => {
83
+ if (settled)
84
+ return;
85
+ settled = true;
86
+ clearTimeout(timer);
87
+ socket.destroy();
88
+ fn();
89
+ };
90
+ const timer = setTimeout(() => finish(() => reject(new Error(`serve request to ${opts.host}:${opts.port} timed out after ${timeoutMs}ms`))), timeoutMs);
91
+ socket.on('error', (err) => finish(() => reject(err)));
92
+ socket.on('close', () => finish(() => reject(new Error('serve connection closed before a response was received'))));
93
+ const run = async () => {
94
+ const challengeRaw = await reader.next();
95
+ const challenge = JSON.parse(challengeRaw.toString('utf8'));
96
+ const baseMsg = {
97
+ id: (0, node_crypto_1.randomUUID)(),
98
+ command,
99
+ args: args ?? {},
100
+ user_agent: USER_AGENT,
101
+ accept_encoding: ACCEPT_ENCODING,
102
+ };
103
+ if (opts.route)
104
+ baseMsg._route = opts.route;
105
+ const { payload, pqSecret } = await (0, protocol_1.buildAuthPayload)(baseMsg, challenge, opts.privateKeyPem || null);
106
+ socket.write((0, protocol_1.frame)(Buffer.from(JSON.stringify(payload), 'utf8')));
107
+ const responseRaw = await reader.next();
108
+ const response = (0, protocol_1.decodeResponse)(responseRaw, pqSecret);
109
+ finish(() => resolve(response));
110
+ };
111
+ // A TLS socket is ready only after 'secureConnect'; a plain socket on 'connect'.
112
+ socket.once(opts.tls ? 'secureConnect' : 'connect', () => {
113
+ run().catch((err) => finish(() => reject(err)));
114
+ });
115
+ });
116
+ }
117
+ //# sourceMappingURL=serveClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serveClient.js","sourceRoot":"","sources":["../../../nodes/BrowserCli/serveClient.ts"],"names":[],"mappings":";;AA4FA,4CAsDC;AAlJD;;;;;;GAMG;AACH,uCAAuD;AACvD,uCAAiD;AAEjD,6CAAyC;AAEzC,yCAAqF;AAErF;;wBAEwB;AACxB,MAAM,cAAc,GAAG,QAAQ,CAAC;AAChC,MAAM,UAAU,GAAG,eAAe,cAAc,EAAE,CAAC;AACnD,kFAAkF;AAClF,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAc,EAAE,CAAC;AAChE,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACvC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAgBlC,6EAA6E;AAC7E,MAAM,WAAW;IAKf,YAAY,MAAc;QAJlB,WAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzB,YAAO,GAAmC,EAAE,CAAC;QAC7C,WAAM,GAAiB,IAAI,CAAC;QAGlC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3D,CAAC;IAEO,MAAM,CAAC,KAAa;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC3C,IAAI,M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C,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE;YACvD,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "n8n-nodes-browser-cli",
3
- "version": "0.1.0",
4
- "description": "n8n community node that controls a remote browser through a browser-cli serve-http gateway",
3
+ "version": "0.2.2",
4
+ "description": "n8n community node that controls a remote browser by talking directly to a browser-cli serve endpoint (Ed25519 + post-quantum encrypted)",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
7
7
  "browser-cli",
@@ -38,5 +38,8 @@
38
38
  },
39
39
  "peerDependencies": {
40
40
  "n8n-workflow": "*"
41
+ },
42
+ "dependencies": {
43
+ "@noble/post-quantum": "^0.6.1"
41
44
  }
42
45
  }