Added some type generics type safety stuff
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 30s

This commit is contained in:
Alan Bridgeman 2026-01-29 11:30:53 -06:00
parent 74316cc41f
commit 223f52b746

View file

@ -98,7 +98,7 @@ type OAuthAppOptions = {
addons?: Addon[],
};
export class OAuthApp extends App {
export class OAuthApp<TCustomClaims extends BridgemanAccessibleAppClaims> extends App {
private onAuth: OnAuthCallback;
private saveSecret: (secret: string) => void | Promise<void>;
@ -120,7 +120,7 @@ export class OAuthApp extends App {
private subscriptionTiers?: AppSubscriptionTier[];
private addons?: Addon[];
private client: Client;
private client: Client<TCustomClaims>;
/**
* Create a new OAuth app
@ -197,7 +197,7 @@ export class OAuthApp extends App {
}
/** Returns the OAuthApp's Client instance (which is useful for managing keys, creating resource request, etc...) */
getClient(): Client {
getClient(): Client<TCustomClaims> {
return this.client;
}
@ -229,7 +229,7 @@ export class OAuthApp extends App {
.getRouter()
.addOutsideFrameworkRoute('/.well-known/jwks.json');
this.client = await Client.setup<BridgemanAccessibleAppClaims>(
this.client = await Client.setup<TCustomClaims>(
app.getExpressApp(),
baseAppUrl,
this.onAuth,
@ -240,7 +240,7 @@ export class OAuthApp extends App {
subscription_tiers: this.subscriptionTiers,
addons: this.addons,
webhooks: this.webhooks
},
} as TCustomClaims,
this.appName,
this.scopes,
{
@ -271,7 +271,7 @@ export class OAuthApp extends App {
*
* @param app The Express app object (that is now listening)
*/
private async onStart(app: App, callback?: (app: OAuthApp) => void | Promise<void>) {
private async onStart(app: App, callback?: (app: OAuthApp<TCustomClaims>) => void | Promise<void>) {
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
@ -299,7 +299,7 @@ export class OAuthApp extends App {
* 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<T extends Initializer>(initializer?: T, callback?: (app: OAuthApp) => void | Promise<void>) {
async run<T extends Initializer>(initializer?: T, callback?: (app: OAuthApp<TCustomClaims>) => void | Promise<void>) {
await super.run(initializer, async (app: App) => this.onStart(app, callback));
}
}