@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.
@@ -11,3 +11,4 @@ export { useOAuth } from './useOAuth';
11
11
  export { useWalletAuth } from './useWalletAuth';
12
12
  // Guest accounts
13
13
  export { useGuestAuth } from './useGuestAuth';
14
+ export { useSignOut } from './useSignOut';
@@ -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
- // ...mapStatus(passwordState),
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 link = useCallback(async (options) => {
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
- link,
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 linkWithSiwe = useCallback(async (opts) => {
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
- linkWithSiwe,
120
- state: siweState,
130
+ linkSiwe,
131
+ ...mapStatus(siweState),
121
132
  };
122
133
  }
@@ -7,4 +7,3 @@
7
7
  export { useOpenfort } from './useOpenfort';
8
8
  export { useOpenfortClient } from './useOpenfortClient';
9
9
  export { useUser } from './useUser';
10
- export { useSignOut } from './useSignOut';
@@ -5,3 +5,4 @@
5
5
  */
6
6
  // Embedded wallet hooks
7
7
  export { useWallets } from './useWallets';
8
+ export { useWallet } from './useWallet';
@@ -0,0 +1,5 @@
1
+ import { useWallets } from "./useWallets";
2
+ export function useWallet() {
3
+ const { activeWallet } = useWallets();
4
+ return activeWallet;
5
+ }
@@ -7,3 +7,4 @@ export { useEmailAuth } from './useEmailAuth';
7
7
  export { useOAuth } from './useOAuth';
8
8
  export { useWalletAuth } from './useWalletAuth';
9
9
  export { useGuestAuth } from './useGuestAuth';
10
+ export { useSignOut } from './useSignOut';
@@ -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
- link: (options: InitializeOAuthOptions) => Promise<InitOAuthReturnType>;
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
- linkWithSiwe: (opts: LinkSiweOptions) => Promise<WalletHookResult>;
40
- state: import("../..").SiweFlowState;
46
+ linkSiwe: (opts: LinkSiweOptions) => Promise<WalletHookResult>;
41
47
  };
42
48
  export {};
@@ -6,4 +6,3 @@
6
6
  export { useOpenfort } from './useOpenfort';
7
7
  export { useOpenfortClient } from './useOpenfortClient';
8
8
  export { useUser } from './useUser';
9
- export { useSignOut } from './useSignOut';
@@ -4,3 +4,4 @@
4
4
  * This module re-exports all wallet-related hooks for convenient importing.
5
5
  */
6
6
  export { useWallets } from './useWallets';
7
+ export { useWallet } from './useWallet';
@@ -0,0 +1 @@
1
+ export declare function useWallet(): import("../..").UserWallet | null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openfort/react-native",
3
3
  "main": "dist/index.js",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "license": "MIT",
6
6
  "description": "React Native SDK for Openfort platform integration",
7
7
  "scripts": {
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,7 +0,0 @@
1
- import { useOpenfortContext } from "../../core";
2
- export function useSignOut() {
3
- const { logout } = useOpenfortContext();
4
- return {
5
- signOut: logout,
6
- };
7
- }
File without changes
@@ -1,3 +0,0 @@
1
- export declare function useSignOut(): {
2
- signOut: () => Promise<void>;
3
- };