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

Cache App Check debug token #5055

Merged
merged 8 commits into from
Jun 29, 2021
Merged

Cache App Check debug token #5055

merged 8 commits into from
Jun 29, 2021

Conversation

hsubox76
Copy link
Contributor

Cache the debug token to memory and indexedDB in a separate place from the regular app check token. Otherwise it will hit the exchange endpoint on every getToken() call and cause 429 (too many requests) errors.

Fixes #5052

@changeset-bot
Copy link

changeset-bot bot commented Jun 21, 2021

🦋 Changeset detected

Latest commit: b837c72

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

This PR includes changesets to release 3 packages
Name Type
@firebase/app-check 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

@hsubox76 hsubox76 requested a review from egilmorez as a code owner June 21, 2021 18:45
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jun 21, 2021

Binary Size Report

Affected SDKs

  • @firebase/app-check

    Type Base (3ea1e1f) Head (b9d535a) Diff
    browser 22.3 kB 22.7 kB +415 B (+1.9%)
    esm2017 18.5 kB 18.9 kB +333 B (+1.8%)
    main 22.3 kB 22.7 kB +415 B (+1.9%)
    module 21.9 kB 22.3 kB +403 B (+1.8%)
  • firebase

    Type Base (3ea1e1f) Head (b9d535a) Diff
    firebase-app-check.js 22.7 kB 22.9 kB +175 B (+0.8%)
    firebase.js 893 kB 893 kB +179 B (+0.0%)

Test Logs

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jun 21, 2021

Size Analysis Report

Affected Products

Diffs between base commit (3ea1e1f) and head commit (b9d535a) are too large (519,572 characters) to display.

Please check below links to see details from the original test log.

packages/app-check/src/internal-api.test.ts Outdated Show resolved Hide resolved
packages/app-check/src/internal-api.test.ts Outdated Show resolved Hide resolved
packages/app-check/src/internal-api.ts Outdated Show resolved Hide resolved
@Feiyang1 Feiyang1 assigned hsubox76 and unassigned Feiyang1 Jun 23, 2021
packages/app-check/src/api.test.ts Outdated Show resolved Hide resolved
packages/app-check/src/internal-api.test.ts Outdated Show resolved Hide resolved
packages/app-check/src/internal-api.test.ts Show resolved Hide resolved
const storageWriteStub = stub(storage, 'writeTokenToStorage');
stub(reCAPTCHA, 'getToken').resolves(fakeRecaptchaToken);
stub(client, 'exchangeToken').resolves(fakeRecaptchaAppCheckToken);
storageWriteStub.resetHistory();
Copy link
Member

Choose a reason for hiding this comment

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

what does resetHistory 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.

If the stub persists from test to test, it clears the call history so "calledOnce" is true even if it's called every time, but considering the stubs are all cleared and re-made after each test it's not needed here. Removed.

packages/app-check/src/internal-api.test.ts Outdated Show resolved Hide resolved
packages/app-check/src/internal-api.test.ts Outdated Show resolved Hide resolved
@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)
    

@hsubox76 hsubox76 merged commit 5d31e21 into master Jun 29, 2021
@hsubox76 hsubox76 deleted the ch-appcheck-dbug branch June 29, 2021 00:17
@google-oss-bot google-oss-bot mentioned this pull request Jun 29, 2021
@firebase firebase locked and limited conversation to collaborators Jul 29, 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.

Firebase app check 429 errors
3 participants