@lunora/auth 1.0.0-alpha.27 → 1.0.0-alpha.270
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.md +233 -104
- package/README.md +107 -15
- package/dist/adapter.d.mts +4 -43
- package/dist/adapter.d.ts +4 -43
- package/dist/adapter.mjs +1 -48
- package/dist/audit.d.mts +147 -0
- package/dist/audit.d.ts +147 -0
- package/dist/audit.mjs +12 -0
- package/dist/cimd-node.d.mts +1 -0
- package/dist/cimd-node.d.ts +1 -0
- package/dist/cimd-node.mjs +1 -0
- package/dist/cimd-workers.d.mts +64 -0
- package/dist/cimd-workers.d.ts +64 -0
- package/dist/cimd-workers.mjs +1 -0
- package/dist/email-guard.d.mts +143 -0
- package/dist/email-guard.d.ts +143 -0
- package/dist/email-guard.mjs +1 -0
- package/dist/index.d.mts +469 -544
- package/dist/index.d.ts +469 -544
- package/dist/index.mjs +1 -12
- package/dist/middleware.d.mts +165 -155
- package/dist/middleware.d.ts +165 -155
- package/dist/middleware.mjs +1 -56
- package/dist/migrate.d.mts +47 -0
- package/dist/migrate.d.ts +47 -0
- package/dist/migrate.mjs +1 -0
- package/dist/packem_shared/AUTH_DO_AUDIT_PATH-fIdwSspk.mjs +1 -0
- package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-C3SqYG3N.mjs +1 -0
- package/dist/packem_shared/LunoraAuthAdminError-Ce2uHRXx.mjs +1 -0
- package/dist/packem_shared/adapter-CBZ17jKi.mjs +2 -0
- package/dist/packem_shared/adapter.d-CElAPJ1U.d.ts +88 -0
- package/dist/packem_shared/adapter.d-CaPwF2v3.d.mts +88 -0
- package/dist/packem_shared/api-key-storage-D15k9_CF.mjs +1 -0
- package/dist/packem_shared/apiKey-B9uGt5Nc.mjs +1 -0
- package/dist/packem_shared/auth-do-BQPWOWW0.mjs +1 -0
- package/dist/packem_shared/authAuditBeforeHook-CQxnNVQq.mjs +1 -0
- package/dist/packem_shared/authCredentialColumns-C09M65Uc.mjs +1 -0
- package/dist/packem_shared/authDiscoveryPaths-BtKCs_3V.mjs +1 -0
- package/dist/packem_shared/authDoColumnAdditions-UwF3Rl41.mjs +1 -0
- package/dist/packem_shared/create-auth.d-QQ66RlWp.d.mts +149 -0
- package/dist/packem_shared/create-auth.d-QQ66RlWp.d.ts +149 -0
- package/dist/packem_shared/createAuth-EjuBT-g8.mjs +1 -0
- package/dist/packem_shared/createDoAuthWiring-DRWvSJIC.mjs +1 -0
- package/dist/packem_shared/createLunoraAuthClient-Ca1AdNhq.mjs +1 -0
- package/dist/packem_shared/createSignUpInvitation-CwrPh0XH.mjs +1 -0
- package/dist/packem_shared/effectiveCookieCache-JvL6i6YO.mjs +1 -0
- package/dist/packem_shared/emailGateDatabaseHooks-Dvyliwxx.mjs +1 -0
- package/dist/packem_shared/handleAuthRequest-Id9Vv_Tk.mjs +1 -0
- package/dist/packem_shared/identity-claims-hAvIl2wm.mjs +1 -0
- package/dist/packem_shared/invite-only.d-C5_mvDx4.d.mts +126 -0
- package/dist/packem_shared/invite-only.d-CYPBrNgv.d.ts +126 -0
- package/dist/packem_shared/isDevEnvironment-yLbPngwn.mjs +1 -0
- package/dist/packem_shared/legacyIssuerCleanupStatements-D9Kf8OD1.mjs +1 -0
- package/dist/packem_shared/mcp-CK5XkDFp.mjs +1 -0
- package/dist/packem_shared/on-cloudflare-edge-Dx6gFjBO.mjs +1 -0
- package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +1 -0
- package/dist/packem_shared/resolveSessionIdentity-EBhckRBW.mjs +1 -0
- package/dist/packem_shared/sessionPresets-DQQYAOER.mjs +1 -0
- package/dist/packem_shared/sql-store-uMubPYI9.mjs +1 -0
- package/dist/packem_shared/uiConfig-B8pN6pks.mjs +1 -0
- package/dist/packem_shared/worker.d-BZ9zDaZC.d.mts +873 -0
- package/dist/packem_shared/worker.d-Ckaeq8QN.d.ts +873 -0
- package/dist/plugins-client.d.mts +251 -1
- package/dist/plugins-client.d.ts +251 -1
- package/dist/plugins-client.mjs +1 -2
- package/dist/plugins-enterprise-client.d.mts +13 -0
- package/dist/plugins-enterprise-client.d.ts +13 -0
- package/dist/plugins-enterprise-client.mjs +1 -0
- package/dist/plugins-enterprise.d.mts +1669 -0
- package/dist/plugins-enterprise.d.ts +1669 -0
- package/dist/plugins-enterprise.mjs +1 -0
- package/dist/plugins.d.mts +180 -2
- package/dist/plugins.d.ts +180 -2
- package/dist/plugins.mjs +1 -22
- package/dist/schema.d.mts +39 -39
- package/dist/schema.d.ts +39 -39
- package/dist/schema.mjs +1 -62
- package/dist/sql-store.d.mts +43 -28
- package/dist/sql-store.d.ts +43 -28
- package/dist/sql-store.mjs +1 -184
- package/dist/store.d.mts +65 -47
- package/dist/store.d.ts +65 -47
- package/dist/store.mjs +1 -183
- package/dist/turnstile-middleware.d.mts +73 -55
- package/dist/turnstile-middleware.d.ts +73 -55
- package/dist/turnstile-middleware.mjs +1 -34
- package/dist/turnstile.d.mts +42 -49
- package/dist/turnstile.d.ts +42 -49
- package/dist/turnstile.mjs +1 -54
- package/dist/worker.d.mts +9 -0
- package/dist/worker.d.ts +9 -0
- package/dist/worker.mjs +1 -0
- package/package.json +58 -7
- package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-DjcUWEQl.mjs +0 -11
- package/dist/packem_shared/LunoraAuthAdminError-D4L7n6gN.mjs +0 -510
- package/dist/packem_shared/compileMigrationsSql-B9bj-mJv.mjs +0 -29
- package/dist/packem_shared/create-auth.d-Mwhb4gSc.d.mts +0 -128
- package/dist/packem_shared/create-auth.d-Mwhb4gSc.d.ts +0 -128
- package/dist/packem_shared/createAuth-BVMMllTm.mjs +0 -87
- package/dist/packem_shared/sessionPresets-Dwwd74_J.mjs +0 -38
package/LICENSE.md
CHANGED
|
@@ -1,111 +1,240 @@
|
|
|
1
|
-
# Functional Source License, Version 1.1, Apache 2.0 Future License
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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.
|
|
106
203
|
|
|
107
204
|
<!-- DEPENDENCIES -->
|
|
108
205
|
<!-- /DEPENDENCIES -->
|
|
109
206
|
|
|
110
207
|
<!-- TYPE_DEPENDENCIES -->
|
|
208
|
+
|
|
209
|
+
# Licenses of bundled types
|
|
210
|
+
The published @lunora/auth artifact additionally contains code with the following licenses:
|
|
211
|
+
MIT
|
|
212
|
+
|
|
213
|
+
# Bundled types:
|
|
214
|
+
## @better-auth/sso
|
|
215
|
+
License: MIT
|
|
216
|
+
By: Bereket Engida
|
|
217
|
+
Repository: git+https://github.com/better-auth/better-auth.git
|
|
218
|
+
|
|
219
|
+
> The MIT License (MIT)
|
|
220
|
+
> Copyright (c) 2024 - present, Bereket Engida
|
|
221
|
+
>
|
|
222
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
223
|
+
> this software and associated documentation files (the “Software”), to deal in
|
|
224
|
+
> the Software without restriction, including without limitation the rights to
|
|
225
|
+
> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
226
|
+
> the Software, and to permit persons to whom the Software is furnished to do so,
|
|
227
|
+
> subject to the following conditions:
|
|
228
|
+
>
|
|
229
|
+
> The above copyright notice and this permission notice shall be included in all
|
|
230
|
+
> copies or substantial portions of the Software.
|
|
231
|
+
>
|
|
232
|
+
> THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
233
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
234
|
+
> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
235
|
+
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
236
|
+
> DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
237
|
+
> ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
238
|
+
> DEALINGS IN THE SOFTWARE.
|
|
239
|
+
|
|
111
240
|
<!-- /TYPE_DEPENDENCIES -->
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<div align="center">
|
|
16
16
|
|
|
17
17
|
[![typescript-image][typescript-badge]][typescript-url]
|
|
18
|
-
[![
|
|
18
|
+
[![Apache-2.0 licence][license-badge]][license]
|
|
19
19
|
[![npm version][npm-version-badge]][npm-version]
|
|
20
20
|
[![npm downloads][npm-downloads-badge]][npm-downloads]
|
|
21
21
|
[![PRs Welcome][prs-welcome-badge]][prs-welcome]
|
|
@@ -55,22 +55,28 @@ pnpm add @lunora/auth
|
|
|
55
55
|
## Usage
|
|
56
56
|
|
|
57
57
|
```ts
|
|
58
|
-
import { createAuth,
|
|
58
|
+
import { createAuth, handleAuthRequest, lunoraD1Adapter } from "@lunora/auth";
|
|
59
|
+
import { createMigrationAuth, ensureMigrated } from "@lunora/auth/migrate";
|
|
59
60
|
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
const options = { secret: env.AUTH_SECRET, emailAndPassword: { enabled: true } };
|
|
62
|
+
|
|
63
|
+
// Prefer lunoraD1Adapter over passing raw env.DB — the raw binding makes
|
|
64
|
+
// better-auth resolve its Kysely adapter via a dynamic import that hangs
|
|
65
|
+
// under @cloudflare/vite-plugin's dev runner.
|
|
66
|
+
const auth = createAuth({ ...options, database: lunoraD1Adapter(env.DB) });
|
|
67
|
+
|
|
68
|
+
// A SECOND instance, over the RAW binding, only for migrating: better-auth
|
|
69
|
+
// migrates through its Kysely adapter alone and throws on lunoraD1Adapter. Build
|
|
70
|
+
// it once and keep it — `ensureMigrated` single-flights on the options object it
|
|
71
|
+
// is handed, so a `createAuth({...})` built inside `fetch` is a fresh key every
|
|
72
|
+
// request and the migration re-runs on each one.
|
|
73
|
+
const migrationAuth = createMigrationAuth({ ...options, database: env.DB });
|
|
68
74
|
|
|
69
75
|
// In your Worker's fetch handler, route /api/auth/* to better-auth and fall
|
|
70
76
|
// through to the Lunora worker for everything else:
|
|
71
77
|
export default {
|
|
72
78
|
async fetch(request, env, ctx) {
|
|
73
|
-
await ensureMigrated(
|
|
79
|
+
await ensureMigrated(migrationAuth); // idempotent schema sync; dev/small deploys
|
|
74
80
|
|
|
75
81
|
const authResponse = await handleAuthRequest(auth, request);
|
|
76
82
|
if (authResponse) return authResponse;
|
|
@@ -80,14 +86,100 @@ export default {
|
|
|
80
86
|
};
|
|
81
87
|
```
|
|
82
88
|
|
|
83
|
-
The runtime resolves the inbound session and stamps `ctx.auth` on every `query` / `mutation` / `action`: `ctx.auth.userId` is the signed-in user's id (or `null` when anonymous), and `ctx.auth.getIdentity()` resolves the
|
|
89
|
+
The runtime resolves the inbound session and stamps `ctx.auth` on every `query` / `mutation` / `action`: `ctx.auth.userId` is the signed-in user's id (or `null` when anonymous), and `ctx.auth.getIdentity()` resolves the claims: `email`, `name`, `role`, `expiresAtMs`, and, with the `organization()` plugin, `orgId` / `teamId` for the session's active organization and team.
|
|
84
90
|
|
|
85
91
|
### Plugins & CAPTCHA
|
|
86
92
|
|
|
87
|
-
better-auth's plugin factories are re-exported from `@lunora/auth/plugins` (so you don't need better-auth's deep import paths): `admin`, `anonymous`, `bearer`, `captcha`, `createAccessControl`, `customSession`, `deviceAuthorization`, `emailOTP`, `genericOAuth`, `haveIBeenPwned`, `jwt`, `magicLink`, `mcp`, `multiSession`, `oAuthProxy`, `
|
|
93
|
+
better-auth's plugin factories are re-exported from `@lunora/auth/plugins` (so you don't need better-auth's deep import paths): `admin`, `anonymous`, `bearer`, `captcha`, `createAccessControl`, `createMcpProtectedRequestHandler`, `customSession`, `deviceAuthorization`, `emailOTP`, `genericOAuth`, `haveIBeenPwned`, `jwt`, `lastLoginMethod`, `magicLink`, `mcp`, `multiSession`, `oAuthProxy`, `oauthDeviceAuthorization`, `oauthProvider`, `oneTap`, `oneTimeToken`, `organization`, `passkey`, `phoneNumber`, `requireMcpAuth`, `scim`, `siwe`, `twoFactor`, and `username`. Enterprise SSO ships separately as `sso` from `@lunora/auth/plugins/enterprise` (an optional peer — see the docs).
|
|
88
94
|
|
|
89
95
|
For Cloudflare Turnstile on the **auth flow**, use the `captcha` plugin (`captcha({ provider: "cloudflare-turnstile", secretKey: env.TURNSTILE_SECRET_KEY })`); it reads the token from the `x-captcha-response` header. For **non-auth** procedures, the package root also exports standalone helpers — `verifyTurnstile` (pure `siteverify`) and `verifyTurnstileMiddleware` (a `.use()` middleware that takes the token from the function args).
|
|
90
96
|
|
|
97
|
+
### Disposable / free-email gating
|
|
98
|
+
|
|
99
|
+
Reject throwaway/disposable signups (and branch on free-vs-business email) by reusing the visulima email lists — pure-data and **edge-safe on the default path** (no DNS). Wire it into better-auth with `withEmailGate` (or `emailGateDatabaseHooks`). The gate runs on sign-up and on address changes (`/change-email`, the email-OTP change, admin updates); `onClassify` fires only at sign-up:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { createAuth, withEmailGate, lunoraD1Adapter } from "@lunora/auth";
|
|
103
|
+
|
|
104
|
+
const auth = createAuth(
|
|
105
|
+
withEmailGate(
|
|
106
|
+
{ secret: env.AUTH_SECRET, database: lunoraD1Adapter(env.DB), emailAndPassword: { enabled: true } },
|
|
107
|
+
{
|
|
108
|
+
blockDisposable: true, // default — reject disposable domains with `EMAIL_DOMAIN_BLOCKED`
|
|
109
|
+
allowDomains: ["your-company.com"], // never blocked; always classified `business`
|
|
110
|
+
denyDomains: [], // extra domains to treat as disposable
|
|
111
|
+
// mx: true, // OPT-IN deliverability check — needs DNS (node:dns), so keep it OFF on the edge path
|
|
112
|
+
onClassify: (c, user) => console.log(`signup ${user.email as string}: ${c.emailClass}`),
|
|
113
|
+
},
|
|
114
|
+
),
|
|
115
|
+
);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
A blocked signup fails with the coded error `EMAIL_DOMAIN_BLOCKED` (HTTP 400); a business/free email passes and its `emailClass` (`disposable | free | business`) is surfaced via `onClassify`. Everything is config-gated and defaults sensibly.
|
|
119
|
+
|
|
120
|
+
- **Programmatic / non-auth use:** `classifyEmail(email, config)` (sync, pure-data) and `assertEmailAllowed(email, config)` (async; throws the coded error) come from `@lunora/auth/email-guard`, plus `emailGateMiddleware({ email: (ctx) => ctx.args.email })` for a `.use()` gate on your own signup mutations.
|
|
121
|
+
- **Edge-safety:** on workerd, `await loadEmailDomainLists()` once at worker init (the gate helpers do this for you). The optional `mx: true` deliverability check is loaded via a dynamic import so `node:dns` never enters the default bundle — enable it only with `nodejs_compat` (or a DNS-over-HTTPS shim).
|
|
122
|
+
|
|
123
|
+
### Invite-only sign-up
|
|
124
|
+
|
|
125
|
+
Close self-serve registration: `inviteOnly()` creates an account only for an address an administrator invited. It hooks `user.create.before`, so it gates every path that mints a user — password sign-up, an OAuth callback creating a new account, magic link, `admin.createUser`, and Lunora's own `AuthAdmin.createUser` — and declares the `signUpInvitation` table it reads, so migrations pick it up on their own.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import { createAuth, createSignUpInvitation } from "@lunora/auth";
|
|
129
|
+
import { inviteOnly } from "@lunora/auth/plugins";
|
|
130
|
+
|
|
131
|
+
const auth = createAuth({
|
|
132
|
+
secret: env.AUTH_SECRET,
|
|
133
|
+
database: lunoraD1Adapter(env.DB),
|
|
134
|
+
emailAndPassword: { enabled: true, requireEmailVerification: true },
|
|
135
|
+
plugins: [inviteOnly()],
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// …from your own admin-authorized code:
|
|
139
|
+
const invite = await createSignUpInvitation(auth, { email: "ada@example.com" });
|
|
140
|
+
const link = `https://app.example/sign-up?email=${encodeURIComponent(invite.email)}&invite=${invite.token}`;
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
An uninvited signup fails with the coded error `SIGN_UP_INVITE_REQUIRED` (HTTP **400** — a 403 from a create hook is swallowed by better-auth's sign-up route and answered with a fabricated success). Leave `emailAndPassword.disableSignUp` **off** — the invitee still uses the ordinary sign-up form, which `@lunora/auth-ui` prefills from `?email=`. `listSignUpInvitations` and `revokeSignUpInvitation` complete the set; all three are trusted server-side calls with no authorization of their own, so gate them like any other admin action.
|
|
144
|
+
|
|
145
|
+
- **An invitation carries a secret token** — 256 CSPRNG bits, returned in the clear exactly once and stored only as a SHA-256. It is checked on `/sign-up/email` and nowhere else. Other account-minting paths admit an invitation only when the new account's email is verified: magic link and email OTP are, and an OAuth or SSO account is only when its provider reports the address verified (SSO reports unverified unless `trustEmailVerified` is set, and SCIM provisioning cannot take an invitation). See [`docs/plugins.mdx`](docs/plugins.mdx). So there are two layers: the database gate requires an unspent invitation whatever created the row, and the route hook additionally requires the token. Missing token, wrong token, expired invitation and never-invited address all answer with one message, so the form is not a directory oracle.
|
|
146
|
+
- **The link is a bearer credential.** Whoever holds it takes the seat — send it to the invitee, not a shared inbox, and reissue rather than resend if unsure. `requireEmailVerification` still matters: the user row is written before the verification mail goes out, so verification is what keeps a spent invitation from becoming a usable session. The plugin warns on startup when password sign-up runs without it.
|
|
147
|
+
- **Plugins that synthesize an address are refused, not admitted.** `anonymous` (`temp-<id>@…`), `siwe` (`<wallet>@<domain>`), and `phoneNumber`'s sign-up-on-verification all create users with a generated email that matches no invitation, so those flows are rejected — but only once a user exists. Under `allowFirstUser: true` the bootstrap runs before the address is compared, so the first anonymous session or wallet sign-in is what claims it. Don't combine them with this.
|
|
148
|
+
- **Nobody signs up before the first invitation exists, including you.** Seed it with `createSignUpInvitation` at worker init or from a one-off internal mutation. `inviteOnly({ allowFirstUser: true })` instead admits the first account uninvited — convenient, but the "is the user table empty" check is racy and open to whoever finds the URL first.
|
|
149
|
+
- **The studio's Users page grows a Sign-up invitations section** when the plugin is installed — invite, see pending/accepted/expired, revoke. The same three ops are on `AuthAdmin` and the client (`listAuthSignUpInvitations`, `createAuthSignUpInvitation`, `revokeAuthSignUpInvitation`), with `useSignUpInvitations()` in `@lunora/react`. Nothing prunes the table; `pruneSignUpInvitations(auth)` deletes the invitations that expired unused and returns the count.
|
|
150
|
+
- **Revocation is not retroactive, and not atomic against a sign-up in flight.** better-auth does not wrap the `before` hook and the user insert in one transaction, and the adapter contract offers no conditional consume, so a revoke landing between the two lets that one account through. `AuthAdmin.removeUser` is how you undo one that already happened.
|
|
151
|
+
|
|
152
|
+
### Security / audit trail
|
|
153
|
+
|
|
154
|
+
Record authentication & security events (sign-in, sign-up, password change, MFA enable/disable, token refresh, session revoke, …) to a durable, queryable audit trail. Install the better-auth `hooks.after` recorder `authAuditHook` with its `hooks.before` companion `authAuditBeforeHook` (or compose both onto existing hooks via `withAuthAudit`), backed by the same D1 database as the auth tables:
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
import { authAuditBeforeHook, authAuditHook, createAuth, d1Executor, lunoraD1Adapter, readAuthAuditLog } from "@lunora/auth";
|
|
158
|
+
|
|
159
|
+
const executor = d1Executor(env.DB);
|
|
160
|
+
|
|
161
|
+
const auth = createAuth({
|
|
162
|
+
secret: env.AUTH_SECRET,
|
|
163
|
+
database: lunoraD1Adapter(env.DB),
|
|
164
|
+
hooks: {
|
|
165
|
+
// reads the owner of a session an admin revokes, which the revoke itself deletes
|
|
166
|
+
before: authAuditBeforeHook(),
|
|
167
|
+
after: authAuditHook({
|
|
168
|
+
executor,
|
|
169
|
+
// retention is CONFIGURABLE and NOT capped — omit it for an unbounded, compliance-grade trail
|
|
170
|
+
retention: 100_000,
|
|
171
|
+
// optional export tap for SIEM forwarding (receives each redacted entry)
|
|
172
|
+
onRecord: (entry) => forwardToSiem(entry),
|
|
173
|
+
}),
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// Query the trail (RLS/admin-gate this in your own read):
|
|
178
|
+
const recent = await readAuthAuditLog(executor, { event: "sign-in", limit: 100 });
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The built-in hook records only the request path in `detail`; it is free-form for entries you append yourself. Either way the payload is scrubbed with `@visulima/redact` before it is persisted, so a token/password that leaks into one never reaches the durable table. Retention defaults to unbounded (set `retention` to bound it). The store lives in the reserved `__lunora_auth_audit__` table (auto-hidden from the data browser).
|
|
182
|
+
|
|
91
183
|
> This README covers the basics. For the full API, options, and guides, see the **[documentation](https://lunora.sh/docs/packages/auth)**.
|
|
92
184
|
|
|
93
185
|
## Related
|
|
@@ -118,11 +210,11 @@ This is an open source project and will always remain free to use. If you think
|
|
|
118
210
|
|
|
119
211
|
## License
|
|
120
212
|
|
|
121
|
-
The Lunora auth package is open-sourced software licensed under the [
|
|
213
|
+
The Lunora auth package is open-sourced software licensed under the [Apache-2.0][license].
|
|
122
214
|
|
|
123
215
|
<!-- badges -->
|
|
124
216
|
|
|
125
|
-
[license-badge]: https://img.shields.io/badge/license-
|
|
217
|
+
[license-badge]: https://img.shields.io/badge/license-Apache--2.0-blue.svg?style=for-the-badge
|
|
126
218
|
[license]: https://github.com/anolilab/lunora/blob/alpha/LICENSE.md
|
|
127
219
|
[npm-version-badge]: https://img.shields.io/npm/v/@lunora/auth?style=for-the-badge
|
|
128
220
|
[npm-version]: https://www.npmjs.com/package/@lunora/auth
|
package/dist/adapter.d.mts
CHANGED
|
@@ -1,43 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
* A better-auth database adapter backed by an {@link AuthStore} — the bridge
|
|
6
|
-
* that routes better-auth's reads and writes through Lunora's data layer
|
|
7
|
-
* instead of better-auth's built-in D1/Kysely adapter. Pass the result as
|
|
8
|
-
* `createAuth({ database: lunoraAuthAdapter(store) })`; better-auth's
|
|
9
|
-
* `createAdapterFactory` handles id generation, default values, field-name
|
|
10
|
-
* mapping and output shaping, so this only translates the cleaned CRUD calls
|
|
11
|
-
* onto the store.
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* const auth = createAuth({
|
|
15
|
-
* secret: env.AUTH_SECRET,
|
|
16
|
-
* emailAndPassword: { enabled: true },
|
|
17
|
-
* database: lunoraAuthAdapter(lunoraStore), // lunoraStore writes via ctx.db
|
|
18
|
-
* });
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* Scope: the {@link AuthStore} interface is single-table CRUD. better-auth's
|
|
22
|
-
* relational `join` reads (an advanced opt-in) are not handled — pair the
|
|
23
|
-
* adapter with `disableJoins` or let better-auth fall back to per-table reads.
|
|
24
|
-
*/
|
|
25
|
-
declare const lunoraAuthAdapter: (store: AuthStore) => ReturnType<typeof createAdapterFactory>;
|
|
26
|
-
/**
|
|
27
|
-
* One-liner for the common case: a better-auth `database` backed by a Cloudflare
|
|
28
|
-
* D1 binding, via Lunora's SQL store — equivalent to
|
|
29
|
-
* `lunoraAuthAdapter(createSqlAuthStore(d1Executor(d1)))`.
|
|
30
|
-
*
|
|
31
|
-
* Prefer this over passing the raw `env.DB` as `database`. With raw D1,
|
|
32
|
-
* better-auth resolves its Kysely adapter through a runtime `await import(...)`
|
|
33
|
-
* inside `auth.$context`, and that dynamic import never settles under
|
|
34
|
-
* `@cloudflare/vite-plugin`'s worker runner — so it hangs *every* auth request
|
|
35
|
-
* in `pnpm dev` (a standalone `wrangler dev` or a deployed worker bundle it
|
|
36
|
-
* up-front, so they're unaffected — which makes the hang baffling to debug).
|
|
37
|
-
* This explicit adapter skips that import entirely, so dev and prod behave the
|
|
38
|
-
* same. The migration instance is the one exception — it wants raw `env.DB` so
|
|
39
|
-
* `ensureMigrated`'s Kysely migrator can create the tables (its `$context` is
|
|
40
|
-
* never resolved, so the hang doesn't apply there).
|
|
41
|
-
*/
|
|
42
|
-
declare const lunoraD1Adapter: (d1: Parameters<typeof d1Executor>[0]) => ReturnType<typeof lunoraAuthAdapter>;
|
|
43
|
-
export { lunoraAuthAdapter, lunoraD1Adapter };
|
|
1
|
+
import 'better-auth/adapters';
|
|
2
|
+
export { l as lunoraAuthAdapter, a as lunoraD1Adapter, b as lunoraDoAdapter } from "./packem_shared/adapter.d-CaPwF2v3.mjs";
|
|
3
|
+
import "./sql-store.mjs";
|
|
4
|
+
import "./store.mjs";
|
package/dist/adapter.d.ts
CHANGED
|
@@ -1,43 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
* A better-auth database adapter backed by an {@link AuthStore} — the bridge
|
|
6
|
-
* that routes better-auth's reads and writes through Lunora's data layer
|
|
7
|
-
* instead of better-auth's built-in D1/Kysely adapter. Pass the result as
|
|
8
|
-
* `createAuth({ database: lunoraAuthAdapter(store) })`; better-auth's
|
|
9
|
-
* `createAdapterFactory` handles id generation, default values, field-name
|
|
10
|
-
* mapping and output shaping, so this only translates the cleaned CRUD calls
|
|
11
|
-
* onto the store.
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* const auth = createAuth({
|
|
15
|
-
* secret: env.AUTH_SECRET,
|
|
16
|
-
* emailAndPassword: { enabled: true },
|
|
17
|
-
* database: lunoraAuthAdapter(lunoraStore), // lunoraStore writes via ctx.db
|
|
18
|
-
* });
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* Scope: the {@link AuthStore} interface is single-table CRUD. better-auth's
|
|
22
|
-
* relational `join` reads (an advanced opt-in) are not handled — pair the
|
|
23
|
-
* adapter with `disableJoins` or let better-auth fall back to per-table reads.
|
|
24
|
-
*/
|
|
25
|
-
declare const lunoraAuthAdapter: (store: AuthStore) => ReturnType<typeof createAdapterFactory>;
|
|
26
|
-
/**
|
|
27
|
-
* One-liner for the common case: a better-auth `database` backed by a Cloudflare
|
|
28
|
-
* D1 binding, via Lunora's SQL store — equivalent to
|
|
29
|
-
* `lunoraAuthAdapter(createSqlAuthStore(d1Executor(d1)))`.
|
|
30
|
-
*
|
|
31
|
-
* Prefer this over passing the raw `env.DB` as `database`. With raw D1,
|
|
32
|
-
* better-auth resolves its Kysely adapter through a runtime `await import(...)`
|
|
33
|
-
* inside `auth.$context`, and that dynamic import never settles under
|
|
34
|
-
* `@cloudflare/vite-plugin`'s worker runner — so it hangs *every* auth request
|
|
35
|
-
* in `pnpm dev` (a standalone `wrangler dev` or a deployed worker bundle it
|
|
36
|
-
* up-front, so they're unaffected — which makes the hang baffling to debug).
|
|
37
|
-
* This explicit adapter skips that import entirely, so dev and prod behave the
|
|
38
|
-
* same. The migration instance is the one exception — it wants raw `env.DB` so
|
|
39
|
-
* `ensureMigrated`'s Kysely migrator can create the tables (its `$context` is
|
|
40
|
-
* never resolved, so the hang doesn't apply there).
|
|
41
|
-
*/
|
|
42
|
-
declare const lunoraD1Adapter: (d1: Parameters<typeof d1Executor>[0]) => ReturnType<typeof lunoraAuthAdapter>;
|
|
43
|
-
export { lunoraAuthAdapter, lunoraD1Adapter };
|
|
1
|
+
import 'better-auth/adapters';
|
|
2
|
+
export { l as lunoraAuthAdapter, a as lunoraD1Adapter, b as lunoraDoAdapter } from "./packem_shared/adapter.d-CElAPJ1U.js";
|
|
3
|
+
import "./sql-store.js";
|
|
4
|
+
import "./store.js";
|