@celljs/ta-relay 4.13.1 → 4.14.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 (58) hide show
  1. package/README.en.md +9 -1
  2. package/README.md +9 -1
  3. package/esm/common/index.d.ts +3 -0
  4. package/esm/common/index.js +3 -0
  5. package/esm/common/relay-friends.js +29 -4
  6. package/esm/common/relay-host-calls.d.ts +34 -0
  7. package/esm/common/relay-host-calls.js +126 -0
  8. package/esm/common/relay-hubs-connection.d.ts +9 -1
  9. package/esm/common/relay-hubs-connection.js +33 -1
  10. package/esm/common/relay-hubs-protocol.d.ts +9 -1
  11. package/esm/common/relay-hubs.d.ts +7 -0
  12. package/esm/common/relay-hubs.js +20 -3
  13. package/esm/common/relay-identity.d.ts +11 -0
  14. package/esm/common/relay-identity.js +12 -1
  15. package/esm/common/relay-protocol.d.ts +1 -1
  16. package/esm/common/relay-protocol.js +2 -1
  17. package/esm/common/relay-team.d.ts +144 -0
  18. package/esm/common/relay-team.js +200 -0
  19. package/esm/common/relay-web.d.ts +13 -0
  20. package/esm/common/relay-web.js +61 -0
  21. package/esm/join/join-i18n.d.ts +53 -0
  22. package/esm/join/join-i18n.js +103 -0
  23. package/esm/join/join.d.ts +1 -0
  24. package/esm/join/join.js +364 -0
  25. package/esm/node/relay-server.d.ts +7 -0
  26. package/esm/node/relay-server.js +28 -3
  27. package/esm/node/relay-viewer.d.ts +2 -0
  28. package/esm/node/relay-viewer.js +9 -4
  29. package/lib/common/index.d.ts +3 -0
  30. package/lib/common/index.js +3 -0
  31. package/lib/common/relay-friends.js +29 -4
  32. package/lib/common/relay-host-calls.d.ts +35 -0
  33. package/lib/common/relay-host-calls.js +130 -0
  34. package/lib/common/relay-hubs-connection.d.ts +9 -1
  35. package/lib/common/relay-hubs-connection.js +33 -1
  36. package/lib/common/relay-hubs-protocol.d.ts +9 -1
  37. package/lib/common/relay-hubs.d.ts +7 -0
  38. package/lib/common/relay-hubs.js +20 -3
  39. package/lib/common/relay-identity.d.ts +11 -0
  40. package/lib/common/relay-identity.js +12 -1
  41. package/lib/common/relay-protocol.d.ts +1 -1
  42. package/lib/common/relay-protocol.js +2 -1
  43. package/lib/common/relay-team.d.ts +145 -0
  44. package/lib/common/relay-team.js +204 -0
  45. package/lib/common/relay-web.d.ts +14 -0
  46. package/lib/common/relay-web.js +64 -0
  47. package/lib/join/join-i18n.d.ts +54 -0
  48. package/lib/join/join-i18n.js +106 -0
  49. package/lib/join/join.d.ts +2 -0
  50. package/lib/join/join.js +366 -0
  51. package/lib/node/relay-server.d.ts +7 -0
  52. package/lib/node/relay-server.js +27 -2
  53. package/lib/node/relay-viewer.d.ts +2 -0
  54. package/lib/node/relay-viewer.js +6 -1
  55. package/package.json +4 -4
  56. package/viewer/join.html +92 -0
  57. package/viewer/page.html +9 -9
  58. package/viewer/room.html +10 -10
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RelayTeamJoining = exports.RelayTeamLinkUtil = exports.RelayTeamSeal = exports.RELAY_TEAM_PACKAGE = exports.RELAY_WEB_PATH = exports.RELAY_JOIN_PATH = void 0;
4
+ const relay_bytes_1 = require("./relay-bytes");
5
+ const relay_host_calls_1 = require("./relay-host-calls");
6
+ const relay_identity_1 = require("./relay-identity");
7
+ const relay_pairing_1 = require("./relay-pairing");
8
+ /** The path of a link that invites into a Ta, on its relay: `<relay>/j#…`; opened in a browser, the page that asks to come in. */
9
+ exports.RELAY_JOIN_PATH = '/j';
10
+ /** Where the relay serves Ta's web page, for one let in from a browser (docs/design/ta-team.md 8.3): `/w/#pair=<pairing link>`. */
11
+ exports.RELAY_WEB_PATH = '/w/';
12
+ /** The package that lets people into a Ta: its host answers `ask` and `wait` of a link. */
13
+ exports.RELAY_TEAM_PACKAGE = '@celljs/ta-team';
14
+ const SEAL_INFO = 'ta-team/1 device';
15
+ /**
16
+ * What lets one asking by a link in, sealed for them alone (docs/design/ta-team.md 8.1): the link's key is shared by all
17
+ * who have the link, so the device of the one let in is sealed with ECDH between a key of the moment of each side.
18
+ */
19
+ var RelayTeamSeal;
20
+ (function (RelayTeamSeal) {
21
+ /** A pair of keys for one request: its public part goes with it. */
22
+ function keys(name) {
23
+ return relay_identity_1.RelayIdentityUtil.create(name);
24
+ }
25
+ RelayTeamSeal.keys = keys;
26
+ async function seal(box, salt, text) {
27
+ const own = await relay_identity_1.RelayIdentityUtil.create('ta');
28
+ const key = await relay_identity_1.RelayKeys.aesKey(await relay_identity_1.RelayIdentityUtil.agree(own, box, salt, SEAL_INFO));
29
+ return { box: own.box, sealed: await relay_identity_1.RelayKeys.seal(key, text) };
30
+ }
31
+ RelayTeamSeal.seal = seal;
32
+ /** Throws when it was not sealed for these keys. */
33
+ async function open(keys, answer, salt) {
34
+ const key = await relay_identity_1.RelayKeys.aesKey(await relay_identity_1.RelayIdentityUtil.agree(keys, answer.box, salt, SEAL_INFO));
35
+ return relay_identity_1.RelayKeys.open(key, answer.sealed);
36
+ }
37
+ RelayTeamSeal.open = open;
38
+ /** Whether a public key is one: what a request carries is checked before anything is sealed for it. */
39
+ function isKey(box) {
40
+ return typeof box === 'string' && /^[A-Za-z0-9_-]{80,100}$/.test(box) && relay_bytes_1.RelayBytes.fromBase64(box).length === 65;
41
+ }
42
+ RelayTeamSeal.isKey = isKey;
43
+ })(RelayTeamSeal || (exports.RelayTeamSeal = RelayTeamSeal = {}));
44
+ /** A link that invites into a Ta: `<relay>/j#v=1&h=…&d=…&k=…&o=…&r=…`; all but the relay in the fragment, which is not sent to it. */
45
+ var RelayTeamLinkUtil;
46
+ (function (RelayTeamLinkUtil) {
47
+ const ID = /^[A-Za-z0-9_-]{16,64}$/;
48
+ function format(link) {
49
+ const fragment = new URLSearchParams({ v: '1', h: link.host, d: link.device, k: link.key, o: link.owner, r: link.role });
50
+ if (link.what) {
51
+ fragment.set('w', link.what);
52
+ }
53
+ return `${link.relay.replace(/\/+$/, '')}${exports.RELAY_JOIN_PATH}#${fragment}`;
54
+ }
55
+ RelayTeamLinkUtil.format = format;
56
+ /** Undefined for text that is not such a link. */
57
+ function parse(text) {
58
+ var _a;
59
+ var _b, _c;
60
+ let url;
61
+ try {
62
+ url = new URL(text.trim());
63
+ }
64
+ catch (_d) {
65
+ return undefined;
66
+ }
67
+ const fragment = new URLSearchParams(url.hash.slice(1));
68
+ const [host, device, key] = ['h', 'd', 'k'].map(name => { var _a; return (_a = fragment.get(name)) !== null && _a !== void 0 ? _a : ''; });
69
+ if (!/^https?:$/.test(url.protocol) ||
70
+ url.pathname !== exports.RELAY_JOIN_PATH ||
71
+ fragment.get('v') !== '1' ||
72
+ !ID.test(host) ||
73
+ !ID.test(device) ||
74
+ !/^[A-Za-z0-9_-]{43}$/.test(key)) {
75
+ return undefined;
76
+ }
77
+ const what = (_a = fragment.get('w')) === null || _a === void 0 ? void 0 : _a.slice(0, 80);
78
+ return { relay: url.origin, host, device, key, owner: (_b = fragment.get('o')) !== null && _b !== void 0 ? _b : '', role: (_c = fragment.get('r')) !== null && _c !== void 0 ? _c : '', ...(what ? { what } : {}) };
79
+ }
80
+ RelayTeamLinkUtil.parse = parse;
81
+ /**
82
+ * The page of a link that signs in with `provider` for the Ta app, in a browser (docs/design/ta-team.md 17): the app
83
+ * waits for the account under `handoff`, an id of its own; all of it in the fragment.
84
+ */
85
+ function signInFor(link, provider, handoff) {
86
+ return `${format(link)}&${new URLSearchParams({ p: provider, x: handoff })}`;
87
+ }
88
+ RelayTeamLinkUtil.signInFor = signInFor;
89
+ /** The sign-in for the Ta app a link of {@link signInFor} asks, if it does. */
90
+ function handoffOf(text) {
91
+ var _a, _b;
92
+ let url;
93
+ try {
94
+ url = new URL(text.trim());
95
+ }
96
+ catch (_c) {
97
+ return undefined;
98
+ }
99
+ const fragment = new URLSearchParams(url.hash.slice(1));
100
+ const provider = (_a = fragment.get('p')) !== null && _a !== void 0 ? _a : '';
101
+ const handoff = (_b = fragment.get('x')) !== null && _b !== void 0 ? _b : '';
102
+ return /^[a-z0-9_-]{1,32}$/.test(provider) && /^[A-Za-z0-9_-]{16,64}$/.test(handoff) ? { provider, handoff } : undefined;
103
+ }
104
+ RelayTeamLinkUtil.handoffOf = handoffOf;
105
+ /** Ta's web page of the relay, signing in with a pairing link (in the fragment, which the relay is not sent). */
106
+ function web(relay, pairing) {
107
+ return `${relay.replace(/\/+$/, '')}${exports.RELAY_WEB_PATH}#${new URLSearchParams({ pair: pairing })}`;
108
+ }
109
+ RelayTeamLinkUtil.web = web;
110
+ })(RelayTeamLinkUtil || (exports.RelayTeamLinkUtil = RelayTeamLinkUtil = {}));
111
+ /**
112
+ * Asking to come into another Ta by its link (docs/design/ta-team.md 8.2, 8.3): a connection to it through the relay with
113
+ * the device of the link, which may only ask and wait for the answer; the device for the one let in comes sealed for a
114
+ * key of this request alone, then the page connects with it. The keys of a request may be kept (`keys`) to wait again
115
+ * after the page was opened again (`resume`).
116
+ */
117
+ class RelayTeamJoining {
118
+ constructor(link) {
119
+ this.closed = false;
120
+ this.calls = new relay_host_calls_1.RelayHostCalls({ relay: link.relay, host: link.host, device: link.device, key: link.key, name: link.owner }, exports.RELAY_TEAM_PACKAGE);
121
+ }
122
+ /** The keys of the request asked. */
123
+ get keys() {
124
+ return this.own;
125
+ }
126
+ /**
127
+ * How to say who one is. A Ta of before has no accounts for those asking (its link may not call `ways`): none needed;
128
+ * a Ta that cannot be reached says so when asked.
129
+ */
130
+ async ways(via) {
131
+ try {
132
+ return (await this.calls.callHost('ways', via ? { via } : {}));
133
+ }
134
+ catch (_a) {
135
+ return { providers: [], required: false };
136
+ }
137
+ }
138
+ /** Where the browser goes to sign in with a provider, and the state it comes back with to the page of the link; for the app, its handoff. */
139
+ async signIn(provider, handoff) {
140
+ return (await this.calls.callHost('signIn', { provider, ...(handoff ? { handoff } : {}) }));
141
+ }
142
+ /** The browser came back signed in for the Ta app: the Ta verifies the account and keeps it for the app. */
143
+ async signedIn(state, code) {
144
+ return (await this.calls.callHost('signedIn', { state, code }));
145
+ }
146
+ /**
147
+ * Waits for the browser to sign in for the app, asking again till it did (the account), this stops or `until`
148
+ * passes; a call that fails (the app was away while the browser was in front) is asked again.
149
+ */
150
+ async handedOff(handoff, until = Date.now() + 10 * 60000) {
151
+ while (!this.closed && Date.now() < until) {
152
+ try {
153
+ const answer = (await this.calls.callHost('handedOff', handoff));
154
+ if (answer.status === 'done' && answer.account) {
155
+ return answer.account;
156
+ }
157
+ }
158
+ catch (_a) {
159
+ await new Promise(resolve => setTimeout(resolve, 1000));
160
+ }
161
+ }
162
+ return undefined;
163
+ }
164
+ /** Asks with a name (`via` a browser, maybe signed in): the answer, or that it waits. */
165
+ async ask(name, via, signIn) {
166
+ const own = await RelayTeamSeal.keys(name || 'ta');
167
+ const answer = (await this.calls.callHost('ask', { name, box: own.box, ...(via ? { via } : {}), ...(signIn ? { signIn } : {}) }));
168
+ // The keys of a request asked: one refused, or that failed, leaves those of a request asked before.
169
+ if (answer.status !== 'refused') {
170
+ this.own = own;
171
+ }
172
+ return answer;
173
+ }
174
+ /** Goes on with a request asked before, with its keys. */
175
+ resume(keys) {
176
+ this.own = keys;
177
+ }
178
+ /** Waits for the answer to a request, asking again till it comes or this stops. */
179
+ async wait(request) {
180
+ for (;;) {
181
+ if (this.closed) {
182
+ return { status: 'gone' };
183
+ }
184
+ const answer = (await this.calls.callHost('wait', request));
185
+ if (answer.status !== 'waiting') {
186
+ return answer;
187
+ }
188
+ }
189
+ }
190
+ /** The pairing link of the device sealed in an answer. */
191
+ async pairing(request, answer) {
192
+ if (!this.own) {
193
+ throw new Error('Ask first.');
194
+ }
195
+ const device = JSON.parse(await RelayTeamSeal.open(this.own, answer, request));
196
+ return relay_pairing_1.RelayPairingUtil.link(relay_pairing_1.RelayPairingUtil.parse(relay_pairing_1.RelayPairingUtil.link(device)));
197
+ }
198
+ close() {
199
+ this.closed = true;
200
+ this.calls.close();
201
+ }
202
+ }
203
+ exports.RelayTeamJoining = RelayTeamJoining;
204
+ //# sourceMappingURL=relay-team.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Ta's web page as the relay serves it under RELAY_WEB_PATH (docs/design/ta-team.md 8.3): the files of the page of
3
+ * `ta serve` (`apps/ta/dist/public`), its base made that path, for one let in from a browser; it signs in with the
4
+ * pairing link of its fragment and reaches the Ta through the relay, end to end, as the Ta app does.
5
+ */
6
+ export declare namespace RelayWebUtil {
7
+ /** The page, its base the path it is served at. */
8
+ function index(html: string): string;
9
+ /** The file of the page a path asks for, relative to its directory; undefined for none (outside it, or not a plain path). */
10
+ function file(path: string): string | undefined;
11
+ /** How a file of the page is answered: the page never framed nor cached old, the files with hashed names kept long. */
12
+ function headers(file: string): Record<string, string>;
13
+ }
14
+ //# sourceMappingURL=relay-web.d.ts.map
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RelayWebUtil = void 0;
4
+ const relay_team_1 = require("./relay-team");
5
+ const TYPES = {
6
+ html: 'text/html; charset=utf-8',
7
+ js: 'text/javascript; charset=utf-8',
8
+ mjs: 'text/javascript; charset=utf-8',
9
+ css: 'text/css; charset=utf-8',
10
+ json: 'application/json',
11
+ webmanifest: 'application/manifest+json',
12
+ svg: 'image/svg+xml',
13
+ png: 'image/png',
14
+ jpg: 'image/jpeg',
15
+ webp: 'image/webp',
16
+ ico: 'image/x-icon',
17
+ woff2: 'font/woff2',
18
+ woff: 'font/woff',
19
+ ttf: 'font/ttf',
20
+ wasm: 'application/wasm',
21
+ txt: 'text/plain; charset=utf-8',
22
+ };
23
+ /**
24
+ * Ta's web page as the relay serves it under RELAY_WEB_PATH (docs/design/ta-team.md 8.3): the files of the page of
25
+ * `ta serve` (`apps/ta/dist/public`), its base made that path, for one let in from a browser; it signs in with the
26
+ * pairing link of its fragment and reaches the Ta through the relay, end to end, as the Ta app does.
27
+ */
28
+ var RelayWebUtil;
29
+ (function (RelayWebUtil) {
30
+ /** The page, its base the path it is served at. */
31
+ function index(html) {
32
+ return html.replace(/<base href="\/">/, `<base href="${relay_team_1.RELAY_WEB_PATH}">`);
33
+ }
34
+ RelayWebUtil.index = index;
35
+ /** The file of the page a path asks for, relative to its directory; undefined for none (outside it, or not a plain path). */
36
+ function file(path) {
37
+ if (!path.startsWith(relay_team_1.RELAY_WEB_PATH)) {
38
+ return undefined;
39
+ }
40
+ const rest = path.slice(relay_team_1.RELAY_WEB_PATH.length) || 'index.html';
41
+ const parts = rest.split('/');
42
+ if (parts.some(part => !part || part === '.' || part === '..' || !/^[\w.@-]+$/.test(part))) {
43
+ return undefined;
44
+ }
45
+ return rest;
46
+ }
47
+ RelayWebUtil.file = file;
48
+ /** How a file of the page is answered: the page never framed nor cached old, the files with hashed names kept long. */
49
+ function headers(file) {
50
+ var _a;
51
+ const type = (_a = TYPES[file.slice(file.lastIndexOf('.') + 1).toLowerCase()]) !== null && _a !== void 0 ? _a : 'application/octet-stream';
52
+ const page = file === 'index.html';
53
+ return {
54
+ 'content-type': type,
55
+ // no-transform: a CDN in front (Cloudflare's analytics) puts no script of its own into the page, which keeps keys.
56
+ 'cache-control': file.startsWith('assets/') ? 'public, max-age=31536000, immutable, no-transform' : 'no-cache, no-transform',
57
+ 'x-content-type-options': 'nosniff',
58
+ 'referrer-policy': 'no-referrer',
59
+ ...(page ? { 'x-frame-options': 'DENY' } : {}),
60
+ };
61
+ }
62
+ RelayWebUtil.headers = headers;
63
+ })(RelayWebUtil || (exports.RelayWebUtil = RelayWebUtil = {}));
64
+ //# sourceMappingURL=relay-web.js.map
@@ -0,0 +1,54 @@
1
+ declare const zh: {
2
+ title: string;
3
+ invalid: string;
4
+ invited: string;
5
+ role: string;
6
+ what: string;
7
+ hint: string;
8
+ name: string;
9
+ namePlaceholder: string;
10
+ join: string;
11
+ joining: string;
12
+ keep: string;
13
+ haveTa: string;
14
+ waiting: string;
15
+ waitingHint: string;
16
+ cancel: string;
17
+ connecting: string;
18
+ refused: string;
19
+ again: string;
20
+ gone: string;
21
+ app: string;
22
+ joined: string;
23
+ open: string;
24
+ failed: string;
25
+ unreachable: string;
26
+ or: string;
27
+ signInWith: string;
28
+ signingIn: string;
29
+ checking: string;
30
+ signInFailed: string;
31
+ needAccount: string;
32
+ keepAccount: string;
33
+ 'provider.wechat': string;
34
+ handedOff: string;
35
+ backToApp: string;
36
+ 'role.admin': string;
37
+ 'role.collaborator': string;
38
+ 'role.viewer': string;
39
+ 'role.guest': string;
40
+ };
41
+ export type JoinText = keyof typeof zh;
42
+ export declare namespace JoinI18n {
43
+ /** A provider in the words of the page: WeChat is 微信 in Chinese. */
44
+ function provider(one: {
45
+ id: string;
46
+ name: string;
47
+ }): string;
48
+ /** A role of those that come with Ta in the words of the page; one of the owner's own as they named it. */
49
+ function role(name: string): string;
50
+ const chinese: boolean;
51
+ function t(id: JoinText, values?: Record<string, string | number>): string;
52
+ }
53
+ export {};
54
+ //# sourceMappingURL=join-i18n.d.ts.map
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JoinI18n = void 0;
4
+ const zh = {
5
+ title: '加入 Ta',
6
+ invalid: '这不是一个完整的 Ta 邀请链接,请检查是否复制完整。',
7
+ invited: '{owner}邀请你一起用 Ta',
8
+ role: '角色:{role}',
9
+ what: '对方分享给你:{what}',
10
+ hint: '加入后你在这个浏览器里使用{owner}的 Ta,能看什么、做什么由对方给你的角色决定。',
11
+ name: '你的名字',
12
+ namePlaceholder: '对方看到的名字',
13
+ join: '申请加入',
14
+ joining: '正在申请…',
15
+ keep: '进入用的钥匙只保存在这个浏览器里;清除浏览器数据后要重新申请。',
16
+ haveTa: '装了 Ta?在 Ta 里打开这个链接,用起来更顺手。',
17
+ waiting: '已向{owner}申请',
18
+ waitingHint: '等对方同意。可以先关掉页面,之后在这个浏览器里再打开这个链接。',
19
+ cancel: '取消申请',
20
+ connecting: '对方同意了,正在进入…',
21
+ refused: '{owner}没有同意你加入',
22
+ again: '再申请一次',
23
+ gone: '这个邀请已失效,请向对方要一个新链接',
24
+ app: '这个邀请给的是管理员角色,要在 Ta 应用里打开:从浏览器加入的人不能当管理员。',
25
+ joined: '你已经加入了{owner}的 Ta',
26
+ open: '打开',
27
+ failed: '没能申请:{reason}',
28
+ unreachable: '{owner}的 Ta 现在连不上,等对方的电脑开着时再试。',
29
+ or: '不登录就是匿名加入,对方看到的是你填的名字。也可以:',
30
+ signInWith: '用{provider}登录',
31
+ signingIn: '正在打开登录…',
32
+ checking: '正在确认你的身份…',
33
+ signInFailed: '没有登录成功:{reason}',
34
+ needAccount: '这个邀请给的是管理员角色,从浏览器加入要先用账号登录,对方会看到你是谁。',
35
+ keepAccount: '用账号登录后,换个浏览器再打开这个链接也是同一个人。进入用的钥匙只保存在这个浏览器里。',
36
+ 'provider.wechat': '微信',
37
+ handedOff: '已用 {who} 登录',
38
+ backToApp: '回到 Ta 应用继续申请加入{owner}的 Ta,这个页面可以关掉了。',
39
+ 'role.admin': '管理员',
40
+ 'role.collaborator': '协作者',
41
+ 'role.viewer': '只读',
42
+ 'role.guest': '访客',
43
+ };
44
+ const en = {
45
+ title: 'Join a Ta',
46
+ invalid: 'This is not a whole link that invites into a Ta: check that it was copied in full.',
47
+ invited: '{owner} invites you to work in their Ta',
48
+ role: 'Role: {role}',
49
+ what: 'Shared with you: {what}',
50
+ hint: "Once in, you use {owner}'s Ta in this browser; what you see and do is the role they give you.",
51
+ name: 'Your name',
52
+ namePlaceholder: 'The name they see',
53
+ join: 'Ask to join',
54
+ joining: 'Asking…',
55
+ keep: 'The key you come in with stays in this browser alone; after clearing its data you ask again.',
56
+ haveTa: 'Have Ta? Open this link in Ta instead.',
57
+ waiting: 'Asked {owner}',
58
+ waitingHint: 'They let you in, or not. You may close this page and open the link again in this browser later.',
59
+ cancel: 'Cancel',
60
+ connecting: 'They let you in; coming in…',
61
+ refused: '{owner} did not let you in',
62
+ again: 'Ask again',
63
+ gone: 'This invitation no longer works: ask for a new link',
64
+ app: 'This invitation gives a role that manages members, which is taken in the Ta app: open it there.',
65
+ joined: "You are in {owner}'s Ta already",
66
+ open: 'Open',
67
+ failed: 'Not asked: {reason}',
68
+ unreachable: "{owner}'s Ta cannot be reached now: try again while their computer is on.",
69
+ or: 'Without signing in you are anonymous, by the name you give. Or:',
70
+ signInWith: 'Sign in with {provider}',
71
+ signingIn: 'Opening the sign-in…',
72
+ checking: 'Checking who you are…',
73
+ signInFailed: 'Not signed in: {reason}',
74
+ needAccount: 'This invitation gives a role that manages members: from a browser, sign in with an account first, and they see who you are.',
75
+ keepAccount: 'Signed in, you are the same person from any browser that opens this link. The key you come in with stays in this browser.',
76
+ 'provider.wechat': 'WeChat',
77
+ handedOff: 'Signed in as {who}',
78
+ backToApp: "Go back to the Ta app to ask to join {owner}'s Ta; you may close this page.",
79
+ 'role.admin': 'Admin',
80
+ 'role.collaborator': 'Collaborator',
81
+ 'role.viewer': 'Viewer',
82
+ 'role.guest': 'Guest',
83
+ };
84
+ var JoinI18n;
85
+ (function (JoinI18n) {
86
+ /** A provider in the words of the page: WeChat is 微信 in Chinese. */
87
+ function provider(one) {
88
+ const key = `provider.${one.id}`;
89
+ const name = key in zh ? t(key) : one.name;
90
+ // Latin among Chinese has a space on each side: 用 GitHub 登录, 用企业账号登录.
91
+ return JoinI18n.chinese && /^[\x20-\x7e]+$/.test(name) ? ` ${name} ` : name;
92
+ }
93
+ JoinI18n.provider = provider;
94
+ /** A role of those that come with Ta in the words of the page; one of the owner's own as they named it. */
95
+ function role(name) {
96
+ const key = `role.${name}`;
97
+ return key in zh ? t(key) : name;
98
+ }
99
+ JoinI18n.role = role;
100
+ JoinI18n.chinese = typeof navigator !== 'undefined' && /^zh\b/i.test(navigator.language);
101
+ function t(id, values = {}) {
102
+ return (JoinI18n.chinese ? zh : en)[id].replace(/\{(\w+)\}/g, (_, name) => { var _a; return String((_a = values[name]) !== null && _a !== void 0 ? _a : ''); });
103
+ }
104
+ JoinI18n.t = t;
105
+ })(JoinI18n || (exports.JoinI18n = JoinI18n = {}));
106
+ //# sourceMappingURL=join-i18n.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=join.d.ts.map