Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angelo/engr 720 implement poh in justverified #90

Merged
merged 45 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
54a9e08
Merge pull request #6 from JustaName-id/staging
Ghadi8 Sep 13, 2024
517877f
Merge pull request #10 from JustaName-id/staging
Ghadi8 Sep 13, 2024
0ef7050
Merge pull request #14 from JustaName-id/staging
Ghadi8 Sep 16, 2024
657a31c
Merge pull request #21 from JustaName-id/staging
Ghadi8 Oct 1, 2024
1f71898
Merge pull request #24 from JustaName-id/staging
Ghadi8 Oct 1, 2024
48dd4a3
Merge pull request #27 from JustaName-id/staging
Ghadi8 Oct 1, 2024
02d70f0
Merge pull request #30 from JustaName-id/staging
Ghadi8 Oct 2, 2024
f01eae1
Merge pull request #36 from JustaName-id/staging
Ghadi8 Oct 14, 2024
eddec45
Merge pull request #39 from JustaName-id/staging
Ghadi8 Oct 14, 2024
3dc0207
Merge pull request #42 from JustaName-id/staging
Ghadi8 Oct 15, 2024
c474f55
Merge pull request #45 from JustaName-id/staging
Ghadi8 Oct 15, 2024
e8ced02
Merge pull request #48 from JustaName-id/staging
Ghadi8 Oct 16, 2024
b7a63df
Merge pull request #50 from JustaName-id/staging
Ghadi8 Oct 25, 2024
3d5be68
Merge pull request #54 from JustaName-id/staging
Ghadi8 Oct 30, 2024
dd0b901
Merge pull request #57 from JustaName-id/staging
Ghadi8 Oct 30, 2024
d66dfe8
Merge pull request #65 from JustaName-id/staging
Ghadi8 Oct 30, 2024
fc659f4
Merge pull request #70 from JustaName-id/staging
Ghadi8 Nov 1, 2024
847d98f
Merge pull request #73 from JustaName-id/develop
Ghadi8 Nov 4, 2024
129fb8b
Merge pull request #74 from JustaName-id/staging
Ghadi8 Nov 4, 2024
9d4f0d9
Merge pull request #75 from JustaName-id/develop
Ghadi8 Nov 4, 2024
11f73c1
Merge pull request #76 from JustaName-id/staging
Ghadi8 Nov 4, 2024
5a71115
Merge pull request #78 from JustaName-id/develop
Ghadi8 Nov 8, 2024
7d062f0
Merge pull request #79 from JustaName-id/staging
Ghadi8 Nov 8, 2024
3d0c419
Merge pull request #83 from JustaName-id/develop
Ghadi8 Nov 22, 2024
fc224ef
Merge pull request #86 from JustaName-id/develop
Ghadi8 Nov 28, 2024
2c43924
Merge pull request #84 from JustaName-id/staging
Ghadi8 Nov 28, 2024
a1addb5
feat(openpassport-static): setup openpassport verification static web…
AngeloAyranji Dec 5, 2024
ea82e06
feat(openpassport-static): add openpassport static verification page
AngeloAyranji Dec 6, 2024
ae3228f
feat(vc-api): add OPENPASSPORT STATIC PAGE URL to environment
AngeloAyranji Dec 6, 2024
2e3212f
feat(vc-api): add getAuthUrl to openpassport
AngeloAyranji Dec 9, 2024
f160ada
feat(vc-api): add ens address in the AuthUrl
AngeloAyranji Dec 9, 2024
d214613
feat(openpassport-static): retreive state and address in static page
AngeloAyranji Dec 9, 2024
4e5cafa
fix(openpassport-static): fix error when generating proof
AngeloAyranji Dec 10, 2024
0c7d3bb
feat: callback api from static + generating vcs (not final yet)
AngeloAyranji Dec 10, 2024
86acd33
Merge pull request #88 from JustaName-id/develop
Ghadi8 Dec 13, 2024
a46a8b0
Merge pull request #89 from JustaName-id/staging
Ghadi8 Dec 13, 2024
ef044ac
feat(vc-api): add verification for proof and address and fix vc gener…
AngeloAyranji Dec 13, 2024
290f84b
Merge branch 'main' of https://github.com/JustaName-id/JustVerified i…
AngeloAyranji Dec 13, 2024
592d164
feat(vc-api): generate openpassport vc
AngeloAyranji Dec 16, 2024
bd2bd79
chore(vc-api): removed unnecessary comments
AngeloAyranji Dec 16, 2024
bd1fa37
feat(vc-api): readded jwt guard to getAuthUrl endpoint
AngeloAyranji Dec 20, 2024
d60b13a
feat(vc-api): verify openpassport proof in verify-records endpoint
AngeloAyranji Jan 3, 2025
1cb6787
feat: added openpassport env vars to k8s secrets
Ghadi8 Jan 3, 2025
3c0687d
fix(vc-api): return false if openpassport verification fails
AngeloAyranji Jan 3, 2025
5d65d8a
fix: fix build
Ghadi8 Jan 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/openpassport-static/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_APP_API_DOMAIN=<your-vc-api-domain>/verifications/v1
VITE_APP_ENVIRONMENT=<YOUR_ENVIRONMENT># (development, production, staging, test)
VITE_APP_OPENPASSPORT_SCOPE=<YOUR_OPENPASSPORT_SCOPE>
18 changes: 18 additions & 0 deletions apps/openpassport-static/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
1 change: 1 addition & 0 deletions apps/openpassport-static/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
15 changes: 15 additions & 0 deletions apps/openpassport-static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>OpenpassportStatic</title>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions apps/openpassport-static/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'openpassport-static',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/openpassport-static',
};
9 changes: 9 additions & 0 deletions apps/openpassport-static/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "openpassport-static",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/openpassport-static/src",
"projectType": "application",
"tags": [],
"// targets": "to see all targets run: nx show project openpassport-static --web",
"targets": {}
}
Binary file added apps/openpassport-static/public/favicon.ico
Binary file not shown.
52 changes: 52 additions & 0 deletions apps/openpassport-static/src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import axios from 'axios';
import { OpenPassportQRcode } from '@openpassport/qrcode';
import { OpenPassportAttestation, OpenPassportVerifier } from '@openpassport/core';

