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 appcheck to distinguish between 3P/2P listeners #5084

Merged
merged 2 commits into from
Jun 30, 2021

Conversation

hsubox76
Copy link
Contributor

Fix a problem discovered while updating the exp version: #5069

App Check should treat listeners added by 3P vs 2P calls differently. 3P listeners should always call the supplied error handler if there's a token error. 2P listeners should return the token with the error field attached to the token.

Porting it here to the v8 version.

@changeset-bot
Copy link

changeset-bot bot commented Jun 30, 2021

🦋 Changeset detected

Latest commit: 7ae3d1d

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

This PR includes changesets to release 4 packages
Name Type
@firebase/app-check Patch
@firebase/app-check-types Patch
firebase Patch
@firebase/rules-unit-testing 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

@github-actions
Copy link
Contributor

Changeset File Check ⚠️

  • Changeset formatting error in following file:
    Package "firebase-compat-typings-test" must depend on the current version of "firebase-exp": "9.0.0-beta.5" vs "file:../../packages-exp/firebase-exp"
    Package "firebase-compat-typings-test" must depend on the current version of "firebase-exp": "9.0.0-beta.5" vs "file:../../packages-exp/firebase-exp"
    Package "firebase-compat-typings-test" must depend on the current version of "firebase-exp": "9.0.0-beta.5" vs "file:../../packages-exp/firebase-exp"
    Error: Failed to find where HEAD diverged from master. Does master exist?
        at async getChangedFilesSince (/home/runner/work/firebase-js-sdk/firebase-js-sdk/node_modules/@changesets/git/dist/git.cjs.dev.js:169:22)
        at async Object.getChangedPackagesSinceRef (/home/runner/work/firebase-js-sdk/firebase-js-sdk/node_modules/@changesets/git/dist/git.cjs.dev.js:208:24)
        at async getStatus (/home/runner/work/firebase-js-sdk/firebase-js-sdk/node_modules/@changesets/cli/dist/cli.cjs.dev.js:977:27)
        at async run$1 (/home/runner/work/firebase-js-sdk/firebase-js-sdk/node_modules/@changesets/cli/dist/cli.cjs.dev.js:1227:11)
    

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jun 30, 2021

Size Analysis Report

