@fonderie/react-native-auth 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fonderie, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # @fonderie/react-native-auth
2
+
3
+ React Native hooks for Fonderie auth — `useLogin`, `useRegister`,
4
+ `useSession`, `useLogout`, `useForgotPassword`, `useResetPassword`, and
5
+ `useVerifyEmail`. Same shape as
6
+ [`@fonderie/react-auth`](https://github.com/fonderie-js/sdk/tree/main/packages/react-auth),
7
+ with the access token persisted to `AsyncStorage` instead of `localStorage`.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install @fonderie/react-native-auth @react-native-async-storage/async-storage
13
+ ```
14
+
15
+ ## Use
16
+
17
+ ```tsx
18
+ import { FonderieClient } from '@fonderie/client';
19
+ import { useLogin, useSession } from '@fonderie/react-native-auth';
20
+
21
+ const client = new FonderieClient({ baseUrl: 'https://api.example.com/v1' });
22
+
23
+ function LoginScreen() {
24
+ const { login, isLoading, error } = useLogin(client.auth);
25
+
26
+ return (
27
+ <TouchableOpacity disabled={isLoading} onPress={() => login({ email, password })}>
28
+ <Text>{isLoading ? 'Signing in…' : 'Sign in'}</Text>
29
+ </TouchableOpacity>
30
+ );
31
+ }
32
+
33
+ function Profile() {
34
+ const { user, isAuthenticated, logout } = useSession(client.auth);
35
+ if (!isAuthenticated) return null;
36
+ return <TouchableOpacity onPress={logout}><Text>Log out {user?.email}</Text></TouchableOpacity>;
37
+ }
38
+ ```
39
+
40
+ Each hook takes the same `AuthClient` instance (`client.auth`) — construct one
41
+ `FonderieClient` at the app root and pass it down (React context or a prop).
42
+ The access token is persisted to `AsyncStorage` and restored automatically by
43
+ `useSession` on mount; don't re-implement that in app code.
44
+
45
+ Want pre-built screens instead of wiring your own form?
46
+ See [`@fonderie/react-native-auth-screens`](https://github.com/fonderie-js/sdk/tree/main/packages/react-native-auth-screens).
47
+
48
+ ## Why this exists
49
+
50
+ You've shipped this plumbing before — auth, teams, billing, messaging —
51
+ and the next project will ask for it again. Fonderie packages it once:
52
+ plain TypeScript modules for
53
+ [`@fonderie/core`](https://github.com/fonderie-js/sdk/tree/main/packages/core),
54
+ PostgreSQL-backed, self-hosted, MIT. No external control plane, no
55
+ per-seat anything. Register the modules you need; skip the ones you don't.
56
+
57
+ **This package owns** the React Native binding for auth — state management
58
+ around `@fonderie/client`, nothing more. No business logic lives here; it
59
+ lives in `@fonderie/auth` on the server.
60
+
61
+ Browse the whole set at
62
+ [fonderie-js/sdk](https://github.com/fonderie-js/sdk) · follow
63
+ [@fonderiejs](https://x.com/fonderiejs)
64
+
65
+ ## License
66
+
67
+ MIT © Fonderie, Inc.
package/dist/index.cjs ADDED
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ FonderieApiError: () => import_client7.FonderieApiError,
34
+ useForgotPassword: () => useForgotPassword,
35
+ useLogin: () => useLogin,
36
+ useLogout: () => useLogout,
37
+ useRegister: () => useRegister,
38
+ useResetPassword: () => useResetPassword,
39
+ useSession: () => useSession,
40
+ useVerifyEmail: () => useVerifyEmail
41
+ });
42
+ module.exports = __toCommonJS(index_exports);
43
+ var import_client7 = require("@fonderie/client");
44
+
45
+ // src/hooks/useForgotPassword.ts
46
+ var import_client = require("@fonderie/client");
47
+ var import_react = require("react");
48
+ function useForgotPassword(client) {
49
+ const [isLoading, setIsLoading] = (0, import_react.useState)(false);
50
+ const [error, setError] = (0, import_react.useState)(null);
51
+ const [sent, setSent] = (0, import_react.useState)(false);
52
+ const forgotPassword = (0, import_react.useCallback)(
53
+ async (email) => {
54
+ setIsLoading(true);
55
+ setError(null);
56
+ try {
57
+ await client.forgotPassword(email);
58
+ setSent(true);
59
+ } catch (err) {
60
+ const apiError = err instanceof import_client.FonderieApiError ? err : new import_client.FonderieApiError("unknown", String(err), 0);
61
+ setError(apiError);
62
+ throw apiError;
63
+ } finally {
64
+ setIsLoading(false);
65
+ }
66
+ },
67
+ [client]
68
+ );
69
+ return { forgotPassword, isLoading, error, sent };
70
+ }
71
+
72
+ // src/hooks/useLogin.ts
73
+ var import_client2 = require("@fonderie/client");
74
+ var import_react2 = require("react");
75
+
76
+ // src/storage.ts
77
+ var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"), 1);
78
+ var TOKEN_KEY = "fonderie_access_token";
79
+ function persistToken(token) {
80
+ return import_async_storage.default.setItem(TOKEN_KEY, token);
81
+ }
82
+ function clearToken() {
83
+ return import_async_storage.default.removeItem(TOKEN_KEY);
84
+ }
85
+ function readToken() {
86
+ return import_async_storage.default.getItem(TOKEN_KEY);
87
+ }
88
+
89
+ // src/hooks/useLogin.ts
90
+ function useLogin(client) {
91
+ const [isLoading, setIsLoading] = (0, import_react2.useState)(false);
92
+ const [error, setError] = (0, import_react2.useState)(null);
93
+ const [data, setData] = (0, import_react2.useState)(null);
94
+ const login = (0, import_react2.useCallback)(
95
+ async (input) => {
96
+ setIsLoading(true);
97
+ setError(null);
98
+ try {
99
+ const { result } = await client.login(input);
100
+ client.setAccessToken(result.tokens.access);
101
+ await persistToken(result.tokens.access);
102
+ setData(result);
103
+ return result;
104
+ } catch (err) {
105
+ const apiError = err instanceof import_client2.FonderieApiError ? err : new import_client2.FonderieApiError("unknown", String(err), 0);
106
+ setError(apiError);
107
+ throw apiError;
108
+ } finally {
109
+ setIsLoading(false);
110
+ }
111
+ },
112
+ [client]
113
+ );
114
+ return { login, isLoading, error, data };
115
+ }
116
+
117
+ // src/hooks/useLogout.ts
118
+ var import_client3 = require("@fonderie/client");
119
+ var import_react3 = require("react");
120
+ function useLogout(client) {
121
+ const [isLoading, setIsLoading] = (0, import_react3.useState)(false);
122
+ const [error, setError] = (0, import_react3.useState)(null);
123
+ const logout = (0, import_react3.useCallback)(async () => {
124
+ setIsLoading(true);
125
+ setError(null);
126
+ try {
127
+ await client.logout();
128
+ } catch (err) {
129
+ const apiError = err instanceof import_client3.FonderieApiError ? err : new import_client3.FonderieApiError("unknown", String(err), 0);
130
+ setError(apiError);
131
+ } finally {
132
+ client.setAccessToken(void 0);
133
+ await clearToken();
134
+ setIsLoading(false);
135
+ }
136
+ }, [client]);
137
+ return { logout, isLoading, error };
138
+ }
139
+
140
+ // src/hooks/useRegister.ts
141
+ var import_client4 = require("@fonderie/client");
142
+ var import_react4 = require("react");
143
+ function useRegister(client) {
144
+ const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
145
+ const [error, setError] = (0, import_react4.useState)(null);
146
+ const [data, setData] = (0, import_react4.useState)(null);
147
+ const register = (0, import_react4.useCallback)(
148
+ async (input) => {
149
+ setIsLoading(true);
150
+ setError(null);
151
+ try {
152
+ const { result } = await client.register(input);
153
+ client.setAccessToken(result.tokens.access);
154
+ await persistToken(result.tokens.access);
155
+ setData(result);
156
+ return result;
157
+ } catch (err) {
158
+ const apiError = err instanceof import_client4.FonderieApiError ? err : new import_client4.FonderieApiError("unknown", String(err), 0);
159
+ setError(apiError);
160
+ throw apiError;
161
+ } finally {
162
+ setIsLoading(false);
163
+ }
164
+ },
165
+ [client]
166
+ );
167
+ return { register, isLoading, error, data };
168
+ }
169
+
170
+ // src/hooks/useResetPassword.ts
171
+ var import_client5 = require("@fonderie/client");
172
+ var import_react5 = require("react");
173
+ function useResetPassword(client) {
174
+ const [isLoading, setIsLoading] = (0, import_react5.useState)(false);
175
+ const [error, setError] = (0, import_react5.useState)(null);
176
+ const [done, setDone] = (0, import_react5.useState)(false);
177
+ const resetPassword = (0, import_react5.useCallback)(
178
+ async (input) => {
179
+ setIsLoading(true);
180
+ setError(null);
181
+ try {
182
+ await client.resetPassword(input);
183
+ setDone(true);
184
+ } catch (err) {
185
+ const apiError = err instanceof import_client5.FonderieApiError ? err : new import_client5.FonderieApiError("unknown", String(err), 0);
186
+ setError(apiError);
187
+ throw apiError;
188
+ } finally {
189
+ setIsLoading(false);
190
+ }
191
+ },
192
+ [client]
193
+ );
194
+ return { resetPassword, isLoading, error, done };
195
+ }
196
+
197
+ // src/hooks/useSession.ts
198
+ var import_react6 = require("react");
199
+ function useSession(client) {
200
+ const [user, setUser] = (0, import_react6.useState)(null);
201
+ const [isLoading, setIsLoading] = (0, import_react6.useState)(true);
202
+ const [isAuthenticated, setIsAuthenticated] = (0, import_react6.useState)(false);
203
+ const refresh = (0, import_react6.useCallback)(async () => {
204
+ setIsLoading(true);
205
+ try {
206
+ const { result } = await client.getUser();
207
+ setUser(result.user);
208
+ setIsAuthenticated(true);
209
+ } catch {
210
+ setUser(null);
211
+ setIsAuthenticated(false);
212
+ client.setAccessToken(void 0);
213
+ await clearToken();
214
+ } finally {
215
+ setIsLoading(false);
216
+ }
217
+ }, [client]);
218
+ const logout = (0, import_react6.useCallback)(async () => {
219
+ try {
220
+ await client.logout();
221
+ } catch {
222
+ }
223
+ client.setAccessToken(void 0);
224
+ await clearToken();
225
+ setUser(null);
226
+ setIsAuthenticated(false);
227
+ }, [client]);
228
+ (0, import_react6.useEffect)(() => {
229
+ readToken().then((token) => {
230
+ if (token) client.setAccessToken(token);
231
+ void refresh();
232
+ });
233
+ }, [client, refresh]);
234
+ return { user, isLoading, isAuthenticated, refresh, logout };
235
+ }
236
+
237
+ // src/hooks/useVerifyEmail.ts
238
+ var import_client6 = require("@fonderie/client");
239
+ var import_react7 = require("react");
240
+ function useVerifyEmail(client) {
241
+ const [isLoading, setIsLoading] = (0, import_react7.useState)(false);
242
+ const [error, setError] = (0, import_react7.useState)(null);
243
+ const [data, setData] = (0, import_react7.useState)(null);
244
+ const verifyEmail = (0, import_react7.useCallback)(
245
+ async (pin) => {
246
+ setIsLoading(true);
247
+ setError(null);
248
+ try {
249
+ const { result } = await client.verifyEmail(pin);
250
+ setData(result);
251
+ return result;
252
+ } catch (err) {
253
+ const apiError = err instanceof import_client6.FonderieApiError ? err : new import_client6.FonderieApiError("unknown", String(err), 0);
254
+ setError(apiError);
255
+ throw apiError;
256
+ } finally {
257
+ setIsLoading(false);
258
+ }
259
+ },
260
+ [client]
261
+ );
262
+ return { verifyEmail, isLoading, error, data };
263
+ }
264
+ // Annotate the CommonJS export names for ESM import in node:
265
+ 0 && (module.exports = {
266
+ FonderieApiError,
267
+ useForgotPassword,
268
+ useLogin,
269
+ useLogout,
270
+ useRegister,
271
+ useResetPassword,
272
+ useSession,
273
+ useVerifyEmail
274
+ });
275
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/hooks/useForgotPassword.ts","../src/hooks/useLogin.ts","../src/storage.ts","../src/hooks/useLogout.ts","../src/hooks/useRegister.ts","../src/hooks/useResetPassword.ts","../src/hooks/useSession.ts","../src/hooks/useVerifyEmail.ts"],"sourcesContent":["export type {\n\tAuthClient,\n\tILoginInput,\n\tILoginResult,\n\tIRegisterInput,\n\tIRegisterResult,\n\tIResetPasswordInput,\n\tITokens,\n\tIUserDTO,\n\tIVerifyEmailResult,\n} from '@fonderie/client';\n\nexport { FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseForgotPasswordReturn,\n\tIUseLoginReturn,\n\tIUseLogoutReturn,\n\tIUseRegisterReturn,\n\tIUseResetPasswordReturn,\n\tIUseSessionReturn,\n\tIUseVerifyEmailReturn,\n} from './hooks';\nexport {\n\tuseForgotPassword,\n\tuseLogin,\n\tuseLogout,\n\tuseRegister,\n\tuseResetPassword,\n\tuseSession,\n\tuseVerifyEmail,\n} from './hooks';\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseForgotPasswordReturn {\n\tforgotPassword: (email: string) => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\tsent: boolean;\n}\n\nexport function useForgotPassword(client: AuthClient): IUseForgotPasswordReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\tconst [sent, setSent] = useState(false);\n\n\tconst forgotPassword = useCallback(\n\t\tasync (email: string) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait client.forgotPassword(email);\n\t\t\t\tsetSent(true);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\treturn { forgotPassword, isLoading, error, sent };\n}\n","import type { AuthClient, ILoginInput, ILoginResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\nimport { persistToken } from '../storage';\n\nexport interface IUseLoginReturn {\n\tlogin: (input: ILoginInput) => Promise<ILoginResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\tdata: ILoginResult | null;\n}\n\nexport function useLogin(client: AuthClient): IUseLoginReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\tconst [data, setData] = useState<ILoginResult | null>(null);\n\n\tconst login = useCallback(\n\t\tasync (input: ILoginInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.login(input);\n\t\t\t\tclient.setAccessToken(result.tokens.access);\n\t\t\t\tawait persistToken(result.tokens.access);\n\t\t\t\tsetData(result);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\treturn { login, isLoading, error, data };\n}\n","import AsyncStorage from '@react-native-async-storage/async-storage';\n\nexport const TOKEN_KEY = 'fonderie_access_token';\n\nexport function persistToken(token: string) {\n\treturn AsyncStorage.setItem(TOKEN_KEY, token);\n}\n\nexport function clearToken() {\n\treturn AsyncStorage.removeItem(TOKEN_KEY);\n}\n\nexport function readToken() {\n\treturn AsyncStorage.getItem(TOKEN_KEY);\n}\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\nimport { clearToken } from '../storage';\n\nexport interface IUseLogoutReturn {\n\tlogout: () => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useLogout(client: AuthClient): IUseLogoutReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst logout = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tawait client.logout();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t} finally {\n\t\t\tclient.setAccessToken(undefined);\n\t\t\tawait clearToken();\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client]);\n\n\treturn { logout, isLoading, error };\n}\n","import type { AuthClient, IRegisterInput, IRegisterResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\nimport { persistToken } from '../storage';\n\nexport interface IUseRegisterReturn {\n\tregister: (input: IRegisterInput) => Promise<IRegisterResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\tdata: IRegisterResult | null;\n}\n\nexport function useRegister(client: AuthClient): IUseRegisterReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\tconst [data, setData] = useState<IRegisterResult | null>(null);\n\n\tconst register = useCallback(\n\t\tasync (input: IRegisterInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.register(input);\n\t\t\t\tclient.setAccessToken(result.tokens.access);\n\t\t\t\tawait persistToken(result.tokens.access);\n\t\t\t\tsetData(result);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\treturn { register, isLoading, error, data };\n}\n","import type { AuthClient, IResetPasswordInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseResetPasswordReturn {\n\tresetPassword: (input: IResetPasswordInput) => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\tdone: boolean;\n}\n\nexport function useResetPassword(client: AuthClient): IUseResetPasswordReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\tconst [done, setDone] = useState(false);\n\n\tconst resetPassword = useCallback(\n\t\tasync (input: IResetPasswordInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait client.resetPassword(input);\n\t\t\t\tsetDone(true);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\treturn { resetPassword, isLoading, error, done };\n}\n","import type { AuthClient, IUserDTO } from '@fonderie/client';\nimport { useCallback, useEffect, useState } from 'react';\nimport { clearToken, readToken } from '../storage';\n\nexport interface IUseSessionReturn {\n\tuser: IUserDTO | null;\n\tisLoading: boolean;\n\tisAuthenticated: boolean;\n\trefresh: () => Promise<void>;\n\tlogout: () => Promise<void>;\n}\n\nexport function useSession(client: AuthClient): IUseSessionReturn {\n\tconst [user, setUser] = useState<IUserDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [isAuthenticated, setIsAuthenticated] = useState(false);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\ttry {\n\t\t\tconst { result } = await client.getUser();\n\t\t\tsetUser(result.user);\n\t\t\tsetIsAuthenticated(true);\n\t\t} catch {\n\t\t\tsetUser(null);\n\t\t\tsetIsAuthenticated(false);\n\t\t\tclient.setAccessToken(undefined);\n\t\t\tawait clearToken();\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client]);\n\n\tconst logout = useCallback(async () => {\n\t\ttry {\n\t\t\tawait client.logout();\n\t\t} catch {\n\t\t\t// Session is being torn down regardless of server response.\n\t\t}\n\t\tclient.setAccessToken(undefined);\n\t\tawait clearToken();\n\t\tsetUser(null);\n\t\tsetIsAuthenticated(false);\n\t}, [client]);\n\n\tuseEffect(() => {\n\t\treadToken().then((token) => {\n\t\t\tif (token) client.setAccessToken(token);\n\t\t\tvoid refresh();\n\t\t});\n\t}, [client, refresh]);\n\n\treturn { user, isLoading, isAuthenticated, refresh, logout };\n}\n","import type { AuthClient, IVerifyEmailResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseVerifyEmailReturn {\n\tverifyEmail: (pin: string) => Promise<IVerifyEmailResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\tdata: IVerifyEmailResult | null;\n}\n\nexport function useVerifyEmail(client: AuthClient): IUseVerifyEmailReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\tconst [data, setData] = useState<IVerifyEmailResult | null>(null);\n\n\tconst verifyEmail = useCallback(\n\t\tasync (pin: string) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.verifyEmail(pin);\n\t\t\t\tsetData(result);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\treturn { verifyEmail, isLoading, error, data };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,IAAAA,iBAAiC;;;ACXjC,oBAAiC;AACjC,mBAAsC;AAS/B,SAAS,kBAAkB,QAA8C;AAC/E,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAkC,IAAI;AAChE,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AAEtC,QAAM,qBAAiB;AAAA,IACtB,OAAO,UAAkB;AACxB,mBAAa,IAAI;AACjB,eAAS,IAAI;AACb,UAAI;AACH,cAAM,OAAO,eAAe,KAAK;AACjC,gBAAQ,IAAI;AAAA,MACb,SAAS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yncStorage","import_client","import_react","import_client","import_react","import_client","import_react","import_react","import_client","import_react"]}
@@ -0,0 +1,60 @@
1
+ import { FonderieApiError, AuthClient, ILoginInput, ILoginResult, IRegisterInput, IRegisterResult, IResetPasswordInput, IUserDTO, IVerifyEmailResult } from '@fonderie/client';
2
+ export { AuthClient, FonderieApiError, ILoginInput, ILoginResult, IRegisterInput, IRegisterResult, IResetPasswordInput, ITokens, IUserDTO, IVerifyEmailResult } from '@fonderie/client';
3
+
4
+ interface IUseForgotPasswordReturn {
5
+ forgotPassword: (email: string) => Promise<void>;
6
+ isLoading: boolean;
7
+ error: FonderieApiError | null;
8
+ sent: boolean;
9
+ }
10
+ declare function useForgotPassword(client: AuthClient): IUseForgotPasswordReturn;
11
+
12
+ interface IUseLoginReturn {
13
+ login: (input: ILoginInput) => Promise<ILoginResult>;
14
+ isLoading: boolean;
15
+ error: FonderieApiError | null;
16
+ data: ILoginResult | null;
17
+ }
18
+ declare function useLogin(client: AuthClient): IUseLoginReturn;
19
+
20
+ interface IUseLogoutReturn {
21
+ logout: () => Promise<void>;
22
+ isLoading: boolean;
23
+ error: FonderieApiError | null;
24
+ }
25
+ declare function useLogout(client: AuthClient): IUseLogoutReturn;
26
+
27
+ interface IUseRegisterReturn {
28
+ register: (input: IRegisterInput) => Promise<IRegisterResult>;
29
+ isLoading: boolean;
30
+ error: FonderieApiError | null;
31
+ data: IRegisterResult | null;
32
+ }
33
+ declare function useRegister(client: AuthClient): IUseRegisterReturn;
34
+
35
+ interface IUseResetPasswordReturn {
36
+ resetPassword: (input: IResetPasswordInput) => Promise<void>;
37
+ isLoading: boolean;
38
+ error: FonderieApiError | null;
39
+ done: boolean;
40
+ }
41
+ declare function useResetPassword(client: AuthClient): IUseResetPasswordReturn;
42
+
43
+ interface IUseSessionReturn {
44
+ user: IUserDTO | null;
45
+ isLoading: boolean;
46
+ isAuthenticated: boolean;
47
+ refresh: () => Promise<void>;
48
+ logout: () => Promise<void>;
49
+ }
50
+ declare function useSession(client: AuthClient): IUseSessionReturn;
51
+
52
+ interface IUseVerifyEmailReturn {
53
+ verifyEmail: (pin: string) => Promise<IVerifyEmailResult>;
54
+ isLoading: boolean;
55
+ error: FonderieApiError | null;
56
+ data: IVerifyEmailResult | null;
57
+ }
58
+ declare function useVerifyEmail(client: AuthClient): IUseVerifyEmailReturn;
59
+
60
+ export { type IUseForgotPasswordReturn, type IUseLoginReturn, type IUseLogoutReturn, type IUseRegisterReturn, type IUseResetPasswordReturn, type IUseSessionReturn, type IUseVerifyEmailReturn, useForgotPassword, useLogin, useLogout, useRegister, useResetPassword, useSession, useVerifyEmail };
@@ -0,0 +1,60 @@
1
+ import { FonderieApiError, AuthClient, ILoginInput, ILoginResult, IRegisterInput, IRegisterResult, IResetPasswordInput, IUserDTO, IVerifyEmailResult } from '@fonderie/client';
2
+ export { AuthClient, FonderieApiError, ILoginInput, ILoginResult, IRegisterInput, IRegisterResult, IResetPasswordInput, ITokens, IUserDTO, IVerifyEmailResult } from '@fonderie/client';
3
+
4
+ interface IUseForgotPasswordReturn {
5
+ forgotPassword: (email: string) => Promise<void>;
6
+ isLoading: boolean;
7
+ error: FonderieApiError | null;
8
+ sent: boolean;
9
+ }
10
+ declare function useForgotPassword(client: AuthClient): IUseForgotPasswordReturn;
11
+
12
+ interface IUseLoginReturn {
13
+ login: (input: ILoginInput) => Promise<ILoginResult>;
14
+ isLoading: boolean;
15
+ error: FonderieApiError | null;
16
+ data: ILoginResult | null;
17
+ }
18
+ declare function useLogin(client: AuthClient): IUseLoginReturn;
19
+
20
+ interface IUseLogoutReturn {
21
+ logout: () => Promise<void>;
22
+ isLoading: boolean;
23
+ error: FonderieApiError | null;
24
+ }
25
+ declare function useLogout(client: AuthClient): IUseLogoutReturn;
26
+
27
+ interface IUseRegisterReturn {
28
+ register: (input: IRegisterInput) => Promise<IRegisterResult>;
29
+ isLoading: boolean;
30
+ error: FonderieApiError | null;
31
+ data: IRegisterResult | null;
32
+ }
33
+ declare function useRegister(client: AuthClient): IUseRegisterReturn;
34
+
35
+ interface IUseResetPasswordReturn {
36
+ resetPassword: (input: IResetPasswordInput) => Promise<void>;
37
+ isLoading: boolean;
38
+ error: FonderieApiError | null;
39
+ done: boolean;
40
+ }
41
+ declare function useResetPassword(client: AuthClient): IUseResetPasswordReturn;
42
+
43
+ interface IUseSessionReturn {
44
+ user: IUserDTO | null;
45
+ isLoading: boolean;
46
+ isAuthenticated: boolean;
47
+ refresh: () => Promise<void>;
48
+ logout: () => Promise<void>;
49
+ }
50
+ declare function useSession(client: AuthClient): IUseSessionReturn;
51
+
52
+ interface IUseVerifyEmailReturn {
53
+ verifyEmail: (pin: string) => Promise<IVerifyEmailResult>;
54
+ isLoading: boolean;
55
+ error: FonderieApiError | null;
56
+ data: IVerifyEmailResult | null;
57
+ }
58
+ declare function useVerifyEmail(client: AuthClient): IUseVerifyEmailReturn;
59
+
60
+ export { type IUseForgotPasswordReturn, type IUseLoginReturn, type IUseLogoutReturn, type IUseRegisterReturn, type IUseResetPasswordReturn, type IUseSessionReturn, type IUseVerifyEmailReturn, useForgotPassword, useLogin, useLogout, useRegister, useResetPassword, useSession, useVerifyEmail };
package/dist/index.js ADDED
@@ -0,0 +1,233 @@
1
+ // src/index.ts
2
+ import { FonderieApiError as FonderieApiError7 } from "@fonderie/client";
3
+
4
+ // src/hooks/useForgotPassword.ts
5
+ import { FonderieApiError } from "@fonderie/client";
6
+ import { useCallback, useState } from "react";
7
+ function useForgotPassword(client) {
8
+ const [isLoading, setIsLoading] = useState(false);
9
+ const [error, setError] = useState(null);
10
+ const [sent, setSent] = useState(false);
11
+ const forgotPassword = useCallback(
12
+ async (email) => {
13
+ setIsLoading(true);
14
+ setError(null);
15
+ try {
16
+ await client.forgotPassword(email);
17
+ setSent(true);
18
+ } catch (err) {
19
+ const apiError = err instanceof FonderieApiError ? err : new FonderieApiError("unknown", String(err), 0);
20
+ setError(apiError);
21
+ throw apiError;
22
+ } finally {
23
+ setIsLoading(false);
24
+ }
25
+ },
26
+ [client]
27
+ );
28
+ return { forgotPassword, isLoading, error, sent };
29
+ }
30
+
31
+ // src/hooks/useLogin.ts
32
+ import { FonderieApiError as FonderieApiError2 } from "@fonderie/client";
33
+ import { useCallback as useCallback2, useState as useState2 } from "react";
34
+
35
+ // src/storage.ts
36
+ import AsyncStorage from "@react-native-async-storage/async-storage";
37
+ var TOKEN_KEY = "fonderie_access_token";
38
+ function persistToken(token) {
39
+ return AsyncStorage.setItem(TOKEN_KEY, token);
40
+ }
41
+ function clearToken() {
42
+ return AsyncStorage.removeItem(TOKEN_KEY);
43
+ }
44
+ function readToken() {
45
+ return AsyncStorage.getItem(TOKEN_KEY);
46
+ }
47
+
48
+ // src/hooks/useLogin.ts
49
+ function useLogin(client) {
50
+ const [isLoading, setIsLoading] = useState2(false);
51
+ const [error, setError] = useState2(null);
52
+ const [data, setData] = useState2(null);
53
+ const login = useCallback2(
54
+ async (input) => {
55
+ setIsLoading(true);
56
+ setError(null);
57
+ try {
58
+ const { result } = await client.login(input);
59
+ client.setAccessToken(result.tokens.access);
60
+ await persistToken(result.tokens.access);
61
+ setData(result);
62
+ return result;
63
+ } catch (err) {
64
+ const apiError = err instanceof FonderieApiError2 ? err : new FonderieApiError2("unknown", String(err), 0);
65
+ setError(apiError);
66
+ throw apiError;
67
+ } finally {
68
+ setIsLoading(false);
69
+ }
70
+ },
71
+ [client]
72
+ );
73
+ return { login, isLoading, error, data };
74
+ }
75
+
76
+ // src/hooks/useLogout.ts
77
+ import { FonderieApiError as FonderieApiError3 } from "@fonderie/client";
78
+ import { useCallback as useCallback3, useState as useState3 } from "react";
79
+ function useLogout(client) {
80
+ const [isLoading, setIsLoading] = useState3(false);
81
+ const [error, setError] = useState3(null);
82
+ const logout = useCallback3(async () => {
83
+ setIsLoading(true);
84
+ setError(null);
85
+ try {
86
+ await client.logout();
87
+ } catch (err) {
88
+ const apiError = err instanceof FonderieApiError3 ? err : new FonderieApiError3("unknown", String(err), 0);
89
+ setError(apiError);
90
+ } finally {
91
+ client.setAccessToken(void 0);
92
+ await clearToken();
93
+ setIsLoading(false);
94
+ }
95
+ }, [client]);
96
+ return { logout, isLoading, error };
97
+ }
98
+
99
+ // src/hooks/useRegister.ts
100
+ import { FonderieApiError as FonderieApiError4 } from "@fonderie/client";
101
+ import { useCallback as useCallback4, useState as useState4 } from "react";
102
+ function useRegister(client) {
103
+ const [isLoading, setIsLoading] = useState4(false);
104
+ const [error, setError] = useState4(null);
105
+ const [data, setData] = useState4(null);
106
+ const register = useCallback4(
107
+ async (input) => {
108
+ setIsLoading(true);
109
+ setError(null);
110
+ try {
111
+ const { result } = await client.register(input);
112
+ client.setAccessToken(result.tokens.access);
113
+ await persistToken(result.tokens.access);
114
+ setData(result);
115
+ return result;
116
+ } catch (err) {
117
+ const apiError = err instanceof FonderieApiError4 ? err : new FonderieApiError4("unknown", String(err), 0);
118
+ setError(apiError);
119
+ throw apiError;
120
+ } finally {
121
+ setIsLoading(false);
122
+ }
123
+ },
124
+ [client]
125
+ );
126
+ return { register, isLoading, error, data };
127
+ }
128
+
129
+ // src/hooks/useResetPassword.ts
130
+ import { FonderieApiError as FonderieApiError5 } from "@fonderie/client";
131
+ import { useCallback as useCallback5, useState as useState5 } from "react";
132
+ function useResetPassword(client) {
133
+ const [isLoading, setIsLoading] = useState5(false);
134
+ const [error, setError] = useState5(null);
135
+ const [done, setDone] = useState5(false);
136
+ const resetPassword = useCallback5(
137
+ async (input) => {
138
+ setIsLoading(true);
139
+ setError(null);
140
+ try {
141
+ await client.resetPassword(input);
142
+ setDone(true);
143
+ } catch (err) {
144
+ const apiError = err instanceof FonderieApiError5 ? err : new FonderieApiError5("unknown", String(err), 0);
145
+ setError(apiError);
146
+ throw apiError;
147
+ } finally {
148
+ setIsLoading(false);
149
+ }
150
+ },
151
+ [client]
152
+ );
153
+ return { resetPassword, isLoading, error, done };
154
+ }
155
+
156
+ // src/hooks/useSession.ts
157
+ import { useCallback as useCallback6, useEffect, useState as useState6 } from "react";
158
+ function useSession(client) {
159
+ const [user, setUser] = useState6(null);
160
+ const [isLoading, setIsLoading] = useState6(true);
161
+ const [isAuthenticated, setIsAuthenticated] = useState6(false);
162
+ const refresh = useCallback6(async () => {
163
+ setIsLoading(true);
164
+ try {
165
+ const { result } = await client.getUser();
166
+ setUser(result.user);
167
+ setIsAuthenticated(true);
168
+ } catch {
169
+ setUser(null);
170
+ setIsAuthenticated(false);
171
+ client.setAccessToken(void 0);
172
+ await clearToken();
173
+ } finally {
174
+ setIsLoading(false);
175
+ }
176
+ }, [client]);
177
+ const logout = useCallback6(async () => {
178
+ try {
179
+ await client.logout();
180
+ } catch {
181
+ }
182
+ client.setAccessToken(void 0);
183
+ await clearToken();
184
+ setUser(null);
185
+ setIsAuthenticated(false);
186
+ }, [client]);
187
+ useEffect(() => {
188
+ readToken().then((token) => {
189
+ if (token) client.setAccessToken(token);
190
+ void refresh();
191
+ });
192
+ }, [client, refresh]);
193
+ return { user, isLoading, isAuthenticated, refresh, logout };
194
+ }
195
+
196
+ // src/hooks/useVerifyEmail.ts
197
+ import { FonderieApiError as FonderieApiError6 } from "@fonderie/client";
198
+ import { useCallback as useCallback7, useState as useState7 } from "react";
199
+ function useVerifyEmail(client) {
200
+ const [isLoading, setIsLoading] = useState7(false);
201
+ const [error, setError] = useState7(null);
202
+ const [data, setData] = useState7(null);
203
+ const verifyEmail = useCallback7(
204
+ async (pin) => {
205
+ setIsLoading(true);
206
+ setError(null);
207
+ try {
208
+ const { result } = await client.verifyEmail(pin);
209
+ setData(result);
210
+ return result;
211
+ } catch (err) {
212
+ const apiError = err instanceof FonderieApiError6 ? err : new FonderieApiError6("unknown", String(err), 0);
213
+ setError(apiError);
214
+ throw apiError;
215
+ } finally {
216
+ setIsLoading(false);
217
+ }
218
+ },
219
+ [client]
220
+ );
221
+ return { verifyEmail, isLoading, error, data };
222
+ }
223
+ export {
224
+ FonderieApiError7 as FonderieApiError,
225
+ useForgotPassword,
226
+ useLogin,
227
+ useLogout,
228
+ useRegister,
229
+ useResetPassword,
230
+ useSession,
231
+ useVerifyEmail
232
+ };
233
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/hooks/useForgotPassword.ts","../src/hooks/useLogin.ts","../src/storage.ts","../src/hooks/useLogout.ts","../src/hooks/useRegister.ts","../src/hooks/useResetPassword.ts","../src/hooks/useSession.ts","../src/hooks/useVerifyEmail.ts"],"sourcesContent":["export type {\n\tAuthClient,\n\tILoginInput,\n\tILoginResult,\n\tIRegisterInput,\n\tIRegisterResult,\n\tIResetPasswordInput,\n\tITokens,\n\tIUserDTO,\n\tIVerifyEmailResult,\n} from '@fonderie/client';\n\nexport { FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseForgotPasswordReturn,\n\tIUseLoginReturn,\n\tIUseLogoutReturn,\n\tIUseRegisterReturn,\n\tIUseResetPasswordReturn,\n\tIUseSessionReturn,\n\tIUseVerifyEmailReturn,\n} from './hooks';\nexport {\n\tuseForgotPassword,\n\tuseLogin,\n\tuseLogout,\n\tuseRegister,\n\tuseResetPassword,\n\tuseSession,\n\tuseVerifyEmail,\n} from './hooks';\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseForgotPasswordReturn {\n\tforgotPassword: (email: string) => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\tsent: boolean;\n}\n\nexport function useForgotPassword(client: AuthClient): IUseForgotPasswordReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\tconst [sent, setSent] = useState(false);\n\n\tconst forgotPassword = useCallback(\n\t\tasync (email: string) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait client.forgotPassword(email);\n\t\t\t\tsetSent(true);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\treturn { forgotPassword, isLoading, error, sent };\n}\n","import type { AuthClient, ILoginInput, ILoginResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\nimport { persistToken } from '../storage';\n\nexport interface IUseLoginReturn {\n\tlogin: (input: ILoginInput) => Promise<ILoginResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\tdata: ILoginResult | null;\n}\n\nexport function useLogin(client: AuthClient): IUseLoginReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\tconst [data, setData] = useState<ILoginResult | null>(null);\n\n\tconst login = useCallback(\n\t\tasync (input: ILoginInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.login(input);\n\t\t\t\tclient.setAccessToken(result.tokens.access);\n\t\t\t\tawait persistToken(result.tokens.access);\n\t\t\t\tsetData(result);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\treturn { login, isLoading, error, data };\n}\n","import AsyncStorage from '@react-native-async-storage/async-storage';\n\nexport const TOKEN_KEY = 'fonderie_access_token';\n\nexport function persistToken(token: string) {\n\treturn AsyncStorage.setItem(TOKEN_KEY, token);\n}\n\nexport function clearToken() {\n\treturn AsyncStorage.removeItem(TOKEN_KEY);\n}\n\nexport function readToken() {\n\treturn AsyncStorage.getItem(TOKEN_KEY);\n}\n","import type { AuthClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\nimport { clearToken } from '../storage';\n\nexport interface IUseLogoutReturn {\n\tlogout: () => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useLogout(client: AuthClient): IUseLogoutReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst logout = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tawait client.logout();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t} finally {\n\t\t\tclient.setAccessToken(undefined);\n\t\t\tawait clearToken();\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client]);\n\n\treturn { logout, isLoading, error };\n}\n","import type { AuthClient, IRegisterInput, IRegisterResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\nimport { persistToken } from '../storage';\n\nexport interface IUseRegisterReturn {\n\tregister: (input: IRegisterInput) => Promise<IRegisterResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\tdata: IRegisterResult | null;\n}\n\nexport function useRegister(client: AuthClient): IUseRegisterReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\tconst [data, setData] = useState<IRegisterResult | null>(null);\n\n\tconst register = useCallback(\n\t\tasync (input: IRegisterInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.register(input);\n\t\t\t\tclient.setAccessToken(result.tokens.access);\n\t\t\t\tawait persistToken(result.tokens.access);\n\t\t\t\tsetData(result);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\treturn { register, isLoading, error, data };\n}\n","import type { AuthClient, IResetPasswordInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseResetPasswordReturn {\n\tresetPassword: (input: IResetPasswordInput) => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\tdone: boolean;\n}\n\nexport function useResetPassword(client: AuthClient): IUseResetPasswordReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\tconst [done, setDone] = useState(false);\n\n\tconst resetPassword = useCallback(\n\t\tasync (input: IResetPasswordInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait client.resetPassword(input);\n\t\t\t\tsetDone(true);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\treturn { resetPassword, isLoading, error, done };\n}\n","import type { AuthClient, IUserDTO } from '@fonderie/client';\nimport { useCallback, useEffect, useState } from 'react';\nimport { clearToken, readToken } from '../storage';\n\nexport interface IUseSessionReturn {\n\tuser: IUserDTO | null;\n\tisLoading: boolean;\n\tisAuthenticated: boolean;\n\trefresh: () => Promise<void>;\n\tlogout: () => Promise<void>;\n}\n\nexport function useSession(client: AuthClient): IUseSessionReturn {\n\tconst [user, setUser] = useState<IUserDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [isAuthenticated, setIsAuthenticated] = useState(false);\n\n\tconst refresh = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\ttry {\n\t\t\tconst { result } = await client.getUser();\n\t\t\tsetUser(result.user);\n\t\t\tsetIsAuthenticated(true);\n\t\t} catch {\n\t\t\tsetUser(null);\n\t\t\tsetIsAuthenticated(false);\n\t\t\tclient.setAccessToken(undefined);\n\t\t\tawait clearToken();\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [client]);\n\n\tconst logout = useCallback(async () => {\n\t\ttry {\n\t\t\tawait client.logout();\n\t\t} catch {\n\t\t\t// Session is being torn down regardless of server response.\n\t\t}\n\t\tclient.setAccessToken(undefined);\n\t\tawait clearToken();\n\t\tsetUser(null);\n\t\tsetIsAuthenticated(false);\n\t}, [client]);\n\n\tuseEffect(() => {\n\t\treadToken().then((token) => {\n\t\t\tif (token) client.setAccessToken(token);\n\t\t\tvoid refresh();\n\t\t});\n\t}, [client, refresh]);\n\n\treturn { user, isLoading, isAuthenticated, refresh, logout };\n}\n","import type { AuthClient, IVerifyEmailResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseVerifyEmailReturn {\n\tverifyEmail: (pin: string) => Promise<IVerifyEmailResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\tdata: IVerifyEmailResult | null;\n}\n\nexport function useVerifyEmail(client: AuthClient): IUseVerifyEmailReturn {\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\tconst [data, setData] = useState<IVerifyEmailResult | null>(null);\n\n\tconst verifyEmail = useCallback(\n\t\tasync (pin: string) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await client.verifyEmail(pin);\n\t\t\t\tsetData(result);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[client],\n\t);\n\n\treturn { verifyEmail, isLoading, error, data };\n}\n"],"mappings":";AAYA,SAAS,oBAAAA,yBAAwB;;;ACXjC,SAAS,wBAAwB;AACjC,SAAS,aAAa,gBAAgB;AAS/B,SAAS,kBAAkB,QAA8C;AAC/E,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkC,IAAI;AAChE,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AAEtC,QAAM,iBAAiB;AAAA,IACtB,OAAO,UAAkB;AACxB,mBAAa,IAAI;AACjB,eAAS,IAAI;AACb,UAAI;AACH,cAAM,OAAO,eAAe,KAAK;AACjC,gBAAQ,IAAI;AAAA,MACb,SAAS,KAAK;AACb,cAAM,WACL,eAAe,mBAAmB,MAAM,IAAI,iBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,iBAAS,QAAQ;AACjB,cAAM;AAAA,MACP,UAAE;AACD,qBAAa,KAAK;AAAA,MACnB;AAAA,IACD;AAAA,IACA,CAAC,MAAM;AAAA,EACR;AAEA,SAAO,EAAE,gBAAgB,WAAW,OAAO,KAAK;AACjD;;;ACnCA,SAAS,oBAAAC,yBAAwB;AACjC,SAAS,eAAAC,cAAa,YAAAC,iBAAgB;;;ACFtC,OAAO,kBAAkB;AAElB,IAAM,YAAY;AAElB,SAAS,aAAa,OAAe;AAC3C,SAAO,aAAa,QAAQ,WAAW,KAAK;AAC7C;AAEO,SAAS,aAAa;AAC5B,SAAO,aAAa,WAAW,SAAS;AACzC;AAEO,SAAS,YAAY;AAC3B,SAAO,aAAa,QAAQ,SAAS;AACtC;;;ADFO,SAAS,SAAS,QAAqC;AA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;AAEpB,SAAO,EAAE,MAAM,WAAW,iBAAiB,SAAS,OAAO;AAC5D;;;ACpDA,SAAS,oBAAAC,yBAAwB;AACjC,SAAS,eAAAC,cAAa,YAAAC,iBAAgB;AAS/B,SAAS,eAAe,QAA2C;AACzE,QAAM,CAAC,WAAW,YAAY,IAAIA,UAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAIA,UAAkC,IAAI;AAChE,QAAM,CAAC,MAAM,OAAO,IAAIA,UAAoC,IAAI;AAEhE,QAAM,cAAcD;AAAA,IACnB,OAAO,QAAgB;AACtB,mBAAa,IAAI;AACjB,eAAS,IAAI;AACb,UAAI;AACH,cAAM,EAAE,OAAO,IAAI,MAAM,OAAO,YAAY,GAAG;AAC/C,gBAAQ,MAAM;AACd,eAAO;AAAA,MACR,SAAS,KAAK;AACb,cAAM,WACL,eAAeD,oBAAmB,MAAM,IAAIA,kBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,iBAAS,QAAQ;AACjB,cAAM;AAAA,MACP,UAAE;AACD,qBAAa,KAAK;AAAA,MACnB;AAAA,IACD;AAAA,IACA,CAAC,MAAM;AAAA,EACR;AAEA,SAAO,EAAE,aAAa,WAAW,OAAO,KAAK;AAC9C;","names":["FonderieApiError","FonderieApiError","useCallback","useState","useState","useCallback","FonderieApiError","FonderieApiError","useCallback","useState","useState","useCallback","FonderieApiError","FonderieApiError","useCallback","useState","useState","useCallback","FonderieApiError","FonderieApiError","useCallback","useState","useCallback","useState","useState","useCallback","FonderieApiError","useCallback","useState"]}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@fonderie/react-native-auth",
3
+ "version": "0.1.0",
4
+ "description": "React Native hooks for Fonderie auth — thin bindings over @fonderie/client.",
5
+ "keywords": [
6
+ "fonderie-js",
7
+ "react-native",
8
+ "auth",
9
+ "hooks",
10
+ "typescript"
11
+ ],
12
+ "license": "MIT",
13
+ "type": "module",
14
+ "engines": {
15
+ "node": ">=20"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "require": "./dist/index.cjs"
22
+ }
23
+ },
24
+ "main": "./dist/index.cjs",
25
+ "module": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "scripts": {
28
+ "build": "tsup",
29
+ "dev": "tsup --watch",
30
+ "typecheck": "tsc --noEmit",
31
+ "lint": "biome lint src",
32
+ "format": "biome format --write src",
33
+ "check": "biome check --write src"
34
+ },
35
+ "dependencies": {
36
+ "@fonderie/client": "*"
37
+ },
38
+ "peerDependencies": {
39
+ "react": ">=18.0.0",
40
+ "@react-native-async-storage/async-storage": ">=1.18.0"
41
+ },
42
+ "devDependencies": {
43
+ "@react-native-async-storage/async-storage": "1.24.0",
44
+ "@types/react-native": "^0.72.8",
45
+ "react-native": "0.76.5",
46
+ "@types/node": "^25.6.0",
47
+ "@types/react": "^18.0.0",
48
+ "react": "^18.0.0",
49
+ "tsup": "^8.5.1",
50
+ "typescript": "^6.0.3"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "files": [
56
+ "dist",
57
+ "LICENSE",
58
+ "README.md"
59
+ ],
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "git+https://github.com/fonderiejs/fonderie.git",
63
+ "directory": "packages/react-native-auth"
64
+ },
65
+ "homepage": "https://github.com/fonderiejs/fonderie/tree/main/packages/react-native-auth#readme",
66
+ "bugs": {
67
+ "url": "https://github.com/fonderiejs/fonderie/issues"
68
+ }
69
+ }