diff --git a/packages/auth/src/error_auth.js b/packages/auth/src/error_auth.js index 251718ea235..e6ae679ff62 100644 --- a/packages/auth/src/error_auth.js +++ b/packages/auth/src/error_auth.js @@ -147,6 +147,7 @@ fireauth.authenum.Error = { INVALID_PASSWORD: 'wrong-password', INVALID_PERSISTENCE: 'invalid-persistence-type', INVALID_PHONE_NUMBER: 'invalid-phone-number', + INVALID_PROVIDER_ID: 'invalid-provider-id', INVALID_RECIPIENT_EMAIL: 'invalid-recipient-email', INVALID_SENDER: 'invalid-sender', INVALID_SESSION_INFO: 'invalid-verification-id', @@ -294,6 +295,8 @@ fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_PHONE_NUMBER] = 'phone number in a format that can be parsed into E.164 format. E.164 ' + 'phone numbers are written in the format [+][country code][subscriber ' + 'number including area code].'; +fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_PROVIDER_ID] = + 'The specified provider ID is invalid.'; fireauth.AuthError.MESSAGES_[fireauth.authenum.Error.INVALID_RECIPIENT_EMAIL] = 'The email corresponding to this action failed to send as the provided ' + 'recipient email address is invalid.'; diff --git a/packages/auth/src/rpchandler.js b/packages/auth/src/rpchandler.js index 65a5352e38f..14aa28f4a9d 100644 --- a/packages/auth/src/rpchandler.js +++ b/packages/auth/src/rpchandler.js @@ -207,6 +207,7 @@ fireauth.RpcHandler.ServerError = { INVALID_OOB_CODE: 'INVALID_OOB_CODE', INVALID_PASSWORD: 'INVALID_PASSWORD', INVALID_PHONE_NUMBER: 'INVALID_PHONE_NUMBER', + INVALID_PROVIDER_ID: 'INVALID_PROVIDER_ID', INVALID_RECIPIENT_EMAIL: 'INVALID_RECIPIENT_EMAIL', INVALID_SENDER: 'INVALID_SENDER', INVALID_SESSION_INFO: 'INVALID_SESSION_INFO', @@ -2244,6 +2245,10 @@ fireauth.RpcHandler.getDeveloperError_ = errorMap[fireauth.RpcHandler.ServerError.MISSING_OOB_CODE] = fireauth.authenum.Error.INTERNAL_ERROR; + // Get Auth URI errors: + errorMap[fireauth.RpcHandler.ServerError.INVALID_PROVIDER_ID] = + fireauth.authenum.Error.INVALID_PROVIDER_ID; + // Operations that require ID token in request: errorMap[fireauth.RpcHandler.ServerError.CREDENTIAL_TOO_OLD_LOGIN_AGAIN] = fireauth.authenum.Error.CREDENTIAL_TOO_OLD_LOGIN_AGAIN; diff --git a/packages/auth/test/rpchandler_test.js b/packages/auth/test/rpchandler_test.js index 08fa7837219..27adb1e2471 100644 --- a/packages/auth/test/rpchandler_test.js +++ b/packages/auth/test/rpchandler_test.js @@ -5268,6 +5268,30 @@ function testGetAuthUri_success() { } +/** + * Tests server side getAuthUri error. + */ +function testGetAuthUri_caughtServerError() { + var expectedUrl = 'https://www.googleapis.com/identitytoolkit/v3/relyin' + + 'gparty/createAuthUri?key=apiKey'; + var requestBody = { + 'providerId': 'abc.com', + 'continueUri': 'http://localhost/widget', + 'customParameter': {} + }; + var errorMap = {}; + // All related server errors for getAuthUri. + errorMap[fireauth.RpcHandler.ServerError.INVALID_PROVIDER_ID] = + fireauth.authenum.Error.INVALID_PROVIDER_ID; + + assertServerErrorsAreHandled(function() { + return rpcHandler.getAuthUri( + 'abc.com', + 'http://localhost/widget'); + }, errorMap, expectedUrl, requestBody); +} + + /** * Tests successful getAuthUri request with Google provider and sessionId. */