@n24q02m/hull 0.0.0-stage → 0.4.0-beta.10

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 (231) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +166 -2
  3. package/build/auth/credential-form.d.ts +163 -0
  4. package/build/auth/credential-form.d.ts.map +1 -0
  5. package/build/auth/credential-form.js +1869 -0
  6. package/build/auth/credential-form.js.map +1 -0
  7. package/build/auth/delegated-oauth-app.d.ts +90 -0
  8. package/build/auth/delegated-oauth-app.d.ts.map +1 -0
  9. package/build/auth/delegated-oauth-app.js +881 -0
  10. package/build/auth/delegated-oauth-app.js.map +1 -0
  11. package/build/auth/index.d.ts +12 -0
  12. package/build/auth/index.d.ts.map +1 -0
  13. package/build/auth/index.js +12 -0
  14. package/build/auth/index.js.map +1 -0
  15. package/build/auth/local-oauth-app.d.ts +152 -0
  16. package/build/auth/local-oauth-app.d.ts.map +1 -0
  17. package/build/auth/local-oauth-app.js +975 -0
  18. package/build/auth/local-oauth-app.js.map +1 -0
  19. package/build/auth/relay-login.d.ts +46 -0
  20. package/build/auth/relay-login.d.ts.map +1 -0
  21. package/build/auth/relay-login.js +197 -0
  22. package/build/auth/relay-login.js.map +1 -0
  23. package/build/auth/router.d.ts +18 -0
  24. package/build/auth/router.d.ts.map +1 -0
  25. package/build/auth/router.js +62 -0
  26. package/build/auth/router.js.map +1 -0
  27. package/build/auth/session-store.d.ts +49 -0
  28. package/build/auth/session-store.d.ts.map +1 -0
  29. package/build/auth/session-store.js +94 -0
  30. package/build/auth/session-store.js.map +1 -0
  31. package/build/auth/stable-sub.d.ts +27 -0
  32. package/build/auth/stable-sub.d.ts.map +1 -0
  33. package/build/auth/stable-sub.js +38 -0
  34. package/build/auth/stable-sub.js.map +1 -0
  35. package/build/auth/well-known.d.ts +4 -0
  36. package/build/auth/well-known.d.ts.map +1 -0
  37. package/build/auth/well-known.js +26 -0
  38. package/build/auth/well-known.js.map +1 -0
  39. package/build/cli/build-cli.d.ts +97 -0
  40. package/build/cli/build-cli.d.ts.map +1 -0
  41. package/build/cli/build-cli.js +309 -0
  42. package/build/cli/build-cli.js.map +1 -0
  43. package/build/cli/index.d.ts +2 -0
  44. package/build/cli/index.d.ts.map +1 -0
  45. package/build/cli/index.js +2 -0
  46. package/build/cli/index.js.map +1 -0
  47. package/build/crypto/aes.d.ts +8 -0
  48. package/build/crypto/aes.d.ts.map +1 -0
  49. package/build/crypto/aes.js +27 -0
  50. package/build/crypto/aes.js.map +1 -0
  51. package/build/crypto/ecdh.d.ts +5 -0
  52. package/build/crypto/ecdh.d.ts.map +1 -0
  53. package/build/crypto/ecdh.js +16 -0
  54. package/build/crypto/ecdh.js.map +1 -0
  55. package/build/crypto/index.d.ts +4 -0
  56. package/build/crypto/index.d.ts.map +1 -0
  57. package/build/crypto/index.js +4 -0
  58. package/build/crypto/index.js.map +1 -0
  59. package/build/crypto/kdf.d.ts +15 -0
  60. package/build/crypto/kdf.d.ts.map +1 -0
  61. package/build/crypto/kdf.js +26 -0
  62. package/build/crypto/kdf.js.map +1 -0
  63. package/build/index.d.ts +19 -0
  64. package/build/index.d.ts.map +1 -0
  65. package/build/index.js +28 -0
  66. package/build/index.js.map +1 -0
  67. package/build/lifecycle/lock.d.ts +68 -0
  68. package/build/lifecycle/lock.d.ts.map +1 -0
  69. package/build/lifecycle/lock.js +173 -0
  70. package/build/lifecycle/lock.js.map +1 -0
  71. package/build/oauth/cache.d.ts +22 -0
  72. package/build/oauth/cache.d.ts.map +1 -0
  73. package/build/oauth/cache.js +24 -0
  74. package/build/oauth/cache.js.map +1 -0
  75. package/build/oauth/index.d.ts +6 -0
  76. package/build/oauth/index.d.ts.map +1 -0
  77. package/build/oauth/index.js +6 -0
  78. package/build/oauth/index.js.map +1 -0
  79. package/build/oauth/jwt-issuer.d.ts +87 -0
  80. package/build/oauth/jwt-issuer.d.ts.map +1 -0
  81. package/build/oauth/jwt-issuer.js +205 -0
  82. package/build/oauth/jwt-issuer.js.map +1 -0
  83. package/build/oauth/pkce.d.ts +10 -0
  84. package/build/oauth/pkce.d.ts.map +1 -0
  85. package/build/oauth/pkce.js +34 -0
  86. package/build/oauth/pkce.js.map +1 -0
  87. package/build/oauth/provider.d.ts +52 -0
  88. package/build/oauth/provider.d.ts.map +1 -0
  89. package/build/oauth/provider.js +98 -0
  90. package/build/oauth/provider.js.map +1 -0
  91. package/build/oauth/user-store.d.ts +25 -0
  92. package/build/oauth/user-store.d.ts.map +1 -0
  93. package/build/oauth/user-store.js +85 -0
  94. package/build/oauth/user-store.js.map +1 -0
  95. package/build/relay/browser.d.ts +15 -0
  96. package/build/relay/browser.d.ts.map +1 -0
  97. package/build/relay/browser.js +121 -0
  98. package/build/relay/browser.js.map +1 -0
  99. package/build/relay/client.d.ts +36 -0
  100. package/build/relay/client.d.ts.map +1 -0
  101. package/build/relay/client.js +135 -0
  102. package/build/relay/client.js.map +1 -0
  103. package/build/relay/session.d.ts +12 -0
  104. package/build/relay/session.d.ts.map +1 -0
  105. package/build/relay/session.js +55 -0
  106. package/build/relay/session.js.map +1 -0
  107. package/build/relay/tool-helpers.d.ts +85 -0
  108. package/build/relay/tool-helpers.d.ts.map +1 -0
  109. package/build/relay/tool-helpers.js +103 -0
  110. package/build/relay/tool-helpers.js.map +1 -0
  111. package/build/relay/wordlist.d.ts +2 -0
  112. package/build/relay/wordlist.d.ts.map +1 -0
  113. package/build/relay/wordlist.js +7782 -0
  114. package/build/relay/wordlist.js.map +1 -0
  115. package/build/schema/types.d.ts +67 -0
  116. package/build/schema/types.d.ts.map +1 -0
  117. package/build/schema/types.js +2 -0
  118. package/build/schema/types.js.map +1 -0
  119. package/build/storage/atomic-write.d.ts +8 -0
  120. package/build/storage/atomic-write.d.ts.map +1 -0
  121. package/build/storage/atomic-write.js +26 -0
  122. package/build/storage/atomic-write.js.map +1 -0
  123. package/build/storage/backends.d.ts +74 -0
  124. package/build/storage/backends.d.ts.map +1 -0
  125. package/build/storage/backends.js +193 -0
  126. package/build/storage/backends.js.map +1 -0
  127. package/build/storage/config-file.d.ts +35 -0
  128. package/build/storage/config-file.d.ts.map +1 -0
  129. package/build/storage/config-file.js +259 -0
  130. package/build/storage/config-file.js.map +1 -0
  131. package/build/storage/credential-store.d.ts +71 -0
  132. package/build/storage/credential-store.d.ts.map +1 -0
  133. package/build/storage/credential-store.js +91 -0
  134. package/build/storage/credential-store.js.map +1 -0
  135. package/build/storage/data-dir.d.ts +58 -0
  136. package/build/storage/data-dir.d.ts.map +1 -0
  137. package/build/storage/data-dir.js +79 -0
  138. package/build/storage/data-dir.js.map +1 -0
  139. package/build/storage/encryption.d.ts +9 -0
  140. package/build/storage/encryption.d.ts.map +1 -0
  141. package/build/storage/encryption.js +27 -0
  142. package/build/storage/encryption.js.map +1 -0
  143. package/build/storage/home-dir.d.ts +11 -0
  144. package/build/storage/home-dir.d.ts.map +1 -0
  145. package/build/storage/home-dir.js +18 -0
  146. package/build/storage/home-dir.js.map +1 -0
  147. package/build/storage/index.d.ts +12 -0
  148. package/build/storage/index.d.ts.map +1 -0
  149. package/build/storage/index.js +15 -0
  150. package/build/storage/index.js.map +1 -0
  151. package/build/storage/machine-id.d.ts +4 -0
  152. package/build/storage/machine-id.d.ts.map +1 -0
  153. package/build/storage/machine-id.js +73 -0
  154. package/build/storage/machine-id.js.map +1 -0
  155. package/build/storage/mode.d.ts +23 -0
  156. package/build/storage/mode.d.ts.map +1 -0
  157. package/build/storage/mode.js +46 -0
  158. package/build/storage/mode.js.map +1 -0
  159. package/build/storage/per-plugin-store.d.ts +65 -0
  160. package/build/storage/per-plugin-store.d.ts.map +1 -0
  161. package/build/storage/per-plugin-store.js +194 -0
  162. package/build/storage/per-plugin-store.js.map +1 -0
  163. package/build/storage/resolver.d.ts +7 -0
  164. package/build/storage/resolver.d.ts.map +1 -0
  165. package/build/storage/resolver.js +38 -0
  166. package/build/storage/resolver.js.map +1 -0
  167. package/build/storage/session-lock.d.ts +19 -0
  168. package/build/storage/session-lock.d.ts.map +1 -0
  169. package/build/storage/session-lock.js +105 -0
  170. package/build/storage/session-lock.js.map +1 -0
  171. package/build/token-auth/authenticator.d.ts +70 -0
  172. package/build/token-auth/authenticator.d.ts.map +1 -0
  173. package/build/token-auth/authenticator.js +146 -0
  174. package/build/token-auth/authenticator.js.map +1 -0
  175. package/build/token-auth/cli.d.ts +38 -0
  176. package/build/token-auth/cli.d.ts.map +1 -0
  177. package/build/token-auth/cli.js +192 -0
  178. package/build/token-auth/cli.js.map +1 -0
  179. package/build/token-auth/context.d.ts +30 -0
  180. package/build/token-auth/context.d.ts.map +1 -0
  181. package/build/token-auth/context.js +32 -0
  182. package/build/token-auth/context.js.map +1 -0
  183. package/build/token-auth/http-guard.d.ts +26 -0
  184. package/build/token-auth/http-guard.d.ts.map +1 -0
  185. package/build/token-auth/http-guard.js +51 -0
  186. package/build/token-auth/http-guard.js.map +1 -0
  187. package/build/token-auth/index.d.ts +14 -0
  188. package/build/token-auth/index.d.ts.map +1 -0
  189. package/build/token-auth/index.js +14 -0
  190. package/build/token-auth/index.js.map +1 -0
  191. package/build/token-auth/limiter.d.ts +20 -0
  192. package/build/token-auth/limiter.d.ts.map +1 -0
  193. package/build/token-auth/limiter.js +41 -0
  194. package/build/token-auth/limiter.js.map +1 -0
  195. package/build/token-auth/loopback.d.ts +17 -0
  196. package/build/token-auth/loopback.d.ts.map +1 -0
  197. package/build/token-auth/loopback.js +62 -0
  198. package/build/token-auth/loopback.js.map +1 -0
  199. package/build/token-auth/py-compat.d.ts +24 -0
  200. package/build/token-auth/py-compat.d.ts.map +1 -0
  201. package/build/token-auth/py-compat.js +76 -0
  202. package/build/token-auth/py-compat.js.map +1 -0
  203. package/build/token-auth/tokens.d.ts +36 -0
  204. package/build/token-auth/tokens.d.ts.map +1 -0
  205. package/build/token-auth/tokens.js +115 -0
  206. package/build/token-auth/tokens.js.map +1 -0
  207. package/build/token-auth/users.d.ts +62 -0
  208. package/build/token-auth/users.d.ts.map +1 -0
  209. package/build/token-auth/users.js +174 -0
  210. package/build/token-auth/users.js.map +1 -0
  211. package/build/transport/cache.d.ts +19 -0
  212. package/build/transport/cache.d.ts.map +1 -0
  213. package/build/transport/cache.js +76 -0
  214. package/build/transport/cache.js.map +1 -0
  215. package/build/transport/index.d.ts +5 -0
  216. package/build/transport/index.d.ts.map +1 -0
  217. package/build/transport/index.js +4 -0
  218. package/build/transport/index.js.map +1 -0
  219. package/build/transport/local-server.d.ts +173 -0
  220. package/build/transport/local-server.d.ts.map +1 -0
  221. package/build/transport/local-server.js +457 -0
  222. package/build/transport/local-server.js.map +1 -0
  223. package/build/transport/oauth-middleware.d.ts +45 -0
  224. package/build/transport/oauth-middleware.d.ts.map +1 -0
  225. package/build/transport/oauth-middleware.js +86 -0
  226. package/build/transport/oauth-middleware.js.map +1 -0
  227. package/build/transport/streamable-http.d.ts +54 -0
  228. package/build/transport/streamable-http.d.ts.map +1 -0
  229. package/build/transport/streamable-http.js +57 -0
  230. package/build/transport/streamable-http.js.map +1 -0
  231. package/package.json +107 -4
