clientAuth.d.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. export interface ClientAuth {
  2. id?: number;
  3. username: string;
  4. clientid: string;
  5. password?: string;
  6. password_hash: string;
  7. salt: string;
  8. use_salt?: boolean;
  9. status: 'enabled' | 'disabled';
  10. device_type?: string;
  11. description?: string;
  12. is_superuser?: boolean;
  13. created_at?: Date;
  14. updated_at?: Date;
  15. last_login_at?: Date;
  16. auth_method?: 'password' | 'token' | 'certificate' | 'external';
  17. auth_expiry?: Date | null;
  18. allowed_ip_ranges?: string | null;
  19. allowed_time_ranges?: string | null;
  20. auth_policy_id?: number | null;
  21. }
  22. export interface AuthMethod {
  23. id: number;
  24. method_name: string;
  25. method_type: 'password' | 'token' | 'certificate' | 'external';
  26. config: any;
  27. is_active: boolean;
  28. created_at: Date;
  29. updated_at: Date;
  30. }
  31. export interface AuthPolicy {
  32. id: number;
  33. policy_name: string;
  34. priority: number;
  35. conditions: any;
  36. actions: any;
  37. is_active: boolean;
  38. description?: string;
  39. created_at: Date;
  40. updated_at: Date;
  41. }
  42. export interface ClientToken {
  43. id?: number;
  44. clientid: string;
  45. token_type: 'jwt' | 'temporary' | 'refresh';
  46. token_value: string;
  47. expires_at: Date;
  48. status: 'active' | 'revoked' | 'expired';
  49. created_at?: Date;
  50. updated_at?: Date;
  51. }
  52. export interface ClientCertificate {
  53. id?: number;
  54. clientid: string;
  55. certificate_pem: string;
  56. fingerprint: string;
  57. expires_at: Date;
  58. status: 'active' | 'revoked' | 'expired';
  59. created_at?: Date;
  60. updated_at?: Date;
  61. }
  62. export declare class ClientAuthModel {
  63. static generateSalt(): string;
  64. static generatePasswordHash(password: string, salt: string, useSalt?: boolean): string;
  65. static generatePasswordHashPBKDF2(password: string, salt: string): string;
  66. static verifyPassword(password: string, salt: string, hash: string, useSalt?: boolean): boolean;
  67. static verifyDynamicPassword(username: string, clientid: string, password: string): Promise<{
  68. valid: boolean;
  69. }>;
  70. static getAll(limit?: number, offset?: number): Promise<ClientAuth[]>;
  71. static getById(id: number): Promise<ClientAuth | null>;
  72. static getByUsernameAndClientid(username: string, clientid: string): Promise<ClientAuth | null>;
  73. static getByStatus(status: string): Promise<ClientAuth[]>;
  74. static getCount(): Promise<number>;
  75. static getStatusStats(): Promise<any>;
  76. static getDeviceTypeStats(): Promise<any[]>;
  77. static create(clientAuthData: Omit<ClientAuth, 'id' | 'created_at' | 'updated_at'>): Promise<ClientAuth>;
  78. static update(id: number, updateData: Partial<Omit<ClientAuth, 'id' | 'created_at'>>): Promise<ClientAuth | null>;
  79. static updatePassword(id: number, newPassword: string, useSalt?: boolean): Promise<boolean>;
  80. static delete(id: number): Promise<boolean>;
  81. static search(searchTerm: string, limit?: number, offset?: number): Promise<ClientAuth[]>;
  82. static getSearchCount(searchTerm: string): Promise<number>;
  83. static getByUsername(username: string): Promise<ClientAuth | null>;
  84. static getByClientId(clientid: string): Promise<ClientAuth | null>;
  85. static verifyClient(username: string, clientid: string, password: string): Promise<boolean>;
  86. static getAuthMethods(): Promise<AuthMethod[]>;
  87. static getAuthMethodById(id: number): Promise<AuthMethod | null>;
  88. static getAuthMethodByName(name: string): Promise<AuthMethod | null>;
  89. static createAuthMethod(authMethod: Omit<AuthMethod, 'id' | 'created_at' | 'updated_at'>): Promise<AuthMethod>;
  90. static updateAuthMethod(id: number, updateData: Partial<Omit<AuthMethod, 'id' | 'created_at'>>): Promise<AuthMethod | null>;
  91. static deleteAuthMethod(id: number): Promise<boolean>;
  92. static getAuthPolicies(): Promise<AuthPolicy[]>;
  93. static getAuthPolicyById(id: number): Promise<AuthPolicy | null>;
  94. static createAuthPolicy(authPolicy: Omit<AuthPolicy, 'id' | 'created_at' | 'updated_at'>): Promise<AuthPolicy>;
  95. static updateAuthPolicy(id: number, updateData: Partial<Omit<AuthPolicy, 'id' | 'created_at'>>): Promise<AuthPolicy | null>;
  96. static deleteAuthPolicy(id: number): Promise<boolean>;
  97. static getClientTokens(clientid: string): Promise<ClientToken[]>;
  98. static getClientTokenByValue(tokenValue: string): Promise<ClientToken | null>;
  99. static createClientToken(clientToken: Omit<ClientToken, 'id' | 'created_at' | 'updated_at'>): Promise<ClientToken>;
  100. static updateClientToken(id: number, updateData: Partial<Omit<ClientToken, 'id' | 'created_at'>>): Promise<ClientToken | null>;
  101. static deleteClientToken(id: number): Promise<boolean>;
  102. static getClientCertificates(clientid: string): Promise<ClientCertificate[]>;
  103. static getClientCertificateByFingerprint(fingerprint: string): Promise<ClientCertificate | null>;
  104. static createClientCertificate(clientCertificate: Omit<ClientCertificate, 'id' | 'created_at' | 'updated_at'>): Promise<ClientCertificate>;
  105. static updateClientCertificate(id: number, updateData: Partial<Omit<ClientCertificate, 'id' | 'created_at'>>): Promise<ClientCertificate | null>;
  106. static deleteClientCertificate(id: number): Promise<boolean>;
  107. static dynamicAuthVerify(username: string, clientid: string, authData: any, ipAddress?: string): Promise<{
  108. success: boolean;
  109. reason?: string;
  110. policy?: any;
  111. }>;
  112. private static verifyByMethod;
  113. private static applyAuthPolicy;
  114. private static isIpAllowed;
  115. private static isTimeAllowed;
  116. static findByUsernameAndClientId(username: string, clientid: string): Promise<ClientAuth | null>;
  117. static findByUsername(username: string): Promise<ClientAuth | null>;
  118. static updateLastLogin(username: string, clientid: string): Promise<void>;
  119. static logAuthEvent(clientid: string, username: string, operationType: string, result: 'success' | 'failure', reason?: string, ipAddress?: string, topic?: string, authMethod?: string, policyId?: number, executionTime?: number): Promise<void>;
  120. }
  121. //# sourceMappingURL=clientAuth.d.ts.map