@portauthority/manifest 0.1.0

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.
Files changed (2) hide show
  1. package/install.js +107 -0
  2. package/package.json +33 -0
package/install.js ADDED
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const { execSync } = require("child_process");
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const https = require("https");
9
+ const http = require("http");
10
+
11
+ const VERSION = require("./package.json").version;
12
+ const REPO = "PortAuthorityHQ/manifest";
13
+
14
+ const PLATFORM_MAP = {
15
+ "darwin-arm64": "manifest-aarch64-apple-darwin.tar.gz",
16
+ "darwin-x64": "manifest-x86_64-apple-darwin.tar.gz",
17
+ "linux-x64": "manifest-x86_64-unknown-linux-gnu.tar.gz",
18
+ "linux-arm64": "manifest-aarch64-unknown-linux-gnu.tar.gz",
19
+ };
20
+
21
+ function getPlatformKey() {
22
+ const platform = process.platform;
23
+ const arch = process.arch;
24
+ return `${platform}-${arch}`;
25
+ }
26
+
27
+ function getDownloadUrl(asset) {
28
+ return `https://github.com/${REPO}/releases/download/v${VERSION}/${asset}`;
29
+ }
30
+
31
+ function download(url) {
32
+ return new Promise((resolve, reject) => {
33
+ const get = url.startsWith("https") ? https.get : http.get;
34
+ get(url, (res) => {
35
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
36
+ // Follow redirect
37
+ download(res.headers.location).then(resolve).catch(reject);
38
+ return;
39
+ }
40
+ if (res.statusCode !== 200) {
41
+ reject(new Error(`Download failed: HTTP ${res.statusCode} from ${url}`));
42
+ return;
43
+ }
44
+ const chunks = [];
45
+ res.on("data", (chunk) => chunks.push(chunk));
46
+ res.on("end", () => resolve(Buffer.concat(chunks)));
47
+ res.on("error", reject);
48
+ }).on("error", reject);
49
+ });
50
+ }
51
+
52
+ async function main() {
53
+ const platformKey = getPlatformKey();
54
+ const asset = PLATFORM_MAP[platformKey];
55
+
56
+ if (!asset) {
57
+ console.error(
58
+ `Unsupported platform: ${platformKey}\n` +
59
+ `Supported: ${Object.keys(PLATFORM_MAP).join(", ")}\n` +
60
+ `Install from source: https://github.com/${REPO}#build-from-source`
61
+ );
62
+ process.exit(1);
63
+ }
64
+
65
+ const url = getDownloadUrl(asset);
66
+ const binDir = path.join(__dirname, "bin");
67
+ const binPath = path.join(binDir, "manifest");
68
+
69
+ // Skip if binary already exists (e.g., re-running postinstall)
70
+ if (fs.existsSync(binPath)) {
71
+ try {
72
+ execSync(`"${binPath}" --version`, { stdio: "ignore" });
73
+ console.log("manifest binary already installed.");
74
+ return;
75
+ } catch {
76
+ // Binary exists but doesn't work — re-download
77
+ }
78
+ }
79
+
80
+ console.log(`Downloading manifest v${VERSION} for ${platformKey}...`);
81
+ console.log(` ${url}`);
82
+
83
+ try {
84
+ const tarball = await download(url);
85
+
86
+ // Write tarball to temp file and extract
87
+ const tmpFile = path.join(__dirname, ".manifest-download.tar.gz");
88
+ fs.writeFileSync(tmpFile, tarball);
89
+
90
+ fs.mkdirSync(binDir, { recursive: true });
91
+ execSync(`tar xzf "${tmpFile}" -C "${binDir}"`, { stdio: "ignore" });
92
+ fs.unlinkSync(tmpFile);
93
+
94
+ // Ensure binary is executable
95
+ fs.chmodSync(binPath, 0o755);
96
+
97
+ console.log(`manifest v${VERSION} installed successfully.`);
98
+ } catch (err) {
99
+ console.error(
100
+ `Failed to install manifest: ${err.message}\n` +
101
+ `You can install manually: https://github.com/${REPO}#installation`
102
+ );
103
+ process.exit(1);
104
+ }
105
+ }
106
+
107
+ main();
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@portauthority/manifest",
3
+ "version": "0.1.0",
4
+ "description": "Cryptographic receipts for AI agent tool calls",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/PortAuthorityHQ/manifest"
9
+ },
10
+ "homepage": "https://github.com/PortAuthorityHQ/manifest",
11
+ "keywords": [
12
+ "ai",
13
+ "agent",
14
+ "mcp",
15
+ "audit",
16
+ "cryptographic",
17
+ "receipts",
18
+ "compliance"
19
+ ],
20
+ "bin": {
21
+ "manifest": "bin/manifest"
22
+ },
23
+ "scripts": {
24
+ "postinstall": "node install.js"
25
+ },
26
+ "files": [
27
+ "install.js",
28
+ "bin/"
29
+ ],
30
+ "engines": {
31
+ "node": ">=16"
32
+ }
33
+ }