more-sso-sdk
Version:
106 lines (99 loc) • 2.56 kB
TypeScript
import React from 'react';
import * as react_jsx_runtime from 'react/jsx-runtime';
interface INetworkResponse<T> {
status: number;
data: T;
}
interface RefreshTokenData {
aud?: string;
business_unit?: string;
designation?: string;
domain_id?: string;
email?: string;
employee_id?: string;
identifier?: string;
job_band?: string;
manager_id?: string;
token?: string;
user_id?: string;
permissions?: {
[key: string]: string;
};
roles?: unknown;
refresh_token?: string;
}
interface RefreshTokenResponse {
data?: RefreshTokenData;
}
interface DevTokenData {
token?: string;
refresh_token?: string;
}
interface DevTokenResponse {
data?: DevTokenData;
detail?: string;
}
interface ProfileDetails {
contact_info?: string;
designation?: string;
domain_id?: string;
email?: string;
employee_id?: string;
full_name?: string;
manager_id?: string;
display_name?: string;
profile_uri?: string;
role?: string;
}
declare enum ENV {
PROD = "prod",
DEV = "dev"
}
declare enum ProjectType {
NEXTJS = "nextjs",
VITE = "vite"
}
declare enum AUTH_KEY {
DEV = "dev_more_auth",
PROD = "prod_more_auth"
}
declare enum REFRESH_TOKEN_KEY {
DEV = "dev_more_auth",
PROD = "prod_more_auth"
}
type Config = {
env: ENV;
redirectUrl: string;
app: string;
idp: string;
};
declare class SSOAuthorization {
static env?: ENV;
static redirectUrl?: string;
static app?: string;
static idp?: string;
static init(config: Config): void;
static login(redirectURL: string): void;
static getToken(redirectURL: string): Promise<RefreshTokenData>;
static logout(redirectURL?: string): Promise<void>;
static getDevToken(username: string): Promise<RefreshTokenData>;
static callLogoutAPI: (refreshToken: string) => Promise<void>;
static getProfileDetails(): Promise<ProfileDetails>;
}
interface Props {
className?: string;
employeeId: string;
name: string;
size?: number;
onClick?: () => void;
}
/**
* InitialAvatar
* Props:
* - name: string
* - employeeId: string // used as deterministic seed
* - size: number // px; default 100
*/
declare const Avatar: React.FC<Props>;
declare const Loader: () => react_jsx_runtime.JSX.Element;
export { AUTH_KEY, Avatar, type DevTokenData, type DevTokenResponse, ENV, type INetworkResponse, Loader, ProjectType, REFRESH_TOKEN_KEY, type RefreshTokenData, type RefreshTokenResponse, SSOAuthorization };