Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33308862
D14083.1768803148.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D14083.1768803148.diff
View Options
diff --git a/lib/hooks/login-hooks.js b/lib/hooks/login-hooks.js
--- a/lib/hooks/login-hooks.js
+++ b/lib/hooks/login-hooks.js
@@ -194,4 +194,4 @@
);
}
-export { usePasswordLogIn, useWalletLogIn, useSecondaryDeviceLogIn };
+export { usePasswordLogIn, useWalletLogIn, useSecondaryDeviceLogIn, useLogIn };
diff --git a/native/account/restore.js b/native/account/restore.js
--- a/native/account/restore.js
+++ b/native/account/restore.js
@@ -3,6 +3,8 @@
import invariant from 'invariant';
import * as React from 'react';
+import { restoreUserActionTypes } from 'lib/actions/user-actions.js';
+import { useLogIn } from 'lib/hooks/login-hooks.js';
import { IdentityClientContext } from 'lib/shared/identity-client-context.js';
import type {
IdentityAuthResult,
@@ -12,6 +14,7 @@
import { getContentSigningKey } from 'lib/utils/crypto-utils.js';
import { composeRawDeviceList } from 'lib/utils/device-list-utils.js';
import { getMessageForException } from 'lib/utils/errors.js';
+import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
import { useSelector } from 'lib/utils/redux-utils.js';
import { useClientBackup } from '../backup/use-client-backup.js';
@@ -113,4 +116,43 @@
);
}
-export { useRestoreProtocol };
+function useRestore(): (
+ userIdentifier: string,
+ secret: string,
+ siweMessage?: string,
+ siweSignature?: string,
+) => Promise<void> {
+ const restoreProtocol = useRestoreProtocol();
+ const dispatchActionPromise = useDispatchActionPromise();
+ const restoreAuth = React.useCallback(
+ (
+ userIdentifier: string,
+ secret: string,
+ siweMessage?: string,
+ siweSignature?: string,
+ ) => {
+ const promise = restoreProtocol(
+ userIdentifier,
+ secret,
+ siweMessage,
+ siweSignature,
+ );
+ void dispatchActionPromise(restoreUserActionTypes, promise);
+ return promise;
+ },
+ [dispatchActionPromise, restoreProtocol],
+ );
+
+ const logIn = useLogIn();
+ return React.useCallback(
+ (
+ userIdentifier: string,
+ secret: string,
+ siweMessage?: string,
+ siweSignature?: string,
+ ) => logIn(restoreAuth(userIdentifier, secret, siweMessage, siweSignature)),
+ [logIn, restoreAuth],
+ );
+}
+
+export { useRestore };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 19, 6:12 AM (15 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5954758
Default Alt Text
D14083.1768803148.diff (2 KB)
Attached To
Mode
D14083: [native] implement hook for restore
Attached
Detach File
Event Timeline
Log In to Comment