@openfort/react-native 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/auth/index.js +1 -0
- package/dist/hooks/auth/useEmailAuth.js +11 -4
- package/dist/hooks/auth/useOAuth.js +2 -2
- package/dist/hooks/auth/useWalletAuth.js +14 -3
- package/dist/hooks/core/index.js +0 -1
- package/dist/hooks/wallet/index.js +1 -0
- package/dist/hooks/wallet/useWallet.js +5 -0
- package/dist/types/hooks/auth/index.d.ts +1 -0
- package/dist/types/hooks/auth/useEmailAuth.d.ts +5 -0
- package/dist/types/hooks/auth/useOAuth.d.ts +1 -1
- package/dist/types/hooks/auth/useWalletAuth.d.ts +8 -2
- package/dist/types/hooks/core/index.d.ts +0 -1
- package/dist/types/hooks/wallet/index.d.ts +1 -0
- package/dist/types/hooks/wallet/useWallet.d.ts +1 -0
- package/package.json +1 -1
- package/dist/hooks/auth/useUser.js +0 -1
- package/dist/hooks/core/useSignOut.js +0 -7
- package/dist/types/hooks/auth/useUser.d.ts +0 -0
- package/dist/types/hooks/core/useSignOut.d.ts +0 -3
package/dist/hooks/auth/index.js
CHANGED
|
@@ -2,8 +2,17 @@ import { useCallback } from 'react';
|
|
|
2
2
|
import { useOpenfortContext } from '../../core/context';
|
|
3
3
|
import { onError, onSuccess } from '../../lib/hookConsistency';
|
|
4
4
|
import { OpenfortError, OpenfortErrorType } from '../../types/openfortError';
|
|
5
|
+
const mapStatus = (status) => {
|
|
6
|
+
return {
|
|
7
|
+
isLoading: status.status === 'submitting-code' || status.status === 'sending-verification-code',
|
|
8
|
+
isError: status.status === 'error',
|
|
9
|
+
isSuccess: status.status === 'done',
|
|
10
|
+
requiresEmailVerification: status.status === 'awaiting-code-input',
|
|
11
|
+
error: "error" in status ? status.error : null,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
5
14
|
export const useEmailAuth = (hookOptions = {}) => {
|
|
6
|
-
const { client, setPasswordState, _internal } = useOpenfortContext();
|
|
15
|
+
const { client, setPasswordState, _internal, passwordState } = useOpenfortContext();
|
|
7
16
|
const signInEmail = useCallback(async (options) => {
|
|
8
17
|
try {
|
|
9
18
|
setPasswordState({ status: 'sending-verification-code' });
|
|
@@ -162,8 +171,6 @@ export const useEmailAuth = (hookOptions = {}) => {
|
|
|
162
171
|
requestResetPassword,
|
|
163
172
|
resetPassword,
|
|
164
173
|
reset,
|
|
165
|
-
|
|
166
|
-
// requiresEmailVerification,
|
|
167
|
-
// isAwaitingInput: status.status === 'awaiting-input',
|
|
174
|
+
...mapStatus(passwordState),
|
|
168
175
|
};
|
|
169
176
|
};
|
|
@@ -158,7 +158,7 @@ export const useOAuth = (hookOptions = {}) => {
|
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
}, [client, setOAuthState, _internal]);
|
|
161
|
-
const
|
|
161
|
+
const linkOauth = useCallback(async (options) => {
|
|
162
162
|
try {
|
|
163
163
|
setOAuthState({ status: 'loading' });
|
|
164
164
|
// Get current user access token for linking
|
|
@@ -285,7 +285,7 @@ export const useOAuth = (hookOptions = {}) => {
|
|
|
285
285
|
const storeCredentials = () => { }; // TODO
|
|
286
286
|
return {
|
|
287
287
|
initOAuth,
|
|
288
|
-
|
|
288
|
+
linkOauth,
|
|
289
289
|
storeCredentials,
|
|
290
290
|
...mapOAuthStatus(oAuthState),
|
|
291
291
|
};
|
|
@@ -2,6 +2,17 @@ import { useCallback } from 'react';
|
|
|
2
2
|
import { useOpenfortContext } from '../../core/context';
|
|
3
3
|
import { onError, onSuccess } from '../../lib/hookConsistency';
|
|
4
4
|
import { OpenfortError, OpenfortErrorType } from '../../types/openfortError';
|
|
5
|
+
const mapStatus = (status) => {
|
|
6
|
+
return {
|
|
7
|
+
isLoading: status.status === 'generating-message' || status.status === 'awaiting-signature' || status.status === 'submitting-signature',
|
|
8
|
+
isError: status.status === 'error',
|
|
9
|
+
isSuccess: status.status === 'done',
|
|
10
|
+
error: "error" in status ? status.error : null,
|
|
11
|
+
isAwaitingSignature: status.status === 'awaiting-signature',
|
|
12
|
+
isGeneratingMessage: status.status === 'generating-message',
|
|
13
|
+
isSubmittingSignature: status.status === 'submitting-signature',
|
|
14
|
+
};
|
|
15
|
+
};
|
|
5
16
|
export function useWalletAuth(hookOptions) {
|
|
6
17
|
const { client, siweState, setSiweState, _internal } = useOpenfortContext();
|
|
7
18
|
const generateSiweMessage = useCallback(async (args) => {
|
|
@@ -36,7 +47,7 @@ export function useWalletAuth(hookOptions) {
|
|
|
36
47
|
});
|
|
37
48
|
}
|
|
38
49
|
}, [client, setSiweState]);
|
|
39
|
-
const
|
|
50
|
+
const linkSiwe = useCallback(async (opts) => {
|
|
40
51
|
try {
|
|
41
52
|
setSiweState({ status: 'submitting-signature' });
|
|
42
53
|
const message = opts.messageOverride || '';
|
|
@@ -116,7 +127,7 @@ export function useWalletAuth(hookOptions) {
|
|
|
116
127
|
return {
|
|
117
128
|
generateSiweMessage,
|
|
118
129
|
signInWithSiwe,
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
linkSiwe,
|
|
131
|
+
...mapStatus(siweState),
|
|
121
132
|
};
|
|
122
133
|
}
|
package/dist/hooks/core/index.js
CHANGED
|
@@ -44,6 +44,11 @@ export type UseEmailHookOptions = {
|
|
|
44
44
|
emailVerificationRedirectTo?: string;
|
|
45
45
|
} & OpenfortHookOptions<EmailAuthResult | EmailVerificationResult> & CreateWalletPostAuthOptions;
|
|
46
46
|
export declare const useEmailAuth: (hookOptions?: UseEmailHookOptions) => {
|
|
47
|
+
isLoading: boolean;
|
|
48
|
+
isError: boolean;
|
|
49
|
+
isSuccess: boolean;
|
|
50
|
+
requiresEmailVerification: boolean;
|
|
51
|
+
error: Error | null;
|
|
47
52
|
signInEmail: (options: SignInEmailOptions) => Promise<EmailAuthResult>;
|
|
48
53
|
signUpEmail: (options: SignUpEmailOptions) => Promise<EmailAuthResult>;
|
|
49
54
|
verifyEmail: () => void;
|
|
@@ -57,6 +57,6 @@ export declare const useOAuth: (hookOptions?: AuthHookOptions) => {
|
|
|
57
57
|
isSuccess: boolean;
|
|
58
58
|
error: Error | null | undefined;
|
|
59
59
|
initOAuth: (options: InitializeOAuthOptions) => Promise<InitOAuthReturnType>;
|
|
60
|
-
|
|
60
|
+
linkOauth: (options: InitializeOAuthOptions) => Promise<InitOAuthReturnType>;
|
|
61
61
|
storeCredentials: () => void;
|
|
62
62
|
};
|
|
@@ -34,9 +34,15 @@ type GenerateSiweMessageResult = {
|
|
|
34
34
|
message?: string;
|
|
35
35
|
};
|
|
36
36
|
export declare function useWalletAuth(hookOptions?: WalletHookOptions): {
|
|
37
|
+
isLoading: boolean;
|
|
38
|
+
isError: boolean;
|
|
39
|
+
isSuccess: boolean;
|
|
40
|
+
error: Error | null;
|
|
41
|
+
isAwaitingSignature: boolean;
|
|
42
|
+
isGeneratingMessage: boolean;
|
|
43
|
+
isSubmittingSignature: boolean;
|
|
37
44
|
generateSiweMessage: (args: GenerateSiweMessageOptions) => Promise<GenerateSiweMessageResult>;
|
|
38
45
|
signInWithSiwe: (opts: SiweOptions) => Promise<WalletHookResult>;
|
|
39
|
-
|
|
40
|
-
state: import("../..").SiweFlowState;
|
|
46
|
+
linkSiwe: (opts: LinkSiweOptions) => Promise<WalletHookResult>;
|
|
41
47
|
};
|
|
42
48
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useWallet(): import("../..").UserWallet | null;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
File without changes
|