-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
75 lines (61 loc) · 2.08 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
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
declare module "verify-user" {
type ArweaveClient = import("ar-wrapper").ArweaveClient;
type TwitterClient = import('twitter-api-v2').TwitterApi;
enum Status {
Success = "Success",
Error = "Error"
}
export interface IOptions {
projectName: string
twitterMessage: string
}
export interface ITwitterConfig {
bearer_token: string;
}
// return type for storeSignature and getUser
export interface IReturn {
status: Status;
msg: string;
username?: string
}
// return type for createTwitterVerificationHash
export interface ITwitterVerificationReturn {
status: Status;
msg: string;
hash: string;
}
// return type for verifyTwitter
export interface IVerifyTwitterReturn {
status: Status;
msg: string;
data: string;
}
export interface IGenerateMessageReturn {
status: Status;
msg: string;
messageToSign?: string
}
export class VerifyUserClient {
// underlying twitter client
twitterClient: TwitterClient;
// underlying ar-wrapper client
arweaveClient: ArweaveClient
// custom options
options: IOptions
// Construct a new client given Twitter Developer API config and arweave account data
constructor(twitterConfig: ITwitterConfig, adminAddress: string, arweaveKeyfile: string, options?: IOptions)
// create a signature to use for Twitter verification
// optional usage - can generate client side as well
createTwitterVerificationHash(signature: string): ITwitterVerificationReturn
// twitter handle and signature required
// optional: name, to display
verifyTwitter(handle: string, verificationHash: string): Promise<IVerifyTwitterReturn>
// store encrypted signedMessage and name on Arweave
storeSignature(signedMessage: string, username: string): Promise<IReturn>
// get user from Arweave with signed message
getUser(signedMessage: string): Promise<IReturn>
// generate a message to sign
// optionally generated on client-side
generateMessageToSign(handle: string, messageTemplate?: string): Promise<IGenerateMessageReturn>
}
}