@coda-console/friends 0.1.0 → 0.3.0

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/package.json CHANGED
@@ -4,12 +4,13 @@
4
4
  "displayName": "好友",
5
5
  "description": "管理 Accord 身份、个人名片与熟人好友通道",
6
6
  "icon": { "symbol": "person.2.fill", "color": "blue" },
7
- "version": "0.1.0",
7
+ "version": "0.3.0",
8
8
  "categories": [
9
9
  "Skills 与工具"
10
10
  ],
11
+ "type": "module",
11
12
  "engines": {
12
- "coda": 5
13
+ "coda": 13
13
14
  },
14
15
  "main": "main.mjs",
15
16
  "activationEvents": [
@@ -34,6 +35,342 @@
34
35
  "icon": "person.2.fill",
35
36
  "frame": "document"
36
37
  }
38
+ ],
39
+ "protocols": [
40
+ {
41
+ "name": "friends/social@1",
42
+ "title": "好友社交网关",
43
+ "description": "业务无关的好友网关:读好友与好友分享的记录,向好友发布、撤回记录,设置可代签的社交名片 friends/card,发私信 friends/dm、好友动态 friends/feed,并以 dm、feed 两条帧流实时跟随;签名与记录全部透传 coda/accord@1,没有身份或证书过期时在本机排队,恢复后自动补发。",
44
+ "spec": {
45
+ "type": "object",
46
+ "properties": { "version": { "const": 1 } },
47
+ "required": ["version"],
48
+ "additionalProperties": false
49
+ },
50
+ "status": {
51
+ "type": "object",
52
+ "properties": {
53
+ "author": { "type": ["string", "null"] },
54
+ "certState": { "enum": ["no_identity", "needs_cert", "active"] },
55
+ "certUntil": { "type": "integer", "minimum": 0 },
56
+ "friendCount": { "type": "integer", "minimum": 0 },
57
+ "pendingCount": { "type": "integer", "minimum": 0 },
58
+ "pausedKinds": { "type": "array", "items": { "type": "string" } }
59
+ },
60
+ "required": ["author", "certState", "friendCount", "pendingCount", "pausedKinds"],
61
+ "additionalProperties": false
62
+ },
63
+ "operations": {
64
+ "friends": {
65
+ "safe": true,
66
+ "input": {
67
+ "type": "object",
68
+ "properties": { "includePending": { "type": "boolean" } },
69
+ "additionalProperties": false
70
+ },
71
+ "result": {
72
+ "type": "object",
73
+ "properties": {
74
+ "selfAuthor": { "type": ["string", "null"] },
75
+ "certState": { "enum": ["no_identity", "needs_cert", "active"] },
76
+ "friends": { "type": "array", "items": { "type": "object" } },
77
+ "truncated": { "type": "boolean" }
78
+ },
79
+ "required": ["selfAuthor", "certState", "friends", "truncated"],
80
+ "additionalProperties": false
81
+ }
82
+ },
83
+ "records": {
84
+ "safe": true,
85
+ "input": {
86
+ "type": "object",
87
+ "properties": {
88
+ "kind": { "type": "string", "minLength": 1 },
89
+ "author": { "type": "string" },
90
+ "id": { "type": "string", "minLength": 1, "maxLength": 256 },
91
+ "limit": { "type": "integer", "minimum": 1, "maximum": 200 },
92
+ "cursor": { "type": "string" },
93
+ "includeAudience": { "type": "boolean" }
94
+ },
95
+ "required": ["kind"],
96
+ "additionalProperties": false
97
+ },
98
+ "result": {
99
+ "type": "object",
100
+ "properties": {
101
+ "records": { "type": "array", "items": { "type": "object" } },
102
+ "truncated": { "type": "boolean" },
103
+ "nextCursor": { "type": "string" }
104
+ },
105
+ "required": ["records", "truncated"]
106
+ }
107
+ },
108
+ "publish": {
109
+ "idempotent": true,
110
+ "input": {
111
+ "type": "object",
112
+ "properties": {
113
+ "kind": { "type": "string", "pattern": "^[a-z][a-z0-9-]{0,63}(?:/[a-z][a-z0-9-]{0,63})?$" },
114
+ "id": { "type": "string", "minLength": 1, "maxLength": 256 },
115
+ "body": { "type": "object" },
116
+ "audience": {
117
+ "type": "array",
118
+ "items": { "type": "string", "pattern": "^(?:public|ed25519:[0-9a-f]{64})$" },
119
+ "maxItems": 500,
120
+ "default": ["public"]
121
+ }
122
+ },
123
+ "required": ["kind", "id", "body"],
124
+ "additionalProperties": false
125
+ },
126
+ "result": {
127
+ "type": "object",
128
+ "properties": {
129
+ "state": { "enum": ["synced", "queued", "paused", "no_identity", "needs_cert", "error"] },
130
+ "skipped": { "type": "boolean" },
131
+ "author": { "type": ["string", "null"] },
132
+ "version": { "type": "integer", "minimum": 0 },
133
+ "error": { "type": "string" }
134
+ },
135
+ "required": ["state"],
136
+ "additionalProperties": false
137
+ }
138
+ },
139
+ "set-card": {
140
+ "idempotent": true,
141
+ "input": {
142
+ "type": "object",
143
+ "properties": {
144
+ "name": { "type": "string", "minLength": 1, "maxLength": 40 },
145
+ "emoji": { "type": "string", "maxLength": 8 },
146
+ "color": { "enum": ["blue", "orange", "green", "purple", "pink", "teal", "gray"] },
147
+ "avatar": {
148
+ "anyOf": [
149
+ {
150
+ "type": "object",
151
+ "description": "内容寻址的图片指针(BlobPointer):path 只收 content/<sha256>,sha256 须与 path 里的一致",
152
+ "properties": {
153
+ "owner": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" },
154
+ "path": { "type": "string", "pattern": "^content/[0-9a-f]{64}$" },
155
+ "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
156
+ "mime": { "type": "string", "minLength": 1, "maxLength": 128 },
157
+ "size": { "type": "integer", "minimum": 0, "maximum": 5242880 },
158
+ "name": { "type": "string", "minLength": 1, "maxLength": 200 }
159
+ },
160
+ "required": ["owner", "path", "sha256"],
161
+ "additionalProperties": false
162
+ },
163
+ { "type": "null" }
164
+ ]
165
+ }
166
+ },
167
+ "required": ["name"],
168
+ "additionalProperties": false
169
+ },
170
+ "result": {
171
+ "type": "object",
172
+ "properties": {
173
+ "state": { "enum": ["synced", "queued", "paused", "no_identity", "needs_cert", "error"] },
174
+ "skipped": { "type": "boolean" },
175
+ "author": { "type": ["string", "null"] },
176
+ "version": { "type": "integer", "minimum": 0 },
177
+ "error": { "type": "string" }
178
+ },
179
+ "required": ["state"],
180
+ "additionalProperties": false
181
+ }
182
+ },
183
+ "send-dm": {
184
+ "idempotent": true,
185
+ "input": {
186
+ "type": "object",
187
+ "properties": {
188
+ "to": { "type": "string", "pattern": "^ed25519:[0-9a-f]{64}$" },
189
+ "id": { "type": "string", "minLength": 1, "maxLength": 200, "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*[^\\s\\u0000-\\u001f\\u007f-\\u009f][^\\u0000-\\u001f\\u007f-\\u009f]*$", "description": "至多 200 个字符且 UTF-8 至多 256 字节,不含控制字符,去首尾空白后不能为空;省略由网关生成 UUID" },
190
+ "text": { "type": "string", "maxLength": 8000, "description": "至多 8000 个字符(码点,按原样计,含首尾空白),发布时去首尾空白" },
191
+ "attachments": {
192
+ "type": "array",
193
+ "minItems": 1,
194
+ "maxItems": 4,
195
+ "items": {
196
+ "type": "object",
197
+ "description": "内容寻址的图片指针(BlobPointer):path 只收 content/<sha256>,sha256 须与 path 里的一致",
198
+ "properties": {
199
+ "owner": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" },
200
+ "path": { "type": "string", "pattern": "^content/[0-9a-f]{64}$" },
201
+ "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
202
+ "mime": { "type": "string", "minLength": 1, "maxLength": 128 },
203
+ "size": { "type": "integer", "minimum": 0, "maximum": 5242880 },
204
+ "name": { "type": "string", "minLength": 1, "maxLength": 200 }
205
+ },
206
+ "required": ["owner", "path", "sha256"],
207
+ "additionalProperties": false
208
+ }
209
+ },
210
+ "replyTo": { "type": "string", "minLength": 1, "maxLength": 200, "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*[^\\s\\u0000-\\u001f\\u007f-\\u009f][^\\u0000-\\u001f\\u007f-\\u009f]*$", "description": "所回复私信的 id:与 id 同样至多 200 个字符且 UTF-8 至多 256 字节,不含控制字符" }
211
+ },
212
+ "required": ["to"],
213
+ "additionalProperties": false
214
+ },
215
+ "result": {
216
+ "type": "object",
217
+ "properties": {
218
+ "state": { "enum": ["synced", "queued", "paused", "no_identity", "needs_cert", "error"] },
219
+ "id": { "type": "string" },
220
+ "skipped": { "type": "boolean" },
221
+ "author": { "type": ["string", "null"] },
222
+ "version": { "type": "integer", "minimum": 0 },
223
+ "error": { "type": "string" }
224
+ },
225
+ "required": ["state"],
226
+ "additionalProperties": false
227
+ }
228
+ },
229
+ "post-feed": {
230
+ "idempotent": true,
231
+ "input": {
232
+ "type": "object",
233
+ "properties": {
234
+ "id": { "type": "string", "minLength": 1, "maxLength": 200, "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*[^\\s\\u0000-\\u001f\\u007f-\\u009f][^\\u0000-\\u001f\\u007f-\\u009f]*$", "description": "至多 200 个字符且 UTF-8 至多 256 字节,不含控制字符,去首尾空白后不能为空;省略由网关生成 UUID" },
235
+ "text": { "type": "string", "maxLength": 8000, "description": "至多 8000 个字符(码点,按原样计,含首尾空白),发布时去首尾空白" },
236
+ "media": {
237
+ "type": "array",
238
+ "minItems": 1,
239
+ "maxItems": 4,
240
+ "items": {
241
+ "type": "object",
242
+ "description": "内容寻址的图片指针(BlobPointer):path 只收 content/<sha256>,sha256 须与 path 里的一致",
243
+ "properties": {
244
+ "owner": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" },
245
+ "path": { "type": "string", "pattern": "^content/[0-9a-f]{64}$" },
246
+ "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
247
+ "mime": { "type": "string", "minLength": 1, "maxLength": 128 },
248
+ "size": { "type": "integer", "minimum": 0, "maximum": 5242880 },
249
+ "name": { "type": "string", "minLength": 1, "maxLength": 200 }
250
+ },
251
+ "required": ["owner", "path", "sha256"],
252
+ "additionalProperties": false
253
+ }
254
+ },
255
+ "audience": {
256
+ "type": "array",
257
+ "items": { "type": "string", "pattern": "^(?:public|ed25519:[0-9a-f]{64})$" },
258
+ "minItems": 1,
259
+ "maxItems": 500
260
+ }
261
+ },
262
+ "additionalProperties": false
263
+ },
264
+ "result": {
265
+ "type": "object",
266
+ "properties": {
267
+ "state": { "enum": ["synced", "queued", "paused", "no_identity", "needs_cert", "error"] },
268
+ "id": { "type": "string" },
269
+ "skipped": { "type": "boolean" },
270
+ "author": { "type": ["string", "null"] },
271
+ "version": { "type": "integer", "minimum": 0 },
272
+ "error": { "type": "string" }
273
+ },
274
+ "required": ["state"],
275
+ "additionalProperties": false
276
+ }
277
+ },
278
+ "retract": {
279
+ "idempotent": true,
280
+ "input": {
281
+ "type": "object",
282
+ "properties": {
283
+ "kind": { "type": "string", "pattern": "^[a-z][a-z0-9-]{0,63}(?:/[a-z][a-z0-9-]{0,63})?$" },
284
+ "id": { "type": "string", "minLength": 1, "maxLength": 256 }
285
+ },
286
+ "required": ["kind"],
287
+ "additionalProperties": false
288
+ },
289
+ "result": {
290
+ "type": "object",
291
+ "properties": {
292
+ "state": { "enum": ["retracted", "queued", "no_identity", "needs_cert", "error"] },
293
+ "count": { "type": "integer", "minimum": 0 },
294
+ "queued": { "type": "integer", "minimum": 0 },
295
+ "truncated": { "type": "boolean" },
296
+ "error": { "type": "string" }
297
+ },
298
+ "required": ["state", "count"],
299
+ "additionalProperties": false
300
+ }
301
+ },
302
+ "outbox": {
303
+ "safe": true,
304
+ "input": {
305
+ "type": "object",
306
+ "properties": { "kind": { "type": "string" } },
307
+ "additionalProperties": false
308
+ },
309
+ "result": {
310
+ "type": "object",
311
+ "properties": {
312
+ "author": { "type": ["string", "null"] },
313
+ "certState": { "enum": ["no_identity", "needs_cert", "active"] },
314
+ "pausedKinds": { "type": "array", "items": { "type": "string" } },
315
+ "pendingCount": { "type": "integer", "minimum": 0 },
316
+ "items": {
317
+ "type": "array",
318
+ "items": {
319
+ "type": "object",
320
+ "properties": {
321
+ "kind": { "type": "string" },
322
+ "id": { "type": "string" },
323
+ "desired": { "enum": ["publish", "retract"] },
324
+ "state": { "type": "string" },
325
+ "lastSyncedAt": { "type": "integer", "minimum": 0 },
326
+ "lastError": { "type": "string" }
327
+ },
328
+ "required": ["kind", "id", "desired", "state"],
329
+ "additionalProperties": false
330
+ }
331
+ }
332
+ },
333
+ "required": ["author", "certState", "pausedKinds", "pendingCount", "items"],
334
+ "additionalProperties": false
335
+ }
336
+ }
337
+ },
338
+ "streams": {
339
+ "dm": {
340
+ "shape": "read",
341
+ "frames": true,
342
+ "description": "私信的实时帧流:首帧 { type: 'snapshot', cursor, items }(按 createdAt 升序),之后每次变化一帧 { type: 'upsert', cursor, item } 或 { type: 'retract', cursor, author, id, peer };peer 只看与这位好友的私信,after 给上次的 cursor 只补增量,续不上回到快照",
343
+ "input": {
344
+ "type": "object",
345
+ "properties": {
346
+ "peer": { "type": "string", "pattern": "^ed25519:[0-9a-f]{64}$" },
347
+ "after": { "type": "string", "minLength": 1, "maxLength": 128 }
348
+ },
349
+ "additionalProperties": false
350
+ }
351
+ },
352
+ "feed": {
353
+ "shape": "read",
354
+ "frames": true,
355
+ "description": "好友动态的实时帧流:首帧 { type: 'snapshot', cursor, items }(按 createdAt 降序),之后每次变化一帧 { type: 'upsert', cursor, item } 或 { type: 'retract', cursor, author, id };author 只看这一位的,after 给上次的 cursor 只补增量,续不上回到快照",
356
+ "input": {
357
+ "type": "object",
358
+ "properties": {
359
+ "author": { "type": "string", "pattern": "^ed25519:[0-9a-f]{64}$" },
360
+ "after": { "type": "string", "minLength": 1, "maxLength": 128 }
361
+ },
362
+ "additionalProperties": false
363
+ }
364
+ }
365
+ },
366
+ "permissions": {
367
+ "read": { "title": "查看好友列表、读取好友分享的记录与实时私信、动态", "read": true, "operations": ["friends", "records"], "streams": ["dm", "feed"] },
368
+ "publish": { "title": "通过好友网关发布、撤回记录、设置社交名片、发私信与动态、查看待发队列", "operations": ["publish", "set-card", "send-dm", "post-feed", "retract", "outbox"] }
369
+ }
370
+ }
371
+ ],
372
+ "protocolImplementations": [
373
+ "friends/social@1"
37
374
  ]
