feat: add captcha support for sign in/up (#4582)

This commit is contained in:
DarkSky
2023-10-18 03:06:07 -05:00
committed by GitHub
parent 524e48c8e6
commit 63ca9671be
42 changed files with 1275 additions and 302 deletions
+7
View File
@@ -0,0 +1,7 @@
import { mintChallengeResponse } from '@affine/native';
export const getChallengeResponse = async (resource: string) => {
// 20 bits challenge is a balance between security and user experience
// 20 bits challenge cost time is about 1-3s on m2 macbook air
return mintChallengeResponse(resource, 20);
};
+4
View File
@@ -4,6 +4,7 @@ import { getLinkPreview } from 'link-preview-js';
import { isMacOS } from '../../shared/utils';
import { logger } from '../logger';
import type { NamespaceHandlers } from '../type';
import { getChallengeResponse } from './challenge';
import { getGoogleOauthCode } from './google-auth';
export const uiHandlers = {
@@ -45,6 +46,9 @@ export const uiHandlers = {
getGoogleOauthCode: async () => {
return getGoogleOauthCode();
},
getChallengeResponse: async (_, challenge: string) => {
return getChallengeResponse(challenge);
},
getBookmarkDataByLink: async (_, link: string) => {
if (
(link.startsWith('https://x.com/') ||