Skip to content

Commit

Permalink
fix(typescript): rotateRefreshToken boolean, ES256K, async customizers
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrikstrid authored and panva committed Dec 18, 2019
1 parent 73131fc commit 22ab1e3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
10 changes: 5 additions & 5 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,9 @@ export interface Configuration {
// TODO: can't seem to get a pass on async when | AsymmetricSigningAlgoritm is also possible return;
jwtAccessTokenSigningAlg?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials, client: Client) => Promise<AsymmetricSigningAlgoritm>;
customizers?: {
jwt?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials, parts: JWTStructured) => JWTStructured;
'jwt-ietf'?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials, parts: JWTStructured) => JWTStructured;
paseto?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials, parts: PASETOStructured) => PASETOStructured;
jwt?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials, parts: JWTStructured) => Promise<JWTStructured> | JWTStructured;
'jwt-ietf'?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials, parts: JWTStructured) => Promise<JWTStructured> | JWTStructured;
paseto?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials, parts: PASETOStructured) => Promise<PASETOStructured> | PASETOStructured;
};
};

Expand Down Expand Up @@ -1065,7 +1065,7 @@ export interface Configuration {

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

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

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

Expand Down Expand Up @@ -1109,7 +1109,7 @@ export interface Configuration {
}

export type NoneAlg = 'none';
export type AsymmetricSigningAlgoritm = 'PS256' | 'PS384' | 'PS512' | 'ES256' | 'ES384' | 'ES512' | 'EdDSA' | 'RS256' | 'RS384' | 'RS512';
export type AsymmetricSigningAlgoritm = 'PS256' | 'PS384' | 'PS512' | 'ES256' | 'ES256K' | 'ES384' | 'ES512' | 'EdDSA' | 'RS256' | 'RS384' | 'RS512';
export type SymmetricSigningAlgorithm = 'HS256' | 'HS384' | 'HS512';
export type SigningAlgorithm = AsymmetricSigningAlgoritm | SymmetricSigningAlgorithm;
export type SigningAlgorithmWithNone = AsymmetricSigningAlgoritm | SymmetricSigningAlgorithm | NoneAlg;
Expand Down
32 changes: 32 additions & 0 deletions types/oidc-provider-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@ import { Provider, interactionPolicy } from './index.d';

new Provider('https://op.example.com');

new Provider('https://op.example.com', {
rotateRefreshToken: true,
formats: {
customizers: {
async jwt(ctx, token, parts) {
ctx.oidc.issuer.substring(0);
token.iat.toFixed();
parts.header = { foo: 'bar' };
parts.payload.foo = 'bar';
return parts;
},
async 'jwt-ietf'(ctx, token, parts) {
ctx.oidc.issuer.substring(0);
token.iat.toFixed();
parts.header = { foo: 'bar' };
parts.payload.foo = 'bar';
return parts;
},
async paseto(ctx, token, parts) {
ctx.oidc.issuer.substring(0);
token.iat.toFixed();
parts.footer = { foo: 'bar' };
parts.footer = Buffer.from('foo');
parts.footer = undefined;
parts.footer = 'foo';
parts.payload.foo = 'bar';
return parts;
},
},
},
});

const provider = new Provider('https://op.example.com', {
acrValues: ['urn:example:bronze'],
adapter: class Adapter {
Expand Down

0 comments on commit 22ab1e3

Please sign in to comment.