Skip to content

Commit

Permalink
Merge pull request wwWallet#67 from wwWallet/delete-createIdToken
Browse files Browse the repository at this point in the history
Delete createIdToken and other unused code
  • Loading branch information
emlun authored Aug 20, 2024
2 parents 1012df6 + add1044 commit a7ce8cd
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 386 deletions.
2 changes: 1 addition & 1 deletion src/routers/communicationHandler.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import express, { Router } from 'express';
import { AuthMiddleware } from '../middlewares/auth.middleware';
import _ from 'lodash';
import { appContainer } from '../services/inversify.config';
import { HandleOutboundRequestError, IssuanceErr, OpenidCredentialReceiving, OutboundCommunication, SendResponseError } from '../services/interfaces';
import { HandleOutboundRequestError, OpenidCredentialReceiving, OutboundCommunication, SendResponseError } from '../services/interfaces';
import { TYPES } from '../services/types';
import * as z from 'zod';

Expand Down
23 changes: 0 additions & 23 deletions src/services/ClientKeystoreService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,6 @@ export class ClientKeystoreService implements WalletKeystore {
) { }


async createIdToken(userId: UserId, nonce: string, audience: string, additionalParameters: AdditionalKeystoreParameters): Promise<Result<{ id_token: string; }, WalletKeystoreErr>> {
let message_id_sent = randomUUID();
const msg = {
message_id: message_id_sent,
request: {
action: SignatureAction.createIdToken,
nonce: nonce,
audience: audience
}
}
await this.socketManagerService.send(userId, msg as ServerSocketMessage)

const result = await this.socketManagerService.expect(userId, message_id_sent, SignatureAction.createIdToken);
if (result.err) {
return Err(WalletKeystoreErr.REMOTE_SIGNING_FAILED);
}
const { message: { message_id, response } } = result.unwrap();
if (response.action == SignatureAction.createIdToken) {
return Ok({ id_token: response.id_token });
}
return Err(WalletKeystoreErr.REMOTE_SIGNING_FAILED);
}

async signJwtPresentation(userId: UserId, nonce: string, audience: string, verifiableCredentials: any[], additionalParameters: AdditionalKeystoreParameters): Promise<Result<{ vpjwt: string }, WalletKeystoreErr>> {
let message_id_sent = randomUUID();
const msg = {
Expand Down
25 changes: 0 additions & 25 deletions src/services/DatabaseKeystoreService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,6 @@ export class DatabaseKeystoreService implements WalletKeystore {
}


async createIdToken(userId: UserId, nonce: string, audience: string, additionalParameters: AdditionalKeystoreParameters): Promise<Result<{ id_token: string; }, WalletKeystoreErr>> {
const user = (await getUser(userId)).unwrap();
const keys = JSON.parse(user.keys.toString()) as WalletKey;

if (!keys.privateKey) {
return Err(WalletKeystoreErr.KEYS_UNAVAILABLE);
}

const privateKey = await importJWK(keys.privateKey, keys.alg);
const jws = await new SignJWT({ nonce: nonce })
.setProtectedHeader({
alg: this.algorithm,
typ: "JWT",
kid: keys.verificationMethod,
})
.setSubject(user.did)
.setIssuer(user.did)
.setExpirationTime('1m')
.setAudience(audience)
.setIssuedAt()
.sign(privateKey);

return Ok({ id_token: jws });
}

async signJwtPresentation(userId: UserId, nonce: string, audience: string, verifiableCredentials: any[], additionalParameters: AdditionalKeystoreParameters): Promise<Result<{ vpjwt: string }, WalletKeystoreErr>> {
const user = (await getUser(userId)).unwrap();
const keys = JSON.parse(user.keys.toString()) as WalletKey;
Expand Down
12 changes: 0 additions & 12 deletions src/services/OpenidForCredentialIssuanceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@ export class OpenidForCredentialIssuanceService implements OpenidCredentialRecei
) { }


async getIssuerState(userId: UserId): Promise<{ issuer_state?: string, error?: Error; }> {
const state = this.states.get(userId.id);
if (!state) {
return { issuer_state: null, error: new Error("No state found") };
}
if (!state.issuer_state) {
return { issuer_state: null, error: new Error("No issuer_state found in state") };
}

return { issuer_state: state.issuer_state, error: null };
}

async generateAuthorizationRequestURL(userId: UserId, credentialOfferURL?: string, legalPersonDID?: string): Promise<{ redirect_to?: string, preauth?: boolean, ask_for_pin?: boolean }> {
console.log("generateAuthorizationRequestURL userId = ", userId);
console.log("LP = ", legalPersonDID);
Expand Down
Loading

0 comments on commit a7ce8cd

Please sign in to comment.