From de7be0fb81a4c52725443f49638bcb8bdcf699de Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Thu, 24 Oct 2024 11:21:22 +0530 Subject: [PATCH] chore: some changes Signed-off-by: Timo Glastra --- packages/oid4vci/src/client.ts | 2 +- packages/oid4vci/src/index.ts | 3 +++ .../authorization-server-metadata.ts | 17 +++++++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/oid4vci/src/client.ts b/packages/oid4vci/src/client.ts index f2fa8e7..662ef51 100644 --- a/packages/oid4vci/src/client.ts +++ b/packages/oid4vci/src/client.ts @@ -35,7 +35,7 @@ export interface Oid4vciClientOptions { export class Oid4vciClient { public constructor(private options: Oid4vciClientOptions) {} - public async isDpopSupported(options: { authorizationServer: string; issuerMetadata: IssuerMetadataResult }) { + public isDpopSupported(options: { authorizationServer: string; issuerMetadata: IssuerMetadataResult }) { const authorizationServerMetadata = getAuthorizationServerMetadataFromList( options.issuerMetadata.authorizationServers, options.authorizationServer diff --git a/packages/oid4vci/src/index.ts b/packages/oid4vci/src/index.ts index 78aa30c..cee0b75 100644 --- a/packages/oid4vci/src/index.ts +++ b/packages/oid4vci/src/index.ts @@ -24,6 +24,7 @@ export { } from './metadata/credential-issuer/credential-configurations' export type { AuthorizationServerMetadata } from './metadata/authorization-server/v-authorization-server-metadata' +export { getAuthorizationServerMetadataFromList } from './metadata/authorization-server/authorization-server-metadata' export { AccessTokenErrorResponse, @@ -60,3 +61,5 @@ export type { export type { IssuerMetadataResult } from './metadata/fetch-issuer-metadata' export { JwtProofTypeIdentifier } from './formats/proof-type/jwt/v-jwt-proof-type' + +export { RequestDpopOptions } from './authorization/dpop/dpop' diff --git a/packages/oid4vci/src/metadata/authorization-server/authorization-server-metadata.ts b/packages/oid4vci/src/metadata/authorization-server/authorization-server-metadata.ts index 0612884..f1b1e66 100644 --- a/packages/oid4vci/src/metadata/authorization-server/authorization-server-metadata.ts +++ b/packages/oid4vci/src/metadata/authorization-server/authorization-server-metadata.ts @@ -41,13 +41,16 @@ export async function fetchAuthorizationServerMetadata( ) // issuer param MUST match - if (authorizationServerResult && authorizationServerResult.issuer !== issuer) { - throw new Oid4vcError( - `The 'issuer' parameter '${authorizationServerResult.issuer}' in the well known authorization server metadata at '${authorizationServerWellKnownMetadataUrl}' does not match the provided issuer '${issuer}'.` - ) + if (authorizationServerResult) { + if (authorizationServerResult.issuer !== issuer) { + throw new Oid4vcError( + `The 'issuer' parameter '${authorizationServerResult.issuer}' in the well known authorization server metadata at '${authorizationServerWellKnownMetadataUrl}' does not match the provided issuer '${issuer}'.` + ) + } + return authorizationServerResult } - return authorizationServerResult + return null } export function getAuthorizationServerMetadataFromList( @@ -60,7 +63,9 @@ export function getAuthorizationServerMetadataFromList( if (!authorizationServerMetadata) { throw new Oid4vcError( - `Authorization server '${issuer}' not found in list of authorization servers. Availalbe authorization servers are ${authorizationServersMetadata.map((as) => `'${as.issuer}'`).join(', ')}` + `Authorization server '${issuer}' not found in list of authorization servers. Availalbe authorization servers are ${authorizationServersMetadata + .map((as) => `'${as.issuer}'`) + .join(', ')}` ) }