Conversation
Create a Tab class to store the per-tab states, and add the listeners for the tab events to update the Tab objects accordingly.
The HTTP header cf-chl-bypass is used to determine what Privacy Pass provider (Cloudflare or hCaptcha) the website supports. We change the tab context according to that header value.
Put the directory structure and the list of improvements to the previous version in the README file.
Because Cloudflare CI uses npm by default, it's better to follow the convention.
We change the place where the context is cleared from onBeforeRequest to onHeadersReceived so that the context will last a bit longer
1. Update the number after issuances and redemptions 2. Update the number when the active tab is changed 3. Update the number when the page in the tab is changed
Changes: - Removes crypto library, since extension relies on webcrypto API and sjcl libraries. - creating a voprf module. - Making Jest to work with ESM. - Adding linter and formating files with prettier. - Fix return type. - Rename a listener file. - Replacing ProviderID -> ProviderId. - Removing plural from providers. - Replacing HCaptcha -> Hcaptcha. - Adding contributor guide. - Adding return types to satisfy linter. - Removing default exports. - Add strickNullChecks to configuration. - Removing yarn related files. - Removing isomorphic-webcrypto. - Attaching TABS variable to window global object.
We need a Storage class so that we can add middlewares for all the operations of the storage.
Since, when clearing the tokens, the provider buttons have to know that the tokens are cleared, we Redux to share such info among the React components. By doing this we can update the number of tokens shown in the buttons immediately when the tokens are cleared
For icon updating, we allow the provider to explicitly actively update the icon using the callback instead of using the event listeners implemented in the Tab class. By doing this, the provider has the freedom to update the icon any time it wants. For tab reloading, we move the logic to the Tab class so that the provider doesn't have to use the Chrome API directly and allow the provider to reload the tab using the callback in the same way as in icon updating.
The issuance involves handleBeforeRequest listener. 1. Firstly, the listener check if the request looks like the one that we should send an issuance request. 2. If it passes the check, the listener returns the cancel command to cancel the request. If not, it returns nothing and let the request continue. 3. At the same time the listener returns, it calls a private method "issue" to send an issuance request to the server and the method return an array of issued tokens. 4. The listener stored the issued tokens in the storage. 5. The listener reloads the tab to get the proper web page for the tab. The redemption involves handleHeadersReceived and handleBeforeSendHeaders listeners. In handleHeadersReceived listener, 1. Firstly, the listener check if the response is the challenge page and it supports Privacy Pass redemption. 2. If it passes the check, the listener gets a token from the storage to redeem. 3. The listener sets "redeemInfo" property which includes the request id and the mentioned token. The property will be used by handleBeforeSendHeaders to redeem the token. 4. The listener returns the redirect command so that the browser will send the same request again with the token attached. In handleBeforeSendHeaders, 1. The listener will check if the provided request id matches the request id in "redeemInfo". If so, it means that the request is from the redirect command returned by handleHeadersReceived. If not, it returns nothing and let the request continue. 2. If it passes the check, the listener attaches the token from "redeemInfo" in the "challenge-bypass-token" HTTP header and clears the "redeemInfo" property because "redeemInfo" is used already.
armfazh
approved these changes
Nov 17, 2021
Member
|
GitHub says there are still conflicts with the rebase. @ppopth |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.