@anycon/protocol 0.5.0 → 0.5.1

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/rpc.js CHANGED
@@ -170,6 +170,7 @@ export class RpcTimeoutError extends Error {
170
170
  * 请求 id 是递增整数;响应按 id 关联;通知按方法名分发(`'*'` 收所有)。
171
171
  */
172
172
  export class RpcPeer {
173
+ #onResult;
173
174
  #send;
174
175
  #defaultTimeoutMs;
175
176
  #pending = new Map();
@@ -177,6 +178,7 @@ export class RpcPeer {
177
178
  #requestHandlers = new Map();
178
179
  #nextId = 1;
179
180
  constructor(options) {
181
+ this.#onResult = options.onResult;
180
182
  this.#send = options.send;
181
183
  this.#defaultTimeoutMs = options.timeoutMs ?? 30_000;
182
184
  }
@@ -218,7 +220,7 @@ export class RpcPeer {
218
220
  signal?.addEventListener('abort', onAbort, { once: true });
219
221
  this.#pending.set(id, entry);
220
222
  try {
221
- this.#send(encodeRpc(makeRequest(id, method, params ?? {})));
223
+ this.#send(encodeRpc(makeRequest(id, method, params ?? {})), method);
222
224
  }
223
225
  catch (err) {
224
226
  entry.cleanup();
@@ -227,7 +229,7 @@ export class RpcPeer {
227
229
  });
228
230
  }
229
231
  notify(method, params) {
230
- this.#send(encodeRpc(makeNotification(method, params ?? {})));
232
+ this.#send(encodeRpc(makeNotification(method, params ?? {})), method);
231
233
  }
232
234
  /** 订阅通知。`method = '*'` 收全部。返回取消订阅函数。 */
233
235
  onNotification(method, handler) {
@@ -279,8 +281,10 @@ export class RpcPeer {
279
281
  entry.cleanup();
280
282
  if (msg.error)
281
283
  entry.reject(AnyconRpcError.fromWire(msg.error));
282
- else
284
+ else {
285
+ this.#onResult?.(entry.method, msg.result);
283
286
  entry.resolve(msg.result);
287
+ }
284
288
  }
285
289
  #onNotification(msg) {
286
290
  for (const key of [msg.method, '*']) {
package/dist/rpc.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rpc.js","sourceRoot":"","sources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D,IAAI,KAAkB,CAAA;QACtB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE;gBACxB,IAAI,EAAE,CAAC,KAAK;gBACZ,OAAO,EAAE,qBAAqB,GAAG,CAAC,MAAM,EAAE;gBAC1C,IAAI,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;aAC9B,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBACH,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,CAAA;YACjE,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,MAAM,GACV,GAAG,YAAY,cAAc;oBAC3B,CAAC,CAAC,GAAG;oBACL,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;gBACrF,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;YAC5C,CAAC;QACH,CAAC;QACD,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anycon/protocol",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "TypeScript side of the Anycon protocol: generated types, envelope msgpack codec, JSON-RPC, and the Noise wasm wrapper.",
5
5
  "homepage": "https://github.com/anycon-ai/anycon/tree/main/packages/protocol#readme",
6
6
  "bugs": {
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/bun": "^1.4.5",
58
- "@types/node": "^26.6.8",
58
+ "@types/node": "^26.6.11",
59
59
  "tsx": "^4.23.15",
60
60
  "typescript": "~5.9.3"
61
61
  }
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/generated.ts CHANGED
@@ -2242,6 +2242,10 @@ export interface NodeInfo {
2242
2242
  platform: string;
2243
2243
  protocol_version: number;
2244
2244
  started_at_ms: number;
2245
+ /**
2246
+ * 当前 RPC 压缩设置;客户端按它决定发送方式,未知时使用默认值。
2247
+ */
2248
+ transport?: NodeTransportSettings | null;
2245
2249
  /**
2246
2250
  * `[twin] accept_links`:这个节点现在接受别的节点的 Twin 连接(docs/spec/daemon.md § 27.2)。旧 daemon 没有这个字段,读作 `false`。
2247
2251
  */
@@ -2381,6 +2385,19 @@ export interface NodeCapabilities {
2381
2385
  */
2382
2386
  worktree?: boolean;
2383
2387
  }
2388
+ /**
2389
+ * RPC 传输的发送设置;接收方始终接受压缩和未压缩消息。
2390
+ */
2391
+ export interface NodeTransportSettings {
2392
+ /**
2393
+ * 最小明文字节数。远程编辑范围为 256–1048576,使用时也夹到此范围。
2394
+ */
2395
+ compress_min_bytes: number;
2396
+ /**
2397
+ * 达到阈值时尝试压缩,只有消息体变小才使用裸 DEFLATE。
2398
+ */
2399
+ compression: boolean;
2400
+ }
2384
2401
  export interface NodeUpdateStatus {
2385
2402
  auto: boolean;
2386
2403
  last_rollback?: UpdateRollback | null;
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 #send: (bytes: Uint8Array) => void
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 entry.resolve(msg.result)
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.9.1 <https://github.com/RustCrypto/stream-ciphers>
874
- chacha20poly1305 0.10.1 <https://github.com/RustCrypto/AEADs/tree/master/chacha20poly1305>
875
- cipher 0.4.4 <https://github.com/RustCrypto/traits>
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.1.4 <https://github.com/RustCrypto/utils>
882
- opaque-debug 0.3.1 <https://github.com/RustCrypto/utils>
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.5.1 <https://github.com/RustCrypto/traits>
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.5.2 <https://github.com/RustCrypto/traits>
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
- anycon-crypto 0.5.0
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.1
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.0 <https://github.com/mcginty/snow>
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 4.1.3 <https://github.com/dalek-cryptography/curve25519-dalek/tree/main/curve25519-dalek>
2043
+ curve25519-dalek 5.1.0 <https://github.com/dalek-cryptography/curve25519-dalek/tree/main/curve25519-dalek>
1836
2044
 
1837
- Copyright (c) <year> <owner>.
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 modification, are permitted provided that the following conditions are met:
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 notice, this list of conditions and the following disclaimer.
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 notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
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 contributors may be used to endorse or promote products derived from this software without specific prior written permission.
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 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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
  --------------------------------------------------------------------------------
@@ -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;