From 6f185f35df0d67626f6ef036e6e36002dc5fc526 Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Tue, 14 Nov 2023 15:50:15 +0000 Subject: [PATCH] fix: update typing for validateScope making scope an optional parameter If a request is received with no scope in the request body, then the `scope` argument to `validateScope` is undefined instead of an array. This change updates the typings to be consistent with that behaviour. --- index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 5cd73d9..6bc4169 100644 --- a/index.d.ts +++ b/index.d.ts @@ -148,7 +148,7 @@ declare namespace OAuth2Server { * Validate requested scope. Calls Model#validateScope() if implemented. * */ - validateScope(user: User, client: Client, scope: string[]): Promise; + validateScope(user: User, client: Client, scope?: string[]): Promise; /** * Retrieve info from the request and client and return token @@ -314,7 +314,7 @@ declare namespace OAuth2Server { * Invoked to check if the requested scope is valid for a particular client/user combination. * */ - validateScope?(user: User, client: Client, scope: string[]): Promise; + validateScope?(user: User, client: Client, scope?: string[]): Promise; /** * Invoked to check if the provided `redirectUri` is valid for a particular `client`. @@ -340,7 +340,7 @@ declare namespace OAuth2Server { * Invoked to check if the requested scope is valid for a particular client/user combination. * */ - validateScope?(user: User, client: Client, scope: string[]): Promise; + validateScope?(user: User, client: Client, scope?: string[]): Promise; } interface RefreshTokenModel extends BaseModel, RequestAuthenticationModel { @@ -374,7 +374,7 @@ declare namespace OAuth2Server { * Invoked to check if the requested scope is valid for a particular client/user combination. * */ - validateScope?(user: User, client: Client, scope: string[]): Promise; + validateScope?(user: User, client: Client, scope?: string[]): Promise; } interface ExtensionModel extends BaseModel, RequestAuthenticationModel {}