@fastshot/auth 1.0.1 → 1.0.3

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.
Files changed (47) hide show
  1. package/package.json +3 -4
  2. package/src/auth.ts +216 -0
  3. package/src/constants.ts +56 -0
  4. package/{dist/hooks/index.d.ts → src/hooks/index.ts} +2 -1
  5. package/src/hooks/useAppleSignIn.ts +92 -0
  6. package/src/hooks/useAuthCallback.ts +135 -0
  7. package/src/hooks/useGoogleSignIn.ts +95 -0
  8. package/{dist/index.js → src/index.ts} +42 -3
  9. package/src/types.ts +109 -0
  10. package/src/utils/deepLink.ts +100 -0
  11. package/src/utils/index.ts +14 -0
  12. package/src/utils/session.ts +45 -0
  13. package/src/utils/ticketExchange.ts +84 -0
  14. package/dist/auth.d.ts +0 -82
  15. package/dist/auth.d.ts.map +0 -1
  16. package/dist/auth.js +0 -149
  17. package/dist/constants.d.ts +0 -38
  18. package/dist/constants.d.ts.map +0 -1
  19. package/dist/constants.js +0 -48
  20. package/dist/hooks/index.d.ts.map +0 -1
  21. package/dist/hooks/index.js +0 -3
  22. package/dist/hooks/useAppleSignIn.d.ts +0 -47
  23. package/dist/hooks/useAppleSignIn.d.ts.map +0 -1
  24. package/dist/hooks/useAppleSignIn.js +0 -60
  25. package/dist/hooks/useAuthCallback.d.ts +0 -56
  26. package/dist/hooks/useAuthCallback.d.ts.map +0 -1
  27. package/dist/hooks/useAuthCallback.js +0 -97
  28. package/dist/hooks/useGoogleSignIn.d.ts +0 -49
  29. package/dist/hooks/useGoogleSignIn.d.ts.map +0 -1
  30. package/dist/hooks/useGoogleSignIn.js +0 -61
  31. package/dist/index.d.ts +0 -61
  32. package/dist/index.d.ts.map +0 -1
  33. package/dist/types.d.ts +0 -95
  34. package/dist/types.d.ts.map +0 -1
  35. package/dist/types.js +0 -1
  36. package/dist/utils/deepLink.d.ts +0 -26
  37. package/dist/utils/deepLink.d.ts.map +0 -1
  38. package/dist/utils/deepLink.js +0 -55
  39. package/dist/utils/index.d.ts +0 -4
  40. package/dist/utils/index.d.ts.map +0 -1
  41. package/dist/utils/index.js +0 -3
  42. package/dist/utils/session.d.ts +0 -7
  43. package/dist/utils/session.d.ts.map +0 -1
  44. package/dist/utils/session.js +0 -25
  45. package/dist/utils/ticketExchange.d.ts +0 -14
  46. package/dist/utils/ticketExchange.d.ts.map +0 -1
  47. package/dist/utils/ticketExchange.js +0 -54
