Skip to content

Commit

Permalink
issuer state is no longer injected with demo endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmanos committed Apr 2, 2024
1 parent 425202e commit f30df7f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
41 changes: 0 additions & 41 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,47 +172,6 @@ app.post('/demo/presentation-request', async (req: Request, res: Response) => {
res.send({ url });
});

app.post('/demo/generate-credential-offer/with-issuer-state', async (req: Request, res: Response) => {
const {
issuer_state,
credential_issuer_identifier,
credential_definition: {
types,
format
}
} = req.body;

if (!issuer_state) {
console.log("Issuer state is missing")
return res.status(400).send({ error: "issuer_state is missing" });
}

await createNewAuthorizationServerState({ req, res });
req.authorizationServerState.credential_issuer_identifier = credential_issuer_identifier;
req.authorizationServerState.grant_type = GrantType.AUTHORIZATION_CODE;

const issuer = credentialIssuersConfigurationService.registeredCredentialIssuerRepository().getCredentialIssuer(credential_issuer_identifier);
if (!issuer) {
return res.status(404).send({ msg: "Issuer not found" });
}
const supportedCredential = issuer.supportedCredentials.filter(sc => {
return _.isEqual(sc.getTypes(), types) && sc.getFormat() == format
})[0];


if (!supportedCredential) {
return res.status(404).send({ msg: "Supported credential not found" });
}

const supportedCredentialObject = supportedCredential.exportCredentialSupportedObject()
req.authorizationServerState.authorization_details = [
{ format: supportedCredentialObject.format, types: supportedCredentialObject.types ?? [], type: 'openid_credential' }
];
const { url } = await openidForCredentialIssuingAuthorizationServerService.generateCredentialOfferURL({ req, res }, supportedCredentialObject, GrantType.AUTHORIZATION_CODE, issuer_state);
console.log("Returned url = ", url)
res.send({ url: url.toString() });
})


// catch 404 and forward to error handler
app.use((req, _res, next) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,7 @@ export class OpenidForCredentialIssuingAuthorizationServerService implements Ope
return;
}

const state = await this.authorizationServerStateRepository.createQueryBuilder("state")
.where("state.issuer_state = :issuer_state", { issuer_state: ctx.req.query.issuer_state })
.getOne();
if (!state) {
return;
}
ctx.req.authorizationServerState = state;
ctx.req.authorizationServerState.issuer_state = ctx.req.query.issuer_state as string ?? undefined;
}

async authorizationRequestPKCEHandler(ctx: {req: Request, res: Response}) {
Expand Down

0 comments on commit f30df7f

Please sign in to comment.