@postman-cse/cse-cred-daemon 0.1.8

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.
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { spawnRaw } = require('../src/index');
5
+
6
+ const result = spawnRaw(process.argv.slice(2));
7
+ if (result.error) {
8
+ console.error('error: native runtime failed');
9
+ process.exit(1);
10
+ }
11
+ process.exit(result.status == null ? 1 : result.status);
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@postman-cse/cse-cred-daemon",
3
+ "version": "0.1.8",
4
+ "description": "CSE credential daemon: signed Rust binary that mediates auth + MCP traffic for Claude/Codex/Droid",
5
+ "main": "src/index.js",
6
+ "bin": {
7
+ "cse-cred-daemon": "bin/cse-cred-daemon-js.js"
8
+ },
9
+ "scripts": {
10
+ "prepare:vendor": "node scripts/sync-vendor.js"
11
+ },
12
+ "engines": {
13
+ "node": ">=18.0.0"
14
+ },
15
+ "files": [
16
+ "src/",
17
+ "bin/"
18
+ ],
19
+ "optionalDependencies": {
20
+ "@postman-cse/cse-cred-daemon-darwin-arm64": "0.1.8"
21
+ }
22
+ }
package/src/index.js ADDED
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+ const child_process = require('child_process');
6
+
7
+ function platformPackageName() {
8
+ return `@postman-cse/cse-cred-daemon-${process.platform}-${process.arch}`;
9
+ }
10
+
11
+ function resolveCoreBinary() {
12
+ const binaryName = 'cse-cred-daemon';
13
+ const platformKey = `${process.platform}-${process.arch}`;
14
+ const platform = process.platform;
15
+ const arch = process.arch;
16
+
17
+ if (platform === 'darwin' && arch === 'arm64') {
18
+ try {
19
+ const pkgJson = require.resolve(`${platformPackageName()}/package.json`);
20
+ const candidate = path.join(path.dirname(pkgJson), 'bin', binaryName);
21
+ if (fs.existsSync(candidate)) {
22
+ try {
23
+ fs.accessSync(candidate, fs.constants.X_OK);
24
+ return candidate;
25
+ } catch (_) {
26
+ throw new Error('native runtime is not executable');
27
+ }
28
+ }
29
+ } catch (e) {
30
+ if (e.message === 'native runtime is not executable') throw e;
31
+ }
32
+ }
33
+
34
+ const vendorCandidate = path.resolve(__dirname, '..', 'vendor', binaryName);
35
+ if (fs.existsSync(vendorCandidate)) {
36
+ try {
37
+ fs.accessSync(vendorCandidate, fs.constants.X_OK);
38
+ return vendorCandidate;
39
+ } catch (_) {
40
+ throw new Error('native runtime is not executable');
41
+ }
42
+ }
43
+
44
+ throw new Error(`native runtime is unavailable for this platform: ${platform}-${arch}`);
45
+ }
46
+
47
+ function spawnRaw(args, options) {
48
+ return child_process.spawnSync(resolveCoreBinary(), args || [], {
49
+ stdio: 'inherit',
50
+ ...(options || {}),
51
+ });
52
+ }
53
+
54
+ module.exports = {
55
+ resolveCoreBinary,
56
+ spawnRaw,
57
+ };