fix: Use local file for oidc-provider typings

Due to v8 of oidc-provider being ESM,
we can't use the typings directly because of a TS bug:
https://github.com/microsoft/TypeScript/issues/49721.
This works around that.
This commit is contained in:
Joachim Van Herwegen
2023-06-16 10:36:55 +02:00
parent 7024ee9a58
commit b3ef4ed017
22 changed files with 2235 additions and 27 deletions

View File

@@ -1,7 +1,7 @@
import { createPublicKey } from 'crypto';
import type { KeyObject } from 'crypto';
import { exportJWK, generateKeyPair, importJWK } from 'jose';
import type { JWKS, AsymmetricSigningAlgorithm } from 'oidc-provider';
import type { JWKS, AsymmetricSigningAlgorithm } from '../../../templates/types/oidc-provider';
import type { KeyValueStorage } from '../../storage/keyvalue/KeyValueStorage';
import type { AlgJwk, JwkGenerator } from './JwkGenerator';

View File

@@ -2,7 +2,6 @@
// import/no-unresolved can't handle jose imports
// tsdoc/syntax can't handle {json} parameter
import { randomBytes } from 'crypto';
import type Provider from 'oidc-provider';
import type { Account,
Adapter,
AsymmetricSigningAlgorithm,
@@ -11,7 +10,8 @@ import type { Account,
KoaContextWithOIDC,
ResourceServer,
UnknownObject,
errors } from 'oidc-provider';
errors } from '../../../templates/types/oidc-provider';
import type Provider from '../../../templates/types/oidc-provider';
import type { Operation } from '../../http/Operation';
import type { ErrorHandler } from '../../http/output/error/ErrorHandler';
import type { ResponseWriter } from '../../http/output/ResponseWriter';
@@ -145,7 +145,8 @@ export class IdentityProviderFactory implements ProviderFactory {
// Render errors with our own error handler
this.configureErrors(config);
// Allow provider to interpret reverse proxy headers
// Allow provider to interpret reverse proxy headers.
// As oidc-provider is an ESM package and CSS is CJS, we have to use a dynamic import here.
const provider = new (await import('oidc-provider')).default(this.baseUrl, config);
provider.proxy = true;

View File

@@ -1,5 +1,5 @@
import type { JWK } from 'jose';
import type { AsymmetricSigningAlgorithm } from 'oidc-provider';
import type { AsymmetricSigningAlgorithm } from '../../../templates/types/oidc-provider';
/**
* A {@link JWK} where the `alg` parameter is always defined.

View File

@@ -1,4 +1,4 @@
import type { Provider } from 'oidc-provider';
import type Provider from '../../../templates/types/oidc-provider';
/**
* Returns a Provider of OIDC interactions.

View File

@@ -3,7 +3,7 @@ import type {
InteractionResults,
KoaContextWithOIDC,
UnknownObject,
} from 'oidc-provider';
} from '../../../templates/types/oidc-provider';
import { BasicRepresentation } from '../../http/representation/BasicRepresentation';
import type { Representation } from '../../http/representation/Representation';
import { APPLICATION_JSON } from '../../util/ContentTypes';

View File

@@ -1,4 +1,4 @@
import type { KoaContextWithOIDC } from 'oidc-provider';
import type { KoaContextWithOIDC } from '../../../templates/types/oidc-provider';
import type { Operation } from '../../http/Operation';
import type { Representation } from '../../http/representation/Representation';
import { APPLICATION_JSON } from '../../util/ContentTypes';

View File

@@ -1,4 +1,4 @@
import type { AdapterPayload, Adapter } from 'oidc-provider';
import type { AdapterPayload, Adapter } from '../../../../../templates/types/oidc-provider';
import type { KeyValueStorage } from '../../../../storage/keyvalue/KeyValueStorage';
import type { AdapterFactory } from '../../../storage/AdapterFactory';
import { PassthroughAdapterFactory, PassthroughAdapter } from '../../../storage/PassthroughAdapterFactory';

View File

@@ -1,5 +1,5 @@
import assert from 'assert';
import type { InteractionResults } from 'oidc-provider';
import type { InteractionResults } from '../../../../../templates/types/oidc-provider';
import type { Operation } from '../../../../http/Operation';
import { getLoggerFor } from '../../../../logging/LogUtil';
import { BadRequestHttpError } from '../../../../util/errors/BadRequestHttpError';

View File

@@ -1,4 +1,4 @@
import type { Adapter } from 'oidc-provider';
import type { Adapter } from '../../../templates/types/oidc-provider';
/**
* A factory that generates an `Adapter` to be used by the IDP to persist information.

View File

@@ -1,4 +1,4 @@
import type { Adapter, AdapterPayload } from 'oidc-provider';
import type { Adapter, AdapterPayload } from '../../../templates/types/oidc-provider';
import { getLoggerFor } from '../../logging/LogUtil';
import type { ExpiringStorage } from '../../storage/keyvalue/ExpiringStorage';
import type { AdapterFactory } from './AdapterFactory';

View File

@@ -1,4 +1,4 @@
import type { Adapter, AdapterPayload } from 'oidc-provider';
import type { Adapter, AdapterPayload } from '../../../templates/types/oidc-provider';
import type { AdapterFactory } from './AdapterFactory';
/**

View File

@@ -1,7 +1,7 @@
import type { Response } from 'cross-fetch';
import { fetch } from 'cross-fetch';
import type { Quad } from 'n3';
import type { Adapter, AdapterPayload } from 'oidc-provider';
import type { Adapter, AdapterPayload } from '../../../templates/types/oidc-provider';
import { getLoggerFor } from '../../logging/LogUtil';
import type { RepresentationConverter } from '../../storage/conversion/RepresentationConverter';
import { createErrorMessage } from '../../util/errors/ErrorUtil';