ltijs
Version:
Easily turn your web application into a LTI 1.3 Learning Tool.
41 lines (40 loc) • 2 kB
TypeScript
import type { z } from 'zod';
import type { LoginRequestPayloadSchema, LaunchCallbackPayloadSchema } from '#services/launch/launch.schemas';
import type { LaunchContext } from '#services/launch/launch-context.service';
import type { HttpRequestParameters, HttpResponse, RouteHandler } from '#services/http-handler/http-handler.types';
import type { IdTokenRecord } from '#services/database-manager/database-manager.types';
import type { Platform } from '#services/platform-manager/platform-manager.types';
import type { State } from '#services/oidc/oidc.types';
export type LoginRequestParams = z.infer<typeof LoginRequestPayloadSchema>;
export type LaunchCallbackParams = z.infer<typeof LaunchCallbackPayloadSchema>;
export interface LoginRequestResult {
redirectUrl: string;
state: string;
/** Never sent to the platform; only ever delivered to the browser for client-side storage. */
recoveryToken: string;
/** Only set when the platform declared postMessage storage support (`lti_storage_target`) at login. */
storageTarget?: string;
platformLoginOrigin?: string;
}
export interface ProcessLaunchResult {
idToken: IdTokenRecord;
state: State;
platform: Platform;
}
export interface TargetLinkUriParts {
targetLinkUri: string;
query?: Record<string, string>;
fragment?: string;
}
/** Extra query parameters to merge into the redirect URL, in addition to the ltik `LaunchContext.redirect` always appends. */
export interface RedirectOptions {
query?: Record<string, string>;
}
export interface LaunchRoutes {
loginRoute: string;
launchRoute: string;
}
/** A launch handler, given the resolved `LaunchContext` plus the raw request/response, for reading extra headers or sending a custom response. */
export type OnLaunchHandler = (context: LaunchContext, request: HttpRequestParameters, response: HttpResponse) => Promise<void>;
export type UnregisteredPlatformHandler = RouteHandler;
export type InactivePlatformHandler = RouteHandler;