-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
46 lines (40 loc) · 1.59 KB
/
index.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
/**
* Splits a locked token into its components. To be performed on the server.
* @param {string} lockedToken - The locked token.
* @returns {object} An object containing the JWT, timestamped JWT, timestamp, signature, and public key.
*/
declare function splitLockedToken(lockedToken: string): {
jwt: string;
timestampedJwt: string;
timestamp: number;
signature: string;
publicKey: string;
};
/**
* Clears the IndexedDB database.
* @returns {Promise<void>} A promise that resolves when the database has been cleared.
*/
declare function clearIdb(): void;
/**
Generates an ECDSA key pair and stores the private key in IndexedDB.
@returns {Promise<string>} A promise that resolves with the base64-encoded public key.
*/
declare function generateKeyPair(): Promise<string>;
/**
Locks a JWT with a timestamp and ECDSA signature. To be run on the client / browser.
@param {string} token - The JWT to lock.
@returns {Promise<string>} A promise that resolves with the locked token.
*/
declare function lockToken(jwt: string): Promise<string>;
/**
Verifies a locked token's timestamp and signature. To be run on the server.
@param {string} lockedToken - The locked token to verify.
@param {number} [validityInterval=2000] - The interval for token validity.
@param {string} [externalPublicKey] - Optional external public key.
@returns {Promise<string>} A promise that resolves with a validation message: 'valid' | 'Invalid signature' | 'Token expired'
*/
declare function verifyLockedToken(
lockedToken: string,
validityInterval?: number,
externalPublicKey?: string
): { validationMessage: string };