@three-ws/x402-modal 0.2.0 → 0.2.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@three-ws/x402-modal` are documented here.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.2.0] - 2026-06-30
9
+
10
+ ### Added
11
+ - Comprehensive documentation: README (CDN + npm install, sub-60s quickstart,
12
+ discover→connect→sign→settle sequence diagram, full API reference, configuration
13
+ and `data-*` attribute reference, Vanilla/React/CDN framework guides, theming
14
+ hooks, security, FAQ), plus `docs/EXAMPLES.md` (9 runnable recipes), updated
15
+ `docs/CONFIGURATION.md` / `docs/BACKEND.md`, and `CONTRIBUTING.md`.
16
+
17
+ ### Changed
18
+ - Published as `@three-ws/x402-modal`. Defaults are now vendor-neutral: the `brand`
19
+ footer link and `builderCode` attribution default to `null` (off) until a host
20
+ opts in. The modal settles a 402 from any origin with zero configuration; USDC
21
+ is the default settlement asset.
22
+ - The build banner is derived from package metadata (no hardcoded host/branding).
23
+
24
+ [0.2.0]: https://github.com/nirholas/x402-modal/releases/tag/v0.2.0
@@ -0,0 +1,92 @@
1
+ # Contributing to @three-ws/x402-modal
2
+
3
+ Thanks for helping improve the x402 payment modal. This guide covers the local
4
+ setup, the build, the tests, and the conventions the project follows.
5
+
6
+ ## Prerequisites
7
+
8
+ - **Node.js >= 18** (the package declares this in `engines`).
9
+ - npm (ships with Node).
10
+
11
+ No global tooling is required — `esbuild` is the only dev dependency.
12
+
13
+ ## Setup
14
+
15
+ ```sh
16
+ git clone https://github.com/nirholas/x402-modal.git
17
+ cd x402-modal
18
+ npm install
19
+ ```
20
+
21
+ ## Project layout
22
+
23
+ | Path | What it is |
24
+ |------------------------|------------|
25
+ | `src/x402-modal.js` | The canonical, side-effect-free core. The public API lives here. |
26
+ | `src/global.js` | The CDN entry: reads `data-x402-*` off its `<script>`, auto-binds, exposes `window.X402`. |
27
+ | `src/util.js` | Pure, DOM-free helpers (encoding, network maps, SIWX message, caps math). Unit-tested in Node. |
28
+ | `types/index.d.ts` | TypeScript declarations for the public API. |
29
+ | `build.mjs` | esbuild config — emits `dist/x402-modal.mjs` (ESM) and `dist/x402.global.js` (IIFE). |
30
+ | `test/*.test.js` | Node `node:test` suites. No DOM required. |
31
+ | `examples/` | A runnable demo page and a reference Solana backend helper. |
32
+ | `docs/` | Protocol, configuration, backend, and examples references. |
33
+
34
+ ## Build
35
+
36
+ ```sh
37
+ npm run build
38
+ ```
39
+
40
+ This produces two artifacts in `dist/`:
41
+
42
+ - `dist/x402-modal.mjs` — ESM, side-effect-free, for bundlers and npm consumers.
43
+ - `dist/x402.global.js` — minified IIFE, the drop-in CDN `<script>`.
44
+
45
+ The build banner is derived from `package.json`, so no host or branding is
46
+ hardcoded in `build.mjs`. The Solana web3.js and keccak imports stay as runtime
47
+ CDN URLs and are never bundled.
48
+
49
+ ## Test
50
+
51
+ ```sh
52
+ npm test
53
+ ```
54
+
55
+ Runs every `test/*.test.js` with Node's built-in test runner. All tests must
56
+ pass before a change is merged. Tests run in plain Node — keep new logic that
57
+ needs coverage in `src/util.js` (DOM-free) so it stays unit-testable.
58
+
59
+ ## Conventions
60
+
61
+ - **No new runtime dependencies.** The package is deliberately dependency-free;
62
+ the only network modules (Solana web3.js, a keccak) are dynamic-imported from a
63
+ CDN, on demand. Adding an npm runtime dependency needs a strong reason.
64
+ - **Keep the core side-effect-free.** `src/x402-modal.js` must never touch
65
+ `window` or auto-bind on import — that behavior belongs in `src/global.js`.
66
+ - **Defaults stay vendor-neutral.** `brand` and `builderCode` default to `null`.
67
+ Don't ship a default footer or builder code.
68
+ - **Update types and docs with the code.** A public-API change updates
69
+ `types/index.d.ts`, the README API reference, and the relevant `docs/` file in
70
+ the same change. Every doc sample must actually run.
71
+ - **Match the existing style.** Tab indentation, small functions, comments that
72
+ explain *why*, not *what*.
73
+
74
+ ## Submitting a change
75
+
76
+ 1. Branch from `main`.
77
+ 2. Make the change; run `npm run build && npm test`.
78
+ 3. Update `types/`, the README, and `docs/` for any public-API change.
79
+ 4. Open a PR describing the change and the user-visible effect.
80
+
81
+ ## Reporting issues
82
+
83
+ Open an issue at <https://github.com/nirholas/x402-modal/issues>. For a payment
84
+ flow bug, include the network (Base / Solana), the wallet, and the shape of the
85
+ `402` body's `accepts[]` entry (redact addresses if needed).
86
+
87
+ ## License
88
+
89
+ By contributing you agree your contributions become the proprietary property of
90
+ the Owner. Proprietary — Copyright (c) 2026 nirholas. All Rights Reserved.
91
+ Unauthorized use, copying, modification, or distribution is prohibited. See
92
+ [LICENSE](./LICENSE).
package/LICENSE CHANGED
@@ -1,180 +1,38 @@
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 transformations
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 designated in writing by the copyright owner as "Not a
57
- 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 included
61
- 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 the 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 cross-claim
80
- or counterclaim in a lawsuit) alleging that the Work or any
81
- Contribution embodied within the Work constitutes direct or contributory
82
- patent infringement, then any patent licenses granted to You under
83
- this License for that Work shall terminate as of the date such
84
- 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 Derivative
92
- 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 in addition to the
115
- 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
- are furnished to do so.
123
-
124
- 5. Submission of Contributions. Unless You explicitly state otherwise,
125
- any Contribution intentionally submitted for inclusion in the Work
126
- by You to the Licensor shall be under the terms and conditions of
127
- this License, without any additional terms or conditions.
128
- Notwithstanding the above, nothing herein shall supersede or modify
129
- the terms of any separate license agreement you may have executed
130
- with Licensor regarding such Contributions.
131
-
132
- 6. Trademarks. This License does not grant permission to use the trade
133
- names, trademarks, service marks, or product names of the Licensor,
134
- except as required for reasonable and customary use in describing the
135
- origin of the Work and reproducing the content of the NOTICE file.
136
-
137
- 7. Disclaimer of Warranty. Unless required by applicable law or
138
- agreed to in writing, Licensor provides the Work (and each
139
- Contributor provides its Contributions) on an "AS IS" BASIS,
140
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
141
- implied, including, without limitation, any warranties or conditions
142
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
143
- PARTICULAR PURPOSE. You are solely responsible for determining the
144
- appropriateness of using or reproducing the Work and assume any
145
- risks associated with Your exercise of permissions under this License.
146
-
147
- 8. Limitation of Liability. In no event and under no legal theory,
148
- whether in tort (including negligence), contract, or otherwise,
149
- unless required by applicable law (such as deliberate and grossly
150
- negligent acts) or agreed to in writing, shall any Contributor be
151
- liable to You for damages, including any direct, indirect, special,
152
- incidental, or exemplary damages of any character arising as a
153
- result of this License or out of the use or inability to use the
154
- Work (including but not limited to damages for loss of goodwill,
155
- work stoppage, computer failure or malfunction, or all other
156
- commercial damages or losses), even if such Contributor has been
157
- advised of the possibility of such damages.
158
-
159
- 9. Accepting Warranty or Additional Liability. While redistributing
160
- the Work or Derivative Works thereof, You may choose to offer,
161
- and charge a fee for, acceptance of support, warranty, indemnity,
162
- or other liability obligations and/or rights consistent with this
163
- License. However, in accepting such obligations, You may offer only
164
- conditions consistent with this License.
165
-
166
- END OF TERMS AND CONDITIONS
167
-
168
- Copyright 2026 nirholas
169
-
170
- Licensed under the Apache License, Version 2.0 (the "License");
171
- you may not use this file except in compliance with the License.
172
- You may obtain a copy of the License at
173
-
174
- http://www.apache.org/licenses/LICENSE-2.0
175
-
176
- Unless required by applicable law or agreed to in writing, software
177
- distributed under the License is distributed on an "AS IS" BASIS,
178
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179
- See the License for the specific language governing permissions and
180
- limitations under the License.
1
+ PROPRIETARY SOFTWARE LICENSE
2
+
3
+ Copyright (c) 2026 nirholas. All Rights Reserved.
4
+
5
+ This software, including all source code, documentation, configuration, build
6
+ output, and associated files in this repository (collectively, the "Software"),
7
+ is the proprietary and confidential property of nirholas (the "Owner"). The
8
+ Software is protected by copyright laws and international treaty provisions. All
9
+ right, title, and interest in and to the Software, including all copyrights,
10
+ trademarks, trade secrets, patents, and other intellectual property rights, are
11
+ and shall remain the sole and exclusive property of the Owner.
12
+
13
+ NO LICENSE OR RIGHT IS GRANTED. No person or entity is granted any license or
14
+ right to access, use, copy, reproduce, modify, adapt, translate, merge, publish,
15
+ distribute, sublicense, sell, lease, rent, lend, transmit, host, display,
16
+ perform, create derivative works from, decompile, disassemble, reverse engineer,
17
+ or otherwise exploit the Software, in whole or in part, in any form or by any
18
+ means, without the express prior written permission of the Owner in each
19
+ instance.
20
+
21
+ Unauthorized access, use, reproduction, modification, or distribution of the
22
+ Software, or of any portion of it, is strictly prohibited, constitutes
23
+ infringement of the Owner's intellectual property rights, and may result in
24
+ severe civil and criminal penalties. Violations will be prosecuted to the
25
+ maximum extent permitted by law.
26
+
27
+ Third-party components, dependencies, and protocols referenced or required by the
28
+ Software remain governed by their own respective licenses; this License applies
29
+ solely to the original works authored by the Owner contained in this repository.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
33
+ FOR A PARTICULAR PURPOSE, TITLE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE OWNER
34
+ BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF
35
+ CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE
36
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37
+
38
+ For licensing inquiries, contact the Owner at https://github.com/nirholas.