Skip to content

Commit 41cacfa

Browse files
authored
build(deps-dev): replace standard with neostandard (#278)
* build(deps-dev): replace standard with neostandard * chore: add eslint.config.js * chore:rebase
1 parent dbd4f9c commit 41cacfa

File tree

5 files changed

+399
-395
lines changed

5 files changed

+399
-395
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![CI](https://github.com/fastify/fastify-oauth2/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fastify-oauth2/actions/workflows/ci.yml)
44
[![NPM version](https://img.shields.io/npm/v/@fastify/oauth2.svg?style=flat)](https://www.npmjs.com/package/@fastify/oauth2)
5-
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
5+
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)
66

77
Wrapper around the [`simple-oauth2`](https://github.com/lelylan/simple-oauth2) library.
88

eslint.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict'
2+
3+
module.exports = require('neostandard')({
4+
ignores: require('neostandard').resolveIgnoresFromGitignore(),
5+
ts: true
6+
})

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"type": "commonjs",
77
"types": "types/index.d.ts",
88
"scripts": {
9-
"lint": "standard | snazzy",
10-
"lint:fix": "standard --fix",
9+
"lint": "eslint",
10+
"lint:fix": "eslint --fix",
1111
"test": "npm run test:unit && npm run test:typescript",
1212
"test:coverage": "npm run test:unit -- --cov --coverage-report=html",
1313
"test:typescript": "tsd",
@@ -32,10 +32,9 @@
3232
"@types/node": "^22.0.0",
3333
"@types/simple-oauth2": "^5.0.7",
3434
"fastify": "^5.0.0",
35+
"neostandard": "^0.12.0",
3536
"nock": "^13.5.4",
3637
"simple-get": "^4.0.1",
37-
"snazzy": "^9.0.0",
38-
"standard": "^17.1.0",
3938
"tap": "^18.7.1",
4039
"tsd": "^0.31.0"
4140
},

types/index.d.ts

Lines changed: 151 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import { FastifyPluginCallback, FastifyReply, FastifyRequest, FastifyInstance } from 'fastify';
2-
import { CookieSerializeOptions } from "@fastify/cookie";
1+
import { FastifyPluginCallback, FastifyReply, FastifyRequest, FastifyInstance } from 'fastify'
2+
import { CookieSerializeOptions } from '@fastify/cookie'
33

44
interface FastifyOauth2 extends FastifyPluginCallback<fastifyOauth2.FastifyOAuth2Options> {
5-
APPLE_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
6-
DISCORD_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
7-
FACEBOOK_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
8-
GITHUB_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
9-
GITLAB_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
10-
LINKEDIN_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
11-
GOOGLE_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
12-
MICROSOFT_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
13-
SPOTIFY_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
14-
VKONTAKTE_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
15-
TWITCH_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
16-
VATSIM_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
17-
VATSIM_DEV_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
18-
EPIC_GAMES_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
19-
YANDEX_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
5+
APPLE_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
6+
DISCORD_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
7+
FACEBOOK_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
8+
GITHUB_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
9+
GITLAB_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
10+
LINKEDIN_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
11+
GOOGLE_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
12+
MICROSOFT_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
13+
SPOTIFY_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
14+
VKONTAKTE_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
15+
TWITCH_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
16+
VATSIM_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
17+
VATSIM_DEV_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
18+
EPIC_GAMES_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
19+
YANDEX_CONFIGURATION: fastifyOauth2.ProviderConfiguration;
2020
}
2121

2222
declare namespace fastifyOauth2 {
@@ -50,163 +50,163 @@ declare namespace fastifyOauth2 {
5050
verifierCookieName?: string;
5151
}
5252

53-
export type TToken = 'access_token' | 'refresh_token'
53+
export type TToken = 'access_token' | 'refresh_token'
5454

55-
export interface Token {
56-
token_type: 'Bearer';
57-
access_token: string;
58-
refresh_token?: string;
59-
id_token?: string;
60-
expires_in: number;
61-
expires_at: Date;
62-
}
55+
export interface Token {
56+
token_type: 'Bearer';
57+
access_token: string;
58+
refresh_token?: string;
59+
id_token?: string;
60+
expires_in: number;
61+
expires_at: Date;
62+
}
6363

64-
export interface OAuth2Token {
65-
/**
64+
export interface OAuth2Token {
65+
/**
6666
* Immutable object containing the token object provided while constructing a new access token instance.
6767
* This property will usually have the schema as specified by RFC6750,
6868
* but the exact properties may vary between authorization servers.
6969
*/
70-
token: Token;
70+
token: Token;
7171

72-
/**
72+
/**
7373
* Determines if the current access token is definitely expired or not
7474
* @param expirationWindowSeconds Window of time before the actual expiration to refresh the token. Defaults to 0.
7575
*/
76-
expired(expirationWindowSeconds?: number): boolean;
77-
78-
/** Refresh the access token */
79-
refresh(params?: {}): Promise<OAuth2Token>;
80-
81-
/** Revoke access or refresh token */
82-
revoke(tokenType: 'access_token' | 'refresh_token'): Promise<void>;
83-
84-
/** Revoke both the existing access and refresh tokens */
85-
revokeAll(): Promise<void>;
86-
}
87-
88-
export interface ProviderConfiguration {
89-
/** String used to set the host to request the tokens to. Required. */
90-
tokenHost: string;
91-
/** String path to request an access token. Default to /oauth/token. */
92-
tokenPath?: string | undefined;
93-
/** String path to revoke an access token. Default to /oauth/revoke. */
94-
revokePath?: string | undefined;
95-
/** String used to set the host to request an "authorization code". Default to the value set on auth.tokenHost. */
96-
authorizeHost?: string | undefined;
97-
/** String path to request an authorization code. Default to /oauth/authorize. */
98-
authorizePath?: string | undefined;
99-
}
100-
101-
export interface Credentials {
102-
client: {
103-
/** Service registered client id. Required. */
104-
id: string;
105-
/** Service registered client secret. Required. */
106-
secret: string;
107-
/** Parameter name used to send the client secret. Default to client_secret. */
108-
secretParamName?: string | undefined;
109-
/** Parameter name used to send the client id. Default to client_id. */
110-
idParamName?: string | undefined;
111-
};
112-
auth?: ProviderConfiguration;
113-
/**
76+
expired(expirationWindowSeconds?: number): boolean;
77+
78+
/** Refresh the access token */
79+
refresh(params?: {}): Promise<OAuth2Token>;
80+
81+
/** Revoke access or refresh token */
82+
revoke(tokenType: 'access_token' | 'refresh_token'): Promise<void>;
83+
84+
/** Revoke both the existing access and refresh tokens */
85+
revokeAll(): Promise<void>;
86+
}
87+
88+
export interface ProviderConfiguration {
89+
/** String used to set the host to request the tokens to. Required. */
90+
tokenHost: string;
91+
/** String path to request an access token. Default to /oauth/token. */
92+
tokenPath?: string | undefined;
93+
/** String path to revoke an access token. Default to /oauth/revoke. */
94+
revokePath?: string | undefined;
95+
/** String used to set the host to request an "authorization code". Default to the value set on auth.tokenHost. */
96+
authorizeHost?: string | undefined;
97+
/** String path to request an authorization code. Default to /oauth/authorize. */
98+
authorizePath?: string | undefined;
99+
}
100+
101+
export interface Credentials {
102+
client: {
103+
/** Service registered client id. Required. */
104+
id: string;
105+
/** Service registered client secret. Required. */
106+
secret: string;
107+
/** Parameter name used to send the client secret. Default to client_secret. */
108+
secretParamName?: string | undefined;
109+
/** Parameter name used to send the client id. Default to client_id. */
110+
idParamName?: string | undefined;
111+
};
112+
auth?: ProviderConfiguration;
113+
/**
114114
* Used to set global options to the internal http library (wreck).
115115
* All options except baseUrl are allowed
116116
* Defaults to header.Accept = "application/json"
117117
*/
118-
http?: {} | undefined;
119-
options?: {
120-
/** Format of data sent in the request body. Defaults to form. */
121-
bodyFormat?: "json" | "form" | undefined;
122-
/**
118+
http?: {} | undefined;
119+
options?: {
120+
/** Format of data sent in the request body. Defaults to form. */
121+
bodyFormat?: 'json' | 'form' | undefined;
122+
/**
123123
* Indicates the method used to send the client.id/client.secret authorization params at the token request.
124124
* If set to body, the bodyFormat option will be used to format the credentials.
125125
* Defaults to header
126126
*/
127-
authorizationMethod?: "header" | "body" | undefined;
128-
} | undefined;
129-
}
130-
131-
export interface OAuth2Namespace {
132-
getAccessTokenFromAuthorizationCodeFlow(
133-
request: FastifyRequest,
134-
): Promise<OAuth2Token>;
135-
136-
getAccessTokenFromAuthorizationCodeFlow(
137-
request: FastifyRequest,
138-
reply: FastifyReply,
139-
): Promise<OAuth2Token>;
140-
141-
getAccessTokenFromAuthorizationCodeFlow(
142-
request: FastifyRequest,
143-
callback: (err: any, token: OAuth2Token) => void,
144-
): void;
145-
146-
getAccessTokenFromAuthorizationCodeFlow(
147-
request: FastifyRequest,
148-
reply: FastifyReply,
149-
callback: (err: any, token: OAuth2Token) => void,
150-
): void;
151-
152-
getNewAccessTokenUsingRefreshToken(
153-
refreshToken: Token,
154-
params: Object,
155-
callback: (err: any, token: OAuth2Token) => void,
156-
): void;
157-
158-
getNewAccessTokenUsingRefreshToken(refreshToken: Token, params: Object): Promise<OAuth2Token>;
159-
160-
generateAuthorizationUri(
161-
request: FastifyRequest,
162-
reply: FastifyReply,
163-
callback: (err: any, uri: string) => void
164-
): void
165-
166-
generateAuthorizationUri(
167-
request: FastifyRequest,
168-
reply: FastifyReply,
169-
): Promise<string>;
170-
171-
revokeToken(
172-
revokeToken: Token,
173-
tokenType: TToken,
174-
httpOptions: Object | undefined,
175-
callback: (err: any) => void
176-
): void;
177-
178-
revokeToken(revokeToken: Token, tokenType: TToken, httpOptions: Object | undefined): Promise<void>;
179-
180-
revokeAllToken(
181-
revokeToken: Token,
182-
httpOptions: Object | undefined,
183-
callback: (err: any) => void
184-
): void;
185-
186-
revokeAllToken(revokeToken: Token, httpOptions: Object | undefined): Promise<void>;
187-
188-
userinfo(tokenSetOrToken: Token | string): Promise<Object>;
189-
190-
userinfo(tokenSetOrToken: Token | string, userInfoExtraOptions: UserInfoExtraOptions | undefined): Promise<Object>;
191-
192-
userinfo(tokenSetOrToken: Token | string, callback: (err: any, userinfo: Object) => void): void;
193-
194-
userinfo(tokenSetOrToken: Token | string, userInfoExtraOptions: UserInfoExtraOptions | undefined, callback: (err: any, userinfo: Object) => void): void;
195-
}
196-
export type UserInfoExtraOptions = { method?: 'GET' | 'POST', via?: 'header' | 'body', params?: object };
197-
export const fastifyOauth2: FastifyOauth2
198-
export {fastifyOauth2 as default}
127+
authorizationMethod?: 'header' | 'body' | undefined;
128+
} | undefined;
129+
}
130+
131+
export interface OAuth2Namespace {
132+
getAccessTokenFromAuthorizationCodeFlow(
133+
request: FastifyRequest,
134+
): Promise<OAuth2Token>;
135+
136+
getAccessTokenFromAuthorizationCodeFlow(
137+
request: FastifyRequest,
138+
reply: FastifyReply,
139+
): Promise<OAuth2Token>;
140+
141+
getAccessTokenFromAuthorizationCodeFlow(
142+
request: FastifyRequest,
143+
callback: (err: any, token: OAuth2Token) => void,
144+
): void;
145+
146+
getAccessTokenFromAuthorizationCodeFlow(
147+
request: FastifyRequest,
148+
reply: FastifyReply,
149+
callback: (err: any, token: OAuth2Token) => void,
150+
): void;
151+
152+
getNewAccessTokenUsingRefreshToken(
153+
refreshToken: Token,
154+
params: Object,
155+
callback: (err: any, token: OAuth2Token) => void,
156+
): void;
157+
158+
getNewAccessTokenUsingRefreshToken(refreshToken: Token, params: Object): Promise<OAuth2Token>;
159+
160+
generateAuthorizationUri(
161+
request: FastifyRequest,
162+
reply: FastifyReply,
163+
callback: (err: any, uri: string) => void
164+
): void
165+
166+
generateAuthorizationUri(
167+
request: FastifyRequest,
168+
reply: FastifyReply,
169+
): Promise<string>;
170+
171+
revokeToken(
172+
revokeToken: Token,
173+
tokenType: TToken,
174+
httpOptions: Object | undefined,
175+
callback: (err: any) => void
176+
): void;
177+
178+
revokeToken(revokeToken: Token, tokenType: TToken, httpOptions: Object | undefined): Promise<void>;
179+
180+
revokeAllToken(
181+
revokeToken: Token,
182+
httpOptions: Object | undefined,
183+
callback: (err: any) => void
184+
): void;
185+
186+
revokeAllToken(revokeToken: Token, httpOptions: Object | undefined): Promise<void>;
187+
188+
userinfo(tokenSetOrToken: Token | string): Promise<Object>;
189+
190+
userinfo(tokenSetOrToken: Token | string, userInfoExtraOptions: UserInfoExtraOptions | undefined): Promise<Object>;
191+
192+
userinfo(tokenSetOrToken: Token | string, callback: (err: any, userinfo: Object) => void): void;
193+
194+
userinfo(tokenSetOrToken: Token | string, userInfoExtraOptions: UserInfoExtraOptions | undefined, callback: (err: any, userinfo: Object) => void): void;
195+
}
196+
export type UserInfoExtraOptions = { method?: 'GET' | 'POST', via?: 'header' | 'body', params?: object }
197+
export const fastifyOauth2: FastifyOauth2
198+
export { fastifyOauth2 as default }
199199
}
200200

201-
declare function fastifyOauth2(...params: Parameters<FastifyOauth2>): ReturnType<FastifyOauth2>
201+
declare function fastifyOauth2 (...params: Parameters<FastifyOauth2>): ReturnType<FastifyOauth2>
202202

203203
export = fastifyOauth2
204204

205-
type UpperCaseCharacters = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z';
205+
type UpperCaseCharacters = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z'
206206

207207
declare module 'fastify' {
208-
interface FastifyInstance {
209-
// UpperCaseCharacters ensures that the name has at least one character in it + is a simple camel-case:ification
210-
[key: `oauth2${UpperCaseCharacters}${string}`]: fastifyOauth2.OAuth2Namespace | undefined;
211-
}
208+
interface FastifyInstance {
209+
// UpperCaseCharacters ensures that the name has at least one character in it + is a simple camel-case:ification
210+
[key: `oauth2${UpperCaseCharacters}${string}`]: fastifyOauth2.OAuth2Namespace | undefined;
211+
}
212212
}

0 commit comments

Comments
 (0)