@celljs/ta-relay 4.17.0 → 4.18.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.
Files changed (68) hide show
  1. package/esm/common/index.d.ts +1 -0
  2. package/esm/common/index.js +1 -0
  3. package/esm/common/relay-faces.d.ts +1 -1
  4. package/esm/common/relay-faces.js +56 -1
  5. package/esm/common/relay-files.d.ts +14 -3
  6. package/esm/common/relay-files.js +41 -16
  7. package/esm/common/relay-friend-sends.d.ts +64 -0
  8. package/esm/common/relay-friend-sends.js +126 -0
  9. package/esm/common/relay-group-invites.d.ts +76 -0
  10. package/esm/common/relay-group-invites.js +163 -0
  11. package/esm/common/relay-hubs-protocol.d.ts +3 -1
  12. package/esm/common/relay-hubs.d.ts +19 -0
  13. package/esm/common/relay-hubs.js +58 -0
  14. package/esm/common/relay-open-in-ta.d.ts +11 -0
  15. package/esm/common/relay-open-in-ta.js +34 -0
  16. package/esm/common/relay-protocol.d.ts +2 -2
  17. package/esm/common/relay-protocol.js +5 -2
  18. package/esm/guest/guest-i18n.d.ts +1 -0
  19. package/esm/guest/guest-i18n.js +45 -41
  20. package/esm/guest/guest-style.d.ts +1 -1
  21. package/esm/guest/guest-style.js +2 -0
  22. package/esm/guest/guest.js +7 -2
  23. package/esm/join/join-i18n.d.ts +1 -0
  24. package/esm/join/join-i18n.js +4 -0
  25. package/esm/join/join.js +4 -1
  26. package/esm/node/relay-files-host.d.ts +2 -0
  27. package/esm/node/relay-files-host.js +24 -5
  28. package/esm/viewer/viewer-i18n.d.ts +1 -0
  29. package/esm/viewer/viewer-i18n.js +4 -0
  30. package/esm/viewer/viewer-style.d.ts +1 -1
  31. package/esm/viewer/viewer-style.js +2 -0
  32. package/esm/viewer/viewer.js +3 -1
  33. package/lib/common/index.d.ts +1 -0
  34. package/lib/common/index.js +1 -0
  35. package/lib/common/relay-faces.d.ts +1 -1
  36. package/lib/common/relay-faces.js +56 -1
  37. package/lib/common/relay-files.d.ts +14 -3
  38. package/lib/common/relay-files.js +42 -17
  39. package/lib/common/relay-friend-sends.d.ts +65 -0
  40. package/lib/common/relay-friend-sends.js +130 -0
  41. package/lib/common/relay-group-invites.d.ts +77 -0
  42. package/lib/common/relay-group-invites.js +167 -0
  43. package/lib/common/relay-hubs-protocol.d.ts +3 -1
  44. package/lib/common/relay-hubs.d.ts +19 -0
  45. package/lib/common/relay-hubs.js +58 -0
  46. package/lib/common/relay-open-in-ta.d.ts +12 -0
  47. package/lib/common/relay-open-in-ta.js +37 -0
  48. package/lib/common/relay-protocol.d.ts +2 -2
  49. package/lib/common/relay-protocol.js +5 -2
  50. package/lib/guest/guest-i18n.d.ts +1 -0
  51. package/lib/guest/guest-i18n.js +45 -41
  52. package/lib/guest/guest-style.d.ts +1 -1
  53. package/lib/guest/guest-style.js +2 -0
  54. package/lib/guest/guest.js +7 -2
  55. package/lib/join/join-i18n.d.ts +1 -0
  56. package/lib/join/join-i18n.js +4 -0
  57. package/lib/join/join.js +4 -1
  58. package/lib/node/relay-files-host.d.ts +2 -0
  59. package/lib/node/relay-files-host.js +23 -4
  60. package/lib/viewer/viewer-i18n.d.ts +1 -0
  61. package/lib/viewer/viewer-i18n.js +4 -0
  62. package/lib/viewer/viewer-style.d.ts +1 -1
  63. package/lib/viewer/viewer-style.js +2 -0
  64. package/lib/viewer/viewer.js +3 -1
  65. package/package.json +3 -3
  66. package/viewer/join.html +12 -3
  67. package/viewer/page.html +18 -9
  68. package/viewer/room.html +19 -8
