Skip to content

Commit

Permalink
fix(typescript): revert void/undefined changes from 6.12.3
Browse files Browse the repository at this point in the history
closes #541
  • Loading branch information
panva committed Oct 3, 2019
1 parent a842b71 commit e0bbaae
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 56 deletions.
80 changes: 40 additions & 40 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,40 +213,40 @@ declare class Session extends BaseModel {
[clientId: string]: ClientAuthorizationState;
};

accountId(): string | undefined;
authTime(): string | undefined;
accountId(): string | void;
authTime(): string | void;
past(age: number): boolean;

ensureClientContainer(clientId: string): undefined;
ensureClientContainer(clientId: string): void;
loginAccount(details: {
account: string;
acr?: string;
amr?: string[];
loginTs?: number;
transient?: boolean;
}): undefined;
authorizationFor(clientId: string): ClientAuthorizationState | undefined;
}): void;
authorizationFor(clientId: string): ClientAuthorizationState | void;
stateFor(clientId: string): string;
sidFor(clientId: string): string;
sidFor(clientId: string, value: string): undefined;
sidFor(clientId: string, value: string): void;
grantIdFor(clientId: string): string;
grantIdFor(clientId: string, value: string): undefined;
metaFor(clientId: string): AnyObject | undefined;
metaFor(clientId: string, value: string): undefined;
grantIdFor(clientId: string, value: string): void;
metaFor(clientId: string): AnyObject | void;
metaFor(clientId: string, value: string): void;
acceptedScopesFor(clientId: string): Set<string>;
acceptedClaimsFor(clientId: string): Set<string>;
promptedScopesFor(clientId: string): Set<string>;
promptedScopesFor(clientId: string, scopes: string[]): undefined;
promptedScopesFor(clientId: string, scopes: string[]): void;
promptedClaimsFor(clientId: string): Set<string>;
promptedClaimsFor(clientId: string, claims: string[]): undefined;
promptedClaimsFor(clientId: string, claims: string[]): void;
rejectedScopesFor(clientId: string): Set<string>;
rejectedScopesFor(clientId: string, scopes: string[], replace?: boolean): undefined;
rejectedScopesFor(clientId: string, scopes: string[], replace?: boolean): void;
rejectedClaimsFor(clientId: string): Set<string>;
rejectedClaimsFor(clientId: string, claims: string[], replace?: boolean): undefined;
rejectedClaimsFor(clientId: string, claims: string[], replace?: boolean): void;

