ltijs
Version:
Easily turn your web application into a LTI 1.3 Learning Tool.
165 lines (164 loc) • 5.35 kB
TypeScript
import mongoose from 'mongoose';
import type { LtiMessageType } from '#services/launch/id-token.constants';
/** The real, existing `platform` collection shape `MongoLegacyDatabaseManager` keeps reading/writing (base fields only -- status and keys live in their own collections). `kid` is what `PlatformRecord.id` maps to. */
export interface LegacyPlatformDoc {
platformUrl: string;
platformName: string;
clientId: string;
authEndpoint: string;
accesstokenEndpoint: string;
authorizationServer?: string;
kid: string;
authConfig: {
method: string;
key: string;
};
}
export interface PlatformStatusDoc {
id: string;
active: boolean;
}
/** Shared by both the `publickey` and `privatekey` collections -- real legacy uses the identical shape for both. */
export interface KeyDoc {
kid: string;
platformUrl: string;
clientId: string;
iv: string;
data: string;
}
export interface LegacyAccessTokenDoc {
platformUrl: string;
clientId: string;
scopes: string;
iv: string;
data: string;
createdAt: Date;
}
export interface NonceDoc {
nonce: string;
createdAt: Date;
}
/**
* The real, existing narrow `idToken` collection shape `MongoLegacyDatabaseManager`
* keeps reading/writing. `launchId` is a new field (not part of the original
* legacy shape): a random opaque ID generated once per launch, written onto
* both this doc and its paired `ContextTokenDoc`, and used as the sole
* correlation/lookup key between the two -- see `getIdToken`/`saveIdToken`.
*/
export interface LegacyIdTokenDoc {
launchId: string;
iss: string;
user: string;
clientId: string;
deploymentId: string;
userInfo?: Record<string, unknown>;
platformInfo: Record<string, unknown>;
platformId: string;
createdAt: Date;
}
/** The real, existing `contexttoken` collection -- `MongoLegacyDatabaseManager` merges this with `LegacyIdTokenDoc` to build an `IdTokenRecord`. */
export interface ContextTokenDoc {
launchId: string;
contextId: string;
user: string;
context?: Record<string, unknown>;
resource?: Record<string, unknown>;
messageType?: LtiMessageType;
version?: string;
deepLinkingSettings?: Record<string, unknown>;
lis?: Record<string, unknown>;
roles?: string[];
targetLinkUri?: string;
custom?: Record<string, unknown>;
launchPresentation?: Record<string, unknown>;
endpoint?: Record<string, unknown>;
namesRoles?: Record<string, unknown>;
createdAt: Date;
[claim: string]: unknown;
}
export declare const LegacyPlatformModel: mongoose.Model<LegacyPlatformDoc, {}, {}, {}, mongoose.Document<unknown, {}, LegacyPlatformDoc, {}, mongoose.DefaultSchemaOptions> & LegacyPlatformDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
} & {
id: string;
}, any, LegacyPlatformDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
}>;
export declare const PlatformStatusModel: mongoose.Model<PlatformStatusDoc, {}, {}, {}, mongoose.Document<unknown, {}, PlatformStatusDoc, {}, mongoose.DefaultSchemaOptions> & PlatformStatusDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
}, any, PlatformStatusDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
}>;
export declare const PublicKeyModel: mongoose.Model<KeyDoc, {}, {}, {}, mongoose.Document<unknown, {}, KeyDoc, {}, mongoose.DefaultSchemaOptions> & KeyDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
} & {
id: string;
}, any, KeyDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
}>;
export declare const PrivateKeyModel: mongoose.Model<KeyDoc, {}, {}, {}, mongoose.Document<unknown, {}, KeyDoc, {}, mongoose.DefaultSchemaOptions> & KeyDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
} & {
id: string;
}, any, KeyDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
}>;
export declare const LegacyAccessTokenModel: mongoose.Model<LegacyAccessTokenDoc, {}, {}, {}, mongoose.Document<unknown, {}, LegacyAccessTokenDoc, {}, mongoose.DefaultSchemaOptions> & LegacyAccessTokenDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
} & {
id: string;
}, any, LegacyAccessTokenDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
}>;
export declare const NonceModel: mongoose.Model<NonceDoc, {}, {}, {}, mongoose.Document<unknown, {}, NonceDoc, {}, mongoose.DefaultSchemaOptions> & NonceDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
} & {
id: string;
}, any, NonceDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
}>;
export declare const LegacyIdTokenModel: mongoose.Model<LegacyIdTokenDoc, {}, {}, {}, mongoose.Document<unknown, {}, LegacyIdTokenDoc, {}, mongoose.DefaultSchemaOptions> & LegacyIdTokenDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
} & {
id: string;
}, any, LegacyIdTokenDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
}>;
export declare const ContextTokenModel: mongoose.Model<ContextTokenDoc, {}, {}, {}, mongoose.Document<unknown, {}, ContextTokenDoc, {}, mongoose.DefaultSchemaOptions> & ContextTokenDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
} & {
id: string;
}, any, ContextTokenDoc & {
_id: mongoose.Types.ObjectId;
} & {
__v: number;
}>;