38
375
  },
39
376
  "license": "MIT",
package/view/app.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  // 好友页:本机 Accord 身份与名片、接受好友邀请、好友列表。Accord 的读写(coda/accord@1)都在这里按交互发起;
2
2
  // 备注只经模块存在本机。好友的昵称、备注、节点名等外来数据一律用 textContent / DOM API 渲染,不进 innerHTML。
3
3
  import { Bridge } from 'coda-view://lib/v1/bridge.js';
4
- import { COLORS, checked, mergeFriendRows, normalizeProfileInput, parseInvite, readProfileRecord, shortAuthor } from '../lib/friends.mjs';
4
+ import { CARD_KIND, COLORS, cardFallbackNotice, checked, mergeFriendRows, mergeProfileAndCard, normalizeProfileInput, parseInvite, readCardRecord, readProfileRecord,
5
+ shortAuthor } from '../lib/friends.mjs';
5
6
 
6
7
  const ACCORD = 'coda/accord@1', LOCAL = { kind: ACCORD, id: 'local' };
7
8
  const coda = window.coda, bridge = new Bridge();
@@ -19,7 +20,7 @@ const h = (tag, attrs = {}, ...children) => {
19
20
  return node;
20
21
  };
21
22
 
22
- const state = { author: null, friends: [], profiles: [], notes: {}, loaded: false, problem: null, editing: null, removing: null, busy: new Set(), notice: new Map() };
23
+ const state = { author: null, friends: [], profiles: [], cards: [], notes: {}, loaded: false, problem: null, editing: null, removing: null, busy: new Set(), notice: new Map() };
23
24
 
