Skip to content

Commit

Permalink
chore: add zupass
Browse files Browse the repository at this point in the history
  • Loading branch information
sztok7 committed May 26, 2024
1 parent e65365b commit 5a3fe4d
Show file tree
Hide file tree
Showing 7 changed files with 841 additions and 54 deletions.
2 changes: 1 addition & 1 deletion 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=https://api.zugitproof.berlin.chainsafe.dev
REACT_APP_GITHUB_CLIENT_ID=Ov23liXvB0xPt7eJJdc9
REACT_APP_GITHUB_CLIENT_ID=Ov23liXuY3hXVMFNHo5X
2 changes: 1 addition & 1 deletion packages/zu-git-pass-client/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
stream: require.resolve('stream-browserify'),
assert: require.resolve('assert'),
// http: require.resolve('stream-http'),
// https: require.resolve('https-browserify'),
path: require.resolve('path-browserify'),
os: require.resolve('os-browserify/browser'),
'process/browser': require.resolve('process/browser'),
vm: require.resolve('vm-browserify'),
Expand Down
3 changes: 3 additions & 0 deletions packages/zu-git-pass-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@pcd/message-pcd": "^0.1.0",
"@pcd/passport-interface": "^0.11.1",
"@pcd/zuauth": "^1.3.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",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/zu-git-pass-client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<div className="App"><GithubLogin /></div>} />
<Route path="/auth/zupass" element={<ZupassLogin />} />
<Route path="/auth/github" element={<div className="App"><GithubLogin /></div>} />
<Route path="/" element={<div className="App"> <ZupassLogin /></div>} />
<Route path="/auth/github/callback" element={<GitHubCallback />} />
</Routes>
</BrowserRouter>
Expand Down
58 changes: 41 additions & 17 deletions packages/zu-git-pass-client/src/ZupassLogin.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,53 @@
// 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';
import { MessagePCDPackage } from '@pcd/message-pcd'

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

console.log(result)
export default function ZupassLogin() {
const login = useCallback(async () => {
const proofUrl = constructProofUrl();

return result
}
const result = await zupassPopupExecute(proofUrl)


export default function ZupassLogin() {
const login = useCallback(async () => {
const route = constructWhatev();
if (result.type !== 'pcd') return

console.log(result.pcdStr)

const pcd = MessagePCDPackage.deserialize(result.pcdStr)

console.log(pcd)

const discourseUrl = process.env.DISCOURSE_URL // searchParams.get('discourse_url')

try {
const response = await fetch(discourseUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
pcd: 'rfgeghfihefuyifghodgf',
email: '[email protected]',
badges: 'Core Contributor'
}),
});

// await zupassPopupSetup()
const result = await response.json();
console.log("Success:", result);
} catch (error) {
console.error("Error:", error);
}
}, []);

await zupassPopupExecute(route)
}, []);

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

This file was deleted.

Loading

0 comments on commit 5a3fe4d

Please sign in to comment.