kaven-utils
Version:
Utils for Node.js.
65 lines (64 loc) • 2.46 kB
TypeScript
/********************************************************************
* @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: 2025-10-14 22:58:04.827
* @version: 6.1.0
* @times: 76
* @lines: 283
* @copyright: Copyright © 2019-2025 Kaven. All Rights Reserved.
* @description: [description]
* @license: [license]
********************************************************************/
import { ILoggingAgent } from "kaven-basic";
import { ISSOClient, ISSOParameterName, ISSOVerifyResult, KavenSSO, SSOAction } 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;
Logger?: ILoggingAgent;
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>;
}