rapay 1.3.1 → 1.3.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.
Files changed (2) hide show
  1. package/install.js +230 -230
  2. package/package.json +51 -51
package/install.js CHANGED
@@ -1,230 +1,230 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Ra Pay CLI installer
5
- * Downloads the correct binary for the user's platform from GitHub Releases
6
- * Verifies SHA256 checksum before installation for security
7
- */
8
-
9
- const { createHash } = require('crypto');
10
- const fs = require('fs');
11
- const path = require('path');
12
- const https = require('https');
13
- const os = require('os');
14
-
15
- const VERSION = '1.3.1'; // CDN binary version (npm package version may differ)
16
- const CDN_BASE = 'https://cdn.rapay.ai';
17
-
18
- // Optic Yellow (#CCFF00) ANSI escape code
19
- const OPTIC_YELLOW = '\x1b[38;2;204;255;0m';
20
- const RESET = '\x1b[0m';
21
-
22
- // Pixelated RA PAY logo (matches CLI logo.rs)
23
- const LOGO = `
24
- ██████╗ █████╗ ██████╗ █████╗ ██╗ ██╗
25
- ██╔══██╗██╔══██╗ ██╔══██╗██╔══██╗╚██╗ ██╔╝
26
- ██████╔╝███████║ ██████╔╝███████║ ╚████╔╝
27
- ██╔══██╗██╔══██║ ██╔═══╝ ██╔══██║ ╚██╔╝
28
- ██║ ██║██║ ██║ ██║ ██║ ██║ ██║
29
- ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
30
- `;
31
-
32
- // Platform/arch to binary name mapping
33
- // NOTE: linux-arm64 not supported yet (keyring native libs don't cross-compile)
34
- const BINARY_MAP = {
35
- 'darwin-x64': 'ra-darwin-x64',
36
- 'darwin-arm64': 'ra-darwin-arm64',
37
- 'linux-x64': 'ra-linux-x64',
38
- 'win32-x64': 'ra-win32-x64.exe',
39
- };
40
-
41
- function getPlatformKey() {
42
- const platform = os.platform();
43
- const arch = os.arch();
44
- return `${platform}-${arch}`;
45
- }
46
-
47
- function getBinaryName() {
48
- const key = getPlatformKey();
49
- const binary = BINARY_MAP[key];
50
-
51
- if (!binary) {
52
- console.error(`Unsupported platform: ${key}`);
53
- console.error(`Supported platforms: ${Object.keys(BINARY_MAP).join(', ')}`);
54
- console.error('');
55
- console.error('For linux-arm64, please build from source:');
56
- console.error(' git clone https://github.com/Ra-Pay-AI/rapay');
57
- console.error(' cd rapay/cli && cargo build --release');
58
- process.exit(1);
59
- }
60
-
61
- return binary;
62
- }
63
-
64
- function getDownloadUrl(filename) {
65
- return `${CDN_BASE}/v${VERSION}/${filename}`;
66
- }
67
-
68
- function download(url) {
69
- return new Promise((resolve, reject) => {
70
- const chunks = [];
71
-
72
- const request = (url) => {
73
- const urlObj = new URL(url);
74
- const options = {
75
- hostname: urlObj.hostname,
76
- path: urlObj.pathname,
77
- headers: {
78
- 'User-Agent': 'rapay-installer/1.0',
79
- 'Accept': '*/*'
80
- }
81
- };
82
-
83
- https.get(options, (response) => {
84
- // Handle redirects
85
- if (response.statusCode === 301 || response.statusCode === 302) {
86
- request(response.headers.location);
87
- return;
88
- }
89
-
90
- if (response.statusCode !== 200) {
91
- reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
92
- return;
93
- }
94
-
95
- response.on('data', (chunk) => chunks.push(chunk));
96
- response.on('end', () => resolve(Buffer.concat(chunks)));
97
- response.on('error', reject);
98
- }).on('error', reject);
99
- };
100
-
101
- request(url);
102
- });
103
- }
104
-
105
- function calculateSha256(buffer) {
106
- return createHash('sha256').update(buffer).digest('hex');
107
- }
108
-
109
- function parseChecksums(content) {
110
- const checksums = {};
111
- const lines = content.toString().split('\n');
112
-
113
- for (const line of lines) {
114
- // Skip comments and empty lines
115
- if (line.startsWith('#') || !line.trim()) continue;
116
-
117
- // Format: "hash filename" or "hash filename"
118
- const match = line.match(/^([a-f0-9]{64})\s+(.+)$/i);
119
- if (match) {
120
- const [, hash, filename] = match;
121
- checksums[filename.trim()] = hash.toLowerCase();
122
- }
123
- }
124
-
125
- return checksums;
126
- }
127
-
128
- async function install() {
129
- const binDir = path.join(__dirname, 'bin');
130
- const platform = os.platform();
131
- const binaryName = getBinaryName();
132
- // Windows: ra.exe, Unix: ra-binary (launcher script handles dispatch)
133
- const destName = platform === 'win32' ? 'ra.exe' : 'ra-binary';
134
- const destPath = path.join(binDir, destName);
135
- const binaryUrl = getDownloadUrl(binaryName);
136
- const checksumsUrl = getDownloadUrl('checksums.txt');
137
-
138
- console.log(`Installing Ra Pay CLI v${VERSION} for ${getPlatformKey()}...`);
139
-
140
- // Create bin directory
141
- if (!fs.existsSync(binDir)) {
142
- fs.mkdirSync(binDir, { recursive: true });
143
- }
144
-
145
- try {
146
- // Step 1: Download checksums.txt
147
- console.log('Downloading checksums...');
148
- let checksums = {};
149
- try {
150
- const checksumsContent = await download(checksumsUrl);
151
- checksums = parseChecksums(checksumsContent);
152
- console.log(` Found ${Object.keys(checksums).length} checksums`);
153
- } catch (error) {
154
- console.error('');
155
- console.error('SECURITY ERROR: Could not download checksums.txt');
156
- console.error('Cannot verify binary integrity. Installation aborted.');
157
- console.error('');
158
- console.error('If this is a new release, checksums may not be published yet.');
159
- console.error('Try again in a few minutes or contact support@rapay.ai');
160
- process.exit(1);
161
- }
162
-
163
- // Step 2: Download binary
164
- console.log(`Downloading ${binaryName}...`);
165
- const binaryBuffer = await download(binaryUrl);
166
- console.log(` Downloaded ${(binaryBuffer.length / 1024 / 1024).toFixed(2)} MB`);
167
-
168
- // Step 3: Verify checksum (if available)
169
- const expectedHash = checksums[binaryName];
170
- if (expectedHash) {
171
- console.log('Verifying checksum...');
172
- const actualHash = calculateSha256(binaryBuffer);
173
-
174
- if (actualHash !== expectedHash) {
175
- console.error('');
176
- console.error('SECURITY ERROR: Checksum verification failed!');
177
- console.error(` Expected: ${expectedHash}`);
178
- console.error(` Got: ${actualHash}`);
179
- console.error('');
180
- console.error('The downloaded binary may have been tampered with.');
181
- console.error('Please report this issue at: https://github.com/Ra-Pay-AI/rapay/issues');
182
- process.exit(1);
183
- }
184
-
185
- console.log(' Checksum verified OK');
186
- } else if (Object.keys(checksums).length > 0) {
187
- // We have checksums but not for this binary - suspicious
188
- console.error('');
189
- console.error(`SECURITY ERROR: No checksum found for ${binaryName}`);
190
- console.error('Cannot verify binary integrity. Installation aborted.');
191
- console.error('');
192
- console.error('This may indicate a supply chain attack or misconfigured release.');
193
- console.error('Please report this at: https://github.com/Ra-Pay-AI/rapay/issues');
194
- process.exit(1);
195
- }
196
-
197
- // Step 4: Write binary to disk
198
- fs.writeFileSync(destPath, binaryBuffer);
199
-
200
- // Step 5: Make executable on Unix
201
- if (platform !== 'win32') {
202
- fs.chmodSync(destPath, 0o755);
203
- // Also ensure launcher script is executable
204
- const launcherPath = path.join(binDir, 'ra');
205
- if (fs.existsSync(launcherPath)) {
206
- fs.chmodSync(launcherPath, 0o755);
207
- }
208
- }
209
-
210
- console.log('');
211
- console.log(OPTIC_YELLOW + LOGO + RESET);
212
- console.log('Ra Pay CLI installed successfully!');
213
- console.log('');
214
- console.log('Quick start:');
215
- console.log(' ra link-bank Connect your Stripe account');
216
- console.log(' ra balance Check your balance');
217
- console.log(' ra send Send payments');
218
- console.log('');
219
- console.log('Run "ra --help" for all commands.');
220
- } catch (error) {
221
- console.error('');
222
- console.error('Failed to install Ra Pay CLI:', error.message);
223
- console.error('');
224
- console.error('You can manually download the binary from:');
225
- console.error(`${CDN_BASE}/v${VERSION}/`);
226
- process.exit(1);
227
- }
228
- }
229
-
230
- install();
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Ra Pay CLI installer
5
+ * Downloads the correct binary for the user's platform from GitHub Releases
6
+ * Verifies SHA256 checksum before installation for security
7
+ */
8
+
9
+ const { createHash } = require('crypto');
10
+ const fs = require('fs');
11
+ const path = require('path');
12
+ const https = require('https');
13
+ const os = require('os');
14
+
15
+ const VERSION = '1.3.3'; // CDN binary version (npm package version may differ)
16
+ const CDN_BASE = 'https://cdn.rapay.ai';
17
+
18
+ // Optic Yellow (#CCFF00) ANSI escape code
19
+ const OPTIC_YELLOW = '\x1b[38;2;204;255;0m';
20
+ const RESET = '\x1b[0m';
21
+
22
+ // Pixelated RA PAY logo (matches CLI logo.rs)
23
+ const LOGO = `
24
+ ██████╗ █████╗ ██████╗ █████╗ ██╗ ██╗
25
+ ██╔══██╗██╔══██╗ ██╔══██╗██╔══██╗╚██╗ ██╔╝
26
+ ██████╔╝███████║ ██████╔╝███████║ ╚████╔╝
27
+ ██╔══██╗██╔══██║ ██╔═══╝ ██╔══██║ ╚██╔╝
28
+ ██║ ██║██║ ██║ ██║ ██║ ██║ ██║
29
+ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
30
+ `;
31
+
32
+ // Platform/arch to binary name mapping
33
+ // NOTE: linux-arm64 not supported yet (keyring native libs don't cross-compile)
34
+ const BINARY_MAP = {
35
+ 'darwin-x64': 'ra-darwin-x64',
36
+ 'darwin-arm64': 'ra-darwin-arm64',
37
+ 'linux-x64': 'ra-linux-x64',
38
+ 'win32-x64': 'ra-win32-x64.exe',
39
+ };
40
+
41
+ function getPlatformKey() {
42
+ const platform = os.platform();
43
+ const arch = os.arch();
44
+ return `${platform}-${arch}`;
45
+ }
46
+
47
+ function getBinaryName() {
48
+ const key = getPlatformKey();
49
+ const binary = BINARY_MAP[key];
50
+
51
+ if (!binary) {
52
+ console.error(`Unsupported platform: ${key}`);
53
+ console.error(`Supported platforms: ${Object.keys(BINARY_MAP).join(', ')}`);
54
+ console.error('');
55
+ console.error('For linux-arm64, please build from source:');
56
+ console.error(' git clone https://github.com/Ra-Pay-AI/rapay');
57
+ console.error(' cd rapay/cli && cargo build --release');
58
+ process.exit(1);
59
+ }
60
+
61
+ return binary;
62
+ }
63
+
64
+ function getDownloadUrl(filename) {
65
+ return `${CDN_BASE}/v${VERSION}/${filename}`;
66
+ }
67
+
68
+ function download(url) {
69
+ return new Promise((resolve, reject) => {
70
+ const chunks = [];
71
+
72
+ const request = (url) => {
73
+ const urlObj = new URL(url);
74
+ const options = {
75
+ hostname: urlObj.hostname,
76
+ path: urlObj.pathname,
77
+ headers: {
78
+ 'User-Agent': 'rapay-installer/1.0',
79
+ 'Accept': '*/*'
80
+ }
81
+ };
82
+
83
+ https.get(options, (response) => {
84
+ // Handle redirects
85
+ if (response.statusCode === 301 || response.statusCode === 302) {
86
+ request(response.headers.location);
87
+ return;
88
+ }
89
+
90
+ if (response.statusCode !== 200) {
91
+ reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
92
+ return;
93
+ }
94
+
95
+ response.on('data', (chunk) => chunks.push(chunk));
96
+ response.on('end', () => resolve(Buffer.concat(chunks)));
97
+ response.on('error', reject);
98
+ }).on('error', reject);
99
+ };
100
+
101
+ request(url);
102
+ });
103
+ }
104
+
105
+ function calculateSha256(buffer) {
106
+ return createHash('sha256').update(buffer).digest('hex');
107
+ }
108
+
109
+ function parseChecksums(content) {
110
+ const checksums = {};
111
+ const lines = content.toString().split('\n');
112
+
113
+ for (const line of lines) {
114
+ // Skip comments and empty lines
115
+ if (line.startsWith('#') || !line.trim()) continue;
116
+
117
+ // Format: "hash filename" or "hash filename"
118
+ const match = line.match(/^([a-f0-9]{64})\s+(.+)$/i);
119
+ if (match) {
120
+ const [, hash, filename] = match;
121
+ checksums[filename.trim()] = hash.toLowerCase();
122
+ }
123
+ }
124
+
125
+ return checksums;
126
+ }
127
+
128
+ async function install() {
129
+ const binDir = path.join(__dirname, 'bin');
130
+ const platform = os.platform();
131
+ const binaryName = getBinaryName();
132
+ // Windows: ra.exe, Unix: ra-binary (launcher script handles dispatch)
133
+ const destName = platform === 'win32' ? 'ra.exe' : 'ra-binary';
134
+ const destPath = path.join(binDir, destName);
135
+ const binaryUrl = getDownloadUrl(binaryName);
136
+ const checksumsUrl = getDownloadUrl('checksums.txt');
137
+
138
+ console.log(`Installing Ra Pay CLI v${VERSION} for ${getPlatformKey()}...`);
139
+
140
+ // Create bin directory
141
+ if (!fs.existsSync(binDir)) {
142
+ fs.mkdirSync(binDir, { recursive: true });
143
+ }
144
+
145
+ try {
146
+ // Step 1: Download checksums.txt
147
+ console.log('Downloading checksums...');
148
+ let checksums = {};
149
+ try {
150
+ const checksumsContent = await download(checksumsUrl);
151
+ checksums = parseChecksums(checksumsContent);
152
+ console.log(` Found ${Object.keys(checksums).length} checksums`);
153
+ } catch (error) {
154
+ console.error('');
155
+ console.error('SECURITY ERROR: Could not download checksums.txt');
156
+ console.error('Cannot verify binary integrity. Installation aborted.');
157
+ console.error('');
158
+ console.error('If this is a new release, checksums may not be published yet.');
159
+ console.error('Try again in a few minutes or contact support@rapay.ai');
160
+ process.exit(1);
161
+ }
162
+
163
+ // Step 2: Download binary
164
+ console.log(`Downloading ${binaryName}...`);
165
+ const binaryBuffer = await download(binaryUrl);
166
+ console.log(` Downloaded ${(binaryBuffer.length / 1024 / 1024).toFixed(2)} MB`);
167
+
168
+ // Step 3: Verify checksum (if available)
169
+ const expectedHash = checksums[binaryName];
170
+ if (expectedHash) {
171
+ console.log('Verifying checksum...');
172
+ const actualHash = calculateSha256(binaryBuffer);
173
+
174
+ if (actualHash !== expectedHash) {
175
+ console.error('');
176
+ console.error('SECURITY ERROR: Checksum verification failed!');
177
+ console.error(` Expected: ${expectedHash}`);
178
+ console.error(` Got: ${actualHash}`);
179
+ console.error('');
180
+ console.error('The downloaded binary may have been tampered with.');
181
+ console.error('Please report this issue at: https://github.com/Ra-Pay-AI/rapay/issues');
182
+ process.exit(1);
183
+ }
184
+
185
+ console.log(' Checksum verified OK');
186
+ } else if (Object.keys(checksums).length > 0) {
187
+ // We have checksums but not for this binary - suspicious
188
+ console.error('');
189
+ console.error(`SECURITY ERROR: No checksum found for ${binaryName}`);
190
+ console.error('Cannot verify binary integrity. Installation aborted.');
191
+ console.error('');
192
+ console.error('This may indicate a supply chain attack or misconfigured release.');
193
+ console.error('Please report this at: https://github.com/Ra-Pay-AI/rapay/issues');
194
+ process.exit(1);
195
+ }
196
+
197
+ // Step 4: Write binary to disk
198
+ fs.writeFileSync(destPath, binaryBuffer);
199
+
200
+ // Step 5: Make executable on Unix
201
+ if (platform !== 'win32') {
202
+ fs.chmodSync(destPath, 0o755);
203
+ // Also ensure launcher script is executable
204
+ const launcherPath = path.join(binDir, 'ra');
205
+ if (fs.existsSync(launcherPath)) {
206
+ fs.chmodSync(launcherPath, 0o755);
207
+ }
208
+ }
209
+
210
+ console.log('');
211
+ console.log(OPTIC_YELLOW + LOGO + RESET);
212
+ console.log('Ra Pay CLI installed successfully!');
213
+ console.log('');
214
+ console.log('Quick start:');
215
+ console.log(' ra link-bank Connect your Stripe account');
216
+ console.log(' ra balance Check your balance');
217
+ console.log(' ra send Send payments');
218
+ console.log('');
219
+ console.log('Run "ra --help" for all commands.');
220
+ } catch (error) {
221
+ console.error('');
222
+ console.error('Failed to install Ra Pay CLI:', error.message);
223
+ console.error('');
224
+ console.error('You can manually download the binary from:');
225
+ console.error(`${CDN_BASE}/v${VERSION}/`);
226
+ process.exit(1);
227
+ }
228
+ }
229
+
230
+ install();
package/package.json CHANGED
@@ -1,51 +1,51 @@
1
- {
2
- "name": "rapay",
3
- "version": "1.3.1",
4
- "description": "CLI-native payment infrastructure for AI agents. Send fiat USD payments via Stripe without browser automation.",
5
- "keywords": [
6
- "cli",
7
- "payments",
8
- "ai-agents",
9
- "stripe",
10
- "fiat",
11
- "terminal",
12
- "automation",
13
- "mcp",
14
- "claude",
15
- "chatgpt"
16
- ],
17
- "author": "Ra Pay AI, LLC <e@rapay.ai>",
18
- "license": "UNLICENSED",
19
- "homepage": "https://rapay.ai",
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/Ra-Pay-AI/rapay"
23
- },
24
- "bugs": {
25
- "url": "https://github.com/Ra-Pay-AI/rapay/issues"
26
- },
27
- "bin": {
28
- "ra": "bin/ra"
29
- },
30
- "scripts": {
31
- "postinstall": "node install.js"
32
- },
33
- "engines": {
34
- "node": ">=14.0.0"
35
- },
36
- "os": [
37
- "darwin",
38
- "linux",
39
- "win32"
40
- ],
41
- "cpu": [
42
- "x64",
43
- "arm64"
44
- ],
45
- "files": [
46
- "bin",
47
- "install.js",
48
- "README.md",
49
- "LICENSE"
50
- ]
51
- }
1
+ {
2
+ "name": "rapay",
3
+ "version": "1.3.3",
4
+ "description": "CLI-native payment infrastructure for AI agents. Send fiat USD payments via Stripe without browser automation.",
5
+ "keywords": [
6
+ "cli",
7
+ "payments",
8
+ "ai-agents",
9
+ "stripe",
10
+ "fiat",
11
+ "terminal",
12
+ "automation",
13
+ "mcp",
14
+ "claude",
15
+ "chatgpt"
16
+ ],
17
+ "author": "Ra Pay AI, LLC <e@rapay.ai>",
18
+ "license": "UNLICENSED",
19
+ "homepage": "https://rapay.ai",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/Ra-Pay-AI/rapay"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/Ra-Pay-AI/rapay/issues"
26
+ },
27
+ "bin": {
28
+ "ra": "bin/ra"
29
+ },
30
+ "scripts": {
31
+ "postinstall": "node install.js"
32
+ },
33
+ "engines": {
34
+ "node": ">=14.0.0"
35
+ },
36
+ "os": [
37
+ "darwin",
38
+ "linux",
39
+ "win32"
40
+ ],
41
+ "cpu": [
42
+ "x64",
43
+ "arm64"
44
+ ],
45
+ "files": [
46
+ "bin",
47
+ "install.js",
48
+ "README.md",
49
+ "LICENSE"
50
+ ]
51
+ }