@paychainly/cli 1.0.3 → 1.0.4

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/bin/paychainly.js CHANGED
@@ -16,7 +16,7 @@ if (!cmd || cmd === 'help' || cmd === '--help' || cmd === '-h') {
16
16
  --api-key Your Paychainly API key (pk_live_... or pk_test_...)
17
17
  --port Local port to forward webhooks to (default: 3000)
18
18
  --forward-to Full local URL to forward webhooks to
19
- --host Paychainly server URL (default: http://localhost:3002)
19
+ --host Paychainly server URL (default: https://api.paychainly.com)
20
20
  --secret Webhook secret to verify incoming signatures
21
21
  `);
22
22
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paychainly/cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Paychainly CLI — relay webhooks to your localhost during development",
5
5
  "keywords": [
6
6
  "paychainly",
@@ -14,8 +14,7 @@
14
14
  "homepage": "https://paychainly.com",
15
15
  "license": "MIT",
16
16
  "bin": {
17
- "paychainly": "bin/paychainly.js",
18
- "paychainly-cli": "bin/paychainly.js"
17
+ "paychainly": "bin/paychainly.js"
19
18
  },
20
19
  "files": [
21
20
  "bin/",
package/src/listen.js CHANGED
@@ -90,7 +90,7 @@ function eventColor(event) {
90
90
  module.exports = function listen(argv) {
91
91
  const args = parseArgs(argv);
92
92
  const apiKey = args['api-key'] || process.env.PAYCHAINLY_API_KEY;
93
- const host = args['host'] || process.env.PAYCHAINLY_HOST || 'http://localhost:3002';
93
+ const host = args['host'] || process.env.PAYCHAINLY_HOST || 'https://api.paychainly.com';
94
94
  const secret = args['secret'] || process.env.PAYCHAINLY_WEBHOOK_SECRET || '';
95
95
  const forwardTo = args['forward-to'] || (args['port'] ? `http://localhost:${args['port']}/webhook` : 'http://localhost:3000/webhook');
96
96
 
package/README.md DELETED
@@ -1,98 +0,0 @@
1
- # @paychainly/cli
2
-
3
- Relay Paychainly webhooks to your local development server. No public URL or tunneling service required.
4
-
5
- ## The Problem
6
-
7
- When you add a webhook URL like `http://localhost:3000/webhook` in the Paychainly dashboard, the Paychainly server cannot reach your machine — it's behind NAT/firewall. This CLI solves that by opening an outbound WebSocket connection from your machine to Paychainly and forwarding incoming webhooks locally.
8
-
9
- ## Installation
10
-
11
- No install needed — use `npx`:
12
-
13
- ```bash
14
- npx @paychainly/cli listen --api-key <your-api-key> --port 3000
15
- ```
16
-
17
- Or install globally:
18
-
19
- ```bash
20
- npm install -g @paychainly/cli
21
- paychainly listen --api-key <your-api-key> --port 3000
22
- ```
23
-
24
- ## Usage
25
-
26
- ```
27
- paychainly listen [options]
28
-
29
- Options:
30
- --api-key Your Paychainly API key (pk_live_... or pk_test_...) [required]
31
- --port Local port to forward webhooks to (default: 3000)
32
- --forward-to Full local URL to forward webhooks to (overrides --port)
33
- --host Paychainly server URL (default: https://api.paychainly.com)
34
- --secret Webhook signing secret to verify HMAC-SHA256 signatures
35
- ```
36
-
37
- ### Basic — forward to port 3000
38
-
39
- ```bash
40
- npx @paychainly/cli listen \
41
- --api-key pk_live_xxxxxxxxxxxxxxxxxxxx \
42
- --port 3000
43
- ```
44
-
45
- ### Custom path
46
-
47
- ```bash
48
- npx @paychainly/cli listen \
49
- --api-key pk_live_xxxxxxxxxxxxxxxxxxxx \
50
- --forward-to http://localhost:4000/api/webhook
51
- ```
52
-
53
- ### With signature verification
54
-
55
- If you set a webhook secret in the Paychainly dashboard, pass it here to verify every incoming signature:
56
-
57
- ```bash
58
- npx @paychainly/cli listen \
59
- --api-key pk_live_xxxxxxxxxxxxxxxxxxxx \
60
- --port 3000 \
61
- --secret whsec_xxxxxxxxxxxxxxxxxxxx
62
- ```
63
-
64
- ## How It Works
65
-
66
- 1. The CLI connects to Paychainly via WebSocket using your API key.
67
- 2. Paychainly detects that your webhook URL points to `localhost` and routes events through the relay instead of making a direct HTTP call.
68
- 3. The CLI receives each event, POSTs it to your local server, and returns the response back to Paychainly.
69
-
70
- Your local server handles webhooks exactly as it would in production — same headers, same payload, same HMAC signature.
71
-
72
- ## Webhook Payload
73
-
74
- Paychainly sends a signed `POST` with `Content-Type: application/json`. The `X-Paychainly-Signature` header contains an HMAC-SHA256 signature you can verify:
75
-
76
- ```js
77
- const crypto = require('crypto')
78
-
79
- function verifySignature(rawBody, signature, secret) {
80
- const expected = crypto
81
- .createHmac('sha256', secret)
82
- .update(rawBody)
83
- .digest('hex')
84
- return crypto.timingSafeEqual(
85
- Buffer.from(signature),
86
- Buffer.from(expected)
87
- )
88
- }
89
- ```
90
-
91
- ## Requirements
92
-
93
- - Node.js 18 or later
94
- - A Paychainly account with an API key
95
-
96
- ## License
97
-
98
- MIT