24
25
  // ---- 备注:经模块存在本机 ----
25
26
  const pendingReplies = new Map();
@@ -41,22 +42,25 @@ function ask(type, input = {}) {
41
42
 
42
43
  // ---- 读本机 Accord ----
43
44
  let reading = 0;
45
+ // profile 与 friends/card 各读各的:一种读不到或没有记录,不挡另一种。
44
46
  async function readProfiles() {
45
47
  const mine = ++reading;
46
- try {
47
- const { records } = await coda.query(LOCAL, 'records', { kind: 'profile', limit: 200 });
48
- if (mine !== reading) return;
49
- state.profiles = records;
50
- state.problem = null;
51
- if (!own.touched) loadOwn();
52
- } catch (e) { if (mine === reading) state.problem = `读不到好友名片:${e.message}`; }
48
+ const [profiles, cards] = await Promise.allSettled(['profile', CARD_KIND].map(kind => coda.query(LOCAL, 'records', { kind, limit: 200 })));
49
+ if (mine !== reading) return;
50
+ if (profiles.status === 'fulfilled') state.profiles = profiles.value?.records ?? [];
51
+ if (cards.status === 'fulfilled') state.cards = cards.value?.records ?? [];
52
+ const failed = [profiles, cards].find(read => read.status === 'rejected');
53
+ state.problem = failed ? `读不到好友名片:${failed.reason?.message ?? failed.reason}` : null;
54
+ if (!own.touched) loadOwn();
53
55
  draw();
54
56
  }
55
- const own = { touched: false, name: '', emoji: '', color: 'blue' };
57
+ const own = { touched: false, name: '', emoji: '', color: 'blue', avatar: undefined };
58
+ const latestOwn = (records, read) => records.map(read).filter(p => p && p.author === state.author).sort((a, b) => b.version - a.version)[0];
59
+ // 本机名片:与好友列表同一条合并规则(profile 写了的优先,缺的由 friends/card 补);头像随表单带着,重新发布不会把它丢掉或带回已清除的。
56
60
  function loadOwn() {
57
- const mine = state.profiles.map(readProfileRecord).filter(p => p && p.author === state.author).sort((a, b) => b.version - a.version)[0];
61
+ const mine = mergeProfileAndCard(latestOwn(state.profiles, readProfileRecord), latestOwn(state.cards, readCardRecord));
58
62
  if (!mine) return;
59
- Object.assign(own, { name: mine.name, emoji: mine.emoji ?? '', color: mine.color ?? 'blue' });
63
+ Object.assign(own, { name: mine.name, emoji: mine.emoji ?? '', color: mine.color ?? 'blue', avatar: mine.avatarPresent ? mine.avatar : undefined });
60
64
  syncOwnForm();
61
65
  }
62
66
 
@@ -99,8 +103,18 @@ async function publishProfile() {
99
103
  ownForm.button.disabled = true;
100
104
  say(ownForm.message, '正在发布…', 'progress');
101
105
  try {
102
- await coda.call(LOCAL, 'publish', { kind: 'profile', id: 'self', body, audience: ['public'] });
103
- say(ownForm.message, '名片已发布,好友会看到它', 'ok');
106
+ try {
107
+ await coda.call(LOCAL, 'publish', { kind: 'profile', id: 'self', body, audience: ['public'] });
108
+ say(ownForm.message, '名片已发布,好友会看到它', 'ok');
109
+ } catch (e) {
110
+ // 绑定了代签证书时 profile 须由客户端根签,这里发不了:改发可代签的社交名片 friends/card,好友一样看得到。
111
+ if (e?.code !== 'forbidden') throw e;
112
+ await coda.call(LOCAL, 'publish', { kind: CARD_KIND, id: 'self', body, audience: ['public'] });
113
+ // 缓存的 state.profiles 可能还没读完或读失败了:现查一次本机作者的根签 profile,查不出来就不承诺。
114
+ let rooted = null;
115
+ try { rooted = ((await coda.query(LOCAL, 'records', { kind: 'profile', author: state.author, limit: 1 }))?.records ?? []).some(record => readProfileRecord(record)); } catch { /* 按没读出来提示 */ }
116
+ say(ownForm.message, cardFallbackNotice(rooted), 'ok');
117
+ }
104
118
  readProfiles();
105
119
  } catch (e) { say(ownForm.message, `没有发布成功:${e.message}`, 'error'); }
106
120
  ownForm.button.disabled = false;
@@ -114,8 +128,8 @@ async function copyKey() {
114
128
  // ---- 添加好友 ----
115
129
  const invite = {
116
130
  paste: h('textarea', { placeholder: '粘贴邀请:JSON、coda-friend:// 链接,或多行 control=… / authKey=…', autocomplete: 'off', spellcheck: 'false', oninput: parsePaste }),
117
- control: h('input', { type: 'text', autocomplete: 'off', spellcheck: 'false', placeholder: 'https://…' }),
118
- authKey: h('input', { type: 'password', autocomplete: 'off', spellcheck: 'false', placeholder: '入网码,提交后立即清空' }),
131
+ control: h('input', { type: 'text', autocomplete: 'off', spellcheck: 'false', placeholder: 'https://…', oninput: dropHidden }),
132
+ authKey: h('input', { type: 'password', autocomplete: 'off', spellcheck: 'false', placeholder: '入网码,提交后立即清空', oninput: dropHidden }),
119
133
  linkId: h('input', { type: 'text', autocomplete: 'off', placeholder: '留空自动生成' }),
120
134
  scope: h('input', { type: 'text', autocomplete: 'off', placeholder: '留空用本机空间' }),
121
135
  peerNode: h('input', { type: 'text', autocomplete: 'off', placeholder: '可选' }),
@@ -123,14 +137,17 @@ const invite = {
123
137
  button: h('button', { class: 'btn', type: 'button', onclick: submitInvite }, '接受邀请'),
124
138
  hidden: {},
125
139
  };
140
+ // hostname、peerPort 只随识别出的那份邀请:手改入网地址或入网码就是另一份邀请了,丢掉;改 linkId、scope、peerNode 不算。
141
+ function dropHidden() { invite.hidden = {}; }
126
142
  function parsePaste() {
143
+ invite.hidden = {};
127
144
  const text = invite.paste.value;
128
145
  if (!text.trim()) return say(invite.message, '', 'hint');
129
146
  try {
130
147
  const found = parseInvite(text);
131
148
  for (const name of ['control', 'authKey', 'scope', 'peerNode']) if (found[name]) invite[name].value = found[name];
132
149
  if (found.linkId && !/^f-[0-9a-f]{8}$/.test(found.linkId)) invite.linkId.value = found.linkId;
133
- invite.hidden.hostname = found.hostname ?? '';
150
+ invite.hidden = { hostname: found.hostname ?? '', peerPort: found.peerPort };
134
151
  say(invite.message, '已识别邀请,核对后点「接受邀请」', 'ok');
135
152
  } catch (e) { say(invite.message, e.message, 'error'); }
136
153
  }
@@ -142,7 +159,7 @@ async function submitInvite() {
142
159
  let input;
143
160
  try {
144
161
  input = checked({ control: invite.control.value, authKey: invite.authKey.value, linkId: invite.linkId.value, scope: invite.scope.value,
145
- peerNode: invite.peerNode.value, hostname: invite.hidden.hostname });
162
+ peerNode: invite.peerNode.value, hostname: invite.hidden.hostname, peerPort: invite.hidden.peerPort });
146
163
  } catch (e) {
147
164
  // 只填了粘贴区、还没有识别出来:再试着从粘贴区解析一次。
148
165
  try { input = parseInvite(invite.paste.value); } catch { return say(invite.message, e.message, 'error'); }
@@ -168,7 +185,7 @@ async function submitInvite() {
168
185
  // ---- 好友列表 ----
169
186
  const list = h('div');
170
187
  const countBadge = h('span', { class: 'count' });
171
- function rows() { return mergeFriendRows({ friends: state.friends, profiles: state.profiles, notes: state.notes }); }
188
+ function rows() { return mergeFriendRows({ friends: state.friends, profiles: state.profiles, cards: state.cards, notes: state.notes }); }
172
189
 
173
190
  async function handshake(row) {
174
191
  state.busy.add(row.node); state.notice.set(row.node, { kind: 'progress', text: '正在互认…' }); draw();