mirror of
https://github.com/zkemail/zk-email-verify.git
synced 2026-01-09 13:38:03 -05:00
Enhancement: Moved from react to vite
This commit is contained in:
2
.yarn/releases/yarn-3.2.3.cjs
vendored
2
.yarn/releases/yarn-3.2.3.cjs
vendored
File diff suppressed because one or more lines are too long
@@ -2,25 +2,25 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<link rel="apple-touch-icon" href="/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
Notice the use of in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
@@ -39,5 +39,6 @@
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
<script type="module" src="/src/index.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
18
package.json
18
package.json
@@ -12,6 +12,7 @@
|
||||
"@types/pako": "^2.0.0",
|
||||
"@types/styled-components": "^5.1.24",
|
||||
"@types/yargs": "^17.0.24",
|
||||
"@vitejs/plugin-react": "^4.0.0",
|
||||
"addressparser": "^1.0.1",
|
||||
"atob": "^2.1.2",
|
||||
"base64-sol": "^1.1.0",
|
||||
@@ -19,6 +20,7 @@
|
||||
"circomlib": "^2.0.3",
|
||||
"circomlibjs": "^0.1.2",
|
||||
"cryo": "^0.0.6",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"ethereumjs-abi": "^0.6.8",
|
||||
"ethers": "^5.7.1",
|
||||
"forge-std": "^1.1.2",
|
||||
@@ -36,7 +38,6 @@
|
||||
"react-json-view": "^1.21.3",
|
||||
"react-router": "^6.2.2",
|
||||
"react-router-dom": "^6.2.2",
|
||||
"react-scripts": "^4",
|
||||
"react-use": "^17.3.2",
|
||||
"readline": "^1.3.0",
|
||||
"serve": "^14.0.1",
|
||||
@@ -45,6 +46,10 @@
|
||||
"styled-components": "^5.3.5",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.8.3",
|
||||
"update-browserslist-db": "latest",
|
||||
"vite": "^4.3.3",
|
||||
"vite-plugin-svgr": "^2.4.0",
|
||||
"vite-tsconfig-paths": "^4.2.0",
|
||||
"wagmi": "^0.6.8",
|
||||
"web-vitals": "^2.1.4",
|
||||
"yargs": "^17.7.1"
|
||||
@@ -53,8 +58,9 @@
|
||||
"react-error-overlay": "6.0.9"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"start": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"serve": "vite preview",
|
||||
"both-build": "react-scripts build && next build",
|
||||
"next-build": "next build",
|
||||
"test": "react-scripts test --runInBand --testPathIgnorePatterns='e2e|src/contracts/lib' --reporters=default --reporters=jest-junit",
|
||||
@@ -97,11 +103,15 @@
|
||||
"browserstack-node-sdk": "^1.6.1",
|
||||
"husky": "^8.0.3",
|
||||
"jest-junit": "^15.0.0",
|
||||
"madge": "^6.0.0",
|
||||
"msw": "^1.0.1",
|
||||
"nodemon": "^2.0.19",
|
||||
"puppeteer": "18.1",
|
||||
"selenium-webdriver": "^4.8.1",
|
||||
"ts-node-dev": "^2.0.0"
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"vite-plugin-commonjs": "^0.7.0",
|
||||
"vite-plugin-ngmi-polyfill": "^0.0.2",
|
||||
"vite-preset-react": "^2.3.0"
|
||||
},
|
||||
"jest": {
|
||||
"transformIgnorePatterns": [
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { writeToStream } = require("./tools");
|
||||
// import { writeToStream } from "./tools";
|
||||
const { DkimVerifier } = require("./dkim-verifier");
|
||||
|
||||
export const dkimVerify = async (input, options) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Calculates relaxed body hash for a message body stream
|
||||
|
||||
const { parseHeaders } = require('./tools');
|
||||
const Writable = require('stream').Writable;
|
||||
import { Writable } from 'stream-browserify';
|
||||
|
||||
/**
|
||||
* Class for separating header from body
|
||||
|
||||
@@ -19,7 +19,9 @@ if (LOCAL) {
|
||||
const crypto = require("crypto");
|
||||
const parseDkimHeaders = require("./parse-dkim-headers");
|
||||
const psl = require("psl");
|
||||
const pki = require("node-forge").pki;
|
||||
// const pki = require("node-forge").pki;
|
||||
// const { parseKey } = require('crypto-browserify');
|
||||
import * as CryptoJS from 'crypto-browserify';
|
||||
|
||||
const defaultDKIMFieldNames =
|
||||
"From:Sender:Reply-To:Subject:Date:Message-ID:To:" +
|
||||
@@ -338,7 +340,8 @@ const getPublicKey = async (type, name, minBitLength, resolver) => {
|
||||
modulusLength = publicKeyObj.algorithm.modulusLength;
|
||||
} else {
|
||||
// fall back to node-forge
|
||||
const pubKeyData = pki.publicKeyFromPem(publicKeyPem.toString());
|
||||
// const pubKeyData = pki.publicKeyFromPem(publicKeyPem.toString());
|
||||
const pubKeyData = CryptoJS.parseKey(publicKeyPem.toString(), 'pem');
|
||||
modulusLength = pubKeyData.n.bitLength();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { createHash } from "crypto";
|
||||
// import { createHash } from "crypto";
|
||||
import * as CryptoJS from 'crypto';
|
||||
import { assert, int64toBytes, int8toBytes, mergeUInt8Arrays, Uint8ArrayToHex } from "./binaryFormat";
|
||||
// const { webcrypto, KeyObject } = await import('crypto');
|
||||
// const { subtle } = webcrypto;
|
||||
import { Hash } from "./fast-sha256";
|
||||
|
||||
export async function shaHash(str: Uint8Array) {
|
||||
return createHash("sha256").update(str).digest();
|
||||
return CryptoJS.createHash('sha256').update(str).digest();
|
||||
}
|
||||
|
||||
export async function partialSha(msg: Uint8Array, msgLen: number): Promise<Uint8Array> {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { generate_inputs, insert13Before10 } from "../scripts/generate_input";
|
||||
import styled, { CSSProperties } from "styled-components";
|
||||
import { sshSignatureToPubKey } from "../helpers/sshFormat";
|
||||
import { Link, useSearchParams } from "react-router-dom";
|
||||
import { dkimVerify } from "../helpers/dkim";
|
||||
// import { dkimVerify } from "../helpers/dkim";
|
||||
import atob from "atob";
|
||||
import { downloadProofFiles, generateProof, verifyProof } from "../helpers/zkp";
|
||||
import { packedNBytesToString } from "../helpers/binaryFormat";
|
||||
|
||||
@@ -15,14 +15,16 @@ import {
|
||||
} from "../helpers/binaryFormat";
|
||||
import { CIRCOM_FIELD_MODULUS, MAX_HEADER_PADDED_BYTES, MAX_BODY_PADDED_BYTES, STRING_PRESELECTOR } from "../../src/helpers/constants";
|
||||
import { shaHash, partialSha, sha256Pad } from "../../src/helpers/shaHash";
|
||||
import { dkimVerify } from "../../src/helpers/dkim";
|
||||
import { dkimVerify } from "../helpers/dkim";
|
||||
import * as fs from "fs";
|
||||
import { stubObject } from "lodash";
|
||||
|
||||
// const argv = yargs(hideBin(process.argv))
|
||||
// import * as yargs from "yargs";
|
||||
var Cryo = require("cryo");
|
||||
const pki = require("node-forge").pki;
|
||||
// const pki = require("node-forge").pki;
|
||||
import * as CryptoJS from 'crypto-browserify';
|
||||
// import { parseKey } from 'crypto-browserify';
|
||||
|
||||
// email_file: Path to email file
|
||||
// nonce: Nonce to disambiguate input/output files (optional, only useful for monolithic server side provers)
|
||||
@@ -268,7 +270,8 @@ export async function generate_inputs(raw_email: Buffer | string, eth_address: s
|
||||
let circuitType = CircuitType.EMAIL;
|
||||
|
||||
let pubkey = result.results[0].publicKey;
|
||||
const pubKeyData = pki.publicKeyFromPem(pubkey.toString());
|
||||
// const pubKeyData = pki.publicKeyFromPem(pubkey.toString());
|
||||
const pubKeyData = CryptoJS.parseKey(pubkey.toString(), 'pem');
|
||||
let modulus = BigInt(pubKeyData.n.toString());
|
||||
let fin_result = await getCircuitInputs(sig, modulus, message, body, body_hash, eth_address, circuitType);
|
||||
return fin_result.circuitInputs;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2020",
|
||||
"target": "ESNext",
|
||||
"module": "esnext",
|
||||
"esModuleInterop": true,
|
||||
"lib": [
|
||||
@@ -19,9 +19,7 @@
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"types": ["vite/client", "vite-plugin-svgr/client"],
|
||||
"incremental": true
|
||||
},
|
||||
"include": [
|
||||
|
||||
1
vite-env.d.ts
vendored
Normal file
1
vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
17
vite.config.ts
Normal file
17
vite.config.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import viteTsconfigPaths from 'vite-tsconfig-paths';
|
||||
import svgrPlugin from 'vite-plugin-svgr';
|
||||
import commonjs from 'vite-plugin-commonjs';
|
||||
import { NgmiPolyfill } from 'vite-plugin-ngmi-polyfill';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
react(),
|
||||
viteTsconfigPaths(),
|
||||
svgrPlugin(),
|
||||
commonjs(),
|
||||
NgmiPolyfill(),
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user