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