@@ -1,47 +0,0 @@
1
- import type { SupabaseClient } from '@supabase/supabase-js';
2
- import type { AuthError, AuthMode } from '../types';
3
- export interface UseAppleSignInConfig {
4
- /** Supabase client instance */
5
- supabaseClient: SupabaseClient;
6
- /** Custom return URL */
7
- returnTo?: string;
8
- /** Auth mode */
9
- mode?: AuthMode;
10
- /** Callback on error */
11
- onError?: (error: AuthError) => void;
12
- }
13
- export interface UseAppleSignInResult {
14
- /** Trigger Apple sign-in */
15
- signIn: () => Promise<void>;
16
- /** Whether sign-in is in progress */
17
- isLoading: boolean;
18
- /** Error from last sign-in attempt */
19
- error: AuthError | null;
20
- /** Reset error state */
21
- reset: () => void;
22
- }
23
- /**
24
- * React hook for Apple sign-in with auth-broker
25
- *
26
- * @example
27
- * ```tsx
28
- * import { useAppleSignIn } from '@fastshot/auth';
29
- * import { supabase } from '../lib/supabase';
30
- *
31
- * function LoginScreen() {
32
- * const { signIn, isLoading, error } = useAppleSignIn({
33
- * supabaseClient: supabase,
34
- * });
35
- *
36
- * return (
37
- * <Button
38
- * title={isLoading ? 'Signing in...' : 'Sign in with Apple'}
39
- * onPress={signIn}
40
- * disabled={isLoading}
41
- * />
42
- * );
43
- * }
44
- * ```
45
- */
46
- export declare function useAppleSignIn(config: UseAppleSignInConfig): UseAppleSignInResult;
47
- //# sourceMappingURL=useAppleSignIn.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAppleSignIn.d.ts","sourceRoot":"","sources":["../../src/hooks/useAppleSignIn.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpD,MAAM,WAAW,oBAAoB;IACnC,+BAA+B;IAC/B,cAAc,EAAE,cAAc,CAAC;IAC/B,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,oBAAoB;IACnC,4BAA4B;IAC5B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,qCAAqC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,wBAAwB;IACxB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAwCjF"}
@@ -1,60 +0,0 @@
1
- import { useState, useCallback } from 'react';
2
- import { signInWithApple } from '../auth';
3
- import { isAuthError, createAuthError } from '../utils';
4
- /**
5
- * React hook for Apple sign-in with auth-broker
6
- *
7
- * @example
8
- * ```tsx
9
- * import { useAppleSignIn } from '@fastshot/auth';
10
- * import { supabase } from '../lib/supabase';
11
- *
12
- * function LoginScreen() {
13
- * const { signIn, isLoading, error } = useAppleSignIn({
14
- * supabaseClient: supabase,
15
- * });
16
- *
17
- * return (
18
- * <Button
19
- * title={isLoading ? 'Signing in...' : 'Sign in with Apple'}
20
- * onPress={signIn}
21
- * disabled={isLoading}
22
- * />
23
- * );
24
- * }
25
- * ```
26
- */
27
- export function useAppleSignIn(config) {
28
- const [isLoading, setIsLoading] = useState(false);
29
- const [error, setError] = useState(null);
30
- const signIn = useCallback(async () => {
31
- setIsLoading(true);
32
- setError(null);
33
- try {
34
- await signInWithApple({
35
- supabaseClient: config.supabaseClient,
36
- returnTo: config.returnTo,
37
- mode: config.mode,
38
- });
39
- }
40
- catch (err) {
41
- const authError = isAuthError(err)
42
- ? err
43
- : createAuthError('UNKNOWN_ERROR', err instanceof Error ? err.message : 'Unknown error', err);
44
- setError(authError);
45
- config.onError?.(authError);
46
- }
47
- finally {
48
- setIsLoading(false);
49
- }
50
- }, [config]);
51
- const reset = useCallback(() => {
52
- setError(null);
53
- }, []);
54
- return {
55
- signIn,
56
- isLoading,
57
- error,
58
- reset,
59
- };
60
- }
@@ -1,56 +0,0 @@
1
- import type { SupabaseClient, Session, User } from '@supabase/supabase-js';
2
- import type { AuthError, AuthCallbackResult } from '../types';
3
- export interface UseAuthCallbackConfig {
4
- /** Supabase client instance */
5
- supabaseClient: SupabaseClient;
6
- /** Callback when authentication succeeds */
7
- onSuccess?: (result: {
8
- session: Session;
9
- user: User;
10
- }) => void;
11
- /** Callback when authentication fails */
12
- onError?: (error: AuthError) => void;
13
- /** Whether to automatically listen for deep links (default: true) */
14
- autoListen?: boolean;
15
- }
16
- export interface UseAuthCallbackResult {
17
- /** Whether callback is being processed */
18
- isProcessing: boolean;
19
- /** Error if callback processing failed */
20
- error: AuthError | null;
21
- /** Manually handle a callback URL */
22
- handleUrl: (url: string) => Promise<AuthCallbackResult>;
23
- }
24
- /**
25
- * React hook to handle OAuth callback deep links
26
- *
27
- * This hook automatically listens for deep link callbacks and restores
28
- * the Supabase session when authentication completes.
29
- *
30
- * @example
31
- * ```tsx
32
- * import { useAuthCallback } from '@fastshot/auth';
33
- * import { supabase } from '../lib/supabase';
34
- *
35
- * function App() {
36
- * const { isProcessing, error } = useAuthCallback({
37
- * supabaseClient: supabase,
38
- * onSuccess: ({ user }) => {
39
- * console.log('Logged in:', user.email);
40
- * navigation.navigate('Home');
41
- * },
42
- * onError: (error) => {
43
- * Alert.alert('Login Failed', error.message);
44
- * },
45
- * });
46
- *
47
- * if (isProcessing) {
48
- * return <LoadingScreen message="Completing sign-in..." />;
49
- * }
50
- *
51
- * return <MainApp />;
52
- * }
53
- * ```
54
- */
55
- export declare function useAuthCallback(config: UseAuthCallbackConfig): UseAuthCallbackResult;
56
- //# sourceMappingURL=useAuthCallback.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAuthCallback.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuthCallback.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAG3E,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9D,MAAM,WAAW,qBAAqB;IACpC,+BAA+B;IAC/B,cAAc,EAAE,cAAc,CAAC;IAC/B,4CAA4C;IAC5C,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/D,yCAAyC;IACzC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACrC,qEAAqE;IACrE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,YAAY,EAAE,OAAO,CAAC;IACtB,0CAA0C;IAC1C,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,qCAAqC;IACrC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACzD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,qBAAqB,CA2EpF"}
@@ -1,97 +0,0 @@
1
- import { useState, useEffect, useCallback } from 'react';
2
- import * as Linking from 'expo-linking';
3
- import { handleAuthCallback } from '../auth';
4
- import { isAuthCallbackUrl } from '../utils';
5
- import { createAuthError } from '../utils';
6
- /**
7
- * React hook to handle OAuth callback deep links
8
- *
9
- * This hook automatically listens for deep link callbacks and restores
10
- * the Supabase session when authentication completes.
11
- *
12
- * @example
13
- * ```tsx
14
- * import { useAuthCallback } from '@fastshot/auth';
15
- * import { supabase } from '../lib/supabase';
16
- *
17
- * function App() {
18
- * const { isProcessing, error } = useAuthCallback({
19
- * supabaseClient: supabase,
20
- * onSuccess: ({ user }) => {
21
- * console.log('Logged in:', user.email);
22
- * navigation.navigate('Home');
23
- * },
24
- * onError: (error) => {
25
- * Alert.alert('Login Failed', error.message);
26
- * },
27
- * });
28
- *
29
- * if (isProcessing) {
30
- * return <LoadingScreen message="Completing sign-in..." />;
31
- * }
32
- *
33
- * return <MainApp />;
34
- * }
35
- * ```
36
- */
37
- export function useAuthCallback(config) {
38
- const { supabaseClient, onSuccess, onError, autoListen = true } = config;
39
- const [isProcessing, setIsProcessing] = useState(false);
40
- const [error, setError] = useState(null);
41
- const handleUrl = useCallback(async (url) => {
42
- // Skip if not an auth callback URL
43
- if (!isAuthCallbackUrl(url)) {
44
- return { success: false, error: 'Not an auth callback URL' };
45
- }
46
- setIsProcessing(true);
47
- setError(null);
48
- try {
49
- const result = await handleAuthCallback(url, supabaseClient);
50
- if (result.success && result.session && result.user) {
51
- onSuccess?.({ session: result.session, user: result.user });
52
- }
53
- else if (!result.success && result.error) {
54
- const authError = createAuthError('CALLBACK_ERROR', result.error);
55
- setError(authError);
56
- onError?.(authError);
57
- }
58
- return result;
59
- }
60
- catch (err) {
61
- const authError = createAuthError('CALLBACK_ERROR', err instanceof Error ? err.message : 'Failed to process callback', err);
62
- setError(authError);
63
- onError?.(authError);
64
- return { success: false, error: authError.message };
65
- }
66
- finally {
67
- setIsProcessing(false);
68
- }
69
- }, [supabaseClient, onSuccess, onError]);
70
- // Auto-listen for deep links
71
- useEffect(() => {
72
- if (!autoListen)
73
- return;
74
- // Handle URL that opened the app
75
- const checkInitialUrl = async () => {
76
- const initialUrl = await Linking.getInitialURL();
77
- if (initialUrl && isAuthCallbackUrl(initialUrl)) {
78
- handleUrl(initialUrl);
79
- }
80
- };
81
- checkInitialUrl();
82
- // Listen for incoming URLs while app is running
83
- const subscription = Linking.addEventListener('url', ({ url }) => {
84
- if (isAuthCallbackUrl(url)) {
85
- handleUrl(url);
86
- }
87
- });
88
- return () => {
89
- subscription.remove();
90
- };
91
- }, [autoListen, handleUrl]);
92
- return {
93
- isProcessing,
94
- error,
95
- handleUrl,
96
- };
97
- }
@@ -1,49 +0,0 @@
1
- import type { SupabaseClient } from '@supabase/supabase-js';
2
- import type { AuthError, AuthMode } from '../types';
3
- export interface UseGoogleSignInConfig {
4
- /** Supabase client instance */
5
- supabaseClient: SupabaseClient;
6
- /** Custom return URL */
7
- returnTo?: string;
8
- /** Auth mode */
9
- mode?: AuthMode;
10
- /** Email hint */
11
- loginHint?: string;
12
- /** Callback on error */
13
- onError?: (error: AuthError) => void;
14
- }
15
- export interface UseGoogleSignInResult {
16
- /** Trigger Google sign-in */
17
- signIn: () => Promise<void>;
18
- /** Whether sign-in is in progress */
19
- isLoading: boolean;
20
- /** Error from last sign-in attempt */
21
- error: AuthError | null;
22
- /** Reset error state */
23
- reset: () => void;
24
- }
25
- /**
26
- * React hook for Google sign-in with auth-broker
27
- *
28
- * @example
29
- * ```tsx
30
- * import { useGoogleSignIn } from '@fastshot/auth';
31
- * import { supabase } from '../lib/supabase';
32
- *
33
- * function LoginScreen() {
34
- * const { signIn, isLoading, error } = useGoogleSignIn({
35
- * supabaseClient: supabase,
36
- * });
37
- *
38
- * return (
39
- * <Button
40
- * title={isLoading ? 'Signing in...' : 'Sign in with Google'}
41
- * onPress={signIn}
42
- * disabled={isLoading}
43
- * />
44
- * );
45
- * }
46
- * ```
47
- */
48
- export declare function useGoogleSignIn(config: UseGoogleSignInConfig): UseGoogleSignInResult;
49
- //# sourceMappingURL=useGoogleSignIn.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGoogleSignIn.d.ts","sourceRoot":"","sources":["../../src/hooks/useGoogleSignIn.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpD,MAAM,WAAW,qBAAqB;IACpC,+BAA+B;IAC/B,cAAc,EAAE,cAAc,CAAC;IAC/B,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,qBAAqB;IACpC,6BAA6B;IAC7B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,qCAAqC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,wBAAwB;IACxB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,qBAAqB,CAyCpF"}
@@ -1,61 +0,0 @@
1
- import { useState, useCallback } from 'react';
2
- import { signInWithGoogle } from '../auth';
3
- import { isAuthError, createAuthError } from '../utils';
4
- /**
5
- * React hook for Google sign-in with auth-broker
6
- *
7
- * @example
8
- * ```tsx
9
- * import { useGoogleSignIn } from '@fastshot/auth';
10
- * import { supabase } from '../lib/supabase';
11
- *
12
- * function LoginScreen() {
13
- * const { signIn, isLoading, error } = useGoogleSignIn({
14
- * supabaseClient: supabase,
15
- * });
16
- *
17
- * return (
18
- * <Button
19
- * title={isLoading ? 'Signing in...' : 'Sign in with Google'}
20
- * onPress={signIn}
21
- * disabled={isLoading}
22
- * />
23
- * );
24
- * }
25
- * ```
26
- */
27
- export function useGoogleSignIn(config) {
28
- const [isLoading, setIsLoading] = useState(false);
29
- const [error, setError] = useState(null);
30
- const signIn = useCallback(async () => {
31
- setIsLoading(true);
32
- setError(null);
33
- try {
34
- await signInWithGoogle({
35
- supabaseClient: config.supabaseClient,
36
- returnTo: config.returnTo,
37
- mode: config.mode,
38
- loginHint: config.loginHint,
39
- });
40
- }
41
- catch (err) {
42
- const authError = isAuthError(err)
43
- ? err
44
- : createAuthError('UNKNOWN_ERROR', err instanceof Error ? err.message : 'Unknown error', err);
45
- setError(authError);
46
- config.onError?.(authError);
47
- }
48
- finally {
49
- setIsLoading(false);
50
- }
51
- }, [config]);
52
- const reset = useCallback(() => {
53
- setError(null);
54
- }, []);
55
- return {
56
- signIn,
57
- isLoading,
58
- error,
59
- reset,
60
- };
61
- }
package/dist/index.d.ts DELETED
@@ -1,61 +0,0 @@
1
- /**
2
- * @fastshot/auth - OAuth authentication SDK for Expo React Native
3
- *
4
- * Provides Google and Apple OAuth authentication via Fastshot's auth-broker,
5
- * with automatic Supabase session restoration.
6
- *
7
- * @example
8
- * ```tsx
9
- * // Using hooks (recommended)
10
- * import { useGoogleSignIn, useAppleSignIn, useAuthCallback } from '@fastshot/auth';
11
- * import { supabase } from './lib/supabase';
12
- *
13
- * function App() {
14
- * // Handle OAuth callbacks automatically
15
- * useAuthCallback({
16
- * supabaseClient: supabase,
17
- * onSuccess: ({ user }) => console.log('Logged in:', user.email),
18
- * });
19
- *
20
- * return <LoginScreen />;
21
- * }
22
- *
23
- * function LoginScreen() {
24
- * const { signIn: googleSignIn, isLoading: googleLoading } = useGoogleSignIn({
25
- * supabaseClient: supabase,
26
- * });
27
- *
28
- * const { signIn: appleSignIn, isLoading: appleLoading } = useAppleSignIn({
29
- * supabaseClient: supabase,
30
- * });
31
- *
32
- * return (
33
- * <View>
34
- * <Button title="Sign in with Google" onPress={googleSignIn} />
35
- * <Button title="Sign in with Apple" onPress={appleSignIn} />
36
- * </View>
37
- * );
38
- * }
39
- * ```
40
- *
41
- * @example
42
- * ```typescript
43
- * // Using standalone functions
44
- * import { signInWithGoogle, handleAuthCallback } from '@fastshot/auth';
45
- * import { supabase } from './lib/supabase';
46
- *
47
- * // Trigger sign-in
48
- * await signInWithGoogle({ supabaseClient: supabase });
49
- *
50
- * // Handle callback (in your deep link handler)
51
- * const result = await handleAuthCallback(url, supabase);
52
- * ```
53
- */
54
- export { signInWithGoogle, signInWithApple, handleAuthCallback, signOut, } from './auth';
55
- export type { SignInOptions } from './auth';
56
- export { useGoogleSignIn, useAppleSignIn, useAuthCallback, } from './hooks';
57
- export type { UseGoogleSignInConfig, UseGoogleSignInResult, UseAppleSignInConfig, UseAppleSignInResult, UseAuthCallbackConfig, UseAuthCallbackResult, } from './hooks';
58
- export { exchangeTicket, isAuthCallbackUrl, parseCallbackUrl, getDefaultCallbackUrl, createAuthError, isAuthError, } from './utils';
59
- export type { OAuthProvider, AuthMode, AuthError, AuthErrorType, AuthCallbackResult, ExchangeTicketResponse, } from './types';
60
- export { AUTH_CONFIG, AUTH_ENDPOINTS } from './constants';
61
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAGH,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,OAAO,GACR,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAG5C,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,WAAW,GACZ,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,aAAa,EACb,QAAQ,EACR,SAAS,EACT,aAAa,EACb,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,95 +0,0 @@
1
- import type { SupabaseClient, User, Session } from '@supabase/supabase-js';
2
- /**
3
- * OAuth provider type
4
- */
5
- export type OAuthProvider = 'google' | 'apple';
6
- /**
7
- * Authentication mode
8
- * - browser: Opens system browser (recommended for most cases)
9
- * - webview: Opens in-app WebView (may have limitations)
10
- */
11
- export type AuthMode = 'browser' | 'webview';
12
- /**
13
- * Configuration for OAuth sign-in
14
- */
15
- export interface SignInConfig {
16
- /** Supabase client instance for session restoration */
17
- supabaseClient: SupabaseClient;
18
- /** Custom return URL (defaults to fastshot://auth/callback) */
19
- returnTo?: string;
20
- /** Auth mode: 'browser' (default) or 'webview' */
21
- mode?: AuthMode;
22
- /** Email hint for Google sign-in */
23
- loginHint?: string;
24
- }
25
- /**
26
- * Response from ticket exchange
27
- */
28
- export interface ExchangeTicketResponse {
29
- access_token: string;
30
- refresh_token: string;
31
- token_type: string;
32
- expires_in: number;
33
- user: User;
34
- }
35
- /**
36
- * Result from OAuth callback handling
37
- */
38
- export interface AuthCallbackResult {
39
- success: boolean;
40
- session?: Session;
41
- user?: User;
42
- error?: string;
43
- }
44
- /**
45
- * Error types for authentication
46
- */
47
- export type AuthErrorType = 'INVALID_TICKET' | 'EXCHANGE_FAILED' | 'SESSION_RESTORE_FAILED' | 'CALLBACK_ERROR' | 'BROWSER_DISMISSED' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
48
- /**
49
- * Authentication error with type
50
- */
51
- export interface AuthError {
52
- type: AuthErrorType;
53
- message: string;
54
- originalError?: unknown;
55
- }
56
- /**
57
- * State for auth hooks
58
- */
59
- export interface AuthHookState {
60
- isLoading: boolean;
61
- error: AuthError | null;
62
- }
63
- /**
64
- * Result from useGoogleSignIn or useAppleSignIn hooks
65
- */
66
- export interface UseSignInResult extends AuthHookState {
67
- signIn: () => Promise<void>;
68
- reset: () => void;
69
- }
70
- /**
71
- * Configuration for useAuthCallback hook
72
- */
73
- export interface UseAuthCallbackConfig {
74
- /** Supabase client instance */
75
- supabaseClient: SupabaseClient;
76
- /** Callback when authentication succeeds */
77
- onSuccess?: (result: {
78
- session: Session;
79
- user: User;
80
- }) => void;
81
- /** Callback when authentication fails */
82
- onError?: (error: AuthError) => void;
83
- }
84
- /**
85
- * Result from useAuthCallback hook
86
- */
87
- export interface UseAuthCallbackResult {
88
- /** Whether callback is being processed */
89
- isProcessing: boolean;
90
- /** Error if callback processing failed */
91
- error: AuthError | null;
92
- /** Manually handle a callback URL */
93
- handleUrl: (url: string) => Promise<AuthCallbackResult>;
94
- }
95
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,cAAc,EAAE,cAAc,CAAC;IAC/B,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,gBAAgB,GAChB,iBAAiB,GACjB,wBAAwB,GACxB,gBAAgB,GAChB,mBAAmB,GACnB,eAAe,GACf,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,+BAA+B;IAC/B,cAAc,EAAE,cAAc,CAAC;IAC/B,4CAA4C;IAC5C,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/D,yCAAyC;IACzC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,YAAY,EAAE,OAAO,CAAC;IACtB,0CAA0C;IAC1C,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,qCAAqC;IACrC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACzD"}
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- /**
2
- * Get the default callback URL for OAuth
3
- */
4
- export declare function getDefaultCallbackUrl(): string;
5
- /**
6
- * Parse OAuth callback URL and extract parameters
7
- */
8
- export declare function parseCallbackUrl(url: string): {
9
- ticket?: string;
10
- error?: string;
11
- errorDescription?: string;
12
- };
13
- /**
14
- * Check if a URL is a valid auth callback URL
15
- */
16
- export declare function isAuthCallbackUrl(url: string): boolean;
17
- /**
18
- * Build the OAuth start URL
19
- */
20
- export declare function buildOAuthStartUrl(provider: 'google' | 'apple', params: {
21
- tenant: string;
22
- returnTo: string;
23
- mode?: 'browser' | 'webview';
24
- loginHint?: string;
25
- }): string;
26
- //# sourceMappingURL=deepLink.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deepLink.d.ts","sourceRoot":"","sources":["../../src/utils/deepLink.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAuBA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAKtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,GAAG,OAAO,EAC5B,MAAM,EAAE;IACN,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,MAAM,CAaR"}
@@ -1,55 +0,0 @@
1
- import { AUTH_CONFIG } from '../constants';
2
- /**
3
- * Get the default callback URL for OAuth
4
- */
5
- export function getDefaultCallbackUrl() {
6
- return `${AUTH_CONFIG.DEEP_LINK_SCHEME}://${AUTH_CONFIG.CALLBACK_PATH}`;
7
- }
8
- /**
9
- * Parse OAuth callback URL and extract parameters
10
- */
11
- export function parseCallbackUrl(url) {
12
- try {
13
- // Handle both URL formats:
14
- // fastshot://auth/callback?ticket=xxx
15
- // fastshot://auth/callback?error=xxx&error_description=xxx
16
- // Extract query string
17
- const queryStart = url.indexOf('?');
18
- if (queryStart === -1) {
19
- return {};
20
- }
21
- const queryString = url.substring(queryStart + 1);
22
- const params = new URLSearchParams(queryString);
23
- return {
24
- ticket: params.get('ticket') || undefined,
25
- error: params.get('error') || undefined,
26
- errorDescription: params.get('error_description') || undefined,
27
- };
28
- }
29
- catch {
30
- return {};
31
- }
32
- }
33
- /**
34
- * Check if a URL is a valid auth callback URL
35
- */
36
- export function isAuthCallbackUrl(url) {
37
- if (!url)
38
- return false;
39
- const expectedPrefix = `${AUTH_CONFIG.DEEP_LINK_SCHEME}://${AUTH_CONFIG.CALLBACK_PATH}`;
40
- return url.startsWith(expectedPrefix);
41
- }
42
- /**
43
- * Build the OAuth start URL
44
- */
45
- export function buildOAuthStartUrl(provider, params) {
46
- const endpoint = provider === 'google' ? '/v1/auth/google/start' : '/v1/auth/apple/start';
47
- const url = new URL(endpoint, AUTH_CONFIG.AUTH_BROKER_URL);
48
- url.searchParams.set('tenant', params.tenant);
49
- url.searchParams.set('return_to', params.returnTo);
50
- url.searchParams.set('mode', params.mode || 'browser');
51
- if (params.loginHint && provider === 'google') {
52
- url.searchParams.set('login_hint', params.loginHint);
53
- }
54
- return url.toString();
55
- }
@@ -1,4 +0,0 @@
1
- export { getDefaultCallbackUrl, parseCallbackUrl, isAuthCallbackUrl, buildOAuthStartUrl, } from './deepLink';
2
- export { exchangeTicket, createAuthError, isAuthError, } from './ticketExchange';
3
- export { restoreSession } from './session';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,cAAc,EACd,eAAe,EACf,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
@@ -1,3 +0,0 @@
1
- export { getDefaultCallbackUrl, parseCallbackUrl, isAuthCallbackUrl, buildOAuthStartUrl, } from './deepLink';
2
- export { exchangeTicket, createAuthError, isAuthError, } from './ticketExchange';
3
- export { restoreSession } from './session';
@@ -1,7 +0,0 @@
1
- import type { SupabaseClient, Session } from '@supabase/supabase-js';
2
- import type { ExchangeTicketResponse } from '../types';
3
- /**
4
- * Restore a Supabase session from exchange response
5
- */
6
- export declare function restoreSession(supabaseClient: SupabaseClient, exchangeResponse: ExchangeTicketResponse): Promise<Session>;
7
- //# sourceMappingURL=session.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,sBAAsB,EAAa,MAAM,UAAU,CAAC;AAGlE;;GAEG;AACH,wBAAsB,cAAc,CAClC,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,sBAAsB,GACvC,OAAO,CAAC,OAAO,CAAC,CAkClB"}