@xodn348/clawpay 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.
package/DISCLAIMER.md ADDED
@@ -0,0 +1,88 @@
1
+ # ClawPay Disclaimer
2
+
3
+ ⚠️ IMPORTANT: Read this disclaimer carefully before using ClawPay.
4
+
5
+ By using ClawPay, you agree to the terms of the Apache License 2.0 and acknowledge this disclaimer.
6
+
7
+ ---
8
+
9
+ ## 1. Financial Disclaimer
10
+
11
+ This software is not financial advice. Use of ClawPay may result in real monetary transactions. You assume full responsibility for all payments initiated through this software.
12
+
13
+ ClawPay does not provide investment advice, tax guidance, or any form of financial planning. Nothing in this software or its documentation constitutes a recommendation to make any financial decision. All payment amounts, recipients, and timing are determined solely by you or by an AI agent acting under your direction.
14
+
15
+ Before deploying ClawPay in any production environment, consult qualified legal and financial professionals to understand the implications for your specific use case.
16
+
17
+ ---
18
+
19
+ ## 2. AI Agent Disclaimer
20
+
21
+ Actions performed by an AI agent through ClawPay are NOT acts of ClawPay's authors or contributors. The authors are not responsible for autonomous agent decisions.
22
+
23
+ When ClawPay is used as a tool by an AI agent (including but not limited to large language models, autonomous agents, or agentic frameworks), the agent acts on behalf of the user or operator who configured and deployed it, not on behalf of ClawPay's authors or contributors. The authors of ClawPay have no visibility into, control over, or responsibility for:
24
+
25
+ - Payment amounts or recipients chosen by an AI agent
26
+ - The frequency or timing of agent-initiated transactions
27
+ - Errors in agent reasoning that result in unintended payments
28
+ - Prompt injection attacks that manipulate agent behavior
29
+
30
+ You are solely responsible for implementing appropriate guardrails, spending limits, human-in-the-loop approval flows, and monitoring when deploying ClawPay in agentic contexts. The authorization ambiguity inherent in autonomous agent payments is a known risk that you must address before production use.
31
+
32
+ ---
33
+
34
+ ## 3. PCI DSS Statement
35
+
36
+ ClawPay never processes, stores, or transmits raw cardholder data (PANs, CVVs). All card input is handled exclusively by Stripe's PCI-compliant Checkout. ClawPay is not in PCI scope.
37
+
38
+ ClawPay integrates with Stripe's hosted payment pages and tokenization infrastructure. Raw card numbers, CVV codes, expiration dates, and other sensitive authentication data never pass through ClawPay's codebase, servers, or logs. Stripe holds PCI DSS Level 1 certification, the highest level of compliance available.
39
+
40
+ This architecture means ClawPay itself does not fall within the scope of PCI DSS requirements. However, your overall payment system may still have PCI obligations depending on how you deploy and integrate ClawPay. Consult a Qualified Security Assessor (QSA) if you have questions about your specific compliance posture.
41
+
42
+ ---
43
+
44
+ ## 4. Not a Money Transmitter
45
+
46
+ ClawPay is a software tool that interfaces with the Stripe API. It is not a payment processor, money transmitter, or financial institution.
47
+
48
+ ClawPay does not hold, move, or settle funds. All payment processing, fund movement, and settlement is performed by Stripe, Inc. under Stripe's own licenses and regulatory authorizations. ClawPay has no money transmission license and does not operate as a financial intermediary.
49
+
50
+ If your use of ClawPay involves activities that may require money transmission licenses, payment facilitator agreements, or other financial regulatory approvals in your jurisdiction, you are responsible for obtaining those approvals independently.
51
+
52
+ ---
53
+
54
+ ## 5. Credential Security
55
+
56
+ You are solely responsible for securing your Stripe API keys. Never commit API keys to version control. ClawPay stores keys only in environment variables.
57
+
58
+ Stripe API keys grant the ability to initiate real financial transactions. Treat them with the same care as passwords or private keys. Specifically:
59
+
60
+ - Do not hardcode API keys in source code
61
+ - Do not commit `.env` files or any file containing API keys to git
62
+ - Rotate keys immediately if you suspect they have been exposed
63
+ - Use Stripe's restricted key feature to limit key permissions to only what ClawPay needs
64
+ - Audit your Stripe Dashboard regularly for unexpected API activity
65
+
66
+ ClawPay reads API keys from environment variables at runtime and does not persist them to disk, logs, or any external service. However, ClawPay cannot protect keys that are mishandled outside of its own execution context. A compromised key can result in unauthorized charges, refunds, or data access on your Stripe account.
67
+
68
+ ---
69
+
70
+ ## 6. Limitation of Liability
71
+
72
+ As stated in Apache License 2.0, Section 8:
73
+
74
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
75
+
76
+ This limitation applies to all damages arising from use of ClawPay, including but not limited to:
77
+
78
+ - Unauthorized or unintended payments initiated through the software
79
+ - Financial losses resulting from AI agent decisions
80
+ - Data breaches caused by improper credential handling
81
+ - Regulatory penalties arising from non-compliant deployments
82
+ - Any other direct or indirect financial harm
83
+
84
+ The full text of the Apache License 2.0 is available in the LICENSE file at the root of this repository.
85
+
86
+ ---
87
+
88
+ *Last updated: 2026*
@@ -0,0 +1,17 @@
1
+ class Clawpay < Formula
2
+ desc "Open-source Stripe MCP Server for AI Agents"
3
+ homepage "https://github.com/xodn348/clawpay"
4
+ url "https://registry.npmjs.org/clawpay/-/clawpay-0.1.0.tgz"
5
+ sha256 "placeholder_sha256"
6
+ license "Apache-2.0"
7
+ depends_on "node"
8
+
9
+ def install
10
+ system "npm", "install", *Language::Node.std_npm_install_args(libexec)
11
+ bin.install_symlink Dir["#{libexec}/bin/*"]
12
+ end
13
+
14
+ test do
15
+ assert_match "clawpay", shell_output("#{bin}/clawpay --help 2>&1", 1)
16
+ end
17
+ end
package/LICENSE ADDED
@@ -0,0 +1,198 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or otherwise designated in writing by the copyright owner as
57
+ "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a
80
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
81
+ or a Contribution incorporated within the Work constitutes direct
82
+ or contributory patent infringement, then any patent licenses
83
+ granted to You under this License for that Work shall terminate
84
+ as of the date such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or
92
+ Derivative Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or as an addendum to
115
+ the NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, copy, modify, merge,
120
+ publish, distribute, sublicense, and/or sell copies of the
121
+ Derivative Works, and to permit persons to whom the Derivative Works
122
+ is furnished to do so, subject to the following conditions:
123
+
124
+ The above copyright notice and this permission notice shall be
125
+ included in all copies or substantial portions of the Software.
126
+
127
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
128
+ any Contribution intentionally submitted for inclusion in the Work
129
+ by You to the Licensor shall be under the terms and conditions of
130
+ this License, without any additional terms or conditions.
131
+ Notwithstanding the above, nothing herein shall supersede or modify
132
+ the terms of any separate license agreement you may have executed
133
+ with Licensor regarding such Contributions.
134
+
135
+ 6. Trademarks. This License does not grant permission to use the trade
136
+ names, trademarks, service marks, or product names of the Licensor,
137
+ except as required for reasonable and customary use in describing the
138
+ origin of the Work and reproducing the content of the NOTICE file.
139
+
140
+ 7. Disclaimer of Warranty. Unless required by applicable law or
141
+ agreed to in writing, Licensor provides the Work (and each
142
+ Contributor provides its Contributions) on an "AS IS" BASIS,
143
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
144
+ implied, including, without limitation, any warranties or conditions
145
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
146
+ PARTICULAR PURPOSE. You are solely responsible for determining the
147
+ appropriateness of using or redistributing the Work and assume any
148
+ risks associated with Your exercise of permissions under this License.
149
+
150
+ 8. Limitation of Liability. In no event and under no legal theory,
151
+ whether in tort (including negligence), contract, or otherwise,
152
+ unless required by applicable law (such as deliberate and grossly
153
+ negligent acts) or agreed to in writing, shall any Contributor be
154
+ liable to You for damages, including any direct, indirect, special,
155
+ incidental, or exemplary damages of any character arising as a
156
+ result of this License or out of the use or inability to use the
157
+ Work (including but not limited to damages for loss of goodwill,
158
+ work stoppage, computer failure or malfunction, or all other
159
+ commercial damages or losses), even if such Contributor has been
160
+ advised of the possibility of such damages.
161
+
162
+ 9. Accepting Warranty or Additional Liability. While redistributing
163
+ the Work or Derivative Works thereof, You may choose to offer,
164
+ and charge a fee for, acceptance of support, warranty, indemnity,
165
+ or other liability obligations and/or rights consistent with this
166
+ License. However, in accepting such obligations, You may act only
167
+ on Your own behalf and on Your sole responsibility, not on behalf
168
+ of any other Contributor, and only if You agree to indemnify,
169
+ defend, and hold each Contributor harmless for any liability
170
+ incurred by, or claims asserted against, such Contributor by reason
171
+ of your accepting any such warranty or additional liability.
172
+
173
+ END OF TERMS AND CONDITIONS
174
+
175
+ APPENDIX: How to apply the Apache License to your work.
176
+
177
+ To apply the Apache License to your work, attach the following
178
+ boilerplate notice, with the fields enclosed by brackets "[]"
179
+ replaced with your own identifying information. (Don't include
180
+ the brackets!) The text should be enclosed in the appropriate
181
+ comment syntax for the file format in use. We also recommend that
182
+ a file or class name and description of purpose be included on the
183
+ same "first page" as the copyright notice for easier identification
184
+ within third-party archives.
185
+
186
+ Copyright 2026 ClawPay Contributors
187
+
188
+ Licensed under the Apache License, Version 2.0 (the "License");
189
+ you may not use this file except in compliance with the License.
190
+ You may obtain a copy of the License at
191
+
192
+ http://www.apache.org/licenses/LICENSE-2.0
193
+
194
+ Unless required by applicable law or agreed to in writing, software
195
+ distributed under the License is distributed on an "AS IS" BASIS,
196
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
197
+ See the License for the specific language governing permissions and
198
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ [![CI](https://github.com/xodn348/clawpay/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/xodn348/clawpay/actions/workflows/ci.yml)
2
+ [![Coverage: 100%](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/xodn348/clawpay/actions/workflows/ci.yml)
3
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
4
+ [![Stripe](https://img.shields.io/badge/Stripe-Powered-635BFF.svg)](https://stripe.com)
5
+ [![MCP](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io)
6
+
7
+ # ClawPay
8
+
9
+ Open-source Stripe MCP Server for AI Agents. Let Claude, OpenCode, and any MCP client make payments.
10
+
11
+ > [!WARNING]
12
+ > ClawPay enables AI agents to make real financial transactions. Real money is involved.
13
+ > AI agent payments may be irreversible. You are responsible for all charges made through your Stripe account.
14
+ > Review your guardrail limits before use. See [DISCLAIMER.md](DISCLAIMER.md) for full terms.
15
+
16
+ > [!NOTE]
17
+ > **ClawPay has zero contact with card data.** Card numbers, CVVs, and expiration dates never pass through ClawPay's code, memory, or logs. All card input is handled entirely by [Stripe Checkout](https://stripe.com/payments/checkout) on Stripe's PCI DSS-certified servers. ClawPay only stores Stripe-issued customer IDs and payment method IDs.
18
+
19
+ ---
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ npm install -g @xodn348/clawpay
25
+ clawpay install
26
+ ```
27
+
28
+ `clawpay install` handles the full setup automatically:
29
+
30
+ 1. Prompts for your Stripe secret key
31
+ 2. Detects OpenCode, Claude Desktop, and Cursor on your machine
32
+ 3. Patches their MCP config files to register ClawPay
33
+ 4. Confirms the connection
34
+
35
+ Once installed, open your AI assistant and say: **"set up payment method"** to register a card through Stripe Checkout.
36
+
37
+ ---
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ # npm
43
+ npm install -g @xodn348/clawpay
44
+
45
+ # bun
46
+ bun add -g @xodn348/clawpay
47
+
48
+ # brew (coming soon)
49
+ brew tap xodn348/clawpay
50
+ brew install clawpay
51
+ ```
52
+
53
+ Node.js 18 or higher is required.
54
+
55
+ ---
56
+
57
+ ## Manual Configuration
58
+
59
+ If auto-detection doesn't find your client, add ClawPay manually.
60
+
61
+ ### OpenCode (`opencode.json`)
62
+
63
+ ```json
64
+ {
65
+ "mcp": {
66
+ "clawpay": {
67
+ "type": "local",
68
+ "command": ["clawpay"],
69
+ "environment": {
70
+ "STRIPE_SECRET_KEY": "sk_test_..."
71
+ }
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ ### Claude Desktop (`claude_desktop_config.json`)
78
+
79
+ ```json
80
+ {
81
+ "mcpServers": {
82
+ "clawpay": {
83
+ "command": "clawpay",
84
+ "args": [],
85
+ "env": {
86
+ "STRIPE_SECRET_KEY": "sk_test_..."
87
+ }
88
+ }
89
+ }
90
+ }
91
+ ```
92
+
93
+ ### Cursor (`~/.cursor/mcp.json`)
94
+
95
+ Same format as Claude Desktop above.
96
+
97
+ Replace `sk_test_...` with your actual Stripe secret key. Use a test key (`sk_test_`) during development and a live key (`sk_live_`) only in production.
98
+
99
+ ---
100
+
101
+ ## MCP Tools Reference
102
+
103
+ ClawPay exposes five tools over the MCP stdio protocol.
104
+
105
+ ### `setup_payment`
106
+
107
+ Opens Stripe Checkout in your browser to register a card. Saves the resulting Stripe customer ID and payment method ID to `~/.clawpay/config.json`. No parameters.
108
+
109
+ ### `pay`
110
+
111
+ Charges the registered payment method.
112
+
113
+ | Parameter | Type | Required | Default | Description |
114
+ |-----------|------|----------|---------|-------------|
115
+ | `amount` | integer | yes | | Amount in cents (e.g., `1000` for $10.00) |
116
+ | `currency` | string | no | `"usd"` | ISO 4217 currency code |
117
+ | `description` | string | yes | | Human-readable description of the charge |
118
+
119
+ Returns a `PaymentResult` with fields: `success`, `paymentIntentId`, `amount`, `currency`, `status`, `error`.
120
+
121
+ ### `get_balance`
122
+
123
+ Returns the current Stripe account balance. No parameters.
124
+
125
+ Returns a `BalanceInfo` with `available` and `pending` arrays, each containing `amount` (cents) and `currency`.
126
+
127
+ ### `list_transactions`
128
+
129
+ Lists recent payment intents from your Stripe account.
130
+
131
+ | Parameter | Type | Required | Default | Description |
132
+ |-----------|------|----------|---------|-------------|
133
+ | `limit` | integer | no | `10` | Number of transactions to return (max 100) |
134
+
135
+ Returns an array of `Transaction` objects with fields: `id`, `amount`, `currency`, `description`, `status`, `created`.
136
+
137
+ ### `refund`
138
+
139
+ Issues a full refund for a previous payment.
140
+
141
+ | Parameter | Type | Required | Description |
142
+ |-----------|------|----------|-------------|
143
+ | `payment_intent_id` | string | yes | The `paymentIntentId` from a previous `pay` call |
144
+
145
+ Returns a `RefundResult` with fields: `success`, `refundId`, `amount`, `status`, `error`. Partial refunds are not supported.
146
+
147
+ ---
148
+
149
+ ## Guardrails Configuration
150
+
151
+ Default limits are conservative. To change them, edit `~/.clawpay/config.json`:
152
+
153
+ ```json
154
+ {
155
+ "guardrails": {
156
+ "maxAmountPerTransactionCents": 10000,
157
+ "maxDailySpendCents": 50000,
158
+ "allowedCurrencies": ["usd"]
159
+ }
160
+ }
161
+ ```
162
+
163
+ The defaults are:
164
+
165
+ - `maxAmountPerTransactionCents`: `10000` ($100.00)
166
+ - `maxDailySpendCents`: `50000` ($500.00)
167
+ - `allowedCurrencies`: `["usd"]`
168
+
169
+ Any `pay` call that exceeds these limits is rejected before it reaches Stripe.
170
+
171
+ ---
172
+
173
+ ## Audit Log
174
+
175
+ Every action ClawPay takes is recorded to `~/.clawpay/audit.log` as JSON Lines (one JSON object per line).
176
+
177
+ **Location:** `~/.clawpay/audit.log`
178
+
179
+ **View live:**
180
+ ```bash
181
+ tail -f ~/.clawpay/audit.log | jq .
182
+ ```
183
+
184
+ Each entry contains: `timestamp` (ISO 8601), `action`, `amount`, `currency`, `status`, and optionally `paymentIntentId`, `refundId`, or `reason`. API keys, card numbers, and other sensitive data are never written to this file.
185
+
186
+ ---
187
+
188
+ ## Contributing
189
+
190
+ Pull requests are welcome. Please open an issue first for significant changes.
191
+
192
+ To report a security vulnerability, follow the process in [SECURITY.md](SECURITY.md). Do not open a public issue for security bugs.
193
+
194
+ ---
195
+
196
+ ## Security & Safety
197
+
198
+ **ClawPay never sees your card data.** All card entry happens inside Stripe Checkout, which is PCI DSS compliant. ClawPay only ever stores and uses Stripe customer IDs and payment method IDs.
199
+
200
+ **Built-in Guardrails.** Out of the box, ClawPay enforces a $100 per-transaction maximum, a $500 daily spend cap, and USD-only payments. All limits are configurable in `~/.clawpay/config.json`.
201
+
202
+ **Full Audit Trail.** Every payment, refund, and setup event is written to `~/.clawpay/audit.log` as JSON lines. No API keys or card data are ever logged.
203
+
204
+ **Automated Security.** The CI pipeline runs a hardcoded-key scan on every push. Dependabot sends weekly dependency update PRs. GitHub secret scanning is enabled on the repository.
205
+
206
+ For vulnerability reports, see [SECURITY.md](SECURITY.md). For full legal terms, see [DISCLAIMER.md](DISCLAIMER.md).
207
+
208
+ ---
209
+
210
+ ## License
211
+
212
+ Apache 2.0. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,8 @@
1
+ import type { ClawPayConfig, GuardrailCheck } from "./types.js";
2
+ export declare function loadConfig(): ClawPayConfig;
3
+ export declare function saveConfig(config: ClawPayConfig): void;
4
+ export declare function isConfigured(): boolean;
5
+ export declare function getDailySpend(): number;
6
+ export declare function recordSpend(amountCents: number): void;
7
+ export declare function checkGuardrails(amountCents: number, currency: string): GuardrailCheck;
8
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAYhE,wBAAgB,UAAU,IAAI,aAAa,CAgB1C;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAGtD;AAED,wBAAgB,YAAY,IAAI,OAAO,CAGtC;AA4BD,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAKrD;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAmCrF"}
package/dist/config.js ADDED
@@ -0,0 +1,97 @@
1
+ import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { homedir } from "node:os";
4
+ import { DEFAULT_CONFIG } from "./types.js";
5
+ const CONFIG_DIR = join(homedir(), ".clawpay");
6
+ const CONFIG_FILE = join(CONFIG_DIR, "config.json");
7
+ function ensureConfigDir() {
8
+ if (!existsSync(CONFIG_DIR)) {
9
+ mkdirSync(CONFIG_DIR, { recursive: true });
10
+ }
11
+ }
12
+ export function loadConfig() {
13
+ ensureConfigDir();
14
+ if (!existsSync(CONFIG_FILE)) {
15
+ return JSON.parse(JSON.stringify(DEFAULT_CONFIG));
16
+ }
17
+ try {
18
+ const raw = readFileSync(CONFIG_FILE, "utf-8");
19
+ const saved = JSON.parse(raw);
20
+ return {
21
+ stripe: { ...DEFAULT_CONFIG.stripe, ...saved.stripe },
22
+ server: { ...DEFAULT_CONFIG.server, ...saved.server },
23
+ guardrails: { ...DEFAULT_CONFIG.guardrails, ...saved.guardrails },
24
+ };
25
+ }
26
+ catch {
27
+ return JSON.parse(JSON.stringify(DEFAULT_CONFIG));
28
+ }
29
+ }
30
+ export function saveConfig(config) {
31
+ ensureConfigDir();
32
+ writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), "utf-8");
33
+ }
34
+ export function isConfigured() {
35
+ const config = loadConfig();
36
+ return Boolean(config.stripe.customerId && config.stripe.paymentMethodId);
37
+ }
38
+ function todayKey() {
39
+ return new Date().toISOString().slice(0, 10);
40
+ }
41
+ function spendLogFile() {
42
+ return join(CONFIG_DIR, `spend-${todayKey()}.json`);
43
+ }
44
+ function loadSpendLog() {
45
+ ensureConfigDir();
46
+ const file = spendLogFile();
47
+ if (!existsSync(file)) {
48
+ return { date: todayKey(), totalCents: 0 };
49
+ }
50
+ try {
51
+ return JSON.parse(readFileSync(file, "utf-8"));
52
+ }
53
+ catch {
54
+ return { date: todayKey(), totalCents: 0 };
55
+ }
56
+ }
57
+ export function getDailySpend() {
58
+ return loadSpendLog().totalCents;
59
+ }
60
+ export function recordSpend(amountCents) {
61
+ ensureConfigDir();
62
+ const log = loadSpendLog();
63
+ log.totalCents += amountCents;
64
+ writeFileSync(spendLogFile(), JSON.stringify(log, null, 2), "utf-8");
65
+ }
66
+ export function checkGuardrails(amountCents, currency) {
67
+ const config = loadConfig();
68
+ const { guardrails } = config;
69
+ if (amountCents <= 0) {
70
+ return { allowed: false, reason: "Amount must be greater than zero." };
71
+ }
72
+ if (!guardrails.allowedCurrencies.includes(currency.toLowerCase())) {
73
+ return {
74
+ allowed: false,
75
+ reason: `Currency "${currency}" is not allowed. Allowed: ${guardrails.allowedCurrencies.join(", ")}.`,
76
+ };
77
+ }
78
+ if (amountCents > guardrails.maxAmountPerTransactionCents) {
79
+ const max = (guardrails.maxAmountPerTransactionCents / 100).toFixed(2);
80
+ const requested = (amountCents / 100).toFixed(2);
81
+ return {
82
+ allowed: false,
83
+ reason: `Amount $${requested} exceeds per-transaction limit of $${max}.`,
84
+ };
85
+ }
86
+ const daily = getDailySpend();
87
+ if (daily + amountCents > guardrails.maxDailySpendCents) {
88
+ const limit = (guardrails.maxDailySpendCents / 100).toFixed(2);
89
+ const spent = (daily / 100).toFixed(2);
90
+ return {
91
+ allowed: false,
92
+ reason: `Would exceed daily spend limit of $${limit} (today: $${spent}).`,
93
+ };
94
+ }
95
+ return { allowed: true };
96
+ }
97
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC;AAC/C,MAA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CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,28 @@
1
+ type AuditAction = "pay" | "refund" | "balance" | "list_transactions" | "setup_payment";
2
+ interface AuditEntry {
3
+ timestamp: string;
4
+ action: AuditAction;
5
+ amount?: number;
6
+ currency?: string;
7
+ paymentIntentId?: string;
8
+ refundId?: string;
9
+ status: "success" | "failed" | "blocked";
10
+ reason?: string;
11
+ }
12
+ export declare function auditLog(entry: AuditEntry): void;
13
+ export declare function auditPayment(opts: {
14
+ amount: number;
15
+ currency: string;
16
+ paymentIntentId?: string;
17
+ status: "success" | "failed" | "blocked";
18
+ reason?: string;
19
+ }): void;
20
+ export declare function auditRefund(opts: {
21
+ refundId?: string;
22
+ amount?: number;
23
+ status: "success" | "failed";
24
+ reason?: string;
25
+ }): void;
26
+ export declare function auditSetup(status: "success" | "failed", reason?: string): void;
27
+ export {};
28
+ //# sourceMappingURL=guardrails.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guardrails.d.ts","sourceRoot":"","sources":["../src/guardrails.ts"],"names":[],"mappings":"AAOA,KAAK,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,mBAAmB,GAAG,eAAe,CAAC;AAExF,UAAU,UAAU;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAMhD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,IAAI,CAUP;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,IAAI,CASP;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAO9E"}