From 94daee1dac1d7fda1f90a43e8a6d26db8bdb206f Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Fri, 20 May 2022 01:16:04 +0200 Subject: [PATCH] WIP: node work --- ...spec.ts => DynamicClientRegistrar.spec.ts} | 2 +- ...Registrar.ts => DynamicClientRegistrar.ts} | 39 +++---------------- 2 files changed, 6 insertions(+), 35 deletions(-) rename packages/node/src/login/oidc/{ClientRegistrar.spec.ts => DynamicClientRegistrar.spec.ts} (99%) rename packages/node/src/login/oidc/{ClientRegistrar.ts => DynamicClientRegistrar.ts} (85%) diff --git a/packages/node/src/login/oidc/ClientRegistrar.spec.ts b/packages/node/src/login/oidc/DynamicClientRegistrar.spec.ts similarity index 99% rename from packages/node/src/login/oidc/ClientRegistrar.spec.ts rename to packages/node/src/login/oidc/DynamicClientRegistrar.spec.ts index 320d0f1273..536e1bbf1d 100644 --- a/packages/node/src/login/oidc/ClientRegistrar.spec.ts +++ b/packages/node/src/login/oidc/DynamicClientRegistrar.spec.ts @@ -21,7 +21,7 @@ import { jest, it, describe, expect } from "@jest/globals"; import { mockStorageUtility } from "@inrupt/solid-client-authn-core"; -import ClientRegistrar from "./ClientRegistrar"; +import DynamicClientRegistrar from "./DynamicClientRegistrar"; import { IssuerConfigFetcherFetchConfigResponse, mockDefaultIssuerMetadata, diff --git a/packages/node/src/login/oidc/ClientRegistrar.ts b/packages/node/src/login/oidc/DynamicClientRegistrar.ts similarity index 85% rename from packages/node/src/login/oidc/ClientRegistrar.ts rename to packages/node/src/login/oidc/DynamicClientRegistrar.ts index c72304a51f..164e99165d 100644 --- a/packages/node/src/login/oidc/ClientRegistrar.ts +++ b/packages/node/src/login/oidc/DynamicClientRegistrar.ts @@ -26,54 +26,25 @@ import { IStorageUtility, - IClientRegistrar, + IDynamicClientRegistrar, + IDynamicClientRegistrarOptions, IIssuerConfig, IClient, - IClientDetails, - IClientRegistrarOptions, ConfigurationError, - determineSigningAlg, PREFERRED_SIGNING_ALG, + negotiateClientSigningAlg, } from "@inrupt/solid-client-authn-core"; import { Client, Issuer } from "openid-client"; import { configToIssuerMetadata } from "./IssuerConfigFetcher"; -export function negotiateClientSigningAlg( - issuerConfig: IIssuerConfig, - clientPreference: string[] -): string { - if (!Array.isArray(issuerConfig.idTokenSigningAlgValuesSupported)) { - throw new Error( - "The OIDC issuer discovery profile is missing the 'id_token_signing_alg_values_supported' value, which is mandatory." - ); - } - - const signingAlg = determineSigningAlg( - issuerConfig.idTokenSigningAlgValuesSupported, - clientPreference - ); - - if (signingAlg === null) { - throw new Error( - `No signature algorithm match between ${JSON.stringify( - issuerConfig.idTokenSigningAlgValuesSupported - )} supported by the Identity Provider and ${JSON.stringify( - clientPreference - )} preferred by the client.` - ); - } - - return signingAlg; -} - /** * @hidden */ -export default class ClientRegistrar implements IClientRegistrar { +export default class DynamicClientRegistrar implements IDynamicClientRegistrar { constructor(private storageUtility: IStorageUtility) {} async getClient( - options: IClientRegistrarOptions, + options: IDynamicClientRegistrarOptions, issuerConfig: IIssuerConfig ): Promise { // If client secret and/or client id are stored in storage, use those.