From 5ca5720fe2c9e5445f3838f112e55130f8e6780d Mon Sep 17 00:00:00 2001 From: David McKeown Date: Mon, 11 Dec 2023 03:49:41 -0800 Subject: [PATCH] feat: support for hosted token worker (#1208) ### Changes When the SDK is used in combination with a strict Content-Security-Policy (CSP), the policy must include `worker-src: blob:` which raises a concern of `unsafe-eval`. This change allows the SDK to be configured to load the worker code from a trusted URL, compliant with the CSP, and allows the user to mitigate the concern. **Todo:** - [x] Just waiting for https://github.com/auth0/auth0-spa-js/pull/1209 to land so that we can get e2e coverage of this ### References > As defined above, special URL schemes that refer to specific pieces of unique content, such as `data:`, `blob:` and `filesystem:` are excluded from matching a policy of * and must be explicitly listed. Policy authors should note that the content of such URLs is often derived from a response body or execution in a Document context, which may be unsafe. Especially for the [default-src](https://www.w3.org/TR/CSP2/#default_src) and [script-src](https://www.w3.org/TR/CSP2/#script_src) directives, policy authors should be aware that allowing `data:` URLs is equivalent to unsafe-inline and **allowing `blob:` or `filesystem:` URLs is equivalent to unsafe-eval**. https://www.w3.org/TR/CSP2/#source-list-guid-matching ### Testing - [X] This change adds unit test coverage - [ ] This change adds integration test coverage - [X] This change has been tested on the latest version of the platform/language ### Checklist - [X] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md) - [X] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md) - [X] All code quality tools/guidelines have been run/followed --------- Co-authored-by: Frederik Prijck --- FAQ.md | 54 ++++++++++++++++++++++----- __tests__/index.test.ts | 13 +++++++ cypress/e2e/getTokenSilently.cy.js | 59 ++++++++++++++++++++++++++++++ rollup.config.js | 24 ++++++++++++ src/Auth0Client.ts | 6 ++- src/global.ts | 10 +++++ static/index.html | 27 +++++++++++++- 7 files changed, 181 insertions(+), 12 deletions(-) diff --git a/FAQ.md b/FAQ.md index dfa28b745..be5e0dbb7 100644 --- a/FAQ.md +++ b/FAQ.md @@ -106,30 +106,31 @@ There are two ways to use our SDK when you want to rely on a Content Delivery Ne ### Using our own CDN bundle -Our own CDN bundle exposes both `createAuth0Client` and `Auth0Client` on a global `auth0` variable, and can be used as shown below. +Our own CDN bundle exposes both `createAuth0Client` and `Auth0Client` on a global `auth0` variable, and can be used as shown below. ```html ``` ### Using import maps with unpkg + If you want to use a CDN bundle together with import maps, you will need to use our ESM bundle from unpkg: ```html