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

Allow landing page to be configured with a precomputed nonce (fix for CF workers) #7601

Merged
merged 5 commits into from Jun 7, 2023

Conversation

trevor-scheer
Copy link
Member

@trevor-scheer trevor-scheer commented Jun 7, 2023

#7539 introduced a v4() call from the uuid package which broke CF workers (apollo-server-integrations/apollo-server-integration-cloudflare-workers#37). This change allows users to configure / precompute the nonce in advance to avoid making crypto-y calls on startup (which CF workers throws errors about).

@trevor-scheer trevor-scheer requested a review from a team June 7, 2023 17:09
@netlify
Copy link

netlify bot commented Jun 7, 2023

Deploy Preview for apollo-server-docs ready!

Name Link
🔨 Latest commit 52bee17
🔍 Latest deploy log https://app.netlify.com/sites/apollo-server-docs/deploys/6480dd6d84a4080008d10984
😎 Deploy Preview https://deploy-preview-7601--apollo-server-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Jun 7, 2023

Deploy Preview for apollo-server-docs failed.

Name Link
🔨 Latest commit ca35e25
🔍 Latest deploy log https://app.netlify.com/sites/apollo-server-docs/deploys/6480b9d39c445600080090b2

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 7, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 52bee17:

Sandbox Source
Apollo Server Typescript Configuration
Apollo Server Configuration

Cloudflare workers don't allow calls to crypto fns among
other things during startup (only during requests). This
allows users to provide that beforehand and bypass the
need to call crypto functions.
@trevor-scheer trevor-scheer force-pushed the trevor/use-web-crypto-if-available branch from a508f32 to 7605df5 Compare June 7, 2023 19:14
@trevor-scheer trevor-scheer changed the title Use Web Crypto API when available to support web workers Allow landing page to be configured with a precomputed nonce (fix for CF workers) Jun 7, 2023
@trevor-scheer trevor-scheer force-pushed the trevor/use-web-crypto-if-available branch from ee0bfb8 to 3ffa445 Compare June 7, 2023 19:29
@trevor-scheer trevor-scheer enabled auto-merge (squash) June 7, 2023 19:43
@trevor-scheer trevor-scheer merged commit 75b668d into main Jun 7, 2023
17 of 18 checks passed
@trevor-scheer trevor-scheer deleted the trevor/use-web-crypto-if-available branch June 7, 2023 19:44
@github-actions github-actions bot mentioned this pull request Jun 7, 2023
trevor-scheer pushed a commit that referenced this pull request Jun 7, 2023
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @apollo/server-integration-testsuite@4.7.3

### Patch Changes

- Updated dependencies
\[[`75b668d9e`](75b668d)]:
    -   @apollo/server@4.7.3

## @apollo/server@4.7.3

### Patch Changes

- [#7601](#7601)
[`75b668d9e`](75b668d)
Thanks [@trevor-scheer](https://github.com/trevor-scheer)! - Provide a
new configuration option for landing page plugins `precomputedNonce`
which allows users to provide a nonce and avoid calling into `uuid`
functions on startup. This is useful for Cloudflare Workers where random
number generation is not available on startup (only during requests).
Unless you are using Cloudflare Workers, you can ignore this change.

The example below assumes you've provided a `PRECOMPUTED_NONCE` variable
in your `wrangler.toml` file.

    Example usage:

    ```ts
    const server = new ApolloServer({
      // ...
      plugins: [
        ApolloServerPluginLandingPageLocalDefault({
          precomputedNonce: PRECOMPUTED_NONCE,
        }),
      ],
    });
    ```

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 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.

None yet

2 participants