Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update types #237

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ declare namespace fastifyOauth2 {
scope?: string[];
credentials: Credentials;
callbackUri: string;
callbackUriParams?: Object;
tokenRequestParams?: Object;
generateStateFunction?: Function;
checkStateFunction?: Function;
callbackUriParams?: Record<string, string>;
tokenRequestParams?: Record<string, string>;
generateStateFunction?: (request: FastifyRequest) => string;
checkStateFunction?: (request?: FastifyRequest, callback?: (err: any) => void) => string | void;
Joabesv marked this conversation as resolved.
Show resolved Hide resolved
startRedirectPath?: string;
tags?: string[];
schema?: object;
Expand Down Expand Up @@ -126,11 +126,11 @@ declare namespace fastifyOauth2 {

getNewAccessTokenUsingRefreshToken(
refreshToken: Token,
params: Object,
params: Record<string, string>,
callback: (err: any, token: OAuth2Token) => void,
): void;

getNewAccessTokenUsingRefreshToken(refreshToken: Token, params: Object): Promise<OAuth2Token>;
getNewAccessTokenUsingRefreshToken(refreshToken: Token, params: Record<string, string>): Promise<OAuth2Token>;

generateAuthorizationUri(
request: FastifyRequest,
Expand All @@ -140,19 +140,19 @@ declare namespace fastifyOauth2 {
revokeToken(
revokeToken: Token,
tokenType: TToken,
httpOptions: Object | undefined,
httpOptions: Record<string, string> | undefined,
callback: (err: any) => void
): void

revokeToken(revokeToken: Token, tokenType: TToken, httpOptions: Object | undefined): Promise<void>
revokeToken(revokeToken: Token, tokenType: TToken, httpOptions: Record<string, string> | undefined): Promise<void>

revokeAllToken(
revokeToken: Token,
httpOptions: Object | undefined,
httpOptions: Record<string, string> | undefined,
callback: (err: any) => void
): void;

revokeAllToken(revokeToken: Token, httpOptions: Object | undefined): Promise<void>
revokeAllToken(revokeToken: Token, httpOptions: Record<string, string> | undefined): Promise<void>
}

export const fastifyOauth2: FastifyOauth2
Expand Down
6 changes: 1 addition & 5 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ const OAuth2Options: FastifyOAuth2Options = {
credentials: credentials,
callbackUri: 'http://localhost/testOauth/callback',
callbackUriParams: {},
generateStateFunction: () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this has been removed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it wasn't being used in any other place. Since it needs to receive a fastifyRequest, it essentially wasn't doing anything, but typescript was yelling, so I removed it!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need the test for this two function.
Please update to the valid syntax.

},
checkStateFunction: () => {
},
startRedirectPath: '/login/testOauth',
cookie: {
secure: true,
Expand Down Expand Up @@ -93,7 +89,7 @@ expectType<string[]>(scope);
expectType<string[]>(tags);
expectType<Credentials>(credentials);

// Ensure duplicayed simple-oauth2 are compatible with simple-oauth2
// Ensure duplicated simple-oauth2 are compatible with simple-oauth2
expectAssignable<ModuleOptions<string>>(credentials);
expectAssignable<ModuleOptions["auth"]>(auth);
// Ensure published types of simple-oauth2 are accepted
Expand Down