toiljs 0.0.101 → 0.0.103
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 +10 -0
- package/build/compiler/.tsbuildinfo +1 -1
- package/build/compiler/toil-docs.generated.js +9 -9
- package/docs/auth/configuration.md +11 -0
- package/docs/introduction/README.md +15 -13
- package/docs/introduction/design-principles.md +58 -34
- package/docs/introduction/distributed.md +13 -4
- package/docs/introduction/how-it-works.md +81 -34
- package/docs/introduction/hyperscale.md +36 -17
- package/docs/introduction/modern-stack.md +63 -18
- package/docs/introduction/vs-other-frameworks.md +44 -28
- package/docs/introduction/why-toil.md +20 -12
- package/package.json +1 -1
- package/server/auth/AuthController.ts +36 -16
- package/src/compiler/toil-docs.generated.ts +9 -9
- package/test/pqauth-email.test.ts +33 -0
|
@@ -111,6 +111,15 @@ function setConfirmation(on: boolean): void {
|
|
|
111
111
|
clearEnvCache();
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
const EMAIL_CONFIRM_ENV = 'AUTH_EMAIL_CONFIRMATION';
|
|
115
|
+
|
|
116
|
+
/** Toggle "send a verify email at register but DO NOT block login" (the decoupled flag). */
|
|
117
|
+
function setEmailConfirmation(on: boolean): void {
|
|
118
|
+
if (on) process.env[EMAIL_CONFIRM_ENV] = 'true';
|
|
119
|
+
else delete process.env[EMAIL_CONFIRM_ENV];
|
|
120
|
+
clearEnvCache();
|
|
121
|
+
}
|
|
122
|
+
|
|
114
123
|
function hexToBytes(hex: string): Uint8Array {
|
|
115
124
|
const out = new Uint8Array(hex.length / 2);
|
|
116
125
|
for (let i = 0; i < out.length; i++) out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
@@ -162,6 +171,7 @@ describe.skipIf(!haveWasm)('built-in auth: email verification + password reset (
|
|
|
162
171
|
__resetRatelimitForTests();
|
|
163
172
|
__clearSentEmails();
|
|
164
173
|
setConfirmation(false); // default: confirmation off unless a case opts in
|
|
174
|
+
setEmailConfirmation(false);
|
|
165
175
|
mod = loadModule();
|
|
166
176
|
const shim = installFetchShim(mod);
|
|
167
177
|
restoreFetch = shim.restore;
|
|
@@ -171,6 +181,7 @@ describe.skipIf(!haveWasm)('built-in auth: email verification + password reset (
|
|
|
171
181
|
afterEach(() => {
|
|
172
182
|
restoreFetch();
|
|
173
183
|
setConfirmation(false);
|
|
184
|
+
setEmailConfirmation(false);
|
|
174
185
|
});
|
|
175
186
|
|
|
176
187
|
it(
|
|
@@ -765,4 +776,26 @@ describe.skipIf(!haveWasm)('built-in auth: email verification + password reset (
|
|
|
765
776
|
InvalidUsernameError,
|
|
766
777
|
);
|
|
767
778
|
});
|
|
779
|
+
|
|
780
|
+
it(
|
|
781
|
+
'AUTH_EMAIL_CONFIRMATION sends the verify email at register but does NOT block login',
|
|
782
|
+
async () => {
|
|
783
|
+
// The decoupled flag: verify-at-register, login NOT gated (unlike the
|
|
784
|
+
// stricter AUTH_REQUIRE_EMAIL_CONFIRMATION, which also blocks login).
|
|
785
|
+
setEmailConfirmation(true);
|
|
786
|
+
__clearSentEmails();
|
|
787
|
+
await Auth.register('kev', 'Kev-pw-strong1!', 'kev@x.com');
|
|
788
|
+
// a confirm link was emailed (the account is stored unconfirmed)
|
|
789
|
+
const tok = tokenFromEmail('confirm', 'kev@x.com');
|
|
790
|
+
expect(tok.length).toBeGreaterThan(0);
|
|
791
|
+
// login SUCCEEDS despite the unconfirmed email (no login gate)
|
|
792
|
+
__resetRatelimitForTests();
|
|
793
|
+
const session = await Auth.login('kev', 'Kev-pw-strong1!');
|
|
794
|
+
expect(session.length).toBeGreaterThan(0);
|
|
795
|
+
// and the emailed confirm link still works
|
|
796
|
+
__resetRatelimitForTests();
|
|
797
|
+
await Auth.confirmEmail(tok);
|
|
798
|
+
},
|
|
799
|
+
90_000,
|
|
800
|
+
);
|
|
768
801
|
});
|