From 8538a4cf059688e1c894fdb1a609dc23ff4c5ed4 Mon Sep 17 00:00:00 2001 From: Adam Nielsen Date: Thu, 27 Nov 2025 11:48:18 +1000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74104=20[ltijs?= =?UTF-8?q?]=20Match=20upstream=20v5.9.7=20by=20@adam-nielsen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/ltijs/lib/Provider/Provider.d.ts | 89 ++++++++++++++++++++------ types/ltijs/ltijs-tests.ts | 21 +++--- types/ltijs/package.json | 2 +- 3 files changed, 80 insertions(+), 32 deletions(-) diff --git a/types/ltijs/lib/Provider/Provider.d.ts b/types/ltijs/lib/Provider/Provider.d.ts index b25eb1022b12f0..240021f14858e6 100644 --- a/types/ltijs/lib/Provider/Provider.d.ts +++ b/types/ltijs/lib/Provider/Provider.d.ts @@ -18,11 +18,10 @@ export interface DeploymentOptions { } export interface ProviderOptions { - appUrl?: string | undefined; - loginUrl?: string | undefined; - sessionTimeoutUrl?: string | undefined; - invalidTokenUrl?: string | undefined; - keysetUrl?: string | undefined; + appRoute?: string | undefined; + loginRoute?: string | undefined; + keysetRoute?: string | undefined; + dynregRoute?: string | undefined; https?: boolean | undefined; ssl?: { key: string; @@ -35,15 +34,47 @@ export interface ProviderOptions { cookies?: { secure?: boolean | undefined; sameSite?: string | undefined; + domain?: string | undefined; } | undefined; + devMode?: boolean | undefined; + ltiaas?: boolean | undefined; + tokenMaxAge?: number | undefined; + dynReg?: { + url: string; + name: string; + logo?: string | undefined; + description?: string | undefined; + redirectUris?: string[] | undefined; + customParameters?: any; + autoActivate?: boolean | undefined; + useDeepLinking?: boolean | undefined; + } | undefined; + + /** + * @deprecated Use `appRoute` property instead. + */ + appUrl?: string | undefined; + /** + * @deprecated Use `loginRoute` property instead. + */ + loginUrl?: string | undefined; + /** + * @deprecated Use `keysetRoute` property instead. + */ + keysetUrl?: string | undefined; +} + +export interface RequestCallback { + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type + (request: Request, response: Response, next: NextFunction): Response | void; } -export interface OnConnectCallback { +export interface TokenRequestCallback { // eslint-disable-next-line @typescript-eslint/no-invalid-void-type - (connection: IdToken, request: Request, response: Response, next: NextFunction): Response | void; + (token: IdToken, request: Request, response: Response, next: NextFunction): Response | void; } -export interface UnregisteredPlatformCallback { +export interface FinalRequestCallback { // eslint-disable-next-line @typescript-eslint/no-invalid-void-type (request: Request, response: Response): Response | void; } @@ -58,6 +89,13 @@ export interface RedirectOptions { ignoreRoot?: boolean | undefined; } +export type GetPlatformFunction = ( + url: string, + clientId?: string, + ENCRYPTIONKEY?: string, + Database?: Database +) => Promise; + declare class Provider { app: Express; @@ -72,34 +110,43 @@ declare class Provider { close(): Promise; - onConnect(_connectCallback: OnConnectCallback, options?: OnConnectOptions): true; + onConnect(_connectCallback: TokenRequestCallback, options?: OnConnectOptions): true; - onDeepLinking(_connectCallback: OnConnectCallback, options?: OnConnectOptions): true; + onDeepLinking(_deepLinkingCallback: TokenRequestCallback): true; - onUnregisteredPlatform(_unregisteredPlatformCallback: UnregisteredPlatformCallback): true; + onDynamicRegistration(_dynamicRegistrationCallback: RequestCallback): true; - loginUrl(): string; + onSessionTimeout(_sessionTimeoutCallback: FinalRequestCallback): true; - appUrl(): string; + onInvalidToken(_invalidTokenCallback: FinalRequestCallback): true; - sessionTimeoutUrl(): string; + onUnregisteredPlatform(_unregisteredPlatformCallback: FinalRequestCallback): true; - invalidTokenUrl(): string; + appRoute(): string; - keysetUrl(): string; + loginRoute(): string; + + keysetRoute(): string; + + dynRegRoute(): string; whitelist(...urls: Array): true; - registerPlatform(config: PlatformConfig): Promise; + registerPlatform(platform: PlatformConfig, getPlatform?: GetPlatformFunction, ENCRYPTIONKEY?: string, Database?: Database): Promise; - getPlatform(url: string): Promise; - getPlatform(url: string, clientId: string): Promise; + getPlatform(url: string, clientId?: string, ENCRYPTIONKEY?: string, Database?: Database): Promise; - deletePlatform(url: string, clientId: string): Promise; + updatePlatformById(platformId: string, platformInfo: PlatformConfig): Promise; - getAllPlatforms(): Promise; + deletePlatform(url: string, clientId: string): Promise; + + getAllPlatforms(): Promise; redirect(response: Response, path: string, options?: RedirectOptions): void; + + appUrl(): string; + loginUrl(): string; + keysetUrl(): string; } declare const defaultProvider: Provider; diff --git a/types/ltijs/ltijs-tests.ts b/types/ltijs/ltijs-tests.ts index 287aeddc19b53a..cba5a8f6a20e73 100644 --- a/types/ltijs/ltijs-tests.ts +++ b/types/ltijs/ltijs-tests.ts @@ -50,11 +50,9 @@ const ltiAdvanced = Provider.setup( }, }, { - appUrl: "/", - loginUrl: "/login", - sessionTimeoutUrl: "/sessionTimeout", - invalidTokenUrl: "/invalidToken", - keysetUrl: "/keys", + appRoute: "/", + loginRoute: "/login", + keysetRoute: "/keys", staticPath: "/views", https: true, ssl: { @@ -65,14 +63,13 @@ const ltiAdvanced = Provider.setup( secure: true, sameSite: "None", }, - serverAddon: app => {}, + serverAddon: app => { }, }, ); // $ExpectType true ltiMinimal.onConnect( (connection, request, response) => { - console.log(connection.endpoint); ltiMinimal.redirect(response, "/main"); }, { @@ -104,7 +101,7 @@ ltiMinimal.deploy(deploymentOptions); // $ExpectType Promise ltiAdvanced.deploy({ port: 4040, silent: true }); -// $ExpectType Promise +// $ExpectType Promise ltiAdvanced.registerPlatform({ url: "https://platform.url", name: "Platform Name", @@ -167,13 +164,17 @@ ltiAdvanced.app.get("/any", (request: Request, response: Response) => { ltiAdvanced.getPlatform("https://platform.url").then(async (platform) => { if (!platform) return; + const p = (Array.isArray(platform) ? platform[0] : platform); + // $expectType string | boolean - const name = await platform?.[0]?.platformName(); + const name = await p.platformName(); }); ltiAdvanced.getPlatform("https://platform.url", "123").then(async (platform) => { if (!platform) return; + const p = (Array.isArray(platform) ? platform[0] : platform); + // $expectType string | boolean - const name = await platform.platformName(); + const name = await p.platformName(); }); diff --git a/types/ltijs/package.json b/types/ltijs/package.json index 66719300b89f9f..0ca5b6737cca46 100644 --- a/types/ltijs/package.json +++ b/types/ltijs/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/ltijs", - "version": "4.0.9999", + "version": "5.9.9999", "projects": [ "https://cvmcosta.github.io/ltijs" ], From 590e2b0dd61486949144b632abdec84960697d06 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Thu, 27 Nov 2025 01:49:04 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A4=96=20dprint=20fmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/ltijs/lib/Provider/Provider.d.ts | 18 ++++++++++++++---- types/ltijs/ltijs-tests.ts | 6 +++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/types/ltijs/lib/Provider/Provider.d.ts b/types/ltijs/lib/Provider/Provider.d.ts index 240021f14858e6..cfe6dc53603f31 100644 --- a/types/ltijs/lib/Provider/Provider.d.ts +++ b/types/ltijs/lib/Provider/Provider.d.ts @@ -93,7 +93,7 @@ export type GetPlatformFunction = ( url: string, clientId?: string, ENCRYPTIONKEY?: string, - Database?: Database + Database?: Database, ) => Promise; declare class Provider { @@ -132,9 +132,19 @@ declare class Provider { whitelist(...urls: Array): true; - registerPlatform(platform: PlatformConfig, getPlatform?: GetPlatformFunction, ENCRYPTIONKEY?: string, Database?: Database): Promise; - - getPlatform(url: string, clientId?: string, ENCRYPTIONKEY?: string, Database?: Database): Promise; + registerPlatform( + platform: PlatformConfig, + getPlatform?: GetPlatformFunction, + ENCRYPTIONKEY?: string, + Database?: Database, + ): Promise; + + getPlatform( + url: string, + clientId?: string, + ENCRYPTIONKEY?: string, + Database?: Database, + ): Promise; updatePlatformById(platformId: string, platformInfo: PlatformConfig): Promise; diff --git a/types/ltijs/ltijs-tests.ts b/types/ltijs/ltijs-tests.ts index cba5a8f6a20e73..6d93e955bdc27b 100644 --- a/types/ltijs/ltijs-tests.ts +++ b/types/ltijs/ltijs-tests.ts @@ -63,7 +63,7 @@ const ltiAdvanced = Provider.setup( secure: true, sameSite: "None", }, - serverAddon: app => { }, + serverAddon: app => {}, }, ); @@ -164,7 +164,7 @@ ltiAdvanced.app.get("/any", (request: Request, response: Response) => { ltiAdvanced.getPlatform("https://platform.url").then(async (platform) => { if (!platform) return; - const p = (Array.isArray(platform) ? platform[0] : platform); + const p = Array.isArray(platform) ? platform[0] : platform; // $expectType string | boolean const name = await p.platformName(); @@ -173,7 +173,7 @@ ltiAdvanced.getPlatform("https://platform.url").then(async (platform) => { ltiAdvanced.getPlatform("https://platform.url", "123").then(async (platform) => { if (!platform) return; - const p = (Array.isArray(platform) ? platform[0] : platform); + const p = Array.isArray(platform) ? platform[0] : platform; // $expectType string | boolean const name = await p.platformName();