Skip to content

Commit

Permalink
feat(extension): add sentry to CSP on build
Browse files Browse the repository at this point in the history
  • Loading branch information
mchappell authored and rhyslbw committed Oct 30, 2024
1 parent a667100 commit 28a3c96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/browser-extension-wallet/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"permissions": ["webRequest", "storage", "tabs", "unlimitedStorage"],
"host_permissions": ["<all_urls>"],
"content_security_policy": {
"extension_pages": "default-src 'self' $LOCALHOST_DEFAULT_SRC; frame-src https://connect.trezor.io/ https://www.youtube-nocookie.com; script-src 'self' 'wasm-unsafe-eval' $LOCALHOST_SCRIPT_SRC; font-src 'self' https://use.typekit.net; object-src 'self'; connect-src $BLOCKFROST_URLS $CARDANO_SERVICES_URLS $CARDANO_WS_SERVER_URLS https://coingecko.live-mainnet.eks.lw.iog.io https://muesliswap.live-mainnet.eks.lw.iog.io $LOCALHOST_CONNECT_SRC $POSTHOG_HOST https://use.typekit.net data:; style-src * 'unsafe-inline'; img-src * data:;"
"extension_pages": "default-src 'self' $LOCALHOST_DEFAULT_SRC; frame-src https://connect.trezor.io/ https://www.youtube-nocookie.com; script-src 'self' 'wasm-unsafe-eval' $LOCALHOST_SCRIPT_SRC; font-src 'self' https://use.typekit.net; object-src 'self'; connect-src $BLOCKFROST_URLS $CARDANO_SERVICES_URLS $CARDANO_WS_SERVER_URLS $SENTRY_URL https://coingecko.live-mainnet.eks.lw.iog.io https://muesliswap.live-mainnet.eks.lw.iog.io $LOCALHOST_CONNECT_SRC $POSTHOG_HOST https://use.typekit.net data:; style-src * 'unsafe-inline'; img-src * data:;"
},
"content_scripts": [
{
Expand Down
8 changes: 7 additions & 1 deletion apps/browser-extension-wallet/webpack-utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const constructSentryConnectSrc = (dsn) => {
if (/https:\/\/[^@]+@([^/]+).*/.test(dsn)) return dsn.replace(/https:\/\/[^@]+@([^/]+).*/, 'https://$1');
return '';
};

const transformManifest = (content, mode) => {
require('dotenv-defaults').config({
path: './.env',
Expand Down Expand Up @@ -32,7 +37,8 @@ const transformManifest = (content, mode) => {
? 'http://localhost:* http://127.0.0.1:* ws://localhost:3000 ws://0.0.0.0:3000/ws wss://localhost:3000 ws://localhost:3001 ws://0.0.0.0:3001/ws wss://localhost:3001'
: 'http://localhost:* http://127.0.0.1:*'
)
.replace('$POSTHOG_HOST', process.env.POSTHOG_HOST);
.replace('$POSTHOG_HOST', process.env.POSTHOG_HOST)
.replace('$SENTRY_URL', constructSentryConnectSrc(process.env.SENTRY_DSN));

if (process.env.LACE_EXTENSION_KEY) {
manifest.key = manifest.key.replace('$LACE_EXTENSION_KEY', process.env.LACE_EXTENSION_KEY);
Expand Down

0 comments on commit 28a3c96

Please sign in to comment.