sshifu 0.6.1 → 0.6.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,34 @@
1
+ # sshifu
2
+
3
+ SSH authentication client with short-lived certificates and OAuth authentication (GitHub organizations).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g sshifu
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ sshifu auth.example.com user@target-server.com
15
+ ```
16
+
17
+ ## Features
18
+
19
+ - 🔐 **Short-lived SSH certificates** - Automatic certificate issuance with configurable TTL (default 8 hours)
20
+ - 🌐 **GitHub OAuth authentication** - Authenticate users via GitHub organization membership
21
+ - 🛠️ **Standard OpenSSH compatibility** - Works with existing `ssh` command without workflow changes
22
+
23
+ ## Requirements
24
+
25
+ - OpenSSH 6.7+ (for certificate support)
26
+ - Node.js 14.0.0+
27
+
28
+ ## Full Documentation
29
+
30
+ See the complete documentation at [github.com/azophy/sshifu](https://github.com/azophy/sshifu)
31
+
32
+ ## License
33
+
34
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sshifu",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "SSH authentication system with short-lived certificates and OAuth authentication (GitHub organizations)",
5
5
  "main": "bin/sshifu.js",
6
6
  "bin": {
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Postinstall script for sshifu
5
+ * Downloads the appropriate binary from GitHub releases
6
+ */
7
+
8
+ const https = require('https');
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const { execSync } = require('child_process');
12
+
13
+ const PACKAGE_NAME = 'sshifu';
14
+ const REPO = 'azophy/sshifu';
15
+
16
+ function getPlatform() {
17
+ const platform = process.platform;
18
+ const arch = process.arch;
19
+
20
+ if (platform === 'linux') {
21
+ if (arch === 'x64') return 'linux-amd64';
22
+ if (arch === 'arm64') return 'linux-arm64';
23
+ if (arch === 'arm') return 'linux-arm';
24
+ }
25
+ if (platform === 'darwin') {
26
+ if (arch === 'x64') return 'darwin-amd64';
27
+ if (arch === 'arm64') return 'darwin-arm64';
28
+ }
29
+ if (platform === 'win32') {
30
+ if (arch === 'x64') return 'windows-amd64';
31
+ }
32
+
33
+ throw new Error(`Unsupported platform: ${platform} ${arch}`);
34
+ }
35
+
36
+ function download(url, dest) {
37
+ return new Promise((resolve, reject) => {
38
+ const file = fs.createWriteStream(dest);
39
+ https.get(url, (response) => {
40
+ if (response.statusCode === 302 || response.statusCode === 301) {
41
+ download(response.headers.location, dest).then(resolve).catch(reject);
42
+ return;
43
+ }
44
+
45
+ if (response.statusCode !== 200) {
46
+ reject(new Error(`Download failed with status ${response.statusCode}`));
47
+ return;
48
+ }
49
+
50
+ response.pipe(file);
51
+ file.on('finish', () => {
52
+ file.close();
53
+ resolve();
54
+ });
55
+ }).on('error', reject);
56
+ });
57
+ }
58
+
59
+ async function main() {
60
+ const platform = getPlatform();
61
+ const binDir = path.join(__dirname, '..', 'bin');
62
+ const binName = process.platform === 'win32' ? `${PACKAGE_NAME}.exe` : PACKAGE_NAME;
63
+ const binPath = path.join(binDir, binName);
64
+
65
+ // Ensure bin directory exists
66
+ if (!fs.existsSync(binDir)) {
67
+ fs.mkdirSync(binDir, { recursive: true });
68
+ }
69
+
70
+ // Get version from package.json
71
+ const pkgPath = path.join(__dirname, '..', 'package.json');
72
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
73
+ let version = pkg.version;
74
+
75
+ // For dev versions, skip download (use local build)
76
+ if (version.includes('dev')) {
77
+ console.log(`[sshifu] Dev version detected, skipping binary download`);
78
+ console.log(`[sshifu] Build manually with: go build -o bin/${binName} ./cmd/${PACKAGE_NAME}`);
79
+ return;
80
+ }
81
+
82
+ const archiveName = `${PACKAGE_NAME}-${platform}.tar.gz`;
83
+ const archiveUrl = `https://github.com/${REPO}/releases/download/v${version}/${archiveName}`;
84
+ const archivePath = path.join(binDir, archiveName);
85
+
86
+ console.log(`[sshifu] Downloading ${archiveUrl}...`);
87
+
88
+ try {
89
+ await download(archiveUrl, archivePath);
90
+
91
+ // Extract the archive
92
+ console.log(`[sshifu] Extracting...`);
93
+ const archiveBinName = `${PACKAGE_NAME}-${platform}${process.platform === 'win32' ? '.exe' : ''}`;
94
+ const extractedPath = path.join(binDir, archiveBinName);
95
+ execSync(`tar -xzf "${archivePath}" -C "${binDir}"`, { stdio: 'ignore' });
96
+
97
+ // Rename to expected name if different
98
+ if (archiveBinName !== binName && fs.existsSync(extractedPath)) {
99
+ fs.renameSync(extractedPath, binPath);
100
+ }
101
+
102
+ // Make executable on Unix
103
+ if (process.platform !== 'win32') {
104
+ fs.chmodSync(binPath, 0o755);
105
+ }
106
+
107
+ // Clean up archive
108
+ fs.unlinkSync(archivePath);
109
+
110
+ console.log(`[sshifu] Binary installed successfully!`);
111
+ } catch (err) {
112
+ console.error(`[sshifu] Installation failed: ${err.message}`);
113
+ console.error(`[sshifu] You can download the binary manually from https://github.com/${REPO}/releases`);
114
+ process.exit(1);
115
+ }
116
+ }
117
+
118
+ main();