@upbond/customauth
Version:
CustomAuth login with torus to get user private key
94 lines (93 loc) • 3.81 kB
TypeScript
import { NodeDetailManager } from "@toruslabs/fetch-node-details";
import Torus from "@toruslabs/torus.js";
import { UserManager } from "oidc-client";
import { AggregateLoginParams, CustomAuthArgs, ExtraParams, InitParams, RedirectResult, SingleLoginParams, TorusKey, TorusSubVerifierInfo } from "./handlers/interfaces";
import SentryHandler from "./sentry";
import { UX_MODE_TYPE } from "./utils/enums";
import StorageHelper from "./utils/StorageHelper";
declare class CustomAuth {
isInitialized: boolean;
config: {
baseUrl: string;
redirectToOpener: boolean;
redirect_uri: string;
uxMode: UX_MODE_TYPE;
locationReplaceOnRedirect: boolean;
popupFeatures: string;
};
torus: Torus;
nodeDetailManager: NodeDetailManager;
storageHelper: StorageHelper;
sentryHandler: SentryHandler;
userManager: UserManager;
constructor({ baseUrl, network, enableLogging, enableOneKey, redirectToOpener, redirectPathName, apiKey, uxMode, locationReplaceOnRedirect, popupFeatures, metadataUrl, storageServerUrl, sentry, web3AuthClientId, }: CustomAuthArgs);
initOIDC(auth: any, client: any, redirect_uri: any): Promise<void>;
init({ skipSw, skipInit, skipPrefetch }?: InitParams): Promise<void>;
triggerLogin(args: SingleLoginParams): Promise<{
userInfo: {
accessToken: string;
idToken?: string;
ref?: string;
extraParams?: string;
extraParamsPassed?: string;
state: import("./handlers/interfaces").TorusGenericObject;
email: string;
name: string;
profileImage: string;
aggregateVerifier?: string;
verifier: string;
verifierId: string;
typeOfLogin: import("./utils/enums").LOGIN_TYPE;
registerOnly?: boolean;
extraVerifierParams?: import("./handlers/interfaces").WebAuthnExtraParams;
};
}>;
triggerAggregateLogin(args: AggregateLoginParams): Promise<{
userInfo: {
accessToken: string;
idToken?: string;
ref?: string;
extraParams?: string;
extraParamsPassed?: string;
state: import("./handlers/interfaces").TorusGenericObject;
aggregateVerifier: string;
email: string;
name: string;
profileImage: string;
verifier: string;
verifierId: string;
typeOfLogin: import("./utils/enums").LOGIN_TYPE;
registerOnly?: boolean;
extraVerifierParams?: import("./handlers/interfaces").WebAuthnExtraParams;
}[];
publicAddress: string;
privateKey: string;
metadataNonce: string;
typeOfUser: "v1" | "v2";
pubKey?: {
pub_key_X: string;
pub_key_Y: string;
};
}>;
SyncToTorusBlockchain(args: any): Promise<{
result: {
publicAddress: string;
privateKey: string;
metadataNonce: string;
typeOfUser: "v1" | "v2";
pubKey?: {
pub_key_X: string;
pub_key_Y: string;
};
};
}>;
getTorusKey(verifier: string, verifierId: string, verifierParams: {
verifier_id: string;
}, idToken: string, additionalParams?: ExtraParams): Promise<TorusKey>;
getAggregateTorusKey(verifier: string, verifierId: string, // unique identifier for user e.g. sub on jwt
subVerifierInfoArray: TorusSubVerifierInfo[]): Promise<TorusKey>;
getPostboxKeyFrom1OutOf1(privKey: string, nonce: string): string;
getUserinfoAndStates(replaceUrl: any, hashParams?: any): Promise<RedirectResult>;
private handlePrefetchRedirectUri;
}
export default CustomAuth;