feat(core): captcha service (#8616)

This commit is contained in:
EYHN
2024-10-28 18:06:52 +00:00
parent 81029db6ce
commit 7699296f11
12 changed files with 246 additions and 190 deletions

View File

@@ -6,6 +6,7 @@ import { Telemetry } from '@affine/core/components/telemetry';
import { router } from '@affine/core/desktop/router';
import { configureCommonModules } from '@affine/core/modules';
import { configureAppTabsHeaderModule } from '@affine/core/modules/app-tabs-header';
import { ValidatorProvider } from '@affine/core/modules/cloud';
import { I18nProvider } from '@affine/core/modules/i18n';
import { configureElectronStateStorageImpls } from '@affine/core/modules/storage';
import { CustomThemeModifier } from '@affine/core/modules/theme-editor';
@@ -75,6 +76,15 @@ framework.impl(ClientSchemaProvider, {
return appInfo?.schema;
},
});
framework.impl(ValidatorProvider, {
async validate(_challenge, resource) {
const token = await apis?.ui?.getChallengeResponse(resource);
if (!token) {
throw new Error('Challenge failed');
}
return token;
},
});
const frameworkProvider = framework.provider();
// setup application lifecycle events, and emit application start event