Skip to content

Commit

Permalink
Cleanup Client types
Browse files Browse the repository at this point in the history
  • Loading branch information
NSeydoux committed Feb 29, 2024
1 parent 2c76a6b commit 329e367
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 39 deletions.
14 changes: 9 additions & 5 deletions packages/core/src/login/oidc/IClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@
* @packageDocumentation
*/

export type ClientType = "static" | "dynamic" | "solid-oidc";

type ISolidOidcClient = {
clientId: string;
clientType: "solid-oidc";
};

type IOpenIdClient = {
type IOpenIdConfidentialClient = {
clientId: string;
clientSecret: string;
clientType: "static" | "dynamic";
clientType: "static";
};

type IOpenIdPublicClient = {
clientId: string;
clientSecret?: string;
clientType: "dynamic";
};

/**
Expand All @@ -43,4 +47,4 @@ type IOpenIdClient = {
export type IClient = {
clientName?: string;
idTokenSignedResponseAlg?: string;
} & (ISolidOidcClient | IOpenIdClient);
} & (ISolidOidcClient | IOpenIdConfidentialClient | IOpenIdPublicClient);
34 changes: 0 additions & 34 deletions packages/node/src/login/oidc/ClientRegistrar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,40 +328,6 @@ describe("ClientRegistrar", () => {
).resolves.toEqual(mockDefaultClientConfig().client_secret);
});

it("throws if client registration doesn't provide a client secret", async () => {
// Sets up the mock-up for DCR
const { Issuer } = jest.requireMock("openid-client") as any;
const mockedClientConfig = mockClientConfig({
client_secret: undefined,
});
const mockedIssuer = {
metadata: mockDefaultIssuerMetadata(),
Client: {
register: (jest.fn() as any).mockResolvedValueOnce({
metadata: mockedClientConfig,
}),
},
};
Issuer.mockReturnValue(mockedIssuer);
const mockStorage = mockStorageUtility({});

// Run the test
const clientRegistrar = getClientRegistrar({
storage: mockStorage,
});
await expect(
clientRegistrar.getClient(
{
sessionId: "mySession",
redirectUrl: "https://example.com",
},
{
...IssuerConfigFetcherFetchConfigResponse,
},
),
).rejects.toThrow();
});

it("uses stores the signing algorithm preferred by the client when the registration didn't return the used algorithm", async () => {
// Sets up the mock-up for DCR
const { Issuer } = jest.requireMock("openid-client") as any;
Expand Down

0 comments on commit 329e367

Please sign in to comment.