save(ttl?: number): Promise<string>;
destroy(): Promise<undefined>;
resetIdentifier(): undefined;
destroy(): Promise<void>;
resetIdentifier(): void;
static find<T>(this: { new (...args: any[]): T }, cookieId: string): Promise<T | undefined>;
static findByUid(uid: string): Promise<Session | undefined>;
static get(ctx: Koa.Context): Promise<Session>;
Expand Down Expand Up @@ -278,7 +278,7 @@ declare class BaseModel {
readonly adapter: Adapter;

save(ttl?: number): Promise<string>;
destroy(): Promise<undefined>;
destroy(): Promise<void>;
emit(eventName: string): void;

static readonly adapter: Adapter;
Expand Down Expand Up @@ -374,7 +374,7 @@ declare class RefreshToken extends BaseToken {

totalLifetime(): number;
isSenderConstrained(): boolean;
consume(): Promise<undefined>;
consume(): Promise<void>;
}

declare class AuthorizationCode extends BaseToken {
Expand Down Expand Up @@ -420,7 +420,7 @@ declare class AuthorizationCode extends BaseToken {
grantId?: string;
gty?: string;

consume(): Promise<undefined>;
consume(): Promise<void>;
}

declare class DeviceCode extends BaseToken {
Expand Down Expand Up @@ -456,7 +456,7 @@ declare class DeviceCode extends BaseToken {
gty: string;
consumed: any;

consume(): Promise<undefined>;
consume(): Promise<void>;
}

declare class ClientCredentials extends BaseToken {
Expand Down Expand Up @@ -546,7 +546,7 @@ declare class IdToken {
declare class ClientKeystore {
fresh(): boolean;
stale(): boolean;
refresh(): Promise<undefined>;
refresh(): Promise<void>;
readonly size: number;
all(parameters?: jose.JWKS.KeyQuery): jose.JWK.Key[];
get(parameters?: jose.JWKS.KeyQuery): jose.JWK.Key;
Expand Down Expand Up @@ -680,7 +680,7 @@ declare class OIDCContext {
readonly body?: AnyObject;
readonly params?: AnyObject;

acceptedScope(): string[] | undefined;
acceptedScope(): string[] | void;
resolvedClaims(): ClaimsWithRejects;

getAccessToken(opts?: { acceptDPoP?: boolean, acceptQueryParam?: boolean }): string;
Expand Down Expand Up @@ -776,13 +776,13 @@ export interface AdapterPayload {
}

export interface Adapter {
upsert(id: string, payload: AdapterPayload, expiresIn: number): Promise<undefined>;
find(id: string): Promise<AdapterPayload | undefined>;
findByUserCode(userCode: string): Promise<AdapterPayload | undefined>;
findByUid(uid: string): Promise<AdapterPayload | undefined>;
consume(id: string): Promise<undefined>;
destroy(id: string): Promise<undefined>;
revokeByGrantId(grantId: string): Promise<undefined>;
upsert(id: string, payload: AdapterPayload, expiresIn: number): Promise<undefined | void>;
find(id: string): Promise<AdapterPayload | undefined | void>;
findByUserCode(userCode: string): Promise<AdapterPayload | undefined | void>;
findByUid(uid: string): Promise<AdapterPayload | undefined | void>;
consume(id: string): Promise<undefined | void>;
destroy(id: string): Promise<undefined | void>;
revokeByGrantId(grantId: string): Promise<undefined | void>;
}

export interface AdapterConstructor {
Expand Down Expand Up @@ -856,7 +856,7 @@ export interface Configuration {
enabled?: boolean;
initialAccessToken?: boolean | string;
policies?: {
[key: string]: (ctx: KoaContextWithOIDC, metadata: ClientMetadata) => void;
[key: string]: (ctx: KoaContextWithOIDC, metadata: ClientMetadata) => void | undefined;
};
idFactory?: () => string;
secretFactory?: () => string;
Expand All @@ -872,9 +872,9 @@ export interface Configuration {
charset?: 'base-20' | 'digits';
mask?: string;
deviceInfo?: (ctx: KoaContextWithOIDC) => AnyObject;
userCodeInputSource?: (ctx: KoaContextWithOIDC, form: string, out?: ErrorOut, err?: errors.OIDCProviderError | Error) => Promise<undefined> | undefined;
userCodeConfirmSource?: (ctx: KoaContextWithOIDC, form: string, client: Client, deviceInfo: AnyObject, userCode: string) => Promise<undefined> | undefined;
successSource?: (ctx: KoaContextWithOIDC) => Promise<undefined> | undefined;
userCodeInputSource?: (ctx: KoaContextWithOIDC, form: string, out?: ErrorOut, err?: errors.OIDCProviderError | Error) => Promise<void | undefined> | void | undefined;
userCodeConfirmSource?: (ctx: KoaContextWithOIDC, form: string, client: Client, deviceInfo: AnyObject, userCode: string) => Promise<void | undefined> | void | undefined;
successSource?: (ctx: KoaContextWithOIDC) => Promise<void | undefined> | void | undefined;
};

requestObjects?: {
Expand Down Expand Up @@ -924,11 +924,11 @@ export interface Configuration {
frontchannelLogout?: {
enabled?: boolean;
ack?: 2;
logoutPendingSource?: (ctx: KoaContextWithOIDC, frames: string[], postLogoutRedirectUri?: string) => Promise<undefined>;
logoutPendingSource?: (ctx: KoaContextWithOIDC, frames: string[], postLogoutRedirectUri?: string) => Promise<void | undefined> | void | undefined;
};
};

extraAccessTokenClaims?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials) => Promise<AnyObject> | AnyObject | Promise<undefined> | undefined;
extraAccessTokenClaims?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials) => Promise<AnyObject> | AnyObject | Promise<void | undefined> | void | undefined;

formats?: {
AccessToken?: AccessTokenFormatFunction | TokenFormat;
Expand Down Expand Up @@ -997,16 +997,16 @@ export interface Configuration {
extraClientMetadata?: {
properties?: string[];

validator?: (key: string, value: any, metadata: ClientMetadata, ctx: KoaContextWithOIDC) => void;
validator?: (key: string, value: any, metadata: ClientMetadata, ctx: KoaContextWithOIDC) => void | undefined;
};

postLogoutSuccessSource?: (ctx: KoaContextWithOIDC) => void;
postLogoutSuccessSource?: (ctx: KoaContextWithOIDC) => Promise<void | undefined> | void | undefined;

rotateRefreshToken?: (ctx: KoaContextWithOIDC) => Promise<boolean> | boolean;

logoutSource?: (ctx: KoaContextWithOIDC, form: string) => void;
logoutSource?: (ctx: KoaContextWithOIDC, form: string) => Promise<void | undefined> | void | undefined;

renderError?: (ctx: KoaContextWithOIDC, out: ErrorOut, error: errors.OIDCProviderError | Error) => void;
renderError?: (ctx: KoaContextWithOIDC, out: ErrorOut, error: errors.OIDCProviderError | Error) => Promise<void | undefined> | void | undefined;

interactions?: {
policy?: interactionPolicy.Prompt[];
Expand Down Expand Up @@ -1101,7 +1101,7 @@ export class Provider extends events.EventEmitter {
res: http.ServerResponse | http2.Http2ServerResponse,
result: InteractionResults,
options?: { mergeWithLastSubmission?: boolean }
): Promise<undefined>;
): Promise<void>;

interactionDetails(req: http.IncomingMessage | http2.Http2ServerRequest, res: http.ServerResponse | http2.Http2ServerResponse): Promise<Interaction>;

Expand All @@ -1119,7 +1119,7 @@ export class Provider extends events.EventEmitter {

registerGrantType(
name: string,
handler: (ctx: KoaContextWithOIDC, next: () => Promise<undefined>) => Promise<undefined> | undefined,
handler: (ctx: KoaContextWithOIDC, next: () => Promise<void>) => Promise<void> | void,
params?: string | string[] | Set<string>,
dupes?: string | string[] | Set<string>
): void;
Expand Down
20 changes: 4 additions & 16 deletions types/oidc-provider-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,10 @@ const provider = new Provider('https://op.example.com', {
this.name = name;
}

async upsert(id: string, payload: object, expiresIn: number) {
return undefined;
}
async consume(id: string) {
return undefined;
}
async destroy(id: string) {
return undefined;
}
async revokeByGrantId(grantId: string) {
return undefined;
}
async upsert(id: string, payload: object, expiresIn: number) {}
async consume(id: string) {}
async destroy(id: string) {}
async revokeByGrantId(grantId: string) {}

async find(id: string) {
return {};
Expand Down Expand Up @@ -354,7 +346,6 @@ const provider = new Provider('https://op.example.com', {
if (postLogoutRedirectUri) {
postLogoutRedirectUri.substring(0);
}
return undefined;
}
},
deviceFlow: {
Expand All @@ -374,19 +365,16 @@ const provider = new Provider('https://op.example.com', {
if (err) {
err.message.substring(0);
}
return undefined;
},
async userCodeConfirmSource(ctx, form, client, deviceInfo, userCode) {
ctx.oidc.issuer.substring(0);
form.substring(0);
client.clientId.substring(0);
JSON.stringify(deviceInfo.foo);
userCode.substring(0);
return undefined;
},
async successSource(ctx) {
ctx.oidc.issuer.substring(0);
return undefined;
}
},
mTLS: {
Expand Down

0 comments on commit e0bbaae

Please sign in to comment.