mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 03:49:56 +08:00
feat(ios): hashcash in swift (#8602)
This commit is contained in:
@@ -4,7 +4,11 @@ import { Telemetry } from '@affine/core/components/telemetry';
|
||||
import { configureMobileModules } from '@affine/core/mobile/modules';
|
||||
import { router } from '@affine/core/mobile/router';
|
||||
import { configureCommonModules } from '@affine/core/modules';
|
||||
import { AuthService, WebSocketAuthProvider } from '@affine/core/modules/cloud';
|
||||
import {
|
||||
AuthService,
|
||||
ValidatorProvider,
|
||||
WebSocketAuthProvider,
|
||||
} from '@affine/core/modules/cloud';
|
||||
import { I18nProvider } from '@affine/core/modules/i18n';
|
||||
import { configureLocalStorageStateStorageImpls } from '@affine/core/modules/storage';
|
||||
import { PopupWindowProvider } from '@affine/core/modules/url';
|
||||
@@ -28,6 +32,7 @@ import { RouterProvider } from 'react-router-dom';
|
||||
|
||||
import { configureFetchProvider } from './fetch';
|
||||
import { Cookie } from './plugins/cookie';
|
||||
import { Hashcash } from './plugins/hashcash';
|
||||
|
||||
const future = {
|
||||
v7_startTransition: true,
|
||||
@@ -66,6 +71,12 @@ framework.impl(WebSocketAuthProvider, {
|
||||
};
|
||||
},
|
||||
});
|
||||
framework.impl(ValidatorProvider, {
|
||||
async validate(_challenge, resource) {
|
||||
const res = await Hashcash.hash({ challenge: resource });
|
||||
return res.value;
|
||||
},
|
||||
});
|
||||
const frameworkProvider = framework.provider();
|
||||
|
||||
// setup application lifecycle events, and emit application start event
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export interface HashcashPlugin {
|
||||
hash(options: {
|
||||
challenge: string;
|
||||
bits?: number;
|
||||
}): Promise<{ value: string }>;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { registerPlugin } from '@capacitor/core';
|
||||
|
||||
import type { HashcashPlugin } from './definitions';
|
||||
|
||||
const Hashcash = registerPlugin<HashcashPlugin>('Hashcash');
|
||||
|
||||
export * from './definitions';
|
||||
export { Hashcash };
|
||||
Reference in New Issue
Block a user