-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth_api.go
More file actions
91 lines (77 loc) · 2.61 KB
/
auth_api.go
File metadata and controls
91 lines (77 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright (c) 2026 threatvec & talkdedsec. All Rights Reserved.
// This software is proprietary and confidential.
package main
import (
"context"
"encoding/json"
"time"
"vaultx/internal/auth"
)
// AnalyzePassword performs comprehensive password strength analysis.
func (a *App) AnalyzePassword(password string) (*auth.PasswordAnalysisResult, error) {
ctx, cancel := context.WithTimeout(a.ctx, 15*time.Second)
defer cancel()
result, err := auth.AnalyzePassword(ctx, password)
if err != nil {
return nil, err
}
if a.db != nil {
raw, _ := json.Marshal(result)
a.db.SaveQueryHistory("passwordanalyzer", "***", string(raw))
}
return result, nil
}
// GeneratePasswords creates N passwords with the given options.
func (a *App) GeneratePasswords(opts auth.GeneratorOptions) ([]auth.GeneratedPassword, error) {
result, err := auth.GeneratePasswords(opts)
if err != nil {
return nil, err
}
return result, nil
}
// ParseEmailHeader parses raw email headers and returns analysis.
func (a *App) ParseEmailHeader(raw string) (*auth.EmailHeaderResult, error) {
result, err := auth.ParseEmailHeader(raw)
if err != nil {
return nil, err
}
if a.db != nil {
j, _ := json.Marshal(result)
a.db.SaveQueryHistory("emailheader", "raw-header", string(j))
}
return result, nil
}
// GenerateTOTPSecret generates a new TOTP secret and QR code.
func (a *App) GenerateTOTPSecret(accountName, issuer string) (*auth.TOTPSecret, error) {
return auth.GenerateTOTPSecret(accountName, issuer)
}
// GetTOTPCode returns the current TOTP code for a given secret.
func (a *App) GetTOTPCode(secret string) (*auth.TOTPCode, error) {
return auth.GetTOTPCode(secret)
}
// ValidateTOTPCode validates a TOTP code against a secret.
func (a *App) ValidateTOTPCode(secret, code string) (bool, error) {
return auth.ValidateTOTPCode(secret, code)
}
// EncodeAll encodes input in all supported formats simultaneously.
func (a *App) EncodeAll(input string) map[string]string {
return auth.EncodeAll(input)
}
// ProcessEncoder handles encode or decode for a specific format.
func (a *App) ProcessEncoder(input, format, mode string, caesarShift int) *auth.EncoderResult {
return auth.ProcessEncoder(input, format, mode, caesarShift)
}
// MonitorPastes checks Pastebin for mentions of the target.
func (a *App) MonitorPastes(target string) (*auth.PasteMonitorResult, error) {
ctx, cancel := context.WithTimeout(a.ctx, 20*time.Second)
defer cancel()
result, err := auth.MonitorPastes(ctx, target)
if err != nil {
return nil, err
}
if a.db != nil {
raw, _ := json.Marshal(result)
a.db.SaveQueryHistory("pastemonitor", target, string(raw))
}
return result, nil
}