Affected Products

  • @firebase/app-check-exp

    • CustomProvider

      Size Table

      TypeBase (74ed43d)Head (882c99f)Diff
      size
      9.46 kB
      9.67 kB
      +214 B (+2.3%)
      size-with-ext-deps
      19.1 kB
      19.4 kB
      +214 B (+1.1%)

      Dependency Table

      TypeBase (74ed43d)Head (882c99f)Diff
      functions

      33 dependencies

      addTokenListener
      computeKey
      createTokenRefresher
      ensureActivated
      exchangeToken
      factory
      formatDummyToken
      getDBPromise
      getDebugState
      getDebugToken
      getExchangeDebugTokenRequest
      getState
      getToken$1
      initializeDebugMode
      internalFactory
      isDebugMode
      isValid
      makeDummyTokenResult
      notifyTokenListeners
      read
      readDebugTokenFromIndexedDB
      readOrCreateDebugTokenFromStorage
      readTokenFromIndexedDB
      readTokenFromStorage
      registerAppCheck
      removeTokenListener
      setState
      sleep
      uuidv4
      write
      writeDebugTokenToIndexedDB
      writeTokenToIndexedDB
      writeTokenToStorage
      

      33 dependencies

      addTokenListener
      computeKey
      createTokenRefresher
      ensureActivated
      exchangeToken
      factory
      formatDummyToken
      getDBPromise
      getDebugState
      getDebugToken
      getExchangeDebugTokenRequest
      getState
      getToken$2
      initializeDebugMode
      internalFactory
      isDebugMode
      isValid
      makeDummyTokenResult
      notifyTokenListeners
      read
      readDebugTokenFromIndexedDB
      readOrCreateDebugTokenFromStorage
      readTokenFromIndexedDB
      readTokenFromStorage
      registerAppCheck
      removeTokenListener
      setState
      sleep
      uuidv4
      write
      writeDebugTokenToIndexedDB
      writeTokenToIndexedDB
      writeTokenToStorage
      

      + getToken$2
      - getToken$1

    • ReCaptchaV3Provider

      Size Table

      TypeBase (74ed43d)Head (882c99f)Diff
      size
      10.7 kB
      11.0 kB
      +214 B (+2.0%)
      size-with-ext-deps
      20.0 kB
      20.2 kB
      +214 B (+1.1%)

      Dependency Table

      TypeBase (74ed43d)Head (882c99f)Diff
      functions

      39 dependencies

      addTokenListener
      computeKey
      createTokenRefresher
      ensureActivated
      exchangeToken
      factory
      formatDummyToken
      getDBPromise
      getDebugState
      getDebugToken
      getExchangeDebugTokenRequest
      getExchangeRecaptchaTokenRequest
      getRecaptcha
      getState
      getToken
      getToken$1
      initialize
      initializeDebugMode
      internalFactory
      isDebugMode
      isValid
      loadReCAPTCHAScript
      makeDummyTokenResult
      notifyTokenListeners
      read
      readDebugTokenFromIndexedDB
      readOrCreateDebugTokenFromStorage
      readTokenFromIndexedDB
      readTokenFromStorage
      registerAppCheck
      removeTokenListener
      renderInvisibleWidget
      setState
      sleep
      uuidv4
      write
      writeDebugTokenToIndexedDB
      writeTokenToIndexedDB
      writeTokenToStorage
      

      39 dependencies

      addTokenListener
      computeKey
      createTokenRefresher
      ensureActivated
      exchangeToken
      factory
      formatDummyToken
      getDBPromise
      getDebugState
      getDebugToken
      getExchangeDebugTokenRequest
      getExchangeRecaptchaTokenRequest
      getRecaptcha
      getState
      getToken$1
      getToken$2
      initialize
      initializeDebugMode
      internalFactory
      isDebugMode
      isValid
      loadReCAPTCHAScript
      makeDummyTokenResult
      notifyTokenListeners
      read
      readDebugTokenFromIndexedDB
      readOrCreateDebugTokenFromStorage
      readTokenFromIndexedDB
      readTokenFromStorage
      registerAppCheck
      removeTokenListener
      renderInvisibleWidget
      setState
      sleep
      uuidv4
      write
      writeDebugTokenToIndexedDB
      writeTokenToIndexedDB
      writeTokenToStorage
      

      + getToken$2
      - getToken

    • getToken

      Size Table

      TypeBase (74ed43d)Head (882c99f)Diff
      size
      ?
      9.38 kB
      ? (?)
      size-with-ext-deps
      ?
      18.6 kB
      ? (?)

      Dependency Table

      TypeBase (74ed43d)Head (882c99f)Diff
      functions
      ?

      34 dependencies

      addTokenListener
      computeKey
      createTokenRefresher
      ensureActivated
      exchangeToken
      factory
      formatDummyToken
      getDBPromise
      getDebugState
      getDebugToken
      getExchangeDebugTokenRequest
      getState
      getToken
      getToken$2
      initializeDebugMode
      internalFactory
      isDebugMode
      isValid
      makeDummyTokenResult
      notifyTokenListeners
      read
      readDebugTokenFromIndexedDB
      readOrCreateDebugTokenFromStorage
      readTokenFromIndexedDB
      readTokenFromStorage
      registerAppCheck
      removeTokenListener
      setState
      sleep
      uuidv4
      write
      writeDebugTokenToIndexedDB
      writeTokenToIndexedDB
      writeTokenToStorage
      

      ?
      classes
      ?

      AppCheckService
      Refresher
      

      ?
      variables
      ?

      19 dependencies

      APP_CHECK_NAME
      APP_CHECK_NAME_INTERNAL
      APP_CHECK_STATES
      BASE_ENDPOINT
      DB_NAME
      DB_VERSION
      DEBUG_STATE
      DEBUG_TOKEN_KEY
      DEFAULT_STATE
      ERRORS
      ERROR_FACTORY
      EXCHANGE_DEBUG_TOKEN_METHOD
      STORE_NAME
      TOKEN_REFRESH_TIME
      dbPromise
      defaultTokenErrorData
      logger
      name
      version
      

      ?
      enums
      ?
      ?

      External Dependency Table

      ModuleBase (74ed43d)Head (882c99f)Diff
      @firebase/app-exp
      ?

      _registerComponent
      registerVersion
      

      ?
      @firebase/component
      ?

      Component
      

      ?
      @firebase/util
      ?

      Deferred
      ErrorFactory
      base64
      getGlobal
      isIndexedDBAvailable
      

      ?
      @firebase/logger
      ?

      Logger
      

      ?
    • initializeAppCheck

      Size Table

      TypeBase (74ed43d)Head (882c99f)Diff
      size
      9.58 kB
      9.80 kB
      +214 B (+2.2%)
      size-with-ext-deps
      19.0 kB
      19.2 kB
      +214 B (+1.1%)

      Dependency Table

      TypeBase (74ed43d)Head (882c99f)Diff
      functions

      35 dependencies

      _activate
      addTokenListener
      computeKey
      createTokenRefresher
      ensureActivated
      exchangeToken
      factory
      formatDummyToken
      getDBPromise
      getDebugState
      getDebugToken
      getExchangeDebugTokenRequest
      getState
      getToken$1
      initializeAppCheck
      initializeDebugMode
      internalFactory
      isDebugMode
      isValid
      makeDummyTokenResult
      notifyTokenListeners
      read
      readDebugTokenFromIndexedDB
      readOrCreateDebugTokenFromStorage
      readTokenFromIndexedDB
      readTokenFromStorage
      registerAppCheck
      removeTokenListener
      setState
      sleep
      uuidv4
      write
      writeDebugTokenToIndexedDB
      writeTokenToIndexedDB
      writeTokenToStorage
      

      35 dependencies

      _activate
      addTokenListener
      computeKey
      createTokenRefresher
      ensureActivated
      exchangeToken
      factory
      formatDummyToken
      getDBPromise
      getDebugState
      getDebugToken
      getExchangeDebugTokenRequest
      getState
      getToken$2
      initializeAppCheck
      initializeDebugMode
      internalFactory
      isDebugMode
      isValid
      makeDummyTokenResult
      notifyTokenListeners
      read
      readDebugTokenFromIndexedDB
      readOrCreateDebugTokenFromStorage
      readTokenFromIndexedDB
      readTokenFromStorage
      registerAppCheck
      removeTokenListener
      setState
      sleep
      uuidv4
      write
      writeDebugTokenToIndexedDB
      writeTokenToIndexedDB
      writeTokenToStorage
      

      + getToken$2
      - getToken$1

    • onTokenChanged

      Size Table

      TypeBase (74ed43d)Head (882c99f)Diff
      size
      ?
      9.47 kB
      ? (?)
      size-with-ext-deps
      ?
      18.7 kB
      ? (?)

      Dependency Table

      TypeBase (74ed43d)Head (882c99f)Diff
      functions
      ?

      34 dependencies

      addTokenListener
      computeKey
      createTokenRefresher
      ensureActivated
      exchangeToken
      factory
      formatDummyToken
      getDBPromise
      getDebugState
      getDebugToken
      getExchangeDebugTokenRequest
      getState
      getToken$2
      initializeDebugMode
      internalFactory
      isDebugMode
      isValid
      makeDummyTokenResult
      notifyTokenListeners
      onTokenChanged
      read
      readDebugTokenFromIndexedDB
      readOrCreateDebugTokenFromStorage
      readTokenFromIndexedDB
      readTokenFromStorage
      registerAppCheck
      removeTokenListener
      setState
      sleep
      uuidv4
      write
      writeDebugTokenToIndexedDB
      writeTokenToIndexedDB
      writeTokenToStorage
      

      ?
      classes
      ?

      AppCheckService
      Refresher
      

      ?
      variables
      ?

      19 dependencies

      APP_CHECK_NAME
      APP_CHECK_NAME_INTERNAL
      APP_CHECK_STATES
      BASE_ENDPOINT
      DB_NAME
      DB_VERSION
      DEBUG_STATE
      DEBUG_TOKEN_KEY
      DEFAULT_STATE
      ERRORS
      ERROR_FACTORY
      EXCHANGE_DEBUG_TOKEN_METHOD
      STORE_NAME
      TOKEN_REFRESH_TIME
      dbPromise
      defaultTokenErrorData
      logger
      name
      version
      

      ?
      enums
      ?
      ?

      External Dependency Table

      ModuleBase (74ed43d)Head (882c99f)Diff
      @firebase/app-exp
      ?

      _registerComponent
      registerVersion
      

      ?
      @firebase/component
      ?

      Component
      

      ?
      @firebase/util
      ?

      Deferred
      ErrorFactory
      base64
      getGlobal
      isIndexedDBAvailable
      

      ?
      @firebase/logger
      ?

      Logger
      

      ?
    • setTokenAutoRefreshEnabled

      Size Table

      TypeBase (74ed43d)Head (882c99f)Diff
      size
      9.28 kB
      9.51 kB
      +228 B (+2.5%)
      size-with-ext-deps
      18.5 kB
      18.7 kB
      +228 B (+1.2%)

      Dependency Table

      TypeBase (74ed43d)Head (882c99f)Diff
      functions

      34 dependencies

      addTokenListener
      computeKey
      createTokenRefresher
      ensureActivated
      exchangeToken
      factory
      formatDummyToken
      getDBPromise
      getDebugState
      getDebugToken
      getExchangeDebugTokenRequest
      getState
      getToken$1
      initializeDebugMode
      internalFactory
      isDebugMode
      isValid
      makeDummyTokenResult
      notifyTokenListeners
      read
      readDebugTokenFromIndexedDB
      readOrCreateDebugTokenFromStorage
      readTokenFromIndexedDB
      readTokenFromStorage
      registerAppCheck
      removeTokenListener
      setState
      setTokenAutoRefreshEnabled
      sleep
      uuidv4
      write
      writeDebugTokenToIndexedDB
      writeTokenToIndexedDB
      writeTokenToStorage
      

      34 dependencies

      addTokenListener
      computeKey
      createTokenRefresher
      ensureActivated
      exchangeToken
      factory
      formatDummyToken
      getDBPromise
      getDebugState
      getDebugToken
      getExchangeDebugTokenRequest
      getState
      getToken$2
      initializeDebugMode
      internalFactory
      isDebugMode
      isValid
      makeDummyTokenResult
      notifyTokenListeners
      read
      readDebugTokenFromIndexedDB
      readOrCreateDebugTokenFromStorage
      readTokenFromIndexedDB
      readTokenFromStorage
      registerAppCheck
      removeTokenListener
      setState
      setTokenAutoRefreshEnabled
      sleep
      uuidv4
      write
      writeDebugTokenToIndexedDB
      writeTokenToIndexedDB
      writeTokenToStorage
      

      + getToken$2
      - getToken$1

  • @firebase/messaging-exp

    • deleteToken

      Dependency Table

      TypeBase (74ed43d)Head (882c99f)Diff
      functions

      27 dependencies

      arrayToBase64
      checkTokenDetails
      dbGet
      dbRemove
      dbSet
      deleteToken
      deleteToken$1
      deleteTokenInternal
      externalizePayload
      extractAppConfig
      getDbPromise
      getEndpoint
      getEventType
      getHeaders
      getKey
      getMissingValueError
      isConsoleMessage
      isWindowSupported
      logToScion
      messageEventListener
      migrateOldDatabase
      propagateDataPayload
      propagateFcmOptions
      propagateNotificationPayload
      registerDefaultSw
      registerMessagingInWindow
      requestDeleteToken
      

      26 dependencies

      arrayToBase64
      checkTokenDetails
      dbGet
      dbRemove
      dbSet
      deleteToken
      deleteTokenInternal
      externalizePayload
      extractAppConfig
      getDbPromise
      getEndpoint
      getEventType
      getHeaders
      getKey
      getMissingValueError
      isConsoleMessage
      isWindowSupported
      logToScion
      messageEventListener
      migrateOldDatabase
      propagateDataPayload
      propagateFcmOptions
      propagateNotificationPayload
      registerDefaultSw
      registerMessagingInWindow
      requestDeleteToken
      

      - deleteToken$1

    • getToken

      Dependency Table

      TypeBase (74ed43d)Head (882c99f)Diff
      functions

      38 dependencies

      arrayToBase64
      base64ToArray
      checkTokenDetails
      dbGet
      dbRemove
      dbSet
      deleteTokenInternal
      externalizePayload
      extractAppConfig
      getBody
      getDbPromise
      getEndpoint
      getEventType
      getHeaders
      getKey
      getMissingValueError
      getNewToken
      getPushSubscription
      getToken
      getToken$1
      getTokenInternal
      isConsoleMessage
      isTokenValid
      isWindowSupported
      logToScion
      messageEventListener
      migrateOldDatabase
      propagateDataPayload
      propagateFcmOptions
      propagateNotificationPayload
      registerDefaultSw
      registerMessagingInWindow
      requestDeleteToken
      requestGetToken
      requestUpdateToken
      updateSwReg
      updateToken
      updateVapidKey
      

      37 dependencies

      arrayToBase64
      base64ToArray
      checkTokenDetails
      dbGet
      dbRemove
      dbSet
      deleteTokenInternal
      externalizePayload
      extractAppConfig
      getBody
      getDbPromise
      getEndpoint
      getEventType
      getHeaders
      getKey
      getMissingValueError
      getNewToken
      getPushSubscription
      getToken
      getTokenInternal
      isConsoleMessage
      isTokenValid
      isWindowSupported
      logToScion
      messageEventListener
      migrateOldDatabase
      propagateDataPayload
      propagateFcmOptions
      propagateNotificationPayload
      registerDefaultSw
      registerMessagingInWindow
      requestDeleteToken
      requestGetToken
      requestUpdateToken
      updateSwReg
      updateToken
      updateVapidKey
      

      - getToken$1

    • onMessage

      Dependency Table

      TypeBase (74ed43d)Head (882c99f)Diff
      functions

      14 dependencies

      externalizePayload
      extractAppConfig
      getEventType
      getMissingValueError
      isConsoleMessage
      isWindowSupported
      logToScion
      messageEventListener
      onMessage
      onMessage$1
      propagateDataPayload
      propagateFcmOptions
      propagateNotificationPayload
      registerMessagingInWindow
      

      13 dependencies

      externalizePayload
      extractAppConfig
      getEventType
      getMissingValueError
      isConsoleMessage
      isWindowSupported
      logToScion
      messageEventListener
      onMessage
      propagateDataPayload
      propagateFcmOptions
      propagateNotificationPayload
      registerMessagingInWindow
      

      - onMessage$1

Comment on lines 41 to 42
'2P' = '2P',
'3P' = '3P'
Copy link
Member

Choose a reason for hiding this comment

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

Change to INTERNAL and EXTERNAL to be consistent with v9 implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

Comment on lines 4 to 5
"outDir": "dist",
"preserveConstEnums": true
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"outDir": "dist",
"preserveConstEnums": true
"outDir": "dist"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

@hsubox76 hsubox76 merged commit 5d007b8 into master Jun 30, 2021
@hsubox76 hsubox76 deleted the ch-appcheck-v8-listeners branch June 30, 2021 23:10
@google-oss-bot google-oss-bot mentioned this pull request Jun 30, 2021
@firebase firebase locked and limited conversation to collaborators Jul 31, 2021
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.

3 participants