@atzentis/auth-expo 0.0.16 → 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/CHANGELOG.md ADDED
@@ -0,0 +1,33 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2026-02-19
10
+
11
+ ### Added
12
+
13
+ - `AuthProvider` with Better Auth client, SecureStore token persistence, expo-localization integration
14
+ - `AuthContainer` layout with KeyboardAvoidingView and safe area handling
15
+ - 8 auth screens: `LoginScreen` (with biometric auth), `SignupScreen`, `PhoneLoginScreen` (2-step OTP), `MagicLinkScreen` (multi-step with token), `TwoFactorScreen` (TOTP + backup codes), `ForgotPasswordScreen` (email + cooldown resend), `ResetPasswordScreen` (token-based), `EmailVerificationScreen` (auto-verify)
16
+ - `AuthView` route-based renderer for flexible screen navigation
17
+ - 7 settings screens: `ChangePasswordScreen`, `ChangeEmailScreen`, `UpdateNameScreen`, `UpdateUsernameScreen`, `UpdateAvatarScreen`, `SessionsScreen`, `DeleteAccountScreen`
18
+ - `TwoFactorSettingsScreen` for 2FA management
19
+ - 2 organization screens: `OrganizationSwitcherScreen`, `OrganizationMembersScreen`
20
+ - `OAuthButton` component (Google, Apple, GitHub providers)
21
+ - `FormInput` and `FormPasswordInput` form components
22
+ - `ErrorFeedback` and `SuccessFeedback` status components
23
+ - `SubmitButton` with loading state
24
+ - `AuthGate` for session-based conditional rendering
25
+ - `ProtectedScreen` for role/permission guards
26
+ - Hooks: `useAuthClient`, `useAuthLocalization`, `useBiometric`, `useAuthRedirect`
27
+ - Mutation hooks: `useLogin`, `useSignup`, `useLogout`, `useRequestPasswordReset`, `useResetPassword`
28
+ - Query hooks: `useUser`, `useSession`
29
+ - React 19 patterns (React.use, Context value=)
30
+ - expo-router integration
31
+
32
+ [Unreleased]: https://github.com/atzentis/atzentis-auth-sdk/compare/v0.1.0...HEAD
33
+ [0.1.0]: https://github.com/atzentis/atzentis-auth-sdk/releases/tag/v0.1.0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Atzentis
3
+ Copyright (c) 2026 Atzentis
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,56 +1,220 @@
1
1
  # @atzentis/auth-expo
2
2
 
