Compression + lint fixes

This commit is contained in:
Hendrik Eeckhaut
2024-11-11 12:18:09 +07:00
parent a30f6890aa
commit 22cbaf9410
5 changed files with 60 additions and 38 deletions

22
package-lock.json generated
View File

@@ -56,6 +56,7 @@
"babel-loader": "^9.2.1",
"babel-preset-react-app": "^10.0.1",
"clean-webpack-plugin": "^4.0.0",
"compression-webpack-plugin": "^11.1.0",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"eslint": "8.1.0",
@@ -7120,6 +7121,27 @@
"node": ">= 0.8.0"
}
},
"node_modules/compression-webpack-plugin": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/compression-webpack-plugin/-/compression-webpack-plugin-11.1.0.tgz",
"integrity": "sha512-zDOQYp10+upzLxW+VRSjEpRRwBXJdsb5lBMlRxx1g8hckIFBpe3DTI0en2w7h+beuq89576RVzfiXrkdPGrHhA==",
"dev": true,
"license": "MIT",
"dependencies": {
"schema-utils": "^4.2.0",
"serialize-javascript": "^6.0.2"
},
"engines": {
"node": ">= 18.12.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
},
"peerDependencies": {
"webpack": "^5.1.0"
}
},
"node_modules/compression/node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",

View File

@@ -19,13 +19,10 @@
},
"repository": {
"type": "git",
"url": ""
"url": "https://github.com/tlsnotary/tlsn-plugin-demo"
},
"author": "",
"license": "ISC",
"bugs": {
"url": ""
},
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
@@ -74,6 +71,7 @@
"babel-loader": "^9.2.1",
"babel-preset-react-app": "^10.0.1",
"clean-webpack-plugin": "^4.0.0",
"compression-webpack-plugin": "^11.1.0",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"eslint": "8.1.0",
@@ -109,4 +107,4 @@
"webpack-dev-server": "^4.11.1"
},
"homepage": ""
}
}

View File

@@ -10,8 +10,6 @@ import { Mutex } from 'async-mutex';
//@ts-ignore
import { verify } from '../rs/0.1.0-alpha.7/index.node';
import { convertNotaryWsToHttp, fetchPublicKeyFromNotary } from './util/index';
import { localPem } from '../web/utils/constants';
const app = express();
const port = 3030;
@@ -42,35 +40,33 @@ const mutex = new Mutex();
app.get('*', (req, res) => {
try {
const storeConfig: AppRootState = {
attestation: {
raw: {
version: '0.1.0-alpha.7',
data: '',
meta: {
notaryUrl: '',
websocketProxyUrl: '',
pluginUrl: '',
const storeConfig: AppRootState = {
attestation: {
raw: {
version: '0.1.0-alpha.7',
data: '',
meta: {
notaryUrl: '',
websocketProxyUrl: '',
pluginUrl: '',
},
},
},
},
};
};
const store = configureAppStore(storeConfig);
const store = configureAppStore(storeConfig);
const html = renderToString(
<Provider store={store}>
<StaticRouter location={req.url}>
<App />
</StaticRouter>
</Provider>,
);
const html = renderToString(
<Provider store={store}>
<StaticRouter location={req.url}>
<App />
</StaticRouter>
</Provider>,
);
const preloadedState = store.getState();
const preloadedState = store.getState();
res.send(`
res.send(`
<!DOCTYPE html>
<html lang="en">
<head>
@@ -89,8 +85,8 @@ app.get('*', (req, res) => {
</body>
</html>
`);
} catch (e) {
res.send(`
} catch (e) {
res.send(`
<!DOCTYPE html>
<html lang="en">
<head>
@@ -109,7 +105,7 @@ app.get('*', (req, res) => {
</body>
</html>
`);
}
}
});
app.post('/poap-claim', async (req, res) => {
@@ -140,7 +136,7 @@ app.post('/verify-attestation', async (req, res) => {
try {
const notaryUrl = convertNotaryWsToHttp(attestation.meta.notaryUrl);
const notaryPem = await fetchPublicKeyFromNotary(notaryUrl);
console.log(notaryPem)
console.log(notaryPem);
const presentation = await verify(attestation.data, notaryPem);
const presentationObj = {
@@ -150,7 +146,7 @@ app.post('/verify-attestation', async (req, res) => {
res.json({ presentationObj });
} catch (e) {
console.error(e);
res.status(500).send('Error verifying attestation')
res.status(500).send('Error verifying attestation');
}
});

View File

@@ -52,7 +52,7 @@ export function convertNotaryWsToHttp(notaryWs: string) {
export async function fetchPublicKeyFromNotary(notaryUrl: string) {
try {
const url = new URL(notaryUrl);
const { hostname } = url;
const { hostname } = url;
if (hostname === '127.0.0.1' || hostname === 'localhost') return localPem;
const res = await fetch(notaryUrl + '/info');
const json: any = await res.json();

View File

@@ -1,7 +1,7 @@
var webpack = require('webpack'),
path = require('path'),
CompressionPlugin = require('compression-webpack-plugin'),
CopyWebpackPlugin = require('copy-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
TerserPlugin = require('terser-webpack-plugin');
var { CleanWebpackPlugin } = require('clean-webpack-plugin');
@@ -88,9 +88,15 @@ const options = {
new CopyWebpackPlugin({
patterns: [
{ from: 'server/util/poaps.txt', to: 'util/' },
{ from: 'server/util/assignments.json', to: 'util/'}
{ from: 'server/util/assignments.json', to: 'util/' }
],
}),
new CompressionPlugin({
algorithm: 'gzip',
test: /\.(js|css|html|svg)$/,
threshold: 10240,
deleteOriginalAssets: false,
}),
].filter(Boolean),
infrastructureLogging: {
level: 'info',