@@ -0,0 +1,163 @@
1
+ import { RELAY_FRIENDS_KIND } from './relay-friends.js';
2
+ import { RelayHubUtil } from './relay-hub-util.js';
3
+ import { RelayIdentityUtil, RelayKeys } from './relay-identity.js';
4
+ /** The keys of the room of friends of the one who invites that hold its invitations to group chats, one a friend and chat. */
5
+ export const RELAY_GROUP_INVITE = 'invite:';
6
+ /** How long an invitation to a group chat works. */
7
+ const DAYS = 7;
8
+ const INFO = 'ta-group/1 invite';
9
+ /**
10
+ * Friends invited into a group chat (docs/design/ta-partners.md): the owner seals the invitation's link for each friend
11
+ * (ECDH of the two, the friend's id the salt) and leaves it in its room of friends, where the friend's Ta reads it even
12
+ * after being away; the friend joins on the user's word, and the owner's Ta lets in at once those it invited, by the
13
+ * identity their ask is signed with, and no one else: another who has the link only asks, as by any link.
14
+ */
15
+ export class RelayGroupInvites {
16
+ constructor(rooms, store) {
17
+ this.rooms = rooms;
18
+ this.store = store;
19
+ }
20
+ /** Invites friends into a group chat of the user's own: how many were. */
21
+ async invite(roomId, friendIds) {
22
+ var _a;
23
+ const record = this.rooms.record(roomId);
24
+ if (!(record === null || record === void 0 ? void 0 : record.own) || record.status !== 'member' || record.unlisted || record.kind === RELAY_FRIENDS_KIND) {
25
+ throw new Error('Only a group chat of your own takes friends.');
26
+ }
27
+ const ids = new Set(friendIds);
28
+ const friends = this.rooms.friends().filter(friend => ids.has(friend.id));
29
+ if (friends.length === 0) {
30
+ throw new Error('None of them is a friend.');
31
+ }
32
+ const { link, expiresAt } = await this.rooms.invite(roomId, { days: DAYS });
33
+ const identity = await this.rooms.identity();
34
+ const mine = await this.rooms.friendRoom();
35
+ const now = Date.now();
36
+ record.invited = {
37
+ ...Object.fromEntries(Object.entries((_a = record.invited) !== null && _a !== void 0 ? _a : {}).filter(([, until]) => until > now)),
38
+ ...Object.fromEntries(friends.map(friend => [friend.id, expiresAt])),
39
+ };
40
+ this.rooms.save();
41
+ await this.prune(mine.id, now);
42
+ for (const friend of friends) {
43
+ const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(identity, friend.box, friend.id, INFO));
44
+ const opened = { link, title: record.title, at: now, expiresAt };
45
+ const sealed = { d: await RelayKeys.seal(key, JSON.stringify(opened)), expiresAt };
46
+ await this.rooms.setState(mine.id, await RelayGroupInvites.keyOf(roomId, friend.id), sealed);
47
+ }
48
+ return friends.length;
49
+ }
50
+ /** Whether an ask to a room of the user's is of a friend it invited: let in at once. */
51
+ admits(record, ask) {
52
+ var _a;
53
+ var _b;
54
+ return record.own && !ask.guest && ((_b = (_a = record.invited) === null || _a === void 0 ? void 0 : _a[ask.id]) !== null && _b !== void 0 ? _b : 0) > Date.now();
55
+ }
56
+ /** One invited is in: its invitation goes. */
57
+ async admitted(record, id) {
58
+ var _a;
59
+ if (((_a = record.invited) === null || _a === void 0 ? void 0 : _a[id]) !== undefined) {
60
+ const { [id]: _gone, ...rest } = record.invited;
61
+ record.invited = rest;
62
+ this.rooms.save();
63
+ }
64
+ const mine = await this.rooms.friendRoom().catch(() => undefined);
65
+ if (mine) {
66
+ await this.rooms.setState(mine.id, await RelayGroupInvites.keyOf(record.id, id), null).catch(() => undefined);
67
+ }
68
+ }
69
+ /** The group chats friends invited the user into, not joined nor turned down, the latest first. */
70
+ async list() {
71
+ return (await this.read()).map(({ link: _link, ...invite }) => invite);
72
+ }
73
+ /** The user's answer to an invitation: joined, or no longer listed. */
74
+ async answer(roomId, accept) {
75
+ const invite = (await this.read()).find(each => each.room === roomId);
76
+ if (!invite) {
77
+ throw new Error('No friend invites you there now.');
78
+ }
79
+ if (accept) {
80
+ await this.rooms.join(invite.link);
81
+ return;
82
+ }
83
+ const book = this.book();
84
+ const now = Date.now();
85
+ book.declined = Object.fromEntries([...Object.entries(book.declined).filter(([, until]) => until > now), [roomId, invite.expiresAt]]);
86
+ this.store.write('groups', book);
87
+ }
88
+ /** Whether a change of the state is of an invitation the user may have: the page reads them again. */
89
+ static heard(record, key) {
90
+ return !!record && !record.own && record.kind === RELAY_FRIENDS_KIND && key.startsWith(RELAY_GROUP_INVITE);
91
+ }
92
+ /** The key of an invitation: neither the room nor the friend can be read from it by the other friends. */
93
+ static async keyOf(room, friend) {
94
+ return RELAY_GROUP_INVITE + (await RelayKeys.hash(`${room}\n${friend}`)).slice(0, 22);
95
+ }
96
+ book() {
97
+ const book = this.store.read('groups');
98
+ return { declined: (book === null || book === void 0 ? void 0 : book.declined) && typeof book.declined === 'object' ? book.declined : {} };
99
+ }
100
+ /** The invitations of the user's own that no longer work, taken out of the room of friends. */
101
+ async prune(room, now) {
102
+ var _a, _b;
103
+ const self = (_b = (_a = this.rooms
104
+ .list()
105
+ .find(info => info.id === room)) === null || _a === void 0 ? void 0 : _a.members.find(member => member.self)) === null || _b === void 0 ? void 0 : _b.member;
106
+ for (const [key, entry] of Object.entries(await this.rooms.getState(room, RELAY_GROUP_INVITE))) {
107
+ const value = entry.value;
108
+ if (entry.by === self && value && Number(value.expiresAt) <= now) {
109
+ await this.rooms.setState(room, key, null).catch(() => undefined);
110
+ }
111
+ }
112
+ }
113
+ async read() {
114
+ const identity = await this.rooms.identity();
115
+ const all = this.rooms.list();
116
+ const inside = new Set(all.filter(room => room.status === 'member' || room.status === 'waiting').map(room => room.id));
117
+ const { declined } = this.book();
118
+ const now = Date.now();
119
+ const found = [];
120
+ for (const room of all) {
121
+ const record = this.rooms.record(room.id);
122
+ if (!record || record.own || record.kind !== RELAY_FRIENDS_KIND || room.status !== 'member' || !record.owner.box) {
123
+ continue;
124
+ }
125
+ const owner = room.members.find(member => member.owner);
126
+ if (!owner || owner.id !== record.owner.id) {
127
+ continue;
128
+ }
129
+ const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(identity, record.owner.box, identity.id, INFO));
130
+ for (const entry of Object.values(await this.rooms.getState(room.id, RELAY_GROUP_INVITE).catch(() => ({})))) {
131
+ const value = entry.value;
132
+ if (entry.by !== owner.member || !value || typeof value.d !== 'string' || Number(value.expiresAt) <= now) {
133
+ continue;
134
+ }
135
+ const opened = await RelayKeys.open(key, value.d).then(text => JSON.parse(text), () => undefined);
136
+ if (!opened || typeof opened.link !== 'string') {
137
+ continue;
138
+ }
139
+ let link;
140
+ try {
141
+ link = RelayHubUtil.parse(opened.link);
142
+ }
143
+ catch (_a) {
144
+ continue;
145
+ }
146
+ // Only a room of the friend's own, by a link it made.
147
+ if (link.owner !== owner.id || link.kind || inside.has(link.room) || declined[link.room] !== undefined || opened.expiresAt <= now) {
148
+ continue;
149
+ }
150
+ found.push({
151
+ room: link.room,
152
+ title: String(opened.title || link.title).slice(0, 80),
153
+ by: { id: owner.id, name: owner.name, ...(owner.look ? { look: owner.look } : {}) },
154
+ at: Number(opened.at) || now,
155
+ expiresAt: opened.expiresAt,
156
+ link: opened.link,
157
+ });
158
+ }
159
+ }
160
+ return found.sort((a, b) => b.at - a.at);
161
+ }
162
+ }
163
+ //# sourceMappingURL=relay-group-invites.js.map
@@ -32,6 +32,8 @@ export interface RelayRoomRecord {
32
32
  capacity?: number;
33
33
  /** Of one asking: the invitation, till the relay has the ask. */
34
34
  invite?: string;
35
+ /** Of the owner: the friends invited into it (RelayGroupInvites), by identity id, till when: let in at once as they ask. */
36
+ invited?: Record<string, number>;
35
37
  asked?: boolean;
36
38
  createdAt: number;
37
39
  joinedAt?: number;
@@ -168,7 +170,7 @@ export interface RelayHubsStore {
168
170
  write(name: RelayHubsStoreName, value: unknown): void;
169
171
  }
170
172
  /** The identity, the rooms (with their keys) and the friends. */
171
- export type RelayHubsStoreName = 'identity' | 'rooms' | 'friends';
173
+ export type RelayHubsStoreName = 'identity' | 'rooms' | 'friends' | 'groups' | 'sends';
172
174
  export interface RelayHubsOptions {
173
175
  store: RelayHubsStore;
174
176
  /** The name of a new identity: that of the user on the system. */
@@ -1,4 +1,6 @@
1
+ import { RelayFriendSends, type RelayFriendShare } from './relay-friend-sends.js';
1
2
  import { RelayFriends } from './relay-friends.js';
3
+ import { type RelayGroupInvite, RelayGroupInvites } from './relay-group-invites.js';
2
4
  import { type RelayHubAskBody } from './relay-hub-util.js';
3
5
  import { Live } from './relay-hubs-connection.js';
4
6
  import { RelayHubsIdentity } from './relay-hubs-identity.js';
@@ -12,6 +14,8 @@ import { type RelayPublicIdentity } from './relay-identity.js';
12
14
  */
13
15
  export declare class RelayHubs extends RelayHubsIdentity {
14
16
  protected readonly book: RelayFriends;
17
+ protected readonly groups: RelayGroupInvites;
18
+ protected readonly sends: RelayFriendSends;
15
19
  /** Connects to the rooms of rooms.json, and keeps connected. */
16
20
  start(): void;
17
21
  stop(): void;
@@ -90,6 +94,21 @@ export declare class RelayHubs extends RelayHubsIdentity {
90
94
  answerFriend(id: string, accept: boolean): Promise<void>;
91
95
  /** No longer friends, on both sides. */
92
96
  removeFriend(id: string): Promise<boolean>;
97
+ /** Invites friends into a group chat of the user's own: they join on their word, let in at once. How many were. */
98
+ inviteFriends(roomId: string, friends: readonly string[]): Promise<number>;
99
+ /** The group chats friends invited the user into. */
100
+ groupInvites(): Promise<RelayGroupInvite[]>;
101
+ /** The user's answer to an invitation into a group chat. */
102
+ answerGroupInvite(roomId: string, accept: boolean): Promise<void>;
103
+ /** Sends a link to friends from the share sheet: how many it went to. */
104
+ sendToFriends(friends: readonly string[], item: {
105
+ link: string;
106
+ title: string;
107
+ }): Promise<number>;
108
+ /** What friends sent the user. */
109
+ friendShares(): Promise<RelayFriendShare[]>;
110
+ /** The user opened one (`keep`) or let it go. */
111
+ answerFriendShare(id: string, keep: boolean): void;
93
112
  protected isFriends(live: Live): boolean;
94
113
  protected friendIds(): Set<string>;
95
114
  protected heardAsk(live: Live, ask: RelayHubAskBody): void;
@@ -1,4 +1,6 @@
1
+ import { RelayFriendSends } from './relay-friend-sends.js';
1
2
  import { RELAY_FRIENDS_KIND, RelayFriends, RelayFriendsUtil } from './relay-friends.js';
3
+ import { RelayGroupInvites } from './relay-group-invites.js';
2
4
  import { RelayHubUtil } from './relay-hub-util.js';
3
5
  import { Live, OPEN, READY_MS } from './relay-hubs-connection.js';
4
6
  import { RelayHubsIdentity } from './relay-hubs-identity.js';
@@ -34,6 +36,27 @@ export class RelayHubs extends RelayHubsIdentity {
34
36
  setState: (room, key, value) => this.setState(room, key, value),
35
37
  offer: (room, member, link) => this.sendBody(this.member(room), { friend: link }, member),
36
38
  }, this.options.store, event => this.notify(event));
39
+ this.groups = new RelayGroupInvites({
40
+ identity: () => this.identity(),
41
+ list: () => this.list(),
42
+ record: room => { var _a; return (_a = this.live.get(room)) === null || _a === void 0 ? void 0 : _a.record; },
43
+ save: () => this.save(),
44
+ friends: () => this.friends(),
45
+ friendRoom: () => this.friendRoom(),
46
+ invite: (room, options) => this.invite(room, options),
47
+ join: link => this.join(link),
48
+ getState: (room, prefix) => this.getState(room, prefix),
49
+ setState: (room, key, value) => this.setState(room, key, value),
50
+ }, this.options.store);
51
+ this.sends = new RelayFriendSends({
52
+ identity: () => this.identity(),
53
+ list: () => this.list(),
54
+ record: room => { var _a; return (_a = this.live.get(room)) === null || _a === void 0 ? void 0 : _a.record; },
55
+ friends: () => this.friends(),
56
+ friendRoom: () => this.friendRoom(),
57
+ getState: (room, prefix) => this.getState(room, prefix),
58
+ setState: (room, key, value) => this.setState(room, key, value),
59
+ }, this.options.store);
37
60
  }
38
61
  /** Connects to the rooms of rooms.json, and keeps connected. */
39
62
  start() {
@@ -379,6 +402,31 @@ export class RelayHubs extends RelayHubsIdentity {
379
402
  removeFriend(id) {
380
403
  return this.book.remove(id);
381
404
  }
405
+ /** Invites friends into a group chat of the user's own: they join on their word, let in at once. How many were. */
406
+ inviteFriends(roomId, friends) {
407
+ return this.groups.invite(roomId, friends);
408
+ }
409
+ /** The group chats friends invited the user into. */
410
+ groupInvites() {
411
+ return this.groups.list();
412
+ }
413
+ /** The user's answer to an invitation into a group chat. */
414
+ answerGroupInvite(roomId, accept) {
415
+ return this.groups.answer(roomId, accept);
416
+ }
417
+ /** Sends a link to friends from the share sheet: how many it went to. */
418
+ sendToFriends(friends, item) {
419
+ return this.sends.send(friends, item);
420
+ }
421
+ /** What friends sent the user. */
422
+ friendShares() {
423
+ return this.sends.list();
424
+ }
425
+ /** The user opened one (`keep`) or let it go. */
426
+ answerFriendShare(id, keep) {
427
+ this.sends.answer(id, keep);
428
+ this.emit({ type: 'rooms' });
429
+ }
382
430
  isFriends(live) {
383
431
  return live.record.own && live.record.kind === RELAY_FRIENDS_KIND;
384
432
  }
@@ -389,6 +437,10 @@ export class RelayHubs extends RelayHubsIdentity {
389
437
  if (this.isFriends(live)) {
390
438
  this.book.asked(ask);
391
439
  }
440
+ else if (this.groups.admits(live.record, ask)) {
441
+ // A friend the user invited: in at once, as the user chose it; asked as any other should that fail.
442
+ void this.answer(live.record.id, ask.member, true).then(() => this.groups.admitted(live.record, ask.id), () => super.heardAsk(live, ask));
443
+ }
392
444
  else {
393
445
  super.heardAsk(live, ask);
394
446
  }
@@ -405,9 +457,15 @@ export class RelayHubs extends RelayHubsIdentity {
405
457
  }
406
458
  /** What changes the friends: rooms coming and going, members, the links friends leave to join back. */
407
459
  after(event) {
460
+ var _a;
408
461
  if (!this.options.guest && (event.type === 'rooms' || (event.type === 'state' && event.key.startsWith('back:')))) {
409
462
  this.book.changed();
410
463
  }
464
+ // A friend invited the user into a group chat, or took it back: the pages read the rooms again.
465
+ const record = (_a = this.live.get(event.type === 'state' ? event.room : '')) === null || _a === void 0 ? void 0 : _a.record;
466
+ if (!this.options.guest && event.type === 'state' && (RelayGroupInvites.heard(record, event.key) || RelayFriendSends.heard(record, event.key))) {
467
+ this.emit({ type: 'rooms' });
468
+ }
411
469
  }
412
470
  owned(roomId) {
413
471
  const live = this.member(roomId);
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A link of Ta handed to the Ta app by the system (docs/design/ta-links.md 5): `ta://open?link=<the link>`, which the
3
+ * pages of the relay offer as "Open in Ta" and the app takes as its own (a scheme of its own on the computer and the
4
+ * phone). The link inside opens as any link of Ta, asking first wherever it would do something. Pure, for the tests.
5
+ */
6
+ export declare namespace RelayOpenInTa {
7
+ const SCHEME = "ta:";
8
+ function link(href: string): string;
9
+ /** The link of Ta inside, or undefined for what is not one (another `ta://`, a page of the web, one too long). */
10
+ function inner(text: string): string | undefined;
11
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A link of Ta handed to the Ta app by the system (docs/design/ta-links.md 5): `ta://open?link=<the link>`, which the
3
+ * pages of the relay offer as "Open in Ta" and the app takes as its own (a scheme of its own on the computer and the
4
+ * phone). The link inside opens as any link of Ta, asking first wherever it would do something. Pure, for the tests.
5
+ */
6
+ export var RelayOpenInTa;
7
+ (function (RelayOpenInTa) {
8
+ RelayOpenInTa.SCHEME = 'ta:';
9
+ const MAX = 4096;
10
+ function link(href) {
11
+ return `ta://open?link=${encodeURIComponent(href)}`;
12
+ }
13
+ RelayOpenInTa.link = link;
14
+ /** The link of Ta inside, or undefined for what is not one (another `ta://`, a page of the web, one too long). */
15
+ function inner(text) {
16
+ const trimmed = text.trim();
17
+ if (trimmed.length > MAX * 3 || !/^ta:\/\/open\?/i.test(trimmed)) {
18
+ return undefined;
19
+ }
20
+ const found = /[?&]link=([^&#]+)/.exec(trimmed);
21
+ if (!found) {
22
+ return undefined;
23
+ }
24
+ try {
25
+ const link = decodeURIComponent(found[1]).trim();
26
+ return /^https?:\/\/\S+$/i.test(link) && link.length <= MAX ? link : undefined;
27
+ }
28
+ catch (_a) {
29
+ return undefined;
30
+ }
31
+ }
32
+ RelayOpenInTa.inner = inner;
33
+ })(RelayOpenInTa || (RelayOpenInTa = {}));
34
+ //# sourceMappingURL=relay-open-in-ta.js.map
@@ -40,9 +40,9 @@ export declare const RELAY_VIEWER_HEADERS: {
40
40
  /** The copies of content kept on the relay, sealed, for when the computer that shared it is off (RelayBlobs). */
41
41
  export declare const RELAY_BLOB_PATH = "/v1/blob/";
42
42
  /** The page a pairing link opens in a browser: the link is for the app, and the key in it stays in the fragment. */
43
- export declare const RELAY_PAIR_PAGE = "<!doctype html><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width\"><title>Ta</title>\n<body style=\"font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em\">\n<h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>\n<p>\u6253\u5F00 Ta \u5E94\u7528\uFF0C\u7C98\u8D34\u8FD9\u4E2A\u94FE\u63A5\uFF0C\u5C31\u80FD\u4ECE\u8FD9\u53F0\u8BBE\u5907\u8FDE\u5230\u4F60\u7684 Ta\u3002</p></body>";
43
+ export declare const RELAY_PAIR_PAGE = "<!doctype html><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width\"><title>Ta</title>\n<body style=\"font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em\">\n<h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>\n<p>\u6253\u5F00 Ta \u5E94\u7528\uFF0C\u7C98\u8D34\u8FD9\u4E2A\u94FE\u63A5\uFF0C\u5C31\u80FD\u4ECE\u8FD9\u53F0\u8BBE\u5907\u8FDE\u5230\u4F60\u7684 Ta\u3002</p><p><a id=\"open\" style=\"display:inline-block;padding:10px 18px;border-radius:20px;background:#111;color:#fff;text-decoration:none;font-weight:600\">Open in Ta \u00B7 \u5728 Ta \u4E2D\u6253\u5F00</a></p>\n<script>document.getElementById('open').href='ta://open?link='+encodeURIComponent(location.href)</script></body>";
44
44
  /** The page a link of an extension opens in a browser. */
45
- export declare const RELAY_SHARE_PAGE = "<!doctype html><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width\"><title>Ta</title>\n<body style=\"font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em\">\n<h1>Ta</h1><p>Someone shared an extension of Ta. Scan the code in the Ta app, or paste this link in its Quick open, to open it.</p>\n<p>\u6709\u4EBA\u5206\u4EAB\u4E86\u4E00\u4E2A Ta \u6269\u5C55\u3002\u5728 Ta \u5E94\u7528\u91CC\u626B\u7801\uFF0C\u6216\u628A\u8FD9\u4E2A\u94FE\u63A5\u7C98\u8D34\u5230\u201C\u5FEB\u6377\u6253\u5F00\u201D\uFF0C\u5C31\u80FD\u6253\u5F00\u5B83\u3002</p></body>";
45
+ export declare const RELAY_SHARE_PAGE = "<!doctype html><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width\"><title>Ta</title>\n<body style=\"font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em\">\n<h1>Ta</h1><p>Someone shared an extension of Ta. Scan the code in the Ta app, or paste this link in its Quick open, to open it.</p>\n<p>\u6709\u4EBA\u5206\u4EAB\u4E86\u4E00\u4E2A Ta \u6269\u5C55\u3002\u5728 Ta \u5E94\u7528\u91CC\u626B\u7801\uFF0C\u6216\u628A\u8FD9\u4E2A\u94FE\u63A5\u7C98\u8D34\u5230\u201C\u5FEB\u6377\u6253\u5F00\u201D\uFF0C\u5C31\u80FD\u6253\u5F00\u5B83\u3002</p><p><a id=\"open\" style=\"display:inline-block;padding:10px 18px;border-radius:20px;background:#111;color:#fff;text-decoration:none;font-weight:600\">Open in Ta \u00B7 \u5728 Ta \u4E2D\u6253\u5F00</a></p>\n<script>document.getElementById('open').href='ta://open?link='+encodeURIComponent(location.href)</script></body>";
46
46
  /**
47
47
  * A package handed on through the relay (RelayShare): the host, asked on a channel by the key of the share,
48
48
  * sends what the package is, then its bytes in chunks small enough for any relay, then the end; sealed as the
@@ -44,16 +44,19 @@ export const RELAY_VIEWER_HEADERS = {
44
44
  };
45
45
  /** The copies of content kept on the relay, sealed, for when the computer that shared it is off (RelayBlobs). */
46
46
  export const RELAY_BLOB_PATH = '/v1/blob/';
47
+ /** Open in Ta on the plain pages of the relay: the link of the page, its fragment too, to the Ta app (RelayOpenInTa). */
48
+ const OPEN_IN_TA = `<p><a id="open" style="display:inline-block;padding:10px 18px;border-radius:20px;background:#111;color:#fff;text-decoration:none;font-weight:600">Open in Ta · 在 Ta 中打开</a></p>
49
+ <script>document.getElementById('open').href='ta://open?link='+encodeURIComponent(location.href)</script>`;
47
50
  /** The page a pairing link opens in a browser: the link is for the app, and the key in it stays in the fragment. */
48
51
  export const RELAY_PAIR_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
49
52
  <body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
50
53
  <h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>
51
- <p>打开 Ta 应用,粘贴这个链接,就能从这台设备连到你的 Ta。</p></body>`;
54
+ <p>打开 Ta 应用,粘贴这个链接,就能从这台设备连到你的 Ta。</p>${OPEN_IN_TA}</body>`;
52
55
  /** The page a link of an extension opens in a browser. */
53
56
  export const RELAY_SHARE_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
54
57
  <body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
55
58
  <h1>Ta</h1><p>Someone shared an extension of Ta. Scan the code in the Ta app, or paste this link in its Quick open, to open it.</p>
56
- <p>有人分享了一个 Ta 扩展。在 Ta 应用里扫码,或把这个链接粘贴到“快捷打开”,就能打开它。</p></body>`;
59
+ <p>有人分享了一个 Ta 扩展。在 Ta 应用里扫码,或把这个链接粘贴到“快捷打开”,就能打开它。</p>${OPEN_IN_TA}</body>`;
57
60
  /** The largest package that is handed on: a gzipped tar of a package of the user, its code and a few assets. */
58
61
  export const RELAY_SHARE_MAX_BYTES = 8 * 1024 * 1024;
59
62
  /** The bytes of a chunk, base64 in a sealed message: well under the 1 MiB of a message of Cloudflare. */
@@ -1,5 +1,6 @@
1
1
  import { type PageLanguage } from '../common/page-language.js';
2
2
  declare const zh: {
3
+ openInTa: string;
3
4
  title: string;
4
5
  invalid: string;
5
6
  inTa: string;
@@ -1,10 +1,11 @@
1
1
  import { pageLanguage } from '../common/page-language.js';
2
2
  const zh = {
3
- title: 'Ta 房间',
4
- invalid: '这不是一个完整的 Ta 房间邀请链接,请检查是否复制完整。',
3
+ openInTa: '在 Ta 中打开',
4
+ title: 'Ta 群聊',
5
+ invalid: '这不是一个完整的 Ta 群聊邀请链接,请检查是否复制完整。',
5
6
  inTa: '这是{by}在 Ta 里的加好友链接,要在 Ta 里打开:用 Ta 扫码,或把链接粘贴到 Ta 的快捷打开。',
6
7
  invited: '{by}邀请你加入',
7
- joinHint: '房主同意后,就能在这里和大家聊天。',
8
+ joinHint: '群主同意后,就能在这里和大家聊天。',
8
9
  name: '你的名字',
9
10
  namePlaceholder: '大家看到的名字',
10
11
  join: '申请加入',
@@ -16,16 +17,16 @@ const zh = {
16
17
  cancel: '取消申请',
17
18
  refused: '{by}没有同意你加入',
18
19
  again: '再申请一次',
19
- removed: '你已被移出这个房间',
20
- closed: '这个房间已被房主解散',
21
- inviteGone: '邀请已失效,请向房主要一个新链接',
22
- own: '这是你自己的房间,请在 Ta 里打开。',
20
+ removed: '你已被移出这个群聊',
21
+ closed: '这个群聊已被群主解散',
22
+ inviteGone: '邀请已失效,请向群主要一个新链接',
23
+ own: '这是你自己的群聊,请在 Ta 里打开。',
23
24
  connecting: '连接中…',
24
25
  online: '另有 {n} 人在线',
25
26
  nobody: '其他人都不在线',
26
27
  onlineNow: '在线',
27
28
  members: '成员',
28
- owner: '房主',
29
+ owner: '群主',
29
30
  you: '我',
30
31
  guest: '网页访客',
31
32
  doubleOf: '{name}的分身',
@@ -33,10 +34,10 @@ const zh = {
33
34
  task: '任务',
34
35
  agentOf: '{name}的智能体',
35
36
  rename: '修改我的名字',
36
- leave: '退出房间',
37
+ leave: '退出群聊',
37
38
  leaveAsk: '退出「{title}」?退出后要有新的邀请才能再进来。',
38
- game: '这个房间里有 Ta 的游戏,装了 Ta 才能一起玩;在这里可以聊天。',
39
- empty: '还没有人说话。只有房间里的人能看到,中继保存的是密文。',
39
+ game: '这个群里有 Ta 的游戏,装了 Ta 才能一起玩;在这里可以聊天。',
40
+ empty: '还没有人说话。只有群里的人能看到,中继保存的是密文。',
40
41
  placeholder: '发消息',
41
42
  send: '发送',
42
43
  failed: '没发出去:{reason}',
@@ -44,11 +45,12 @@ const zh = {
44
45
  close: '关闭',
45
46
  };
46
47
  const zhTw = {
47
- title: 'Ta 房間',
48
- invalid: '這不是一個完整的 Ta 房間邀請連結,請檢查是否複製完整。',
48
+ openInTa: '在 Ta 中開啟',
49
+ title: 'Ta 群聊',
50
+ invalid: '這不是一個完整的 Ta 群聊邀請連結,請檢查是否複製完整。',
49
51
  inTa: '這是{by}在 Ta 裡的加好友連結,要在 Ta 裡開啟:用 Ta 掃碼,或把連結貼上到 Ta 的快捷開啟。',
50
52
  invited: '{by}邀請你加入',
51
- joinHint: '房主同意後,就能在這裡和大家聊天。',
53
+ joinHint: '群主同意後,就能在這裡和大家聊天。',
52
54
  name: '你的名字',
53
55
  namePlaceholder: '大家看到的名字',
54
56
  join: '申請加入',
@@ -60,16 +62,16 @@ const zhTw = {
60
62
  cancel: '取消申請',
61
63
  refused: '{by}沒有同意你加入',
62
64
  again: '再申請一次',
63
- removed: '你已被移出這個房間',
64
- closed: '這個房間已被房主解散',
65
- inviteGone: '邀請已失效,請向房主要一個新連結',
66
- own: '這是你自己的房間,請在 Ta 裡開啟。',
65
+ removed: '你已被移出這個群聊',
66
+ closed: '這個群聊已被群主解散',
67
+ inviteGone: '邀請已失效,請向群主要一個新連結',
68
+ own: '這是你自己的群聊,請在 Ta 裡開啟。',
67
69
  connecting: '連線中…',
68
70
  online: '另有 {n} 人線上',
69
71
  nobody: '其他人都不線上',
70
72
  onlineNow: '線上',
71
73
  members: '成員',
72
- owner: '房主',
74
+ owner: '群主',
73
75
  you: '我',
74
76
  guest: '網頁訪客',
75
77
  doubleOf: '{name}的分身',
@@ -77,10 +79,10 @@ const zhTw = {
77
79
  task: '任務',
78
80
  agentOf: '{name}的智慧體',
79
81
  rename: '修改我的名字',
80
- leave: '退出房間',
82
+ leave: '退出群聊',
81
83
  leaveAsk: '退出「{title}」?退出後要有新的邀請才能再進來。',
82
- game: '這個房間裡有 Ta 的遊戲,裝了 Ta 才能一起玩;在這裡可以聊天。',
83
- empty: '還沒有人說話。只有房間裡的人能看到,中繼儲存的是密文。',
84
+ game: '這個群裡有 Ta 的遊戲,裝了 Ta 才能一起玩;在這裡可以聊天。',
85
+ empty: '還沒有人說話。只有群裡的人能看到,中繼儲存的是密文。',
84
86
  placeholder: '發訊息',
85
87
  send: '傳送',
86
88
  failed: '沒發出去:{reason}',
@@ -88,8 +90,9 @@ const zhTw = {
88
90
  close: '關閉',
89
91
  };
90
92
  const en = {
91
- title: 'A room of Ta',
92
- invalid: 'This is not a whole link that invites into a room of Ta: check it was copied in full.',
93
+ openInTa: 'Open in Ta',
94
+ title: 'A group chat of Ta',
95
+ invalid: 'This is not a whole link that invites into a group chat of Ta: check it was copied in full.',
93
96
  inTa: 'This link of {by} adds them as a friend in Ta, and opens in Ta: scan it with Ta, or paste it in Quick open of Ta.',
94
97
  invited: '{by} invites you to join',
95
98
  joinHint: 'Once the owner lets you in, you chat with everyone here.',
@@ -104,10 +107,10 @@ const en = {
104
107
  cancel: 'Cancel',
105
108
  refused: '{by} did not let you in',
106
109
  again: 'Ask again',
107
- removed: 'You were taken out of this room',
108
- closed: 'This room was closed by its owner',
110
+ removed: 'You were taken out of this group chat',
111
+ closed: 'This group chat was closed by its owner',
109
112
  inviteGone: 'The invitation no longer works: ask the owner for a new link',
110
- own: 'This is a room of your own: open it in Ta.',
113
+ own: 'This is a group chat of your own: open it in Ta.',
111
114
  connecting: 'Connecting…',
112
115
  online: '{n} more online',
113
116
  nobody: 'Nobody else online',
@@ -121,10 +124,10 @@ const en = {
121
124
  task: 'Task',
122
125
  agentOf: "{name}'s agent",
123
126
  rename: 'Change my name',
124
- leave: 'Leave the room',
127
+ leave: 'Leave the group chat',
125
128
  leaveAsk: 'Leave “{title}”? You come back only by a new invitation.',
126
- game: 'This room plays a game of Ta, which takes Ta to play; here you chat.',
127
- empty: 'Nothing said yet. Only those in the room read it: the relay keeps it sealed.',
129
+ game: 'This group chat plays a game of Ta, which takes Ta to play; here you chat.',
130
+ empty: 'Nothing said yet. Only those in the group chat read it: the relay keeps it sealed.',
128
131
  placeholder: 'Message',
129
132
  send: 'Send',
130
133
  failed: 'Not sent: {reason}',
@@ -132,11 +135,12 @@ const en = {
132
135
  close: 'Close',
133
136
  };
134
137
  const ja = {
135
- title: 'Ta のルーム',
136
- invalid: 'これは Ta ルームへの完全な招待リンクではありません。全体がコピーされているか確認してください。',
138
+ openInTa: 'Ta で開く',
139
+ title: 'Ta のグループチャット',
140
+ invalid: 'これは Ta グループチャットへの完全な招待リンクではありません。全体がコピーされているか確認してください。',
137
141
  inTa: 'これは {by} さんが Ta で友だちを追加するリンクで、Ta で開きます。Ta でスキャンするか、Ta のクイックオープンにペーストしてください。',
138
142
  invited: '{by}さんがあなたを招待しています',
139
- joinHint: 'ルーム管理者が承認すると、ここでみんなとチャットできます。',
143
+ joinHint: 'グループチャット管理者が承認すると、ここでみんなとチャットできます。',
140
144
  name: 'あなたの名前',
141
145
  namePlaceholder: 'みんなに見える名前',
142
146
  join: '参加をリクエスト',
@@ -148,16 +152,16 @@ const ja = {
148
152
  cancel: 'キャンセル',
149
153
  refused: '{by}さんはあなたの参加を承認しませんでした',
150
154
  again: 'もう一度リクエスト',
151
- removed: 'このルームから削除されました',
152
- closed: 'このルームはルーム管理者に閉じられました',
153
- inviteGone: '招待が無効です。ルーム管理者に新しいリンクをリクエストしてください',
154
- own: 'これはあなた自身のルームです。Ta で開いてください。',
155
+ removed: 'このグループチャットから削除されました',
156
+ closed: 'このグループチャットはグループチャット管理者に閉じられました',
157
+ inviteGone: '招待が無効です。グループチャット管理者に新しいリンクをリクエストしてください',
158
+ own: 'これはあなた自身のグループチャットです。Ta で開いてください。',
155
159
  connecting: '接続中…',
156
160
  online: '他に {n} 人がオンライン',
157
161
  nobody: '他に誰もオンラインではありません',
158
162
  onlineNow: 'オンライン',
159
163
  members: 'メンバー',
160
- owner: 'ルーム管理者',
164
+ owner: 'グループチャット管理者',
161
165
  you: '私',
162
166
  guest: 'ウェブゲスト',
163
167
  doubleOf: '{name}の分身',
@@ -165,10 +169,10 @@ const ja = {
165
169
  task: 'タスク',
166
170
  agentOf: '{name}のエージェント',
167
171
  rename: '名前を変更',
168
- leave: 'ルームを退出',
172
+ leave: 'グループチャットを退出',
169
173
  leaveAsk: '「{title}」を退出しますか?退出後は新しい招待でのみ戻ることができます。',
170
- game: 'このルームには Ta のゲームがあり、プレイするには Ta が必要です。ここでチャットできます。',
171
- empty: 'まだ誰も話していません。ルーム内の人だけが見ることができ、リレーは暗号化されて保存されます。',
174
+ game: 'このグループチャットには Ta のゲームがあり、プレイするには Ta が必要です。ここでチャットできます。',
175
+ empty: 'まだ誰も話していません。グループ内の人だけが見ることができ、リレーは暗号化されて保存されます。',
172
176
  placeholder: 'メッセージ',
173
177
  send: '送信',
174
178
  failed: '送信されませんでした:{reason}',