diff --git a/auth/email_action_links.go b/auth/email_action_links.go index 6b649254..282e79fe 100644 --- a/auth/email_action_links.go +++ b/auth/email_action_links.go @@ -31,7 +31,9 @@ type ActionCodeSettings struct { AndroidPackageName string `json:"androidPackageName,omitempty"` AndroidMinimumVersion string `json:"androidMinimumVersion,omitempty"` AndroidInstallApp bool `json:"androidInstallApp,omitempty"` - DynamicLinkDomain string `json:"dynamicLinkDomain,omitempty"` + LinkDomain string `json:"linkDomain,omitempty"` + // Deprecated: Use LinkDomain instead. + DynamicLinkDomain string `json:"dynamicLinkDomain,omitempty"` } func (settings *ActionCodeSettings) toMap() (map[string]interface{}, error) { diff --git a/auth/email_action_links_test.go b/auth/email_action_links_test.go index 876f3300..2575ff32 100644 --- a/auth/email_action_links_test.go +++ b/auth/email_action_links_test.go @@ -35,6 +35,7 @@ var testActionLinkResponse = []byte(fmt.Sprintf(testActionLinkFormat, testAction var testActionCodeSettings = &ActionCodeSettings{ URL: "https://example.dynamic.link", HandleCodeInApp: true, + LinkDomain: "hosted.page.link", DynamicLinkDomain: "custom.page.link", IOSBundleID: "com.example.ios", AndroidPackageName: "com.example.android", @@ -44,6 +45,7 @@ var testActionCodeSettings = &ActionCodeSettings{ var testActionCodeSettingsMap = map[string]interface{}{ "continueUrl": "https://example.dynamic.link", "canHandleCodeInApp": true, + "linkDomain": "hosted.page.link", "dynamicLinkDomain": "custom.page.link", "iOSBundleId": "com.example.ios", "androidPackageName": "com.example.android", @@ -293,6 +295,7 @@ func TestEmailVerificationLinkError(t *testing.T) { cases := map[string]func(error) bool{ "UNAUTHORIZED_DOMAIN": IsUnauthorizedContinueURI, "INVALID_DYNAMIC_LINK_DOMAIN": IsInvalidDynamicLinkDomain, + "INVALID_HOSTING_LINK_DOMAIN": IsInvalidHostingLinkDomain, } s := echoServer(testActionLinkResponse, t) defer s.Close() diff --git a/auth/user_mgt.go b/auth/user_mgt.go index 601c1e03..63a5c381 100644 --- a/auth/user_mgt.go +++ b/auth/user_mgt.go @@ -522,6 +522,7 @@ const ( emailAlreadyExists = "EMAIL_ALREADY_EXISTS" emailNotFound = "EMAIL_NOT_FOUND" invalidDynamicLinkDomain = "INVALID_DYNAMIC_LINK_DOMAIN" + invalidHostingLinkDomain = "INVALID_HOSTING_LINK_DOMAIN" phoneNumberAlreadyExists = "PHONE_NUMBER_ALREADY_EXISTS" tenantNotFound = "TENANT_NOT_FOUND" uidAlreadyExists = "UID_ALREADY_EXISTS" @@ -556,6 +557,11 @@ func IsInvalidDynamicLinkDomain(err error) bool { return hasAuthErrorCode(err, invalidDynamicLinkDomain) } +// IsInvalidHostingLinkDomain checks if the given error was due to an invalid hosting link domain. +func IsInvalidHostingLinkDomain(err error) bool { + return hasAuthErrorCode(err, invalidHostingLinkDomain) +} + // IsInvalidEmail checks if the given error was due to an invalid email. // // Deprecated: Always returns false. @@ -1447,6 +1453,11 @@ var serverError = map[string]*authError{ message: "the provided dynamic link domain is not configured or authorized for the current project", authCode: invalidDynamicLinkDomain, }, + "INVALID_HOSTING_LINK_DOMAIN": { + code: internal.InvalidArgument, + message: "the provided hosting link domain is not configured in Firebase Hosting or is not owned by the current project", + authCode: invalidHostingLinkDomain, + }, "PHONE_NUMBER_EXISTS": { code: internal.AlreadyExists, message: "user with the provided phone number already exists", diff --git a/auth/user_mgt_test.go b/auth/user_mgt_test.go index 97e64c39..53ccdc58 100644 --- a/auth/user_mgt_test.go +++ b/auth/user_mgt_test.go @@ -2151,6 +2151,11 @@ func TestHTTPErrorWithCode(t *testing.T) { errorutils.IsInvalidArgument, "the provided dynamic link domain is not configured or authorized for the current project", }, + "INVALID_HOSTING_LINK_DOMAIN": { + IsInvalidHostingLinkDomain, + errorutils.IsInvalidArgument, + "the provided hosting link domain is not configured in Firebase Hosting or is not owned by the current project", + }, "PHONE_NUMBER_EXISTS": { IsPhoneNumberAlreadyExists, errorutils.IsAlreadyExists,