@aotter/mantle-cloudflare 0.0.11-alpha.11
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/LICENSE +202 -0
- package/README.md +10 -0
- package/dist/assets/aotterFavicon.d.ts +2 -0
- package/dist/assets/aotterFavicon.d.ts.map +1 -0
- package/dist/assets/aotterFavicon.js +5 -0
- package/dist/assets/aotterFavicon.js.map +1 -0
- package/dist/auth/ConsoleEmailSender.d.ts +15 -0
- package/dist/auth/ConsoleEmailSender.d.ts.map +1 -0
- package/dist/auth/ConsoleEmailSender.js +19 -0
- package/dist/auth/ConsoleEmailSender.js.map +1 -0
- package/dist/auth/appleClientSecret.d.ts +70 -0
- package/dist/auth/appleClientSecret.d.ts.map +1 -0
- package/dist/auth/appleClientSecret.js +111 -0
- package/dist/auth/appleClientSecret.js.map +1 -0
- package/dist/auth/createAuth.d.ts +176 -0
- package/dist/auth/createAuth.d.ts.map +1 -0
- package/dist/auth/createAuth.js +360 -0
- package/dist/auth/createAuth.js.map +1 -0
- package/dist/bindings/AssetsAssetServer.d.ts +14 -0
- package/dist/bindings/AssetsAssetServer.d.ts.map +1 -0
- package/dist/bindings/AssetsAssetServer.js +20 -0
- package/dist/bindings/AssetsAssetServer.js.map +1 -0
- package/dist/bindings/D1DatabaseDriver.d.ts +21 -0
- package/dist/bindings/D1DatabaseDriver.d.ts.map +1 -0
- package/dist/bindings/D1DatabaseDriver.js +126 -0
- package/dist/bindings/D1DatabaseDriver.js.map +1 -0
- package/dist/bindings/KvCacheBinding.d.ts +14 -0
- package/dist/bindings/KvCacheBinding.d.ts.map +1 -0
- package/dist/bindings/KvCacheBinding.js +27 -0
- package/dist/bindings/KvCacheBinding.js.map +1 -0
- package/dist/bindings/R2MediaStorage.d.ts +80 -0
- package/dist/bindings/R2MediaStorage.d.ts.map +1 -0
- package/dist/bindings/R2MediaStorage.js +189 -0
- package/dist/bindings/R2MediaStorage.js.map +1 -0
- package/dist/bindings/WorkersQueueHookDispatcher.d.ts +38 -0
- package/dist/bindings/WorkersQueueHookDispatcher.d.ts.map +1 -0
- package/dist/bindings/WorkersQueueHookDispatcher.js +68 -0
- package/dist/bindings/WorkersQueueHookDispatcher.js.map +1 -0
- package/dist/bindings/index.d.ts +6 -0
- package/dist/bindings/index.d.ts.map +1 -0
- package/dist/bindings/index.js +6 -0
- package/dist/bindings/index.js.map +1 -0
- package/dist/handlers/index.d.ts +2 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +2 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/turnstile.d.ts +43 -0
- package/dist/handlers/turnstile.d.ts.map +1 -0
- package/dist/handlers/turnstile.js +71 -0
- package/dist/handlers/turnstile.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/mount/bootRuntimeOnce.d.ts +17 -0
- package/dist/mount/bootRuntimeOnce.d.ts.map +1 -0
- package/dist/mount/bootRuntimeOnce.js +35 -0
- package/dist/mount/bootRuntimeOnce.js.map +1 -0
- package/dist/mount/cmsConfig.d.ts +33 -0
- package/dist/mount/cmsConfig.d.ts.map +1 -0
- package/dist/mount/cmsConfig.js +2 -0
- package/dist/mount/cmsConfig.js.map +1 -0
- package/dist/mount/index.d.ts +6 -0
- package/dist/mount/index.d.ts.map +1 -0
- package/dist/mount/index.js +5 -0
- package/dist/mount/index.js.map +1 -0
- package/dist/mount/mountMcp.d.ts +32 -0
- package/dist/mount/mountMcp.d.ts.map +1 -0
- package/dist/mount/mountMcp.js +107 -0
- package/dist/mount/mountMcp.js.map +1 -0
- package/dist/mount/mountPublicRoutes.d.ts +82 -0
- package/dist/mount/mountPublicRoutes.d.ts.map +1 -0
- package/dist/mount/mountPublicRoutes.js +243 -0
- package/dist/mount/mountPublicRoutes.js.map +1 -0
- package/dist/mount/mountServerEndpoints.d.ts +10 -0
- package/dist/mount/mountServerEndpoints.d.ts.map +1 -0
- package/dist/mount/mountServerEndpoints.js +503 -0
- package/dist/mount/mountServerEndpoints.js.map +1 -0
- package/dist/oauth/consentHtml.d.ts +15 -0
- package/dist/oauth/consentHtml.d.ts.map +1 -0
- package/dist/oauth/consentHtml.js +89 -0
- package/dist/oauth/consentHtml.js.map +1 -0
- package/dist/oauth/index.d.ts +4 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +4 -0
- package/dist/oauth/index.js.map +1 -0
- package/dist/oauth/mountOAuth.d.ts +29 -0
- package/dist/oauth/mountOAuth.d.ts.map +1 -0
- package/dist/oauth/mountOAuth.js +105 -0
- package/dist/oauth/mountOAuth.js.map +1 -0
- package/dist/oauth/oauthConstants.d.ts +15 -0
- package/dist/oauth/oauthConstants.d.ts.map +1 -0
- package/dist/oauth/oauthConstants.js +15 -0
- package/dist/oauth/oauthConstants.js.map +1 -0
- package/dist/oauth/oauthSingleton.d.ts +34 -0
- package/dist/oauth/oauthSingleton.d.ts.map +1 -0
- package/dist/oauth/oauthSingleton.js +22 -0
- package/dist/oauth/oauthSingleton.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @aotter/mantle-cloudflare
|
|
2
|
+
|
|
3
|
+
Cloudflare Workers adapter for mantle.
|
|
4
|
+
|
|
5
|
+
This package mounts the runtime on Hono, implements the runtime ports against
|
|
6
|
+
Cloudflare D1 / KV / Workers assets, and owns Better Auth wiring for GitHub
|
|
7
|
+
OAuth plus MCP OAuth/DCR.
|
|
8
|
+
|
|
9
|
+
`0.0.7-alpha` is an early prerelease for the agent-provisioning proof. The API
|
|
10
|
+
surface remains in flux until `v0.1.0`.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const AOTTER_FAVICON_SVG = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 128 128\">\n <rect width=\"128\" height=\"128\" rx=\"28\" fill=\"#1a3062\"/>\n <path fill=\"#f7fafc\" d=\"M111.76,52.77c-4.05-6.75-13.09-19.07-28.16-25.67-.97-.43-9.36-4.13-19.6-4.13s-18.63,3.7-19.6,4.13c-15.08,6.59-24.12,18.91-28.16,25.67-6.57,10.92-6.56,17.8-6.03,20.94,1.45,8.52,35.82,16.09,33.19,19.03-3.96,4.86-1.12,12.29,7.1,12.29h26.99c8.22,0,11.06-7.44,7.1-12.29-2.63-2.94,31.74-10.5,33.19-19.03.53-3.14.54-10.01-6.03-20.94ZM101.76,64.08c-8.92,11.77-25.79,25.56-25.93,25.68-1.1,1.23-.4,2.67.21,3.94.72,1.5,1.15,2.54.53,3.38-.47.64-.75.83-1.22.83h-22.95c-.46,0-.75-.2-1.22-.83-.61-.84-.19-1.88.53-3.38.61-1.27,1.31-2.71.21-3.94-.15-.11-15.88-13.29-24.81-25.07-.46-.6-.61-1.51-.42-2.54.36-2.03,1.85-4.15,3.8-5.4,1.28-.82,2.75-1.22,4.12-1.22,1.71,0,3.25.63,4.03,1.83,1.16,1.8,14.73,23.3,16.48,26.48,1.3,2.35,2.68,3.27,4.08,2.7,1.4-.56,1-3.17-.57-12.12-1.28-7.28-3.03-22.92-3.03-31.19,0-2.17,2.62-4.45,6.45-5.08v-.03c.57-.08,3.04-.08,3.62,0v.03c3.84.63,6.45,2.91,6.45,5.08,0,8.27-1.75,23.91-3.03,31.19-1.57,8.95-1.96,11.55-.57,12.12,1.4.57,2.77-.34,4.08-2.7,1.75-3.17,16.45-25.28,17.61-27.09.77-1.2,2.32-1.83,4.03-1.83,1.37,0,2.84.4,4.12,1.22,1.95,1.25,3.45,3.38,3.8,5.4.18,1.04.03,1.94-.42,2.54Z\"/>\n</svg>";
|
|
2
|
+
//# sourceMappingURL=aotterFavicon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aotterFavicon.d.ts","sourceRoot":"","sources":["../../src/assets/aotterFavicon.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,2vCAGxB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const AOTTER_FAVICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
|
|
2
|
+
<rect width="128" height="128" rx="28" fill="#1a3062"/>
|
|
3
|
+
<path fill="#f7fafc" d="M111.76,52.77c-4.05-6.75-13.09-19.07-28.16-25.67-.97-.43-9.36-4.13-19.6-4.13s-18.63,3.7-19.6,4.13c-15.08,6.59-24.12,18.91-28.16,25.67-6.57,10.92-6.56,17.8-6.03,20.94,1.45,8.52,35.82,16.09,33.19,19.03-3.96,4.86-1.12,12.29,7.1,12.29h26.99c8.22,0,11.06-7.44,7.1-12.29-2.63-2.94,31.74-10.5,33.19-19.03.53-3.14.54-10.01-6.03-20.94ZM101.76,64.08c-8.92,11.77-25.79,25.56-25.93,25.68-1.1,1.23-.4,2.67.21,3.94.72,1.5,1.15,2.54.53,3.38-.47.64-.75.83-1.22.83h-22.95c-.46,0-.75-.2-1.22-.83-.61-.84-.19-1.88.53-3.38.61-1.27,1.31-2.71.21-3.94-.15-.11-15.88-13.29-24.81-25.07-.46-.6-.61-1.51-.42-2.54.36-2.03,1.85-4.15,3.8-5.4,1.28-.82,2.75-1.22,4.12-1.22,1.71,0,3.25.63,4.03,1.83,1.16,1.8,14.73,23.3,16.48,26.48,1.3,2.35,2.68,3.27,4.08,2.7,1.4-.56,1-3.17-.57-12.12-1.28-7.28-3.03-22.92-3.03-31.19,0-2.17,2.62-4.45,6.45-5.08v-.03c.57-.08,3.04-.08,3.62,0v.03c3.84.63,6.45,2.91,6.45,5.08,0,8.27-1.75,23.91-3.03,31.19-1.57,8.95-1.96,11.55-.57,12.12,1.4.57,2.77-.34,4.08-2.7,1.75-3.17,16.45-25.28,17.61-27.09.77-1.2,2.32-1.83,4.03-1.83,1.37,0,2.84.4,4.12,1.22,1.95,1.25,3.45,3.38,3.8,5.4.18,1.04.03,1.94-.42,2.54Z"/>
|
|
4
|
+
</svg>`;
|
|
5
|
+
//# sourceMappingURL=aotterFavicon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aotterFavicon.js","sourceRoot":"","sources":["../../src/assets/aotterFavicon.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;OAG3B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EmailSender, EmailSendArgs } from "@aotter/mantle-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Dev convenience: writes the email to `console.log` instead of
|
|
4
|
+
* sending it. Use this in `wrangler dev` to read OTP codes off the
|
|
5
|
+
* Worker logs without wiring a real sender.
|
|
6
|
+
*
|
|
7
|
+
* **Never wire this in production.** Boot diagnostics will not stop
|
|
8
|
+
* you — Better Auth is happy to call `sender.send()` either way —
|
|
9
|
+
* but real recipients won't get the email. Wrap in an env-gated
|
|
10
|
+
* factory at the adapter wiring site.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ConsoleEmailSender implements EmailSender {
|
|
13
|
+
send(args: EmailSendArgs): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ConsoleEmailSender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsoleEmailSender.d.ts","sourceRoot":"","sources":["../../src/auth/ConsoleEmailSender.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEzE;;;;;;;;;GASG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IAC9C,IAAI,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ/C"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev convenience: writes the email to `console.log` instead of
|
|
3
|
+
* sending it. Use this in `wrangler dev` to read OTP codes off the
|
|
4
|
+
* Worker logs without wiring a real sender.
|
|
5
|
+
*
|
|
6
|
+
* **Never wire this in production.** Boot diagnostics will not stop
|
|
7
|
+
* you — Better Auth is happy to call `sender.send()` either way —
|
|
8
|
+
* but real recipients won't get the email. Wrap in an env-gated
|
|
9
|
+
* factory at the adapter wiring site.
|
|
10
|
+
*/
|
|
11
|
+
export class ConsoleEmailSender {
|
|
12
|
+
async send(args) {
|
|
13
|
+
const { to, subject, text, locale, category } = args;
|
|
14
|
+
console.log(`[ConsoleEmailSender] ${category ?? "email"} → ${to} (${locale})\n` +
|
|
15
|
+
` subject: ${subject}\n` +
|
|
16
|
+
` body: ${text}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ConsoleEmailSender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsoleEmailSender.js","sourceRoot":"","sources":["../../src/auth/ConsoleEmailSender.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,OAAO,kBAAkB;IAC7B,KAAK,CAAC,IAAI,CAAC,IAAmB;QAC5B,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QACrD,OAAO,CAAC,GAAG,CACT,wBAAwB,QAAQ,IAAI,OAAO,MAAM,EAAE,KAAK,MAAM,KAAK;YACjE,cAAc,OAAO,IAAI;YACzB,WAAW,IAAI,EAAE,CACpB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper for the Sign In with Apple `clientSecret` field.
|
|
3
|
+
*
|
|
4
|
+
* Apple's "client secret" is **not** an OAuth client secret — it is
|
|
5
|
+
* an ES256-signed JWT the relying party generates from:
|
|
6
|
+
*
|
|
7
|
+
* - Team ID (Apple Developer team identifier, 10 chars)
|
|
8
|
+
* - Key ID (the Sign-In key id, 10 chars; visible in Apple Developer)
|
|
9
|
+
* - Private key (the `.p8` file Apple lets you download once)
|
|
10
|
+
* - Audience (typically the Services ID — same as the Better Auth
|
|
11
|
+
* `clientId` you pass for `provider: "apple"`)
|
|
12
|
+
*
|
|
13
|
+
* The JWT lives at most 180 days per Apple's policy. This helper
|
|
14
|
+
* defaults to 30 days; **the adopter is responsible for regenerating
|
|
15
|
+
* the JWT before it expires** (e.g. on deploy, or via a scheduled
|
|
16
|
+
* worker). A long-lived Cloudflare isolate can outlive the default,
|
|
17
|
+
* and Apple will reject signin attempts with an expired secret —
|
|
18
|
+
* don't rely on isolate restart cadence for rotation.
|
|
19
|
+
*
|
|
20
|
+
* Built on `crypto.subtle` (native to Workers) — no `node:crypto`, no
|
|
21
|
+
* JWT deps.
|
|
22
|
+
*
|
|
23
|
+
* # Adopter usage
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* const appleSecret = await appleClientSecret({
|
|
27
|
+
* teamId: env.APPLE_TEAM_ID,
|
|
28
|
+
* keyId: env.APPLE_KEY_ID,
|
|
29
|
+
* privateKey: env.APPLE_PRIVATE_KEY, // contents of the .p8 file
|
|
30
|
+
* audience: env.APPLE_SERVICES_ID, // your Services ID
|
|
31
|
+
* });
|
|
32
|
+
* const auth = createAuth({
|
|
33
|
+
* methods: [{
|
|
34
|
+
* kind: "social",
|
|
35
|
+
* provider: "apple",
|
|
36
|
+
* clientId: env.APPLE_SERVICES_ID,
|
|
37
|
+
* clientSecret: appleSecret,
|
|
38
|
+
* }],
|
|
39
|
+
* // ...
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* `env.APPLE_PRIVATE_KEY` is the multi-line PEM contents of the `.p8`
|
|
44
|
+
* file (set via `wrangler secret put APPLE_PRIVATE_KEY` — paste the
|
|
45
|
+
* whole file when prompted). The helper also accepts the bare
|
|
46
|
+
* base64-encoded DER if the PEM wrapping doesn't survive your secret
|
|
47
|
+
* pipeline.
|
|
48
|
+
*/
|
|
49
|
+
export interface AppleClientSecretArgs {
|
|
50
|
+
/** Apple Developer team identifier (10 chars). */
|
|
51
|
+
readonly teamId: string;
|
|
52
|
+
/** Sign-In key id (10 chars). */
|
|
53
|
+
readonly keyId: string;
|
|
54
|
+
/**
|
|
55
|
+
* `.p8` file contents — either PEM-wrapped
|
|
56
|
+
* (`-----BEGIN PRIVATE KEY-----\n…\n-----END PRIVATE KEY-----`)
|
|
57
|
+
* or just the base64 of the DER.
|
|
58
|
+
*/
|
|
59
|
+
readonly privateKey: string;
|
|
60
|
+
/** Typically the Services ID — same string you pass for `clientId`. */
|
|
61
|
+
readonly audience: string;
|
|
62
|
+
/**
|
|
63
|
+
* JWT lifetime in seconds. Apple caps at 180 days
|
|
64
|
+
* (`180 * 24 * 60 * 60 = 15552000`); the default here is 30 days.
|
|
65
|
+
* The helper rejects values above Apple's cap.
|
|
66
|
+
*/
|
|
67
|
+
readonly expiresInSeconds?: number;
|
|
68
|
+
}
|
|
69
|
+
export declare function appleClientSecret(args: AppleClientSecretArgs): Promise<string>;
|
|
70
|
+
//# sourceMappingURL=appleClientSecret.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appleClientSecret.d.ts","sourceRoot":"","sources":["../../src/auth/appleClientSecret.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,MAAM,WAAW,qBAAqB;IACpC,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAMD,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAoCjB"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper for the Sign In with Apple `clientSecret` field.
|
|
3
|
+
*
|
|
4
|
+
* Apple's "client secret" is **not** an OAuth client secret — it is
|
|
5
|
+
* an ES256-signed JWT the relying party generates from:
|
|
6
|
+
*
|
|
7
|
+
* - Team ID (Apple Developer team identifier, 10 chars)
|
|
8
|
+
* - Key ID (the Sign-In key id, 10 chars; visible in Apple Developer)
|
|
9
|
+
* - Private key (the `.p8` file Apple lets you download once)
|
|
10
|
+
* - Audience (typically the Services ID — same as the Better Auth
|
|
11
|
+
* `clientId` you pass for `provider: "apple"`)
|
|
12
|
+
*
|
|
13
|
+
* The JWT lives at most 180 days per Apple's policy. This helper
|
|
14
|
+
* defaults to 30 days; **the adopter is responsible for regenerating
|
|
15
|
+
* the JWT before it expires** (e.g. on deploy, or via a scheduled
|
|
16
|
+
* worker). A long-lived Cloudflare isolate can outlive the default,
|
|
17
|
+
* and Apple will reject signin attempts with an expired secret —
|
|
18
|
+
* don't rely on isolate restart cadence for rotation.
|
|
19
|
+
*
|
|
20
|
+
* Built on `crypto.subtle` (native to Workers) — no `node:crypto`, no
|
|
21
|
+
* JWT deps.
|
|
22
|
+
*
|
|
23
|
+
* # Adopter usage
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* const appleSecret = await appleClientSecret({
|
|
27
|
+
* teamId: env.APPLE_TEAM_ID,
|
|
28
|
+
* keyId: env.APPLE_KEY_ID,
|
|
29
|
+
* privateKey: env.APPLE_PRIVATE_KEY, // contents of the .p8 file
|
|
30
|
+
* audience: env.APPLE_SERVICES_ID, // your Services ID
|
|
31
|
+
* });
|
|
32
|
+
* const auth = createAuth({
|
|
33
|
+
* methods: [{
|
|
34
|
+
* kind: "social",
|
|
35
|
+
* provider: "apple",
|
|
36
|
+
* clientId: env.APPLE_SERVICES_ID,
|
|
37
|
+
* clientSecret: appleSecret,
|
|
38
|
+
* }],
|
|
39
|
+
* // ...
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* `env.APPLE_PRIVATE_KEY` is the multi-line PEM contents of the `.p8`
|
|
44
|
+
* file (set via `wrangler secret put APPLE_PRIVATE_KEY` — paste the
|
|
45
|
+
* whole file when prompted). The helper also accepts the bare
|
|
46
|
+
* base64-encoded DER if the PEM wrapping doesn't survive your secret
|
|
47
|
+
* pipeline.
|
|
48
|
+
*/
|
|
49
|
+
const DEFAULT_EXPIRES_IN_SECONDS = 30 * 24 * 60 * 60; // 30 days
|
|
50
|
+
const APPLE_MAX_EXPIRES_IN_SECONDS = 180 * 24 * 60 * 60; // 180 days
|
|
51
|
+
const APPLE_TOKEN_AUDIENCE_ISSUER = "https://appleid.apple.com";
|
|
52
|
+
export async function appleClientSecret(args) {
|
|
53
|
+
const expiresIn = args.expiresInSeconds ?? DEFAULT_EXPIRES_IN_SECONDS;
|
|
54
|
+
if (!Number.isFinite(expiresIn) || expiresIn <= 0) {
|
|
55
|
+
// `Number.isFinite` filters NaN / Infinity — without it, NaN slips
|
|
56
|
+
// through `<= 0` and lands as `exp: NaN` → JSON serialises null
|
|
57
|
+
// → Apple rejects opaquely. Catch at the boundary with a clear msg.
|
|
58
|
+
throw new Error("appleClientSecret: expiresInSeconds must be a positive finite number");
|
|
59
|
+
}
|
|
60
|
+
if (expiresIn > APPLE_MAX_EXPIRES_IN_SECONDS) {
|
|
61
|
+
throw new Error(`appleClientSecret: expiresInSeconds ${expiresIn} exceeds Apple's 180-day max (${APPLE_MAX_EXPIRES_IN_SECONDS}).`);
|
|
62
|
+
}
|
|
63
|
+
const now = Math.floor(Date.now() / 1000);
|
|
64
|
+
const header = { alg: "ES256", kid: args.keyId };
|
|
65
|
+
const payload = {
|
|
66
|
+
iss: args.teamId,
|
|
67
|
+
iat: now,
|
|
68
|
+
exp: now + expiresIn,
|
|
69
|
+
aud: APPLE_TOKEN_AUDIENCE_ISSUER,
|
|
70
|
+
sub: args.audience,
|
|
71
|
+
};
|
|
72
|
+
const headerB64 = base64UrlEncode(textEncoder.encode(JSON.stringify(header)));
|
|
73
|
+
const payloadB64 = base64UrlEncode(textEncoder.encode(JSON.stringify(payload)));
|
|
74
|
+
const signingInput = `${headerB64}.${payloadB64}`;
|
|
75
|
+
const key = await importApplePrivateKey(args.privateKey);
|
|
76
|
+
const signature = await crypto.subtle.sign({ name: "ECDSA", hash: "SHA-256" }, key, textEncoder.encode(signingInput));
|
|
77
|
+
return `${signingInput}.${base64UrlEncode(new Uint8Array(signature))}`;
|
|
78
|
+
}
|
|
79
|
+
const textEncoder = new TextEncoder();
|
|
80
|
+
const PEM_MARKERS_RE = /-----(?:BEGIN|END) [^-]+-----/g;
|
|
81
|
+
async function importApplePrivateKey(input) {
|
|
82
|
+
const der = decodePrivateKeyToDer(input);
|
|
83
|
+
return crypto.subtle.importKey("pkcs8", der, { name: "ECDSA", namedCurve: "P-256" }, false, ["sign"]);
|
|
84
|
+
}
|
|
85
|
+
function decodePrivateKeyToDer(input) {
|
|
86
|
+
// Strip PEM markers + all whitespace; tolerate the bare-base64 path too.
|
|
87
|
+
const body = input.replace(PEM_MARKERS_RE, "").replace(/\s+/g, "");
|
|
88
|
+
if (body.length === 0) {
|
|
89
|
+
throw new Error("appleClientSecret: privateKey is empty after stripping the PEM wrapper.");
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
return base64ToBytes(body);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
throw new Error("appleClientSecret: privateKey is not valid base64 — paste the contents of your .p8 file (PEM or base64).");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function base64UrlEncode(bytes) {
|
|
99
|
+
let bin = "";
|
|
100
|
+
for (let i = 0; i < bytes.length; i++)
|
|
101
|
+
bin += String.fromCharCode(bytes[i]);
|
|
102
|
+
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
103
|
+
}
|
|
104
|
+
function base64ToBytes(b64) {
|
|
105
|
+
const bin = atob(b64);
|
|
106
|
+
const out = new Uint8Array(bin.length);
|
|
107
|
+
for (let i = 0; i < bin.length; i++)
|
|
108
|
+
out[i] = bin.charCodeAt(i);
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=appleClientSecret.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appleClientSecret.js","sourceRoot":"","sources":["../../src/auth/appleClientSecret.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { EmailSender } from "@aotter/mantle-runtime";
|
|
2
|
+
export declare const ADMIN_ROLES: readonly ["contributor", "editor", "owner"];
|
|
3
|
+
export type AdminRole = (typeof ADMIN_ROLES)[number];
|
|
4
|
+
export declare const ADMIN_ROLE_SET: ReadonlySet<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Provider id for the `kind: "social"` method. Mirrors Better Auth's
|
|
7
|
+
* own `socialProviders` block keys for 1.6.9. Adding a provider that
|
|
8
|
+
* Better Auth supports = adding its id here; no other wiring needed
|
|
9
|
+
* (the config flows through to Better Auth as-is, plus the per-
|
|
10
|
+
* provider i18n label).
|
|
11
|
+
*/
|
|
12
|
+
export type SocialProviderId = "github" | "google" | "apple" | "microsoft-entra-id" | "facebook" | "discord" | "twitter" | "linkedin" | "spotify" | "twitch" | "gitlab" | "tiktok" | "reddit" | "kick" | "vk" | "naver" | "kakao" | "line" | "slack" | "atlassian" | "zoom" | "notion" | "figma" | "linear" | "vercel" | "paypal" | "huggingface" | "cognito" | "salesforce" | "polar" | "railway" | "roblox" | "paybin" | "wechat" | "dropbox";
|
|
13
|
+
/**
|
|
14
|
+
* Auth method config (discriminated union). Each `kind` is one auth
|
|
15
|
+
* surface adopters can opt into; adding a new method = adding a new
|
|
16
|
+
* union case here, not a new top-level key on `CreateAuthConfig` —
|
|
17
|
+
* per ADR-0014.
|
|
18
|
+
*
|
|
19
|
+
* `kind: "social"` is the OAuth-based bucket — `provider` discriminates
|
|
20
|
+
* the upstream IDP. We use one case rather than one-per-provider so
|
|
21
|
+
* adding (e.g.) Apple doesn't churn the union; Better Auth's
|
|
22
|
+
* provider-shaped quirks ride in `extras`.
|
|
23
|
+
*/
|
|
24
|
+
export type AuthMethodConfig = {
|
|
25
|
+
readonly kind: "social";
|
|
26
|
+
readonly provider: SocialProviderId;
|
|
27
|
+
readonly clientId: string;
|
|
28
|
+
readonly clientSecret: string;
|
|
29
|
+
/** Override the OAuth callback URL Better Auth tells the IDP to
|
|
30
|
+
* redirect to. The consumer is then responsible for forwarding
|
|
31
|
+
* requests at that URI to `auth.handler`. */
|
|
32
|
+
readonly redirectURI?: string;
|
|
33
|
+
/** OAuth scopes. Defaults vary per provider; only set when the
|
|
34
|
+
* default doesn't cover what you need (e.g. extra Google
|
|
35
|
+
* scopes for a Drive integration). */
|
|
36
|
+
readonly scope?: ReadonlyArray<string>;
|
|
37
|
+
/** Escape hatch for provider-specific options Better Auth
|
|
38
|
+
* accepts but we don't surface as first-class fields —
|
|
39
|
+
* Microsoft Entra ID's `tenantId`, Reddit's `duration`,
|
|
40
|
+
* per-provider `prompt` / `accessType` knobs, etc. Merged
|
|
41
|
+
* into the provider's config verbatim.
|
|
42
|
+
*
|
|
43
|
+
* Reserved keys are rejected at construction so a stray entry
|
|
44
|
+
* can't silently shadow first-class config: `clientId`,
|
|
45
|
+
* `clientSecret`, `redirectURI`, `scope`, `mapProfileToUser`.
|
|
46
|
+
* Use the first-class fields for those.
|
|
47
|
+
*
|
|
48
|
+
* Note: Apple specifically does NOT accept teamId/keyId/
|
|
49
|
+
* privateKey via Better Auth — its `clientSecret` is the
|
|
50
|
+
* pre-signed ES256 JWT the adopter generates out-of-band. */
|
|
51
|
+
readonly extras?: Readonly<Record<string, unknown>>;
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: "email-otp";
|
|
54
|
+
/** Transactional-email sender. SDK never owns body templates;
|
|
55
|
+
* the locale is passed through so the sender can branch. */
|
|
56
|
+
readonly sender: EmailSender;
|
|
57
|
+
/** OTP length (Better Auth default 6). */
|
|
58
|
+
readonly otpLength?: number;
|
|
59
|
+
/** OTP TTL in seconds (Better Auth default 300 = 5 min). */
|
|
60
|
+
readonly expiresInSeconds?: number;
|
|
61
|
+
/** Allowed attempts before the OTP locks (Better Auth default 3). */
|
|
62
|
+
readonly allowedAttempts?: number;
|
|
63
|
+
/** Fallback locale when the request carries no Accept-Language —
|
|
64
|
+
* typically the site's canonical locale. BCP 47. Defaults to "en". */
|
|
65
|
+
readonly fallbackLocale?: string;
|
|
66
|
+
} | {
|
|
67
|
+
readonly kind: "magic-link";
|
|
68
|
+
/** Transactional-email sender. The email body carries a single
|
|
69
|
+
* clickable URL; Better Auth verifies the token when the user
|
|
70
|
+
* lands on it. */
|
|
71
|
+
readonly sender: EmailSender;
|
|
72
|
+
/** Link TTL in seconds. Defaults to 900 (15 min); see
|
|
73
|
+
* `MAGIC_LINK_DEFAULT_EXPIRES_SECONDS` for rationale. */
|
|
74
|
+
readonly expiresInSeconds?: number;
|
|
75
|
+
/** Allowed verification attempts. Defaults to 3 to survive
|
|
76
|
+
* mail-prefetcher URL scans (Outlook Safe Links etc.); see
|
|
77
|
+
* `MAGIC_LINK_DEFAULT_ALLOWED_ATTEMPTS`. */
|
|
78
|
+
readonly allowedAttempts?: number;
|
|
79
|
+
/** Fallback locale when the request carries no Accept-Language. */
|
|
80
|
+
readonly fallbackLocale?: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* First-staff promotion rule. Decoupled from `methods[]` so switching
|
|
84
|
+
* the bootstrap signal (e.g. `github-login` → `email`) doesn't touch
|
|
85
|
+
* any method's options.
|
|
86
|
+
*
|
|
87
|
+
* Promotion fires on `user.create.after`, which Better Auth dispatches
|
|
88
|
+
* **only on first user creation**. If the operator signs in via one
|
|
89
|
+
* method (say GitHub) before the rule can match (say `match: "email"`
|
|
90
|
+
* with a non-GitHub email), the user row is created and a later
|
|
91
|
+
* sign-in via a different method on the SAME email reuses that row —
|
|
92
|
+
* `create.after` does not re-fire and the owner role is never
|
|
93
|
+
* assigned. Match key first; the linked second method inherits the
|
|
94
|
+
* role via the shared `user.id`.
|
|
95
|
+
*
|
|
96
|
+
* `match: "github-login"` is also brittle when multiple social
|
|
97
|
+
* methods are registered. Only the `github` provider's
|
|
98
|
+
* `mapProfileToUser` shim populates `user.githubLogin`; if the
|
|
99
|
+
* operator's first sign-in is via Google or another non-GitHub
|
|
100
|
+
* social, `githubLogin` is null and the rule silently no-ops. For
|
|
101
|
+
* mixed-social setups prefer `match: "email"`.
|
|
102
|
+
*/
|
|
103
|
+
export type BootstrapOwnerRule = {
|
|
104
|
+
readonly match: "github-login";
|
|
105
|
+
readonly value: string;
|
|
106
|
+
} | {
|
|
107
|
+
readonly match: "email";
|
|
108
|
+
readonly value: string;
|
|
109
|
+
};
|
|
110
|
+
export interface CreateAuthConfig {
|
|
111
|
+
readonly database: D1Database;
|
|
112
|
+
readonly baseURL: string;
|
|
113
|
+
readonly secret: string;
|
|
114
|
+
/** Registered auth methods. Boot fails fast if empty. */
|
|
115
|
+
readonly methods: ReadonlyArray<AuthMethodConfig>;
|
|
116
|
+
/** First-user-becomes-owner rule. Without it, the `owner` role must
|
|
117
|
+
* be assigned manually in D1. */
|
|
118
|
+
readonly bootstrapOwner?: BootstrapOwnerRule;
|
|
119
|
+
/** Better Auth's built-in rate limit. Defaults off; production
|
|
120
|
+
* deployments should set it. */
|
|
121
|
+
readonly rateLimit?: {
|
|
122
|
+
readonly window: number;
|
|
123
|
+
readonly max: number;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Method kind exposed to clients. Mirrors `AuthMethodConfig["kind"]`
|
|
128
|
+
* but without the adapter-internal config (secrets, sender refs). The
|
|
129
|
+
* admin SPA reads this to decide which sign-in sections to render.
|
|
130
|
+
*/
|
|
131
|
+
export type AuthMethodKind = AuthMethodConfig["kind"];
|
|
132
|
+
/**
|
|
133
|
+
* Public-facing method descriptor exposed via `Auth.methods` and the
|
|
134
|
+
* `GET /api/auth/methods` endpoint. The `social` kind carries the
|
|
135
|
+
* upstream `provider` so the admin SPA can render a per-provider
|
|
136
|
+
* button (label + future brand icon). Secrets, senders, and per-
|
|
137
|
+
* provider extras stay private.
|
|
138
|
+
*/
|
|
139
|
+
export type AuthMethodInfo = {
|
|
140
|
+
readonly kind: "email-otp";
|
|
141
|
+
} | {
|
|
142
|
+
readonly kind: "magic-link";
|
|
143
|
+
} | {
|
|
144
|
+
readonly kind: "social";
|
|
145
|
+
readonly provider: SocialProviderId;
|
|
146
|
+
};
|
|
147
|
+
export interface Auth {
|
|
148
|
+
readonly handler: (request: Request) => Promise<Response>;
|
|
149
|
+
readonly getSession: (request: Request) => Promise<{
|
|
150
|
+
session: {
|
|
151
|
+
id: string;
|
|
152
|
+
userId: string;
|
|
153
|
+
expiresAt: Date;
|
|
154
|
+
};
|
|
155
|
+
user: {
|
|
156
|
+
id: string;
|
|
157
|
+
email: string;
|
|
158
|
+
name: string;
|
|
159
|
+
image?: string | null;
|
|
160
|
+
role?: string | null;
|
|
161
|
+
githubLogin?: string | null;
|
|
162
|
+
};
|
|
163
|
+
} | null>;
|
|
164
|
+
/** Read `user.role` directly from D1. Bearer-token auth surfaces
|
|
165
|
+
* (MCP, HTTP Triggers) need this because OAuth access tokens carry
|
|
166
|
+
* userId + scopes but not the user's role. */
|
|
167
|
+
readonly getUserRole: (userId: string) => Promise<string | null>;
|
|
168
|
+
/** Methods the consumer registered, in declaration order. The admin
|
|
169
|
+
* SPA renders sign-in sections per this list. Secrets, senders, and
|
|
170
|
+
* per-provider extras are intentionally excluded — UI doesn't need
|
|
171
|
+
* them. `social` methods carry the upstream `provider` id for
|
|
172
|
+
* per-provider rendering. */
|
|
173
|
+
readonly methods: ReadonlyArray<AuthMethodInfo>;
|
|
174
|
+
}
|
|
175
|
+
export declare function createAuth(config: CreateAuthConfig): Auth;
|
|
176
|
+
//# sourceMappingURL=createAuth.d.ts.map
|