myde-remote-connect 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -195
- package/dist/loopback_adapter.js +80 -90
- package/dist/loopback_adapter.js.map +1 -1
- package/dist/peerjs_adapter.js +115 -138
- package/dist/peerjs_adapter.js.map +1 -1
- package/dist/sconnect.d.ts +32 -30
- package/dist/sconnect.js +620 -13310
- package/dist/sconnect.js.map +1 -1
- package/dist/sconnect_type.d.ts +165 -169
- package/package.json +4 -12
- package/sconnect_type.d.ts +165 -169
- package/dist/noise_utils.d.ts +0 -41
- package/dist/spake/index.d.ts +0 -114
- package/dist/spake/utils.d.ts +0 -36
package/sconnect_type.d.ts
CHANGED
|
@@ -19,92 +19,85 @@
|
|
|
19
19
|
* - PIN 码:6位数字,用户手动传递,用于初次配对时的 PAKE 握手验证。
|
|
20
20
|
*/
|
|
21
21
|
export declare class SecureChannel {
|
|
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
|
-
* 完成后会触发 `credentialRotated` 事件,应用层应保存新凭证。
|
|
104
|
-
*
|
|
105
|
-
* 仅在通道处于 `ready` 状态时可调用。
|
|
106
|
-
*/
|
|
107
|
-
rotateCredential(): Promise<void>;
|
|
22
|
+
constructor(signalAdapter: SignalingAdapter, options?: ChannelOptions);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 初始化通道,设置本设备身份。
|
|
26
|
+
* 必须在 tryConnect 或 pairInit 之前调用。
|
|
27
|
+
*
|
|
28
|
+
* @param myDeviceId 本设备 UUID
|
|
29
|
+
* @param remoteId 可选的远程设备 UUID
|
|
30
|
+
*/
|
|
31
|
+
init(myDeviceId: string, remoteId?: string): Promise<void>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 主动断开连接并清理会话密钥。
|
|
35
|
+
* 通道实例随后可丢弃,不会影响已保存的凭证。
|
|
36
|
+
*/
|
|
37
|
+
disconnect(): void;
|
|
38
|
+
|
|
39
|
+
// ================= 连接 =================
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 尝试使用已保存的凭证建立安全连接。
|
|
43
|
+
*
|
|
44
|
+
* 应用层应从本地安全存储中读取此前保存的 `Credential`,调用此方法。
|
|
45
|
+
* 内部将使用该凭证与对方执行基于长期密钥的握手(如 Noise IK)。
|
|
46
|
+
*
|
|
47
|
+
* @returns 若成功,返回 `{ success: true, credential }`,其中 credential 可能更新了 lastConnected;
|
|
48
|
+
* 若失败(凭证失效、对方无记录等),返回 `{ success: false }`,需重新走配对流程。
|
|
49
|
+
*/
|
|
50
|
+
tryConnect(credential?: CredentialPrivateInfo): Promise<ConnectResult>;
|
|
51
|
+
|
|
52
|
+
// ================= 初次配对(需用户传递 PIN) =================
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 预生成 PIN,可在 pairInit 之前调用以提前展示给用户。
|
|
56
|
+
* 重复调用会重新生成 PIN。
|
|
57
|
+
* @returns 6 位数字 PIN
|
|
58
|
+
*/
|
|
59
|
+
updatePIN(): string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 在需要身份验证的信道中进行配对,通过 PIN,完成基于 PAKE 的握手,只需要一方输入 PIN。
|
|
63
|
+
*/
|
|
64
|
+
pairInit(credential: CredentialPublicInfo): Promise<{
|
|
65
|
+
/** 展示给用户的 6 位数字 PIN,需要用户输入到另一端 */
|
|
66
|
+
pin: string;
|
|
67
|
+
/** 用户输入对方的 PIN */
|
|
68
|
+
inputOtherPin: (pin: string) => void;
|
|
69
|
+
/** 等待配对完成 */
|
|
70
|
+
waitForPairing: () => Promise<Credential>;
|
|
71
|
+
}>;
|
|
72
|
+
|
|
73
|
+
// ================= 数据收发(安全通道建立后) =================
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 发送加密数据(任意可序列化对象)。
|
|
77
|
+
* @throws {ChannelNotReadyError} 若安全通道尚未就绪(未调用成功配对/重连)
|
|
78
|
+
*/
|
|
79
|
+
send(payload: string): Promise<void>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 发送二进制数据(高效)。
|
|
83
|
+
* @throws {ChannelNotReadyError}
|
|
84
|
+
*/
|
|
85
|
+
sendBinary(data: ArrayBuffer | Uint8Array): Promise<void>;
|
|
86
|
+
|
|
87
|
+
// ================= 事件订阅 =================
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 监听通道事件。
|
|
91
|
+
* @param event 事件名
|
|
92
|
+
* @param callback 回调函数
|
|
93
|
+
*/
|
|
94
|
+
on<K extends keyof SecureChannelEvents>(
|
|
95
|
+
event: K,
|
|
96
|
+
callback: SecureChannelEvents[K],
|
|
97
|
+
): void;
|
|
98
|
+
|
|
99
|
+
/** 移除事件监听 */
|
|
100
|
+
off(event: string, callback: Function): void;
|
|
108
101
|
}
|
|
109
102
|
|
|
110
103
|
// ================= 相关类型定义 =================
|
|
@@ -121,94 +114,94 @@ type SignalingAdapter = TrustedSignalingAdapter | UntrustedSignalingAdapter;
|
|
|
121
114
|
|
|
122
115
|
/** 受信任的信令适配器(物理信道等),外部已验证身份,不加密 */
|
|
123
116
|
interface TrustedSignalingAdapter {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
117
|
+
trustIdentity: true;
|
|
118
|
+
/** 受信任信道不使用加密,固定为 false */
|
|
119
|
+
supportNativeEncryption: false;
|
|
120
|
+
init(myId: string): Promise<void>;
|
|
121
|
+
connect(id: string): Promise<void>;
|
|
122
|
+
send(data: Uint8Array): Promise<void>;
|
|
123
|
+
close(): void;
|
|
124
|
+
onMessage: (handler: (data: Uint8Array) => void) => void;
|
|
125
|
+
onClose: (handler: () => void) => void;
|
|
126
|
+
onError: (handler: (err: Error) => void) => void;
|
|
134
127
|
}
|
|
135
128
|
|
|
136
129
|
/** 不受信任的信令适配器(网络信道等),需要内部 PAKE 验证,可选加密 */
|
|
137
130
|
interface UntrustedSignalingAdapter {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
131
|
+
trustIdentity: false;
|
|
132
|
+
/** PAKE 验证后是否启用应用层加密(如 Noise) */
|
|
133
|
+
supportNativeEncryption: boolean;
|
|
134
|
+
init(myId: string): Promise<void>;
|
|
135
|
+
connect(id: string): Promise<void>;
|
|
136
|
+
send(data: Uint8Array): Promise<void>;
|
|
137
|
+
close(): void;
|
|
138
|
+
onMessage: (handler: (data: Uint8Array) => void) => void;
|
|
139
|
+
onClose: (handler: () => void) => void;
|
|
140
|
+
onError: (handler: (err: Error) => void) => void;
|
|
148
141
|
}
|
|
149
142
|
|
|
150
143
|
/** 配对请求信息(接收方通过 pairRequest 事件获取) */
|
|
151
144
|
interface PairRequest {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
145
|
+
/** 发起方的设备 ID */
|
|
146
|
+
remoteDeviceId: string;
|
|
147
|
+
/** 发起方的显示名称(可选) */
|
|
148
|
+
remoteDisplayName?: string;
|
|
149
|
+
/** 输入对方的 PIN(触发 PAKE 交换) */
|
|
150
|
+
inputOtherPin: (pin: string) => void;
|
|
151
|
+
/** 等待配对完成 */
|
|
152
|
+
waitForPairing: () => Promise<Credential>;
|
|
153
|
+
/** 拒绝配对请求 */
|
|
154
|
+
reject: () => void;
|
|
162
155
|
}
|
|
163
156
|
|
|
164
157
|
/** 连接请求信息(接收方通过 connectRequest 事件获取,用于 Credential 重连) */
|
|
165
158
|
interface ConnectRequest {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
159
|
+
/** 发起方的设备 ID */
|
|
160
|
+
remoteDeviceId: string;
|
|
161
|
+
/** 发起方的显示名称(可选) */
|
|
162
|
+
remoteDisplayName?: string;
|
|
163
|
+
/** 接受连接请求,传入本地保存的关于对方的 Credential */
|
|
164
|
+
accept: (credential: Credential) => Promise<ConnectResult>;
|
|
165
|
+
/** 拒绝连接请求 */
|
|
166
|
+
reject: () => void;
|
|
174
167
|
}
|
|
175
168
|
|
|
176
169
|
/** 通道配置选项 */
|
|
177
170
|
interface ChannelOptions {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
171
|
+
/** 连接请求超时时间(毫秒),默认 30000 */
|
|
172
|
+
connectTimeout?: number;
|
|
173
|
+
/** 配对超时时间(毫秒),默认 60000(PIN 输入需要更多时间) */
|
|
174
|
+
pairingTimeout?: number;
|
|
175
|
+
/** 握手超时时间(毫秒),默认 30000 */
|
|
176
|
+
handshakeTimeout?: number;
|
|
177
|
+
/** 允许的最大 PIN 错误尝试次数,默认 5,超出后自动断开并触发 error 事件 */
|
|
178
|
+
maxPinAttempts?: number;
|
|
179
|
+
/** 配对请求间隔限制(毫秒),默认 1000 */
|
|
180
|
+
pairInterval?: number;
|
|
181
|
+
/** 连接请求间隔限制(毫秒),默认 20 */
|
|
182
|
+
connectInterval?: number;
|
|
190
183
|
}
|
|
191
184
|
|
|
192
185
|
interface CredentialPublicInfo {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
186
|
+
/** 我方设备 UUID */
|
|
187
|
+
myDeviceId: string;
|
|
188
|
+
/** 我方可读名称(可选) */
|
|
189
|
+
myDisplayName?: string;
|
|
190
|
+
/** 对方设备 UUID */
|
|
191
|
+
remoteDeviceId: string;
|
|
192
|
+
/** 对方可读名称(可选) */
|
|
193
|
+
remoteDisplayName?: string;
|
|
201
194
|
}
|
|
202
195
|
|
|
203
196
|
interface CredentialPrivateInfo {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
197
|
+
/** 我方长期私钥(格式取决于底层实现,可能为 CryptoKey 或 Uint8Array) */
|
|
198
|
+
myPrivateKey: Uint8Array; // todo 使用 Web Crypto API
|
|
199
|
+
/** 我方长期公钥(用于对方验证我方身份) */
|
|
200
|
+
myPublicKey: Uint8Array;
|
|
201
|
+
/** 对方长期公钥(用于验证对方身份) */
|
|
202
|
+
remotePublicKey: Uint8Array;
|
|
203
|
+
/** 凭证创建时间戳(毫秒) */
|
|
204
|
+
createdAt: number;
|
|
212
205
|
}
|
|
213
206
|
|
|
214
207
|
/**
|
|
@@ -217,37 +210,35 @@ interface CredentialPrivateInfo {
|
|
|
217
210
|
* 私钥部分(myPrivateKey)绝不应离开本地设备。
|
|
218
211
|
*/
|
|
219
212
|
interface Credential extends CredentialPublicInfo, CredentialPrivateInfo {
|
|
220
|
-
|
|
221
|
-
|
|
213
|
+
/** 上次成功连接时间戳(毫秒),用于 UI 排序 */
|
|
214
|
+
lastConnected?: number;
|
|
222
215
|
}
|
|
223
216
|
|
|
224
217
|
/** `tryConnect` 返回的结果类型 */
|
|
225
218
|
interface ConnectSuccess {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
219
|
+
success: true;
|
|
220
|
+
/** 重连成功,可能更新了 lastConnected 等字段的凭证 */
|
|
221
|
+
credential: Credential;
|
|
229
222
|
}
|
|
230
223
|
|
|
231
224
|
interface ConnectFailed {
|
|
232
|
-
|
|
225
|
+
success: false;
|
|
233
226
|
}
|
|
234
227
|
|
|
235
228
|
interface ConnectNeedsPairing {
|
|
236
|
-
|
|
237
|
-
|
|
229
|
+
success: false;
|
|
230
|
+
reason: "NEEDS_PAIRING";
|
|
238
231
|
}
|
|
239
232
|
|
|
240
233
|
type ConnectResult = ConnectSuccess | ConnectFailed | ConnectNeedsPairing;
|
|
241
234
|
|
|
242
235
|
export type SecureChannelEvents = {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
credentialRotated: (updatedCredential: Credential) => void;
|
|
250
|
-
credentialInvalidated: (remoteDeviceId: string) => void;
|
|
236
|
+
ready: () => void;
|
|
237
|
+
data: (data: ArrayBuffer, text: () => string) => void;
|
|
238
|
+
disconnect: () => void;
|
|
239
|
+
error: (err: SConnectError) => void;
|
|
240
|
+
pairRequest: (request: PairRequest) => void;
|
|
241
|
+
connectRequest: (request: ConnectRequest) => void;
|
|
251
242
|
};
|
|
252
243
|
|
|
253
244
|
// ================= 状态类型 =================
|
|
@@ -256,4 +247,9 @@ export type SecureChannelEvents = {
|
|
|
256
247
|
type ChannelState = "Idle" | "Ready" | "Handshaking" | "Connected";
|
|
257
248
|
|
|
258
249
|
/** 握手类型 */
|
|
259
|
-
type HandshakeType =
|
|
250
|
+
type HandshakeType =
|
|
251
|
+
| "pake"
|
|
252
|
+
| "ik"
|
|
253
|
+
| "connect-request"
|
|
254
|
+
| "connect-response"
|
|
255
|
+
| null;
|
package/dist/noise_utils.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Noise 握手库封装
|
|
3
|
-
* 提供 Uint8Array 接口,内部使用 b4a 进行 Buffer 转换
|
|
4
|
-
*/
|
|
5
|
-
interface KeyPair {
|
|
6
|
-
publicKey: Uint8Array;
|
|
7
|
-
privateKey: Uint8Array;
|
|
8
|
-
}
|
|
9
|
-
export interface NoiseState {
|
|
10
|
-
complete: boolean;
|
|
11
|
-
tx: Uint8Array;
|
|
12
|
-
rx: Uint8Array;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* 创建 Noise 握手状态
|
|
16
|
-
*/
|
|
17
|
-
export declare function createNoise(pattern: string, initiator: boolean, staticKeypair?: KeyPair): NoiseState;
|
|
18
|
-
/**
|
|
19
|
-
* 初始化握手状态
|
|
20
|
-
*/
|
|
21
|
-
export declare function initialiseNoise(state: NoiseState, prologue: Uint8Array, remoteStatic?: Uint8Array): void;
|
|
22
|
-
/**
|
|
23
|
-
* 发送握手消息
|
|
24
|
-
*/
|
|
25
|
-
export declare function sendNoise(state: NoiseState): Uint8Array;
|
|
26
|
-
/**
|
|
27
|
-
* 接收握手消息
|
|
28
|
-
*/
|
|
29
|
-
export declare function recvNoise(state: NoiseState, message: Uint8Array): void;
|
|
30
|
-
/**
|
|
31
|
-
* 销毁握手状态
|
|
32
|
-
*/
|
|
33
|
-
export declare function destroyNoise(state: NoiseState): void;
|
|
34
|
-
/**
|
|
35
|
-
* 创建加密器
|
|
36
|
-
*/
|
|
37
|
-
export declare function createCipher(key: Uint8Array): {
|
|
38
|
-
encrypt: (data: Uint8Array) => Uint8Array;
|
|
39
|
-
decrypt: (data: Uint8Array) => Uint8Array;
|
|
40
|
-
};
|
|
41
|
-
export {};
|
package/dist/spake/index.d.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ESM 版本的 SPAKE2 实现
|
|
3
|
-
* 基于原始 spake2 模块重写,使用 Web Crypto API 和 Uint8Array
|
|
4
|
-
*/
|
|
5
|
-
import BN from "bn.js";
|
|
6
|
-
declare const curveEd25519: {
|
|
7
|
-
name: string;
|
|
8
|
-
M: string;
|
|
9
|
-
N: string;
|
|
10
|
-
p: BN;
|
|
11
|
-
h: BN;
|
|
12
|
-
};
|
|
13
|
-
declare class EllipticCurve {
|
|
14
|
-
private ec;
|
|
15
|
-
private name;
|
|
16
|
-
M: any;
|
|
17
|
-
N: any;
|
|
18
|
-
P: any;
|
|
19
|
-
p: BN;
|
|
20
|
-
h: BN;
|
|
21
|
-
constructor(curve: typeof curveEd25519);
|
|
22
|
-
decodePoint(buf: string | Uint8Array): any;
|
|
23
|
-
encodePoint(p: any): Uint8Array;
|
|
24
|
-
}
|
|
25
|
-
interface CipherSuite {
|
|
26
|
-
curve: EllipticCurve;
|
|
27
|
-
hash: (content: Uint8Array) => Promise<Uint8Array>;
|
|
28
|
-
kdf: (salt: Uint8Array, ikm: Uint8Array, info: string) => Promise<Uint8Array>;
|
|
29
|
-
mac: (content: Uint8Array, secret: Uint8Array) => Promise<Uint8Array>;
|
|
30
|
-
mhf: (passphrase: Uint8Array, salt: Uint8Array, options: {
|
|
31
|
-
n: number;
|
|
32
|
-
r: number;
|
|
33
|
-
p: number;
|
|
34
|
-
}) => Promise<Uint8Array>;
|
|
35
|
-
}
|
|
36
|
-
interface SPAKE2Options {
|
|
37
|
-
suite?: string;
|
|
38
|
-
plus?: boolean;
|
|
39
|
-
mhf?: {
|
|
40
|
-
n: number;
|
|
41
|
-
r: number;
|
|
42
|
-
p: number;
|
|
43
|
-
};
|
|
44
|
-
kdf?: {
|
|
45
|
-
AAD: string;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
declare class SharedSecret {
|
|
49
|
-
protected Ke: Uint8Array;
|
|
50
|
-
protected Ka: Uint8Array;
|
|
51
|
-
protected KcA: Uint8Array;
|
|
52
|
-
protected KcB: Uint8Array;
|
|
53
|
-
protected options: SPAKE2Options;
|
|
54
|
-
protected cipherSuite: CipherSuite;
|
|
55
|
-
protected transcript: Uint8Array;
|
|
56
|
-
constructor({ options, transcript, cipherSuite, }: {
|
|
57
|
-
options: SPAKE2Options;
|
|
58
|
-
transcript: Uint8Array;
|
|
59
|
-
cipherSuite: CipherSuite;
|
|
60
|
-
});
|
|
61
|
-
init(): Promise<void>;
|
|
62
|
-
getConfirmation(): Promise<Uint8Array>;
|
|
63
|
-
verify(incomingConfirmation: Uint8Array): Promise<void>;
|
|
64
|
-
toBuffer(): Uint8Array;
|
|
65
|
-
}
|
|
66
|
-
declare class ClientState {
|
|
67
|
-
private options;
|
|
68
|
-
private cipherSuite;
|
|
69
|
-
private clientIdentity;
|
|
70
|
-
private serverIdentity;
|
|
71
|
-
private x;
|
|
72
|
-
private w;
|
|
73
|
-
private T;
|
|
74
|
-
constructor({ clientIdentity, serverIdentity, w, x, options, cipherSuite, }: {
|
|
75
|
-
clientIdentity: string;
|
|
76
|
-
serverIdentity: string;
|
|
77
|
-
w: BN;
|
|
78
|
-
x: BN;
|
|
79
|
-
options: SPAKE2Options;
|
|
80
|
-
cipherSuite: CipherSuite;
|
|
81
|
-
});
|
|
82
|
-
getMessage(): Uint8Array;
|
|
83
|
-
finish(incomingMessage: Uint8Array): Promise<SharedSecret>;
|
|
84
|
-
}
|
|
85
|
-
declare class ServerState {
|
|
86
|
-
private options;
|
|
87
|
-
private cipherSuite;
|
|
88
|
-
private clientIdentity;
|
|
89
|
-
private serverIdentity;
|
|
90
|
-
private y;
|
|
91
|
-
private w;
|
|
92
|
-
private S;
|
|
93
|
-
constructor({ clientIdentity, serverIdentity, w, y, options, cipherSuite, }: {
|
|
94
|
-
clientIdentity: string;
|
|
95
|
-
serverIdentity: string;
|
|
96
|
-
w: BN;
|
|
97
|
-
y: BN;
|
|
98
|
-
options: SPAKE2Options;
|
|
99
|
-
cipherSuite: CipherSuite;
|
|
100
|
-
});
|
|
101
|
-
getMessage(): Uint8Array;
|
|
102
|
-
finish(incomingMessage: Uint8Array): Promise<SharedSecret>;
|
|
103
|
-
}
|
|
104
|
-
export declare class SPAKE2 {
|
|
105
|
-
private options;
|
|
106
|
-
private cipherSuite;
|
|
107
|
-
constructor(options?: SPAKE2Options);
|
|
108
|
-
startClient(clientIdentity: string, serverIdentity: string, password: string, salt: string): Promise<ClientState>;
|
|
109
|
-
startServer(clientIdentity: string, serverIdentity: string, verifier: Uint8Array): Promise<ServerState>;
|
|
110
|
-
computeVerifier(password: string, salt: string, clientIdentity: string, serverIdentity: string): Promise<Uint8Array>;
|
|
111
|
-
private _computeW;
|
|
112
|
-
}
|
|
113
|
-
export declare function spake2(options?: SPAKE2Options): SPAKE2;
|
|
114
|
-
export {};
|
package/dist/spake/utils.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Uint8Array 工具函数
|
|
3
|
-
* 替代 Node.js Buffer 的常用功能
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* 将 Uint8Array 转换为十六进制字符串
|
|
7
|
-
*/
|
|
8
|
-
export declare function uint8ArrayToHex(arr: Uint8Array): string;
|
|
9
|
-
/**
|
|
10
|
-
* 将十六进制字符串转换为 Uint8Array
|
|
11
|
-
*/
|
|
12
|
-
export declare function hexToUint8Array(hex: string): Uint8Array;
|
|
13
|
-
/**
|
|
14
|
-
* 将字符串转换为 Uint8Array
|
|
15
|
-
*/
|
|
16
|
-
export declare function stringToUint8Array(str: string): Uint8Array;
|
|
17
|
-
/**
|
|
18
|
-
* 将 Uint8Array 转换为字符串
|
|
19
|
-
*/
|
|
20
|
-
export declare function uint8ArrayToString(arr: Uint8Array): string;
|
|
21
|
-
/**
|
|
22
|
-
* 比较两个 Uint8Array 是否相等
|
|
23
|
-
*/
|
|
24
|
-
export declare function uint8ArrayEquals(a: Uint8Array, b: Uint8Array): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* 连接多个 Uint8Array
|
|
27
|
-
*/
|
|
28
|
-
export declare function concatUint8Array(...arrays: Uint8Array[]): Uint8Array;
|
|
29
|
-
/**
|
|
30
|
-
* 创建空的 Uint8Array
|
|
31
|
-
*/
|
|
32
|
-
export declare function emptyUint8Array(): Uint8Array;
|
|
33
|
-
/**
|
|
34
|
-
* 复制 Uint8Array
|
|
35
|
-
*/
|
|
36
|
-
export declare function copyUint8Array(arr: Uint8Array): Uint8Array;
|