@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.
Files changed (55) hide show
  1. package/android/build.gradle +64 -0
  2. package/android/src/main/AndroidManifest.xml +2 -0
  3. package/android/src/main/java/expo/modules/clerk/googlesignin/ClerkGoogleSignInModule.kt +264 -0
  4. package/app.plugin.js +1 -0
  5. package/dist/errorThrower.d.ts +1 -1
  6. package/dist/google-one-tap/ClerkGoogleOneTapSignIn.d.ts +104 -0
  7. package/dist/google-one-tap/ClerkGoogleOneTapSignIn.d.ts.map +1 -0
  8. package/dist/google-one-tap/ClerkGoogleOneTapSignIn.js +153 -0
  9. package/dist/google-one-tap/ClerkGoogleOneTapSignIn.js.map +1 -0
  10. package/dist/google-one-tap/index.d.ts +3 -0
  11. package/dist/google-one-tap/index.d.ts.map +1 -0
  12. package/dist/google-one-tap/index.js +37 -0
  13. package/dist/google-one-tap/index.js.map +1 -0
  14. package/dist/google-one-tap/types.d.ts +139 -0
  15. package/dist/google-one-tap/types.d.ts.map +1 -0
  16. package/dist/google-one-tap/types.js +17 -0
  17. package/dist/google-one-tap/types.js.map +1 -0
  18. package/dist/hooks/index.d.ts +1 -0
  19. package/dist/hooks/index.d.ts.map +1 -1
  20. package/dist/hooks/index.js +2 -0
  21. package/dist/hooks/index.js.map +1 -1
  22. package/dist/hooks/useSignInWithGoogle.android.d.ts +47 -0
  23. package/dist/hooks/useSignInWithGoogle.android.d.ts.map +1 -0
  24. package/dist/hooks/useSignInWithGoogle.android.js +65 -0
  25. package/dist/hooks/useSignInWithGoogle.android.js.map +1 -0
  26. package/dist/hooks/useSignInWithGoogle.d.ts +52 -0
  27. package/dist/hooks/useSignInWithGoogle.d.ts.map +1 -0
  28. package/dist/hooks/useSignInWithGoogle.ios.d.ts +47 -0
  29. package/dist/hooks/useSignInWithGoogle.ios.d.ts.map +1 -0
  30. package/dist/hooks/useSignInWithGoogle.ios.js +70 -0
  31. package/dist/hooks/useSignInWithGoogle.ios.js.map +1 -0
  32. package/dist/hooks/useSignInWithGoogle.js +39 -0
  33. package/dist/hooks/useSignInWithGoogle.js.map +1 -0
  34. package/dist/hooks/useSignInWithGoogle.shared.d.ts +17 -0
  35. package/dist/hooks/useSignInWithGoogle.shared.d.ts.map +1 -0
  36. package/dist/hooks/useSignInWithGoogle.shared.js +112 -0
  37. package/dist/hooks/useSignInWithGoogle.shared.js.map +1 -0
  38. package/dist/hooks/useSignInWithGoogle.types.d.ts +12 -0
  39. package/dist/hooks/useSignInWithGoogle.types.d.ts.map +1 -0
  40. package/dist/hooks/useSignInWithGoogle.types.js +17 -0
  41. package/dist/hooks/useSignInWithGoogle.types.js.map +1 -0
  42. package/dist/index.d.ts +0 -1
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +0 -3
  45. package/dist/index.js.map +1 -1
  46. package/dist/provider/ClerkProvider.js +1 -1
  47. package/dist/utils/errors.d.ts +1 -1
  48. package/expo-module.config.json +9 -0
  49. package/ios/ClerkGoogleSignIn.podspec +22 -0
  50. package/ios/ClerkGoogleSignInModule.swift +229 -0
  51. package/package.json +31 -10
  52. package/plugin/build/withClerkExpo.d.ts +3 -0
  53. package/plugin/build/withClerkExpo.js +36 -0
  54. package/plugin/src/withClerkExpo.ts +45 -0
  55. package/plugin/tsconfig.json +15 -0
