Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the linkWithCredential API to call the signUp endpoint #7692

Merged
merged 5 commits into from
Nov 1, 2023

Conversation

prameshj
Copy link
Contributor

@prameshj prameshj commented Oct 11, 2023

The /signUp API supports linking when Email Enumeration Protection is enabled as well as disabled. /setAccountInfo does not work when Email Enumeration Protection is enabled.

Verified with the test app that anonymous user upgrade works.

@changeset-bot
Copy link

changeset-bot bot commented Oct 11, 2023

🦋 Changeset detected

Latest commit: f075b7c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/auth Patch
@firebase/auth-compat Patch
firebase Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 11, 2023

Size Report 1

Affected Products

  • @firebase/auth

    TypeBase (698eeb6)Merge (91cd419)Diff
    browser175 kB176 kB+202 B (+0.1%)
    cordova203 kB204 kB+297 B (+0.1%)
    esm5228 kB229 kB+297 B (+0.1%)
    main173 kB173 kB+309 B (+0.2%)
    module175 kB176 kB+202 B (+0.1%)
    react-native188 kB188 kB+313 B (+0.2%)
  • @firebase/auth/cordova

    TypeBase (698eeb6)Merge (91cd419)Diff
    browser203 kB204 kB+297 B (+0.1%)
    module203 kB204 kB+297 B (+0.1%)
  • @firebase/auth/internal

    TypeBase (698eeb6)Merge (91cd419)Diff
    browser186 kB186 kB+202 B (+0.1%)
    esm5242 kB242 kB+297 B (+0.1%)
    main209 kB209 kB+313 B (+0.1%)
    module186 kB186 kB+202 B (+0.1%)
  • bundle

    TypeBase (698eeb6)Merge (91cd419)Diff
    auth (EmailAndPassword)80.5 kB80.6 kB+59 B (+0.1%)
  • firebase

    TypeBase (698eeb6)Merge (91cd419)Diff
    firebase-auth-compat.js136 kB136 kB+111 B (+0.1%)
    firebase-auth-cordova.js173 kB173 kB+261 B (+0.2%)
    firebase-auth.js146 kB146 kB+143 B (+0.1%)
    firebase-compat.js777 kB777 kB+111 B (+0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/OhYqSLusMR.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 11, 2023

Size Analysis Report 1

Affected Products

  • @firebase/auth

    • EmailAuthCredential

      Size

      TypeBase (698eeb6)Merge (71a1afd)Diff
      size42.2 kB42.2 kB+59 B (+0.1%)
      size-with-ext-deps63.0 kB63.0 kB+59 B (+0.1%)

      Dependency

      TypeBase (698eeb6)Merge (71a1afd)Diff
      functions

      63 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseEnforcementState
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _performSignInRequest
      _persistenceKeyName
      _prodErrorMap
      _reloadWithoutSaving
      _tokenExpiresIn
      assertStringOrUndefined
      createErrorInternal
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      handleRecaptchaFlow
      injectRecaptchaFields
      isEnterprise
      isUserInvalidated
      mergeProviderData
      registerAuth
      reload
      requestStsToken
      secondsStringToMilliseconds
      signInWithEmailLink$1
      signInWithEmailLinkForLinking
      signInWithPassword
      updateEmailPassword
      utcTimestampToDateString

      63 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseEnforcementState
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _performSignInRequest
      _persistenceKeyName
      _prodErrorMap
      _reloadWithoutSaving
      _tokenExpiresIn
      assertStringOrUndefined
      createErrorInternal
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      handleRecaptchaFlow
      injectRecaptchaFields
      isEnterprise
      isUserInvalidated
      linkEmailPassword
      mergeProviderData
      registerAuth
      reload
      requestStsToken
      secondsStringToMilliseconds
      signInWithEmailLink$1
      signInWithEmailLinkForLinking
      signInWithPassword
      utcTimestampToDateString

      + linkEmailPassword
      - updateEmailPassword

    • EmailAuthProvider

      Size

      TypeBase (698eeb6)Merge (71a1afd)Diff
      size43.6 kB43.7 kB+59 B (+0.1%)
      size-with-ext-deps64.7 kB64.7 kB+59 B (+0.1%)

      Dependency

      TypeBase (698eeb6)Merge (71a1afd)Diff
      functions

      65 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseEnforcementState
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _performSignInRequest
      _persistenceKeyName
      _prodErrorMap
      _reloadWithoutSaving
      _tokenExpiresIn
      assertStringOrUndefined
      createErrorInternal
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      handleRecaptchaFlow
      injectRecaptchaFields
      isEnterprise
      isUserInvalidated
      mergeProviderData
      parseDeepLink
      parseMode
      registerAuth
      reload
      requestStsToken
      secondsStringToMilliseconds
      signInWithEmailLink$1
      signInWithEmailLinkForLinking
      signInWithPassword
      updateEmailPassword
      utcTimestampToDateString

      65 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseEnforcementState
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _performSignInRequest
      _persistenceKeyName
      _prodErrorMap
      _reloadWithoutSaving
      _tokenExpiresIn
      assertStringOrUndefined
      createErrorInternal
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      handleRecaptchaFlow
      injectRecaptchaFields
      isEnterprise
      isUserInvalidated
      linkEmailPassword
      mergeProviderData
      parseDeepLink
      parseMode
      registerAuth
      reload
      requestStsToken
      secondsStringToMilliseconds
      signInWithEmailLink$1
      signInWithEmailLinkForLinking
      signInWithPassword
      utcTimestampToDateString

      + linkEmailPassword
      - updateEmailPassword

    • signInWithEmailAndPassword

      Size

      TypeBase (698eeb6)Merge (71a1afd)Diff
      size45.3 kB45.3 kB+59 B (+0.1%)
      size-with-ext-deps66.3 kB66.4 kB+59 B (+0.1%)

      Dependency

      TypeBase (698eeb6)Merge (71a1afd)Diff
      functions

      71 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseEnforcementState
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _performSignInRequest
      _persistenceKeyName
      _processCredentialSavingMfaContextIfNecessary
      _prodErrorMap
      _reloadWithoutSaving
      _signInWithCredential
      _tokenExpiresIn
      assertStringOrUndefined
      createErrorInternal
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      handleRecaptchaFlow
      injectRecaptchaFields
      isEnterprise
      isUserInvalidated
      mergeProviderData
      parseDeepLink
      parseMode
      providerIdForResponse
      recachePasswordPolicy
      registerAuth
      reload
      requestStsToken
      secondsStringToMilliseconds
      signInWithCredential
      signInWithEmailAndPassword
      signInWithEmailLink$1
      signInWithEmailLinkForLinking
      signInWithPassword
      updateEmailPassword
      utcTimestampToDateString

      71 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseEnforcementState
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _performSignInRequest
      _persistenceKeyName
      _processCredentialSavingMfaContextIfNecessary
      _prodErrorMap
      _reloadWithoutSaving
      _signInWithCredential
      _tokenExpiresIn
      assertStringOrUndefined
      createErrorInternal
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      handleRecaptchaFlow
      injectRecaptchaFields
      isEnterprise
      isUserInvalidated
      linkEmailPassword
      mergeProviderData
      parseDeepLink
      parseMode
      providerIdForResponse
      recachePasswordPolicy
      registerAuth
      reload
      requestStsToken
      secondsStringToMilliseconds
      signInWithCredential
      signInWithEmailAndPassword
      signInWithEmailLink$1
      signInWithEmailLinkForLinking
      signInWithPassword
      utcTimestampToDateString

      + linkEmailPassword
      - updateEmailPassword

    • signInWithEmailLink

      Size

      TypeBase (698eeb6)Merge (71a1afd)Diff
      size45.3 kB45.3 kB+59 B (+0.1%)
      size-with-ext-deps66.3 kB66.4 kB+59 B (+0.1%)

      Dependency

      TypeBase (698eeb6)Merge (71a1afd)Diff
      functions

      71 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getCurrentUrl
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseEnforcementState
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _performSignInRequest
      _persistenceKeyName
      _processCredentialSavingMfaContextIfNecessary
      _prodErrorMap
      _reloadWithoutSaving
      _signInWithCredential
      _tokenExpiresIn
      assertStringOrUndefined
      createErrorInternal
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      handleRecaptchaFlow
      injectRecaptchaFields
      isEnterprise
      isUserInvalidated
      mergeProviderData
      parseDeepLink
      parseMode
      providerIdForResponse
      registerAuth
      reload
      requestStsToken
      secondsStringToMilliseconds
      signInWithCredential
      signInWithEmailLink
      signInWithEmailLink$1
      signInWithEmailLinkForLinking
      signInWithPassword
      updateEmailPassword
      utcTimestampToDateString

      71 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getCurrentUrl
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseEnforcementState
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _performSignInRequest
      _persistenceKeyName
      _processCredentialSavingMfaContextIfNecessary
      _prodErrorMap
      _reloadWithoutSaving
      _signInWithCredential
      _tokenExpiresIn
      assertStringOrUndefined
      createErrorInternal
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      handleRecaptchaFlow
      injectRecaptchaFields
      isEnterprise
      isUserInvalidated
      linkEmailPassword
      mergeProviderData
      parseDeepLink
      parseMode
      providerIdForResponse
      registerAuth
      reload
      requestStsToken
      secondsStringToMilliseconds
      signInWithCredential
      signInWithEmailLink
      signInWithEmailLink$1
      signInWithEmailLinkForLinking
      signInWithPassword
      utcTimestampToDateString

      + linkEmailPassword
      - updateEmailPassword

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/T1hAMHlj7H.html

@prameshj prameshj force-pushed the emailenum-link branch 2 times, most recently from 890a61d to a0e4b95 Compare October 11, 2023 05:08
@@ -166,7 +169,7 @@ export class EmailAuthCredential extends AuthCredential {
): Promise<IdTokenResponse> {
switch (this.signInMethod) {
case SignInMethod.EMAIL_PASSWORD:
return updateEmailPassword(auth, {
return linkEmailPassword(auth, {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once #7666 merges, we should also wrap this with reCAPTCHA Enterprise logic.

@prameshj prameshj force-pushed the emailenum-link branch 2 times, most recently from 29790a2 to fba2873 Compare October 11, 2023 15:59
@prameshj prameshj marked this pull request as ready for review October 11, 2023 16:01
@prameshj prameshj requested review from lisajian, renkelvin, sam-gc and a team as code owners October 11, 2023 16:01
@prameshj prameshj requested review from a team as code owners October 13, 2023 23:48
mockEndpointWithParams only works for URL params/GET and not for POST body.
Removed this usage with a TODO.
// First call without recaptcha token should fail with MISSING_RECAPTCHA_TOKEN error
// Though the internal implementation retries with a reCAPTCHA Enterprise token, the second call will fail in this test.
// This is because our endpoint mock does not support returning different responses based on different request body params.
// TODO(renkelvin) - refactor this once we expose a mockEndpointWithBodyParams or similar method.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this method do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean what SHOULD mockEndpointWithBodyParams do? We need a method that will send a different response based on a different request body.

mockEndpointWithParams - is an existing method which sends the specified response, for the request with the given URL Params. But our sign up/sign in are POST methods, so they never match the url param or the mock.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I think we may just create a single helper method like mockEndpoint(url, params, body).

@renkelvin renkelvin self-requested a review October 19, 2023 21:59
@prameshj prameshj merged commit f10acb3 into master Nov 1, 2023
@prameshj prameshj deleted the emailenum-link branch November 1, 2023 19:31
@google-oss-bot google-oss-bot mentioned this pull request Nov 7, 2023
prameshj added a commit that referenced this pull request Nov 13, 2023
* Update the linkWithCredential API to call the signUp endpoint

* Use the SignUpRequest and Response.

* changeset

* Add recaptcha enterprise support to the link API (which calls signUp)

* Refactored existing recaptcha enterprise tests, added new for link API.

mockEndpointWithParams only works for URL params/GET and not for POST body.
Removed this usage with a TODO.
@firebase firebase locked and limited conversation to collaborators Dec 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants