-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathauth-interface.ts
More file actions
216 lines (197 loc) · 5.41 KB
/
Copy pathauth-interface.ts
File metadata and controls
216 lines (197 loc) · 5.41 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import {
DCConnectInfo,
NFTBindStatus,
User,
Account,
AccountInfo,
SignReqMessage,
SignResponseMessage,
EIP712SignReqMessage,
} from "../common/types/types";
/**
* 认证操作接口
* 处理用户身份验证、账户管理和访问控制
*/
export interface IAuthOperations {
/**
* 获取当前登录用户信息
* @returns 当前登录用户信息
*/
getLoginInfo(): Promise<[Account | null, Error | null]>;
/**
* 账户登录通过钱包
* 主题色可通过初始化 DC 时的 appInfo.themeColor 传递给钱包。
* @returns 是否登录成功
*/
accountLoginWithWallet(): Promise<[Account | null, Error | null]>;
/**
* 账户登录
* @param nftAccount NFT账户
* @param password 密码
* @param safecode 安全码,默认000000
* @returns 是否登录成功
*/
accountLogin(
nftAccount: string,
password: string,
safecode: string,
): Promise<[string, Error | null]>;
/**
* 签名数据
* @param payload 要签名的数据
* @returns 签名结果
*/
sign(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
/**
* 解密数据
* @param payload 要解密的数据
* @returns 解密结果
*/
decrypt(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
/**
* 将公钥绑定NFT账号
* @param account NFT账号
* @param password 密码
* @param seccode 安全码
* @param mnemonic 助记词,将安全存储在DC云端
* @returns [状态码, 错误信息]
*/
bindNFTAccount(
account: string,
password: string,
seccode: string,
mnemonic: string,
): Promise<[NFTBindStatus | null, Error | null]>;
/**
* NFT账号密码修改
* @param account NFT账号
* @param password 密码
* @param seccode 安全码
* @param mnemonic 助记词 (可选,如果是主账号登录则需要)
*/
nftAccountPasswordModify(
account: string,
password: string,
seccode: string,
mnemonic?: string,
): Promise<[boolean | null, Error | null]>;
/**
* 创建APP访问账号,返回APP专用私钥
* @param appId 应用ID
* @param mnemonic 助记词
* @returns [私钥字符串, 错误]
*/
generateAppAccount(
appId: string,
mnemonic: string,
): Promise<[string | null, Error | null]>;
/**
* 检查NFT账号是否成功绑定到当前用户的公钥
* @param nftAccount NFT账号
* @param pubKeyStr 公钥字符串
* @returns 是否成功绑定
*/
isNftAccountBindSuccess(
nftAccount: string,
pubKeyStr: string,
): Promise<[boolean | null, Error | null]>;
/**
* 检查NFT账号是否已经被公钥绑定
* @param nftAccount NFT账号
* @returns 是否被其他账号绑定
*/
isNftAccountBinded(
nftAccount: string,
): Promise<[boolean | null, Error | null]>;
/**
* 获取用户信息
* @param nftAccount NFT账户
* @returns 用户信息
*/
getUserInfoWithNft(nftAccount: string): Promise<[User | null, Error | null]>;
/**
* 获取用户钱包信息
* @param pubkeyAccount 账户名
* @returns 用户信息
*/
getUserInfoWithAccount(
pubkeyAccount: string,
): Promise<[User | null, Error | null]>;
getToken(publicKeyBase32: string): Promise<[boolean, Error | null]>;
/**
* 开启定时验证token线程
*/
startDcPeerTokenKeepValidTask(): Promise<[boolean, Error | null]>;
/**
* 检查用户空间是否足够
* @param needSize 需要的空间大小
* @returns 空间信息
*/
ifEnoughUserSpace(needSize?: number): Promise<[boolean | null, Error | null]>;
/**
* 刷新用户信息
* @returns 用户信息
*/
refreshUserInfo(): Promise<[User | null, Error | null]>;
/**
* 获取用户默认数据库
* @param threadId 数据库ID
* @param rk 读取密钥,主要用来加解密真正的数据,注意对数据记录进行加密和解密
* @param sk 服务密钥,主要用来处理传输过程加解密,主要对数据链表头进行加密和解密
* @param remark 备注信息
* @returns 用户默认数据库信息
*/
setUserDefaultDB(
threadId: string,
rk: string,
sk: string,
remark: string,
vaccount?: string,
): Promise<Error | null>;
/**
* 跳转到钱包进行签名
* @param data 签名数据
SignReqMessage: {
type: string,
origin: string,
data<SignReqMessageData>:{
appUrl: string,
ethAccount: string,
messageType?: string, // 'string',//string,hex,base64,eip712
message: string,
}
}
*/
signMessageWithWallet(
data: SignReqMessage,
): Promise<[SignResponseMessage | null, Error | null]>;
/**
* 跳转到钱包进行EIP712签名
* @param data 签名数据
EIP712SignReqMessage: {
type: string,
origin: string,
data<EIP712SignReqMessageData>:{
appUrl: string,
ethAccount: string,
domain: any,
types: any,
primaryType: string,
message: any,
}
}
*/
signEIP712MessageWithWallet(
data: EIP712SignReqMessage,
): Promise<[SignResponseMessage | null, Error | null]>;
/**
* 续订存储套餐
* 打开钱包页面进行存储套餐购买,购买完成后返回结果
* @returns [是否成功, 错误信息]
*/
renewStoragePlan(): Promise<[boolean, Error | null]>;
/**
* 退出登录
*/
exitLogin(): void;
}