From 54bfb3cd6f16d8689523b64c378eb1deb3fd1721 Mon Sep 17 00:00:00 2001 From: Alan Bridgeman Date: Fri, 3 Apr 2026 06:55:03 -0500 Subject: [PATCH] Modified OAuthApp to properly handle additional scopes not defined in the auth Scopes enum --- src/oauth/OAuthApp.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/oauth/OAuthApp.ts b/src/oauth/OAuthApp.ts index e928203..ddaa69d 100644 --- a/src/oauth/OAuthApp.ts +++ b/src/oauth/OAuthApp.ts @@ -14,7 +14,7 @@ import { HealthCheckableRequestClient } from '../utils/HealthCheckableRequestCli import type { BridgemanAccessibleAppClaims } from './types/BridgemanAccessibleAppClaims.js'; -interface BasicOAuthAppOptions { +interface BasicOAuthAppOptions { // ------------------ // Basic app metadata // ------------------ @@ -39,7 +39,7 @@ interface BasicOAuthAppOptions { contacts?: string[], /** The "available" scopes (scopes an app token COULD ask for - token scopes would have to ask for this or a subset of this list) */ - scopes?: Scopes[], + scopes?: (TScopes | Scopes)[], // ----------------------------------------------------- // Optional Mechanical Details (how the OAuth app works) @@ -98,16 +98,16 @@ interface BasicOAuthAppOptions { //addons?: Addon[], }; -type OAuthAppOptions = T & BasicOAuthAppOptions; +type OAuthAppOptions = T & BasicOAuthAppOptions; -export class OAuthApp extends App { +export class OAuthApp extends App { private onAuth: OnAuthCallback; private saveSecret: (secret: string) => void | Promise; private getSecret: () => Promise; - private options: OAuthAppOptions; + private options: OAuthAppOptions; - private client: Client; + private client: Client; /** * Create a new OAuth app @@ -158,17 +158,17 @@ export class OAuthApp extend onAuth: OnAuthCallback, saveSecret: (secret: string) => void | Promise, getSecret: () => Promise, - options?: OAuthAppOptions + options?: OAuthAppOptions ) { super(); this.onAuth = onAuth; this.saveSecret = saveSecret; this.getSecret = getSecret; - this.options = options ?? {} as OAuthAppOptions; + this.options = options ?? {} as OAuthAppOptions; } /** Returns the OAuthApp's Client instance (which is useful for managing keys, creating resource request, etc...) */ - getClient(): Client { + getClient(): Client { return this.client; } @@ -200,7 +200,7 @@ export class OAuthApp extend .getRouter() .addOutsideFrameworkRoute(BaseKeystore.WELL_KNOWN_URI); - this.client = await Client.setup( + this.client = await Client.setup( app.getExpressApp(), baseAppUrl, this.onAuth, @@ -322,7 +322,7 @@ export class OAuthApp extend * * @param app The Express app object (that is now listening) */ - private async onStart(app: App, callback?: (app: OAuthApp) => void | Promise) { + private async onStart(app: App, callback?: (app: OAuthApp) => void | Promise) { try { // Setup the OAuth client. // This is done here because we need the client to be serving/listening for requests for the auth library stuff to work @@ -350,7 +350,7 @@ export class OAuthApp extend * And doesn't have to worry about the OAuth details to make this work. * Though it does provide tweaking the OAuth details via options provided to the constructor. */ - async run(initializer?: T, callback?: (app: OAuthApp) => void | Promise) { + async run(initializer?: T, callback?: (app: OAuthApp) => void | Promise) { await super.run(initializer, async (app: App) => this.onStart(app, callback)); } } \ No newline at end of file