@clerk/expo 3.0.0-snapshot.v20251215212157 → 3.0.0-snapshot.v20251216175437
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/android/build.gradle +64 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/clerk/googlesignin/ClerkGoogleSignInModule.kt +264 -0
- package/app.plugin.js +1 -0
- package/dist/errorThrower.d.ts +1 -1
- package/dist/google-one-tap/ClerkGoogleOneTapSignIn.d.ts +104 -0
- package/dist/google-one-tap/ClerkGoogleOneTapSignIn.d.ts.map +1 -0
- package/dist/google-one-tap/ClerkGoogleOneTapSignIn.js +153 -0
- package/dist/google-one-tap/ClerkGoogleOneTapSignIn.js.map +1 -0
- package/dist/google-one-tap/index.d.ts +3 -0
- package/dist/google-one-tap/index.d.ts.map +1 -0
- package/dist/google-one-tap/index.js +37 -0
- package/dist/google-one-tap/index.js.map +1 -0
- package/dist/google-one-tap/types.d.ts +139 -0
- package/dist/google-one-tap/types.d.ts.map +1 -0
- package/dist/google-one-tap/types.js +17 -0
- package/dist/google-one-tap/types.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useSignInWithGoogle.android.d.ts +47 -0
- package/dist/hooks/useSignInWithGoogle.android.d.ts.map +1 -0
- package/dist/hooks/useSignInWithGoogle.android.js +65 -0
- package/dist/hooks/useSignInWithGoogle.android.js.map +1 -0
- package/dist/hooks/useSignInWithGoogle.d.ts +52 -0
- package/dist/hooks/useSignInWithGoogle.d.ts.map +1 -0
- package/dist/hooks/useSignInWithGoogle.ios.d.ts +47 -0
- package/dist/hooks/useSignInWithGoogle.ios.d.ts.map +1 -0
- package/dist/hooks/useSignInWithGoogle.ios.js +70 -0
- package/dist/hooks/useSignInWithGoogle.ios.js.map +1 -0
- package/dist/hooks/useSignInWithGoogle.js +39 -0
- package/dist/hooks/useSignInWithGoogle.js.map +1 -0
- package/dist/hooks/useSignInWithGoogle.shared.d.ts +17 -0
- package/dist/hooks/useSignInWithGoogle.shared.d.ts.map +1 -0
- package/dist/hooks/useSignInWithGoogle.shared.js +112 -0
- package/dist/hooks/useSignInWithGoogle.shared.js.map +1 -0
- package/dist/hooks/useSignInWithGoogle.types.d.ts +12 -0
- package/dist/hooks/useSignInWithGoogle.types.d.ts.map +1 -0
- package/dist/hooks/useSignInWithGoogle.types.js +17 -0
- package/dist/hooks/useSignInWithGoogle.types.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/dist/provider/ClerkProvider.js +1 -1
- package/dist/utils/errors.d.ts +1 -1
- package/expo-module.config.json +9 -0
- package/ios/ClerkGoogleSignIn.podspec +22 -0
- package/ios/ClerkGoogleSignInModule.swift +229 -0
- package/package.json +31 -10
- package/plugin/build/withClerkExpo.d.ts +3 -0
- package/plugin/build/withClerkExpo.js +36 -0
- package/plugin/src/withClerkExpo.ts +45 -0
- package/plugin/tsconfig.json +15 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration parameters for Google One Tap Sign-In.
|
|
3
|
+
*/
|
|
4
|
+
export type ConfigureParams = {
|
|
5
|
+
/**
|
|
6
|
+
* The web client ID from Google Cloud Console.
|
|
7
|
+
* This is required for Google Sign-In to work.
|
|
8
|
+
* On iOS, this is used as the serverClientID for token audience.
|
|
9
|
+
*/
|
|
10
|
+
webClientId: string;
|
|
11
|
+
/**
|
|
12
|
+
* The iOS client ID from Google Cloud Console.
|
|
13
|
+
* This is only used on iOS for the OAuth flow.
|
|
14
|
+
* If not provided, webClientId will be used.
|
|
15
|
+
* @platform iOS
|
|
16
|
+
*/
|
|
17
|
+
iosClientId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional hosted domain to restrict sign-in to a specific domain.
|
|
20
|
+
*/
|
|
21
|
+
hostedDomain?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to enable auto-select for returning users.
|
|
24
|
+
* When true, if only one credential is available, it will be automatically selected.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
autoSelectEnabled?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Parameters for the signIn method.
|
|
31
|
+
*/
|
|
32
|
+
export type SignInParams = {
|
|
33
|
+
/**
|
|
34
|
+
* A cryptographically random string used to mitigate replay attacks.
|
|
35
|
+
* The nonce will be included in the ID token.
|
|
36
|
+
*/
|
|
37
|
+
nonce?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to filter credentials to only show accounts that have been
|
|
40
|
+
* previously authorized for this app.
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
filterByAuthorizedAccounts?: boolean;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Parameters for the createAccount method.
|
|
47
|
+
*/
|
|
48
|
+
export type CreateAccountParams = {
|
|
49
|
+
/**
|
|
50
|
+
* A cryptographically random string used to mitigate replay attacks.
|
|
51
|
+
* The nonce will be included in the ID token.
|
|
52
|
+
*/
|
|
53
|
+
nonce?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Parameters for the presentExplicitSignIn method.
|
|
57
|
+
*/
|
|
58
|
+
export type ExplicitSignInParams = {
|
|
59
|
+
/**
|
|
60
|
+
* A cryptographically random string used to mitigate replay attacks.
|
|
61
|
+
* The nonce will be included in the ID token.
|
|
62
|
+
*/
|
|
63
|
+
nonce?: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* User information returned from Google Sign-In.
|
|
67
|
+
*/
|
|
68
|
+
export type GoogleUser = {
|
|
69
|
+
/**
|
|
70
|
+
* The user's unique Google identifier (OIDC "sub" claim).
|
|
71
|
+
* This is distinct from the user's email address.
|
|
72
|
+
*/
|
|
73
|
+
id: string;
|
|
74
|
+
/**
|
|
75
|
+
* The user's email address.
|
|
76
|
+
*/
|
|
77
|
+
email: string;
|
|
78
|
+
/**
|
|
79
|
+
* The user's full display name.
|
|
80
|
+
*/
|
|
81
|
+
name: string | null;
|
|
82
|
+
/**
|
|
83
|
+
* The user's given (first) name.
|
|
84
|
+
*/
|
|
85
|
+
givenName: string | null;
|
|
86
|
+
/**
|
|
87
|
+
* The user's family (last) name.
|
|
88
|
+
*/
|
|
89
|
+
familyName: string | null;
|
|
90
|
+
/**
|
|
91
|
+
* URL to the user's profile picture.
|
|
92
|
+
*/
|
|
93
|
+
photo: string | null;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Successful sign-in response.
|
|
97
|
+
*/
|
|
98
|
+
export type OneTapSuccessResponse = {
|
|
99
|
+
type: 'success';
|
|
100
|
+
data: {
|
|
101
|
+
/**
|
|
102
|
+
* The Google ID token containing user information and nonce.
|
|
103
|
+
*/
|
|
104
|
+
idToken: string;
|
|
105
|
+
/**
|
|
106
|
+
* The user's information.
|
|
107
|
+
*/
|
|
108
|
+
user: GoogleUser;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Response when the user cancels the sign-in flow.
|
|
113
|
+
*/
|
|
114
|
+
export type CancelledResponse = {
|
|
115
|
+
type: 'cancelled';
|
|
116
|
+
data: null;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Response when no saved credential is found.
|
|
120
|
+
*/
|
|
121
|
+
export type NoSavedCredentialFound = {
|
|
122
|
+
type: 'noSavedCredentialFound';
|
|
123
|
+
data: null;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Union type for all possible One Tap responses.
|
|
127
|
+
*/
|
|
128
|
+
export type OneTapResponse = OneTapSuccessResponse | CancelledResponse | NoSavedCredentialFound;
|
|
129
|
+
/**
|
|
130
|
+
* Error codes that can be thrown by the Google Sign-In module.
|
|
131
|
+
*/
|
|
132
|
+
export type GoogleSignInErrorCode = 'SIGN_IN_CANCELLED' | 'NO_SAVED_CREDENTIAL_FOUND' | 'NOT_CONFIGURED' | 'GOOGLE_SIGN_IN_ERROR';
|
|
133
|
+
/**
|
|
134
|
+
* Error thrown by the Google Sign-In module.
|
|
135
|
+
*/
|
|
136
|
+
export interface GoogleSignInError extends Error {
|
|
137
|
+
code: GoogleSignInErrorCode;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/google-one-tap/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpB;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE;QACJ;;WAEG;QACH,OAAO,EAAE,MAAM,CAAC;QAEhB;;WAEG;QACH,IAAI,EAAE,UAAU,CAAC;KAClB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG,iBAAiB,GAAG,sBAAsB,CAAC;AAEhG;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,mBAAmB,GACnB,2BAA2B,GAC3B,gBAAgB,GAChB,sBAAsB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,KAAK;IAC9C,IAAI,EAAE,qBAAqB,CAAC;CAC7B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/google-one-tap/types.ts"],"sourcesContent":["/**\n * Configuration parameters for Google One Tap Sign-In.\n */\nexport type ConfigureParams = {\n /**\n * The web client ID from Google Cloud Console.\n * This is required for Google Sign-In to work.\n * On iOS, this is used as the serverClientID for token audience.\n */\n webClientId: string;\n\n /**\n * The iOS client ID from Google Cloud Console.\n * This is only used on iOS for the OAuth flow.\n * If not provided, webClientId will be used.\n * @platform iOS\n */\n iosClientId?: string;\n\n /**\n * Optional hosted domain to restrict sign-in to a specific domain.\n */\n hostedDomain?: string;\n\n /**\n * Whether to enable auto-select for returning users.\n * When true, if only one credential is available, it will be automatically selected.\n * @default false\n */\n autoSelectEnabled?: boolean;\n};\n\n/**\n * Parameters for the signIn method.\n */\nexport type SignInParams = {\n /**\n * A cryptographically random string used to mitigate replay attacks.\n * The nonce will be included in the ID token.\n */\n nonce?: string;\n\n /**\n * Whether to filter credentials to only show accounts that have been\n * previously authorized for this app.\n * @default true\n */\n filterByAuthorizedAccounts?: boolean;\n};\n\n/**\n * Parameters for the createAccount method.\n */\nexport type CreateAccountParams = {\n /**\n * A cryptographically random string used to mitigate replay attacks.\n * The nonce will be included in the ID token.\n */\n nonce?: string;\n};\n\n/**\n * Parameters for the presentExplicitSignIn method.\n */\nexport type ExplicitSignInParams = {\n /**\n * A cryptographically random string used to mitigate replay attacks.\n * The nonce will be included in the ID token.\n */\n nonce?: string;\n};\n\n/**\n * User information returned from Google Sign-In.\n */\nexport type GoogleUser = {\n /**\n * The user's unique Google identifier (OIDC \"sub\" claim).\n * This is distinct from the user's email address.\n */\n id: string;\n\n /**\n * The user's email address.\n */\n email: string;\n\n /**\n * The user's full display name.\n */\n name: string | null;\n\n /**\n * The user's given (first) name.\n */\n givenName: string | null;\n\n /**\n * The user's family (last) name.\n */\n familyName: string | null;\n\n /**\n * URL to the user's profile picture.\n */\n photo: string | null;\n};\n\n/**\n * Successful sign-in response.\n */\nexport type OneTapSuccessResponse = {\n type: 'success';\n data: {\n /**\n * The Google ID token containing user information and nonce.\n */\n idToken: string;\n\n /**\n * The user's information.\n */\n user: GoogleUser;\n };\n};\n\n/**\n * Response when the user cancels the sign-in flow.\n */\nexport type CancelledResponse = {\n type: 'cancelled';\n data: null;\n};\n\n/**\n * Response when no saved credential is found.\n */\nexport type NoSavedCredentialFound = {\n type: 'noSavedCredentialFound';\n data: null;\n};\n\n/**\n * Union type for all possible One Tap responses.\n */\nexport type OneTapResponse = OneTapSuccessResponse | CancelledResponse | NoSavedCredentialFound;\n\n/**\n * Error codes that can be thrown by the Google Sign-In module.\n */\nexport type GoogleSignInErrorCode =\n | 'SIGN_IN_CANCELLED'\n | 'NO_SAVED_CREDENTIAL_FOUND'\n | 'NOT_CONFIGURED'\n | 'GOOGLE_SIGN_IN_ERROR';\n\n/**\n * Error thrown by the Google Sign-In module.\n */\nexport interface GoogleSignInError extends Error {\n code: GoogleSignInErrorCode;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { useClerk, useEmailLink, useOrganization, useOrganizationList, useSession, useSessionList, useSignIn, useSignUp, useUser, useReverification, } from '@clerk/react';
|
|
2
2
|
export * from './useSignInWithApple';
|
|
3
|
+
export * from './useSignInWithGoogle';
|
|
3
4
|
export * from './useSSO';
|
|
4
5
|
export * from './useOAuth';
|
|
5
6
|
export * from './useAuth';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,SAAS,EACT,SAAS,EACT,OAAO,EACP,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,SAAS,EACT,SAAS,EACT,OAAO,EACP,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(hooks_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(hooks_exports);
|
|
34
34
|
var import_react = require("@clerk/react");
|
|
35
35
|
__reExport(hooks_exports, require("./useSignInWithApple"), module.exports);
|
|
36
|
+
__reExport(hooks_exports, require("./useSignInWithGoogle"), module.exports);
|
|
36
37
|
__reExport(hooks_exports, require("./useSSO"), module.exports);
|
|
37
38
|
__reExport(hooks_exports, require("./useOAuth"), module.exports);
|
|
38
39
|
__reExport(hooks_exports, require("./useAuth"), module.exports);
|
|
@@ -49,6 +50,7 @@ __reExport(hooks_exports, require("./useAuth"), module.exports);
|
|
|
49
50
|
useSignUp,
|
|
50
51
|
useUser,
|
|
51
52
|
...require("./useSignInWithApple"),
|
|
53
|
+
...require("./useSignInWithGoogle"),
|
|
52
54
|
...require("./useSSO"),
|
|
53
55
|
...require("./useOAuth"),
|
|
54
56
|
...require("./useAuth")
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/index.ts"],"sourcesContent":["export {\n useClerk,\n useEmailLink,\n useOrganization,\n useOrganizationList,\n useSession,\n useSessionList,\n useSignIn,\n useSignUp,\n useUser,\n useReverification,\n} from '@clerk/react';\n\nexport * from './useSignInWithApple';\nexport * from './useSSO';\nexport * from './useOAuth';\nexport * from './useAuth';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAWO;AAEP,0BAAc,iCAbd;AAcA,0BAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/index.ts"],"sourcesContent":["export {\n useClerk,\n useEmailLink,\n useOrganization,\n useOrganizationList,\n useSession,\n useSessionList,\n useSignIn,\n useSignUp,\n useUser,\n useReverification,\n} from '@clerk/react';\n\nexport * from './useSignInWithApple';\nexport * from './useSignInWithGoogle';\nexport * from './useSSO';\nexport * from './useOAuth';\nexport * from './useAuth';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAWO;AAEP,0BAAc,iCAbd;AAcA,0BAAc,kCAdd;AAeA,0BAAc,qBAfd;AAgBA,0BAAc,uBAhBd;AAiBA,0BAAc,sBAjBd;","names":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { StartGoogleAuthenticationFlowParams, StartGoogleAuthenticationFlowReturnType } from './useSignInWithGoogle.types';
|
|
2
|
+
export type { StartGoogleAuthenticationFlowParams, StartGoogleAuthenticationFlowReturnType };
|
|
3
|
+
/**
|
|
4
|
+
* Hook for native Google Authentication on Android using Clerk's built-in Google One Tap module.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides a simplified way to authenticate users with their Google account
|
|
7
|
+
* using the native Android Google Sign-In UI with Credential Manager. The authentication
|
|
8
|
+
* flow automatically handles the ID token exchange with Clerk's backend and manages
|
|
9
|
+
* the transfer flow between sign-in and sign-up.
|
|
10
|
+
*
|
|
11
|
+
* Features:
|
|
12
|
+
* - Native Google One Tap UI
|
|
13
|
+
* - Built-in nonce support for replay attack protection
|
|
14
|
+
* - No additional dependencies required
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { useSignInWithGoogle } from '@clerk/clerk-expo';
|
|
19
|
+
* import { Button } from 'react-native';
|
|
20
|
+
*
|
|
21
|
+
* function GoogleSignInButton() {
|
|
22
|
+
* const { startGoogleAuthenticationFlow } = useSignInWithGoogle();
|
|
23
|
+
*
|
|
24
|
+
* const onPress = async () => {
|
|
25
|
+
* try {
|
|
26
|
+
* const { createdSessionId, setActive } = await startGoogleAuthenticationFlow();
|
|
27
|
+
*
|
|
28
|
+
* if (createdSessionId && setActive) {
|
|
29
|
+
* await setActive({ session: createdSessionId });
|
|
30
|
+
* }
|
|
31
|
+
* } catch (err) {
|
|
32
|
+
* console.error('Google Authentication error:', err);
|
|
33
|
+
* }
|
|
34
|
+
* };
|
|
35
|
+
*
|
|
36
|
+
* return <Button title="Sign in with Google" onPress={onPress} />;
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @platform Android - This is the Android-specific implementation using Credential Manager
|
|
41
|
+
*
|
|
42
|
+
* @returns An object containing the `startGoogleAuthenticationFlow` function
|
|
43
|
+
*/
|
|
44
|
+
export declare function useSignInWithGoogle(): {
|
|
45
|
+
startGoogleAuthenticationFlow: (startGoogleAuthenticationFlowParams?: StartGoogleAuthenticationFlowParams) => Promise<StartGoogleAuthenticationFlowReturnType>;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=useSignInWithGoogle.android.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSignInWithGoogle.android.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignInWithGoogle.android.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,mCAAmC,EACnC,uCAAuC,EACxC,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,mCAAmC,EAAE,uCAAuC,EAAE,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,mBAAmB;0EAIO,mCAAmC,KACxE,OAAO,CAAC,uCAAuC,CAAC;EA2BpD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useSignInWithGoogle_android_exports = {};
|
|
30
|
+
__export(useSignInWithGoogle_android_exports, {
|
|
31
|
+
useSignInWithGoogle: () => useSignInWithGoogle
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useSignInWithGoogle_android_exports);
|
|
34
|
+
var import_react = require("@clerk/react");
|
|
35
|
+
var import_expo_constants = __toESM(require("expo-constants"));
|
|
36
|
+
var import_errors = require("../utils/errors");
|
|
37
|
+
var import_useSignInWithGoogle = require("./useSignInWithGoogle.shared");
|
|
38
|
+
function useSignInWithGoogle() {
|
|
39
|
+
const clerk = (0, import_react.useClerk)();
|
|
40
|
+
async function startGoogleAuthenticationFlow(startGoogleAuthenticationFlowParams) {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const { client, loaded, setActive } = clerk;
|
|
43
|
+
if (!loaded || !client) {
|
|
44
|
+
return {
|
|
45
|
+
createdSessionId: null,
|
|
46
|
+
setActive
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const webClientId = ((_b = (_a = import_expo_constants.default.expoConfig) == null ? void 0 : _a.extra) == null ? void 0 : _b.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID) || process.env.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID;
|
|
50
|
+
if (!webClientId) {
|
|
51
|
+
return import_errors.errorThrower.throw(
|
|
52
|
+
"Google Sign-In credentials not found. Please set EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID in your .env file."
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return (0, import_useSignInWithGoogle.executeGoogleAuthenticationFlow)({ client, setActive }, { webClientId }, startGoogleAuthenticationFlowParams);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
startGoogleAuthenticationFlow
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
useSignInWithGoogle
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=useSignInWithGoogle.android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useSignInWithGoogle.android.ts"],"sourcesContent":["import { useClerk } from '@clerk/react';\nimport Constants from 'expo-constants';\n\nimport { errorThrower } from '../utils/errors';\nimport { executeGoogleAuthenticationFlow } from './useSignInWithGoogle.shared';\nimport type {\n StartGoogleAuthenticationFlowParams,\n StartGoogleAuthenticationFlowReturnType,\n} from './useSignInWithGoogle.types';\n\nexport type { StartGoogleAuthenticationFlowParams, StartGoogleAuthenticationFlowReturnType };\n\n/**\n * Hook for native Google Authentication on Android using Clerk's built-in Google One Tap module.\n *\n * This hook provides a simplified way to authenticate users with their Google account\n * using the native Android Google Sign-In UI with Credential Manager. The authentication\n * flow automatically handles the ID token exchange with Clerk's backend and manages\n * the transfer flow between sign-in and sign-up.\n *\n * Features:\n * - Native Google One Tap UI\n * - Built-in nonce support for replay attack protection\n * - No additional dependencies required\n *\n * @example\n * ```tsx\n * import { useSignInWithGoogle } from '@clerk/clerk-expo';\n * import { Button } from 'react-native';\n *\n * function GoogleSignInButton() {\n * const { startGoogleAuthenticationFlow } = useSignInWithGoogle();\n *\n * const onPress = async () => {\n * try {\n * const { createdSessionId, setActive } = await startGoogleAuthenticationFlow();\n *\n * if (createdSessionId && setActive) {\n * await setActive({ session: createdSessionId });\n * }\n * } catch (err) {\n * console.error('Google Authentication error:', err);\n * }\n * };\n *\n * return <Button title=\"Sign in with Google\" onPress={onPress} />;\n * }\n * ```\n *\n * @platform Android - This is the Android-specific implementation using Credential Manager\n *\n * @returns An object containing the `startGoogleAuthenticationFlow` function\n */\nexport function useSignInWithGoogle() {\n const clerk = useClerk();\n\n async function startGoogleAuthenticationFlow(\n startGoogleAuthenticationFlowParams?: StartGoogleAuthenticationFlowParams,\n ): Promise<StartGoogleAuthenticationFlowReturnType> {\n const { client, loaded, setActive } = clerk;\n\n if (!loaded || !client) {\n return {\n createdSessionId: null,\n setActive,\n };\n }\n\n // Get environment variables from expo-constants\n const webClientId =\n Constants.expoConfig?.extra?.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID ||\n process.env.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID;\n\n if (!webClientId) {\n return errorThrower.throw(\n 'Google Sign-In credentials not found. Please set EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID in your .env file.',\n );\n }\n\n return executeGoogleAuthenticationFlow({ client, setActive }, { webClientId }, startGoogleAuthenticationFlowParams);\n }\n\n return {\n startGoogleAuthenticationFlow,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AACzB,4BAAsB;AAEtB,oBAA6B;AAC7B,iCAAgD;AAiDzC,SAAS,sBAAsB;AACpC,QAAM,YAAQ,uBAAS;AAEvB,iBAAe,8BACb,qCACkD;AA1DtD;AA2DI,UAAM,EAAE,QAAQ,QAAQ,UAAU,IAAI;AAEtC,QAAI,CAAC,UAAU,CAAC,QAAQ;AACtB,aAAO;AAAA,QACL,kBAAkB;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAGA,UAAM,gBACJ,iCAAAA,QAAU,eAAV,mBAAsB,UAAtB,mBAA6B,2CAC7B,QAAQ,IAAI;AAEd,QAAI,CAAC,aAAa;AAChB,aAAO,2BAAa;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAEA,eAAO,4DAAgC,EAAE,QAAQ,UAAU,GAAG,EAAE,YAAY,GAAG,mCAAmC;AAAA,EACpH;AAEA,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":["Constants"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SetActive, SignInResource, SignUpResource } from '@clerk/shared/types';
|
|
2
|
+
type SignUpUnsafeMetadata = Record<string, unknown>;
|
|
3
|
+
export type StartGoogleAuthenticationFlowParams = {
|
|
4
|
+
unsafeMetadata?: SignUpUnsafeMetadata;
|
|
5
|
+
};
|
|
6
|
+
export type StartGoogleAuthenticationFlowReturnType = {
|
|
7
|
+
createdSessionId: string | null;
|
|
8
|
+
setActive?: SetActive;
|
|
9
|
+
signIn?: SignInResource;
|
|
10
|
+
signUp?: SignUpResource;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Stub for Google Authentication hook on unsupported platforms.
|
|
14
|
+
*
|
|
15
|
+
* Native Google Authentication is only available on iOS and Android.
|
|
16
|
+
* For web platforms, use the OAuth-based Google Sign-In flow instead via useSSO.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* import { useSSO } from '@clerk/clerk-expo';
|
|
21
|
+
* import { Button } from 'react-native';
|
|
22
|
+
*
|
|
23
|
+
* function GoogleSignInButton() {
|
|
24
|
+
* const { startSSOFlow } = useSSO();
|
|
25
|
+
*
|
|
26
|
+
* const onPress = async () => {
|
|
27
|
+
* try {
|
|
28
|
+
* const { createdSessionId, setActive } = await startSSOFlow({
|
|
29
|
+
* strategy: 'oauth_google'
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* if (createdSessionId && setActive) {
|
|
33
|
+
* await setActive({ session: createdSessionId });
|
|
34
|
+
* }
|
|
35
|
+
* } catch (err) {
|
|
36
|
+
* console.error('Google Authentication error:', err);
|
|
37
|
+
* }
|
|
38
|
+
* };
|
|
39
|
+
*
|
|
40
|
+
* return <Button title="Sign in with Google" onPress={onPress} />;
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @platform iOS, Android - This hook only works on iOS and Android. On other platforms, it will throw an error.
|
|
45
|
+
*
|
|
46
|
+
* @returns An object containing the `startGoogleAuthenticationFlow` function that throws an error
|
|
47
|
+
*/
|
|
48
|
+
export declare function useSignInWithGoogle(): {
|
|
49
|
+
startGoogleAuthenticationFlow: (startGoogleAuthenticationFlowParams?: StartGoogleAuthenticationFlowParams) => Promise<StartGoogleAuthenticationFlowReturnType>;
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=useSignInWithGoogle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSignInWithGoogle.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignInWithGoogle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrF,KAAK,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,MAAM,MAAM,mCAAmC,GAAG;IAChD,cAAc,CAAC,EAAE,oBAAoB,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IACpD,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,mBAAmB,IAAI;IACrC,6BAA6B,EAAE,CAC7B,mCAAmC,CAAC,EAAE,mCAAmC,KACtE,OAAO,CAAC,uCAAuC,CAAC,CAAC;CACvD,CAaA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { StartGoogleAuthenticationFlowParams, StartGoogleAuthenticationFlowReturnType } from './useSignInWithGoogle.types';
|
|
2
|
+
export type { StartGoogleAuthenticationFlowParams, StartGoogleAuthenticationFlowReturnType };
|
|
3
|
+
/**
|
|
4
|
+
* Hook for native Google Authentication on iOS using Clerk's built-in Google Sign-In module.
|
|
5
|
+
*
|
|
6
|
+
* This hook provides a simplified way to authenticate users with their Google account
|
|
7
|
+
* using the native iOS Google Sign-In UI. The authentication flow automatically
|
|
8
|
+
* handles the ID token exchange with Clerk's backend and manages the transfer flow
|
|
9
|
+
* between sign-in and sign-up.
|
|
10
|
+
*
|
|
11
|
+
* Features:
|
|
12
|
+
* - Native Google Sign-In UI
|
|
13
|
+
* - Built-in nonce support for replay attack protection
|
|
14
|
+
* - No additional dependencies required
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { useSignInWithGoogle } from '@clerk/clerk-expo';
|
|
19
|
+
* import { Button } from 'react-native';
|
|
20
|
+
*
|
|
21
|
+
* function GoogleSigninButton() {
|
|
22
|
+
* const { startGoogleAuthenticationFlow } = useSignInWithGoogle();
|
|
23
|
+
*
|
|
24
|
+
* const onPress = async () => {
|
|
25
|
+
* try {
|
|
26
|
+
* const { createdSessionId, setActive } = await startGoogleAuthenticationFlow();
|
|
27
|
+
*
|
|
28
|
+
* if (createdSessionId && setActive) {
|
|
29
|
+
* await setActive({ session: createdSessionId });
|
|
30
|
+
* }
|
|
31
|
+
* } catch (err) {
|
|
32
|
+
* console.error('Google Authentication error:', err);
|
|
33
|
+
* }
|
|
34
|
+
* };
|
|
35
|
+
*
|
|
36
|
+
* return <Button title="Sign in with Google" onPress={onPress} />;
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @platform iOS - This is the iOS-specific implementation using Google Sign-In SDK
|
|
41
|
+
*
|
|
42
|
+
* @returns An object containing the `startGoogleAuthenticationFlow` function
|
|
43
|
+
*/
|
|
44
|
+
export declare function useSignInWithGoogle(): {
|
|
45
|
+
startGoogleAuthenticationFlow: (startGoogleAuthenticationFlowParams?: StartGoogleAuthenticationFlowParams) => Promise<StartGoogleAuthenticationFlowReturnType>;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=useSignInWithGoogle.ios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSignInWithGoogle.ios.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignInWithGoogle.ios.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,mCAAmC,EACnC,uCAAuC,EACxC,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,mCAAmC,EAAE,uCAAuC,EAAE,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,mBAAmB;0EAIO,mCAAmC,KACxE,OAAO,CAAC,uCAAuC,CAAC;EAkCpD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useSignInWithGoogle_ios_exports = {};
|
|
30
|
+
__export(useSignInWithGoogle_ios_exports, {
|
|
31
|
+
useSignInWithGoogle: () => useSignInWithGoogle
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useSignInWithGoogle_ios_exports);
|
|
34
|
+
var import_react = require("@clerk/react");
|
|
35
|
+
var import_expo_constants = __toESM(require("expo-constants"));
|
|
36
|
+
var import_errors = require("../utils/errors");
|
|
37
|
+
var import_useSignInWithGoogle = require("./useSignInWithGoogle.shared");
|
|
38
|
+
function useSignInWithGoogle() {
|
|
39
|
+
const clerk = (0, import_react.useClerk)();
|
|
40
|
+
async function startGoogleAuthenticationFlow(startGoogleAuthenticationFlowParams) {
|
|
41
|
+
var _a, _b, _c, _d;
|
|
42
|
+
const { client, loaded, setActive } = clerk;
|
|
43
|
+
if (!loaded || !client) {
|
|
44
|
+
return {
|
|
45
|
+
createdSessionId: null,
|
|
46
|
+
setActive
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const webClientId = ((_b = (_a = import_expo_constants.default.expoConfig) == null ? void 0 : _a.extra) == null ? void 0 : _b.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID) || process.env.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID;
|
|
50
|
+
const iosClientId = ((_d = (_c = import_expo_constants.default.expoConfig) == null ? void 0 : _c.extra) == null ? void 0 : _d.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID) || process.env.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID;
|
|
51
|
+
if (!webClientId || !iosClientId) {
|
|
52
|
+
return import_errors.errorThrower.throw(
|
|
53
|
+
"Google Sign-In credentials not found. Please set EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID and EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID in your .env file."
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return (0, import_useSignInWithGoogle.executeGoogleAuthenticationFlow)(
|
|
57
|
+
{ client, setActive },
|
|
58
|
+
{ webClientId, iosClientId },
|
|
59
|
+
startGoogleAuthenticationFlowParams
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
startGoogleAuthenticationFlow
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
useSignInWithGoogle
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=useSignInWithGoogle.ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useSignInWithGoogle.ios.ts"],"sourcesContent":["import { useClerk } from '@clerk/react';\nimport Constants from 'expo-constants';\n\nimport { errorThrower } from '../utils/errors';\nimport { executeGoogleAuthenticationFlow } from './useSignInWithGoogle.shared';\nimport type {\n StartGoogleAuthenticationFlowParams,\n StartGoogleAuthenticationFlowReturnType,\n} from './useSignInWithGoogle.types';\n\nexport type { StartGoogleAuthenticationFlowParams, StartGoogleAuthenticationFlowReturnType };\n\n/**\n * Hook for native Google Authentication on iOS using Clerk's built-in Google Sign-In module.\n *\n * This hook provides a simplified way to authenticate users with their Google account\n * using the native iOS Google Sign-In UI. The authentication flow automatically\n * handles the ID token exchange with Clerk's backend and manages the transfer flow\n * between sign-in and sign-up.\n *\n * Features:\n * - Native Google Sign-In UI\n * - Built-in nonce support for replay attack protection\n * - No additional dependencies required\n *\n * @example\n * ```tsx\n * import { useSignInWithGoogle } from '@clerk/clerk-expo';\n * import { Button } from 'react-native';\n *\n * function GoogleSigninButton() {\n * const { startGoogleAuthenticationFlow } = useSignInWithGoogle();\n *\n * const onPress = async () => {\n * try {\n * const { createdSessionId, setActive } = await startGoogleAuthenticationFlow();\n *\n * if (createdSessionId && setActive) {\n * await setActive({ session: createdSessionId });\n * }\n * } catch (err) {\n * console.error('Google Authentication error:', err);\n * }\n * };\n *\n * return <Button title=\"Sign in with Google\" onPress={onPress} />;\n * }\n * ```\n *\n * @platform iOS - This is the iOS-specific implementation using Google Sign-In SDK\n *\n * @returns An object containing the `startGoogleAuthenticationFlow` function\n */\nexport function useSignInWithGoogle() {\n const clerk = useClerk();\n\n async function startGoogleAuthenticationFlow(\n startGoogleAuthenticationFlowParams?: StartGoogleAuthenticationFlowParams,\n ): Promise<StartGoogleAuthenticationFlowReturnType> {\n const { client, loaded, setActive } = clerk;\n\n if (!loaded || !client) {\n return {\n createdSessionId: null,\n setActive,\n };\n }\n\n // Get environment variables from expo-constants\n const webClientId =\n Constants.expoConfig?.extra?.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID ||\n process.env.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID;\n const iosClientId =\n Constants.expoConfig?.extra?.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID ||\n process.env.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID;\n\n if (!webClientId || !iosClientId) {\n return errorThrower.throw(\n 'Google Sign-In credentials not found. Please set EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID and EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID in your .env file.',\n );\n }\n\n return executeGoogleAuthenticationFlow(\n { client, setActive },\n { webClientId, iosClientId },\n startGoogleAuthenticationFlowParams,\n );\n }\n\n return {\n startGoogleAuthenticationFlow,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AACzB,4BAAsB;AAEtB,oBAA6B;AAC7B,iCAAgD;AAiDzC,SAAS,sBAAsB;AACpC,QAAM,YAAQ,uBAAS;AAEvB,iBAAe,8BACb,qCACkD;AA1DtD;AA2DI,UAAM,EAAE,QAAQ,QAAQ,UAAU,IAAI;AAEtC,QAAI,CAAC,UAAU,CAAC,QAAQ;AACtB,aAAO;AAAA,QACL,kBAAkB;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAGA,UAAM,gBACJ,iCAAAA,QAAU,eAAV,mBAAsB,UAAtB,mBAA6B,2CAC7B,QAAQ,IAAI;AACd,UAAM,gBACJ,iCAAAA,QAAU,eAAV,mBAAsB,UAAtB,mBAA6B,2CAC7B,QAAQ,IAAI;AAEd,QAAI,CAAC,eAAe,CAAC,aAAa;AAChC,aAAO,2BAAa;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAEA,eAAO;AAAA,MACL,EAAE,QAAQ,UAAU;AAAA,MACpB,EAAE,aAAa,YAAY;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":["Constants"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useSignInWithGoogle_exports = {};
|
|
20
|
+
__export(useSignInWithGoogle_exports, {
|
|
21
|
+
useSignInWithGoogle: () => useSignInWithGoogle
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useSignInWithGoogle_exports);
|
|
24
|
+
var import_errors = require("../utils/errors");
|
|
25
|
+
function useSignInWithGoogle() {
|
|
26
|
+
function startGoogleAuthenticationFlow(_startGoogleAuthenticationFlowParams) {
|
|
27
|
+
return import_errors.errorThrower.throw(
|
|
28
|
+
'Native Google Authentication is only available on iOS and Android. For web and other platforms, please use the OAuth-based flow with useSSO and strategy: "oauth_google".'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
startGoogleAuthenticationFlow
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
useSignInWithGoogle
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=useSignInWithGoogle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useSignInWithGoogle.ts"],"sourcesContent":["import type { SetActive, SignInResource, SignUpResource } from '@clerk/shared/types';\n\nimport { errorThrower } from '../utils/errors';\n\ntype SignUpUnsafeMetadata = Record<string, unknown>;\n\nexport type StartGoogleAuthenticationFlowParams = {\n unsafeMetadata?: SignUpUnsafeMetadata;\n};\n\nexport type StartGoogleAuthenticationFlowReturnType = {\n createdSessionId: string | null;\n setActive?: SetActive;\n signIn?: SignInResource;\n signUp?: SignUpResource;\n};\n\n/**\n * Stub for Google Authentication hook on unsupported platforms.\n *\n * Native Google Authentication is only available on iOS and Android.\n * For web platforms, use the OAuth-based Google Sign-In flow instead via useSSO.\n *\n * @example\n * ```tsx\n * import { useSSO } from '@clerk/clerk-expo';\n * import { Button } from 'react-native';\n *\n * function GoogleSignInButton() {\n * const { startSSOFlow } = useSSO();\n *\n * const onPress = async () => {\n * try {\n * const { createdSessionId, setActive } = await startSSOFlow({\n * strategy: 'oauth_google'\n * });\n *\n * if (createdSessionId && setActive) {\n * await setActive({ session: createdSessionId });\n * }\n * } catch (err) {\n * console.error('Google Authentication error:', err);\n * }\n * };\n *\n * return <Button title=\"Sign in with Google\" onPress={onPress} />;\n * }\n * ```\n *\n * @platform iOS, Android - This hook only works on iOS and Android. On other platforms, it will throw an error.\n *\n * @returns An object containing the `startGoogleAuthenticationFlow` function that throws an error\n */\nexport function useSignInWithGoogle(): {\n startGoogleAuthenticationFlow: (\n startGoogleAuthenticationFlowParams?: StartGoogleAuthenticationFlowParams,\n ) => Promise<StartGoogleAuthenticationFlowReturnType>;\n} {\n function startGoogleAuthenticationFlow(\n _startGoogleAuthenticationFlowParams?: StartGoogleAuthenticationFlowParams,\n ): Promise<StartGoogleAuthenticationFlowReturnType> {\n return errorThrower.throw(\n 'Native Google Authentication is only available on iOS and Android. ' +\n 'For web and other platforms, please use the OAuth-based flow with useSSO and strategy: \"oauth_google\".',\n );\n }\n\n return {\n startGoogleAuthenticationFlow,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA6B;AAmDtB,SAAS,sBAId;AACA,WAAS,8BACP,sCACkD;AAClD,WAAO,2BAAa;AAAA,MAClB;AAAA,IAEF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ClientResource, SetActive } from '@clerk/shared/types';
|
|
2
|
+
import type { StartGoogleAuthenticationFlowParams, StartGoogleAuthenticationFlowReturnType } from './useSignInWithGoogle.types';
|
|
3
|
+
export type GoogleClientIds = {
|
|
4
|
+
webClientId: string;
|
|
5
|
+
iosClientId?: string;
|
|
6
|
+
};
|
|
7
|
+
export type GoogleAuthenticationFlowContext = {
|
|
8
|
+
client: ClientResource;
|
|
9
|
+
setActive: SetActive;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Core implementation of Google Authentication flow shared between iOS and Android.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function executeGoogleAuthenticationFlow(context: GoogleAuthenticationFlowContext, clientIds: GoogleClientIds, params?: StartGoogleAuthenticationFlowParams): Promise<StartGoogleAuthenticationFlowReturnType>;
|
|
17
|
+
//# sourceMappingURL=useSignInWithGoogle.shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSignInWithGoogle.shared.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignInWithGoogle.shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrE,OAAO,KAAK,EACV,mCAAmC,EACnC,uCAAuC,EACxC,MAAM,6BAA6B,CAAC;AAErC,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,+BAA+B,EACxC,SAAS,EAAE,eAAe,EAC1B,MAAM,CAAC,EAAE,mCAAmC,GAC3C,OAAO,CAAC,uCAAuC,CAAC,CAmGlD"}
|