@authon/react-native 0.3.5 → 0.3.6
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/index.cjs +30 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/index.d.cts +0 -298
- package/dist/index.d.ts +0 -298
package/dist/index.d.ts
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { AuthonUser as AuthonUser$1, OAuthProviderType, BrandingConfig, Web3Chain, Web3WalletType, Web3NonceResponse, Web3Wallet, PasskeyCredential } from '@authon/shared';
|
|
4
|
-
export { BrandingConfig, OAuthProviderType } from '@authon/shared';
|
|
5
|
-
import { ViewStyle, TextStyle } from 'react-native';
|
|
6
|
-
|
|
7
|
-
type AuthonUser = AuthonUser$1;
|
|
8
|
-
interface AuthonReactNativeConfig {
|
|
9
|
-
publishableKey: string;
|
|
10
|
-
apiUrl?: string;
|
|
11
|
-
}
|
|
12
|
-
interface AuthState {
|
|
13
|
-
isLoaded: boolean;
|
|
14
|
-
isSignedIn: boolean;
|
|
15
|
-
userId: string | null;
|
|
16
|
-
sessionId: string | null;
|
|
17
|
-
accessToken: string | null;
|
|
18
|
-
}
|
|
19
|
-
interface SignInParams {
|
|
20
|
-
strategy: 'email_password' | 'oauth';
|
|
21
|
-
email?: string;
|
|
22
|
-
password?: string;
|
|
23
|
-
provider?: string;
|
|
24
|
-
}
|
|
25
|
-
interface SignUpParams {
|
|
26
|
-
email: string;
|
|
27
|
-
password: string;
|
|
28
|
-
displayName?: string;
|
|
29
|
-
}
|
|
30
|
-
type OAuthFlowMode = 'popup' | 'redirect' | 'auto';
|
|
31
|
-
interface StartOAuthOptions {
|
|
32
|
-
redirectUri?: string;
|
|
33
|
-
returnTo?: string;
|
|
34
|
-
flow?: OAuthFlowMode;
|
|
35
|
-
}
|
|
36
|
-
type AuthonEventType = 'signedIn' | 'signedOut' | 'error' | 'tokenRefreshed';
|
|
37
|
-
interface AuthonEvents {
|
|
38
|
-
signedIn: (user: AuthonUser) => void;
|
|
39
|
-
signedOut: () => void;
|
|
40
|
-
error: (error: Error) => void;
|
|
41
|
-
tokenRefreshed: () => void;
|
|
42
|
-
}
|
|
43
|
-
interface TokenPair {
|
|
44
|
-
accessToken: string;
|
|
45
|
-
refreshToken: string;
|
|
46
|
-
expiresAt: number;
|
|
47
|
-
}
|
|
48
|
-
interface ApiAuthResponse {
|
|
49
|
-
accessToken: string;
|
|
50
|
-
refreshToken: string;
|
|
51
|
-
expiresIn: number;
|
|
52
|
-
user: AuthonUser;
|
|
53
|
-
}
|
|
54
|
-
interface OAuthCompletedResponse extends ApiAuthResponse {
|
|
55
|
-
status: 'completed';
|
|
56
|
-
}
|
|
57
|
-
interface OAuthErrorResponse {
|
|
58
|
-
status: 'error';
|
|
59
|
-
message: string;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
type TokenStorage = {
|
|
63
|
-
getItem(key: string): Promise<string | null>;
|
|
64
|
-
setItem(key: string, value: string): Promise<void>;
|
|
65
|
-
removeItem(key: string): Promise<void>;
|
|
66
|
-
};
|
|
67
|
-
type OAuthPollResponse = OAuthCompletedResponse | OAuthErrorResponse;
|
|
68
|
-
declare class AuthonMobileClient {
|
|
69
|
-
private apiUrl;
|
|
70
|
-
private publishableKey;
|
|
71
|
-
private storageKey;
|
|
72
|
-
private tokens;
|
|
73
|
-
private user;
|
|
74
|
-
private storage;
|
|
75
|
-
private refreshTimer;
|
|
76
|
-
private listeners;
|
|
77
|
-
private _providers;
|
|
78
|
-
private _branding;
|
|
79
|
-
private _initialized;
|
|
80
|
-
constructor(config: AuthonReactNativeConfig);
|
|
81
|
-
setStorage(storage: TokenStorage): void;
|
|
82
|
-
initialize(): Promise<TokenPair | null>;
|
|
83
|
-
/** Fetch providers + branding from API (lazy, cached) */
|
|
84
|
-
ensureInitialized(): Promise<void>;
|
|
85
|
-
signIn(params: SignInParams): Promise<{
|
|
86
|
-
tokens: TokenPair;
|
|
87
|
-
user: AuthonUser;
|
|
88
|
-
}>;
|
|
89
|
-
signUp(params: SignUpParams): Promise<{
|
|
90
|
-
tokens: TokenPair;
|
|
91
|
-
user: AuthonUser;
|
|
92
|
-
}>;
|
|
93
|
-
signOut(): Promise<void>;
|
|
94
|
-
getUser(): Promise<AuthonUser | null>;
|
|
95
|
-
getCachedUser(): AuthonUser | null;
|
|
96
|
-
refreshToken(refreshToken?: string): Promise<TokenPair | null>;
|
|
97
|
-
getAccessToken(): string | null;
|
|
98
|
-
isAuthenticated(): boolean;
|
|
99
|
-
getProviders(): Promise<OAuthProviderType[]>;
|
|
100
|
-
getBranding(): Promise<BrandingConfig | null>;
|
|
101
|
-
getOAuthUrl(provider: string, options?: string | StartOAuthOptions): Promise<{
|
|
102
|
-
url: string;
|
|
103
|
-
state: string;
|
|
104
|
-
}>;
|
|
105
|
-
pollOAuth(state: string): Promise<OAuthPollResponse | null>;
|
|
106
|
-
/** Poll for OAuth completion (3 minute timeout, matching JS SDK) */
|
|
107
|
-
completeOAuth(state: string): Promise<{
|
|
108
|
-
tokens: TokenPair;
|
|
109
|
-
user: AuthonUser;
|
|
110
|
-
}>;
|
|
111
|
-
getApiUrl(): string;
|
|
112
|
-
web3GetNonce(address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number): Promise<Web3NonceResponse>;
|
|
113
|
-
web3Verify(message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType): Promise<{
|
|
114
|
-
tokens: TokenPair;
|
|
115
|
-
user: AuthonUser;
|
|
116
|
-
}>;
|
|
117
|
-
web3GetWallets(): Promise<Web3Wallet[]>;
|
|
118
|
-
web3LinkWallet(params: {
|
|
119
|
-
address: string;
|
|
120
|
-
chain: Web3Chain;
|
|
121
|
-
walletType: Web3WalletType;
|
|
122
|
-
chainId?: number;
|
|
123
|
-
message: string;
|
|
124
|
-
signature: string;
|
|
125
|
-
}): Promise<Web3Wallet>;
|
|
126
|
-
web3UnlinkWallet(walletId: string): Promise<void>;
|
|
127
|
-
passwordlessSendCode(identifier: string, type?: 'email' | 'sms'): Promise<void>;
|
|
128
|
-
passwordlessVerifyCode(identifier: string, code: string): Promise<{
|
|
129
|
-
tokens: TokenPair;
|
|
130
|
-
user: AuthonUser;
|
|
131
|
-
}>;
|
|
132
|
-
passkeyStartRegister(name?: string): Promise<{
|
|
133
|
-
options: Record<string, unknown>;
|
|
134
|
-
}>;
|
|
135
|
-
passkeyCompleteRegister(credential: Record<string, unknown>): Promise<PasskeyCredential>;
|
|
136
|
-
passkeyStartAuth(email?: string): Promise<{
|
|
137
|
-
options: Record<string, unknown>;
|
|
138
|
-
}>;
|
|
139
|
-
passkeyCompleteAuth(credential: Record<string, unknown>): Promise<{
|
|
140
|
-
tokens: TokenPair;
|
|
141
|
-
user: AuthonUser;
|
|
142
|
-
}>;
|
|
143
|
-
passkeyList(): Promise<PasskeyCredential[]>;
|
|
144
|
-
passkeyDelete(credentialId: string): Promise<void>;
|
|
145
|
-
on<K extends AuthonEventType>(event: K, listener: AuthonEvents[K]): () => void;
|
|
146
|
-
private emit;
|
|
147
|
-
destroy(): void;
|
|
148
|
-
private clearSession;
|
|
149
|
-
private clearRefreshTimer;
|
|
150
|
-
/** Schedule auto-refresh 60 seconds before token expiry (like JS SDK) */
|
|
151
|
-
private scheduleRefresh;
|
|
152
|
-
private persistTokens;
|
|
153
|
-
private toTokenPair;
|
|
154
|
-
private requestAuth;
|
|
155
|
-
private request;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
interface AuthonContextValue extends AuthState {
|
|
159
|
-
user: AuthonUser | null;
|
|
160
|
-
signIn: (params: SignInParams) => Promise<void>;
|
|
161
|
-
signUp: (params: SignUpParams) => Promise<void>;
|
|
162
|
-
signOut: () => Promise<void>;
|
|
163
|
-
getToken: () => string | null;
|
|
164
|
-
/** Available OAuth providers (fetched from API) */
|
|
165
|
-
providers: OAuthProviderType[];
|
|
166
|
-
/** Branding config (fetched from API) */
|
|
167
|
-
branding: BrandingConfig | null;
|
|
168
|
-
/** Start OAuth flow — returns { url, state }. Open url in browser, then call completeOAuth(state) */
|
|
169
|
-
startOAuth: (provider: OAuthProviderType, options?: string | StartOAuthOptions) => Promise<{
|
|
170
|
-
url: string;
|
|
171
|
-
state: string;
|
|
172
|
-
}>;
|
|
173
|
-
/** Poll for OAuth result after user completes browser flow */
|
|
174
|
-
completeOAuth: (state: string) => Promise<void>;
|
|
175
|
-
/** Subscribe to auth events */
|
|
176
|
-
on: <K extends AuthonEventType>(event: K, listener: AuthonEvents[K]) => () => void;
|
|
177
|
-
/** Get the underlying client instance */
|
|
178
|
-
client: AuthonMobileClient;
|
|
179
|
-
}
|
|
180
|
-
declare const AuthonContext: React.Context<AuthonContextValue | null>;
|
|
181
|
-
interface AuthonProviderProps extends AuthonReactNativeConfig {
|
|
182
|
-
children: React.ReactNode;
|
|
183
|
-
storage?: {
|
|
184
|
-
getItem(key: string): Promise<string | null>;
|
|
185
|
-
setItem(key: string, value: string): Promise<void>;
|
|
186
|
-
removeItem(key: string): Promise<void>;
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
declare function AuthonProvider({ children, storage, ...config }: AuthonProviderProps): react_jsx_runtime.JSX.Element;
|
|
190
|
-
|
|
191
|
-
declare function useAuthon(): AuthonContextValue;
|
|
192
|
-
|
|
193
|
-
declare function useUser(): {
|
|
194
|
-
isLoaded: boolean;
|
|
195
|
-
isSignedIn: boolean;
|
|
196
|
-
user: AuthonUser | null;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
interface Web3LinkWalletParams {
|
|
200
|
-
address: string;
|
|
201
|
-
chain: Web3Chain;
|
|
202
|
-
walletType: Web3WalletType;
|
|
203
|
-
chainId?: number;
|
|
204
|
-
message: string;
|
|
205
|
-
signature: string;
|
|
206
|
-
}
|
|
207
|
-
interface UseAuthonWeb3Return {
|
|
208
|
-
getNonce: (address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number) => Promise<Web3NonceResponse | null>;
|
|
209
|
-
verify: (message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType) => Promise<boolean>;
|
|
210
|
-
getWallets: () => Promise<Web3Wallet[] | null>;
|
|
211
|
-
linkWallet: (params: Web3LinkWalletParams) => Promise<Web3Wallet | null>;
|
|
212
|
-
unlinkWallet: (walletId: string) => Promise<boolean>;
|
|
213
|
-
isLoading: boolean;
|
|
214
|
-
error: Error | null;
|
|
215
|
-
}
|
|
216
|
-
declare function useAuthonWeb3(): UseAuthonWeb3Return;
|
|
217
|
-
|
|
218
|
-
interface UseAuthonPasswordlessReturn {
|
|
219
|
-
sendCode: (identifier: string, type?: 'email' | 'sms') => Promise<boolean>;
|
|
220
|
-
verifyCode: (identifier: string, code: string) => Promise<{
|
|
221
|
-
tokens: TokenPair;
|
|
222
|
-
user: AuthonUser;
|
|
223
|
-
} | null>;
|
|
224
|
-
isLoading: boolean;
|
|
225
|
-
error: Error | null;
|
|
226
|
-
}
|
|
227
|
-
declare function useAuthonPasswordless(): UseAuthonPasswordlessReturn;
|
|
228
|
-
|
|
229
|
-
interface UseAuthonPasskeysReturn {
|
|
230
|
-
startRegister: (name?: string) => Promise<{
|
|
231
|
-
options: Record<string, unknown>;
|
|
232
|
-
} | null>;
|
|
233
|
-
completeRegister: (credential: Record<string, unknown>) => Promise<PasskeyCredential | null>;
|
|
234
|
-
startAuth: (email?: string) => Promise<{
|
|
235
|
-
options: Record<string, unknown>;
|
|
236
|
-
} | null>;
|
|
237
|
-
completeAuth: (credential: Record<string, unknown>) => Promise<{
|
|
238
|
-
tokens: TokenPair;
|
|
239
|
-
user: AuthonUser;
|
|
240
|
-
} | null>;
|
|
241
|
-
listPasskeys: () => Promise<PasskeyCredential[] | null>;
|
|
242
|
-
deletePasskey: (credentialId: string) => Promise<boolean>;
|
|
243
|
-
isLoading: boolean;
|
|
244
|
-
error: Error | null;
|
|
245
|
-
}
|
|
246
|
-
declare function useAuthonPasskeys(): UseAuthonPasskeysReturn;
|
|
247
|
-
|
|
248
|
-
interface IconProps {
|
|
249
|
-
size?: number;
|
|
250
|
-
color?: string;
|
|
251
|
-
}
|
|
252
|
-
declare function ProviderIcon({ provider, size, color }: IconProps & {
|
|
253
|
-
provider: OAuthProviderType;
|
|
254
|
-
}): react_jsx_runtime.JSX.Element | null;
|
|
255
|
-
|
|
256
|
-
interface SocialButtonProps {
|
|
257
|
-
provider: OAuthProviderType;
|
|
258
|
-
onPress: (provider: OAuthProviderType) => void;
|
|
259
|
-
loading?: boolean;
|
|
260
|
-
disabled?: boolean;
|
|
261
|
-
/** Override button label. Default: "Continue with {Provider}" */
|
|
262
|
-
label?: string;
|
|
263
|
-
/** Compact mode — icon-only square button (default: false) */
|
|
264
|
-
compact?: boolean;
|
|
265
|
-
/** Override button style */
|
|
266
|
-
style?: ViewStyle;
|
|
267
|
-
/** Override label text style */
|
|
268
|
-
labelStyle?: TextStyle;
|
|
269
|
-
/** Icon size (default: 20, compact default: 24) */
|
|
270
|
-
iconSize?: number;
|
|
271
|
-
/** Border radius (default: 10) */
|
|
272
|
-
borderRadius?: number;
|
|
273
|
-
/** Button height (default: 48) */
|
|
274
|
-
height?: number;
|
|
275
|
-
/** Button size for compact mode (default: 48) */
|
|
276
|
-
size?: number;
|
|
277
|
-
}
|
|
278
|
-
declare function SocialButton({ provider, onPress, loading, disabled, label, compact, style, labelStyle, iconSize, borderRadius, height, size, }: SocialButtonProps): react_jsx_runtime.JSX.Element;
|
|
279
|
-
|
|
280
|
-
interface SocialButtonsProps {
|
|
281
|
-
/** Called after successful OAuth sign-in */
|
|
282
|
-
onSuccess?: () => void;
|
|
283
|
-
/** Called on OAuth error */
|
|
284
|
-
onError?: (error: Error) => void;
|
|
285
|
-
/** Container style */
|
|
286
|
-
style?: ViewStyle;
|
|
287
|
-
/** Gap between buttons (default: 10, compact default: 12) */
|
|
288
|
-
gap?: number;
|
|
289
|
-
/** Compact mode — icon-only square buttons in a row (default: false) */
|
|
290
|
-
compact?: boolean;
|
|
291
|
-
/** Custom labels per provider. e.g. { google: 'Google로 로그인' } */
|
|
292
|
-
labels?: Partial<Record<OAuthProviderType, string>>;
|
|
293
|
-
/** Props to pass through to each SocialButton */
|
|
294
|
-
buttonProps?: Partial<Omit<SocialButtonProps, 'provider' | 'onPress' | 'loading' | 'disabled' | 'compact' | 'label'>>;
|
|
295
|
-
}
|
|
296
|
-
declare function SocialButtons({ onSuccess, onError, style, gap, compact, labels, buttonProps, }: SocialButtonsProps): react_jsx_runtime.JSX.Element | null;
|
|
297
|
-
|
|
298
|
-
export { type AuthState, AuthonContext, type AuthonContextValue, type AuthonEventType, type AuthonEvents, AuthonMobileClient, AuthonProvider, type AuthonReactNativeConfig, type AuthonUser, type OAuthCompletedResponse, type OAuthErrorResponse, type OAuthFlowMode, ProviderIcon, type SignInParams, type SignUpParams, SocialButton, type SocialButtonProps, SocialButtons, type SocialButtonsProps, type StartOAuthOptions, type TokenPair, type UseAuthonPasskeysReturn, type UseAuthonPasswordlessReturn, type UseAuthonWeb3Return, type Web3LinkWalletParams, useAuthon, useAuthonPasskeys, useAuthonPasswordless, useAuthonWeb3, useUser };
|