Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32516009
D10454.1767121764.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
D10454.1767121764.diff
View Options
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,
@@ -333,6 +334,31 @@
return useKeyserverCall(keyserverAuth);
}
+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[] {
@@ -683,4 +709,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,11 @@
+username?: ?string,
+walletAddress?: ?string,
};
+
+export type IdentityRegisterResult = {
+ +userID: string,
+ +accessToken: string,
+ +username: string,
+};
+
+export const ONE_TIME_KEYS_NUMBER: number = Object.freeze(10);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 30, 7:09 PM (20 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5869330
Default Alt Text
D10454.1767121764.diff (2 KB)
Attached To
Mode
D10454: [lib] add identity register action
Attached
Detach File
Event Timeline
Log In to Comment