export function App() {
const address = new URLSearchParams(window.location.search).get('address');
const state = new URLSearchParams(window.location.search).get('state');

const environment = import.meta.env.VITE_APP_ENVIRONMENT;
const scope = import.meta.env.VITE_APP_OPENPASSPORT_SCOPE;
let openPassportVerifier = new OpenPassportVerifier('prove_offchain', scope);

if (environment === 'development' || environment === 'staging') {
openPassportVerifier = openPassportVerifier.allowMockPassports();
}

const callback = async (attestation: OpenPassportAttestation) => {
try {
const encodedAttestation = btoa(JSON.stringify(attestation));

await axios.get(
`${import.meta.env.VITE_APP_API_DOMAIN}/credentials/socials/openpassport/callback`,
{
params: {
code: encodedAttestation,
state: state,
},
}
);
} catch (error) {
console.error('Error in callback:', error);
}
}

if (!address || !state) {
return <h2>Please provide an address parameter in the URL to continue</h2>;
}

return (
<OpenPassportQRcode
appName={scope}
userId={address.replace("0x", "")}
userIdType={"hex"}
openPassportVerifier={openPassportVerifier}
onSuccess={async (attestation) => {
await callback(attestation);
}}
/>
);
}

export default App;
Empty file.
16 changes: 16 additions & 0 deletions apps/openpassport-static/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Buffer } from 'buffer';
import { StrictMode } from 'react';
import * as ReactDOM from 'react-dom/client';

import App from './app/app';

window.Buffer = Buffer;

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<StrictMode>
<App />
</StrictMode>
);
23 changes: 23 additions & 0 deletions apps/openpassport-static/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts",
"vite/client"
]
},
"exclude": [
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/**/*.spec.tsx",
"src/**/*.test.tsx",
"src/**/*.spec.js",
"src/**/*.test.js",
"src/**/*.spec.jsx",
"src/**/*.test.jsx"
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}
21 changes: 21 additions & 0 deletions apps/openpassport-static/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"types": ["vite/client"]
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../tsconfig.base.json"
}
25 changes: 25 additions & 0 deletions apps/openpassport-static/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": [
"jest",
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
40 changes: 40 additions & 0 deletions apps/openpassport-static/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/// <reference types='vitest' />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/apps/openpassport-static',

define: {
'global': {},
},

server: {
port: 4200,
host: 'localhost',
},

preview: {
port: 4300,
host: 'localhost',
},

plugins: [react(), nxViteTsPaths(), nxCopyAssetsPlugin(['*.md'])],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

build: {
outDir: '../../dist/apps/openpassport-static',
emptyOutDir: true,
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
},
});
3 changes: 3 additions & 0 deletions apps/vc-api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ TELEGRAM_BOT_TOKEN=<YOUR_TELEGRAM_BOT_TOKEN>
TELEGRAM_BOT_USERNAME=<YOUR_TELEGRAM_BOT_USERNAME>
TELEGRAM_STATIC_PAGE_URL=<YOUR_TELEGRAM_STATIC_PAGE_URL>

OPENPASSPORT_SCOPE=<YOUR_OPENPASSPORT_SCOPE>
OPENPASSPORT_STATIC_PAGE_URL=<YOUR_OPENPASSPORT_STATIC_PAGE_URL>

DISCORD_CLIENT_ID=<YOUR_DISCORD_CLIENT_ID>
DISCORD_CLIENT_SECRET=<YOUR_DISCORD_CLIENT_SECRET>

