@thoughtbot/react-native-social-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.
Files changed (52) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +316 -0
  3. package/ReactNativeSocialAuth.podspec +22 -0
  4. package/android/build.gradle +70 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/thoughtbot/reactnativesocialauth/GoogleSignInModule.kt +188 -0
  7. package/android/src/main/java/com/thoughtbot/reactnativesocialauth/ReactNativeSocialAuthPackage.kt +31 -0
  8. package/ios/GoogleSignIn.h +7 -0
  9. package/ios/GoogleSignIn.mm +213 -0
  10. package/lib/module/google/GoogleLogo.js +41 -0
  11. package/lib/module/google/GoogleLogo.js.map +1 -0
  12. package/lib/module/google/GoogleSignIn.js +124 -0
  13. package/lib/module/google/GoogleSignIn.js.map +1 -0
  14. package/lib/module/google/GoogleSignInButton.js +176 -0
  15. package/lib/module/google/GoogleSignInButton.js.map +1 -0
  16. package/lib/module/google/NativeGoogleSignIn.js +5 -0
  17. package/lib/module/google/NativeGoogleSignIn.js.map +1 -0
  18. package/lib/module/google/errors.js +69 -0
  19. package/lib/module/google/errors.js.map +1 -0
  20. package/lib/module/google/index.js +6 -0
  21. package/lib/module/google/index.js.map +1 -0
  22. package/lib/module/google/types.js +2 -0
  23. package/lib/module/google/types.js.map +1 -0
  24. package/lib/module/index.js +4 -0
  25. package/lib/module/index.js.map +1 -0
  26. package/lib/module/package.json +1 -0
  27. package/lib/typescript/package.json +1 -0
  28. package/lib/typescript/src/google/GoogleLogo.d.ts +6 -0
  29. package/lib/typescript/src/google/GoogleLogo.d.ts.map +1 -0
  30. package/lib/typescript/src/google/GoogleSignIn.d.ts +89 -0
  31. package/lib/typescript/src/google/GoogleSignIn.d.ts.map +1 -0
  32. package/lib/typescript/src/google/GoogleSignInButton.d.ts +74 -0
  33. package/lib/typescript/src/google/GoogleSignInButton.d.ts.map +1 -0
  34. package/lib/typescript/src/google/NativeGoogleSignIn.d.ts +12 -0
  35. package/lib/typescript/src/google/NativeGoogleSignIn.d.ts.map +1 -0
  36. package/lib/typescript/src/google/errors.d.ts +57 -0
  37. package/lib/typescript/src/google/errors.d.ts.map +1 -0
  38. package/lib/typescript/src/google/index.d.ts +6 -0
  39. package/lib/typescript/src/google/index.d.ts.map +1 -0
  40. package/lib/typescript/src/google/types.d.ts +93 -0
  41. package/lib/typescript/src/google/types.d.ts.map +1 -0
  42. package/lib/typescript/src/index.d.ts +3 -0
  43. package/lib/typescript/src/index.d.ts.map +1 -0
  44. package/package.json +180 -0
  45. package/src/google/GoogleLogo.tsx +35 -0
  46. package/src/google/GoogleSignIn.ts +131 -0
  47. package/src/google/GoogleSignInButton.tsx +224 -0
  48. package/src/google/NativeGoogleSignIn.ts +12 -0
  49. package/src/google/errors.ts +72 -0
  50. package/src/google/index.ts +19 -0
  51. package/src/google/types.ts +100 -0
  52. package/src/index.tsx +18 -0
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { GoogleSignIn, GoogleSignInButton, GoogleSignInError, GoogleSignInErrorCode, isGoogleSignInError } from "./google/index.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GoogleSignIn","GoogleSignInButton","GoogleSignInError","GoogleSignInErrorCode","isGoogleSignInError"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SACEA,YAAY,EACZC,kBAAkB,EAClBC,iBAAiB,EACjBC,qBAAqB,EACrBC,mBAAmB,QACd,mBAAU","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,6 @@
1
+ interface GoogleLogoProps {
2
+ size?: number;
3
+ }
4
+ export declare function GoogleLogo({ size }: GoogleLogoProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
6
+ //# sourceMappingURL=GoogleLogo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleLogo.d.ts","sourceRoot":"","sources":["../../../../src/google/GoogleLogo.tsx"],"names":[],"mappings":"AAEA,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,UAAU,CAAC,EAAE,IAAS,EAAE,EAAE,eAAe,2CA4BxD"}
@@ -0,0 +1,89 @@
1
+ import type { GoogleAuthCredential, GoogleSignInConfig, GoogleUser } from './types';
2
+ /**
3
+ * Initialize the native Google Sign-In SDK. Must be called once at app startup
4
+ * (or before any other method) — subsequent calls overwrite the prior config.
5
+ *
6
+ * @param config - See {@link GoogleSignInConfig}.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * GoogleSignIn.configure({
11
+ * webClientId: 'WEB_CLIENT_ID.apps.googleusercontent.com',
12
+ * iosClientId: 'IOS_CLIENT_ID.apps.googleusercontent.com',
13
+ * });
14
+ * ```
15
+ */
16
+ declare function configure(config: GoogleSignInConfig): void;
17
+ /**
18
+ * Trigger the Google sign-in flow.
19
+ *
20
+ * @remarks
21
+ * On both platforms, the SDK attempts silent restore of a previously authorized
22
+ * account first, then falls back to the interactive bottom sheet / system sheet
23
+ * if no authorized account is found.
24
+ *
25
+ * @returns A {@link GoogleAuthCredential} containing the ID token, optional
26
+ * access token, and user profile.
27
+ *
28
+ * @throws A {@link GoogleSignInError} with one of the
29
+ * {@link GoogleSignInErrorCode} values — most commonly `SIGN_IN_CANCELLED`
30
+ * when the user dismisses the sheet, or `NOT_CONFIGURED` when called before
31
+ * {@link configure}.
32
+ */
33
+ declare function signIn(): Promise<GoogleAuthCredential>;
34
+ /**
35
+ * Clear the local credential state so the next {@link signIn} call requires
36
+ * fresh user interaction. The user remains signed into Google itself.
37
+ *
38
+ * @throws A {@link GoogleSignInError} with code `NOT_CONFIGURED` when called
39
+ * before {@link configure}.
40
+ */
41
+ declare function signOut(): Promise<void>;
42
+ /**
43
+ * Return the in-memory authenticated user, or `null` if nobody has signed in
44
+ * since app launch.
45
+ *
46
+ * @returns The current {@link GoogleUser}, or `null`.
47
+ *
48
+ * @throws A {@link GoogleSignInError} with code `NOT_CONFIGURED` when called
49
+ * before {@link configure}.
50
+ */
51
+ declare function getCurrentUser(): Promise<GoogleUser | null>;
52
+ /**
53
+ * Revoke the app's access to the user's Google account. The user will see a
54
+ * fresh consent screen on the next {@link signIn}.
55
+ *
56
+ * @throws A {@link GoogleSignInError} with code `NOT_CONFIGURED` when called
57
+ * before {@link configure}.
58
+ */
59
+ declare function revokeAccess(): Promise<void>;
60
+ /**
61
+ * Synchronous check for whether a user is currently signed in (in memory).
62
+ *
63
+ * @returns `true` when {@link getCurrentUser} would resolve to a non-null user.
64
+ *
65
+ * @throws A {@link GoogleSignInError} with code `NOT_CONFIGURED` when called
66
+ * before {@link configure}.
67
+ */
68
+ declare function isSignedIn(): boolean;
69
+ /**
70
+ * The Google Sign-In runtime API. Call {@link GoogleSignIn.configure} once at
71
+ * app startup, then drive the flow with the other methods.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * GoogleSignIn.configure({ webClientId: '...' });
76
+ * const credential = await GoogleSignIn.signIn();
77
+ * console.log(credential.user.email);
78
+ * ```
79
+ */
80
+ export declare const GoogleSignIn: {
81
+ readonly configure: typeof configure;
82
+ readonly signIn: typeof signIn;
83
+ readonly signOut: typeof signOut;
84
+ readonly getCurrentUser: typeof getCurrentUser;
85
+ readonly revokeAccess: typeof revokeAccess;
86
+ readonly isSignedIn: typeof isSignedIn;
87
+ };
88
+ export {};
89
+ //# sourceMappingURL=GoogleSignIn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleSignIn.d.ts","sourceRoot":"","sources":["../../../../src/google/GoogleSignIn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACX,MAAM,SAAS,CAAC;AAejB;;;;;;;;;;;;;GAaG;AACH,iBAAS,SAAS,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAGnD;AAED;;;;;;;;;;;;;;;GAeG;AACH,iBAAe,MAAM,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAIrD;AAED;;;;;;GAMG;AACH,iBAAe,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAGtC;AAED;;;;;;;;GAQG;AACH,iBAAe,cAAc,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAI1D;AAED;;;;;;GAMG;AACH,iBAAe,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAG3C;AAED;;;;;;;GAOG;AACH,iBAAS,UAAU,IAAI,OAAO,CAG7B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY;;;;;;;CAOf,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { type StyleProp, type ViewStyle } from 'react-native';
2
+ /**
3
+ * One of the three button themes defined by Google's branding guidelines.
4
+ *
5
+ * - `light` — white background, dark text, gray border
6
+ * - `dark` — near-black background, light text, gray border
7
+ * - `neutral` — light gray background, dark text, no border
8
+ */
9
+ export type GoogleSignInButtonTheme = 'light' | 'dark' | 'neutral';
10
+ /**
11
+ * Button corner radius:
12
+ *
13
+ * - `rounded` — pill shape (`borderRadius: 20`)
14
+ * - `square` — slightly rounded rectangle (`borderRadius: 4`)
15
+ */
16
+ export type GoogleSignInButtonShape = 'rounded' | 'square';
17
+ /**
18
+ * The call-to-action label. Only these three strings are permitted by Google.
19
+ *
20
+ * - `signin` — "Sign in with Google"
21
+ * - `signup` — "Sign up with Google"
22
+ * - `continue` — "Continue with Google"
23
+ */
24
+ export type GoogleSignInButtonText = 'signin' | 'signup' | 'continue';
25
+ /**
26
+ * Button size:
27
+ *
28
+ * - `standard` — full button with logo + text
29
+ * - `icon` — 40×40 logo-only button for compact layouts
30
+ */
31
+ export type GoogleSignInButtonSize = 'standard' | 'icon';
32
+ /** Props for {@link GoogleSignInButton}. */
33
+ export interface GoogleSignInButtonProps {
34
+ /** {@inheritDoc GoogleSignInButtonTheme} @defaultValue `'light'` */
35
+ theme?: GoogleSignInButtonTheme;
36
+ /** {@inheritDoc GoogleSignInButtonShape} @defaultValue `'rounded'` */
37
+ shape?: GoogleSignInButtonShape;
38
+ /** {@inheritDoc GoogleSignInButtonText} @defaultValue `'signin'` */
39
+ text?: GoogleSignInButtonText;
40
+ /** {@inheritDoc GoogleSignInButtonSize} @defaultValue `'standard'` */
41
+ size?: GoogleSignInButtonSize;
42
+ /** Tap handler. Typically wired to {@link GoogleSignIn.signIn}. */
43
+ onPress?: () => void;
44
+ /**
45
+ * When `true`, renders at 0.38 opacity and disables taps.
46
+ * @defaultValue false
47
+ */
48
+ disabled?: boolean;
49
+ /** Additional container styles (margin, alignment, etc.). */
50
+ style?: StyleProp<ViewStyle>;
51
+ /** Testing identifier. */
52
+ testID?: string;
53
+ }
54
+ /**
55
+ * A pre-built button conforming to Google's official branding guidelines.
56
+ *
57
+ * @remarks
58
+ * The Google "G" is rendered via `react-native-svg` so the button stays crisp
59
+ * at any density without bundled raster assets. Colors, typography, padding,
60
+ * and the permitted CTA strings all follow the official spec — do not
61
+ * restyle the logo or override theme colors, or Google may reject your app
62
+ * during brand review.
63
+ *
64
+ * @example
65
+ * ```tsx
66
+ * <GoogleSignInButton
67
+ * theme="dark"
68
+ * text="continue"
69
+ * onPress={() => GoogleSignIn.signIn()}
70
+ * />
71
+ * ```
72
+ */
73
+ export declare function GoogleSignInButton({ theme, shape, text, size, onPress, disabled, style, testID, }: GoogleSignInButtonProps): import("react/jsx-runtime").JSX.Element;
74
+ //# sourceMappingURL=GoogleSignInButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleSignInButton.d.ts","sourceRoot":"","sources":["../../../../src/google/GoogleSignInButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAwBtB;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,MAAM,CAAC;AAEzD,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC,oEAAoE;IACpE,KAAK,CAAC,EAAE,uBAAuB,CAAC;IAChC,sEAAsE;IACtE,KAAK,CAAC,EAAE,uBAAuB,CAAC;IAChC,oEAAoE;IACpE,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,sEAAsE;IACtE,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,0BAA0B;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAqCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,KAAe,EACf,KAAiB,EACjB,IAAe,EACf,IAAiB,EACjB,OAAO,EACP,QAAgB,EAChB,KAAK,EACL,MAAM,GACP,EAAE,uBAAuB,2CAwCzB"}
@@ -0,0 +1,12 @@
1
+ import { type TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ configure(config: Object): void;
4
+ signIn(): Promise<Object>;
5
+ signOut(): Promise<void>;
6
+ getCurrentUser(): Promise<Object | null>;
7
+ revokeAccess(): Promise<void>;
8
+ isSignedIn(): boolean;
9
+ }
10
+ declare const _default: Spec;
11
+ export default _default;
12
+ //# sourceMappingURL=NativeGoogleSignIn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeGoogleSignIn.d.ts","sourceRoot":"","sources":["../../../../src/google/NativeGoogleSignIn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,UAAU,IAAI,OAAO,CAAC;CACvB;;AAED,wBAAsE"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Discriminator for {@link GoogleSignInError.code}. Identical on Android and
3
+ * iOS so error-handling code is platform-agnostic.
4
+ */
5
+ export declare enum GoogleSignInErrorCode {
6
+ /** The user dismissed the sign-in sheet. Don't surface an error. */
7
+ SIGN_IN_CANCELLED = "SIGN_IN_CANCELLED",
8
+ /** A generic native failure; inspect `message` and `nativeErrorCode` for details. */
9
+ SIGN_IN_FAILED = "SIGN_IN_FAILED",
10
+ /** No Google accounts are available on the device. */
11
+ NO_CREDENTIALS = "NO_CREDENTIALS",
12
+ /** Google Play Services is missing or out of date (Android only). */
13
+ PLAY_SERVICES_NOT_AVAILABLE = "PLAY_SERVICES_NOT_AVAILABLE",
14
+ /** The device could not reach Google's auth servers. */
15
+ NETWORK_ERROR = "NETWORK_ERROR",
16
+ /** A method was called before {@link GoogleSignIn.configure}. */
17
+ NOT_CONFIGURED = "NOT_CONFIGURED"
18
+ }
19
+ /**
20
+ * Typed error thrown / rejected by every {@link GoogleSignIn} method.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * try {
25
+ * await GoogleSignIn.signIn();
26
+ * } catch (error) {
27
+ * if (isGoogleSignInError(error) && error.code === GoogleSignInErrorCode.SIGN_IN_CANCELLED) {
28
+ * return;
29
+ * }
30
+ * throw error;
31
+ * }
32
+ * ```
33
+ */
34
+ export declare class GoogleSignInError extends Error {
35
+ /** The platform-agnostic error code. */
36
+ readonly code: GoogleSignInErrorCode;
37
+ /**
38
+ * The underlying native error code (e.g. Android `28444`, iOS
39
+ * `kGIDSignInErrorCode...`). Useful for telemetry; do not branch on it from
40
+ * application code — branch on {@link code} instead.
41
+ */
42
+ readonly nativeErrorCode: string | undefined;
43
+ /**
44
+ * @param code - A {@link GoogleSignInErrorCode} value.
45
+ * @param message - Human-readable description, suitable for logs.
46
+ * @param nativeErrorCode - Optional native-side code for diagnostics.
47
+ */
48
+ constructor(code: GoogleSignInErrorCode, message: string, nativeErrorCode?: string);
49
+ }
50
+ /**
51
+ * Type guard that narrows `unknown` to {@link GoogleSignInError}.
52
+ *
53
+ * @param error - Any caught value.
54
+ * @returns `true` when `error` is a {@link GoogleSignInError} instance.
55
+ */
56
+ export declare function isGoogleSignInError(error: unknown): error is GoogleSignInError;
57
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/google/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,qBAAqB;IAC/B,oEAAoE;IACpE,iBAAiB,sBAAsB;IACvC,qFAAqF;IACrF,cAAc,mBAAmB;IACjC,sDAAsD;IACtD,cAAc,mBAAmB;IACjC,qEAAqE;IACrE,2BAA2B,gCAAgC;IAC3D,wDAAwD;IACxD,aAAa,kBAAkB;IAC/B,iEAAiE;IACjE,cAAc,mBAAmB;CAClC;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7C;;;;OAIG;gBAED,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,MAAM;CAO3B;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,iBAAiB,CAE5B"}
@@ -0,0 +1,6 @@
1
+ export { GoogleSignIn } from './GoogleSignIn';
2
+ export { GoogleSignInError, GoogleSignInErrorCode, isGoogleSignInError, } from './errors';
3
+ export { GoogleSignInButton } from './GoogleSignInButton';
4
+ export type { GoogleSignInButtonProps, GoogleSignInButtonTheme, GoogleSignInButtonShape, GoogleSignInButtonText, GoogleSignInButtonSize, } from './GoogleSignInButton';
5
+ export type { GoogleSignInConfig, GoogleUser, GoogleAuthCredential, } from './types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/google/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EACV,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,kBAAkB,EAClB,UAAU,EACV,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Configuration accepted by {@link GoogleSignIn.configure}.
3
+ *
4
+ * @remarks
5
+ * `webClientId` is required on every platform — it sets the audience (`aud`)
6
+ * of the issued ID token so a single backend verification path works across
7
+ * iOS, Android, and web.
8
+ */
9
+ export interface GoogleSignInConfig {
10
+ /**
11
+ * The OAuth 2.0 **Web application** client ID from Google Cloud Console.
12
+ * Used as the `serverClientID` on iOS and the `serverClientId` on Android,
13
+ * which becomes the `aud` claim of the issued ID token.
14
+ */
15
+ webClientId: string;
16
+ /**
17
+ * The OAuth 2.0 **iOS application** client ID. Required when running on iOS;
18
+ * ignored on Android.
19
+ */
20
+ iosClientId?: string;
21
+ /**
22
+ * When `true`, request a server auth code in addition to the ID token so a
23
+ * backend can exchange it for refresh tokens. Not yet exposed end-to-end.
24
+ *
25
+ * @defaultValue false
26
+ */
27
+ offlineAccess?: boolean;
28
+ /**
29
+ * Additional OAuth scopes to request beyond the default `openid email profile`.
30
+ */
31
+ scopes?: string[];
32
+ /**
33
+ * Restrict sign-in to accounts on a specific Google Workspace domain (e.g.
34
+ * `"example.com"`).
35
+ */
36
+ hostedDomain?: string;
37
+ /**
38
+ * When `true`, returning users sign in silently with the most recently used
39
+ * account without showing the bottom sheet.
40
+ *
41
+ * @defaultValue false
42
+ */
43
+ autoSelect?: boolean;
44
+ /**
45
+ * A unique value bound into the ID token. Recommended when verifying tokens
46
+ * server-side to prevent replay attacks.
47
+ *
48
+ * @remarks
49
+ * Honored on Android. On iOS the GoogleSignIn 7.x public API does not expose
50
+ * a nonce parameter; nonce verification must be enforced server-side instead.
51
+ */
52
+ nonce?: string;
53
+ }
54
+ /**
55
+ * The authenticated Google account's profile, returned by
56
+ * {@link GoogleSignIn.signIn} and {@link GoogleSignIn.getCurrentUser}.
57
+ */
58
+ export interface GoogleUser {
59
+ /** The user's stable Google account ID (`sub` claim in the ID token). */
60
+ id: string;
61
+ /** The user's primary email address. */
62
+ email: string;
63
+ /** The user's full display name, if provided. */
64
+ displayName: string | null;
65
+ /** The user's given (first) name, if provided. */
66
+ givenName: string | null;
67
+ /** The user's family (last) name, if provided. */
68
+ familyName: string | null;
69
+ /** A URL to the user's profile photo (200×200), if provided. */
70
+ photoUrl: string | null;
71
+ }
72
+ /**
73
+ * The result of a successful {@link GoogleSignIn.signIn} call.
74
+ *
75
+ * @remarks
76
+ * Pass `idToken` to your backend and verify it with Google's public keys. The
77
+ * `aud` claim will equal the {@link GoogleSignInConfig.webClientId} you passed
78
+ * to {@link GoogleSignIn.configure}.
79
+ */
80
+ export interface GoogleAuthCredential {
81
+ /** The Google-issued ID token. JWT format; verify on your backend. */
82
+ idToken: string;
83
+ /** OAuth access token for calling Google APIs; `null` when not requested. */
84
+ accessToken: string | null;
85
+ /**
86
+ * One-time code your backend can exchange for refresh tokens. `null` unless
87
+ * {@link GoogleSignInConfig.offlineAccess} was set.
88
+ */
89
+ serverAuthCode: string | null;
90
+ /** The authenticated user's profile. */
91
+ user: GoogleUser;
92
+ }
93
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/google/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,yEAAyE;IACzE,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,kDAAkD;IAClD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kDAAkD;IAClD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gEAAgE;IAChE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;OAGG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,wCAAwC;IACxC,IAAI,EAAE,UAAU,CAAC;CAClB"}
@@ -0,0 +1,3 @@
1
+ export { GoogleSignIn, GoogleSignInButton, GoogleSignInError, GoogleSignInErrorCode, isGoogleSignInError, } from './google';
2
+ export type { GoogleSignInButtonProps, GoogleSignInButtonTheme, GoogleSignInButtonShape, GoogleSignInButtonText, GoogleSignInButtonSize, GoogleSignInConfig, GoogleUser, GoogleAuthCredential, } from './google';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,oBAAoB,GACrB,MAAM,UAAU,CAAC"}
package/package.json ADDED
@@ -0,0 +1,180 @@
1
+ {
2
+ "name": "@thoughtbot/react-native-social-auth",
3
+ "version": "0.1.0",
4
+ "description": "OAuth sign in buttons and methods for React Native",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "*.podspec",
22
+ "react-native.config.js",
23
+ "!ios/build",
24
+ "!android/build",
25
+ "!android/gradle",
26
+ "!android/gradlew",
27
+ "!android/gradlew.bat",
28
+ "!android/local.properties",
29
+ "!**/__tests__",
30
+ "!**/__fixtures__",
31
+ "!**/__mocks__",
32
+ "!**/.*"
33
+ ],
34
+ "scripts": {
35
+ "example": "yarn workspace @thoughtbot/react-native-social-auth-example",
36
+ "clean": "del-cli lib",
37
+ "prepare": "bob build",
38
+ "typecheck": "tsc",
39
+ "test": "jest",
40
+ "release": "release-it --only-version",
41
+ "lint": "eslint \"**/*.{js,ts,tsx}\""
42
+ },
43
+ "keywords": [
44
+ "react-native",
45
+ "ios",
46
+ "android",
47
+ "oauth",
48
+ "social",
49
+ "authentication",
50
+ "login"
51
+ ],
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/thoughtbot/react-native-social-auth.git"
55
+ },
56
+ "author": "Tomi Alu <malcolmtomisin@gmail.com> (https://github.com/MalcolmTomisin)",
57
+ "license": "MIT",
58
+ "bugs": {
59
+ "url": "https://github.com/thoughtbot/react-native-social-auth/issues"
60
+ },
61
+ "homepage": "https://github.com/thoughtbot/react-native-social-auth#readme",
62
+ "publishConfig": {
63
+ "registry": "https://registry.npmjs.org/"
64
+ },
65
+ "devDependencies": {
66
+ "@commitlint/config-conventional": "^20.5.0",
67
+ "@eslint/compat": "^2.0.3",
68
+ "@eslint/eslintrc": "^3.3.5",
69
+ "@eslint/js": "^10.0.1",
70
+ "@jest/globals": "^30.0.0",
71
+ "@react-native/babel-preset": "0.85.0",
72
+ "@react-native/eslint-config": "0.85.0",
73
+ "@react-native/jest-preset": "0.85.0",
74
+ "@release-it/conventional-changelog": "^10.0.6",
75
+ "@testing-library/react-native": "^13.3",
76
+ "@types/react": "^19.2.0",
77
+ "@types/react-test-renderer": "^19",
78
+ "commitlint": "^20.5.0",
79
+ "del-cli": "^7.0.0",
80
+ "eslint": "^9.39.4",
81
+ "eslint-config-prettier": "^10.1.8",
82
+ "eslint-plugin-ft-flow": "^3.0.11",
83
+ "eslint-plugin-prettier": "^5.5.5",
84
+ "jest": "^30.3.0",
85
+ "lefthook": "^2.1.4",
86
+ "prettier": "^3.8.1",
87
+ "react": "19.2.0",
88
+ "react-native": "0.83.4",
89
+ "react-native-builder-bob": "^0.41.0",
90
+ "react-native-svg": "^15.15.5",
91
+ "react-test-renderer": "19.2.0",
92
+ "release-it": "^19.2.4",
93
+ "turbo": "^2.8.21",
94
+ "typescript": "^6.0.2"
95
+ },
96
+ "peerDependencies": {
97
+ "react": "*",
98
+ "react-native": "*",
99
+ "react-native-svg": ">=13.0.0"
100
+ },
101
+ "workspaces": [
102
+ "example"
103
+ ],
104
+ "packageManager": "yarn@4.11.0",
105
+ "react-native-builder-bob": {
106
+ "source": "src",
107
+ "output": "lib",
108
+ "targets": [
109
+ [
110
+ "module",
111
+ {
112
+ "esm": true
113
+ }
114
+ ],
115
+ [
116
+ "typescript",
117
+ {
118
+ "project": "tsconfig.build.json"
119
+ }
120
+ ]
121
+ ]
122
+ },
123
+ "codegenConfig": {
124
+ "name": "ReactNativeSocialAuthSpec",
125
+ "type": "modules",
126
+ "jsSrcsDir": "src",
127
+ "android": {
128
+ "javaPackageName": "com.thoughtbot.reactnativesocialauth"
129
+ }
130
+ },
131
+ "jest": {
132
+ "preset": "@react-native/jest-preset",
133
+ "modulePathIgnorePatterns": [
134
+ "<rootDir>/example/node_modules",
135
+ "<rootDir>/lib/"
136
+ ]
137
+ },
138
+ "commitlint": {
139
+ "extends": [
140
+ "@commitlint/config-conventional"
141
+ ]
142
+ },
143
+ "release-it": {
144
+ "git": {
145
+ "commitMessage": "chore: release ${version}",
146
+ "tagName": "v${version}"
147
+ },
148
+ "npm": {
149
+ "publish": true
150
+ },
151
+ "github": {
152
+ "release": true
153
+ },
154
+ "plugins": {
155
+ "@release-it/conventional-changelog": {
156
+ "preset": {
157
+ "name": "angular"
158
+ }
159
+ }
160
+ }
161
+ },
162
+ "prettier": {
163
+ "quoteProps": "consistent",
164
+ "singleQuote": true,
165
+ "tabWidth": 2,
166
+ "trailingComma": "es5",
167
+ "useTabs": false
168
+ },
169
+ "create-react-native-library": {
170
+ "type": "turbo-module",
171
+ "languages": "kotlin-objc",
172
+ "tools": [
173
+ "jest",
174
+ "lefthook",
175
+ "release-it",
176
+ "eslint"
177
+ ],
178
+ "version": "0.62.0"
179
+ }
180
+ }
@@ -0,0 +1,35 @@
1
+ import Svg, { Path, ClipPath, Rect, Defs, G } from 'react-native-svg';
2
+
3
+ interface GoogleLogoProps {
4
+ size?: number;
5
+ }
6
+
7
+ export function GoogleLogo({ size = 20 }: GoogleLogoProps) {
8
+ return (
9
+ <Svg width={size} height={size} viewBox="10 10 20 20" fill="none">
10
+ <Defs>
11
+ <ClipPath id="g-clip">
12
+ <Rect width="20" height="20" x="10" y="10" />
13
+ </ClipPath>
14
+ </Defs>
15
+ <G clipPath="url(#g-clip)">
16
+ <Path
17
+ d="M29.6 20.2273C29.6 19.5182 29.5364 18.8364 29.4182 18.1818H20V22.05H25.3818C25.15 23.3 24.4455 24.3591 23.3864 25.0682V27.5773H26.6182C28.5091 25.8364 29.6 23.2727 29.6 20.2273Z"
18
+ fill="#4285F4"
19
+ />
20
+ <Path
21
+ d="M20 30C22.7 30 24.9636 29.1045 26.6181 27.5773L23.3863 25.0682C22.4909 25.6682 21.3454 26.0227 20 26.0227C17.3954 26.0227 15.1909 24.2636 14.4045 21.9H11.0636V24.4909C12.7091 27.7591 16.0909 30 20 30Z"
22
+ fill="#34A853"
23
+ />
24
+ <Path
25
+ d="M14.4045 21.9C14.2045 21.3 14.0909 20.6591 14.0909 20C14.0909 19.3409 14.2045 18.7 14.4045 18.1V15.5091H11.0636C10.3864 16.8591 10 18.3864 10 20C10 21.6136 10.3864 23.1409 11.0636 24.4909L14.4045 21.9Z"
26
+ fill="#FBBC04"
27
+ />
28
+ <Path
29
+ d="M20 13.9773C21.4681 13.9773 22.7863 14.4818 23.8227 15.4727L26.6909 12.6045C24.9591 10.9909 22.6954 10 20 10C16.0909 10 12.7091 12.2409 11.0636 15.5091L14.4045 18.1C15.1909 15.7364 17.3954 13.9773 20 13.9773Z"
30
+ fill="#E94235"
31
+ />
32
+ </G>
33
+ </Svg>
34
+ );
35
+ }