-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from cre8/cre8/issue21
Add demo pages for issuer and verifier
- Loading branch information
Showing
24 changed files
with
586 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules | ||
/**/node_modules | ||
.git | ||
.gitignore | ||
*.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM node:20-slim AS base | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
FROM base AS build | ||
# the downside of this is that is can not cache the node_modules since a change to all elements will trigger a cache invalidation | ||
COPY . /usr/src/app | ||
WORKDIR /usr/src/app | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | ||
# build the project | ||
RUN pnpm --filter=issuer-demo run build | ||
# deploy the project | ||
RUN pnpm deploy --filter=issuer-demo --prod /app | ||
|
||
FROM georgjung/nginx-brotli:1.23.3 | ||
WORKDIR /usr/share/nginx/html | ||
RUN mkdir -p /etc/nginx && \ | ||
echo 'events {}' > /etc/nginx/nginx.conf && \ | ||
echo 'http {' >> /etc/nginx/nginx.conf && \ | ||
echo ' include /etc/nginx/mime.types;' >> /etc/nginx/nginx.conf && \ | ||
echo ' server {' >> /etc/nginx/nginx.conf && \ | ||
echo ' listen 80;' >> /etc/nginx/nginx.conf && \ | ||
echo ' root /usr/share/nginx/html;' >> /etc/nginx/nginx.conf && \ | ||
echo ' index index.html;' >> /etc/nginx/nginx.conf && \ | ||
echo ' location / {' >> /etc/nginx/nginx.conf && \ | ||
echo ' try_files $uri $uri/ /index.html =404;' >> /etc/nginx/nginx.conf && \ | ||
echo ' }' >> /etc/nginx/nginx.conf && \ | ||
echo ' }' >> /etc/nginx/nginx.conf && \ | ||
echo '}' >> /etc/nginx/nginx.conf | ||
COPY --from=build /usr/src/app/apps/issuer-demo/dist . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Issuer Demo</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "issuer-demo", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview", | ||
"clean": "rm -rf dist && rm -rf node_modules", | ||
"lint": "biome lint .", | ||
"format": "biome check --apply .", | ||
"publish": "pnpm run build && cd ../../ && docker compose build issuer-demo && docker compose push issuer-demo" | ||
}, | ||
"devDependencies": { | ||
"@types/qrcode": "^1.5.5", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.2.0" | ||
}, | ||
"dependencies": { | ||
"qrcode": "^1.5.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"issuerUrl": "http://localhost:3001", | ||
"credentialId": "Identity" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import './style.css'; | ||
import qrcode from 'qrcode'; | ||
|
||
interface RequestLinkBody { | ||
credentialSubject?: Record<string, unknown>; | ||
credentialId: string; | ||
pin?: boolean; | ||
} | ||
|
||
interface Config { | ||
issuerUrl: string; | ||
credentialId: string; | ||
} | ||
|
||
let config: Config; | ||
|
||
//fetch the config | ||
fetch('/config.json') | ||
.then((res) => res.json()) | ||
.then((res) => { | ||
config = res; | ||
}); | ||
|
||
let loop: NodeJS.Timeout; | ||
|
||
function getCode() { | ||
if (loop) { | ||
clearInterval(loop); | ||
} | ||
const body: RequestLinkBody = { | ||
credentialId: config.credentialId, | ||
}; | ||
fetch(`${config.issuerUrl}/request`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(body), | ||
}) | ||
.then((res) => res.json()) | ||
.then((res) => { | ||
//display the qrocde | ||
qrcode | ||
.toDataURL(res.uri) | ||
.then((url) => | ||
(document.getElementById('qr') as HTMLElement).setAttribute( | ||
'src', | ||
url | ||
) | ||
); | ||
getStatus(res.session.preAuthorizedCode); | ||
//request for the status update in the background with a loop | ||
loop = setInterval(() => getStatus(res.session.preAuthorizedCode), 2000); | ||
}); | ||
} | ||
|
||
function getStatus(id: string) { | ||
fetch(`${config.issuerUrl}/sessions/${id}`) | ||
.then((res) => res.json()) | ||
.then((res) => { | ||
console.log(res); | ||
status.innerHTML = res.status; | ||
}); | ||
} | ||
|
||
(document.querySelector<HTMLDivElement>('#app') as HTMLDivElement).innerHTML = ` | ||
<button id="get">Get Code</button> | ||
<img id="qr" /> | ||
<div id="status"></div> | ||
`; | ||
const status = document.getElementById('status') as HTMLDivElement; | ||
(document.getElementById('get') as HTMLElement).addEventListener( | ||
'click', | ||
getCode | ||
); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"useDefineForClassFields": true, | ||
"module": "ESNext", | ||
"lib": ["ES2020", "DOM", "DOM.Iterable"], | ||
"skipLibCheck": true, | ||
|
||
/* Bundler mode */ | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
|
||
/* Linting */ | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM node:20-slim AS base | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
FROM base AS build | ||
# the downside of this is that is can not cache the node_modules since a change to all elements will trigger a cache invalidation | ||
COPY . /usr/src/app | ||
WORKDIR /usr/src/app | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | ||
# build the project | ||
RUN pnpm --filter=verifier-demo run build | ||
# deploy the project | ||
RUN pnpm deploy --filter=verifier-demo --prod /app | ||
|
||
FROM georgjung/nginx-brotli:1.23.3 | ||
WORKDIR /usr/share/nginx/html | ||
RUN mkdir -p /etc/nginx && \ | ||
echo 'events {}' > /etc/nginx/nginx.conf && \ | ||
echo 'http {' >> /etc/nginx/nginx.conf && \ | ||
echo ' include /etc/nginx/mime.types;' >> /etc/nginx/nginx.conf && \ | ||
echo ' server {' >> /etc/nginx/nginx.conf && \ | ||
echo ' listen 80;' >> /etc/nginx/nginx.conf && \ | ||
echo ' root /usr/share/nginx/html;' >> /etc/nginx/nginx.conf && \ | ||
echo ' index index.html;' >> /etc/nginx/nginx.conf && \ | ||
echo ' location / {' >> /etc/nginx/nginx.conf && \ | ||
echo ' try_files $uri $uri/ /index.html =404;' >> /etc/nginx/nginx.conf && \ | ||
echo ' }' >> /etc/nginx/nginx.conf && \ | ||
echo ' }' >> /etc/nginx/nginx.conf && \ | ||
echo '}' >> /etc/nginx/nginx.conf | ||
COPY --from=build /usr/src/app/apps/verifier-demo/dist . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Verifier Demo</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "verifier-demo", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview", | ||
"clean": "rm -rf dist && rm -rf node_modules", | ||
"lint": "biome lint .", | ||
"format": "biome check --apply .", | ||
"publish": "pnpm run build && cd ../../ && docker compose build verifier-demo && docker compose push verifier-demo" | ||
}, | ||
"devDependencies": { | ||
"@types/qrcode": "^1.5.5", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.2.0" | ||
}, | ||
"dependencies": { | ||
"qrcode": "^1.5.3" | ||
} | ||
} |
Oops, something went wrong.