Expand Down
4 changes: 3 additions & 1 deletion apps/vc-api/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": ["error"]
"@nx/dependency-checks": ["error", {"ignoredDependencies": [
"@nx/webpack"
]}]
}
}
]
Expand Down
9 changes: 6 additions & 3 deletions apps/vc-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"node": ">=18.12.0 <=18.18.0"
},
"dependencies": {
"@nx/webpack": "19.7.2",
"@veramo/core": "^6.0.0",
"@veramo/credential-eip712": "^6.0.0",
"class-transformer": "^0.5.1",
Expand All @@ -31,7 +30,7 @@
"@golevelup/ts-jest": "^0.5.6",
"supertest": "^7.0.0",
"@nestjs/common": "^10.0.2",
"express": "4.21.1",
"express": "4.21.2",
"@nestjs/core": "^10.0.2",
"ethers": "^6.13.2",
"@nestjs/axios": "^3.0.3",
Expand All @@ -41,6 +40,10 @@
"viem": "^2.21.7",
"@nestjs/platform-express": "^10.0.2",
"@nestjs/testing": "^10.0.2",
"@justaname.id/sdk": "^0.2.146"
"@justaname.id/sdk": "^0.2.146",
"@openpassport/core": "^0.0.11"
},
"devDependencies": {
"@nx/webpack": "19.7.2"
}
}
9 changes: 4 additions & 5 deletions apps/vc-api/src/api/credentials/credentials.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { filter, Subject, take } from 'rxjs';
import { SubjectData } from './isubject.data';
import { JwtGuard } from '../../guards/jwt.guard';
import {CredentialsGenerateEmailOtpApiRequestQuery} from "./requests/credentials.generate-email-otp.request.api";
import {CredentialsGetAuthUrlRequestApiRequestParam} from "./requests/credentials.get-auth-url.request.api";
import {CredentialsGetAuthUrlApiRequestQuery, CredentialsGetAuthUrlRequestApiRequestParam} from "./requests/credentials.get-auth-url.request.api";
import {CredentialsGenerateEmailResponseApi} from "./responses/credentials.generate.email.response.api";
import {CredentialsResendOtpRequestApi} from "./requests/credentials.resend-otp.request.api";
import {CredentialsVerifyOtpRequestApi} from "./requests/credentials.verify-otp.request.api";
Expand Down Expand Up @@ -40,15 +40,14 @@ export class CredentialsController {
@Res() res: Response,
@Req() req: Request & { user: Siwens }
): Promise<any> {

const authId = uuidv4();
const subject = new Subject<SubjectData>();
this.authSubjects.set(authId, subject);

const redirectUrl = await this.credentialCreatorFacade.getSocialAuthUrl(
authGetAuthUrlRequestApi.authName,
req.user?.ens,
req.user?.chainId,
req.user.ens,
req.user.chainId,
authId
)

Expand Down Expand Up @@ -81,7 +80,7 @@ export class CredentialsController {
@Get('socials/:authName/callback')
async callback(
@Param() authGetAuthUrlRequestApiParam: CredentialsGetAuthUrlRequestApiRequestParam,
@Query() authGetAuthUrlRequestApiQuery: any,
@Query() authGetAuthUrlRequestApiQuery: CredentialsGetAuthUrlApiRequestQuery,
@Res() res: Response
): Promise<void> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ enum AuthName {
Github = 'github',
Discord = 'discord',
Telegram = 'telegram',
OpenPassport = 'openpassport',
}

export class CredentialsGetAuthUrlRequestApiRequestParam
Expand Down
2 changes: 2 additions & 0 deletions apps/vc-api/src/api/filters/vc.api.filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AuthenticationExceptionFilter } from './auth/authentication.filter';
import { JustaNameInitializerExceptionFilter } from './auth/justaName-intializer.filter';
import { Web3ProviderExceptionFilter } from './web3-provider/web3-provider.filter';
import { RecordsFetchingExceptionFilter } from './verify-records/records-fetching.filter';
import { VerificationFailedExceptionFilter } from './verify-records/verification-failed.filter';

export const VCManagementApiFilters = [
OTPExceptionFilter,
Expand All @@ -18,4 +19,5 @@ export const VCManagementApiFilters = [
SocialResolverNotFoundExceptionFilter,
Web3ProviderExceptionFilter,
RecordsFetchingExceptionFilter,
VerificationFailedExceptionFilter,
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BaseExceptionFilter } from '@nestjs/core';
import { ArgumentsHost, Catch, HttpStatus } from '@nestjs/common';
import { VerificationFailedException } from '../../../core/domain/exceptions/VerificationFailed.exception';

@Catch(VerificationFailedException)
export class VerificationFailedExceptionFilter extends BaseExceptionFilter {
catch(exception: VerificationFailedException, host: ArgumentsHost) {
const context = host.switchToHttp();
const response = context.getResponse();
const httpStatus = HttpStatus.BAD_REQUEST;

response.status(httpStatus).json({
message: exception.message,
});
}
}
6 changes: 6 additions & 0 deletions apps/vc-api/src/config/env.validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ class EnvironmentVariables implements Environment{
@IsString({message: 'TELEGRAM_STATIC_PAGE_URL must be a string'})
TELEGRAM_STATIC_PAGE_URL!: string;

@IsString({message: 'OPENPASSPORT_STATIC_PAGE_URL must be a string'})
OPENPASSPORT_STATIC_PAGE_URL!: string;

@IsString({message: 'OPENPASSPORT_SCOPE must be a string'})
OPENPASSPORT_SCOPE!: string;

@IsString({message: 'JWT_SECRET must be a string'})
JWT_SECRET: string;

Expand Down
Loading
Loading