Skip to content

Commit

Permalink
serve web
Browse files Browse the repository at this point in the history
  • Loading branch information
eike-hass committed Apr 30, 2024
1 parent e0b3b12 commit 5cb14a3
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data/**
!data/.gitkeep
8 changes: 8 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ FROM node:20

RUN apt-get update && apt-get install -y protobuf-compiler

WORKDIR /web

COPY web/package*.json ./

RUN npm install

COPY web/. .

WORKDIR /backend

COPY backend/package*.json ./
Expand Down
4 changes: 2 additions & 2 deletions backend/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Controller, Get } from '@nestjs/common';
import { Controller, Get, Post } from '@nestjs/common';
import { AppService } from './app.service';

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}

@Get()
@Post()
getHello(): string {
return this.appService.getHello();
}
Expand Down
Empty file added data/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions oid4vc/TangleLabs/src/httpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const createServer = (rp: RelyingParty, userService: UserService) => {

const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.route("/api/health").get(
asyncHandler(async (req, res) => {
res.status(200).send();
Expand All @@ -16,6 +17,7 @@ export const createServer = (rp: RelyingParty, userService: UserService) => {
app.route("/api/auth").post(
asyncHandler(async (req, res) => {

console.debug(req.body)
const { id_token: idToken } = req.body;
const { state } = req.body;
const { iss } = await rp.validateJwt(idToken);
Expand Down
36 changes: 35 additions & 1 deletion tooling/API/OID4VC/HTTP.http
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,38 @@
###
GET /api/health
###
POST /api/auth
{{
const crypto = require('crypto');

const header = {
"alg": "HS256",
"typ": "JWT"
}
const encodedHeaders = btoa(JSON.stringify(header))

const claims = {
"role": "admin"
}
const encodedPayload = btoa(JSON.stringify(claims))

const encodedSignature = crypto.createHmac('sha256', "mysecret").update(`${encodedHeaders}.${encodedPayload}`).digest("base64url")

console.log(encodedSignature);
const jwt = `${encodedHeaders}.${encodedPayload}.${encodedSignature}`;
console.log(jwt);
exports.jwt = jwt
}}

POST /api/auth
Content-Type: application/x-www-form-urlencoded

id_token={{jwt}}

HTTP/1.1 500 - Internal Server Error
content-length: 1180
content-security-policy: default-src 'none'
content-type: text/html; charset=utf-8
date: Mon, 29 Apr 2024 16:18:21 GMT
x-content-type-options: nosniff
x-powered-by: Express
connection: close
6 changes: 6 additions & 0 deletions web/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ const CracoAlias = require("craco-alias");

module.exports = {

devServer: {
devMiddleware: {
writeToDisk: true,
},
},

plugins: [
{
plugin: CracoAlias,
Expand Down
5 changes: 1 addition & 4 deletions web/src/context/globalState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ type State = {

type ReducerAction = AddCredentialAction | ConnectDIDAction | RequestInviteAction | RequestInviteAction | RequestIssuanceAction | RequestPresentationAction | SetQRContentAction | SetCompleteIssuanceAction;

// "undefined" means the URL will be computed from the `window.location` object
const URL = config.websocketURL // process.env.NODE_ENV === 'production' ? undefined : 'http://localhost:4000';

const socket = SocketIOClient(URL, {
const socket = SocketIOClient("/", {
autoConnect: true,
transports: ['websocket'],
secure: true,
Expand Down

0 comments on commit 5cb14a3

Please sign in to comment.