-
Notifications
You must be signed in to change notification settings - Fork 867
/
Copy pathotp.d.ts
85 lines (78 loc) · 1.73 KB
/
otp.d.ts
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
declare enum OTPType {
totp = "totp",
hotp = "hotp",
battle = "battle",
steam = "steam",
hex = "hex",
hhex = "hhex",
}
interface OTPEntryInterface {
type: OTPType;
index: number;
issuer: string;
secret: string | null;
account: string;
hash: string;
counter: number;
code: string;
period: number;
digits: number;
algorithm: number; // OTPAlgorithm
pinned: boolean;
encData?: string;
encryption?: EncryptionInterface;
create(): Promise<void>;
update(): Promise<void>;
next(): Promise<void>;
applyEncryption(encryption: EncryptionInterface): void;
changeEncryption(encryption: EncryptionInterface): void;
delete(): Promise<void>;
generate(): void;
genUUID(): void;
}
interface EncryptionInterface {
getEncryptedString(data: string): string;
decryptSecretString(entry: string): string | null;
decryptEncSecret(entry: OTPEntryInterface): RawOTPStorage | null;
getEncryptionStatus(): boolean;
updateEncryptionPassword(password: string): void;
getEncryptionKeyId(): string;
setEncryptionKeyId(id: string): void;
}
interface RawOTPStorage {
dataType?: "OTPStorage";
account?: string;
encrypted: boolean;
keyId?: string;
hash: string;
index: number;
issuer?: string;
secret: string;
type: OTPType;
counter?: number;
period?: number;
digits?: number;
algorithm?: string;
pinned?: boolean;
}
interface EncOTPStorage {
dataType: "EncOTPStorage";
keyId: string;
data: string;
index: number;
}
type OTPStorage = RawOTPStorage | EncOTPStorage;
interface OldKey {
enc: string;
hash: string;
}
interface Key {
dataType: "Key";
// UUID
id: string;
// Salt used to generate encryption key
salt: string;
// Hash of the encryption key
hash: string;
version: 3;
}