3
- React Native/Expo integration for [Atzentis Authentication](https://auth.atzentis.com).
3
+ [![npm version](https://img.shields.io/npm/v/@atzentis/auth-expo)](https://www.npmjs.com/package/@atzentis/auth-expo)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](../../LICENSE)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue)](https://www.typescriptlang.org/)
4
6
 
5
- Extends `@atzentis/auth-sdk` with native device signals, biometric authentication, and secure token storage.
7
+ React Native/Expo auth screens and components for [auth.atzentis.com](https://auth.atzentis.com). Provides 18 ready-to-use native screens, biometric authentication, secure token storage via `expo-secure-store`, and first-class expo-router integration.
8
+
9
+ ## Features
10
+
11
+ - **18 native screens** — complete auth, settings, and organization flows for React Native
12
+ - **Biometric authentication** — FaceID/TouchID via `expo-local-authentication`
13
+ - **Secure storage** — tokens stored in the device keychain via `expo-secure-store`
14
+ - **expo-router integration** — `AuthView` maps route strings to screens; `useAuthRedirect` wraps `router.replace`
15
+ - **Session-based conditional rendering** — `AuthGate` and `ProtectedScreen` with role/permission guards
16
+ - **TanStack Query** — 5 mutation hooks and 2 query hooks backed by the same cache as `@atzentis/auth-react`
17
+ - **React 19 patterns** — uses `React.use(Context)` and `<Context value={}>` provider syntax
6
18
 
7
19
  ## Installation
8
20
 
9
21
  ```bash
10
- pnpm add @atzentis/auth-sdk @atzentis/auth-expo
22
+ npx expo install @atzentis/auth-expo @atzentis/auth-sdk
23
+ ```
11
24
 
12
- # Peer dependencies
13
- npx expo install expo-device expo-application expo-secure-store
25
+ Then install the required peer dependencies:
26
+
27
+ ```bash
28
+ npx expo install \
29
+ better-auth \
30
+ @better-auth/expo \
31
+ expo-secure-store \
32
+ expo-local-authentication \
33
+ expo-localization \
34
+ expo-router \
35
+ expo-application \
36
+ expo-device \
37
+ expo-haptics
14
38
  ```
15
39
 
40
+ And install the JS peer dependencies:
41
+
42
+ ```bash
43
+ npm install @tanstack/react-query react-hook-form @hookform/resolvers
44
+ ```
45
+
46
+ ## Peer Dependencies
47
+
48
+ | Package | Version | Required |
49
+ | --- | --- | --- |
50
+ | `better-auth` | >= 1.2.0 | Yes |
51
+ | `@better-auth/expo` | >= 1.2.0 | Yes |
52
+ | `expo-secure-store` | >= 14.0.0 | Yes |
53
+ | `expo-localization` | >= 16.0.0 | Yes |
54
+ | `expo-router` | >= 4.0.0 | Yes |
55
+ | `expo-application` | >= 6.0.0 | Yes |
56
+ | `expo-device` | >= 7.0.0 | Yes |
57
+ | `react-native` | >= 0.76.0 | Yes |
58
+ | `@tanstack/react-query` | >= 5.0.0 | Yes |
59
+ | `react-hook-form` | >= 7.45.0 | Yes |
60
+ | `@hookform/resolvers` | >= 3.3.0 | Yes |
61
+ | `lucide-react-native` | >= 0.400.0 | Yes |
62
+ | `@expo/ui` | >= 0.6.0 | Optional |
63
+ | `expo-local-authentication` | >= 15.0.0 | Optional |
64
+ | `expo-haptics` | >= 14.0.0 | Optional |
65
+ | `react-native-reanimated` | >= 3.0.0 | Optional |
66
+
16
67
  ## Quick Start
17
68
 
18
- ```typescript
19
- import { AuthClient } from "@atzentis/auth-sdk";
20
- import { withExpoAuth } from "@atzentis/auth-expo";
69
+ Wrap your auth flow with `AuthProvider` and render screens via `AuthView`:
21
70
 
22
- const auth = new AuthClient({
23
- apiKey: "atz_live_xxxxx",
24
- baseUrl: "https://auth.atzentis.com",
25
- });
71
+ ```tsx
72
+ import { AuthProvider, AuthView } from "@atzentis/auth-expo";
26
73
 
27
- const expoAuth = withExpoAuth(auth, {
28
- scheme: "myapp-auth",
29
- storagePrefix: "myapp-auth",
30
- collectDeviceInfo: true,
31
- });
74
+ export default function AuthScreen() {
75
+ return (
76
+ <AuthProvider baseUrl="https://auth.atzentis.com">
77
+ <AuthView initialRoute="login" />
78
+ </AuthProvider>
79
+ );
80
+ }
32
81
  ```
33
82
 
34
- ## Features
83
+ For settings or organization screens, render them directly:
35
84
 
36
- - Secure token storage via `expo-secure-store`
37
- - Native device signal collection for security fingerprinting
38
- - OAuth deep linking support
39
- - Biometric authentication for session refresh (FaceID/TouchID)
85
+ ```tsx
86
+ import { AuthProvider, ChangePasswordScreen } from "@atzentis/auth-expo";
40
87
 
41
- ## Peer Dependencies
88
+ export default function ChangePasswordPage() {
89
+ return (
90
+ <AuthProvider baseUrl="https://auth.atzentis.com">
91
+ <ChangePasswordScreen />
92
+ </AuthProvider>
93
+ );
94
+ }
95
+ ```
96
+
97
+ ## Screens
98
+
99
+ ### Auth Screens
100
+
101
+ | Screen | Description |
102
+ | --- | --- |
103
+ | `LoginScreen` | Email/password login with optional biometric sign-in |
104
+ | `SignupScreen` | New account registration |
105
+ | `PhoneLoginScreen` | Two-step phone number + OTP verification |
106
+ | `MagicLinkScreen` | Multi-step passwordless magic link flow |
107
+ | `TwoFactorScreen` | TOTP code entry with backup code fallback |
108
+ | `ForgotPasswordScreen` | Email input with timed cooldown for resend |
109
+ | `ResetPasswordScreen` | Token-based new password form |
110
+ | `EmailVerificationScreen` | Auto-verify via deep link or manual OTP entry |
111
+
112
+ Use `AuthView` to render any auth screen by route name:
42
113
 
43
- - `react` >= 18.0.0
44
- - `react-native` >= 0.73.0
45
- - `expo-device` >= 7.0.0
46
- - `expo-application` >= 6.0.0
47
- - `expo-secure-store` >= 14.0.0
114
+ ```tsx
115
+ import { AuthView } from "@atzentis/auth-expo";
116
+
117
+ // Renders the LoginScreen
118
+ <AuthView initialRoute="login" />
119
+
120
+ // Renders the SignupScreen
121
+ <AuthView initialRoute="signup" />
122
+
123
+ // Supported routes: "login" | "signup" | "phone-login" | "magic-link"
124
+ // "two-factor" | "forgot-password" | "reset-password" | "email-verification"
125
+ ```
126
+
127
+ ### Settings Screens
128
+
129
+ | Screen | Description |
130
+ | --- | --- |
131
+ | `ChangePasswordScreen` | Update account password |
132
+ | `ChangeEmailScreen` | Update email address with verification |
133
+ | `UpdateNameScreen` | Update display name |
134
+ | `UpdateUsernameScreen` | Update username |
135
+ | `UpdateAvatarScreen` | Upload or select a profile avatar |
136
+ | `SessionsScreen` | View and revoke active sessions |
137
+ | `DeleteAccountScreen` | Multi-step account deletion with confirmation |
138
+ | `TwoFactorSettingsScreen` | Enable, verify, or disable two-factor authentication |
139
+
140
+ ### Organization Screens
141
+
142
+ | Screen | Description |
143
+ | --- | --- |
144
+ | `OrganizationSwitcherScreen` | List organizations and switch the active one |
145
+ | `OrganizationMembersScreen` | View members, update roles, and remove members |
146
+
147
+ ## Components
148
+
149
+ | Component | Description |
150
+ | --- | --- |
151
+ | `AuthGate` | Renders children only when a session exists; renders a fallback otherwise |
152
+ | `ProtectedScreen` | RBAC guard — accepts `role` and `permission` props with a fallback |
153
+ | `OAuthButton` | Native OAuth provider button (google, apple, github) |
154
+ | `FormInput` | Styled text input for use inside auth forms |
155
+ | `FormPasswordInput` | Password input with show/hide toggle |
156
+ | `SubmitButton` | Loading-aware submit button |
157
+ | `ErrorFeedback` | Accessible error message display |
158
+ | `SuccessFeedback` | Accessible success message display |
159
+ | `AuthContainer` | `KeyboardAvoidingView` layout wrapper for auth screens |
160
+
161
+ ## Hooks
162
+
163
+ | Hook | Purpose |
164
+ | --- | --- |
165
+ | `useAuthClient()` | Access the underlying Better Auth client instance |
166
+ | `useAuthLocalization()` | Access the active localization strings |
167
+ | `useBiometric()` | Check biometric availability and trigger authentication |
168
+ | `useAuthRedirect()` | Programmatic navigation using `expo-router`'s `router.replace` |
169
+
170
+ ### Mutation Hooks
171
+
172
+ | Hook | Purpose |
173
+ | --- | --- |
174
+ | `useLogin()` | Sign in with email and password |
175
+ | `useSignup()` | Create a new account |
176
+ | `useLogout()` | Sign out the current session |
177
+ | `useRequestPasswordReset()` | Request a password reset email |
178
+ | `useResetPassword()` | Submit a new password using a reset token |
179
+
180
+ ### Query Hooks
181
+
182
+ | Hook | Purpose |
183
+ | --- | --- |
184
+ | `useUser()` | Fetch the current user profile |
185
+ | `useSession()` | Fetch the current session |
186
+
187
+ ## AuthProvider Props
188
+
189
+ | Prop | Type | Description |
190
+ | --- | --- | --- |
191
+ | `baseUrl` | `string` | Required. The auth.atzentis.com URL |
192
+ | `initialUser` | `User` | Optional. Pre-hydrated user for SSR |
193
+ | `onSessionExpired` | `() => void` | Called when the session expires |
194
+ | `onTokenRefreshed` | `(session: Session) => void` | Called after a successful token refresh |
195
+ | `onNewDeviceAlert` | `(alert: LoginAlert) => void` | Called when a new device login is detected |
196
+
197
+ ## Localization
198
+
199
+ All screens and components read from the shared `@atzentis/auth-locales` package. Override strings by passing a `localization` prop to `AuthProvider`:
200
+
201
+ ```tsx
202
+ <AuthProvider
203
+ baseUrl="https://auth.atzentis.com"
204
+ localization={{
205
+ loginScreen: {
206
+ title: "Welcome back",
207
+ submitButton: "Continue",
208
+ },
209
+ }}
210
+ >
211
+ ```
48
212
 
49
213
  ## Related Packages
50
214
 
51
- - [`@atzentis/auth-sdk`](https://www.npmjs.com/package/@atzentis/auth-sdk) - Core SDK (required)
52
- - [`@atzentis/auth-react`](https://www.npmjs.com/package/@atzentis/auth-react) - React hooks and components
215
+ - [`@atzentis/auth-sdk`](https://www.npmjs.com/package/@atzentis/auth-sdk) Core TypeScript client (required)
216
+ - [`@atzentis/auth-react`](https://www.npmjs.com/package/@atzentis/auth-react) React hooks and components for web
53
217
 
54
218
  ## License
55
219
 
56
- MIT
220
+ MIT — see [LICENSE](../../LICENSE) for details.