mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 03:26:47 +08:00
feat: add captcha support for sign in/up (#4582)
This commit is contained in:
@@ -10,6 +10,7 @@ import { AuthModule } from '../src/modules/auth';
|
||||
import { AuthResolver } from '../src/modules/auth/resolver';
|
||||
import { AuthService } from '../src/modules/auth/service';
|
||||
import { PrismaModule } from '../src/prisma';
|
||||
import { mintChallengeResponse, verifyChallengeResponse } from '../src/storage';
|
||||
import { RateLimiterModule } from '../src/throttler';
|
||||
|
||||
let authService: AuthService;
|
||||
@@ -176,3 +177,10 @@ test('should return valid sessionToken if request headers valid', async t => {
|
||||
);
|
||||
t.is(result.sessionToken, '123456');
|
||||
});
|
||||
|
||||
test('verify challenge', async t => {
|
||||
const resource = 'xp8D3rcXV9bMhWrb6abxl';
|
||||
const response = await mintChallengeResponse(resource, 20);
|
||||
const success = await verifyChallengeResponse(response, 20, resource);
|
||||
t.true(success);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user