Skip to content

Commit

Permalink
chore: zupass
Browse files Browse the repository at this point in the history
  • Loading branch information
sztok7 committed May 26, 2024
1 parent 5fa746a commit e65365b
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/zu-git-pass-client/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
REACT_APP_ZU_GIT_SERVER_API=http://localhost:3000
REACT_APP_GITHUB_CLIENT_ID=Ov23liXvB0xPt7eJJdc9
REACT_APP_ZU_GIT_SERVER_API=https://api.zugitproof.berlin.chainsafe.dev
REACT_APP_GITHUB_CLIENT_ID=Ov23liXvB0xPt7eJJdc9
33 changes: 33 additions & 0 deletions packages/zu-git-pass-client/craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const webpack = require('webpack');
const path = require('path');

module.exports = {
webpack: {
alias: {
'crypto': 'crypto-browserify',
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
}),
],
configure: (webpackConfig) => {
const fallback = webpackConfig.resolve.fallback || {};
Object.assign(fallback, {
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
assert: require.resolve('assert'),
// http: require.resolve('stream-http'),
// https: require.resolve('https-browserify'),
os: require.resolve('os-browserify/browser'),
'process/browser': require.resolve('process/browser'),
vm: require.resolve('vm-browserify'),
// url: require.resolve('url'),
});
webpackConfig.resolve.fallback = fallback;

return webpackConfig;
},
},
};
18 changes: 14 additions & 4 deletions packages/zu-git-pass-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@pcd/passport-interface": "^0.11.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"assert": "^2.1.0",
"crypto-browserify": "^3.12.0",
"os-browserify": "^0.3.0",
"process": "^0.11.10",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.23.1",
"react-scripts": "5.0.1",
"stream-browserify": "^3.0.0",
"vm-browserify": "^1.1.2",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "PORT=3001 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"start": "PORT=3001 craco start",
"build": "craco build",
"test": "craco test",
"eject": "craco eject"
},
"eslintConfig": {
"extends": [
Expand All @@ -35,5 +42,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@craco/craco": "^7.1.0"
}
}
2 changes: 2 additions & 0 deletions packages/zu-git-pass-client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { BrowserRouter, Routes, Route } from "react-router-dom";
import './App.css';
import GithubLogin from './GithubLogin';
import GitHubCallback from './GitHubCallback';
import ZupassLogin from './ZupassLogin.js';

function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<div className="App"><GithubLogin /></div>} />
<Route path="/auth/zupass" element={<ZupassLogin />} />
<Route path="/auth/github/callback" element={<GitHubCallback />} />
</Routes>
</BrowserRouter>
Expand Down
4 changes: 2 additions & 2 deletions packages/zu-git-pass-client/src/GitHubCallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function GitHubCallback() {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
// TODO figure out from where to take zupass email
body: JSON.stringify({ code, zupassEmail: "marin@chainsafe.io" }),
body: JSON.stringify({ code, zupassEmail: "filip.stokovic@chainsafe.io" }),
})
.then(response => response.json())
.then(data => {
Expand All @@ -21,4 +21,4 @@ export default function GitHubCallback() {
}, []);

return <div>Auth in progress...</div>;
}
}
29 changes: 29 additions & 0 deletions packages/zu-git-pass-client/src/ZupassLogin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// import { zuAuthRedirect } from './lib/pcd-zuauth.js';
import { useCallback } from 'react';
// import { constructZupassPcdGetRequestUrl } from '@pcd/passport-interface';
import { getWithoutProvingUrl } from '@pcd/passport-interface/PassportInterface';
import { zupassPopupExecute } from '@pcd/passport-interface';

const constructWhatev = () => {
// constructZupassPcdGetRequestUrl('https://zupass.org', window.location.pathname, 'message-pcd', {});
const result = getWithoutProvingUrl('https://zupass.org', window.location.href, 'message-pcd', true)

console.log(result)

return result
}


export default function ZupassLogin() {
const login = useCallback(async () => {
const route = constructWhatev();

// await zupassPopupSetup()

await zupassPopupExecute(route)
}, []);

return (
<button onClick={login}>Login mit dem Zupass</button>
);
}
12 changes: 12 additions & 0 deletions packages/zu-git-pass-client/src/lib/pcd-zuauth.js

Large diffs are not rendered by default.

0 comments on commit e65365b

Please sign in to comment.