@dsh-mobile/mobile-remote 3.4.1-beta.1 → 3.4.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/README.md CHANGED
@@ -253,7 +253,7 @@ pushUrls:
253
253
 
254
254
  ## 版本与兼容
255
255
 
256
- - **版本号统一**:App 版本和插件版本用同一条版本线(插件 3.4.0,App 3.4.0+42)。插件发布在 npm(`@dsh-mobile/mobile-remote`),手机 App 在 App Store 和官网 https://dsh.claud.ing/。
256
+ - **版本号统一**:App 版本和插件版本用同一条版本线(插件 3.4.1,App 3.4.1+43)。插件发布在 npm(`@dsh-mobile/mobile-remote`),手机 App 在 App Store 和官网 https://dsh.claud.ing/。
257
257
  - **版本差矩阵**(一句话:谁旧谁吃亏,但都不崩):
258
258
 
259
259
  | 组合 | 结果 |
@@ -4,10 +4,15 @@
4
4
 
5
5
 
6
6
 
7
+
8
+
9
+
10
+
7
11
  import {
8
12
  createCipheriv, createDecipheriv, createHash, createHmac, createPrivateKey, createPublicKey,
9
13
  diffieHellman, generateKeyPairSync, randomBytes, sign as edSign, verify as edVerify, timingSafeEqual,
10
14
  } from "node:crypto";
15
+ import { chacha20poly1305 } from "@noble/ciphers/chacha.js";
11
16
 
12
17
  export const EMPTY = new Uint8Array(0);
13
18
 
@@ -100,7 +105,25 @@ const nonceFor = (counter) => {
100
105
  n.writeBigUInt64LE(BigInt(counter), 4);
101
106
  return n;
102
107
  };
108
+
109
+ let nativeAead;
110
+ export function nativeAeadAvailable() {
111
+ if (nativeAead === undefined) {
112
+ try {
113
+ createCipheriv("chacha20-poly1305", Buffer.alloc(32), Buffer.alloc(12), { authTagLength: 16 });
114
+ nativeAead = true;
115
+ } catch {
116
+ nativeAead = false;
117
+ }
118
+ }
119
+ return nativeAead;
120
+ }
121
+
122
+ export function _forceNativeAead(value) {
123
+ nativeAead = value;
124
+ }
103
125
  export function aeadEncrypt(key, counter, ad, plaintext) {
126
+ if (!nativeAeadAvailable()) return u8(Buffer.from(chacha20poly1305(Uint8Array.from(key), u8(nonceFor(counter)), Uint8Array.from(ad)).encrypt(Uint8Array.from(plaintext))));
104
127
  const c = createCipheriv("chacha20-poly1305", Buffer.from(key), nonceFor(counter), { authTagLength: 16 });
105
128
  c.setAAD(Buffer.from(ad), { plaintextLength: plaintext.length });
106
129
  return concat(c.update(Buffer.from(plaintext)), c.final(), c.getAuthTag());
@@ -108,6 +131,7 @@ export function aeadEncrypt(key, counter, ad, plaintext) {
108
131
 
109
132
  export function aeadDecrypt(key, counter, ad, ciphertext) {
110
133
  if (ciphertext.length < 16) throw new Error("ciphertext too short");
134
+ if (!nativeAeadAvailable()) return u8(Buffer.from(chacha20poly1305(Uint8Array.from(key), u8(nonceFor(counter)), Uint8Array.from(ad)).decrypt(Uint8Array.from(ciphertext))));
111
135
  const body = ciphertext.subarray(0, ciphertext.length - 16);
112
136
  const tag = ciphertext.subarray(ciphertext.length - 16);
113
137
  const d = createDecipheriv("chacha20-poly1305", Buffer.from(key), nonceFor(counter), { authTagLength: 16 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-mobile/mobile-remote",
3
- "version": "3.4.1-beta.1",
3
+ "version": "3.4.1",
4
4
  "description": "DSH Mobile:把 DeepSeek Harness 变成随身控制台——手机远程发消息派活、看进度、收通知、审批决策、管理会话;配套 Flutter App(Android、iPhone / iPad)",
5
5
  "homepage": "https://dsh.claud.ing/",
6
6
  "repository": {
@@ -55,6 +55,7 @@
55
55
  "dsh": ">=0.2.1-rc.2 <0.4.0-0"
56
56
  },
57
57
  "dependencies": {
58
+ "@noble/ciphers": "2.4.0",
58
59
  "qrcode": "^1.5.4",
59
60
  "werift": "0.27.0"
60
61
  },