Skip to content

Commit

Permalink
update tangle labs and impierce oid4vc, switch to ES256, rework issuance
Browse files Browse the repository at this point in the history
  • Loading branch information
eike-hass committed Aug 14, 2024
1 parent 89f69e6 commit 80e2c60
Show file tree
Hide file tree
Showing 26 changed files with 1,386 additions and 660 deletions.
6 changes: 6 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ RUN apt-get update && apt-get install -y protobuf-compiler

COPY shared /shared

ARG REACT_APP_ISSUERS_GOVERNMENT_DID
ENV REACT_APP_ISSUERS_GOVERNMENT_DID=$REACT_APP_ISSUERS_GOVERNMENT_DID

ARG REACT_APP_ISSUERS_COMPANY_HOUSE_DID
ENV REACT_APP_ISSUERS_COMPANY_HOUSE_DID=$REACT_APP_ISSUERS_COMPANY_HOUSE_DID

WORKDIR /web

COPY web/package*.json ./
Expand Down
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"proto:generate": "protoc --experimental_allow_proto3_optional --ts_proto_out=./src --proto_path=../shared/proto identity/domain_linkage.proto identity/presentation.proto identity/credentials.proto user/user.proto oid4vc/siopv2.proto oid4vc/oid4vci.proto oid4vc/oid4vp.proto --ts_proto_opt=esModuleInterop=true --ts_proto_opt=nestJs=true"
"proto:generate": "protoc --experimental_allow_proto3_optional --ts_proto_out=./src --proto_path=../shared/proto identity/domain_linkage.proto identity/presentation.proto identity/credentials.proto identity/utils.proto user/user.proto oid4vc/siopv2.proto oid4vc/oid4vci.proto oid4vc/oid4vp.proto --ts_proto_opt=esModuleInterop=true --ts_proto_opt=nestJs=true"
},
"dependencies": {
"@grpc/grpc-js": "^1.9.13",
Expand Down
6 changes: 5 additions & 1 deletion backend/src/identity/identity.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import configuration from './configuration';
ClientProxyFactory.create({
transport: Transport.GRPC,
options: {
package: ['credentials', 'presentation', 'domain_linkage'],
package: ['credentials', 'presentation', 'domain_linkage', 'utils'],
url: configService.getOrThrow('grpc_service_url'),
protoPath: [
join(
Expand All @@ -34,6 +34,10 @@ import configuration from './configuration';
configService.getOrThrow('grpc_service_protopath'),
'domain_linkage.proto',
),
join(
configService.getOrThrow('grpc_service_protopath'),
'utils.proto',
),
],
},
}),
Expand Down
30 changes: 30 additions & 0 deletions backend/src/identity/identity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ import {
DomainLinkageClient,
ValidateDidResponse,
} from './domain_linkage';
import {
IOTA_UTILS_SERVICE_NAME,
IotaDidToAliasAddressResponse,
IotaUtilsClient,
} from './utils';

@Injectable()
export class IdentityService implements OnModuleInit {
private identityService: JwtClient;
private presentationService: CredentialPresentationClient;
private domainLinkageService: DomainLinkageClient;
private utilsService: IotaUtilsClient;

private readonly logger = new Logger(IdentityService.name);

Expand All @@ -43,6 +49,9 @@ export class IdentityService implements OnModuleInit {
this.domainLinkageService = this.client.getService<DomainLinkageClient>(
DOMAIN_LINKAGE_SERVICE_NAME,
);
this.utilsService = this.client.getService<IotaUtilsClient>(
IOTA_UTILS_SERVICE_NAME,
);
}

async create(
Expand Down Expand Up @@ -126,4 +135,25 @@ export class IdentityService implements OnModuleInit {
throw error;
}
}

async parseDID(did: string): Promise<IotaDidToAliasAddressResponse> {
this.logger.debug('Received DID parsing request', did);

try {
const response = await lastValueFrom(
this.utilsService
.didIotaToAliasAddress({
did,
})
.pipe(
timeout(this.configService.get<number>('grpc_service_timeout')),
),
);
this.logger.debug('parsing response', response);
return response;
} catch (error) {
this.logger.error(error);
throw error;
}
}
}
129 changes: 129 additions & 0 deletions backend/src/identity/utils.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions backend/src/webapp/webapp.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,29 @@ export class WebAppGateway {
this.logger.debug(`send validation response for did:${payload.did}`);
}

@SubscribeMessage('requestDIDParsing')
async requestDIDParsing(
@MessageBody()
payload: {
did: string;
},
@ConnectedSocket() client: Socket,
) {
this.logger.debug(
`receiving DIDParsing request for did :${payload.did}`,
payload,
);

const result = await this.webAppService.requestDIDParsing(payload.did);

await client.emitWithAck('parsedDID', {
did: payload.did,
result,
});

this.logger.debug(`send parsing response for did:${payload.did}`);
}

async connectDid(session_id: string, did: string, scope: Scopes) {
const connectedClient = this.findClient(session_id);

Expand Down
11 changes: 11 additions & 0 deletions backend/src/webapp/webapp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as CompanyCredentialConfig from '../../../shared/credentials/CompanyCre
import { Providers } from '../../../shared/types/Providers';
import { ValidateDidResponse } from 'src/identity/domain_linkage';
import { JwtCreationResponse } from 'src/identity/credentials';
import { IotaDidToAliasAddressResponse } from 'src/identity/utils';

type Token = {
sessionId: string;
Expand Down Expand Up @@ -139,6 +140,16 @@ export class WebAppService {
return validation;
}

async requestDIDParsing(did: string): Promise<IotaDidToAliasAddressResponse> {
this.logger.debug(`receiving DIDParsing request for did:${did}`);

const result = await this.identityService.parseDID(did);

this.logger.debug(`parsing for did:${did}`, did);

return result;
}

async connectUser(user: User): Promise<void> {
this.logger.debug(
`connect user with did:${user.did} and code:${user.code}`,
Expand Down
16 changes: 12 additions & 4 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ services:
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.web-dev.address=:9000"
- "--entrypoints.grpc.address=:5000"
# - "--log.level=DEBUG"
ports:
- "${HTTP_PORT}:80/tcp"
- "9000:9000/tcp"
- "${GRPC_PORT}:5000/tcp"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
Expand All @@ -33,21 +35,27 @@ services:
extends:
file: docker-compose.yml
service: backend
expose:
- '9000'
volumes:
- ./backend/src:/backend/src
- ./web/build:/web/build
- ./web/src:/web/src
- ./proto:/proto
- ./types:/types
entrypoint:
- npm
- run
- start:dev
- "/bin/sh"
- "-c"
- "npm run start:dev & cd ../web/ && npm run start"
labels:
traefik.enable: true
traefik.http.routers.backend.rule: Host(`selv.local`)
traefik.http.routers.backend.entrypoints: web
traefik.http.routers.backend.service: backend
traefik.http.services.backend.loadbalancer.server.port: "3000"
traefik.http.routers.web-dev-server.rule: Host(`selv.local`)
traefik.http.routers.web-dev-server.entrypoints: web-dev
traefik.http.routers.web-dev-server.service: web-dev-server
traefik.http.services.web-dev-server.loadbalancer.server.port: "9000"
traefik.http.routers.backend-grpc.rule: PathPrefix(`/backend`)
traefik.http.routers.backend-grpc.middlewares: backend-grpc-stripprefix
traefik.http.middlewares.backend-grpc-stripprefix.stripprefix.prefixes: /backend
Expand Down
Loading

0 comments on commit 80e2c60

Please sign in to comment.