/
challenge.ts
51 lines (39 loc) · 1.49 KB
/
challenge.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
import type { Name } from "@ndn/packet";
import type { ParameterKV } from "../packet/mod";
/** Client side of a challenge. */
export interface ClientChallenge {
/** Challenge module identifier. */
readonly challengeId: string;
/**
* Create a message to select and start the challenge.
* @returns Parameter key-value pairs to send to server in initial CHALLENGE request.
*/
start: (context: ClientChallengeStartContext) => Promise<ParameterKV>;
/**
* Create a message to continue the challenge.
* @returns Parameter key-value pairs to send to server in continuing CHALLENGE request.
*/
next: (context: ClientChallengeContext) => Promise<ParameterKV>;
}
/** Contextual information for challenge selection. */
export interface ClientChallengeStartContext {
/** Request session ID. */
requestId: Uint8Array;
/** Certificate name of the self-signed certificate. */
certRequestName: Name;
}
/** Contextual information for challenge continuation. */
export interface ClientChallengeContext {
/** Request session ID. */
requestId: Uint8Array;
/** Certificate name of the self-signed certificate. */
certRequestName: Name;
/** Challenge specific status string. */
challengeStatus: string;
/** Number of remaining tries to complete challenge. */
remainingTries: number;
/** Remaining time to complete challenge, in milliseconds. */
remainingTime: number;
/** Challenge parameter key-value pairs, from CHALLENGE response packet. */
parameters: ParameterKV;
}