@authon/react-native 0.2.2 → 0.3.1

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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
- import { AuthonUser as AuthonUser$1, OAuthProviderType, BrandingConfig } from '@authon/shared';
3
+ import { AuthonUser as AuthonUser$1, OAuthProviderType, BrandingConfig, Web3Chain, Web3WalletType, Web3NonceResponse, Web3Wallet, PasskeyCredential } from '@authon/shared';
4
4
  export { BrandingConfig, OAuthProviderType } from '@authon/shared';
5
5
  import { ViewStyle, TextStyle } from 'react-native';
6
6
 
@@ -27,6 +27,12 @@ interface SignUpParams {
27
27
  password: string;
28
28
  displayName?: string;
29
29
  }
30
+ type OAuthFlowMode = 'popup' | 'redirect' | 'auto';
31
+ interface StartOAuthOptions {
32
+ redirectUri?: string;
33
+ returnTo?: string;
34
+ flow?: OAuthFlowMode;
35
+ }
30
36
  type AuthonEventType = 'signedIn' | 'signedOut' | 'error' | 'tokenRefreshed';
31
37
  interface AuthonEvents {
32
38
  signedIn: (user: AuthonUser) => void;
@@ -83,7 +89,7 @@ declare class AuthonMobileClient {
83
89
  isAuthenticated(): boolean;
84
90
  getProviders(): Promise<OAuthProviderType[]>;
85
91
  getBranding(): Promise<BrandingConfig | null>;
86
- getOAuthUrl(provider: string, redirectUri: string): Promise<{
92
+ getOAuthUrl(provider: string, options?: string | StartOAuthOptions): Promise<{
87
93
  url: string;
88
94
  state: string;
89
95
  }>;
@@ -94,6 +100,39 @@ declare class AuthonMobileClient {
94
100
  user: AuthonUser;
95
101
  }>;
96
102
  getApiUrl(): string;
103
+ web3GetNonce(address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number): Promise<Web3NonceResponse>;
104
+ web3Verify(message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType): Promise<{
105
+ tokens: TokenPair;
106
+ user: AuthonUser;
107
+ }>;
108
+ web3GetWallets(): Promise<Web3Wallet[]>;
109
+ web3LinkWallet(params: {
110
+ address: string;
111
+ chain: Web3Chain;
112
+ walletType: Web3WalletType;
113
+ chainId?: number;
114
+ message: string;
115
+ signature: string;
116
+ }): Promise<Web3Wallet>;
117
+ web3UnlinkWallet(walletId: string): Promise<void>;
118
+ passwordlessSendCode(identifier: string, type?: 'email' | 'sms'): Promise<void>;
119
+ passwordlessVerifyCode(identifier: string, code: string): Promise<{
120
+ tokens: TokenPair;
121
+ user: AuthonUser;
122
+ }>;
123
+ passkeyStartRegister(name?: string): Promise<{
124
+ options: Record<string, unknown>;
125
+ }>;
126
+ passkeyCompleteRegister(credential: Record<string, unknown>): Promise<PasskeyCredential>;
127
+ passkeyStartAuth(email?: string): Promise<{
128
+ options: Record<string, unknown>;
129
+ }>;
130
+ passkeyCompleteAuth(credential: Record<string, unknown>): Promise<{
131
+ tokens: TokenPair;
132
+ user: AuthonUser;
133
+ }>;
134
+ passkeyList(): Promise<PasskeyCredential[]>;
135
+ passkeyDelete(credentialId: string): Promise<void>;
97
136
  on<K extends AuthonEventType>(event: K, listener: AuthonEvents[K]): () => void;
98
137
  private emit;
99
138
  destroy(): void;
@@ -103,6 +142,7 @@ declare class AuthonMobileClient {
103
142
  private scheduleRefresh;
104
143
  private persistTokens;
105
144
  private toTokenPair;
145
+ private requestAuth;
106
146
  private request;
107
147
  }
108
148
 
@@ -117,7 +157,7 @@ interface AuthonContextValue extends AuthState {
117
157
  /** Branding config (fetched from API) */
118
158
  branding: BrandingConfig | null;
119
159
  /** Start OAuth flow — returns { url, state }. Open url in browser, then call completeOAuth(state) */
120
- startOAuth: (provider: OAuthProviderType, redirectUri?: string) => Promise<{
160
+ startOAuth: (provider: OAuthProviderType, options?: string | StartOAuthOptions) => Promise<{
121
161
  url: string;
122
162
  state: string;
123
163
  }>;
@@ -147,6 +187,55 @@ declare function useUser(): {
147
187
  user: AuthonUser | null;
148
188
  };
149
189
 
190
+ interface Web3LinkWalletParams {
191
+ address: string;
192
+ chain: Web3Chain;
193
+ walletType: Web3WalletType;
194
+ chainId?: number;
195
+ message: string;
196
+ signature: string;
197
+ }
198
+ interface UseAuthonWeb3Return {
199
+ getNonce: (address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number) => Promise<Web3NonceResponse | null>;
200
+ verify: (message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType) => Promise<boolean>;
201
+ getWallets: () => Promise<Web3Wallet[] | null>;
202
+ linkWallet: (params: Web3LinkWalletParams) => Promise<Web3Wallet | null>;
203
+ unlinkWallet: (walletId: string) => Promise<boolean>;
204
+ isLoading: boolean;
205
+ error: Error | null;
206
+ }
207
+ declare function useAuthonWeb3(): UseAuthonWeb3Return;
208
+
209
+ interface UseAuthonPasswordlessReturn {
210
+ sendCode: (identifier: string, type?: 'email' | 'sms') => Promise<boolean>;
211
+ verifyCode: (identifier: string, code: string) => Promise<{
212
+ tokens: TokenPair;
213
+ user: AuthonUser;
214
+ } | null>;
215
+ isLoading: boolean;
216
+ error: Error | null;
217
+ }
218
+ declare function useAuthonPasswordless(): UseAuthonPasswordlessReturn;
219
+
220
+ interface UseAuthonPasskeysReturn {
221
+ startRegister: (name?: string) => Promise<{
222
+ options: Record<string, unknown>;
223
+ } | null>;
224
+ completeRegister: (credential: Record<string, unknown>) => Promise<PasskeyCredential | null>;
225
+ startAuth: (email?: string) => Promise<{
226
+ options: Record<string, unknown>;
227
+ } | null>;
228
+ completeAuth: (credential: Record<string, unknown>) => Promise<{
229
+ tokens: TokenPair;
230
+ user: AuthonUser;
231
+ } | null>;
232
+ listPasskeys: () => Promise<PasskeyCredential[] | null>;
233
+ deletePasskey: (credentialId: string) => Promise<boolean>;
234
+ isLoading: boolean;
235
+ error: Error | null;
236
+ }
237
+ declare function useAuthonPasskeys(): UseAuthonPasskeysReturn;
238
+
150
239
  interface IconProps {
151
240
  size?: number;
152
241
  color?: string;
@@ -197,4 +286,4 @@ interface SocialButtonsProps {
197
286
  }
198
287
  declare function SocialButtons({ onSuccess, onError, style, gap, compact, labels, buttonProps, }: SocialButtonsProps): react_jsx_runtime.JSX.Element | null;
199
288
 
200
- export { type AuthState, AuthonContext, type AuthonContextValue, type AuthonEventType, type AuthonEvents, AuthonMobileClient, AuthonProvider, type AuthonReactNativeConfig, type AuthonUser, ProviderIcon, type SignInParams, type SignUpParams, SocialButton, type SocialButtonProps, SocialButtons, type SocialButtonsProps, type TokenPair, useAuthon, useUser };
289
+ export { type AuthState, AuthonContext, type AuthonContextValue, type AuthonEventType, type AuthonEvents, AuthonMobileClient, AuthonProvider, type AuthonReactNativeConfig, type AuthonUser, 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 };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
- import { AuthonUser as AuthonUser$1, OAuthProviderType, BrandingConfig } from '@authon/shared';
3
+ import { AuthonUser as AuthonUser$1, OAuthProviderType, BrandingConfig, Web3Chain, Web3WalletType, Web3NonceResponse, Web3Wallet, PasskeyCredential } from '@authon/shared';
4
4
  export { BrandingConfig, OAuthProviderType } from '@authon/shared';
5
5
  import { ViewStyle, TextStyle } from 'react-native';
6
6
 
@@ -27,6 +27,12 @@ interface SignUpParams {
27
27
  password: string;
28
28
  displayName?: string;
29
29
  }
30
+ type OAuthFlowMode = 'popup' | 'redirect' | 'auto';
31
+ interface StartOAuthOptions {
32
+ redirectUri?: string;
33
+ returnTo?: string;
34
+ flow?: OAuthFlowMode;
35
+ }
30
36
  type AuthonEventType = 'signedIn' | 'signedOut' | 'error' | 'tokenRefreshed';
31
37
  interface AuthonEvents {
32
38
  signedIn: (user: AuthonUser) => void;
@@ -83,7 +89,7 @@ declare class AuthonMobileClient {
83
89
  isAuthenticated(): boolean;
84
90
  getProviders(): Promise<OAuthProviderType[]>;
85
91
  getBranding(): Promise<BrandingConfig | null>;
86
- getOAuthUrl(provider: string, redirectUri: string): Promise<{
92
+ getOAuthUrl(provider: string, options?: string | StartOAuthOptions): Promise<{
87
93
  url: string;
88
94
  state: string;
89
95
  }>;
@@ -94,6 +100,39 @@ declare class AuthonMobileClient {
94
100
  user: AuthonUser;
95
101
  }>;
96
102
  getApiUrl(): string;
103
+ web3GetNonce(address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number): Promise<Web3NonceResponse>;
104
+ web3Verify(message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType): Promise<{
105
+ tokens: TokenPair;
106
+ user: AuthonUser;
107
+ }>;
108
+ web3GetWallets(): Promise<Web3Wallet[]>;
109
+ web3LinkWallet(params: {
110
+ address: string;
111
+ chain: Web3Chain;
112
+ walletType: Web3WalletType;
113
+ chainId?: number;
114
+ message: string;
115
+ signature: string;
116
+ }): Promise<Web3Wallet>;
117
+ web3UnlinkWallet(walletId: string): Promise<void>;
118
+ passwordlessSendCode(identifier: string, type?: 'email' | 'sms'): Promise<void>;
119
+ passwordlessVerifyCode(identifier: string, code: string): Promise<{
120
+ tokens: TokenPair;
121
+ user: AuthonUser;
122
+ }>;
123
+ passkeyStartRegister(name?: string): Promise<{
124
+ options: Record<string, unknown>;
125
+ }>;
126
+ passkeyCompleteRegister(credential: Record<string, unknown>): Promise<PasskeyCredential>;
127
+ passkeyStartAuth(email?: string): Promise<{
128
+ options: Record<string, unknown>;
129
+ }>;
130
+ passkeyCompleteAuth(credential: Record<string, unknown>): Promise<{
131
+ tokens: TokenPair;
132
+ user: AuthonUser;
133
+ }>;
134
+ passkeyList(): Promise<PasskeyCredential[]>;
135
+ passkeyDelete(credentialId: string): Promise<void>;
97
136
  on<K extends AuthonEventType>(event: K, listener: AuthonEvents[K]): () => void;
98
137
  private emit;
99
138
  destroy(): void;
@@ -103,6 +142,7 @@ declare class AuthonMobileClient {
103
142
  private scheduleRefresh;
104
143
  private persistTokens;
105
144
  private toTokenPair;
145
+ private requestAuth;
106
146
  private request;
107
147
  }
108
148
 
@@ -117,7 +157,7 @@ interface AuthonContextValue extends AuthState {
117
157
  /** Branding config (fetched from API) */
118
158
  branding: BrandingConfig | null;
119
159
  /** Start OAuth flow — returns { url, state }. Open url in browser, then call completeOAuth(state) */
120
- startOAuth: (provider: OAuthProviderType, redirectUri?: string) => Promise<{
160
+ startOAuth: (provider: OAuthProviderType, options?: string | StartOAuthOptions) => Promise<{
121
161
  url: string;
122
162
  state: string;
123
163
  }>;
@@ -147,6 +187,55 @@ declare function useUser(): {
147
187
  user: AuthonUser | null;
148
188
  };
149
189
 
190
+ interface Web3LinkWalletParams {
191
+ address: string;
192
+ chain: Web3Chain;
193
+ walletType: Web3WalletType;
194
+ chainId?: number;
195
+ message: string;
196
+ signature: string;
197
+ }
198
+ interface UseAuthonWeb3Return {
199
+ getNonce: (address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number) => Promise<Web3NonceResponse | null>;
200
+ verify: (message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType) => Promise<boolean>;
201
+ getWallets: () => Promise<Web3Wallet[] | null>;
202
+ linkWallet: (params: Web3LinkWalletParams) => Promise<Web3Wallet | null>;
203
+ unlinkWallet: (walletId: string) => Promise<boolean>;
204
+ isLoading: boolean;
205
+ error: Error | null;
206
+ }
207
+ declare function useAuthonWeb3(): UseAuthonWeb3Return;
208
+
209
+ interface UseAuthonPasswordlessReturn {
210
+ sendCode: (identifier: string, type?: 'email' | 'sms') => Promise<boolean>;
211
+ verifyCode: (identifier: string, code: string) => Promise<{
212
+ tokens: TokenPair;
213
+ user: AuthonUser;
214
+ } | null>;
215
+ isLoading: boolean;
216
+ error: Error | null;
217
+ }
218
+ declare function useAuthonPasswordless(): UseAuthonPasswordlessReturn;
219
+
220
+ interface UseAuthonPasskeysReturn {
221
+ startRegister: (name?: string) => Promise<{
222
+ options: Record<string, unknown>;
223
+ } | null>;
224
+ completeRegister: (credential: Record<string, unknown>) => Promise<PasskeyCredential | null>;
225
+ startAuth: (email?: string) => Promise<{
226
+ options: Record<string, unknown>;
227
+ } | null>;
228
+ completeAuth: (credential: Record<string, unknown>) => Promise<{
229
+ tokens: TokenPair;
230
+ user: AuthonUser;
231
+ } | null>;
232
+ listPasskeys: () => Promise<PasskeyCredential[] | null>;
233
+ deletePasskey: (credentialId: string) => Promise<boolean>;
234
+ isLoading: boolean;
235
+ error: Error | null;
236
+ }
237
+ declare function useAuthonPasskeys(): UseAuthonPasskeysReturn;
238
+
150
239
  interface IconProps {
151
240
  size?: number;
152
241
  color?: string;
@@ -197,4 +286,4 @@ interface SocialButtonsProps {
197
286
  }
198
287
  declare function SocialButtons({ onSuccess, onError, style, gap, compact, labels, buttonProps, }: SocialButtonsProps): react_jsx_runtime.JSX.Element | null;
199
288
 
200
- export { type AuthState, AuthonContext, type AuthonContextValue, type AuthonEventType, type AuthonEvents, AuthonMobileClient, AuthonProvider, type AuthonReactNativeConfig, type AuthonUser, ProviderIcon, type SignInParams, type SignUpParams, SocialButton, type SocialButtonProps, SocialButtons, type SocialButtonsProps, type TokenPair, useAuthon, useUser };
289
+ export { type AuthState, AuthonContext, type AuthonContextValue, type AuthonEventType, type AuthonEvents, AuthonMobileClient, AuthonProvider, type AuthonReactNativeConfig, type AuthonUser, 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 };
package/dist/index.js CHANGED
@@ -141,8 +141,14 @@ var AuthonMobileClient = class {
141
141
  await this.ensureInitialized();
142
142
  return this._branding;
143
143
  }
144
- async getOAuthUrl(provider, redirectUri) {
145
- const params = new URLSearchParams({ redirectUri, flow: "redirect" });
144
+ async getOAuthUrl(provider, options) {
145
+ const normalized = typeof options === "string" ? { redirectUri: options } : options ?? {};
146
+ const redirectUri = normalized.redirectUri || `${this.apiUrl}/v1/auth/oauth/redirect`;
147
+ const flow = normalized.flow || "redirect";
148
+ const params = new URLSearchParams({ redirectUri, flow });
149
+ if (normalized.returnTo) {
150
+ params.set("returnTo", normalized.returnTo);
151
+ }
146
152
  return await this.request(
147
153
  "GET",
148
154
  `/v1/auth/oauth/${provider}/url?${params.toString()}`
@@ -184,6 +190,100 @@ var AuthonMobileClient = class {
184
190
  getApiUrl() {
185
191
  return this.apiUrl;
186
192
  }
193
+ // ── Web3 ──
194
+ async web3GetNonce(address, chain, walletType, chainId) {
195
+ return this.request("POST", "/v1/auth/web3/nonce", {
196
+ address,
197
+ chain,
198
+ walletType,
199
+ ...chainId != null ? { chainId } : {}
200
+ });
201
+ }
202
+ async web3Verify(message, signature, address, chain, walletType) {
203
+ const res = await this.request("POST", "/v1/auth/web3/verify", {
204
+ message,
205
+ signature,
206
+ address,
207
+ chain,
208
+ walletType
209
+ });
210
+ this.tokens = this.toTokenPair(res);
211
+ this.user = res.user;
212
+ await this.persistTokens();
213
+ this.scheduleRefresh(this.tokens.expiresAt);
214
+ this.emit("signedIn", res.user);
215
+ return { tokens: this.tokens, user: res.user };
216
+ }
217
+ async web3GetWallets() {
218
+ return this.request("GET", "/v1/auth/web3/wallets");
219
+ }
220
+ async web3LinkWallet(params) {
221
+ return this.request("POST", "/v1/auth/web3/wallets/link", params);
222
+ }
223
+ async web3UnlinkWallet(walletId) {
224
+ await this.requestAuth("DELETE", `/v1/auth/web3/wallets/${walletId}`);
225
+ }
226
+ // ── Passwordless ──
227
+ async passwordlessSendCode(identifier, type = "email") {
228
+ if (type === "sms") {
229
+ await this.request("POST", "/v1/auth/passwordless/sms-otp", { phone: identifier });
230
+ } else {
231
+ await this.request("POST", "/v1/auth/passwordless/email-otp", { email: identifier });
232
+ }
233
+ }
234
+ async passwordlessVerifyCode(identifier, code) {
235
+ const res = await this.request("POST", "/v1/auth/passwordless/verify", {
236
+ email: identifier,
237
+ code
238
+ });
239
+ this.tokens = this.toTokenPair(res);
240
+ this.user = res.user;
241
+ await this.persistTokens();
242
+ this.scheduleRefresh(this.tokens.expiresAt);
243
+ this.emit("signedIn", res.user);
244
+ return { tokens: this.tokens, user: res.user };
245
+ }
246
+ // ── Passkeys ──
247
+ async passkeyStartRegister(name) {
248
+ return this.requestAuth(
249
+ "POST",
250
+ "/v1/auth/passkeys/register/options",
251
+ name ? { name } : void 0
252
+ );
253
+ }
254
+ async passkeyCompleteRegister(credential) {
255
+ return this.requestAuth(
256
+ "POST",
257
+ "/v1/auth/passkeys/register/verify",
258
+ credential
259
+ );
260
+ }
261
+ async passkeyStartAuth(email) {
262
+ return this.request(
263
+ "POST",
264
+ "/v1/auth/passkeys/authenticate/options",
265
+ email ? { email } : void 0
266
+ );
267
+ }
268
+ async passkeyCompleteAuth(credential) {
269
+ const res = await this.request(
270
+ "POST",
271
+ "/v1/auth/passkeys/authenticate/verify",
272
+ credential
273
+ );
274
+ this.tokens = this.toTokenPair(res);
275
+ this.user = res.user;
276
+ await this.persistTokens();
277
+ this.scheduleRefresh(this.tokens.expiresAt);
278
+ this.emit("signedIn", res.user);
279
+ return { tokens: this.tokens, user: res.user };
280
+ }
281
+ async passkeyList() {
282
+ return this.requestAuth("GET", "/v1/auth/passkeys");
283
+ }
284
+ async passkeyDelete(credentialId) {
285
+ await this.requestAuth("DELETE", `/v1/auth/passkeys/${credentialId}`);
286
+ }
187
287
  // ── Event system ──
188
288
  on(event, listener) {
189
289
  if (!this.listeners.has(event)) this.listeners.set(event, /* @__PURE__ */ new Set());
@@ -236,6 +336,10 @@ var AuthonMobileClient = class {
236
336
  expiresAt: Date.now() + res.expiresIn * 1e3
237
337
  };
238
338
  }
339
+ async requestAuth(method, path, body) {
340
+ if (!this.tokens?.accessToken) throw new Error("Must be signed in");
341
+ return this.request(method, path, body);
342
+ }
239
343
  async request(method, path, body) {
240
344
  const headers = {
241
345
  "Content-Type": "application/json",
@@ -356,9 +460,8 @@ function AuthonProvider({ children, storage, ...config }) {
356
460
  return client.getAccessToken();
357
461
  }, [client]);
358
462
  const startOAuth = useCallback(
359
- async (provider, redirectUri) => {
360
- const uri = redirectUri || `${client.getApiUrl()}/v1/auth/oauth/redirect`;
361
- return client.getOAuthUrl(provider, uri);
463
+ async (provider, options) => {
464
+ return client.getOAuthUrl(provider, options);
362
465
  },
363
466
  [client]
364
467
  );
@@ -418,6 +521,160 @@ function useUser() {
418
521
  return { isLoaded, isSignedIn, user };
419
522
  }
420
523
 
524
+ // src/useAuthonWeb3.ts
525
+ import { useCallback as useCallback2, useContext as useContext2, useState as useState2 } from "react";
526
+ function useAuthonWeb3() {
527
+ const ctx = useContext2(AuthonContext);
528
+ if (!ctx) throw new Error("useAuthonWeb3 must be used within <AuthonProvider>");
529
+ const [isLoading, setIsLoading] = useState2(false);
530
+ const [error, setError] = useState2(null);
531
+ const wrap = useCallback2(async (fn) => {
532
+ setIsLoading(true);
533
+ setError(null);
534
+ try {
535
+ return await fn();
536
+ } catch (err) {
537
+ setError(err instanceof Error ? err : new Error(String(err)));
538
+ return null;
539
+ } finally {
540
+ setIsLoading(false);
541
+ }
542
+ }, []);
543
+ const getNonce = useCallback2(
544
+ (address, chain, walletType, chainId) => wrap(() => ctx.client.web3GetNonce(address, chain, walletType, chainId)),
545
+ [ctx.client, wrap]
546
+ );
547
+ const verify = useCallback2(
548
+ async (message, signature, address, chain, walletType) => {
549
+ const result = await wrap(
550
+ () => ctx.client.web3Verify(message, signature, address, chain, walletType)
551
+ );
552
+ return result !== null;
553
+ },
554
+ [ctx.client, wrap]
555
+ );
556
+ const getWallets = useCallback2(
557
+ () => wrap(() => ctx.client.web3GetWallets()),
558
+ [ctx.client, wrap]
559
+ );
560
+ const linkWallet = useCallback2(
561
+ (params) => wrap(() => ctx.client.web3LinkWallet(params)),
562
+ [ctx.client, wrap]
563
+ );
564
+ const unlinkWallet = useCallback2(
565
+ async (walletId) => {
566
+ const result = await wrap(() => ctx.client.web3UnlinkWallet(walletId));
567
+ return result !== null;
568
+ },
569
+ [ctx.client, wrap]
570
+ );
571
+ return {
572
+ getNonce,
573
+ verify,
574
+ getWallets,
575
+ linkWallet,
576
+ unlinkWallet,
577
+ isLoading,
578
+ error
579
+ };
580
+ }
581
+
582
+ // src/useAuthonPasswordless.ts
583
+ import { useCallback as useCallback3, useContext as useContext3, useState as useState3 } from "react";
584
+ function useAuthonPasswordless() {
585
+ const ctx = useContext3(AuthonContext);
586
+ if (!ctx) throw new Error("useAuthonPasswordless must be used within <AuthonProvider>");
587
+ const [isLoading, setIsLoading] = useState3(false);
588
+ const [error, setError] = useState3(null);
589
+ const wrap = useCallback3(async (fn) => {
590
+ setIsLoading(true);
591
+ setError(null);
592
+ try {
593
+ return await fn();
594
+ } catch (err) {
595
+ setError(err instanceof Error ? err : new Error(String(err)));
596
+ return null;
597
+ } finally {
598
+ setIsLoading(false);
599
+ }
600
+ }, []);
601
+ const sendCode = useCallback3(
602
+ async (identifier, type = "email") => {
603
+ const result = await wrap(() => ctx.client.passwordlessSendCode(identifier, type));
604
+ return result !== null;
605
+ },
606
+ [ctx.client, wrap]
607
+ );
608
+ const verifyCode = useCallback3(
609
+ (identifier, code) => wrap(() => ctx.client.passwordlessVerifyCode(identifier, code)),
610
+ [ctx.client, wrap]
611
+ );
612
+ return {
613
+ sendCode,
614
+ verifyCode,
615
+ isLoading,
616
+ error
617
+ };
618
+ }
619
+
620
+ // src/useAuthonPasskeys.ts
621
+ import { useCallback as useCallback4, useContext as useContext4, useState as useState4 } from "react";
622
+ function useAuthonPasskeys() {
623
+ const ctx = useContext4(AuthonContext);
624
+ if (!ctx) throw new Error("useAuthonPasskeys must be used within <AuthonProvider>");
625
+ const [isLoading, setIsLoading] = useState4(false);
626
+ const [error, setError] = useState4(null);
627
+ const wrap = useCallback4(async (fn) => {
628
+ setIsLoading(true);
629
+ setError(null);
630
+ try {
631
+ return await fn();
632
+ } catch (err) {
633
+ setError(err instanceof Error ? err : new Error(String(err)));
634
+ return null;
635
+ } finally {
636
+ setIsLoading(false);
637
+ }
638
+ }, []);
639
+ const startRegister = useCallback4(
640
+ (name) => wrap(() => ctx.client.passkeyStartRegister(name)),
641
+ [ctx.client, wrap]
642
+ );
643
+ const completeRegister = useCallback4(
644
+ (credential) => wrap(() => ctx.client.passkeyCompleteRegister(credential)),
645
+ [ctx.client, wrap]
646
+ );
647
+ const startAuth = useCallback4(
648
+ (email) => wrap(() => ctx.client.passkeyStartAuth(email)),
649
+ [ctx.client, wrap]
650
+ );
651
+ const completeAuth = useCallback4(
652
+ (credential) => wrap(() => ctx.client.passkeyCompleteAuth(credential)),
653
+ [ctx.client, wrap]
654
+ );
655
+ const listPasskeys = useCallback4(
656
+ () => wrap(() => ctx.client.passkeyList()),
657
+ [ctx.client, wrap]
658
+ );
659
+ const deletePasskey = useCallback4(
660
+ async (credentialId) => {
661
+ const result = await wrap(() => ctx.client.passkeyDelete(credentialId));
662
+ return result !== null;
663
+ },
664
+ [ctx.client, wrap]
665
+ );
666
+ return {
667
+ startRegister,
668
+ completeRegister,
669
+ startAuth,
670
+ completeAuth,
671
+ listPasskeys,
672
+ deletePasskey,
673
+ isLoading,
674
+ error
675
+ };
676
+ }
677
+
421
678
  // src/icons.tsx
422
679
  import "react";
423
680
  import Svg, { Path, Rect } from "react-native-svg";
@@ -588,7 +845,7 @@ var styles = StyleSheet.create({
588
845
  });
589
846
 
590
847
  // src/SocialButtons.tsx
591
- import { useState as useState2 } from "react";
848
+ import { useState as useState5 } from "react";
592
849
  import { View, StyleSheet as StyleSheet2, Linking } from "react-native";
593
850
  import { jsx as jsx4 } from "react/jsx-runtime";
594
851
  function SocialButtons({
@@ -601,7 +858,7 @@ function SocialButtons({
601
858
  buttonProps
602
859
  }) {
603
860
  const { providers, startOAuth, completeOAuth } = useAuthon();
604
- const [loadingProvider, setLoadingProvider] = useState2(null);
861
+ const [loadingProvider, setLoadingProvider] = useState5(null);
605
862
  if (providers.length === 0) return null;
606
863
  const resolvedGap = gap ?? (compact ? 12 : 10);
607
864
  const handlePress = async (provider) => {
@@ -660,6 +917,9 @@ export {
660
917
  SocialButton,
661
918
  SocialButtons,
662
919
  useAuthon,
920
+ useAuthonPasskeys,
921
+ useAuthonPasswordless,
922
+ useAuthonWeb3,
663
923
  useUser
664
924
  };
665
925
  //# sourceMappingURL=index.js.map