Skip to content

Commit

Permalink
💄 move oidc types to .d.ts file
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Sep 3, 2024
1 parent 914335a commit 9416aad
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 35 deletions.
1 change: 0 additions & 1 deletion src/config/oidc-provider-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import epochTime from "../services/epoch-time";
import { findAccount } from "../services/oidc-account-adapter";
import policy from "../services/oidc-policy";
import { renderWithEjsLayout } from "../services/renderer";
import type { OIDCContextParams } from "../types/oidc-provider";

//

Expand Down
1 change: 0 additions & 1 deletion src/controllers/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { setEmailInUnauthenticatedSession } from "../managers/session/unauthenti
import epochTime from "../services/epoch-time";
import { mustReturnOneOrganizationInPayload } from "../services/must-return-one-organization-in-payload";
import { shouldTrigger2fa } from "../services/should-trigger-2fa";
import type { OidcInteractionResults } from "../types/oidc-provider";
import { postStartSignInController } from "./user/signin-signup";

export const interactionStartControllerFactory =
Expand Down
1 change: 0 additions & 1 deletion src/managers/oidc-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import { getSelectedOrganizationId } from "../repositories/redis/selected-organization";
import { logger } from "../services/log";
import { mustReturnOneOrganizationInPayload } from "../services/must-return-one-organization-in-payload";
import type { OIDCContextParams } from "../types/oidc-provider";

export const getClientsOrderedByConnectionCount = async (
user_id: number,
Expand Down
1 change: 0 additions & 1 deletion src/middlewares/connection-count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { NextFunction } from "express";
import { KoaContextWithOIDC } from "oidc-provider";
import { recordNewConnection } from "../managers/oidc-client";
import { logger } from "../services/log";
import type { OIDCContextParams } from "../types/oidc-provider";

// this is not an express middleware but an oidc-provider middleware as described here:
// https://github.com/panva/node-oidc-provider/blob/v7.x/docs/README.md#pre--and-post-middlewares
Expand Down
4 changes: 0 additions & 4 deletions src/services/oidc-policy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { interactionPolicy } from "oidc-provider";
import { getSelectedOrganizationId } from "../repositories/redis/selected-organization";
import type {
OIDCContextParams,
OidcInteractionResults,
} from "../types/oidc-provider";
import { mustReturnOneOrganizationInPayload } from "./must-return-one-organization-in-payload";

//
Expand Down
29 changes: 29 additions & 0 deletions src/types/oidc-provider.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// NOTE(douglasduteil): app related oidc-provider types
// Those interfaces override the type which is incomplete in the original lib
//

import type {
InteractionResults,
OIDCContext,
UnknownObject,
} from "oidc-provider";

declare global {
/**
* Extends the {@link OIDCContext.params} type.
* Should be used instead of KoaContextWithOIDC["oidc"]["params"]
*/
interface OIDCContextParams extends UnknownObject {
scope: string;
prompt: "select_organization" | "update_userinfo";
}

/**
* Extends the {@link OIDCContext.result} type.
*/
interface OidcInteractionResults extends InteractionResults {
select_organization?: boolean;
update_userinfo?: boolean;
}
}
27 changes: 0 additions & 27 deletions src/types/oidc-provider.ts

This file was deleted.

0 comments on commit 9416aad

Please sign in to comment.