Page MenuHomePhabricator

D10454.diff
No OneTemporary

D10454.diff

diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js
--- a/lib/actions/user-actions.js
+++ b/lib/actions/user-actions.js
@@ -30,6 +30,7 @@
UpdateUserAvatarResponse,
} from '../types/avatar-types.js';
import type { RawEntryInfo, CalendarQuery } from '../types/entry-types.js';
+import type { IdentityRegisterResult } from '../types/identity-service-types.js';
import type {
RawMessageInfo,
MessageTruncationStatuses,
@@ -372,6 +373,31 @@
);
}
+const identityRegisterActionTypes = Object.freeze({
+ started: 'IDENTITY_REGISTER_STARTED',
+ success: 'IDENTITY_REGISTER_SUCCESS',
+ failed: 'IDENTITY_REGISTER_FAILED',
+});
+function useIdentityRegister(): (
+ username: string,
+ password: string,
+) => Promise<IdentityRegisterResult> {
+ const client = React.useContext(IdentityClientContext);
+ const identityClient = client?.identityClient;
+ return React.useCallback(
+ (username, password) => {
+ if (!identityClient) {
+ throw new Error('Identity service client is not initialized');
+ }
+ if (!identityClient.registerUser) {
+ throw new Error('Register user method unimplemented');
+ }
+ return identityClient.registerUser(username, password);
+ },
+ [identityClient],
+ );
+}
+
function mergeUserInfos(
...userInfoArrays: Array<$ReadOnlyArray<UserInfo>>
): UserInfo[] {
@@ -723,4 +749,6 @@
useDeleteIdentityAccount,
keyserverAuthActionTypes,
useKeyserverAuth,
+ identityRegisterActionTypes,
+ useIdentityRegister,
};
diff --git a/lib/types/identity-service-types.js b/lib/types/identity-service-types.js
--- a/lib/types/identity-service-types.js
+++ b/lib/types/identity-service-types.js
@@ -22,6 +22,10 @@
export interface IdentityServiceClient {
+deleteUser: () => Promise<void>;
+getKeyserverKeys: string => Promise<?OutboundKeyInfoResponse>;
+ +registerUser?: (
+ username: string,
+ password: string,
+ ) => Promise<IdentityRegisterResult>;
}
export type IdentityServiceAuthLayer = {
@@ -43,3 +47,9 @@
+username?: ?string,
+walletAddress?: ?string,
};
+
+export type IdentityRegisterResult = {
+ +userID: string,
+ +accessToken: string,
+ +username: string,
+};

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 5, 1:56 PM (17 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2426140
Default Alt Text
D10454.diff (2 KB)

Event Timeline