Skip to content

Commit 8538a4c

Browse files
authored
🤖 Merge PR DefinitelyTyped#74104 [ltijs] Match upstream v5.9.7 by @adam-nielsen
1 parent c303b67 commit 8538a4c

File tree

3 files changed

+80
-32
lines changed

3 files changed

+80
-32
lines changed

types/ltijs/lib/Provider/Provider.d.ts

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ export interface DeploymentOptions {
1818
}
1919

2020
export interface ProviderOptions {
21-
appUrl?: string | undefined;
22-
loginUrl?: string | undefined;
23-
sessionTimeoutUrl?: string | undefined;
24-
invalidTokenUrl?: string | undefined;
25-
keysetUrl?: string | undefined;
21+
appRoute?: string | undefined;
22+
loginRoute?: string | undefined;
23+
keysetRoute?: string | undefined;
24+
dynregRoute?: string | undefined;
2625
https?: boolean | undefined;
2726
ssl?: {
2827
key: string;
@@ -35,15 +34,47 @@ export interface ProviderOptions {
3534
cookies?: {
3635
secure?: boolean | undefined;
3736
sameSite?: string | undefined;
37+
domain?: string | undefined;
3838
} | undefined;
39+
devMode?: boolean | undefined;
40+
ltiaas?: boolean | undefined;
41+
tokenMaxAge?: number | undefined;
42+
dynReg?: {
43+
url: string;
44+
name: string;
45+
logo?: string | undefined;
46+
description?: string | undefined;
47+
redirectUris?: string[] | undefined;
48+
customParameters?: any;
49+
autoActivate?: boolean | undefined;
50+
useDeepLinking?: boolean | undefined;
51+
} | undefined;
52+
53+
/**
54+
* @deprecated Use `appRoute` property instead.
55+
*/
56+
appUrl?: string | undefined;
57+
/**
58+
* @deprecated Use `loginRoute` property instead.
59+
*/
60+
loginUrl?: string | undefined;
61+
/**
62+
* @deprecated Use `keysetRoute` property instead.
63+
*/
64+
keysetUrl?: string | undefined;
65+
}
66+
67+
export interface RequestCallback {
68+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
69+
(request: Request, response: Response, next: NextFunction): Response | void;
3970
}
4071

41-
export interface OnConnectCallback {
72+
export interface TokenRequestCallback {
4273
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
43-
(connection: IdToken, request: Request, response: Response, next: NextFunction): Response | void;
74+
(token: IdToken, request: Request, response: Response, next: NextFunction): Response | void;
4475
}
4576

46-
export interface UnregisteredPlatformCallback {
77+
export interface FinalRequestCallback {
4778
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
4879
(request: Request, response: Response): Response | void;
4980
}
@@ -58,6 +89,13 @@ export interface RedirectOptions {
5889
ignoreRoot?: boolean | undefined;
5990
}
6091

92+
export type GetPlatformFunction = (
93+
url: string,
94+
clientId?: string,
95+
ENCRYPTIONKEY?: string,
96+
Database?: Database
97+
) => Promise<Platform[] | Platform | false>;
98+
6199
declare class Provider {
62100
app: Express;
63101

@@ -72,34 +110,43 @@ declare class Provider {
72110

73111
close(): Promise<boolean>;
74112

75-
onConnect(_connectCallback: OnConnectCallback, options?: OnConnectOptions): true;
113+
onConnect(_connectCallback: TokenRequestCallback, options?: OnConnectOptions): true;
76114

77-
onDeepLinking(_connectCallback: OnConnectCallback, options?: OnConnectOptions): true;
115+
onDeepLinking(_deepLinkingCallback: TokenRequestCallback): true;
78116

79-
onUnregisteredPlatform(_unregisteredPlatformCallback: UnregisteredPlatformCallback): true;
117+
onDynamicRegistration(_dynamicRegistrationCallback: RequestCallback): true;
80118

81-
loginUrl(): string;
119+
onSessionTimeout(_sessionTimeoutCallback: FinalRequestCallback): true;
82120

83-
appUrl(): string;
121+
onInvalidToken(_invalidTokenCallback: FinalRequestCallback): true;
84122

85-
sessionTimeoutUrl(): string;
123+
onUnregisteredPlatform(_unregisteredPlatformCallback: FinalRequestCallback): true;
86124

87-
invalidTokenUrl(): string;
125+
appRoute(): string;
88126

89-
keysetUrl(): string;
127+
loginRoute(): string;
128+
129+
keysetRoute(): string;
130+
131+
dynRegRoute(): string;
90132

91133
whitelist(...urls: Array<string | { route: string; method: string }>): true;
92134

93-
registerPlatform(config: PlatformConfig): Promise<Platform | false>;
135+
registerPlatform(platform: PlatformConfig, getPlatform?: GetPlatformFunction, ENCRYPTIONKEY?: string, Database?: Database): Promise<Platform>;
94136

95-
getPlatform(url: string): Promise<Platform[] | false>;
96-
getPlatform(url: string, clientId: string): Promise<Platform | false>;
137+
getPlatform(url: string, clientId?: string, ENCRYPTIONKEY?: string, Database?: Database): Promise<Platform[] | Platform | false>;
97138

98-
deletePlatform(url: string, clientId: string): Promise<boolean>;
139+
updatePlatformById(platformId: string, platformInfo: PlatformConfig): Promise<Platform>;
99140

100-
getAllPlatforms(): Promise<Platform[] | false>;
141+
deletePlatform(url: string, clientId: string): Promise<true>;
142+
143+
getAllPlatforms(): Promise<Platform[]>;
101144

102145
redirect(response: Response, path: string, options?: RedirectOptions): void;
146+
147+
appUrl(): string;
148+
loginUrl(): string;
149+
keysetUrl(): string;
103150
}
104151

105152
declare const defaultProvider: Provider;

types/ltijs/ltijs-tests.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ const ltiAdvanced = Provider.setup(
5050
},
5151
},
5252
{
53-
appUrl: "/",
54-
loginUrl: "/login",
55-
sessionTimeoutUrl: "/sessionTimeout",
56-
invalidTokenUrl: "/invalidToken",
57-
keysetUrl: "/keys",
53+
appRoute: "/",
54+
loginRoute: "/login",
55+
keysetRoute: "/keys",
5856
staticPath: "/views",
5957
https: true,
6058
ssl: {
@@ -65,14 +63,13 @@ const ltiAdvanced = Provider.setup(
6563
secure: true,
6664
sameSite: "None",
6765
},
68-
serverAddon: app => {},
66+
serverAddon: app => { },
6967
},
7068
);
7169

7270
// $ExpectType true
7371
ltiMinimal.onConnect(
7472
(connection, request, response) => {
75-
console.log(connection.endpoint);
7673
ltiMinimal.redirect(response, "/main");
7774
},
7875
{
@@ -104,7 +101,7 @@ ltiMinimal.deploy(deploymentOptions);
104101
// $ExpectType Promise<true | undefined>
105102
ltiAdvanced.deploy({ port: 4040, silent: true });
106103

107-
// $ExpectType Promise<false | Platform>
104+
// $ExpectType Promise<Platform>
108105
ltiAdvanced.registerPlatform({
109106
url: "https://platform.url",
110107
name: "Platform Name",
@@ -167,13 +164,17 @@ ltiAdvanced.app.get("/any", (request: Request, response: Response) => {
167164
ltiAdvanced.getPlatform("https://platform.url").then(async (platform) => {
168165
if (!platform) return;
169166

167+
const p = (Array.isArray(platform) ? platform[0] : platform);
168+
170169
// $expectType string | boolean
171-
const name = await platform?.[0]?.platformName();
170+
const name = await p.platformName();
172171
});
173172

174173
ltiAdvanced.getPlatform("https://platform.url", "123").then(async (platform) => {
175174
if (!platform) return;
176175

176+
const p = (Array.isArray(platform) ? platform[0] : platform);
177+
177178
// $expectType string | boolean
178-
const name = await platform.platformName();
179+
const name = await p.platformName();
179180
});

types/ltijs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/ltijs",
4-
"version": "4.0.9999",
4+
"version": "5.9.9999",
55
"projects": [
66
"https://cvmcosta.github.io/ltijs"
77
],

0 commit comments

Comments
 (0)