Skip to content

refactor(types): update types to be more concise #314

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

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Changes from all 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
58 changes: 29 additions & 29 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ declare namespace OAuth2Server {
*/
class Request {
body?: any;
headers?: { [key: string]: string; } | undefined;
method?: string | undefined;
query?: { [key: string]: string; } | undefined;
headers?: Record<string, string>;
method?: string;
query?: Record<string, string>;

/**
* Instantiates Request using the supplied options.
*
*/
constructor(options?: { [key: string]: any } | http.IncomingMessage);
constructor(options?: Record<string, any> | http.IncomingMessage);

/**
* Returns the specified HTTP header field. The match is case-insensitive.
Expand All @@ -79,14 +79,14 @@ declare namespace OAuth2Server {
*/
class Response {
body?: any;
headers?: { [key: string]: string; } | undefined;
status?: number | undefined;
headers?: Record<string, string>;
status?: number;

/**
* Instantiates Response using the supplied options.
*
*/
constructor(options?: { [key: string]: any; } | http.ServerResponse);
constructor(options?: Record<string, any> | http.ServerResponse);

/**
* Returns the specified HTTP header field. The match is case-insensitive.
Expand Down Expand Up @@ -173,66 +173,66 @@ declare namespace OAuth2Server {
/**
* Set the X-Accepted-OAuth-Scopes HTTP header on response objects.
*/
addAcceptedScopesHeader?: boolean | undefined;
addAcceptedScopesHeader?: boolean;

/**
* Set the X-OAuth-Scopes HTTP header on response objects.
*/
addAuthorizedScopesHeader?: boolean | undefined;
addAuthorizedScopesHeader?: boolean;

/**
* Allow clients to pass bearer tokens in the query string of a request.
*/
allowBearerTokensInQueryString?: boolean | undefined;
allowBearerTokensInQueryString?: boolean;
}

interface AuthorizeOptions {
/**
* The authenticate handler
*/
authenticateHandler?: {} | undefined;
authenticateHandler?: {};

/**
* Allow clients to specify an empty state
*/
allowEmptyState?: boolean | undefined;
allowEmptyState?: boolean;

/**
* Lifetime of generated authorization codes in seconds (default = 5 minutes).
*/
authorizationCodeLifetime?: number | undefined;
authorizationCodeLifetime?: number;
}

interface TokenOptions {
/**
* Lifetime of generated access tokens in seconds (default = 1 hour)
*/
accessTokenLifetime?: number | undefined;
accessTokenLifetime?: number;

/**
* Lifetime of generated refresh tokens in seconds (default = 2 weeks)
*/
refreshTokenLifetime?: number | undefined;
refreshTokenLifetime?: number;

/**
* Allow extended attributes to be set on the returned token
*/
allowExtendedTokenAttributes?: boolean | undefined;
allowExtendedTokenAttributes?: boolean;

/**
* Require a client secret. Defaults to true for all grant types.
*/
requireClientAuthentication?: {} | undefined;
requireClientAuthentication?: {};

/**
* Always revoke the used refresh token and issue a new one for the refresh_token grant.
*/
alwaysIssueNewRefreshToken?: boolean | undefined;
alwaysIssueNewRefreshToken?: boolean;

/**
* Additional supported grant types.
*/
extendedGrantTypes?: { [key: string]: typeof AbstractGrantType } | undefined;
extendedGrantTypes?: Record<string, typeof AbstractGrantType>;
}

/**
Expand Down Expand Up @@ -392,10 +392,10 @@ declare namespace OAuth2Server {
*/
interface Client {
id: string;
redirectUris?: string | string[] | undefined;
redirectUris?: string | string[];
grants: string | string[];
accessTokenLifetime?: number | undefined;
refreshTokenLifetime?: number | undefined;
accessTokenLifetime?: number;
refreshTokenLifetime?: number;
[key: string]: any;
}

Expand All @@ -406,7 +406,7 @@ declare namespace OAuth2Server {
authorizationCode: string;
expiresAt: Date;
redirectUri: string;
scope?: string[] | undefined;
scope?: string[];
client: Client;
user: User;
codeChallenge?: string;
Expand All @@ -419,10 +419,10 @@ declare namespace OAuth2Server {
*/
interface Token {
accessToken: string;
accessTokenExpiresAt?: Date | undefined;
refreshToken?: string | undefined;
refreshTokenExpiresAt?: Date | undefined;
scope?: string[] | undefined;
accessTokenExpiresAt?: Date;
refreshToken?: string;
refreshTokenExpiresAt?: Date;
scope?: string[];
client: Client;
user: User;
[key: string]: any;
Expand All @@ -433,8 +433,8 @@ declare namespace OAuth2Server {
*/
interface RefreshToken {
refreshToken: string;
refreshTokenExpiresAt?: Date | undefined;
scope?: string[] | undefined;
refreshTokenExpiresAt?: Date;
scope?: string[];
client: Client;
user: User;
[key: string]: any;
Expand Down