62 lines
2.3 KiB
TypeScript
62 lines
2.3 KiB
TypeScript
import { type TransportClient, READY_STATE } from "@tensamin/ttp-core";
|
|
import { createSchema } from "./schema";
|
|
import type { ZodObject } from "zod";
|
|
/**
|
|
* @param redirectUrl The URL should point to the TAuth HTTP Server at http://hostname:port/callback
|
|
*/
|
|
export declare class TAuthClient {
|
|
frontendUrl: string;
|
|
identifier: string;
|
|
privateKey: string;
|
|
publicKey: string;
|
|
redirectUrl: URL;
|
|
schema: ReturnType<typeof createSchema>;
|
|
httpServer: {
|
|
port: number;
|
|
hostname: string;
|
|
};
|
|
clientMap: Map<string, TransportClient<{
|
|
identification: {
|
|
request: ZodObject<{
|
|
app_identifier: import("zod").ZodString;
|
|
app_session_id: import("zod").ZodNumber;
|
|
app_public_key: import("zod").ZodString;
|
|
user_id: import("zod").ZodNumber;
|
|
}, import("zod/v4/core").$strip>;
|
|
response: ZodObject<{
|
|
challenge: import("zod").ZodBase64;
|
|
public_key: import("zod").ZodBase64;
|
|
}, import("zod/v4/core").$strip>;
|
|
};
|
|
challenge_response: {
|
|
request: ZodObject<{
|
|
challenge: import("zod").ZodBase64;
|
|
}, import("zod/v4/core").$strip>;
|
|
response: ZodObject<{
|
|
app_data: ZodObject<import("zod/v4/core").$ZodLooseShape, import("zod/v4/core").$strip>;
|
|
}, import("zod/v4/core").$strip>;
|
|
};
|
|
}>>;
|
|
constructor({ frontendUrl, identifier, privateKey, publicKey, redirectUrl, appData, httpServer, htmlSuccessPage, }: {
|
|
frontendUrl: string;
|
|
identifier: string;
|
|
privateKey: string;
|
|
publicKey: string;
|
|
redirectUrl: string;
|
|
appData: ZodObject;
|
|
httpServer?: {
|
|
port: number;
|
|
hostname: string;
|
|
};
|
|
htmlSuccessPage?: string;
|
|
});
|
|
generateChallenge(userId: number): Promise<string>;
|
|
solveChallenge(userId: number, challenge: string): Promise<string>;
|
|
createTTP(userId: number, sessionId: number, omikronUrl: string): void;
|
|
generateLink(challenge?: string): string;
|
|
}
|
|
export declare function getFriendlyReadyState(stateIndex: number): keyof typeof READY_STATE;
|
|
export declare function generateKeyPair(): {
|
|
private: string;
|
|
public: string;
|
|
};
|