@stripe/link-cli 0.0.1 → 0.1.1

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 (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +223 -0
  3. package/dist/cli.js +14079 -0
  4. package/package.json +46 -8
  5. package/index.js +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Stripe, LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,223 @@
1
+ # Link CLI
2
+
3
+ Link CLI lets agents get secure, one-time-use payment credentials from a Link wallet — so they can complete purchases on your behalf without ever storing your real card details.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i -g @stripe/link-cli
9
+ ```
10
+
11
+ Or run directly with `npx`:
12
+
13
+ ```bash
14
+ npx @stripe/link-cli
15
+ ```
16
+
17
+ You can install the skill via `link-cli skill --install`.
18
+
19
+ ## Quickstart
20
+
21
+ ### Login
22
+
23
+ The `link-cli` requires a Link account. You can login to your existing one or [register online](https://app.link.com).
24
+
25
+ ```bash
26
+ link-cli auth login
27
+ ```
28
+
29
+ You'll receive a verification URL and a short passphrase. Visit the URL, log in to your Link account, and enter the passphrase to approve the connection.
30
+
31
+ ### List payment methods
32
+
33
+ ```bash
34
+ link-cli payment-methods list
35
+ ```
36
+
37
+ Returns the cards and bank accounts saved to your Link account. Use the `id` field as `payment_method_id` in the next step. If you have no payment methods, you can [add new ones in Link](https://app.link.com/wallet).
38
+
39
+ ### Create a spend request
40
+
41
+ To request a secure, one-time payment credential from your Link wallet, you create a spend request. You specify a payment method in your account, as well as some merchant details, line items, and amounts.
42
+
43
+ ```bash
44
+ link-cli spend-request create \
45
+ --payment-method-id csmrpd_xxx \
46
+ --merchant-name "Stripe Press" \
47
+ --merchant-url "https://press.stripe.com" \
48
+ --context "Purchasing 'Working in Public' from press.stripe.com. The user initiated this purchase through the shopping assistant." \
49
+ --amount 3500 \
50
+ --line-item "name:Working in Public,unit_amount:3500,quantity:1" \
51
+ --total "type:total,display_text:Total,amount:3500" \
52
+ --request-approval
53
+ ```
54
+
55
+ The `--request-approval` flag triggers a push notification (or email) to the user for approval, then polls until the request is approved or denied.
56
+
57
+ Users can easily approve requests with the [Link app](https://link.com/download).
58
+
59
+ #### Credential types
60
+
61
+ By default, a spend request provisions a virtual card. For merchants that support the [Machine Payments Protocol](https://mpp.dev) (HTTP 402) and the Stripe payment method, you can instead include `--credential-type "shared_payment_token"`.
62
+
63
+ ### Execute payment
64
+
65
+ The approved spend request includes a `card` object with `number`, `cvc`, `exp_month`, `exp_year`, `billing_address`, and `valid_until`. Enter these into the merchant's checkout form.
66
+
67
+ ```bash
68
+ link-cli spend-request retrieve lsrq_001 --output-json
69
+ ```
70
+ By default, retrieving a spend request will not include card details. Use the `--include=card` to see unmasked card details.
71
+
72
+ If the merchant supports MPP, use `link-cli mpp pay` instead:
73
+
74
+ ```bash
75
+ link-cli mpp pay https://climate.stripe.dev/api/contribute \
76
+ --spend-request-id lsrq_001 \
77
+ --method POST \
78
+ --data '{"amount":100}' \
79
+ --output-json
80
+ ```
81
+
82
+ ## Advanced
83
+
84
+ ### Authentication
85
+
86
+ ```bash
87
+ link-cli auth login --client-name "Claude Code" --output-json # identify the connecting agent
88
+ link-cli auth status --output-json # check auth status
89
+ link-cli auth logout --output-json # disconnect
90
+ ```
91
+
92
+ When `--client-name` is provided, the name is shown in the Link app when the user approves the connection — e.g. `Claude Code on my-macbook` instead of `link-cli on my-macbook`.
93
+
94
+ ### Spend request lifecycle
95
+
96
+ A spend request moves through: **create** → **request approval** → **approved** (with credentials).
97
+
98
+ **Required fields for create:** `payment_method_id`, `merchant_name`, `merchant_url`, `context`, `amount`
99
+
100
+ **Constraints:** `context` must be at least 100 characters; `amount` must not exceed 50000 (cents); `currency` must be a 3-letter ISO code.
101
+ **Test mode:** Pass `--test` to create testmode credentials (uses test card `4242424242424242`). Useful for development and integration testing without using real payment methods.
102
+
103
+ ```bash
104
+ # Update before approval
105
+ link-cli spend-request update lsrq_001 \
106
+ --merchant-url https://press.stripe.com/working-in-public \
107
+ --output-json
108
+
109
+ # Request approval separately (alternative to create --request-approval)
110
+ link-cli spend-request request-approval lsrq_001 --output-json
111
+
112
+ # Retrieve at any time (includes card credentials once approved)
113
+ link-cli spend-request retrieve lsrq_001 --output-json
114
+ ```
115
+
116
+ ### JSON
117
+
118
+ All commands accept `--json` for structured input (mutually exclusive with flags):
119
+
120
+ ```bash
121
+ link-cli spend-request create --json '{
122
+ "payment_method_id": "csmrpd_xxx",
123
+ "merchant_name": "Stripe Press",
124
+ "merchant_url": "https://press.stripe.com/working-in-public",
125
+ "context": "Purchasing '\''Working in Public'\'' from press.stripe.com. The user initiated this purchase through the shopping assistant.",
126
+ "amount": 3500,
127
+ "line_items": [{ "name": "Working in Public", "unit_amount": 3500, "quantity": 1 }],
128
+ "totals": [{ "type": "total", "display_text": "Total", "amount": 3500 }]
129
+ }' --output-json
130
+ ```
131
+
132
+ All commands also accept `--output-json` for structured JSON output. Errors are returned as JSON to stderr with exit code 1.
133
+
134
+ ### MPP
135
+
136
+ Use `mpp pay` to complete purchases on merchants that use the [Machine Payments Protocol](https://mpp.dev). The spend request must use `credential_type: "shared_payment_token"` and be approved. The SPT is one-time-use — if payment fails, create a new spend request.
137
+
138
+ ```bash
139
+ link-cli mpp pay https://climate.stripe.dev/api/contribute \
140
+ --spend-request-id lsrq_001 \
141
+ --method POST \
142
+ --data '{"amount":100}' \
143
+ --header "X-Custom: value" \
144
+ --output-json
145
+ ```
146
+
147
+ Use `mpp decode` to validate a raw `WWW-Authenticate` header and extract the `network_id` needed for `shared_payment_token` spend requests:
148
+
149
+ ```bash
150
+ link-cli mpp decode \
151
+ --challenge 'Payment id="ch_001", realm="merchant.example", method="stripe", intent="charge", request="..."' \
152
+ --output-json
153
+ ```
154
+
155
+ ### Environment variables
156
+
157
+ | Variable | Effect |
158
+ |----------|--------|
159
+ | `LINK_API_BASE_URL` | Override the API base URL |
160
+ | `LINK_AUTH_BASE_URL` | Override the auth base URL |
161
+ | `LINK_HTTP_PROXY` | Route all requests through an HTTP proxy (requires `undici`) |
162
+
163
+ ## Development
164
+
165
+ ```bash
166
+ pnpm install
167
+ pnpm run build
168
+ pnpm run link-cli --help
169
+ ```
170
+
171
+ Watch mode:
172
+
173
+ ```bash
174
+ pnpm run dev
175
+ ```
176
+
177
+ Run tests:
178
+
179
+ ```bash
180
+ pnpm run test
181
+ ```
182
+
183
+ Type-check and lint:
184
+
185
+ ```bash
186
+ pnpm run typecheck
187
+ pnpm biome check .
188
+ ```
189
+
190
+ ## Releasing
191
+
192
+ This project uses [Changesets](https://github.com/changesets/changesets) to manage versioning and publishing. Only `@stripe/link-cli` is published to npm — internal packages (`@stripe/link-sdk`, `@stripe/link-typescript-config`) are ignored by changesets.
193
+
194
+ ### Add a changeset
195
+
196
+ When you make a user-facing change, add a changeset before merging:
197
+
198
+ ```bash
199
+ pnpm changeset
200
+ ```
201
+
202
+ Follow the prompts to select the package (`@stripe/link-cli`) and the semver bump type (patch, minor, or major). This creates a markdown file in `.changeset/` describing the change.
203
+
204
+ ### Version
205
+
206
+ Once changesets have accumulated on `main`, create a version PR:
207
+
208
+ ```bash
209
+ pnpm changeset version
210
+ ```
211
+
212
+ This consumes all pending changesets, bumps the version in `packages/cli/package.json`, and updates `CHANGELOG.md`.
213
+
214
+ ### Publish
215
+
216
+ After the version PR is merged:
217
+
218
+ ```bash
219
+ pnpm run build
220
+ pnpm changeset publish
221
+ ```
222
+
223
+ This publishes `@stripe/link-cli` to npm. CI also runs `pnpm --filter @stripe/link-cli publish --dry-run --no-git-checks` on every push to `main` to verify the package is publishable.