mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
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:
parent
7024ee9a58
commit
b3ef4ed017
@ -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';
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { Provider } from 'oidc-provider';
|
||||
import type Provider from '../../../templates/types/oidc-provider';
|
||||
|
||||
/**
|
||||
* Returns a Provider of OIDC interactions.
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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.
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
||||
/**
|
||||
|
@ -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';
|
||||
|
2209
templates/types/oidc-provider.d.ts
vendored
Normal file
2209
templates/types/oidc-provider.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,3 @@
|
||||
import type { Provider } from 'oidc-provider';
|
||||
import type { Operation } from '../../../src/http/Operation';
|
||||
import { BasicRepresentation } from '../../../src/http/representation/BasicRepresentation';
|
||||
import type { Representation } from '../../../src/http/representation/Representation';
|
||||
@ -16,6 +15,7 @@ import type {
|
||||
} from '../../../src/storage/conversion/RepresentationConverter';
|
||||
import { APPLICATION_JSON, APPLICATION_X_WWW_FORM_URLENCODED } from '../../../src/util/ContentTypes';
|
||||
import { CONTENT_TYPE } from '../../../src/util/Vocabularies';
|
||||
import type Provider from '../../../templates/types/oidc-provider';
|
||||
|
||||
describe('An IdentityProviderHttpHandler', (): void => {
|
||||
const request: HttpRequest = {} as any;
|
||||
|
@ -1,8 +1,8 @@
|
||||
import type { Provider } from 'oidc-provider';
|
||||
import type { ProviderFactory } from '../../../src/identity/configuration/ProviderFactory';
|
||||
import { OidcHttpHandler } from '../../../src/identity/OidcHttpHandler';
|
||||
import type { HttpRequest } from '../../../src/server/HttpRequest';
|
||||
import type { HttpResponse } from '../../../src/server/HttpResponse';
|
||||
import type Provider from '../../../templates/types/oidc-provider';
|
||||
|
||||
describe('An OidcHttpHandler', (): void => {
|
||||
const request: HttpRequest = {
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { generateKeyPair, importJWK, jwtVerify, SignJWT } from 'jose';
|
||||
import * as jose from 'jose';
|
||||
import type { JWKS } from 'oidc-provider';
|
||||
import { CachedJwkGenerator } from '../../../../src/identity/configuration/CachedJwkGenerator';
|
||||
import type { AlgJwk } from '../../../../src/identity/configuration/JwkGenerator';
|
||||
import type { KeyValueStorage } from '../../../../src/storage/keyvalue/KeyValueStorage';
|
||||
import type { JWKS } from '../../../../templates/types/oidc-provider';
|
||||
|
||||
describe('A CachedJwkGenerator', (): void => {
|
||||
const alg = 'ES256';
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Readable } from 'stream';
|
||||
import { exportJWK, generateKeyPair } from 'jose';
|
||||
import type * as Koa from 'koa';
|
||||
import type { errors, Configuration, KoaContextWithOIDC } from 'oidc-provider';
|
||||
import type { ErrorHandler } from '../../../../src/http/output/error/ErrorHandler';
|
||||
import type { ResponseWriter } from '../../../../src/http/output/ResponseWriter';
|
||||
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';
|
||||
@ -16,12 +15,11 @@ import type { KeyValueStorage } from '../../../../src/storage/keyvalue/KeyValueS
|
||||
import { FoundHttpError } from '../../../../src/util/errors/FoundHttpError';
|
||||
import { extractErrorTerms } from '../../../../src/util/errors/HttpErrorUtil';
|
||||
import { OAuthHttpError } from '../../../../src/util/errors/OAuthHttpError';
|
||||
import type { errors, Configuration, KoaContextWithOIDC } from '../../../../templates/types/oidc-provider';
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
jest.mock('oidc-provider', (): any => ({
|
||||
Provider: jest.fn().mockImplementation((issuer: string, config: Configuration): any =>
|
||||
({ issuer, config, use: jest.fn() })),
|
||||
}));
|
||||
jest.mock('oidc-provider', (): any =>
|
||||
jest.fn().mockImplementation((issuer: string, config: Configuration): any => ({ issuer, config, use: jest.fn() })));
|
||||
|
||||
const routes = {
|
||||
authorization: '/foo/oidc/auth',
|
||||
|
@ -1,10 +1,10 @@
|
||||
import type { Provider } from 'oidc-provider';
|
||||
import type { ProviderFactory } from '../../../../src/identity/configuration/ProviderFactory';
|
||||
import { ConsentHandler } from '../../../../src/identity/interaction/ConsentHandler';
|
||||
import type { Interaction } from '../../../../src/identity/interaction/InteractionHandler';
|
||||
import { FoundHttpError } from '../../../../src/util/errors/FoundHttpError';
|
||||
import { NotImplementedHttpError } from '../../../../src/util/errors/NotImplementedHttpError';
|
||||
import { readJsonStream } from '../../../../src/util/StreamUtil';
|
||||
import type Provider from '../../../../templates/types/oidc-provider';
|
||||
import { createPostJsonOperation } from './email-password/handler/Util';
|
||||
|
||||
const newGrantId = 'newGrantId';
|
||||
|
@ -1,4 +1,3 @@
|
||||
import type { Adapter } from 'oidc-provider';
|
||||
import {
|
||||
ClientCredentialsAdapter,
|
||||
ClientCredentialsAdapterFactory,
|
||||
@ -8,6 +7,7 @@ import type {
|
||||
} from '../../../../../../src/identity/interaction/email-password/credentials/ClientCredentialsAdapterFactory';
|
||||
import type { AdapterFactory } from '../../../../../../src/identity/storage/AdapterFactory';
|
||||
import type { KeyValueStorage } from '../../../../../../src/storage/keyvalue/KeyValueStorage';
|
||||
import type { Adapter } from '../../../../../../templates/types/oidc-provider';
|
||||
|
||||
describe('A ClientCredentialsAdapterFactory', (): void => {
|
||||
let storage: jest.Mocked<KeyValueStorage<string, ClientCredentials>>;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import type { AdapterPayload } from 'oidc-provider';
|
||||
import type { ExpiringAdapter } from '../../../../src/identity/storage/ExpiringAdapterFactory';
|
||||
import { ExpiringAdapterFactory } from '../../../../src/identity/storage/ExpiringAdapterFactory';
|
||||
import type { ExpiringStorage } from '../../../../src/storage/keyvalue/ExpiringStorage';
|
||||
import type { AdapterPayload } from '../../../../templates/types/oidc-provider';
|
||||
|
||||
// Use fixed dates
|
||||
jest.useFakeTimers();
|
||||
|
@ -1,9 +1,9 @@
|
||||
import type { Adapter } from 'oidc-provider';
|
||||
import type { AdapterFactory } from '../../../../src/identity/storage/AdapterFactory';
|
||||
import {
|
||||
PassthroughAdapter,
|
||||
PassthroughAdapterFactory,
|
||||
} from '../../../../src/identity/storage/PassthroughAdapterFactory';
|
||||
import type { Adapter } from '../../../../templates/types/oidc-provider';
|
||||
|
||||
describe('A PassthroughAdapterFactory', (): void => {
|
||||
let sourceFactory: jest.Mocked<AdapterFactory>;
|
||||
|
@ -1,8 +1,8 @@
|
||||
import fetch from 'cross-fetch';
|
||||
import type { Adapter } from 'oidc-provider';
|
||||
import type { AdapterFactory } from '../../../../src/identity/storage/AdapterFactory';
|
||||
import { WebIdAdapterFactory } from '../../../../src/identity/storage/WebIdAdapterFactory';
|
||||
import { RdfToQuadConverter } from '../../../../src/storage/conversion/RdfToQuadConverter';
|
||||
import type { Adapter } from '../../../../templates/types/oidc-provider';
|
||||
|
||||
jest.mock('cross-fetch');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user