package/LICENSE ADDED
@@ -0,0 +1,201 @@
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, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,167 @@
1
- # Temporary Holding Version
1
+ # @n24q02m/hull
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **TypeScript core of hull: MCP Streamable HTTP transport, OAuth 2.1 authorization server, credential storage and relay client for self-hosted MCP servers.**
4
+
5
+ This package is the TypeScript side of the hull monorepo. It is released in
6
+ lockstep with the Python dist `n24q02m-hull`: one hull release tag publishes
7
+ the same version to npm and PyPI.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @n24q02m/hull
13
+ # or
14
+ bun add @n24q02m/hull
15
+ ```
16
+
17
+ Requirements: Node.js >= 24.21.0. The package is ESM only and ships its own
18
+ TypeScript declarations.
19
+
20
+ ## Subpath exports
21
+
22
+ Import the whole surface from the package root, or a narrower slice from a
23
+ subpath:
24
+
25
+ | Import path | Provides |
26
+ |---|---|
27
+ | `@n24q02m/hull` | Everything below, plus `buildCli` (console-script subcommand dispatch around a server entry point) and `tryOpenBrowser` |
28
+ | `@n24q02m/hull/transport` | `runHttpServer` (local HTTP server with routes), `StreamableHTTPServer` (MCP Streamable HTTP transport), `OAuthMiddleware` (bearer JWT verification) |
29
+ | `@n24q02m/hull/oauth` | `OAuthProvider` (OAuth 2.1 authorization server), `JWTIssuer`, `verifyPKCE`, `InMemoryAuthCache`, `SqliteUserStore` |
30
+ | `@n24q02m/hull/auth` | `createLocalOAuthApp` and `createDelegatedOAuthApp` (credential-form and upstream-OAuth flows), `renderCredentialForm`, `createSessionStore`, `deriveStableSub`, `authorizationServerMetadata` / `protectedResourceMetadata` (well-known documents) |
31
+ | `@n24q02m/hull/crypto` | AES `encrypt` / `decrypt`, ECDH `generateKeyPair` / `deriveSharedSecret` / `exportPublicKey` / `importPublicKey`, key derivation `deriveAesKey` / `deriveJwtSigningSeed` |
32
+ | `@n24q02m/hull/storage` | `atomicWriteFile`, credential backends (`LocalFsBackend`, `InMemoryBackend`, `CfKvBackend`, `backendFromEnv`), encrypted credential read/write/delete and config import/export, `PerPluginStore`, data dir helpers (`dataDir`, `dataDirCandidates`, `legacyDataDirs`), `resolveConfig` (environment variables, then stored config, then defaults), server mode state, session lock, machine identity helpers |
33
+ | `@n24q02m/hull/relay` | Relay client: `createSession`, `generatePassphrase`, `pollForResult`, `sendMessage`, `pollForResponses`, `notifyComplete` |
34
+ | `@n24q02m/hull/schema` | Type-only config schema: `ConfigField`, `ConfigMode`, `RelayConfigSchema` and related form layout types |
35
+ | `@n24q02m/hull/token-auth` | Token-table HTTP auth: `Authenticator`, `hashToken` / `verifyToken`, `loadUsers`, `currentUser`, `ensurePathAllowed`, `guardRequest`, `SlidingWindowLimiter`, `tokenCliHandler` |
36
+
37
+ ## Credential storage layout
38
+
39
+ `PerPluginStore` keeps one AES-256-GCM encrypted blob per plugin slug (for
40
+ example `wet`) under a short, machine-bound data dir:
41
+
42
+ ```text
43
+ ~/.<plugin>/config.json single-user credentials
44
+ ~/.<plugin>/.secret single-user machine key (32 bytes, 0600)
45
+ ~/.<plugin>/subs/<sub>/config.json HTTP multi-user credentials, one per sub
46
+ ```
47
+
48
+ Multi-user blobs use a key derived with scrypt from the `CREDENTIAL_SECRET`
49
+ environment variable (salt `<plugin>:<sub>`) instead of `.secret`.
50
+ Environment variables take precedence over stored values through
51
+ `resolveConfig`, which is how containers override the store.
52
+
53
+ Credentials written by earlier releases stay readable, so upgrading does not
54
+ require signing in again. With the default `LocalFsBackend`, `load()` checks
55
+ these dirs in order, and the first one holding a blob decides the result:
56
+
57
+ 1. `~/.<plugin>/` (current)
58
+ 2. `~/.<plugin>-mcp/`
59
+ 3. `~/.better-<plugin>-mcp/`
60
+
61
+ A legacy blob is decrypted with that legacy dir's own key material (its
62
+ `.secret`, or the salt `better-<plugin>:<sub>` for the third layout). Legacy
63
+ dirs are only read, never written. The next `save()` writes to `~/.<plugin>/`,
64
+ and from then on the new copy takes precedence. `clear()` removes the blob
65
+ from every location. A corrupt blob is reported as corrupt; the store does
66
+ not fall back to an older copy behind it. Injected backends (`InMemoryBackend`,
67
+ `CfKvBackend`, a `LocalFsBackend` with a custom `baseDir`) are used as the
68
+ only source.
69
+
70
+ ## CLI built-ins
71
+
72
+ `buildCli(serverName, { serve, extra, version, pluginName })` routes a leading
73
+ positional argument to a subcommand. Bare or flag-prefixed argv (for example
74
+ `--http`) still starts the server. The built-in subcommands are:
75
+
76
+ | Subcommand | Behaviour |
77
+ |---|---|
78
+ | `status` | Same as `config status`: prints configured / not configured (exit 0), or reports a corrupt blob (exit 1). Legacy dirs count. |
79
+ | `logout [--yes]` | Same as `config delete`: removes the stored credential from the current and every legacy dir. Without `--yes` it prompts on a TTY; non-interactive use without `--yes` exits 1. |
80
+ | `config status` / `config delete [--yes]` | The long forms of the two commands above. |
81
+ | `doctor` | Runtime, backend, store dir and config checks. Warns `only legacy store dir found` when credentials still sit in a legacy dir. |
82
+ | `relay status` / `relay open` / `relay reset` | Relay session state. |
83
+ | `token hash` | Mint a token-table hash (see below). |
84
+
85
+ `auth` is not a built-in. Signing in depends on the server (OAuth device code,
86
+ bot token, API key, relay form), so each server provides its own `auth`
87
+ handler through `extra`. Entries in `extra` also override a built-in of the
88
+ same name.
89
+
90
+ ## Token-table HTTP auth
91
+
92
+ `runHttpServer` accepts an `auth` option with the three modes of core-py
93
+ `[server] auth`. It replaces the OAuth/relay stack for that server: `auth` is
94
+ mutually exclusive with `relaySchema`, `delegatedOAuth`, `jwtIssuer`,
95
+ `authDisabled` and `authScope`, and needs neither a relay nor an OAuth
96
+ issuer.
97
+
98
+ | Mode | Config | Behaviour |
99
+ |---|---|---|
100
+ | `no-auth` | `{ mode: 'no-auth' }` | No Authorization header. Every request runs as `localAuthContext()` (`uid: 'local'`). Refuses to start on a non-loopback `host`. |
101
+ | `token` | `{ mode: 'token', tokenHash, rpm? }` | One shared bearer token checked against a `scrypt$...` hash. Caller `uid: 'shared'`, namespace `default`; optional shared per-minute cap. |
102
+ | `multi` | `{ mode: 'multi', usersFile?, users? }` | A users.toml table (default `~/.hull/users.toml`). Token maps to a user and namespace; 401 wrong token, 403 disabled user, 429 over the user's `limits.rpm`. |
103
+
104
+ ```ts
105
+ import { runHttpServer } from '@n24q02m/hull/transport'
106
+ import { currentUser, ensurePathAllowed } from '@n24q02m/hull/token-auth'
107
+
108
+ await runHttpServer(makeServer, {
109
+ serverName: 'my-mcp',
110
+ host: '0.0.0.0',
111
+ auth: { mode: 'multi', usersFile: '~/.hull/users.toml' }
112
+ })
113
+
114
+ // Inside a tool handler:
115
+ const user = currentUser() // { uid, namespace, mode, allowedRoots, rpm, ... }
116
+ ensurePathAllowed(user, requestedPath) // throws PathNotAllowedError outside allowed_roots
117
+ ```
118
+
119
+ ```toml
120
+ # users.toml
121
+ [users.alice]
122
+ token_hash = "scrypt$32768$8$1$<salt-hex>$<dk-hex>"
123
+ namespace = "alice"
124
+ enabled = true # optional, default true
125
+ allowed_roots = ["/data/alice"] # optional, default [] (grants no paths)
126
+
127
+ [users.alice.limits]
128
+ rpm = 60 # optional, default unlimited
129
+ ```
130
+
131
+ The guard runs before routing on every path except `/health`, so `/mcp` and
132
+ `extraRoutes` handlers both see the caller through `currentUser()`.
133
+ Rejections use the core-py JSON body (`{"error": "unauthorized", "detail":
134
+ "invalid token"}`) and add `WWW-Authenticate: Bearer` on 401. The config is
135
+ validated before the port is bound, so a malformed hash or users.toml fails
136
+ at startup. Hashes are interchangeable with core-py (`scrypt`, N=2^15, r=8,
137
+ p=1, 16-byte salt, 32-byte key).
138
+
139
+ Mint a hash with the built-in `token hash` subcommand of any `buildCli`
140
+ entry point. It reads the token from piped stdin or a hidden, confirmed
141
+ prompt (never from argv) and prints only the hash:
142
+
143
+ ```bash
144
+ my-mcp token hash # interactive hidden prompt
145
+ printf '%s' "$TOKEN" | my-mcp token hash
146
+ ```
147
+
148
+ ## Example
149
+
150
+ ```ts
151
+ import { runHttpServer } from '@n24q02m/hull/transport'
152
+ import { encrypt, decrypt } from '@n24q02m/hull/crypto'
153
+ import type { RelayConfigSchema } from '@n24q02m/hull/schema'
154
+ ```
155
+
156
+ ## Development
157
+
158
+ ```bash
159
+ bun install --frozen-lockfile
160
+ bun run check # biome + tsc type-check
161
+ bun run test
162
+ bun run build # emits build/
163
+ ```
164
+
165
+ ## License
166
+
167
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Credential form HTML renderer.
3
+ *
4
+ * Renders a dark-themed HTML form from a RelayConfigSchema.
5
+ * Used as the OAuth authorization page presented to the user during relay config.
6
+ *
7
+ * This is a TypeScript port of core-py's `credential_form.py`. CSS and embedded JS
8
+ * are kept verbatim so the rendered form has visual + behavioral parity between
9
+ * Python and TS servers.
10
+ */
11
+ export interface ConfigField {
12
+ key: string;
13
+ label: string;
14
+ type: string;
15
+ placeholder?: string;
16
+ helpText?: string;
17
+ helpUrl?: string;
18
+ required?: boolean;
19
+ /** Regex string for client-side validation; rendered as the input's `pattern` attribute. */
20
+ validation?: string;
21
+ }
22
+ /**
23
+ * Return true iff every required field in `schema` has a non-empty value in
24
+ * `config`. For schemas whose fields are all optional, requires the explicit
25
+ * `_setup_complete: "true"` flag — see core-py `is_schema_complete` docstring.
26
+ *
27
+ * Strict equality on the flag: only the literal string `"true"` counts. This
28
+ * guards against legacy / partial bootstrap entries (e.g. peer-shared cloud
29
+ * keys) tricking the auto-open gate into thinking the user has configured.
30
+ */
31
+ export declare function isSchemaComplete(config: Record<string, string> | null | undefined, schema: RelayConfigSchema): boolean;
32
+ export interface CapabilityInfo {
33
+ label: string;
34
+ priority?: string;
35
+ description?: string;
36
+ }
37
+ /**
38
+ * A credential-form tab (schema-level `tabs` capability). Each tab is a
39
+ * mutually-exclusive credential mode; only the active tab's fields submit.
40
+ */
41
+ export interface TabGroup {
42
+ id: string;
43
+ label: string;
44
+ fields: ConfigField[];
45
+ }
46
+ /**
47
+ * A repeatable field group (schema-level `cardGroup` capability). Renders
48
+ * Add/Remove cards, each cloning `fields`; submitted as a JSON array under
49
+ * `key` (e.g. `{ accounts: [{...}, {...}] }`).
50
+ */
51
+ export interface CardGroup {
52
+ key: string;
53
+ fields: ConfigField[];
54
+ itemLabel?: string;
55
+ heading?: string;
56
+ addButtonLabel?: string;
57
+ minItems?: number;
58
+ titleField?: string;
59
+ }
60
+ export interface RelayConfigSchema {
61
+ server: string;
62
+ displayName?: string;
63
+ description?: string;
64
+ fields?: ConfigField[];
65
+ capabilityInfo?: CapabilityInfo[];
66
+ /** Mutually-exclusive credential modes; see the tabbed render path. */
67
+ tabs?: TabGroup[];
68
+ /** One repeatable field group; see the card-group render path. */
69
+ cardGroup?: CardGroup;
70
+ }
71
+ export interface RenderOptions {
72
+ submitUrl: string;
73
+ pageTitle?: string;
74
+ /**
75
+ * Optional ``{KEY: VALUE}`` map populated by the OAuth AS from
76
+ * ``?prefill_<KEY>=<VALUE>`` query params on GET /authorize. Each matching
77
+ * field renders with an HTML-escaped ``value="..."`` attr so users only
78
+ * type what skret cannot supply (OTP / 2FA / one-time codes). Non-matching
79
+ * keys are ignored.
80
+ */
81
+ prefill?: Record<string, string>;
82
+ /**
83
+ * For a `tabs` schema, the id of the tab to render active on load (defaults
84
+ * to the first tab). Ignored for non-tabbed schemas.
85
+ */
86
+ initialTab?: string;
87
+ /**
88
+ * Opt-in workspace-username field (multi-user stable-sub). Honoured by the
89
+ * flat, `tabs`, and `cardGroup` render paths.
90
+ */
91
+ includeUsernameField?: boolean;
92
+ }
93
+ /**
94
+ * Wrap `bodyHtml` in the shared dark-theme HTML shell.
95
+ *
96
+ * The shell provides `<!DOCTYPE html>`, `<head>` (charset, viewport, a
97
+ * Content-Security-Policy meta, escaped `<title>`, embedded `FORM_SHELL_CSS`)
98
+ * and a `<body>` whose only child is `bodyHtml`. `bodyHtml` is inserted
99
+ * verbatim, so callers MUST pre-escape any untrusted values they interpolate.
100
+ *
101
+ * The CSP (`default-src 'none'; style-src 'unsafe-inline'; script-src
102
+ * 'unsafe-inline'; connect-src 'self'`) permits the page's own inline
103
+ * `<style>`/`<script>` and same-origin `fetch` submits while blocking any
104
+ * external resource load.
105
+ *
106
+ * `title` is HTML-escaped before being placed in `<title>`.
107
+ *
108
+ * Used by `renderCredentialForm` (relay credential form) and by
109
+ * `loginGetHandler` in `relay-login.ts` (the `/login` password gate) so both
110
+ * pages share identical typography, palette, card layout, and input styling.
111
+ * Parity with Python `render_form_shell` in
112
+ * `packages/core-py/src/mcp_core/auth/credential_form.py`.
113
+ */
114
+ export declare function renderFormShell(title: string, bodyHtml: string): string;
115
+ /**
116
+ * Render a dark-themed HTML credential form from a RelayConfigSchema.
117
+ *
118
+ * @param schema RelayConfigSchema with server metadata and field definitions.
119
+ * @param options.submitUrl URL the form POSTs to as JSON via fetch().
120
+ * @param options.pageTitle Optional browser tab title. Defaults to displayName.
121
+ * @param options.prefill Optional ``{KEY: VALUE}`` map for input ``value=`` attrs.
122
+ * @returns Complete HTML document string, XSS-safe with all dynamic content escaped.
123
+ */
124
+ export declare function renderCredentialForm(schema: RelayConfigSchema, options: RenderOptions): string;
125
+ /**
126
+ * Relay config field schema (D7).
127
+ *
128
+ * Each field supports:
129
+ * name (string, required): config.enc key
130
+ * label (string, required): UI label
131
+ * required (boolean, required): server gate
132
+ * secret (boolean, optional, default false): true = never re-render value to HTML
133
+ * oauthField (boolean, optional, default false): true = managed by OAuth flow,
134
+ * render as Re-authorize button instead of input
135
+ * type (string, optional, default "text"): UI input type
136
+ * description (string, optional): help text
137
+ * default (unknown, optional): default value if user submits empty
138
+ * pattern (string, optional): client-side regex validation
139
+ *
140
+ * Parity with core-py `RelayConfigField` (snake_case `oauth_field` -> camelCase
141
+ * `oauthField` per TS convention).
142
+ */
143
+ export interface RelayConfigField {
144
+ name: string;
145
+ label: string;
146
+ required: boolean;
147
+ secret?: boolean;
148
+ oauthField?: boolean;
149
+ type?: 'text' | 'password' | 'url' | 'email';
150
+ description?: string;
151
+ default?: unknown;
152
+ pattern?: string;
153
+ }
154
+ /** Return true if field stores a credential that must not be re-rendered to HTML. */
155
+ export declare function isSecretField(field: RelayConfigField): boolean;
156
+ /**
157
+ * Return true if field represents an OAuth-managed credential.
158
+ *
159
+ * OAuth fields render as "Re-authorize" buttons, not raw input boxes.
160
+ * Examples: refresh_token, access_token, id_token.
161
+ */
162
+ export declare function isOAuthField(field: RelayConfigField): boolean;
163
+ //# sourceMappingURL=credential-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-form.d.ts","sourceRoot":"","sources":["../../src/auth/credential-form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,EACjD,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAqBT;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,WAAW,EAAE,CAAA;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IACtB,cAAc,CAAC,EAAE,cAAc,EAAE,CAAA;IACjC,uEAAuE;IACvE,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAA;IACjB,kEAAkE;IAClE,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAwaD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgBvE;AAg8BD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAob9F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,KAAK,GAAG,OAAO,CAAA;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAE9D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAE7D"}