Skip to content

Commit

Permalink
build(deps): upgrade oidc-provider to version 8.5.1
Browse files Browse the repository at this point in the history
This version of `oidc-provider` exports the Provider as a named export. The latest version of the `@types` package also includes the previously missing typings.

BREAKING CHANGE: The `InteractionDetails` type has been renamed to `Interaction` and is now exported directly from `oidc-provider`.
  • Loading branch information
adrianbrs committed Oct 2, 2024
1 parent 7a70e89 commit 4532f12
Show file tree
Hide file tree
Showing 7 changed files with 5,147 additions and 4,151 deletions.
4 changes: 2 additions & 2 deletions lib/helpers/interaction.helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
InteractionDetails,
Interaction,
InteractionResults,
KoaContextWithOIDC,
Provider,
Expand All @@ -13,7 +13,7 @@ export class InteractionHelper {
this.provider = oidc.provider;
}

details(): Promise<InteractionDetails> {
details(): Promise<Interaction> {
return this.provider.interactionDetails(this.ctx.req, this.ctx.res);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/interfaces/oidc-module.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { VersionValue } from '@nestjs/common/interfaces';
import {
AdapterFactory,
Configuration,
OidcProviderModule,
Provider,
ProviderModule,
} from '../types/oidc.types';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand All @@ -13,7 +13,7 @@ export interface OidcConfiguration extends Configuration {}
export interface OidcModuleFactoryArgs {
issuer: string;
config?: Configuration;
module: ProviderModule;
module: OidcProviderModule;
}

export type OidcModuleFactoryFn = (
Expand Down
11 changes: 4 additions & 7 deletions lib/oidc.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from './oidc.constants';
import { OidcController } from './oidc.controller';
import { OidcService } from './oidc.service';
import { ProviderModule } from './types/oidc.types';
import { OidcProviderModule } from './types/oidc.types';

@Global()
@Module({
Expand Down Expand Up @@ -64,17 +64,14 @@ export class OidcModule {
// FIXME: This is a workaround for the current limitation of Nest that doesn't support ESM-only packages
const moduleProvider: Provider = {
provide: OIDC_PROVIDER_MODULE,
useFactory: async (): Promise<ProviderModule> =>
importOidcProvider().then(({ default: Provider, ...module }) => ({
Provider,
...module,
})),
useFactory: async (): Promise<OidcProviderModule> =>
importOidcProvider(),
};

const oidcProvider: Provider = {
provide: OIDC_PROVIDER,
useFactory: async (
providerModule: ProviderModule,
providerModule: OidcProviderModule,
moduleOptions: OidcModuleOptions,
): Promise<any> => {
// Change controller path manually until Nest doesn't provide an official way for this
Expand Down
29 changes: 5 additions & 24 deletions lib/types/oidc.types.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
import type _Provider from 'oidc-provider';
import type { errors, interactionPolicy } from 'oidc-provider';
import type * as _OidcProvider from 'oidc-provider';

//===================================//
// RE-EXPORT ONLY TYPES TO AVOID //
// IMPORTING ESM AT RUNTIME //
//===================================//
export type * from 'oidc-provider';

export type Provider = _Provider;
export type ProviderClass = typeof _Provider;

export type ProviderModule = {
Provider: ProviderClass;
errors: typeof errors;
interactionPolicy: typeof interactionPolicy;
};

//===================================//
// MISSING NON-EXPORTED OIDC TYPES //
//===================================//

type SessionPromise = ReturnType<Provider['Session']['get']>;
export type Session =
SessionPromise extends Promise<infer T> ? T : SessionPromise;

type InteractionDetailsPromise = ReturnType<Provider['interactionDetails']>;
export type InteractionDetails =
InteractionDetailsPromise extends Promise<infer T>
? T
: InteractionDetailsPromise;
/**
* Represents the `oidc-provider` module imported via dynamic import.
*/
export type OidcProviderModule = typeof _OidcProvider;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@types/jest": "^29.5.12",
"@types/lodash.merge": "^4.6.6",
"@types/node": "^20.11.19",
"@types/oidc-provider": "^8.4.4",
"@types/oidc-provider": "^8.5.2",
"@types/supertest": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
Expand All @@ -67,7 +67,7 @@
"jest-mock": "^29.7.0",
"lint-staged": "^15.2.2",
"lodash.merge": "^4.6.2",
"oidc-provider": "^8.4.5",
"oidc-provider": "^8.5.1",
"prettier": "^3.2.5",
"prettier-eslint-cli": "^8.0.1",
"reflect-metadata": "^0.2.1",
Expand All @@ -81,7 +81,7 @@
"peerDependencies": {
"@nestjs/common": ">=9.0.0",
"@nestjs/core": ">=9.0.0",
"oidc-provider": "^8.4.5",
"oidc-provider": "^8.5.1",
"reflect-metadata": ">=0.1.13"
},
"engines": {
Expand Down
Loading

0 comments on commit 4532f12

Please sign in to comment.