@@ -0,0 +1,64 @@
1
+ apply plugin: 'com.android.library'
2
+ apply plugin: 'kotlin-android'
3
+
4
+ group = 'com.clerk.expo'
5
+ version = '1.0.0'
6
+
7
+ // Dependency versions - centralized for easier updates
8
+ // See: https://docs.gradle.org/current/userguide/version_catalogs.html for app-level version catalogs
9
+ ext {
10
+ credentialsVersion = "1.3.0"
11
+ googleIdVersion = "1.1.1"
12
+ kotlinxCoroutinesVersion = "1.7.3"
13
+ }
14
+
15
+ def safeExtGet(prop, fallback) {
16
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
17
+ }
18
+
19
+ android {
20
+ namespace "expo.modules.clerk.googlesignin"
21
+
22
+ compileSdk safeExtGet("compileSdkVersion", 36)
23
+
24
+ defaultConfig {
25
+ minSdk safeExtGet("minSdkVersion", 24)
26
+ targetSdk safeExtGet("targetSdkVersion", 36)
27
+ versionCode 1
28
+ versionName "1.0.0"
29
+ }
30
+
31
+ buildTypes {
32
+ release {
33
+ minifyEnabled false
34
+ }
35
+ }
36
+
37
+ compileOptions {
38
+ sourceCompatibility JavaVersion.VERSION_17
39
+ targetCompatibility JavaVersion.VERSION_17
40
+ }
41
+
42
+ kotlinOptions {
43
+ jvmTarget = "17"
44
+ }
45
+
46
+ sourceSets {
47
+ main {
48
+ java.srcDirs = ['src/main/java']
49
+ }
50
+ }
51
+ }
52
+
53
+ dependencies {
54
+ // Expo modules core
55
+ implementation project(':expo-modules-core')
56
+
57
+ // Credential Manager for Google Sign-In with nonce support
58
+ implementation "androidx.credentials:credentials:$credentialsVersion"
59
+ implementation "androidx.credentials:credentials-play-services-auth:$credentialsVersion"
60
+ implementation "com.google.android.libraries.identity.googleid:googleid:$googleIdVersion"
61
+
62
+ // Coroutines for async operations
63
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinxCoroutinesVersion"
64
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,264 @@
1
+ package expo.modules.clerk.googlesignin
2
+
3
+ import android.content.Context
4
+ import androidx.credentials.ClearCredentialStateRequest
5
+ import androidx.credentials.CredentialManager
6
+ import androidx.credentials.CustomCredential
7
+ import androidx.credentials.GetCredentialRequest
8
+ import androidx.credentials.GetCredentialResponse
9
+ import androidx.credentials.exceptions.GetCredentialCancellationException
10
+ import androidx.credentials.exceptions.GetCredentialException
11
+ import androidx.credentials.exceptions.NoCredentialException
12
+ import com.google.android.libraries.identity.googleid.GetGoogleIdOption
13
+ import com.google.android.libraries.identity.googleid.GetSignInWithGoogleOption
14
+ import com.google.android.libraries.identity.googleid.GoogleIdTokenCredential
15
+ import com.google.android.libraries.identity.googleid.GoogleIdTokenParsingException
16
+ import expo.modules.kotlin.Promise
17
+ import expo.modules.kotlin.exception.CodedException
18
+ import expo.modules.kotlin.modules.Module
19
+ import expo.modules.kotlin.modules.ModuleDefinition
20
+ import expo.modules.kotlin.records.Field
21
+ import expo.modules.kotlin.records.Record
22
+ import kotlinx.coroutines.CoroutineScope
23
+ import kotlinx.coroutines.Dispatchers
24
+ import kotlinx.coroutines.launch
25
+
26
+ // Configuration parameters
27
+ class ConfigureParams : Record {
28
+ @Field
29
+ val webClientId: String = ""
30
+
31
+ @Field
32
+ val hostedDomain: String? = null
33
+
34
+ @Field
35
+ val autoSelectEnabled: Boolean? = null
36
+ }
37
+
38
+ // Sign-in parameters
39
+ class SignInParams : Record {
40
+ @Field
41
+ val nonce: String? = null
42
+
43
+ @Field
44
+ val filterByAuthorizedAccounts: Boolean? = null
45
+ }
46
+
47
+ // Create account parameters
48
+ class CreateAccountParams : Record {
49
+ @Field
50
+ val nonce: String? = null
51
+ }
52
+
53
+ // Explicit sign-in parameters
54
+ class ExplicitSignInParams : Record {
55
+ @Field
56
+ val nonce: String? = null
57
+ }
58
+
59
+ // Custom exceptions
60
+ class GoogleSignInCancelledException : CodedException("SIGN_IN_CANCELLED", "User cancelled the sign-in flow", null)
61
+ class GoogleSignInNoCredentialException : CodedException("NO_SAVED_CREDENTIAL_FOUND", "No saved credential found", null)
62
+ class GoogleSignInException(message: String) : CodedException("GOOGLE_SIGN_IN_ERROR", message, null)
63
+ class GoogleSignInNotConfiguredException : CodedException("NOT_CONFIGURED", "Google Sign-In is not configured. Call configure() first.", null)
64
+ class GoogleSignInActivityUnavailableException : CodedException("E_ACTIVITY_UNAVAILABLE", "Activity is not available", null)
65
+
66
+ class ClerkGoogleSignInModule : Module() {
67
+ private var webClientId: String? = null
68
+ private var hostedDomain: String? = null
69
+ private var autoSelectEnabled: Boolean = false
70
+ private val mainScope = CoroutineScope(Dispatchers.Main)
71
+
72
+ private val context: Context
73
+ get() = requireNotNull(appContext.reactContext)
74
+
75
+ private val credentialManager: CredentialManager
76
+ get() = CredentialManager.create(context)
77
+
78
+ override fun definition() = ModuleDefinition {
79
+ Name("ClerkGoogleSignIn")
80
+
81
+ // Configure the module
82
+ Function("configure") { params: ConfigureParams ->
83
+ webClientId = params.webClientId
84
+ hostedDomain = params.hostedDomain
85
+ autoSelectEnabled = params.autoSelectEnabled ?: false
86
+ }
87
+
88
+ // Sign in - attempts automatic sign-in with saved credentials
89
+ AsyncFunction("signIn") { params: SignInParams?, promise: Promise ->
90
+ val clientId = webClientId ?: run {
91
+ promise.reject(GoogleSignInNotConfiguredException())
92
+ return@AsyncFunction
93
+ }
94
+
95
+ val activity = appContext.currentActivity ?: run {
96
+ promise.reject(GoogleSignInActivityUnavailableException())
97
+ return@AsyncFunction
98
+ }
99
+
100
+ mainScope.launch {
101
+ try {
102
+ val googleIdOption = GetGoogleIdOption.Builder()
103
+ .setFilterByAuthorizedAccounts(params?.filterByAuthorizedAccounts ?: true)
104
+ .setServerClientId(clientId)
105
+ .setAutoSelectEnabled(autoSelectEnabled)
106
+ .apply {
107
+ params?.nonce?.let { setNonce(it) }
108
+ }
109
+ .build()
110
+
111
+ val request = GetCredentialRequest.Builder()
112
+ .addCredentialOption(googleIdOption)
113
+ .build()
114
+
115
+ val result = credentialManager.getCredential(
116
+ request = request,
117
+ context = activity
118
+ )
119
+
120
+ handleSignInResult(result, promise)
121
+ } catch (e: GetCredentialCancellationException) {
122
+ promise.reject(GoogleSignInCancelledException())
123
+ } catch (e: NoCredentialException) {
124
+ promise.reject(GoogleSignInNoCredentialException())
125
+ } catch (e: GetCredentialException) {
126
+ promise.reject(GoogleSignInException(e.message ?: "Unknown error"))
127
+ } catch (e: Exception) {
128
+ promise.reject(GoogleSignInException(e.message ?: "Unknown error"))
129
+ }
130
+ }
131
+ }
132
+
133
+ // Create account - shows account creation UI
134
+ AsyncFunction("createAccount") { params: CreateAccountParams?, promise: Promise ->
135
+ val clientId = webClientId ?: run {
136
+ promise.reject(GoogleSignInNotConfiguredException())
137
+ return@AsyncFunction
138
+ }
139
+
140
+ val activity = appContext.currentActivity ?: run {
141
+ promise.reject(GoogleSignInActivityUnavailableException())
142
+ return@AsyncFunction
143
+ }
144
+
145
+ mainScope.launch {
146
+ try {
147
+ val googleIdOption = GetGoogleIdOption.Builder()
148
+ .setFilterByAuthorizedAccounts(false) // Show all accounts for creation
149
+ .setServerClientId(clientId)
150
+ .apply {
151
+ params?.nonce?.let { setNonce(it) }
152
+ }
153
+ .build()
154
+
155
+ val request = GetCredentialRequest.Builder()
156
+ .addCredentialOption(googleIdOption)
157
+ .build()
158
+
159
+ val result = credentialManager.getCredential(
160
+ request = request,
161
+ context = activity
162
+ )
163
+
164
+ handleSignInResult(result, promise)
165
+ } catch (e: GetCredentialCancellationException) {
166
+ promise.reject(GoogleSignInCancelledException())
167
+ } catch (e: NoCredentialException) {
168
+ promise.reject(GoogleSignInNoCredentialException())
169
+ } catch (e: GetCredentialException) {
170
+ promise.reject(GoogleSignInException(e.message ?: "Unknown error"))
171
+ } catch (e: Exception) {
172
+ promise.reject(GoogleSignInException(e.message ?: "Unknown error"))
173
+ }
174
+ }
175
+ }
176
+
177
+ // Explicit sign-in - uses Sign In With Google button flow
178
+ AsyncFunction("presentExplicitSignIn") { params: ExplicitSignInParams?, promise: Promise ->
179
+ val clientId = webClientId ?: run {
180
+ promise.reject(GoogleSignInNotConfiguredException())
181
+ return@AsyncFunction
182
+ }
183
+
184
+ val activity = appContext.currentActivity ?: run {
185
+ promise.reject(GoogleSignInActivityUnavailableException())
186
+ return@AsyncFunction
187
+ }
188
+
189
+ mainScope.launch {
190
+ try {
191
+ val signInWithGoogleOption = GetSignInWithGoogleOption.Builder(clientId)
192
+ .apply {
193
+ params?.nonce?.let { setNonce(it) }
194
+ hostedDomain?.let { setHostedDomainFilter(it) }
195
+ }
196
+ .build()
197
+
198
+ val request = GetCredentialRequest.Builder()
199
+ .addCredentialOption(signInWithGoogleOption)
200
+ .build()
201
+
202
+ val result = credentialManager.getCredential(
203
+ request = request,
204
+ context = activity
205
+ )
206
+
207
+ handleSignInResult(result, promise)
208
+ } catch (e: GetCredentialCancellationException) {
209
+ promise.reject(GoogleSignInCancelledException())
210
+ } catch (e: GetCredentialException) {
211
+ promise.reject(GoogleSignInException(e.message ?: "Unknown error"))
212
+ } catch (e: Exception) {
213
+ promise.reject(GoogleSignInException(e.message ?: "Unknown error"))
214
+ }
215
+ }
216
+ }
217
+
218
+ // Sign out - clears credential state
219
+ AsyncFunction("signOut") { promise: Promise ->
220
+ mainScope.launch {
221
+ try {
222
+ credentialManager.clearCredentialState(ClearCredentialStateRequest())
223
+ promise.resolve(null)
224
+ } catch (e: Exception) {
225
+ promise.reject(GoogleSignInException(e.message ?: "Failed to sign out"))
226
+ }
227
+ }
228
+ }
229
+ }
230
+
231
+ private fun handleSignInResult(result: GetCredentialResponse, promise: Promise) {
232
+ when (val credential = result.credential) {
233
+ is CustomCredential -> {
234
+ if (credential.type == GoogleIdTokenCredential.TYPE_GOOGLE_ID_TOKEN_CREDENTIAL) {
235
+ try {
236
+ val googleIdTokenCredential = GoogleIdTokenCredential.createFrom(credential.data)
237
+
238
+ promise.resolve(mapOf(
239
+ "type" to "success",
240
+ "data" to mapOf(
241
+ "idToken" to googleIdTokenCredential.idToken,
242
+ "user" to mapOf(
243
+ "id" to googleIdTokenCredential.id,
244
+ "email" to googleIdTokenCredential.id,
245
+ "name" to googleIdTokenCredential.displayName,
246
+ "givenName" to googleIdTokenCredential.givenName,
247
+ "familyName" to googleIdTokenCredential.familyName,
248
+ "photo" to googleIdTokenCredential.profilePictureUri?.toString()
249
+ )
250
+ )
251
+ ))
252
+ } catch (e: GoogleIdTokenParsingException) {
253
+ promise.reject(GoogleSignInException("Failed to parse Google ID token: ${e.message}"))
254
+ }
255
+ } else {
256
+ promise.reject(GoogleSignInException("Unexpected credential type: ${credential.type}"))
257
+ }
258
+ }
259
+ else -> {
260
+ promise.reject(GoogleSignInException("Unexpected credential type"))
261
+ }
262
+ }
263
+ }
264
+ }
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/build/withClerkExpo');
@@ -1,3 +1,3 @@
1
- declare const errorThrower: import("@clerk/shared/error-FQfTKcEF").y;
1
+ declare const errorThrower: import("@clerk/shared/error-uvNWuzfd").y;
2
2
  export { errorThrower };
3
3
  //# sourceMappingURL=errorThrower.d.ts.map
@@ -0,0 +1,104 @@
1
+ import type { CancelledResponse, ConfigureParams, CreateAccountParams, ExplicitSignInParams, NoSavedCredentialFound, OneTapResponse, OneTapSuccessResponse, SignInParams } from './types';
2
+ /**
3
+ * Check if a response indicates the user cancelled the sign-in flow.
4
+ */
5
+ export declare function isCancelledResponse(response: OneTapResponse): response is CancelledResponse;
6
+ /**
7
+ * Check if a response indicates no saved credential was found.
8
+ */
9
+ export declare function isNoSavedCredentialFoundResponse(response: OneTapResponse): response is NoSavedCredentialFound;
10
+ /**
11
+ * Check if a response is a successful sign-in.
12
+ */
13
+ export declare function isSuccessResponse(response: OneTapResponse): response is OneTapSuccessResponse;
14
+ /**
15
+ * Check if an error has a code property (Google Sign-In error).
16
+ */
17
+ export declare function isErrorWithCode(error: unknown): error is {
18
+ code: string;
19
+ message: string;
20
+ };
21
+ /**
22
+ * Clerk's Google One Tap Sign-In module for Android.
23
+ *
24
+ * This module provides native Google Sign-In functionality using Google's
25
+ * Credential Manager API with full nonce support for replay attack protection.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * import { ClerkGoogleOneTapSignIn } from '@clerk/clerk-expo';
30
+ * import * as Crypto from 'expo-crypto';
31
+ *
32
+ * // Configure once at app startup
33
+ * ClerkGoogleOneTapSignIn.configure({
34
+ * webClientId: 'YOUR_WEB_CLIENT_ID',
35
+ * });
36
+ *
37
+ * // Sign in with nonce
38
+ * const nonce = Crypto.randomUUID();
39
+ * const response = await ClerkGoogleOneTapSignIn.signIn({ nonce });
40
+ *
41
+ * if (response.type === 'success') {
42
+ * const { idToken } = response.data;
43
+ * // Use idToken with Clerk
44
+ * }
45
+ * ```
46
+ *
47
+ * @platform Android
48
+ */
49
+ export declare const ClerkGoogleOneTapSignIn: {
50
+ /**
51
+ * Configure Google Sign-In. Must be called before any sign-in methods.
52
+ *
53
+ * @param params - Configuration parameters
54
+ * @param params.webClientId - The web client ID from Google Cloud Console (required)
55
+ * @param params.hostedDomain - Optional domain restriction
56
+ * @param params.autoSelectEnabled - Auto-select for single credential (default: false)
57
+ */
58
+ configure(params: ConfigureParams): void;
59
+ /**
60
+ * Attempt to sign in with saved credentials (One Tap).
61
+ *
62
+ * This method will show the One Tap UI if there are saved credentials,
63
+ * or return a "noSavedCredentialFound" response if there are none.
64
+ *
65
+ * @param params - Sign-in parameters
66
+ * @param params.nonce - Cryptographic nonce for replay protection
67
+ * @param params.filterByAuthorizedAccounts - Only show previously authorized accounts (default: true)
68
+ *
69
+ * @returns Promise resolving to OneTapResponse
70
+ */
71
+ signIn(params?: SignInParams): Promise<OneTapResponse>;
72
+ /**
73
+ * Create a new account (shows all Google accounts).
74
+ *
75
+ * This method shows the account picker with all available Google accounts,
76
+ * not just previously authorized ones.
77
+ *
78
+ * @param params - Create account parameters
79
+ * @param params.nonce - Cryptographic nonce for replay protection
80
+ *
81
+ * @returns Promise resolving to OneTapResponse
82
+ */
83
+ createAccount(params?: CreateAccountParams): Promise<OneTapResponse>;
84
+ /**
85
+ * Present explicit sign-in UI (Google Sign-In button flow).
86
+ *
87
+ * This shows the full Google Sign-In UI, similar to clicking a
88
+ * "Sign in with Google" button.
89
+ *
90
+ * @param params - Explicit sign-in parameters
91
+ * @param params.nonce - Cryptographic nonce for replay protection
92
+ *
93
+ * @returns Promise resolving to OneTapResponse
94
+ */
95
+ presentExplicitSignIn(params?: ExplicitSignInParams): Promise<OneTapResponse>;
96
+ /**
97
+ * Sign out and clear credential state.
98
+ *
99
+ * This disables automatic sign-in until the user signs in again.
100
+ */
101
+ signOut(): Promise<void>;
102
+ };
103
+ export type { ConfigureParams, SignInParams, CreateAccountParams, ExplicitSignInParams, OneTapResponse, OneTapSuccessResponse, CancelledResponse, NoSavedCredentialFound, GoogleUser, } from './types';
104
+ //# sourceMappingURL=ClerkGoogleOneTapSignIn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClerkGoogleOneTapSignIn.d.ts","sourceRoot":"","sources":["../../src/google-one-tap/ClerkGoogleOneTapSignIn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,EACd,qBAAqB,EACrB,YAAY,EACb,MAAM,SAAS,CAAC;AAqBjB;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,GAAG,QAAQ,IAAI,iBAAiB,CAE3F;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,cAAc,GAAG,QAAQ,IAAI,sBAAsB,CAE7G;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,QAAQ,IAAI,qBAAqB,CAE7F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAO1F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,uBAAuB;IAClC;;;;;;;OAOG;sBACe,eAAe,GAAG,IAAI;IAIxC;;;;;;;;;;;OAWG;oBACmB,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;IAgB5D;;;;;;;;;;OAUG;2BAC0B,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAgB1E;;;;;;;;;;OAUG;mCACkC,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC;IAanF;;;;OAIG;eACc,OAAO,CAAC,IAAI,CAAC;CAG/B,CAAC;AAEF,YAAY,EACV,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,GACX,MAAM,SAAS,CAAC"}
@@ -0,0 +1,153 @@
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 ClerkGoogleOneTapSignIn_exports = {};
20
+ __export(ClerkGoogleOneTapSignIn_exports, {
21
+ ClerkGoogleOneTapSignIn: () => ClerkGoogleOneTapSignIn,
22
+ isCancelledResponse: () => isCancelledResponse,
23
+ isErrorWithCode: () => isErrorWithCode,
24
+ isNoSavedCredentialFoundResponse: () => isNoSavedCredentialFoundResponse,
25
+ isSuccessResponse: () => isSuccessResponse
26
+ });
27
+ module.exports = __toCommonJS(ClerkGoogleOneTapSignIn_exports);
28
+ var import_expo_modules_core = require("expo-modules-core");
29
+ let _nativeModule = null;
30
+ function getNativeModule() {
31
+ if (!_nativeModule) {
32
+ _nativeModule = (0, import_expo_modules_core.requireNativeModule)("ClerkGoogleSignIn");
33
+ }
34
+ return _nativeModule;
35
+ }
36
+ function isCancelledResponse(response) {
37
+ return response.type === "cancelled";
38
+ }
39
+ function isNoSavedCredentialFoundResponse(response) {
40
+ return response.type === "noSavedCredentialFound";
41
+ }
42
+ function isSuccessResponse(response) {
43
+ return response.type === "success";
44
+ }
45
+ function isErrorWithCode(error) {
46
+ return error !== null && typeof error === "object" && "code" in error && typeof error.code === "string";
47
+ }
48
+ const ClerkGoogleOneTapSignIn = {
49
+ /**
50
+ * Configure Google Sign-In. Must be called before any sign-in methods.
51
+ *
52
+ * @param params - Configuration parameters
53
+ * @param params.webClientId - The web client ID from Google Cloud Console (required)
54
+ * @param params.hostedDomain - Optional domain restriction
55
+ * @param params.autoSelectEnabled - Auto-select for single credential (default: false)
56
+ */
57
+ configure(params) {
58
+ getNativeModule().configure(params);
59
+ },
60
+ /**
61
+ * Attempt to sign in with saved credentials (One Tap).
62
+ *
63
+ * This method will show the One Tap UI if there are saved credentials,
64
+ * or return a "noSavedCredentialFound" response if there are none.
65
+ *
66
+ * @param params - Sign-in parameters
67
+ * @param params.nonce - Cryptographic nonce for replay protection
68
+ * @param params.filterByAuthorizedAccounts - Only show previously authorized accounts (default: true)
69
+ *
70
+ * @returns Promise resolving to OneTapResponse
71
+ */
72
+ async signIn(params) {
73
+ try {
74
+ return await getNativeModule().signIn(params != null ? params : {});
75
+ } catch (error) {
76
+ if (isErrorWithCode(error)) {
77
+ if (error.code === "SIGN_IN_CANCELLED") {
78
+ return { type: "cancelled", data: null };
79
+ }
80
+ if (error.code === "NO_SAVED_CREDENTIAL_FOUND") {
81
+ return { type: "noSavedCredentialFound", data: null };
82
+ }
83
+ }
84
+ throw error;
85
+ }
86
+ },
87
+ /**
88
+ * Create a new account (shows all Google accounts).
89
+ *
90
+ * This method shows the account picker with all available Google accounts,
91
+ * not just previously authorized ones.
92
+ *
93
+ * @param params - Create account parameters
94
+ * @param params.nonce - Cryptographic nonce for replay protection
95
+ *
96
+ * @returns Promise resolving to OneTapResponse
97
+ */
98
+ async createAccount(params) {
99
+ try {
100
+ return await getNativeModule().createAccount(params != null ? params : {});
101
+ } catch (error) {
102
+ if (isErrorWithCode(error)) {
103
+ if (error.code === "SIGN_IN_CANCELLED") {
104
+ return { type: "cancelled", data: null };
105
+ }
106
+ if (error.code === "NO_SAVED_CREDENTIAL_FOUND") {
107
+ return { type: "noSavedCredentialFound", data: null };
108
+ }
109
+ }
110
+ throw error;
111
+ }
112
+ },
113
+ /**
114
+ * Present explicit sign-in UI (Google Sign-In button flow).
115
+ *
116
+ * This shows the full Google Sign-In UI, similar to clicking a
117
+ * "Sign in with Google" button.
118
+ *
119
+ * @param params - Explicit sign-in parameters
120
+ * @param params.nonce - Cryptographic nonce for replay protection
121
+ *
122
+ * @returns Promise resolving to OneTapResponse
123
+ */
124
+ async presentExplicitSignIn(params) {
125
+ try {
126
+ return await getNativeModule().presentExplicitSignIn(params != null ? params : {});
127
+ } catch (error) {
128
+ if (isErrorWithCode(error)) {
129
+ if (error.code === "SIGN_IN_CANCELLED") {
130
+ return { type: "cancelled", data: null };
131
+ }
132
+ }
133
+ throw error;
134
+ }
135
+ },
136
+ /**
137
+ * Sign out and clear credential state.
138
+ *
139
+ * This disables automatic sign-in until the user signs in again.
140
+ */
141
+ async signOut() {
142
+ await getNativeModule().signOut();
143
+ }
144
+ };
145
+ // Annotate the CommonJS export names for ESM import in node:
146
+ 0 && (module.exports = {
147
+ ClerkGoogleOneTapSignIn,
148
+ isCancelledResponse,
149
+ isErrorWithCode,
150
+ isNoSavedCredentialFoundResponse,
151
+ isSuccessResponse
152
+ });
153
+ //# sourceMappingURL=ClerkGoogleOneTapSignIn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/google-one-tap/ClerkGoogleOneTapSignIn.ts"],"sourcesContent":["import { requireNativeModule } from 'expo-modules-core';\n\nimport type {\n CancelledResponse,\n ConfigureParams,\n CreateAccountParams,\n ExplicitSignInParams,\n NoSavedCredentialFound,\n OneTapResponse,\n OneTapSuccessResponse,\n SignInParams,\n} from './types';\n\n// Type for the native module methods\ninterface ClerkGoogleSignInNativeModule {\n configure(params: ConfigureParams): void;\n signIn(params: SignInParams): Promise<OneTapResponse>;\n createAccount(params: CreateAccountParams): Promise<OneTapResponse>;\n presentExplicitSignIn(params: ExplicitSignInParams): Promise<OneTapResponse>;\n signOut(): Promise<void>;\n}\n\n// Lazy-load the native module to avoid crashes when not available\nlet _nativeModule: ClerkGoogleSignInNativeModule | null = null;\n\nfunction getNativeModule(): ClerkGoogleSignInNativeModule {\n if (!_nativeModule) {\n _nativeModule = requireNativeModule<ClerkGoogleSignInNativeModule>('ClerkGoogleSignIn');\n }\n return _nativeModule;\n}\n\n/**\n * Check if a response indicates the user cancelled the sign-in flow.\n */\nexport function isCancelledResponse(response: OneTapResponse): response is CancelledResponse {\n return response.type === 'cancelled';\n}\n\n/**\n * Check if a response indicates no saved credential was found.\n */\nexport function isNoSavedCredentialFoundResponse(response: OneTapResponse): response is NoSavedCredentialFound {\n return response.type === 'noSavedCredentialFound';\n}\n\n/**\n * Check if a response is a successful sign-in.\n */\nexport function isSuccessResponse(response: OneTapResponse): response is OneTapSuccessResponse {\n return response.type === 'success';\n}\n\n/**\n * Check if an error has a code property (Google Sign-In error).\n */\nexport function isErrorWithCode(error: unknown): error is { code: string; message: string } {\n return (\n error !== null &&\n typeof error === 'object' &&\n 'code' in error &&\n typeof (error as { code: unknown }).code === 'string'\n );\n}\n\n/**\n * Clerk's Google One Tap Sign-In module for Android.\n *\n * This module provides native Google Sign-In functionality using Google's\n * Credential Manager API with full nonce support for replay attack protection.\n *\n * @example\n * ```typescript\n * import { ClerkGoogleOneTapSignIn } from '@clerk/clerk-expo';\n * import * as Crypto from 'expo-crypto';\n *\n * // Configure once at app startup\n * ClerkGoogleOneTapSignIn.configure({\n * webClientId: 'YOUR_WEB_CLIENT_ID',\n * });\n *\n * // Sign in with nonce\n * const nonce = Crypto.randomUUID();\n * const response = await ClerkGoogleOneTapSignIn.signIn({ nonce });\n *\n * if (response.type === 'success') {\n * const { idToken } = response.data;\n * // Use idToken with Clerk\n * }\n * ```\n *\n * @platform Android\n */\nexport const ClerkGoogleOneTapSignIn = {\n /**\n * Configure Google Sign-In. Must be called before any sign-in methods.\n *\n * @param params - Configuration parameters\n * @param params.webClientId - The web client ID from Google Cloud Console (required)\n * @param params.hostedDomain - Optional domain restriction\n * @param params.autoSelectEnabled - Auto-select for single credential (default: false)\n */\n configure(params: ConfigureParams): void {\n getNativeModule().configure(params);\n },\n\n /**\n * Attempt to sign in with saved credentials (One Tap).\n *\n * This method will show the One Tap UI if there are saved credentials,\n * or return a \"noSavedCredentialFound\" response if there are none.\n *\n * @param params - Sign-in parameters\n * @param params.nonce - Cryptographic nonce for replay protection\n * @param params.filterByAuthorizedAccounts - Only show previously authorized accounts (default: true)\n *\n * @returns Promise resolving to OneTapResponse\n */\n async signIn(params?: SignInParams): Promise<OneTapResponse> {\n try {\n return await getNativeModule().signIn(params ?? {});\n } catch (error) {\n if (isErrorWithCode(error)) {\n if (error.code === 'SIGN_IN_CANCELLED') {\n return { type: 'cancelled', data: null };\n }\n if (error.code === 'NO_SAVED_CREDENTIAL_FOUND') {\n return { type: 'noSavedCredentialFound', data: null };\n }\n }\n throw error;\n }\n },\n\n /**\n * Create a new account (shows all Google accounts).\n *\n * This method shows the account picker with all available Google accounts,\n * not just previously authorized ones.\n *\n * @param params - Create account parameters\n * @param params.nonce - Cryptographic nonce for replay protection\n *\n * @returns Promise resolving to OneTapResponse\n */\n async createAccount(params?: CreateAccountParams): Promise<OneTapResponse> {\n try {\n return await getNativeModule().createAccount(params ?? {});\n } catch (error) {\n if (isErrorWithCode(error)) {\n if (error.code === 'SIGN_IN_CANCELLED') {\n return { type: 'cancelled', data: null };\n }\n if (error.code === 'NO_SAVED_CREDENTIAL_FOUND') {\n return { type: 'noSavedCredentialFound', data: null };\n }\n }\n throw error;\n }\n },\n\n /**\n * Present explicit sign-in UI (Google Sign-In button flow).\n *\n * This shows the full Google Sign-In UI, similar to clicking a\n * \"Sign in with Google\" button.\n *\n * @param params - Explicit sign-in parameters\n * @param params.nonce - Cryptographic nonce for replay protection\n *\n * @returns Promise resolving to OneTapResponse\n */\n async presentExplicitSignIn(params?: ExplicitSignInParams): Promise<OneTapResponse> {\n try {\n return await getNativeModule().presentExplicitSignIn(params ?? {});\n } catch (error) {\n if (isErrorWithCode(error)) {\n if (error.code === 'SIGN_IN_CANCELLED') {\n return { type: 'cancelled', data: null };\n }\n }\n throw error;\n }\n },\n\n /**\n * Sign out and clear credential state.\n *\n * This disables automatic sign-in until the user signs in again.\n */\n async signOut(): Promise<void> {\n await getNativeModule().signOut();\n },\n};\n\nexport type {\n ConfigureParams,\n SignInParams,\n CreateAccountParams,\n ExplicitSignInParams,\n OneTapResponse,\n OneTapSuccessResponse,\n CancelledResponse,\n NoSavedCredentialFound,\n GoogleUser,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAoC;AAuBpC,IAAI,gBAAsD;AAE1D,SAAS,kBAAiD;AACxD,MAAI,CAAC,eAAe;AAClB,wBAAgB,8CAAmD,mBAAmB;AAAA,EACxF;AACA,SAAO;AACT;AAKO,SAAS,oBAAoB,UAAyD;AAC3F,SAAO,SAAS,SAAS;AAC3B;AAKO,SAAS,iCAAiC,UAA8D;AAC7G,SAAO,SAAS,SAAS;AAC3B;AAKO,SAAS,kBAAkB,UAA6D;AAC7F,SAAO,SAAS,SAAS;AAC3B;AAKO,SAAS,gBAAgB,OAA4D;AAC1F,SACE,UAAU,QACV,OAAO,UAAU,YACjB,UAAU,SACV,OAAQ,MAA4B,SAAS;AAEjD;AA8BO,MAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASrC,UAAU,QAA+B;AACvC,oBAAgB,EAAE,UAAU,MAAM;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,OAAO,QAAgD;AAC3D,QAAI;AACF,aAAO,MAAM,gBAAgB,EAAE,OAAO,0BAAU,CAAC,CAAC;AAAA,IACpD,SAAS,OAAO;AACd,UAAI,gBAAgB,KAAK,GAAG;AAC1B,YAAI,MAAM,SAAS,qBAAqB;AACtC,iBAAO,EAAE,MAAM,aAAa,MAAM,KAAK;AAAA,QACzC;AACA,YAAI,MAAM,SAAS,6BAA6B;AAC9C,iBAAO,EAAE,MAAM,0BAA0B,MAAM,KAAK;AAAA,QACtD;AAAA,MACF;AACA,YAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAM,cAAc,QAAuD;AACzE,QAAI;AACF,aAAO,MAAM,gBAAgB,EAAE,cAAc,0BAAU,CAAC,CAAC;AAAA,IAC3D,SAAS,OAAO;AACd,UAAI,gBAAgB,KAAK,GAAG;AAC1B,YAAI,MAAM,SAAS,qBAAqB;AACtC,iBAAO,EAAE,MAAM,aAAa,MAAM,KAAK;AAAA,QACzC;AACA,YAAI,MAAM,SAAS,6BAA6B;AAC9C,iBAAO,EAAE,MAAM,0BAA0B,MAAM,KAAK;AAAA,QACtD;AAAA,MACF;AACA,YAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAM,sBAAsB,QAAwD;AAClF,QAAI;AACF,aAAO,MAAM,gBAAgB,EAAE,sBAAsB,0BAAU,CAAC,CAAC;AAAA,IACnE,SAAS,OAAO;AACd,UAAI,gBAAgB,KAAK,GAAG;AAC1B,YAAI,MAAM,SAAS,qBAAqB;AACtC,iBAAO,EAAE,MAAM,aAAa,MAAM,KAAK;AAAA,QACzC;AAAA,MACF;AACA,YAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,UAAyB;AAC7B,UAAM,gBAAgB,EAAE,QAAQ;AAAA,EAClC;AACF;","names":[]}
@@ -0,0 +1,3 @@
1
+ export { ClerkGoogleOneTapSignIn, isCancelledResponse, isNoSavedCredentialFoundResponse, isSuccessResponse, isErrorWithCode, } from './ClerkGoogleOneTapSignIn';
2
+ export type { ConfigureParams, SignInParams, CreateAccountParams, ExplicitSignInParams, OneTapResponse, OneTapSuccessResponse, CancelledResponse, NoSavedCredentialFound, GoogleUser, GoogleSignInError, GoogleSignInErrorCode, } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/google-one-tap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,gCAAgC,EAChC,iBAAiB,EACjB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,37 @@
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 google_one_tap_exports = {};
20
+ __export(google_one_tap_exports, {
21
+ ClerkGoogleOneTapSignIn: () => import_ClerkGoogleOneTapSignIn.ClerkGoogleOneTapSignIn,
22
+ isCancelledResponse: () => import_ClerkGoogleOneTapSignIn.isCancelledResponse,
23
+ isErrorWithCode: () => import_ClerkGoogleOneTapSignIn.isErrorWithCode,
24
+ isNoSavedCredentialFoundResponse: () => import_ClerkGoogleOneTapSignIn.isNoSavedCredentialFoundResponse,
25
+ isSuccessResponse: () => import_ClerkGoogleOneTapSignIn.isSuccessResponse
26
+ });
27
+ module.exports = __toCommonJS(google_one_tap_exports);
28
+ var import_ClerkGoogleOneTapSignIn = require("./ClerkGoogleOneTapSignIn");
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ ClerkGoogleOneTapSignIn,
32
+ isCancelledResponse,
33
+ isErrorWithCode,
34
+ isNoSavedCredentialFoundResponse,
35
+ isSuccessResponse
36
+ });
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/google-one-tap/index.ts"],"sourcesContent":["export {\n ClerkGoogleOneTapSignIn,\n isCancelledResponse,\n isNoSavedCredentialFoundResponse,\n isSuccessResponse,\n isErrorWithCode,\n} from './ClerkGoogleOneTapSignIn';\n\nexport type {\n ConfigureParams,\n SignInParams,\n CreateAccountParams,\n ExplicitSignInParams,\n OneTapResponse,\n OneTapSuccessResponse,\n CancelledResponse,\n NoSavedCredentialFound,\n GoogleUser,\n GoogleSignInError,\n GoogleSignInErrorCode,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qCAMO;","names":[]}