diff --git a/src/backend/Firebase.res b/src/backend/Firebase.res index c5e9cf9..70de170 100644 --- a/src/backend/Firebase.res +++ b/src/backend/Firebase.res @@ -503,11 +503,15 @@ module StyledFirebaseAuth = { module Functions = { type t + // we are currently using just these two, but more can be added if needed + // @see https://firebase.google.com/docs/functions/locations + type functionLocation = [#"europe-central2" | #"europe-west3"] + @module("firebase/functions") external getFunctions: FirebaseApp.t => t = "getFunctions" @module("firebase/functions") - external getFunctionsInRegion: (FirebaseApp.t, string) => t = "getFunctions" + external getFunctionsInRegion: (FirebaseApp.t, functionLocation) => t = "getFunctions" type callResult<'a> = {data: 'a} @module("firebase/functions") diff --git a/src/backend/FirebaseWebAuthn.res b/src/backend/FirebaseWebAuthn.res index c119dcf..11c18fa 100644 --- a/src/backend/FirebaseWebAuthn.res +++ b/src/backend/FirebaseWebAuthn.res @@ -1,16 +1,17 @@ @module("@firebase-web-authn/browser") -external linkWithPasskey: ( +external createUserWithPasskey: ( Firebase.Auth.t, Firebase.Functions.t, string, -) => promise = "linkWithPasskey" +) => promise = "createUserWithPasskey" @module("@firebase-web-authn/browser") -external createUserWithPasskey: ( +external linkWithPasskey: ( Firebase.Auth.t, Firebase.Functions.t, string, -) => promise = "createUserWithPasskey" +) => promise = "linkWithPasskey" + @module("@firebase-web-authn/browser") external signInWithPasskey: ( diff --git a/src/components/FirebaseAuthProvider/FirebaseAuthProvider.res b/src/components/FirebaseAuthProvider/FirebaseAuthProvider.res index 3e3115d..40b6eec 100644 --- a/src/components/FirebaseAuthProvider/FirebaseAuthProvider.res +++ b/src/components/FirebaseAuthProvider/FirebaseAuthProvider.res @@ -14,7 +14,7 @@ let make = (~children) => { Auth.setLanguageCode(auth, "cs") let analytics = app->Analytics.getAnalytics - let functions = app->Functions.getFunctionsInRegion(`europe-west3`) + let functions = app->Functions.getFunctionsInRegion(#"europe-west3") let messaging = app->Messaging.getMessaging diff --git a/src/pages/Onboarding/Onboarding.res b/src/pages/Onboarding/Onboarding.res index b3938f5..386bae0 100644 --- a/src/pages/Onboarding/Onboarding.res +++ b/src/pages/Onboarding/Onboarding.res @@ -22,7 +22,7 @@ let make = (~children, ~user: Firebase.User.t) => { let email = user.email->Null.getExn try { // TODO: upgrade the FirebaseWebAuthn and deploy to "europe-west3" - let functions = app->Firebase.Functions.getFunctionsInRegion(`us-central1`) + let functions = app->Firebase.Functions.getFunctionsInRegion(#"europe-central2") let _ = await FirebaseWebAuthn.linkWithPasskey(auth, functions, email) setWebAuthn(Some("1")) } catch { diff --git a/src/pages/Unauthenticated/Unauthenticated.res b/src/pages/Unauthenticated/Unauthenticated.res index 78e0904..605a3eb 100644 --- a/src/pages/Unauthenticated/Unauthenticated.res +++ b/src/pages/Unauthenticated/Unauthenticated.res @@ -8,7 +8,7 @@ let make = () => { let (view, setView) = React.useState(() => SignIn) let (signInWithPasskey, runSignInWithPasskey) = Hooks.usePromise(() => { // TODO: upgrade the FirebaseWebAuthn and deploy to "europe-west3" - let functions = app->Firebase.Functions.getFunctionsInRegion(`us-central1`) + let functions = app->Firebase.Functions.getFunctionsInRegion(#"europe-central2") FirebaseWebAuthn.signInWithPasskey(auth, functions) }) let isOnlineStatus = DomUtils.useIsOnline()