Skip to content

Commit

Permalink
merded and added ebsi did key missing service (not implemented)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmanos committed Sep 6, 2023
2 parents 6a5c1c8 + 8732fc9 commit 78e124f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/routers/user.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { appContainer } from '../services/inversify.config';
import { DatabaseKeystoreService } from '../services/DatabaseKeystoreService';

const databaseKeyStoreService = appContainer.resolve(DatabaseKeystoreService);
import * as scrypt from "../scrypt";


/**
Expand All @@ -25,9 +26,8 @@ userController.post('/register', async (req: Request, res: Response) => {
res.status(500).send({ error: "No username or password was given" });
return;
}
// const naturalPersonWallet: NaturalPersonWallet = await new NaturalPersonWallet().createWallet(config.alg);

const passwordHash = crypto.createHash('sha256').update(password).digest('base64');
const passwordHash = await scrypt.createHash(password);
// const keysStringified = JSON.stringify(naturalPersonWallet.key);
const newUser: CreateUser = {
username: username ? username : "",
Expand Down Expand Up @@ -64,7 +64,7 @@ userController.post('/login', async (req: Request, res: Response) => {
}
const userRes = await getUserByCredentials(username, password);
if (userRes.err) {
res.send(500).send({});
res.status(500).send({});
return;
}
console.log('user res = ', userRes)
Expand Down Expand Up @@ -100,4 +100,4 @@ userController.post('/login', async (req: Request, res: Response) => {
// res.send({ publicKeyJwk });
// });

export default userController;
export default userController;
18 changes: 18 additions & 0 deletions src/services/EBSIDidKeyUtilityService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { injectable } from 'inversify';
import 'reflect-metadata';
import { DidKeyUtilityService } from './interfaces';
import { JWK } from 'jose';


@injectable()
export class EBSIDidKeyUtilityService implements DidKeyUtilityService {


async getPublicKeyJwk(did: string): Promise<JWK> {
throw new Error("Not implemented");
}

async generateKeyPair(): Promise<{ did: string, key: any }> {
throw new Error("Not implemented")
}
}
26 changes: 11 additions & 15 deletions src/services/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@ import { OpenidForCredentialIssuanceMattrV2Service } from "./OpenidForCredential
import config from "../../config";
import { W3CDidKeyUtilityService } from "./W3CDidKeyUtilityService";
import { VerifierRegistryService } from "./VerifierRegistryService";
import { EBSIDidKeyUtilityService } from "./EBSIDidKeyUtilityService";

const appContainer = new Container();


appContainer.bind<WalletKeystore>(TYPES.WalletKeystore)
.to(DatabaseKeystoreService)


// appContainer.bind<LegalPersonsRegistry>(TYPES.LegalPersonsRegistry)
// .to(LegalPersonService)
// .whenTargetNamed(LegalPersonService.identifier);



console.log("Service name = ", config.servicesConfiguration.issuanceService)
switch (config.servicesConfiguration.issuanceService) {
case "OpenidForCredentialIssuanceService":
appContainer.bind<OpenidCredentialReceiving>(TYPES.OpenidForCredentialIssuanceService)
Expand All @@ -38,22 +31,25 @@ case "OpenidForCredentialIssuanceMattrV2Service":
appContainer.bind<OutboundCommunication>(TYPES.OpenidForPresentationService)
.to(OpenidForPresentationService)


if (!config.servicesConfiguration.didKeyService) {
throw new Error("config.servicesConfiguration.didKeyService not set on configuration file");
}

switch (config.servicesConfiguration.didKeyService) {
case "W3C":
appContainer.bind<DidKeyUtilityService>(TYPES.DidKeyUtilityService)
.to(W3CDidKeyUtilityService)
break;
default:
case "EBSI":
appContainer.bind<DidKeyUtilityService>(TYPES.DidKeyUtilityService)
.to(W3CDidKeyUtilityService)
.to(EBSIDidKeyUtilityService)
break;
default:
throw new Error("config.servicesConfiguration.didKeyService must have value 'EBSI' or 'W3C'");
}

appContainer.bind<VerifierRegistryService>(TYPES.VerifierRegistryService)
.to(VerifierRegistryService)

export { appContainer }


// example usage
// const openidForCredentialIssuanceService = appContainer.getNamed<OpenidCredentialReceiving>(TYPES.OpenidCredentialReceiving, OpenidForCredentialIssuanceService.identifier);
export { appContainer }

0 comments on commit 78e124f

Please sign in to comment.