Skip to content

Commit 05764fe

Browse files
authored
Merge pull request #90 from JustaName-id/angelo/engr-720-implement-poh-in-justverified
Angelo/engr 720 implement poh in justverified
2 parents 39128cd + 5d65d8a commit 05764fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+21130
-20134
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
VITE_APP_API_DOMAIN=<your-vc-api-domain>/verifications/v1
2+
VITE_APP_ENVIRONMENT=<YOUR_ENVIRONMENT># (development, production, staging, test)
3+
VITE_APP_OPENPASSPORT_SCOPE=<YOUR_OPENPASSPORT_SCOPE>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["plugin:@nx/react", "../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>OpenpassportStatic</title>
6+
<base href="/" />
7+
8+
<meta name="viewport" content="width=device-width, initial-scale=1" />
9+
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
10+
</head>
11+
<body>
12+
<div id="root"></div>
13+
<script type="module" src="/src/main.tsx"></script>
14+
</body>
15+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'openpassport-static',
4+
preset: '../../jest.preset.js',
5+
transform: {
6+
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
7+
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
8+
},
9+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
10+
coverageDirectory: '../../coverage/apps/openpassport-static',
11+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "openpassport-static",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "apps/openpassport-static/src",
5+
"projectType": "application",
6+
"tags": [],
7+
"// targets": "to see all targets run: nx show project openpassport-static --web",
8+
"targets": {}
9+
}
14.7 KB
Binary file not shown.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import axios from 'axios';
2+
import { OpenPassportQRcode } from '@openpassport/qrcode';
3+
import { OpenPassportAttestation, OpenPassportVerifier } from '@openpassport/core';
4+
5+
export function App() {
6+
const address = new URLSearchParams(window.location.search).get('address');
7+
const state = new URLSearchParams(window.location.search).get('state');
8+
9+
const environment = import.meta.env.VITE_APP_ENVIRONMENT;
10+
const scope = import.meta.env.VITE_APP_OPENPASSPORT_SCOPE;
11+
let openPassportVerifier = new OpenPassportVerifier('prove_offchain', scope);
12+
13+
if (environment === 'development' || environment === 'staging') {
14+
openPassportVerifier = openPassportVerifier.allowMockPassports();
15+
}
16+
17+
const callback = async (attestation: OpenPassportAttestation) => {
18+
try {
19+
const encodedAttestation = btoa(JSON.stringify(attestation));
20+
21+
await axios.get(
22+
`${import.meta.env.VITE_APP_API_DOMAIN}/credentials/socials/openpassport/callback`,
23+
{
24+
params: {
25+
code: encodedAttestation,
26+
state: state,
27+
},
28+
}
29+
);
30+
} catch (error) {
31+
console.error('Error in callback:', error);
32+
}
33+
}
34+
35+
if (!address || !state) {
36+
return <h2>Please provide an address parameter in the URL to continue</h2>;
37+
}
38+
39+
return (
40+
<OpenPassportQRcode
41+
appName={scope}
42+
userId={address.replace("0x", "")}
43+
userIdType={"hex"}
44+
openPassportVerifier={openPassportVerifier}
45+
onSuccess={async (attestation) => {
46+
await callback(attestation);
47+
}}
48+
/>
49+
);
50+
}
51+
52+
export default App;

apps/openpassport-static/src/assets/.gitkeep

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Buffer } from 'buffer';
2+
import { StrictMode } from 'react';
3+
import * as ReactDOM from 'react-dom/client';
4+
5+
import App from './app/app';
6+
7+
window.Buffer = Buffer;
8+
9+
const root = ReactDOM.createRoot(
10+
document.getElementById('root') as HTMLElement
11+
);
12+
root.render(
13+
<StrictMode>
14+
<App />
15+
</StrictMode>
16+
);

0 commit comments

Comments
 (0)