@voltro/plugin-auth 0.86.0 → 0.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5484 -0
- package/README.md +83 -0
- package/THIRD-PARTY-NOTICES.md +3 -227
- package/dist/admission.js +1 -2
- package/dist/appUserStore.js +1 -2
- package/dist/authExtensions.js +8 -0
- package/dist/csrf.js +1 -2
- package/dist/emailVerification.js +14 -13
- package/dist/guest.d.ts +99 -0
- package/dist/guest.js +3 -0
- package/dist/guestClient.js +236 -0
- package/dist/guestCredential.js +11 -0
- package/dist/guestPasswordUpgrade.js +84 -0
- package/dist/guestPlugin.js +165 -0
- package/dist/guestSchema.js +19 -0
- package/dist/guestSecrets.js +9 -0
- package/dist/guestService.js +223 -0
- package/dist/handlers.js +114 -115
- package/dist/impersonation.js +80 -80
- package/dist/index.d.ts +265 -15
- package/dist/index.js +27 -19
- package/dist/invitations.js +24 -25
- package/dist/mail.js +1 -2
- package/dist/memberships.js +1 -2
- package/dist/native/guestStorage.js +40 -0
- package/dist/native.d.ts +110 -0
- package/dist/native.js +46 -45
- package/dist/nativeRoutes.js +62 -74
- package/dist/overlayPlugin.js +166 -0
- package/dist/passkeyHandlers.js +1 -2
- package/dist/password.js +1 -2
- package/dist/plugin.d.ts +119 -10
- package/dist/plugin.js +100 -80
- package/dist/postgresUserStore.js +20 -9
- package/dist/revocation.js +41 -25
- package/dist/schema.d.ts +41 -1
- package/dist/schema.js +100 -100
- package/dist/session.js +1 -2
- package/dist/sessionFamily.js +14 -0
- package/dist/sessionRegistry.js +94 -80
- package/dist/signedClaims.js +23 -0
- package/dist/strategy.d.ts +13 -9
- package/dist/strategy.js +27 -24
- package/dist/subjectGuard.js +1 -2
- package/dist/tokens.js +1 -2
- package/dist/totp.js +1 -2
- package/dist/userStore.js +146 -140
- package/dist/web/guestStorage.js +46 -0
- package/dist/web/passkeyClient.js +1 -2
- package/dist/web/requireAuth.js +1 -2
- package/dist/web/subjectContext.js +1 -2
- package/dist/web.d.ts +94 -0
- package/dist/web.js +4 -2
- package/dist/webauthn.js +1 -2
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -20,6 +20,21 @@ Installation, guides, the full API reference, and examples all live in the
|
|
|
20
20
|
**[Voltro documentation](https://docs.voltro.dev/docs/intro/getting-started)** — the single source of truth. This README is
|
|
21
21
|
deliberately short so there is nothing here to drift out of date.
|
|
22
22
|
|
|
23
|
+
The opt-in `auth.guest` extension adds durable guest device credentials and
|
|
24
|
+
registered sessions. Its current status is **built**; see [Guest
|
|
25
|
+
identities](https://docs.voltro.dev/docs/authentication/guests) for the storage
|
|
26
|
+
contract, trusted transaction-bound account upgrade and remaining validation
|
|
27
|
+
limits.
|
|
28
|
+
|
|
29
|
+
`@voltro/plugin-auth/guest` provides the same guest client and pure credential
|
|
30
|
+
parser without React or server imports. Possession remains a server SQL check.
|
|
31
|
+
|
|
32
|
+
`@voltro/plugin-auth/native` also exports `nativeGuestStore`: adapt a supplied
|
|
33
|
+
durable native store and host-wide lock without a memory fallback. Create and
|
|
34
|
+
Resume responses bind the guest subject to the device proof before exposing
|
|
35
|
+
the session or persisting a new proof. Real OS-keystore verification remains
|
|
36
|
+
separate from the port contract.
|
|
37
|
+
|
|
23
38
|
## Registered device sessions
|
|
24
39
|
|
|
25
40
|
`rotateRegisteredSession` replaces a credential atomically and retains inactive
|
|
@@ -30,7 +45,75 @@ upgraded auth replicas. See the bilingual
|
|
|
30
45
|
[session guide](https://docs.voltro.dev/docs/authentication/sessions) for authority
|
|
31
46
|
checks, device families and revocation cache limits.
|
|
32
47
|
|
|
48
|
+
`lockRegisteredSession(store, userId, sessionId)` reads an owned, unrotated
|
|
49
|
+
credential under the device-family fence. Supply the store of an existing
|
|
50
|
+
transaction, after the application's account/tenant fences, and keep that
|
|
51
|
+
transaction through the protected write. The helper does not validate a signed
|
|
52
|
+
token, expiry or application permissions. Root and presented-row locking reads
|
|
53
|
+
also serve rotation, touch and family revocation; ordinary reads and zero cache
|
|
54
|
+
TTL are not a substitute for native transaction semantics.
|
|
55
|
+
|
|
33
56
|
## License
|
|
34
57
|
|
|
35
58
|
Proprietary. © 2026 Voltro UG. Your use is governed by the
|
|
36
59
|
[Terms of Service](https://voltro.cloud/legal/terms). See the bundled `LICENSE`.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Complete device-family root discovery
|
|
63
|
+
|
|
64
|
+
Account-wide DataStore registry revocation locks actual user-owned family roots
|
|
65
|
+
in stable order before descendant rows. It never enumerates roots through an
|
|
66
|
+
ordinary older snapshot or rediscoveries after the current-root query. Revoke-other-
|
|
67
|
+
devices resolves its preserved lineage after acquiring the root roster, including
|
|
68
|
+
an owned rotation alias; unknown/foreign keep IDs retain no unverified family.
|
|
69
|
+
|
|
70
|
+
For an existing transaction, real owner/account fences must precede the registry's
|
|
71
|
+
family fences. New-root issuance must change the same actual owner's persisted
|
|
72
|
+
revision atomically with registration when an older repeatable-read snapshot is
|
|
73
|
+
possible. PostgreSQL row locking alone does not refresh that snapshot. Applications
|
|
74
|
+
owe whole-transaction retry/abort, not a cache workaround or fabricated owner.
|
|
75
|
+
Cloud implements this with private users.sessionFamilyRevision and its existing
|
|
76
|
+
account lifecycle fence. Other custom registries/issuers owe their equivalent
|
|
77
|
+
native contract. Native dialect/rollback/concurrency/replica/restart proof remains
|
|
78
|
+
required. Stop old issuers and apply declared schema before coordinated cutover.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### Session reads require the owned canonical family root
|
|
82
|
+
|
|
83
|
+
`findSession` and `listSessions` return only unrotated credentials whose canonical
|
|
84
|
+
family root exists and has the same `userId`. A rotated root is still a valid
|
|
85
|
+
anchor; its tenant and expiry do not replace those of the current credential.
|
|
86
|
+
Missing, foreign or chained roots are refused without reconstructing any row.
|
|
87
|
+
Custom `SessionStore` implementations must enforce this read contract too.
|
|
88
|
+
Registry and Memory reads reject ambiguous duplicate IDs. PostgreSQL uses a
|
|
89
|
+
single self-join on the actual sessions table for each lookup/enumeration.
|
|
90
|
+
Memory insert/read results copy stored dates rather than exposing mutable
|
|
91
|
+
references. These reads are point-in-time eligibility checks, not a replacement
|
|
92
|
+
for locked current-session validation inside a protected write transaction.
|
|
93
|
+
Positive revocation-cache entries still obey the configured TTL; choose the
|
|
94
|
+
required revocation window explicitly.
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
### Bind a revocation check to the signed user
|
|
98
|
+
|
|
99
|
+
`makeSessionRevocationChecker(store, options).isLiveFor(sessionId, userId)`
|
|
100
|
+
requires the verified signed user's ID. A live credential owned by another
|
|
101
|
+
user is refused. The cached entry retains the actual row owner; checking a
|
|
102
|
+
wrong user neither authorizes that user nor poisons the owner's verdict.
|
|
103
|
+
`invalidate(sessionId)` clears that credential regardless of requested user.
|
|
104
|
+
Positive freshness is capped by both TTL and observed row expiry.
|
|
105
|
+
|
|
106
|
+
`SessionRevocationChecker` implementers must provide `isLiveFor`, `invalidate`
|
|
107
|
+
and a finite nonnegative `ttlMs`. The ownerless `isLive` method is removed;
|
|
108
|
+
unsupported objects fail construction rather than becoming cache options.
|
|
109
|
+
Options accept only finite nonnegative `ttlMs`, nonnegative safe-integer
|
|
110
|
+
`maxEntries` and a `now` clock function. Zero `maxEntries` disables caching.
|
|
111
|
+
Normal HTTP auth, carried strategies and Cloud reauthorization/renewal pass
|
|
112
|
+
the verified subject ID. Native root ownership, current account authorization
|
|
113
|
+
and protected write fences remain separate requirements. Existing signed
|
|
114
|
+
payloads and session schemas do not change. Run `voltro update` to receive the
|
|
115
|
+
manual migration instructions for custom checker calls and implementations.
|
|
116
|
+
|
|
117
|
+
With `requireSessionId: true`, a missing checker fails authentication even if
|
|
118
|
+
the signed payload carries an ID. Wire a store, registry or conforming checker;
|
|
119
|
+
the flag alone does not prove a persisted session.
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Third-Party Notices — @voltro/plugin-auth
|
|
2
2
|
|
|
3
|
-
This package uses the
|
|
3
|
+
This package uses the third-party software listed below. Each is the
|
|
4
4
|
property of its respective copyright holders and is used under the terms of
|
|
5
5
|
its license. This file is provided for attribution; it grants no rights in
|
|
6
6
|
@voltro/plugin-auth itself, which is proprietary (see LICENSE).
|
|
7
7
|
|
|
8
|
-
Generated from the resolved runtime dependency closure (
|
|
8
|
+
Generated from the resolved runtime dependency closure (2 packages).
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
## jose@6.2.
|
|
12
|
+
## jose@6.2.13
|
|
13
13
|
|
|
14
14
|
License: MIT
|
|
15
15
|
|
|
@@ -37,214 +37,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
37
37
|
SOFTWARE.
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
## typeid-js@1.2.0
|
|
41
|
-
|
|
42
|
-
License: Apache-2.0
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
Apache License
|
|
46
|
-
Version 2.0, January 2004
|
|
47
|
-
http://www.apache.org/licenses/
|
|
48
|
-
|
|
49
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
50
|
-
|
|
51
|
-
1. Definitions.
|
|
52
|
-
|
|
53
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
54
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
55
|
-
|
|
56
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
57
|
-
the copyright owner that is granting the License.
|
|
58
|
-
|
|
59
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
60
|
-
other entities that control, are controlled by, or are under common
|
|
61
|
-
control with that entity. For the purposes of this definition,
|
|
62
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
63
|
-
direction or management of such entity, whether by contract or
|
|
64
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
65
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
66
|
-
|
|
67
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
68
|
-
exercising permissions granted by this License.
|
|
69
|
-
|
|
70
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
71
|
-
including but not limited to software source code, documentation
|
|
72
|
-
source, and configuration files.
|
|
73
|
-
|
|
74
|
-
"Object" form shall mean any form resulting from mechanical
|
|
75
|
-
transformation or translation of a Source form, including but
|
|
76
|
-
not limited to compiled object code, generated documentation,
|
|
77
|
-
and conversions to other media types.
|
|
78
|
-
|
|
79
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
80
|
-
Object form, made available under the License, as indicated by a
|
|
81
|
-
copyright notice that is included in or attached to the work
|
|
82
|
-
(an example is provided in the Appendix below).
|
|
83
|
-
|
|
84
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
85
|
-
form, that is based on (or derived from) the Work and for which the
|
|
86
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
87
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
88
|
-
of this License, Derivative Works shall not include works that remain
|
|
89
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
90
|
-
the Work and Derivative Works thereof.
|
|
91
|
-
|
|
92
|
-
"Contribution" shall mean any work of authorship, including
|
|
93
|
-
the original version of the Work and any modifications or additions
|
|
94
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
95
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
96
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
97
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
98
|
-
means any form of electronic, verbal, or written communication sent
|
|
99
|
-
to the Licensor or its representatives, including but not limited to
|
|
100
|
-
communication on electronic mailing lists, source code control systems,
|
|
101
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
102
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
103
|
-
excluding communication that is conspicuously marked or otherwise
|
|
104
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
105
|
-
|
|
106
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
107
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
108
|
-
subsequently incorporated within the Work.
|
|
109
|
-
|
|
110
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
111
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
112
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
113
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
114
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
115
|
-
Work and such Derivative Works in Source or Object form.
|
|
116
|
-
|
|
117
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
118
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
119
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
120
|
-
(except as stated in this section) patent license to make, have made,
|
|
121
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
122
|
-
where such license applies only to those patent claims licensable
|
|
123
|
-
by such Contributor that are necessarily infringed by their
|
|
124
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
125
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
126
|
-
institute patent litigation against any entity (including a
|
|
127
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
128
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
129
|
-
or contributory patent infringement, then any patent licenses
|
|
130
|
-
granted to You under this License for that Work shall terminate
|
|
131
|
-
as of the date such litigation is filed.
|
|
132
|
-
|
|
133
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
134
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
135
|
-
modifications, and in Source or Object form, provided that You
|
|
136
|
-
meet the following conditions:
|
|
137
|
-
|
|
138
|
-
(a) You must give any other recipients of the Work or
|
|
139
|
-
Derivative Works a copy of this License; and
|
|
140
|
-
|
|
141
|
-
(b) You must cause any modified files to carry prominent notices
|
|
142
|
-
stating that You changed the files; and
|
|
143
|
-
|
|
144
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
145
|
-
that You distribute, all copyright, patent, trademark, and
|
|
146
|
-
attribution notices from the Source form of the Work,
|
|
147
|
-
excluding those notices that do not pertain to any part of
|
|
148
|
-
the Derivative Works; and
|
|
149
|
-
|
|
150
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
151
|
-
distribution, then any Derivative Works that You distribute must
|
|
152
|
-
include a readable copy of the attribution notices contained
|
|
153
|
-
within such NOTICE file, excluding those notices that do not
|
|
154
|
-
pertain to any part of the Derivative Works, in at least one
|
|
155
|
-
of the following places: within a NOTICE text file distributed
|
|
156
|
-
as part of the Derivative Works; within the Source form or
|
|
157
|
-
documentation, if provided along with the Derivative Works; or,
|
|
158
|
-
within a display generated by the Derivative Works, if and
|
|
159
|
-
wherever such third-party notices normally appear. The contents
|
|
160
|
-
of the NOTICE file are for informational purposes only and
|
|
161
|
-
do not modify the License. You may add Your own attribution
|
|
162
|
-
notices within Derivative Works that You distribute, alongside
|
|
163
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
164
|
-
that such additional attribution notices cannot be construed
|
|
165
|
-
as modifying the License.
|
|
166
|
-
|
|
167
|
-
You may add Your own copyright statement to Your modifications and
|
|
168
|
-
may provide additional or different license terms and conditions
|
|
169
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
170
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
171
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
172
|
-
the conditions stated in this License.
|
|
173
|
-
|
|
174
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
175
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
176
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
177
|
-
this License, without any additional terms or conditions.
|
|
178
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
179
|
-
the terms of any separate license agreement you may have executed
|
|
180
|
-
with Licensor regarding such Contributions.
|
|
181
|
-
|
|
182
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
183
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
184
|
-
except as required for reasonable and customary use in describing the
|
|
185
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
186
|
-
|
|
187
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
188
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
189
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
190
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
191
|
-
implied, including, without limitation, any warranties or conditions
|
|
192
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
193
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
194
|
-
appropriateness of using or redistributing the Work and assume any
|
|
195
|
-
risks associated with Your exercise of permissions under this License.
|
|
196
|
-
|
|
197
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
198
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
199
|
-
unless required by applicable law (such as deliberate and grossly
|
|
200
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
201
|
-
liable to You for damages, including any direct, indirect, special,
|
|
202
|
-
incidental, or consequential damages of any character arising as a
|
|
203
|
-
result of this License or out of the use or inability to use the
|
|
204
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
205
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
206
|
-
other commercial damages or losses), even if such Contributor
|
|
207
|
-
has been advised of the possibility of such damages.
|
|
208
|
-
|
|
209
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
210
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
211
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
212
|
-
or other liability obligations and/or rights consistent with this
|
|
213
|
-
License. However, in accepting such obligations, You may act only
|
|
214
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
215
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
216
|
-
defend, and hold each Contributor harmless for any liability
|
|
217
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
218
|
-
of your accepting any such warranty or additional liability.
|
|
219
|
-
|
|
220
|
-
END OF TERMS AND CONDITIONS
|
|
221
|
-
|
|
222
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
223
|
-
|
|
224
|
-
To apply the Apache License to your work, attach the following
|
|
225
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
226
|
-
replaced with your own identifying information. (Don't include
|
|
227
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
228
|
-
comment syntax for the file format. We also recommend that a
|
|
229
|
-
file or class name and description of purpose be included on the
|
|
230
|
-
same "printed page" as the copyright notice for easier
|
|
231
|
-
identification within third-party archives.
|
|
232
|
-
|
|
233
|
-
Copyright [yyyy] [name of copyright owner]
|
|
234
|
-
|
|
235
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
236
|
-
you may not use this file except in compliance with the License.
|
|
237
|
-
You may obtain a copy of the License at
|
|
238
|
-
|
|
239
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
240
|
-
|
|
241
|
-
Unless required by applicable law or agreed to in writing, software
|
|
242
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
243
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
244
|
-
See the License for the specific language governing permissions and
|
|
245
|
-
limitations under the License.
|
|
246
|
-
```
|
|
247
|
-
|
|
248
40
|
## ulid@3.0.2
|
|
249
41
|
|
|
250
42
|
License: MIT
|
|
@@ -273,19 +65,3 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
273
65
|
SOFTWARE.
|
|
274
66
|
```
|
|
275
67
|
|
|
276
|
-
## uuid@11.1.1
|
|
277
|
-
|
|
278
|
-
License: MIT
|
|
279
|
-
|
|
280
|
-
```
|
|
281
|
-
The MIT License (MIT)
|
|
282
|
-
|
|
283
|
-
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
|
284
|
-
|
|
285
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
286
|
-
|
|
287
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
288
|
-
|
|
289
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
290
|
-
```
|
|
291
|
-
|
package/dist/admission.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Effect as e } from "effect";
|
|
2
|
-
|
|
2
|
+
// src/admission.ts
|
|
3
3
|
var t = (t, n, r = { store: void 0 }) => {
|
|
4
4
|
if (t === void 0) return e.succeed(null);
|
|
5
5
|
let i = t(n, r);
|
|
6
6
|
return e.isEffect(i) ? i : e.promise(() => i);
|
|
7
7
|
};
|
|
8
|
-
//#endregion
|
|
9
8
|
export { t as decideAdmission };
|
package/dist/appUserStore.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memoryUserStore as e } from "./userStore.js";
|
|
2
2
|
import { postgresUserStore as t } from "./postgresUserStore.js";
|
|
3
|
-
|
|
3
|
+
// src/appUserStore.ts
|
|
4
4
|
var n = (n = {}) => ({ sql: r }) => r === void 0 ? e() : r.onDialectOrElse({
|
|
5
5
|
pg: () => t(r, n),
|
|
6
6
|
orElse: () => {
|
|
@@ -15,5 +15,4 @@ var n = (n = {}) => ({ sql: r }) => r === void 0 ? e() : r.onDialectOrElse({
|
|
|
15
15
|
return i.apply(r, [...t]);
|
|
16
16
|
};
|
|
17
17
|
} });
|
|
18
|
-
//#endregion
|
|
19
18
|
export { n as appUserStore, r as deferredUserStore };
|
package/dist/csrf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHmac as e, randomBytes as t, timingSafeEqual as n } from "node:crypto";
|
|
2
|
-
|
|
2
|
+
// src/csrf.ts
|
|
3
3
|
var r = "voltro:csrf", i = "x-csrf-token", a = (e) => e.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""), o = (e) => {
|
|
4
4
|
let t = e.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - e.length % 4) % 4);
|
|
5
5
|
return Buffer.from(t, "base64");
|
|
@@ -18,5 +18,4 @@ var r = "voltro:csrf", i = "x-csrf-token", a = (e) => e.toString("base64").repla
|
|
|
18
18
|
let i = Buffer.from(e), a = Buffer.from(t);
|
|
19
19
|
return i.length !== a.length || !n(i, a) ? !1 : l(e, r);
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { r as CSRF_COOKIE_NAME, i as CSRF_HEADER_NAME, l as isCsrfTokenWellFormed, c as issueCsrfToken, u as verifyCsrf };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { newAuthId as e } from "./userStore.js";
|
|
2
2
|
import { hashToken as t, mintToken as n } from "./tokens.js";
|
|
3
3
|
import { Effect as r } from "effect";
|
|
4
|
-
|
|
4
|
+
// src/emailVerification.ts
|
|
5
5
|
var i = 60, a = "email_not_verified", o = "emailVerified", s = (e) => e?.policy ?? "off", c = (e) => s(e) !== "off", l = (e, t) => {
|
|
6
6
|
if (e.emailVerifiedAt != null) return !0;
|
|
7
7
|
let n = t?.exemptAccountsCreatedBefore;
|
|
@@ -22,27 +22,29 @@ var i = 60, a = "email_not_verified", o = "emailVerified", s = (e) => e?.policy
|
|
|
22
22
|
body: JSON.stringify(t),
|
|
23
23
|
contentType: "application/json; charset=utf-8"
|
|
24
24
|
}), p = (e, t, n) => `${e}${t}${t.includes("?") ? "&" : "?"}token=${encodeURIComponent(n)}`, m = (t, i, a) => r.gen(function* () {
|
|
25
|
-
let o =
|
|
26
|
-
if (
|
|
25
|
+
let o = t.email;
|
|
26
|
+
if (o === null) return !1;
|
|
27
|
+
let s = a.emailVerification, c = (a.now ?? Date.now)(), l = (s?.resendCooldownSeconds ?? 60) * 1e3;
|
|
28
|
+
if (l > 0) {
|
|
27
29
|
let e = yield* i.latestToken(t.id, "email-verify");
|
|
28
|
-
if (e &&
|
|
30
|
+
if (e && c - e.createdAt.getTime() < l) return !1;
|
|
29
31
|
}
|
|
30
|
-
let
|
|
32
|
+
let u = n("email-verify", s?.ttlSeconds ?? 86400);
|
|
31
33
|
if (yield* i.insertToken({
|
|
32
34
|
id: e("tok"),
|
|
33
|
-
tokenHash:
|
|
35
|
+
tokenHash: u.tokenHash,
|
|
34
36
|
userId: t.id,
|
|
35
37
|
purpose: "email-verify",
|
|
36
|
-
expiresAt:
|
|
38
|
+
expiresAt: u.expiresAt
|
|
37
39
|
}).pipe(r.ignore), !a.sendEmail) return !1;
|
|
38
|
-
let
|
|
40
|
+
let d = p(a.appBaseUrl ?? "", s?.callbackPath ?? "/auth/verify-email/callback", u.token);
|
|
39
41
|
return yield* r.tryPromise(() => a.sendEmail({
|
|
40
|
-
to:
|
|
42
|
+
to: o,
|
|
41
43
|
kind: "email-verify",
|
|
42
|
-
actionUrl:
|
|
44
|
+
actionUrl: d,
|
|
43
45
|
subject: "Confirm your email address",
|
|
44
|
-
text: `Confirm your email address: ${
|
|
45
|
-
html: `<p><a href="${
|
|
46
|
+
text: `Confirm your email address: ${d}`,
|
|
47
|
+
html: `<p><a href="${d}">Confirm your email address</a> — this link expires in 24 hours.</p>`
|
|
46
48
|
})).pipe(r.ignore), !0;
|
|
47
49
|
}), h = (e, t, n) => r.gen(function* () {
|
|
48
50
|
if (!e.email && !e.userId) return f(400, { error: "email or userId required" });
|
|
@@ -58,5 +60,4 @@ var i = 60, a = "email_not_verified", o = "emailVerified", s = (e) => e?.policy
|
|
|
58
60
|
verified: !0
|
|
59
61
|
})) : f(401, { error: "invalid or expired token" });
|
|
60
62
|
});
|
|
61
|
-
//#endregion
|
|
62
63
|
export { a as EMAIL_NOT_VERIFIED_CODE, o as EMAIL_VERIFIED_METADATA_KEY, i as EMAIL_VERIFY_RESEND_COOLDOWN_S, c as emailVerificationActive, d as emailVerificationGuard, g as handleEmailVerifyConfirm, h as handleEmailVerifyRequest, u as isEmailVerified, m as sendEmailVerification, l as userEmailVerified };
|
package/dist/guest.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { SubjectIdentity } from '@voltro/protocol';
|
|
2
|
+
|
|
3
|
+
/** Serializes operations in one client. A rejected existing credential never
|
|
4
|
+
* creates a replacement identity. Storage failures never enable memory fallback. */
|
|
5
|
+
export declare const createGuestClient: (options: GuestClientOptions) => {
|
|
6
|
+
connect: () => Promise<GuestClientSession>;
|
|
7
|
+
/** Prepare without replacing the active proof, persist both proofs, then
|
|
8
|
+
* commit. A later connect recovers the same identity after a lost response. */
|
|
9
|
+
rotate: () => Promise<GuestClientSession>;
|
|
10
|
+
/** Revoke on the server first. Keep the durable proof on transport failure
|
|
11
|
+
* so the caller can retry; erase locally only after confirmed revocation. */
|
|
12
|
+
revoke: () => Promise<void>;
|
|
13
|
+
/** Turn this guest into an email/password account under the same subject ID
|
|
14
|
+
* (`authRoutesPlugin({ guestUpgrade })`). The device proof is erased only after the
|
|
15
|
+
* server confirmed the account; on any refusal or transport failure it stays. */
|
|
16
|
+
upgrade: (input: {
|
|
17
|
+
readonly email: string;
|
|
18
|
+
readonly password: string;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
readonly subject: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
/** The registered account signed in on this device (cookie clients), or null. */
|
|
23
|
+
account: () => Promise<GuestClientAccount | null>;
|
|
24
|
+
/** The signed-in account if there is one, else this device's guest (resumed or created once).
|
|
25
|
+
* The usual entry for a game that offers accounts: a reload after `upgrade` or `signIn` stays the account. */
|
|
26
|
+
start: () => Promise<GuestClientPlayer>;
|
|
27
|
+
/** Sign in to an existing account with email and password (`authRoutesPlugin`), e.g. on a second
|
|
28
|
+
* device. This device's guest proof stays: after `signOut`, `start` resumes that guest. */
|
|
29
|
+
signIn: (input: {
|
|
30
|
+
readonly email: string;
|
|
31
|
+
readonly password: string;
|
|
32
|
+
}) => Promise<GuestClientAccount>;
|
|
33
|
+
/** End the account session on the server and clear its cookie. */
|
|
34
|
+
signOut: () => Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** A registered account signed in on this device (by upgrade or sign-in), through the session cookie. */
|
|
38
|
+
declare interface GuestClientAccount {
|
|
39
|
+
readonly subject: Extract<SubjectIdentity, {
|
|
40
|
+
readonly type: 'user';
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare class GuestClientError extends Error {
|
|
45
|
+
readonly code: 'storage_unavailable' | 'credential_rejected' | 'upgrade_conflict' | 'account_signed_in' | 'transport_failed' | 'invalid_response';
|
|
46
|
+
readonly status?: number | undefined;
|
|
47
|
+
constructor(code: 'storage_unavailable' | 'credential_rejected' | 'upgrade_conflict' | 'account_signed_in' | 'transport_failed' | 'invalid_response', status?: number | undefined);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export declare interface GuestClientOptions {
|
|
51
|
+
readonly apiBaseUrl: string;
|
|
52
|
+
readonly storage: GuestCredentialStore;
|
|
53
|
+
readonly prefix?: string;
|
|
54
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
55
|
+
/** Web clients include cookies and obtain a signed CSRF token for each post. */
|
|
56
|
+
readonly cookies?: boolean;
|
|
57
|
+
/** Prefix of the app's auth routes, for `upgrade`, `account`, `signIn` and `signOut` (default `/auth`). */
|
|
58
|
+
readonly accountPrefix?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** What `start` found: the signed-in account, else this device's guest. */
|
|
62
|
+
declare type GuestClientPlayer = {
|
|
63
|
+
readonly kind: 'account';
|
|
64
|
+
readonly subject: GuestClientAccount['subject'];
|
|
65
|
+
} | {
|
|
66
|
+
readonly kind: 'guest';
|
|
67
|
+
readonly subject: GuestClientSession['subject'];
|
|
68
|
+
readonly session: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export declare interface GuestClientSession {
|
|
72
|
+
readonly subject: Extract<SubjectIdentity, {
|
|
73
|
+
readonly type: 'user';
|
|
74
|
+
}> & {
|
|
75
|
+
readonly kind: 'guest';
|
|
76
|
+
};
|
|
77
|
+
readonly session: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Platform-backed durable secret storage. Native implementations use the
|
|
81
|
+
* operating system's secure store; writes resolve only after persistence. */
|
|
82
|
+
export declare interface GuestCredentialStore {
|
|
83
|
+
/** Serialize the whole read/create/write operation across users of this
|
|
84
|
+
* namespace, including other browser tabs or native client instances. */
|
|
85
|
+
readonly exclusive: <A>(work: () => Promise<A>) => Promise<A>;
|
|
86
|
+
readonly read: () => Promise<string | null>;
|
|
87
|
+
/** Persist the opaque value, including an in-progress rotation journal. */
|
|
88
|
+
readonly write: (value: string) => Promise<void>;
|
|
89
|
+
readonly remove: () => Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Browser-safe shape only. Possession is verified against SQL on the server. */
|
|
93
|
+
export declare const parseGuestCredential: (credential: string) => {
|
|
94
|
+
readonly guestId: string;
|
|
95
|
+
readonly deviceId: string;
|
|
96
|
+
readonly secret: string;
|
|
97
|
+
} | null;
|
|
98
|
+
|
|
99
|
+
export { }
|
package/dist/guest.js
ADDED