index.d.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. declare module "totpChecker" {
  2. export interface ToTpGeneratorOptions {
  3. digits?: number;
  4. period?: number;
  5. algorithm?: "SHA-1" | "SHA-256" | "SHA-512";
  6. label?: string;
  7. secretLength?: number;
  8. issuer: string;
  9. }
  10. export interface ToTpSecretAndUrl {
  11. url: string;
  12. secret: string;
  13. }
  14. export class TotpChecker {
  15. static ValidateTotp(_totpSecret: string, _code: string): Promise<boolean>;
  16. static EncodeBase32(input: Buffer): string;
  17. static GenerateCode(optionsOrIssuer: ToTpGeneratorOptions | string): ToTpSecretAndUrl;
  18. }
  19. }
  20. declare module "yesManAuthenticationHandler" {
  21. import { IAuthenticationHandler } from "index";
  22. export class YesManAuthenticationHandler implements IAuthenticationHandler {
  23. private useTotp;
  24. constructor(useTotp: boolean);
  25. tryLogin(username: string, password: string, totp?: string): Promise<boolean | null>;
  26. needTotp(username: string): Promise<boolean | null>;
  27. }
  28. }
  29. declare module "sqliteAuthenticationHandler" {
  30. import { IAuthenticationHandler } from "index";
  31. export interface AccountInformation {
  32. username: string;
  33. passwordEncoded: string;
  34. totpSecret: string | null;
  35. }
  36. export type GetAccountInformationFunction = ((username: string) => Promise<AccountInformation | null>);
  37. export type EncodePasswordFunction = ((password: string) => string);
  38. export class SqliteAuthenticationHandler implements IAuthenticationHandler {
  39. passwordEncoder: EncodePasswordFunction;
  40. getAccountInformation: GetAccountInformationFunction;
  41. constructor(getAccountInformationFunction: GetAccountInformationFunction, passwordEncoder: EncodePasswordFunction);
  42. needTotp(username: string): Promise<boolean | null>;
  43. tryLogin(username: string, password: string, totp?: string): Promise<boolean | null>;
  44. }
  45. }
  46. declare module "index" {
  47. export interface IAuthenticationHandler {
  48. tryLogin(username: string, password: string, totp?: string): Promise<boolean | null>;
  49. needTotp(username: string): Promise<boolean | null>;
  50. }
  51. export class AuthenticationLoader {
  52. private handlers;
  53. addAuthenticationHandler(authenticationHandler: IAuthenticationHandler): void;
  54. tryLogin(username: string, password: string, totpCode?: string): Promise<boolean>;
  55. needTotp(username: string): Promise<boolean>;
  56. }
  57. import { YesManAuthenticationHandler } from "yesManAuthenticationHandler";
  58. export { YesManAuthenticationHandler };
  59. import { TotpChecker, ToTpGeneratorOptions, ToTpSecretAndUrl } from "totpChecker";
  60. export { TotpChecker, ToTpGeneratorOptions, ToTpSecretAndUrl };
  61. import { AccountInformation, EncodePasswordFunction, GetAccountInformationFunction, SqliteAuthenticationHandler } from "sqliteAuthenticationHandler";
  62. export { AccountInformation, EncodePasswordFunction, GetAccountInformationFunction, SqliteAuthenticationHandler };
  63. }
  64. //# sourceMappingURL=index.d.ts.map