@anycon/protocol 0.5.0 → 0.5.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/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/crypto.d.ts +20 -0
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +32 -0
- package/dist/crypto.js.map +1 -1
- package/dist/envelope.d.ts.map +1 -1
- package/dist/envelope.js +6 -1
- package/dist/envelope.js.map +1 -1
- package/dist/generated.d.ts +42 -2
- package/dist/generated.d.ts.map +1 -1
- package/dist/method-types.d.ts +4 -0
- package/dist/method-types.d.ts.map +1 -1
- package/dist/rpc.d.ts +3 -1
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +7 -3
- package/dist/rpc.js.map +1 -1
- package/package.json +2 -2
- package/src/constants.ts +1 -0
- package/src/crypto.ts +49 -0
- package/src/envelope.ts +5 -1
- package/src/generated.ts +63 -18
- package/src/method-types.ts +1 -0
- package/src/rpc.ts +12 -5
- package/wasm/THIRD-PARTY-LICENSES.txt +245 -18
- package/wasm/anycon_crypto.d.ts +10 -0
- package/wasm/anycon_crypto.js +51 -0
- package/wasm/anycon_crypto_bg.wasm +0 -0
- package/wasm/anycon_crypto_bg.wasm.d.ts +2 -0
package/src/crypto.ts
CHANGED
|
@@ -10,9 +10,35 @@
|
|
|
10
10
|
* 角色:配对(XXpsk3)joiner 是 initiator、host(daemon)是 responder;重连(IK)客户端是 initiator。
|
|
11
11
|
*/
|
|
12
12
|
import { PAIR_CODE_ALPHABET, PAIR_CODE_LEN, PAIR_CODE_LEN_LONG } from './constants.js'
|
|
13
|
+
import type { NodeInfo } from './generated.js'
|
|
13
14
|
|
|
14
15
|
export type Role = 'initiator' | 'responder'
|
|
15
16
|
|
|
17
|
+
/** 解密并解压后的消息上限;与 Rust crypto 的 MAX_OPENED 一致,对端不可信。 */
|
|
18
|
+
export const MAX_OPENED = 16 * 1024 * 1024
|
|
19
|
+
|
|
20
|
+
/** RPC 发送阈值:未知节点使用默认设置;上传块避免同步压缩占用浏览器主线程。 */
|
|
21
|
+
export function rpcCompressMin(
|
|
22
|
+
plaintextLength: number,
|
|
23
|
+
method: string | undefined,
|
|
24
|
+
settings?: NodeInfo['transport'],
|
|
25
|
+
): number | undefined {
|
|
26
|
+
if (method === 'blob.put_chunk' || !(settings?.compression ?? true)) return undefined
|
|
27
|
+
const threshold = Math.min(1048576, Math.max(256, settings?.compress_min_bytes ?? 1024))
|
|
28
|
+
return plaintextLength >= threshold ? threshold : undefined
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** open 失败的阶段;只有解密成功后的错误会消耗接收 nonce。 */
|
|
32
|
+
export class OpenError extends Error {
|
|
33
|
+
override readonly name = 'OpenError'
|
|
34
|
+
constructor(
|
|
35
|
+
message: string,
|
|
36
|
+
readonly nonceConsumed: boolean,
|
|
37
|
+
) {
|
|
38
|
+
super(message)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
16
42
|
/** X25519 静态密钥对。纯数据,可序列化保存(`secret` 是敏感信息,0600 / IndexedDB)。 */
|
|
17
43
|
export interface Keypair {
|
|
18
44
|
readonly public: Uint8Array
|
|
@@ -33,6 +59,13 @@ export interface Transport {
|
|
|
33
59
|
encrypt(plaintext: Uint8Array): Uint8Array
|
|
34
60
|
/** 解密 `encrypt` 的输出,还原整条明文。乱序 / 篡改会抛错。 */
|
|
35
61
|
decrypt(ciphertext: Uint8Array): Uint8Array
|
|
62
|
+
/** 将内部标记和消息体一起加密;省略阈值时不压缩,达到阈值且体积变小时使用裸 DEFLATE。 */
|
|
63
|
+
seal(plaintext: Uint8Array, compressMin?: number): Uint8Array
|
|
64
|
+
/**
|
|
65
|
+
* 解密并按内部标记解压,输出不超过 MAX_OPENED 字节。
|
|
66
|
+
* 失败抛出 OpenError;nonceConsumed 表示解密是否已成功。为 true 时必须丢弃通道并重新握手。
|
|
67
|
+
*/
|
|
68
|
+
open(ciphertext: Uint8Array): Uint8Array
|
|
36
69
|
/** 对端静态公钥。 */
|
|
37
70
|
readonly remotePublic: Uint8Array
|
|
38
71
|
/** 释放 wasm 内存。之后不能再用。 */
|
|
@@ -148,6 +181,8 @@ interface RawKeypair {
|
|
|
148
181
|
interface RawTransport {
|
|
149
182
|
encrypt(plaintext: Uint8Array): Uint8Array
|
|
150
183
|
decrypt(ciphertext: Uint8Array): Uint8Array
|
|
184
|
+
seal(plaintext: Uint8Array, compressMin?: number): Uint8Array
|
|
185
|
+
open(ciphertext: Uint8Array): Uint8Array
|
|
151
186
|
readonly remotePublic: Uint8Array | (() => Uint8Array)
|
|
152
187
|
free(): void
|
|
153
188
|
}
|
|
@@ -230,6 +265,20 @@ function wrapTransport(raw: RawTransport): Transport {
|
|
|
230
265
|
return {
|
|
231
266
|
encrypt: (plaintext) => raw.encrypt(plaintext),
|
|
232
267
|
decrypt: (ciphertext) => raw.decrypt(ciphertext),
|
|
268
|
+
seal: (plaintext, compressMin) => raw.seal(plaintext, compressMin),
|
|
269
|
+
open: (ciphertext) => {
|
|
270
|
+
try {
|
|
271
|
+
return raw.open(ciphertext)
|
|
272
|
+
} catch (error) {
|
|
273
|
+
// Rust decrypt 对所有失败回滚 nonce;内部标记和解压错误发生在解密成功之后。
|
|
274
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
275
|
+
const rolledBack =
|
|
276
|
+
message === 'decrypt failed' ||
|
|
277
|
+
message === 'malformed frame' ||
|
|
278
|
+
message.startsWith('noise: ')
|
|
279
|
+
throw new OpenError(message, !rolledBack)
|
|
280
|
+
}
|
|
281
|
+
},
|
|
233
282
|
remotePublic: remote,
|
|
234
283
|
free: () => raw.free(),
|
|
235
284
|
}
|
package/src/envelope.ts
CHANGED
|
@@ -102,7 +102,7 @@ type ControlType = Control['type']
|
|
|
102
102
|
/** 每个变体的字段声明顺序(不含 `type`),对应 control.rs。 */
|
|
103
103
|
const CONTROL_FIELD_ORDER: Readonly<Record<ControlType, readonly string[]>> = {
|
|
104
104
|
auth: ['device_token', 'protocol_version', 'client', 'preview_token'],
|
|
105
|
-
auth_ok: ['device_id', 'server_time_ms', 'peers_online', 'quota'],
|
|
105
|
+
auth_ok: ['device_id', 'server_time_ms', 'peers_online', 'quota', 'ping'],
|
|
106
106
|
auth_fail: ['reason'],
|
|
107
107
|
pair_begin: ['match_id'],
|
|
108
108
|
pair_registered: ['expires_at_ms'],
|
|
@@ -129,6 +129,8 @@ const CONTROL_FIELD_ORDER: Readonly<Record<ControlType, readonly string[]>> = {
|
|
|
129
129
|
quota_update: ['quota'],
|
|
130
130
|
rotate_token: [],
|
|
131
131
|
token_rotated: ['device_token'],
|
|
132
|
+
ping: ['id'],
|
|
133
|
+
pong: ['id'],
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
/** Rust 侧 `#[serde(skip_serializing_if = "Option::is_none")]` 的字段:None 时整键省略,而不是编码为 nil。 */
|
|
@@ -192,6 +194,8 @@ function canonicalControl(ctrl: Control): Dict {
|
|
|
192
194
|
if (isDict(src.quota)) {
|
|
193
195
|
src.quota = orderKeys(src.quota, QUOTA_ORDER, undefined)
|
|
194
196
|
}
|
|
197
|
+
// Rust 侧 `ping: bool` 为 false 时整键省略(`skip_serializing_if = "Not::not"`)
|
|
198
|
+
if (ctrl.type === 'auth_ok' && src.ping === false) delete src.ping
|
|
195
199
|
return orderKeys(src, order, CONTROL_SKIP_NONE[ctrl.type], { type: ctrl.type })
|
|
196
200
|
}
|
|
197
201
|
|
package/src/generated.ts
CHANGED
|
@@ -43,6 +43,11 @@ export type Control =
|
|
|
43
43
|
* 已配对且当前在线的对端。
|
|
44
44
|
*/
|
|
45
45
|
peers_online: string[];
|
|
46
|
+
/**
|
|
47
|
+
* 这个 hub 会回应 [`Control::Ping`]。旧 hub 没有这个字段(反序列化为 false),
|
|
48
|
+
* 它会丢弃无法解码的控制消息,所以客户端只在它为 true 时才发 `ping`。
|
|
49
|
+
*/
|
|
50
|
+
ping?: boolean;
|
|
46
51
|
quota?: Quota | null;
|
|
47
52
|
server_time_ms: number;
|
|
48
53
|
type: "auth_ok";
|
|
@@ -163,6 +168,14 @@ export type Control =
|
|
|
163
168
|
| {
|
|
164
169
|
device_token: string;
|
|
165
170
|
type: "token_rotated";
|
|
171
|
+
}
|
|
172
|
+
| {
|
|
173
|
+
id: number;
|
|
174
|
+
type: "ping";
|
|
175
|
+
}
|
|
176
|
+
| {
|
|
177
|
+
id: number;
|
|
178
|
+
type: "pong";
|
|
166
179
|
};
|
|
167
180
|
export type AuthFailReason = "invalid" | "revoked" | "version" | "quota" | "protocol" | "suspended" | "unknown";
|
|
168
181
|
/**
|
|
@@ -596,23 +609,26 @@ export type Kind = "handshake" | "data" | "notify" | "control";
|
|
|
596
609
|
*/
|
|
597
610
|
export type OwnerConfirmStatus = "ready" | "unset" | "untrusted";
|
|
598
611
|
export type UpdateReason =
|
|
599
|
-
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
612
|
+
| (
|
|
613
|
+
| "remote_disabled"
|
|
614
|
+
| "no_update"
|
|
615
|
+
| "busy"
|
|
616
|
+
| "already_rolled_back"
|
|
617
|
+
| "unsupported_installation"
|
|
618
|
+
| "check_failed"
|
|
619
|
+
| "download_failed"
|
|
620
|
+
| "provenance_failed"
|
|
621
|
+
| "invalid_archive"
|
|
622
|
+
| "version_probe_failed"
|
|
623
|
+
| "install_failed"
|
|
624
|
+
| "interrupted"
|
|
625
|
+
| "startup_failed"
|
|
626
|
+
| "health_timeout"
|
|
627
|
+
| "snapshot_failed"
|
|
628
|
+
| "restore_failed"
|
|
629
|
+
| "unknown"
|
|
630
|
+
)
|
|
631
|
+
| "check_disabled";
|
|
616
632
|
export type UpdateManagedBy =
|
|
617
633
|
"installer" | "homebrew" | "cargo" | "dev" | "readonly" | "unmanaged" | "root" | "unsupported" | "unknown";
|
|
618
634
|
export type UpdatePhase =
|
|
@@ -2242,6 +2258,10 @@ export interface NodeInfo {
|
|
|
2242
2258
|
platform: string;
|
|
2243
2259
|
protocol_version: number;
|
|
2244
2260
|
started_at_ms: number;
|
|
2261
|
+
/**
|
|
2262
|
+
* 当前 RPC 压缩设置;客户端按它决定发送方式,未知时使用默认值。
|
|
2263
|
+
*/
|
|
2264
|
+
transport?: NodeTransportSettings | null;
|
|
2245
2265
|
/**
|
|
2246
2266
|
* `[twin] accept_links`:这个节点现在接受别的节点的 Twin 连接(docs/spec/daemon.md § 27.2)。旧 daemon 没有这个字段,读作 `false`。
|
|
2247
2267
|
*/
|
|
@@ -2372,6 +2392,10 @@ export interface NodeCapabilities {
|
|
|
2372
2392
|
* 支持更新状态和 `node.update`。安装方式和机器级开关见 `node.info.update`。
|
|
2373
2393
|
*/
|
|
2374
2394
|
update?: boolean;
|
|
2395
|
+
/**
|
|
2396
|
+
* 支持 `node.update_check`(立即检查新版本)。旧 daemon 没有这个字段,读作 false。
|
|
2397
|
+
*/
|
|
2398
|
+
update_check?: boolean;
|
|
2375
2399
|
/**
|
|
2376
2400
|
* 有 workspace(文件夹即项目)。SDK 节点可能没有。
|
|
2377
2401
|
*/
|
|
@@ -2381,8 +2405,29 @@ export interface NodeCapabilities {
|
|
|
2381
2405
|
*/
|
|
2382
2406
|
worktree?: boolean;
|
|
2383
2407
|
}
|
|
2408
|
+
/**
|
|
2409
|
+
* RPC 传输的发送设置;接收方始终接受压缩和未压缩消息。
|
|
2410
|
+
*/
|
|
2411
|
+
export interface NodeTransportSettings {
|
|
2412
|
+
/**
|
|
2413
|
+
* 最小明文字节数。远程编辑范围为 256–1048576,使用时也夹到此范围。
|
|
2414
|
+
*/
|
|
2415
|
+
compress_min_bytes: number;
|
|
2416
|
+
/**
|
|
2417
|
+
* 达到阈值时尝试压缩,只有消息体变小才使用裸 DEFLATE。
|
|
2418
|
+
*/
|
|
2419
|
+
compression: boolean;
|
|
2420
|
+
}
|
|
2384
2421
|
export interface NodeUpdateStatus {
|
|
2385
2422
|
auto: boolean;
|
|
2423
|
+
/**
|
|
2424
|
+
* 节点现在没在检查新版本(`update.check` 关着等)。旧 daemon 没有这个字段,读作 false。
|
|
2425
|
+
*/
|
|
2426
|
+
check_disabled?: boolean;
|
|
2427
|
+
/**
|
|
2428
|
+
* 最近一次成功检查的时间;从没成功过则省略。旧 daemon 没有这个字段。
|
|
2429
|
+
*/
|
|
2430
|
+
last_check_ms?: number | null;
|
|
2386
2431
|
last_rollback?: UpdateRollback | null;
|
|
2387
2432
|
managed_by: UpdateManagedBy;
|
|
2388
2433
|
phase: UpdatePhase;
|
|
@@ -2656,7 +2701,7 @@ export interface NodeTwinLinkCodeResult {
|
|
|
2656
2701
|
expires_ms: number;
|
|
2657
2702
|
}
|
|
2658
2703
|
/**
|
|
2659
|
-
*
|
|
2704
|
+
* 更新状态变化时发送,也是 `node.update_check` 的结果。字段缺省表示对应的 `node.info` 中也没有已知更新。
|
|
2660
2705
|
*/
|
|
2661
2706
|
export interface NodeUpdateChanged {
|
|
2662
2707
|
update: NodeUpdateStatus;
|
package/src/method-types.ts
CHANGED
|
@@ -199,6 +199,7 @@ import type {
|
|
|
199
199
|
export interface RequestMethods {
|
|
200
200
|
'node.info': { params: Empty; result: NodeInfo }
|
|
201
201
|
'node.update': { params: Empty; result: NodeUpdateStatus }
|
|
202
|
+
'node.update_check': { params: Empty; result: NodeUpdateChanged }
|
|
202
203
|
'node.devices': { params: Empty; result: NodeDevicesResult }
|
|
203
204
|
'node.revoke_device': { params: NodeRevokeDeviceParams; result: Empty }
|
|
204
205
|
'node.pair_begin': { params: NodePairBeginParams; result: NodePairBeginResult }
|
package/src/rpc.ts
CHANGED
|
@@ -201,8 +201,10 @@ export class RpcTimeoutError extends Error {
|
|
|
201
201
|
// ---------- RpcPeer ----------
|
|
202
202
|
|
|
203
203
|
export interface RpcPeerOptions {
|
|
204
|
+
/** 成功响应与请求关联后同步通知,便于传输层更新 node.info 缓存。 */
|
|
205
|
+
onResult?: (method: string, result: unknown) => void
|
|
204
206
|
/** 发出一条已编码的 JSON-RPC 消息(上层负责加密 + 装信封)。同步抛错会让对应 `request()` 拒绝。 */
|
|
205
|
-
send: (bytes: Uint8Array) => void
|
|
207
|
+
send: (bytes: Uint8Array, method?: string) => void
|
|
206
208
|
/** `request()` 默认超时,毫秒。默认 30 秒。 */
|
|
207
209
|
timeoutMs?: number
|
|
208
210
|
}
|
|
@@ -228,7 +230,8 @@ type RequestHandler = (params: unknown) => unknown | Promise<unknown>
|
|
|
228
230
|
* 请求 id 是递增整数;响应按 id 关联;通知按方法名分发(`'*'` 收所有)。
|
|
229
231
|
*/
|
|
230
232
|
export class RpcPeer {
|
|
231
|
-
readonly #
|
|
233
|
+
readonly #onResult: RpcPeerOptions['onResult']
|
|
234
|
+
readonly #send: RpcPeerOptions['send']
|
|
232
235
|
readonly #defaultTimeoutMs: number
|
|
233
236
|
readonly #pending = new Map<RpcId, Pending>()
|
|
234
237
|
readonly #notificationHandlers = new Map<string, Set<NotificationHandler>>()
|
|
@@ -236,6 +239,7 @@ export class RpcPeer {
|
|
|
236
239
|
#nextId = 1
|
|
237
240
|
|
|
238
241
|
constructor(options: RpcPeerOptions) {
|
|
242
|
+
this.#onResult = options.onResult
|
|
239
243
|
this.#send = options.send
|
|
240
244
|
this.#defaultTimeoutMs = options.timeoutMs ?? 30_000
|
|
241
245
|
}
|
|
@@ -278,7 +282,7 @@ export class RpcPeer {
|
|
|
278
282
|
signal?.addEventListener('abort', onAbort, { once: true })
|
|
279
283
|
this.#pending.set(id, entry)
|
|
280
284
|
try {
|
|
281
|
-
this.#send(encodeRpc(makeRequest(id, method, params ?? {})))
|
|
285
|
+
this.#send(encodeRpc(makeRequest(id, method, params ?? {})), method)
|
|
282
286
|
} catch (err) {
|
|
283
287
|
entry.cleanup()
|
|
284
288
|
reject(err)
|
|
@@ -287,7 +291,7 @@ export class RpcPeer {
|
|
|
287
291
|
}
|
|
288
292
|
|
|
289
293
|
notify(method: string, params?: unknown): void {
|
|
290
|
-
this.#send(encodeRpc(makeNotification(method, params ?? {})))
|
|
294
|
+
this.#send(encodeRpc(makeNotification(method, params ?? {})), method)
|
|
291
295
|
}
|
|
292
296
|
|
|
293
297
|
/** 订阅通知。`method = '*'` 收全部。返回取消订阅函数。 */
|
|
@@ -346,7 +350,10 @@ export class RpcPeer {
|
|
|
346
350
|
if (!entry) return
|
|
347
351
|
entry.cleanup()
|
|
348
352
|
if (msg.error) entry.reject(AnyconRpcError.fromWire(msg.error))
|
|
349
|
-
else
|
|
353
|
+
else {
|
|
354
|
+
this.#onResult?.(entry.method, msg.result)
|
|
355
|
+
entry.resolve(msg.result)
|
|
356
|
+
}
|
|
350
357
|
}
|
|
351
358
|
|
|
352
359
|
#onNotification(msg: RpcNotification): void {
|
|
@@ -866,23 +866,21 @@ Apache License 2.0 (Apache-2.0)
|
|
|
866
866
|
Used by:
|
|
867
867
|
argon2 0.6.0 <https://github.com/RustCrypto/password-hashes>
|
|
868
868
|
base64ct 1.8.3 <https://github.com/RustCrypto/formats>
|
|
869
|
-
blake2 0.10.6 <https://github.com/RustCrypto/hashes>
|
|
870
869
|
blake2 0.11.0 <https://github.com/RustCrypto/hashes>
|
|
871
870
|
block-buffer 0.10.4 <https://github.com/RustCrypto/utils>
|
|
872
871
|
block-buffer 0.12.1 <https://github.com/RustCrypto/utils>
|
|
873
|
-
chacha20 0.
|
|
874
|
-
chacha20poly1305 0.
|
|
875
|
-
cipher 0.
|
|
872
|
+
chacha20 0.10.2 <https://github.com/RustCrypto/stream-ciphers>
|
|
873
|
+
chacha20poly1305 0.11.0 <https://github.com/RustCrypto/AEADs>
|
|
874
|
+
cipher 0.5.2 <https://github.com/RustCrypto/traits>
|
|
876
875
|
crypto-common 0.1.7 <https://github.com/RustCrypto/traits>
|
|
877
876
|
crypto-common 0.2.2 <https://github.com/RustCrypto/traits>
|
|
878
877
|
digest 0.10.7 <https://github.com/RustCrypto/traits>
|
|
879
878
|
digest 0.11.3 <https://github.com/RustCrypto/traits>
|
|
880
879
|
hybrid-array 0.4.15 <https://github.com/RustCrypto/hybrid-array>
|
|
881
|
-
inout 0.
|
|
882
|
-
|
|
883
|
-
poly1305 0.8.0 <https://github.com/RustCrypto/universal-hashes>
|
|
880
|
+
inout 0.2.4 <https://github.com/RustCrypto/utils>
|
|
881
|
+
poly1305 0.9.1 <https://github.com/RustCrypto/universal-hashes>
|
|
884
882
|
sha2 0.10.9 <https://github.com/RustCrypto/hashes>
|
|
885
|
-
universal-hash 0.
|
|
883
|
+
universal-hash 0.6.1 <https://github.com/RustCrypto/traits>
|
|
886
884
|
|
|
887
885
|
Apache License
|
|
888
886
|
Version 2.0, January 2004
|
|
@@ -1091,7 +1089,7 @@ limitations under the License.
|
|
|
1091
1089
|
Apache License 2.0 (Apache-2.0)
|
|
1092
1090
|
|
|
1093
1091
|
Used by:
|
|
1094
|
-
aead 0.
|
|
1092
|
+
aead 0.6.1 <https://github.com/RustCrypto/traits>
|
|
1095
1093
|
|
|
1096
1094
|
Apache License
|
|
1097
1095
|
Version 2.0, January 2004
|
|
@@ -1705,12 +1703,222 @@ limitations under the License.
|
|
|
1705
1703
|
Apache License 2.0 (Apache-2.0)
|
|
1706
1704
|
|
|
1707
1705
|
Used by:
|
|
1708
|
-
|
|
1706
|
+
adler2 2.0.1 <https://github.com/oyvindln/adler2>
|
|
1707
|
+
|
|
1708
|
+
Apache License
|
|
1709
|
+
Version 2.0, January 2004
|
|
1710
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
1711
|
+
|
|
1712
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
1713
|
+
|
|
1714
|
+
1. Definitions.
|
|
1715
|
+
|
|
1716
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
1717
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
1718
|
+
|
|
1719
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
1720
|
+
the copyright owner that is granting the License.
|
|
1721
|
+
|
|
1722
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
1723
|
+
other entities that control, are controlled by, or are under common
|
|
1724
|
+
control with that entity. For the purposes of this definition,
|
|
1725
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
1726
|
+
direction or management of such entity, whether by contract or
|
|
1727
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
1728
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
1729
|
+
|
|
1730
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
1731
|
+
exercising permissions granted by this License.
|
|
1732
|
+
|
|
1733
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
1734
|
+
including but not limited to software source code, documentation
|
|
1735
|
+
source, and configuration files.
|
|
1736
|
+
|
|
1737
|
+
"Object" form shall mean any form resulting from mechanical
|
|
1738
|
+
transformation or translation of a Source form, including but
|
|
1739
|
+
not limited to compiled object code, generated documentation,
|
|
1740
|
+
and conversions to other media types.
|
|
1741
|
+
|
|
1742
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
1743
|
+
Object form, made available under the License, as indicated by a
|
|
1744
|
+
copyright notice that is included in or attached to the work
|
|
1745
|
+
(an example is provided in the Appendix below).
|
|
1746
|
+
|
|
1747
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
1748
|
+
form, that is based on (or derived from) the Work and for which the
|
|
1749
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
1750
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
1751
|
+
of this License, Derivative Works shall not include works that remain
|
|
1752
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
1753
|
+
the Work and Derivative Works thereof.
|
|
1754
|
+
|
|
1755
|
+
"Contribution" shall mean any work of authorship, including
|
|
1756
|
+
the original version of the Work and any modifications or additions
|
|
1757
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
1758
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
1759
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
1760
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
1761
|
+
means any form of electronic, verbal, or written communication sent
|
|
1762
|
+
to the Licensor or its representatives, including but not limited to
|
|
1763
|
+
communication on electronic mailing lists, source code control systems,
|
|
1764
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
1765
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
1766
|
+
excluding communication that is conspicuously marked or otherwise
|
|
1767
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
1768
|
+
|
|
1769
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
1770
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
1771
|
+
subsequently incorporated within the Work.
|
|
1772
|
+
|
|
1773
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
1774
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
1775
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
1776
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
1777
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
1778
|
+
Work and such Derivative Works in Source or Object form.
|
|
1779
|
+
|
|
1780
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
1781
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
1782
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
1783
|
+
(except as stated in this section) patent license to make, have made,
|
|
1784
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
1785
|
+
where such license applies only to those patent claims licensable
|
|
1786
|
+
by such Contributor that are necessarily infringed by their
|
|
1787
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
1788
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
1789
|
+
institute patent litigation against any entity (including a
|
|
1790
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
1791
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
1792
|
+
or contributory patent infringement, then any patent licenses
|
|
1793
|
+
granted to You under this License for that Work shall terminate
|
|
1794
|
+
as of the date such litigation is filed.
|
|
1795
|
+
|
|
1796
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
1797
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
1798
|
+
modifications, and in Source or Object form, provided that You
|
|
1799
|
+
meet the following conditions:
|
|
1800
|
+
|
|
1801
|
+
(a) You must give any other recipients of the Work or
|
|
1802
|
+
Derivative Works a copy of this License; and
|
|
1803
|
+
|
|
1804
|
+
(b) You must cause any modified files to carry prominent notices
|
|
1805
|
+
stating that You changed the files; and
|
|
1806
|
+
|
|
1807
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
1808
|
+
that You distribute, all copyright, patent, trademark, and
|
|
1809
|
+
attribution notices from the Source form of the Work,
|
|
1810
|
+
excluding those notices that do not pertain to any part of
|
|
1811
|
+
the Derivative Works; and
|
|
1812
|
+
|
|
1813
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
1814
|
+
distribution, then any Derivative Works that You distribute must
|
|
1815
|
+
include a readable copy of the attribution notices contained
|
|
1816
|
+
within such NOTICE file, excluding those notices that do not
|
|
1817
|
+
pertain to any part of the Derivative Works, in at least one
|
|
1818
|
+
of the following places: within a NOTICE text file distributed
|
|
1819
|
+
as part of the Derivative Works; within the Source form or
|
|
1820
|
+
documentation, if provided along with the Derivative Works; or,
|
|
1821
|
+
within a display generated by the Derivative Works, if and
|
|
1822
|
+
wherever such third-party notices normally appear. The contents
|
|
1823
|
+
of the NOTICE file are for informational purposes only and
|
|
1824
|
+
do not modify the License. You may add Your own attribution
|
|
1825
|
+
notices within Derivative Works that You distribute, alongside
|
|
1826
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
1827
|
+
that such additional attribution notices cannot be construed
|
|
1828
|
+
as modifying the License.
|
|
1829
|
+
|
|
1830
|
+
You may add Your own copyright statement to Your modifications and
|
|
1831
|
+
may provide additional or different license terms and conditions
|
|
1832
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
1833
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
1834
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
1835
|
+
the conditions stated in this License.
|
|
1836
|
+
|
|
1837
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
1838
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
1839
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
1840
|
+
this License, without any additional terms or conditions.
|
|
1841
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
1842
|
+
the terms of any separate license agreement you may have executed
|
|
1843
|
+
with Licensor regarding such Contributions.
|
|
1844
|
+
|
|
1845
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
1846
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
1847
|
+
except as required for reasonable and customary use in describing the
|
|
1848
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
1849
|
+
|
|
1850
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
1851
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
1852
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
1853
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
1854
|
+
implied, including, without limitation, any warranties or conditions
|
|
1855
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
1856
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
1857
|
+
appropriateness of using or redistributing the Work and assume any
|
|
1858
|
+
risks associated with Your exercise of permissions under this License.
|
|
1859
|
+
|
|
1860
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
1861
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
1862
|
+
unless required by applicable law (such as deliberate and grossly
|
|
1863
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
1864
|
+
liable to You for damages, including any direct, indirect, special,
|
|
1865
|
+
incidental, or consequential damages of any character arising as a
|
|
1866
|
+
result of this License or out of the use or inability to use the
|
|
1867
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
1868
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
1869
|
+
other commercial damages or losses), even if such Contributor
|
|
1870
|
+
has been advised of the possibility of such damages.
|
|
1871
|
+
|
|
1872
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
1873
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
1874
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
1875
|
+
or other liability obligations and/or rights consistent with this
|
|
1876
|
+
License. However, in accepting such obligations, You may act only
|
|
1877
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
1878
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
1879
|
+
defend, and hold each Contributor harmless for any liability
|
|
1880
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
1881
|
+
of your accepting any such warranty or additional liability.
|
|
1882
|
+
|
|
1883
|
+
END OF TERMS AND CONDITIONS
|
|
1884
|
+
|
|
1885
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
1886
|
+
|
|
1887
|
+
To apply the Apache License to your work, attach the following
|
|
1888
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
1889
|
+
replaced with your own identifying information. (Don't include
|
|
1890
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
1891
|
+
comment syntax for the file format. We also recommend that a
|
|
1892
|
+
file or class name and description of purpose be included on the
|
|
1893
|
+
same "printed page" as the copyright notice for easier
|
|
1894
|
+
identification within third-party archives.
|
|
1895
|
+
|
|
1896
|
+
Copyright [yyyy] [name of copyright owner]
|
|
1897
|
+
|
|
1898
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
1899
|
+
you may not use this file except in compliance with the License.
|
|
1900
|
+
You may obtain a copy of the License at
|
|
1901
|
+
|
|
1902
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
1903
|
+
|
|
1904
|
+
Unless required by applicable law or agreed to in writing, software
|
|
1905
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
1906
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1907
|
+
See the License for the specific language governing permissions and
|
|
1908
|
+
limitations under the License.
|
|
1909
|
+
|
|
1910
|
+
|
|
1911
|
+
--------------------------------------------------------------------------------
|
|
1912
|
+
Apache License 2.0 (Apache-2.0)
|
|
1913
|
+
|
|
1914
|
+
Used by:
|
|
1915
|
+
anycon-crypto 0.5.2
|
|
1916
|
+
miniz_oxide 0.9.1 <https://github.com/Frommi/miniz_oxide/tree/master/miniz_oxide>
|
|
1709
1917
|
pin-project-lite 0.2.17 <https://github.com/taiki-e/pin-project-lite>
|
|
1710
1918
|
proc-macro2 1.0.107 <https://github.com/dtolnay/proc-macro2>
|
|
1711
1919
|
quote 1.0.47 <https://github.com/dtolnay/quote>
|
|
1712
1920
|
rand 0.8.8 <https://github.com/rust-random/rand>
|
|
1713
|
-
snow 0.10.
|
|
1921
|
+
snow 0.10.3 <https://github.com/mcginty/snow>
|
|
1714
1922
|
syn 3.0.10 <https://github.com/dtolnay/syn>
|
|
1715
1923
|
thiserror-impl 2.0.21 <https://github.com/dtolnay/thiserror>
|
|
1716
1924
|
thiserror 2.0.21 <https://github.com/dtolnay/thiserror>
|
|
@@ -1832,19 +2040,38 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
1832
2040
|
BSD 3-Clause "New" or "Revised" License (BSD-3-Clause)
|
|
1833
2041
|
|
|
1834
2042
|
Used by:
|
|
1835
|
-
curve25519-dalek
|
|
2043
|
+
curve25519-dalek 5.1.0 <https://github.com/dalek-cryptography/curve25519-dalek/tree/main/curve25519-dalek>
|
|
1836
2044
|
|
|
1837
|
-
Copyright (c)
|
|
2045
|
+
Copyright (c) 2016-2021 isis agora lovecruft. All rights reserved.
|
|
2046
|
+
Copyright (c) 2016-2021 Henry de Valence. All rights reserved.
|
|
2047
|
+
Copyright (c) 2025-2026 The Beneficial AI Foundation. All rights reserved.
|
|
1838
2048
|
|
|
1839
|
-
Redistribution and use in source and binary forms, with or without
|
|
2049
|
+
Redistribution and use in source and binary forms, with or without
|
|
2050
|
+
modification, are permitted provided that the following conditions are
|
|
2051
|
+
met:
|
|
1840
2052
|
|
|
1841
|
-
1. Redistributions of source code must retain the above copyright
|
|
2053
|
+
1. Redistributions of source code must retain the above copyright
|
|
2054
|
+
notice, this list of conditions and the following disclaimer.
|
|
1842
2055
|
|
|
1843
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
2056
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
2057
|
+
notice, this list of conditions and the following disclaimer in the
|
|
2058
|
+
documentation and/or other materials provided with the distribution.
|
|
1844
2059
|
|
|
1845
|
-
3. Neither the name of the copyright holder nor the names of its
|
|
2060
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
2061
|
+
contributors may be used to endorse or promote products derived from
|
|
2062
|
+
this software without specific prior written permission.
|
|
1846
2063
|
|
|
1847
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
2064
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
2065
|
+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
2066
|
+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
2067
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
2068
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
2069
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
2070
|
+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
2071
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
2072
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
2073
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
2074
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1848
2075
|
|
|
1849
2076
|
|
|
1850
2077
|
--------------------------------------------------------------------------------
|
package/wasm/anycon_crypto.d.ts
CHANGED
|
@@ -106,7 +106,15 @@ export class WasmTransport {
|
|
|
106
106
|
* 加密任意长度明文;超过 65519 字节自动分片(`[u16 be 长度][密文]` 拼接)。
|
|
107
107
|
*/
|
|
108
108
|
encrypt(plaintext: Uint8Array): Uint8Array;
|
|
109
|
+
/**
|
|
110
|
+
* 解密并按内部标记解压;解密成功后的错误要求丢弃通道并重新握手。
|
|
111
|
+
*/
|
|
112
|
+
open(ciphertext: Uint8Array): Uint8Array;
|
|
109
113
|
remotePublic(): Uint8Array;
|
|
114
|
+
/**
|
|
115
|
+
* 将标记和消息体一起加密;未指定阈值时不压缩,达到阈值且体积变小时使用裸 DEFLATE。
|
|
116
|
+
*/
|
|
117
|
+
seal(plaintext: Uint8Array, compress_min?: number | null): Uint8Array;
|
|
110
118
|
}
|
|
111
119
|
|
|
112
120
|
/**
|
|
@@ -223,7 +231,9 @@ export interface InitOutput {
|
|
|
223
231
|
readonly wasmpairsecrets_psk: (a: number, b: number) => void;
|
|
224
232
|
readonly wasmtransport_decrypt: (a: number, b: number, c: number, d: number) => void;
|
|
225
233
|
readonly wasmtransport_encrypt: (a: number, b: number, c: number, d: number) => void;
|
|
234
|
+
readonly wasmtransport_open: (a: number, b: number, c: number, d: number) => void;
|
|
226
235
|
readonly wasmtransport_remotePublic: (a: number, b: number) => void;
|
|
236
|
+
readonly wasmtransport_seal: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
227
237
|
readonly __wbindgen_export: (a: number) => void;
|
|
228
238
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
229
239
|
readonly __wbindgen_export2: (a: number, b: number) => number;
|