UNPKG

kaven-utils

Version:

Utils for Node.js.

63 lines (62 loc) 2.38 kB
/******************************************************************** * @author: Kaven * @email: kaven@wuwenkai.com * @website: http://blog.kaven.xyz * @file: [Kaven-Utils] /src/net/sso/KavenSSOServer.ts * @create: 2019-02-21 11:27:41.259 * @modify: 2023-12-08 15:35:00.375 * @version: 5.4.0 * @times: 73 * @lines: 282 * @copyright: Copyright © 2019-2023 Kaven. All Rights Reserved. * @description: [description] * @license: [license] ********************************************************************/ import { KavenSSO, ISSOParameterName, SSOAction, ISSOClient, ISSOVerifyResult } from "./KavenSSO.js"; export interface ISSOClientForServer extends ISSOClient { appID: string; returnTo?: string; serverSessionID?: string; notifyTo?: string; } export interface ISSOServerOption { loginPath?: string; ssoPath?: string; /** * name for url query parameters */ parameterName?: ISSOParameterName; /** * token name for cookie or http header */ tokenName?: string; sessionSet?: Set<string>; } export interface ISSOServerVerifyResult extends ISSOVerifyResult { client?: ISSOClientForServer; } export declare class KavenSSOServer extends KavenSSO { readonly LoginPath: string; readonly SSOPath: string; /** * Server logged in sessions */ readonly LoginSessionSet: Set<string>; private readonly clientsMap; constructor(secret: string, options?: ISSOServerOption); GetClients(appID: string, sessionID?: string): ISSOClientForServer[]; GetClientsByServerSessionID(serverSessionID: string): ISSOClientForServer[]; GetClient(token: string): ISSOClientForServer | undefined; /** * * @param originalUrl * @param userID * @param loginSessionID If defined, a new client will be created */ Verify(originalUrl: string, userID?: string, loginSessionID?: string): Promise<ISSOServerVerifyResult | undefined>; MakeNotifyURL(client: ISSOClientForServer, action: SSOAction, data?: string): Promise<string> | undefined; MakeRedirectURL(client: ISSOClientForServer): Promise<string | undefined>; GetRedirectToClientURL(client?: ISSOClientForServer): Promise<string | undefined>; private DeleteToken; Logout(serverSessionID: string, ignoreToken?: string): Promise<void>; }