@vitrinka/web 0.9.1 → 0.9.2
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/CHANGELOG.md +36 -0
- package/README.md +9 -2
- package/build/recorder/version.d.ts +2 -2
- package/build/recorder/version.js +1 -1
- package/build/report/face.d.ts +14 -0
- package/build/report/face.js +18 -0
- package/build/report/reader.d.ts +19 -2
- package/build/report/reader.js +32 -3
- package/build/report/widget.d.ts +29 -6
- package/build/report/widget.js +91 -31
- package/build/report/wire.d.ts +37 -3
- package/build/report/wire.js +60 -11
- package/build/report-widget.mjs +5 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @vitrinka/web
|
|
2
2
|
|
|
3
|
+
## 0.9.2
|
|
4
|
+
|
|
5
|
+
- **A linked member co-owns what they report.** When this browser holds a
|
|
6
|
+
vitrinka member link for the widget's `base`, Report a problem proves it
|
|
7
|
+
to the server: the link's token rides in the body of the report
|
|
8
|
+
(`memberToken` on `POST /api/v1/reports`) and of the reporter session
|
|
9
|
+
(`POST /api/v1/report/session {token, memberToken}`), so the member owns
|
|
10
|
+
the report beside the reporter and finds it in **My reports**. Your
|
|
11
|
+
`vkb_` key stays the bearer. A link minted on another vitrinka is never
|
|
12
|
+
sent, and neither is a `vkr_` key your build passes. With a reporter your
|
|
13
|
+
server signed and a linked member, My reports lists what vitrinka returns
|
|
14
|
+
for the two: the reporter's reports and the member's. Without a signed
|
|
15
|
+
reporter there is still no session, and My reports stays this browser's
|
|
16
|
+
list.
|
|
17
|
+
- **A link vitrinka refuses never costs the report.** Either call may come
|
|
18
|
+
back with `memberError`: the link was revoked, belongs to another
|
|
19
|
+
workspace, or its person is no longer a member. The report files anyway,
|
|
20
|
+
and the console says why once. A revoked link, or one whose person left,
|
|
21
|
+
is forgotten, as a link a session door answers 401 is. A link for another
|
|
22
|
+
workspace stays.
|
|
23
|
+
- **Linking, unlinking or relinking opens a fresh session.** The reporter
|
|
24
|
+
session and the My reports list it read were held for your token alone.
|
|
25
|
+
They are now held for your token and the member link together, so
|
|
26
|
+
**Unlink** (cs **Odpojit**), a new link, or a change in another tab drops
|
|
27
|
+
both, a list still loading included, and an open My reports reloads.
|
|
28
|
+
|
|
29
|
+
Upgrading:
|
|
30
|
+
|
|
31
|
+
- **The server side ships in vitrinka first.** An older vitrinka refuses
|
|
32
|
+
the unknown `memberToken` by name; the widget then sends the report, or
|
|
33
|
+
opens the session, again without it, once, as 0.8.0 does for `type`. The
|
|
34
|
+
link is ignored: the report files as the reporter's alone and My reports
|
|
35
|
+
reads as before. The widget now reads that refusal for the field it
|
|
36
|
+
names, never for a field the server lists as accepted, so the reporter's
|
|
37
|
+
`type` stays.
|
|
38
|
+
|
|
3
39
|
## 0.9.1
|
|
4
40
|
|
|
5
41
|
- **The button keeps its name with a shortcut set.** 0.9.0's default
|
package/README.md
CHANGED
|
@@ -432,7 +432,10 @@ portal**. A list opens inside the card with ← back.
|
|
|
432
432
|
/api/v1/report/session`, renewed when it lapses) and reads `GET
|
|
433
433
|
/api/v1/report/mine` with it (header `X-Vitrinka-Reporter`): each report
|
|
434
434
|
with its step — Received, Planned, In progress, Fixed, Done — linked to
|
|
435
|
-
its page. The `vkb_` key alone reads nothing.
|
|
435
|
+
its page. The `vkb_` key alone reads nothing. When the browser also holds
|
|
436
|
+
a member link for the widget's `base` (below), the trade proves it too,
|
|
437
|
+
and the list is what vitrinka returns for the two: the reporter's
|
|
438
|
+
reports and the member's.
|
|
436
439
|
- **An asserted email, or anonymous**: this browser's own sends — the last
|
|
437
440
|
20 for this vitrinka and this site, filed or "Waiting for approval",
|
|
438
441
|
marked "Sent from this browser" (`localStorage`). A signed reporter gets
|
|
@@ -444,7 +447,11 @@ account from the account popover with the pill's flow: a short code,
|
|
|
444
447
|
browser's own `vkr_` token, kept where the pill keeps its link
|
|
445
448
|
(`vitrinka.recorder.link`, with the `base` it was minted on), so linking
|
|
446
449
|
here links the pill on this site and **Unlink** forgets it for both.
|
|
447
|
-
Reporters never need it: your token vouches for them.
|
|
450
|
+
Reporters never need it: your token vouches for them. Every report sent
|
|
451
|
+
from a linked browser proves the link (`memberToken` in the body, your
|
|
452
|
+
`vkb_` key still the bearer), so the member co-owns it and finds it in My
|
|
453
|
+
reports. A link vitrinka refuses never stops the report: one revoked, or
|
|
454
|
+
whose person is no longer a member, is forgotten.
|
|
448
455
|
|
|
449
456
|
**The face switch** (npm entry only). A browser holding a member link for
|
|
450
457
|
the widget's `base` gets **Record** and **Recent recordings** in the ⋯
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Sent as `meta.recorder` and written as `data-vitrinka-page`; bumped with the package version. */
|
|
2
|
-
export declare const RECORDER_VERSION = "0.9.
|
|
3
|
-
export declare const RECORDER_ID = "web/0.9.
|
|
2
|
+
export declare const RECORDER_VERSION = "0.9.2";
|
|
3
|
+
export declare const RECORDER_ID = "web/0.9.2";
|
package/build/report/face.d.ts
CHANGED
|
@@ -7,6 +7,20 @@ export declare const FACE_KEY = "vitrinka.report.face";
|
|
|
7
7
|
* workspace `base` addresses (any, for a bare origin).
|
|
8
8
|
*/
|
|
9
9
|
export declare function memberLinked(base: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The member link a report and a reporter session prove to `base` (vt-8020):
|
|
12
|
+
* the stored link's own token wherever `memberLinked` holds, else ''. Never a
|
|
13
|
+
* link minted on another vitrinka, and never a `vkr_` key the host configured
|
|
14
|
+
* — that is a build's, kept in the recorder's config, not in the link.
|
|
15
|
+
*/
|
|
16
|
+
export declare function memberTokenFor(base: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* vitrinka's `memberError` says the link is gone for good — revoked, or its
|
|
19
|
+
* person no longer a member — rather than only not good here (another
|
|
20
|
+
* workspace). A gone link is forgotten as a 401 on a session door forgets it;
|
|
21
|
+
* any other answer keeps it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function memberLinkGone(err: string): boolean;
|
|
10
24
|
/** The face this browser last picked here; null when it never picked (or storage is blocked). */
|
|
11
25
|
export declare function rememberedFace(): ReportFace | null;
|
|
12
26
|
export declare function rememberFace(face: ReportFace): void;
|
package/build/report/face.js
CHANGED
|
@@ -46,6 +46,24 @@ export function memberLinked(base) {
|
|
|
46
46
|
return false; // not a URL: no link can be for it
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* The member link a report and a reporter session prove to `base` (vt-8020):
|
|
51
|
+
* the stored link's own token wherever `memberLinked` holds, else ''. Never a
|
|
52
|
+
* link minted on another vitrinka, and never a `vkr_` key the host configured
|
|
53
|
+
* — that is a build's, kept in the recorder's config, not in the link.
|
|
54
|
+
*/
|
|
55
|
+
export function memberTokenFor(base) {
|
|
56
|
+
return memberLinked(base) ? (readLink()?.token ?? '') : '';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* vitrinka's `memberError` says the link is gone for good — revoked, or its
|
|
60
|
+
* person no longer a member — rather than only not good here (another
|
|
61
|
+
* workspace). A gone link is forgotten as a 401 on a session door forgets it;
|
|
62
|
+
* any other answer keeps it.
|
|
63
|
+
*/
|
|
64
|
+
export function memberLinkGone(err) {
|
|
65
|
+
return /revoked|not[\s_-]?(?:a[\s_-])?member|no longer a member/i.test(err);
|
|
66
|
+
}
|
|
49
67
|
/** The face this browser last picked here; null when it never picked (or storage is blocked). */
|
|
50
68
|
export function rememberedFace() {
|
|
51
69
|
const v = store()?.getItem(FACE_KEY);
|
package/build/report/reader.d.ts
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
* publishable key: the host's signed token is traded once for a short-lived
|
|
4
4
|
* reporter session, which then lists the reporter's reports and their news.
|
|
5
5
|
* A `vkb_` key alone reads nothing — every list call carries the session.
|
|
6
|
+
* A browser linked to a vitrinka member on the widget's base proves the link
|
|
7
|
+
* in the trade too (`memberToken`, vt-8020): the session then lists the
|
|
8
|
+
* reporter's reports and the member's, as the server joins them.
|
|
6
9
|
*
|
|
7
|
-
* POST /api/v1/report/session {token} → {reporter, session, expiresAt, portalUrl?}
|
|
10
|
+
* POST /api/v1/report/session {token, memberToken?} → {reporter, session, expiresAt, portalUrl?, memberError?}
|
|
8
11
|
* GET /api/v1/report/mine?cursor= X-Vitrinka-Reporter → {reports, nextCursor}
|
|
9
12
|
* GET /api/v1/report/updates?cursor= X-Vitrinka-Reporter → {updates, nextCursor}
|
|
10
13
|
*/
|
|
@@ -21,6 +24,8 @@ export interface ReporterSession {
|
|
|
21
24
|
expiresAt: string;
|
|
22
25
|
/** The project's reporter portal, when one is bound. */
|
|
23
26
|
portalUrl?: string;
|
|
27
|
+
/** The server did not take the member link the trade carried (revoked, another workspace, no longer a member); the session is the reporter's alone. */
|
|
28
|
+
memberError?: string;
|
|
24
29
|
}
|
|
25
30
|
/** One of the reporter's reports, as the portal projects it. */
|
|
26
31
|
export interface MyReport {
|
|
@@ -36,7 +41,19 @@ export interface MyReports {
|
|
|
36
41
|
reports: MyReport[];
|
|
37
42
|
nextCursor?: string;
|
|
38
43
|
}
|
|
39
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Trade the host's token for a reporter session, proving `memberToken` beside
|
|
46
|
+
* it when there is one. A vitrinka older than the field refuses it by name:
|
|
47
|
+
* the session is the reporter's alone then, never lost — the trade goes again
|
|
48
|
+
* without it, once.
|
|
49
|
+
*/
|
|
50
|
+
export declare function openSession(target: ApiTarget, token: string, memberToken?: string): Promise<ReporterSession>;
|
|
51
|
+
/**
|
|
52
|
+
* Whose session a widget holds: the host's signed token and the member link
|
|
53
|
+
* the trade proved — '' without a host token, which opens none. Linking,
|
|
54
|
+
* unlinking or relinking is another key, so another session and list.
|
|
55
|
+
*/
|
|
56
|
+
export declare function sessionKey(hostToken: string, memberToken: string): string;
|
|
40
57
|
/** Still good for at least a minute more. */
|
|
41
58
|
export declare function sessionLive(s: ReporterSession | null, now?: number): s is ReporterSession;
|
|
42
59
|
export declare function listMine(target: ApiTarget, session: string, cursor?: string): Promise<MyReports>;
|
package/build/report/reader.js
CHANGED
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
* publishable key: the host's signed token is traded once for a short-lived
|
|
4
4
|
* reporter session, which then lists the reporter's reports and their news.
|
|
5
5
|
* A `vkb_` key alone reads nothing — every list call carries the session.
|
|
6
|
+
* A browser linked to a vitrinka member on the widget's base proves the link
|
|
7
|
+
* in the trade too (`memberToken`, vt-8020): the session then lists the
|
|
8
|
+
* reporter's reports and the member's, as the server joins them.
|
|
6
9
|
*
|
|
7
|
-
* POST /api/v1/report/session {token} → {reporter, session, expiresAt, portalUrl?}
|
|
10
|
+
* POST /api/v1/report/session {token, memberToken?} → {reporter, session, expiresAt, portalUrl?, memberError?}
|
|
8
11
|
* GET /api/v1/report/mine?cursor= X-Vitrinka-Reporter → {reports, nextCursor}
|
|
9
12
|
* GET /api/v1/report/updates?cursor= X-Vitrinka-Reporter → {updates, nextCursor}
|
|
10
13
|
*/
|
|
11
14
|
import { VitrinkaApiError } from '../recorder/api';
|
|
15
|
+
import { refusedField } from './wire';
|
|
12
16
|
async function call(method, path, target, body, session) {
|
|
13
17
|
const res = await fetch(target.url + path, {
|
|
14
18
|
method,
|
|
@@ -26,8 +30,33 @@ async function call(method, path, target, body, session) {
|
|
|
26
30
|
throw new VitrinkaApiError(`${method} ${path} → ${res.status}: ${text}`, res.status);
|
|
27
31
|
return (text ? JSON.parse(text) : {});
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Trade the host's token for a reporter session, proving `memberToken` beside
|
|
35
|
+
* it when there is one. A vitrinka older than the field refuses it by name:
|
|
36
|
+
* the session is the reporter's alone then, never lost — the trade goes again
|
|
37
|
+
* without it, once.
|
|
38
|
+
*/
|
|
39
|
+
export async function openSession(target, token, memberToken = '') {
|
|
40
|
+
const path = '/api/v1/report/session';
|
|
41
|
+
if (!memberToken)
|
|
42
|
+
return call('POST', path, target, { token });
|
|
43
|
+
try {
|
|
44
|
+
return await call('POST', path, target, { token, memberToken });
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
if (refusedField(e) !== 'memberToken')
|
|
48
|
+
throw e;
|
|
49
|
+
console.warn('vitrinka: this server takes no member link yet — the reporter session opens without it');
|
|
50
|
+
return call('POST', path, target, { token });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Whose session a widget holds: the host's signed token and the member link
|
|
55
|
+
* the trade proved — '' without a host token, which opens none. Linking,
|
|
56
|
+
* unlinking or relinking is another key, so another session and list.
|
|
57
|
+
*/
|
|
58
|
+
export function sessionKey(hostToken, memberToken) {
|
|
59
|
+
return hostToken ? JSON.stringify([hostToken, memberToken]) : '';
|
|
31
60
|
}
|
|
32
61
|
/** Still good for at least a minute more. */
|
|
33
62
|
export function sessionLive(s, now = Date.now()) {
|
package/build/report/widget.d.ts
CHANGED
|
@@ -82,9 +82,11 @@ export declare class ReportWidget {
|
|
|
82
82
|
/** Swaps this widget for the recorder pill; set only for a linked member (setRecordSwitch). */
|
|
83
83
|
private recordSwitch;
|
|
84
84
|
private menu;
|
|
85
|
-
/** The reporter session the host's signed token was traded for (vt-8020 D4), and that token. */
|
|
85
|
+
/** The reporter session the host's signed token was traded for (vt-8020 D4), and whose it is: that token and the member link it proved (reader.ts sessionKey). */
|
|
86
86
|
private session;
|
|
87
|
-
private
|
|
87
|
+
private sessionKey;
|
|
88
|
+
/** The member link this widget last saw for its base ('' none): a change is another person's session (linkChanged). */
|
|
89
|
+
private linkSeen;
|
|
88
90
|
/** The vitrinka member this browser is linked to (vt-8020 D3), read with the link's own token. */
|
|
89
91
|
private member;
|
|
90
92
|
private mine;
|
|
@@ -131,14 +133,35 @@ export declare class ReportWidget {
|
|
|
131
133
|
private show;
|
|
132
134
|
private target;
|
|
133
135
|
private toggleMenu;
|
|
134
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* The host's signed token traded once for a reporter session, with the
|
|
138
|
+
* member link beside it when this browser holds one for the base; renewed
|
|
139
|
+
* only when it is about to lapse. Answers the session in force.
|
|
140
|
+
*/
|
|
135
141
|
private refreshWho;
|
|
142
|
+
/** Whose session the widget should hold now (reader.ts sessionKey). */
|
|
143
|
+
private whoKey;
|
|
136
144
|
/**
|
|
137
|
-
* identify()
|
|
138
|
-
* the previous person never stay on screen for the
|
|
139
|
-
* reports reloads for whoever is here now.
|
|
145
|
+
* identify(), the page-wide identity or the member link moved: a session
|
|
146
|
+
* and a list read for the previous person never stay on screen for the
|
|
147
|
+
* next one, and an open My reports reloads for whoever is here now.
|
|
140
148
|
*/
|
|
141
149
|
private whoChanged;
|
|
150
|
+
/**
|
|
151
|
+
* The stored link moved (watchMemberLink: Unlink, the link flow, another
|
|
152
|
+
* tab, a refused link forgotten). Only a change of this base's link counts;
|
|
153
|
+
* the recorder's other notifications pass. The member the popover named was
|
|
154
|
+
* the previous link's: an open card reads the new link's (refreshMember).
|
|
155
|
+
*/
|
|
156
|
+
private linkChanged;
|
|
157
|
+
/**
|
|
158
|
+
* vitrinka did not take the member link a report or a session proved
|
|
159
|
+
* (`memberError`): they stand as the reporter's alone. A link revoked, or
|
|
160
|
+
* whose person is no longer a member, is forgotten as a 401 on a session
|
|
161
|
+
* door forgets it (recorder/link.ts) — only the one that was sent, never a
|
|
162
|
+
* link made since. Any other answer keeps it.
|
|
163
|
+
*/
|
|
164
|
+
private memberRefused;
|
|
142
165
|
private refreshMember;
|
|
143
166
|
private openReports;
|
|
144
167
|
private loadReports;
|
package/build/report/widget.js
CHANGED
|
@@ -33,17 +33,18 @@ import { clearLink, defaultLinkLabel, readLink, storeLink } from '../recorder/co
|
|
|
33
33
|
import { readRecents } from '../recorder/recents';
|
|
34
34
|
import { createHudHost, createSheetHost, insideHud, sheetTarget } from '../recorder/hud/host';
|
|
35
35
|
import { listen } from '../recorder/hud/listen';
|
|
36
|
+
import { forgetLink } from '../recorder/link';
|
|
36
37
|
import { RECORDER_VERSION } from '../recorder/version';
|
|
37
38
|
import { admit, DEFAULT_ATTACHMENT_CAPS, formatBytes, pastedName, typesLabel } from './attachments';
|
|
38
39
|
import { cornerToward, DRAG_THRESHOLD, nearestCorner, readDock, saveDock } from './drag';
|
|
39
|
-
import { memberLinked, rememberDisplayMode } from './face';
|
|
40
|
+
import { memberLinked, memberLinkGone, memberTokenFor, rememberDisplayMode, watchMemberLink } from './face';
|
|
40
41
|
import { acquireEngine, releaseEngine } from './engine';
|
|
41
42
|
import { browserLocale, parseLocale, REPORT_KINDS, strings } from './i18n';
|
|
42
43
|
import { normalizeIdentity, onSharedIdentity, sharedIdentity } from './identity';
|
|
43
44
|
import { keybindAria, keybindLabel, loadKeybind, matchesKeybind, readKeybindPress, saveKeybind, watchKeybind } from './keybind';
|
|
44
45
|
import { arrowEnds, arrowHead, isMark, rectBetween, renumber, toWire, } from './markers';
|
|
45
46
|
import { coachSide, cornerRect, pickCorner } from './place';
|
|
46
|
-
import { listMine, openSession, sessionLive } from './reader';
|
|
47
|
+
import { listMine, openSession, sessionKey, sessionLive } from './reader';
|
|
47
48
|
import { noteSent, readSent } from './sent';
|
|
48
49
|
import { COACH_KEY, readCoach, readSize, SIZE_KEY, SIZE_SCALE, SIZES, techDetails, writePref } from './settings';
|
|
49
50
|
import { REPORT_CSS } from './styles';
|
|
@@ -477,9 +478,11 @@ export class ReportWidget {
|
|
|
477
478
|
/** Swaps this widget for the recorder pill; set only for a linked member (setRecordSwitch). */
|
|
478
479
|
recordSwitch = null;
|
|
479
480
|
menu = null;
|
|
480
|
-
/** The reporter session the host's signed token was traded for (vt-8020 D4), and that token. */
|
|
481
|
+
/** The reporter session the host's signed token was traded for (vt-8020 D4), and whose it is: that token and the member link it proved (reader.ts sessionKey). */
|
|
481
482
|
session = null;
|
|
482
|
-
|
|
483
|
+
sessionKey = '';
|
|
484
|
+
/** The member link this widget last saw for its base ('' none): a change is another person's session (linkChanged). */
|
|
485
|
+
linkSeen = '';
|
|
483
486
|
/** The vitrinka member this browser is linked to (vt-8020 D3), read with the link's own token. */
|
|
484
487
|
member = null;
|
|
485
488
|
mine = { rows: [], state: 'ok' };
|
|
@@ -775,6 +778,7 @@ export class ReportWidget {
|
|
|
775
778
|
on(e.accPortal, 'click', fromMenu(() => undefined));
|
|
776
779
|
on(e.accLink, 'click', fromMenu(() => this.startLinkFlow()));
|
|
777
780
|
on(e.accUnlink, 'click', () => {
|
|
781
|
+
// clearLink notifies: linkChanged drops the session and the list read with the link, a response in flight included.
|
|
778
782
|
clearLink();
|
|
779
783
|
this.member = null;
|
|
780
784
|
this.paint();
|
|
@@ -911,6 +915,9 @@ export class ReportWidget {
|
|
|
911
915
|
this.paint();
|
|
912
916
|
}));
|
|
913
917
|
this.offs.push(onSharedIdentity(() => this.whoChanged()));
|
|
918
|
+
// Linked, unlinked or relinked — here, in the link flow, or in another tab: the session belongs to the pairing it proved.
|
|
919
|
+
this.linkSeen = memberTokenFor(this.opts.base);
|
|
920
|
+
this.offs.push(watchMemberLink(() => this.linkChanged()));
|
|
914
921
|
// The recorder took the page's capture over: stop saying minutes are attached.
|
|
915
922
|
if (this.engine)
|
|
916
923
|
this.offs.push(this.engine.onChange(() => this.paint()));
|
|
@@ -975,46 +982,88 @@ export class ReportWidget {
|
|
|
975
982
|
const first = pop?.querySelector('button:not([hidden]), a:not([hidden])');
|
|
976
983
|
first?.focus();
|
|
977
984
|
}
|
|
978
|
-
/**
|
|
985
|
+
/**
|
|
986
|
+
* The host's signed token traded once for a reporter session, with the
|
|
987
|
+
* member link beside it when this browser holds one for the base; renewed
|
|
988
|
+
* only when it is about to lapse. Answers the session in force.
|
|
989
|
+
*/
|
|
979
990
|
async refreshWho() {
|
|
980
|
-
const
|
|
981
|
-
if (!
|
|
991
|
+
const token = this.whoToken();
|
|
992
|
+
if (!token) {
|
|
982
993
|
this.session = null;
|
|
983
|
-
this.
|
|
994
|
+
this.sessionKey = '';
|
|
984
995
|
return null;
|
|
985
996
|
}
|
|
986
|
-
|
|
997
|
+
const member = memberTokenFor(this.opts.base);
|
|
998
|
+
const key = sessionKey(token, member);
|
|
999
|
+
if (this.sessionKey === key && sessionLive(this.session))
|
|
987
1000
|
return this.session;
|
|
988
|
-
this.
|
|
1001
|
+
this.sessionKey = key;
|
|
989
1002
|
let opened = null;
|
|
990
1003
|
try {
|
|
991
|
-
opened = await openSession(this.target(),
|
|
1004
|
+
opened = await openSession(this.target(), token, member);
|
|
992
1005
|
}
|
|
993
1006
|
catch (e) {
|
|
994
1007
|
console.warn('vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only', e);
|
|
995
1008
|
}
|
|
996
|
-
// The person changed while the trade was in flight (whoChanged): this session is someone else's now.
|
|
997
|
-
if (this.
|
|
1009
|
+
// The person or the member link changed while the trade was in flight (whoChanged): this session is someone else's now.
|
|
1010
|
+
if (this.sessionKey !== key)
|
|
998
1011
|
return null;
|
|
999
1012
|
this.session = opened;
|
|
1000
1013
|
this.paint();
|
|
1001
|
-
|
|
1014
|
+
// A link forgotten here moves the key (linkChanged), and the session for the reporter alone is opened instead.
|
|
1015
|
+
if (opened?.memberError)
|
|
1016
|
+
this.memberRefused(opened.memberError, member);
|
|
1017
|
+
return this.sessionKey === key ? this.session : null;
|
|
1018
|
+
}
|
|
1019
|
+
/** Whose session the widget should hold now (reader.ts sessionKey). */
|
|
1020
|
+
whoKey() {
|
|
1021
|
+
return sessionKey(this.whoToken(), memberTokenFor(this.opts.base));
|
|
1002
1022
|
}
|
|
1003
1023
|
/**
|
|
1004
|
-
* identify()
|
|
1005
|
-
* the previous person never stay on screen for the
|
|
1006
|
-
* reports reloads for whoever is here now.
|
|
1024
|
+
* identify(), the page-wide identity or the member link moved: a session
|
|
1025
|
+
* and a list read for the previous person never stay on screen for the
|
|
1026
|
+
* next one, and an open My reports reloads for whoever is here now.
|
|
1007
1027
|
*/
|
|
1008
1028
|
whoChanged() {
|
|
1009
|
-
if (this.
|
|
1029
|
+
if (this.whoKey() !== this.sessionKey) {
|
|
1010
1030
|
this.session = null;
|
|
1011
|
-
this.
|
|
1031
|
+
this.sessionKey = '';
|
|
1012
1032
|
this.mine = { rows: [], state: 'ok' };
|
|
1013
1033
|
if (this.isOpen)
|
|
1014
1034
|
void (this.view === 'reports' ? this.loadReports() : this.refreshWho());
|
|
1015
1035
|
}
|
|
1016
1036
|
this.paint();
|
|
1017
1037
|
}
|
|
1038
|
+
/**
|
|
1039
|
+
* The stored link moved (watchMemberLink: Unlink, the link flow, another
|
|
1040
|
+
* tab, a refused link forgotten). Only a change of this base's link counts;
|
|
1041
|
+
* the recorder's other notifications pass. The member the popover named was
|
|
1042
|
+
* the previous link's: an open card reads the new link's (refreshMember).
|
|
1043
|
+
*/
|
|
1044
|
+
linkChanged() {
|
|
1045
|
+
const now = memberTokenFor(this.opts.base);
|
|
1046
|
+
if (now === this.linkSeen)
|
|
1047
|
+
return;
|
|
1048
|
+
this.linkSeen = now;
|
|
1049
|
+
this.member = null;
|
|
1050
|
+
if (now && this.isOpen)
|
|
1051
|
+
void this.refreshMember();
|
|
1052
|
+
this.whoChanged();
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* vitrinka did not take the member link a report or a session proved
|
|
1056
|
+
* (`memberError`): they stand as the reporter's alone. A link revoked, or
|
|
1057
|
+
* whose person is no longer a member, is forgotten as a 401 on a session
|
|
1058
|
+
* door forgets it (recorder/link.ts) — only the one that was sent, never a
|
|
1059
|
+
* link made since. Any other answer keeps it.
|
|
1060
|
+
*/
|
|
1061
|
+
memberRefused(err, sent) {
|
|
1062
|
+
const gone = memberLinkGone(err);
|
|
1063
|
+
console.warn(`vitrinka: vitrinka did not take this browser’s member link (${err}) — ${gone ? 'it is forgotten; link the account again' : 'it stays linked, and the reporter alone owns what goes with it'}`);
|
|
1064
|
+
if (gone && sent && readLink()?.token === sent)
|
|
1065
|
+
forgetLink();
|
|
1066
|
+
}
|
|
1018
1067
|
async refreshMember() {
|
|
1019
1068
|
// The browser-wide link goes only to the vitrinka it was minted on: its token never reaches another widget's base.
|
|
1020
1069
|
const link = memberLinked(this.opts.base) ? readLink() : null;
|
|
@@ -1025,16 +1074,23 @@ export class ReportWidget {
|
|
|
1025
1074
|
}
|
|
1026
1075
|
return;
|
|
1027
1076
|
}
|
|
1077
|
+
let member;
|
|
1078
|
+
let mode;
|
|
1028
1079
|
try {
|
|
1029
1080
|
const me = await api('GET', '/api/v1/recorder/me', undefined, { target: { url: this.opts.base, key: link.token } });
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
rememberDisplayMode(me.displayMode);
|
|
1081
|
+
member = { email: me.user?.email ?? '', name: me.user?.name ?? '', workspace: me.workspace?.slug ?? link.workspace };
|
|
1082
|
+
mode = me.displayMode;
|
|
1033
1083
|
}
|
|
1034
1084
|
catch (e) {
|
|
1035
1085
|
console.warn('vitrinka: the linked vitrinka account could not be read', e);
|
|
1036
|
-
|
|
1086
|
+
member = { email: '', name: '', workspace: link.workspace };
|
|
1037
1087
|
}
|
|
1088
|
+
// The link moved while vitrinka answered (linkChanged): this member, and their mode, are the previous link's.
|
|
1089
|
+
if (memberTokenFor(this.opts.base) !== link.token)
|
|
1090
|
+
return;
|
|
1091
|
+
this.member = member;
|
|
1092
|
+
// A dev-mode member starts on the pill next mount (face.ts startFace).
|
|
1093
|
+
rememberDisplayMode(mode);
|
|
1038
1094
|
this.paint();
|
|
1039
1095
|
}
|
|
1040
1096
|
async openReports() {
|
|
@@ -1042,10 +1098,10 @@ export class ReportWidget {
|
|
|
1042
1098
|
await this.loadReports();
|
|
1043
1099
|
}
|
|
1044
1100
|
async loadReports() {
|
|
1045
|
-
const asked = this.
|
|
1101
|
+
const asked = this.whoKey();
|
|
1046
1102
|
const session = await this.refreshWho();
|
|
1047
|
-
// The person changed meanwhile: whoChanged already reloads for the next one.
|
|
1048
|
-
if (this.
|
|
1103
|
+
// The person or the member link changed meanwhile: whoChanged already reloads for the next one.
|
|
1104
|
+
if (this.whoKey() !== asked)
|
|
1049
1105
|
return;
|
|
1050
1106
|
if (!session) {
|
|
1051
1107
|
this.mine = { rows: [], state: 'ok' };
|
|
@@ -1062,8 +1118,8 @@ export class ReportWidget {
|
|
|
1062
1118
|
console.warn('vitrinka: My reports could not be loaded', e);
|
|
1063
1119
|
mine = { rows: [], state: 'failed' };
|
|
1064
1120
|
}
|
|
1065
|
-
// A list read for the previous person is dropped; whoChanged already reloads for the next one.
|
|
1066
|
-
if (this.
|
|
1121
|
+
// A list read for the previous person or link is dropped; whoChanged already reloads for the next one.
|
|
1122
|
+
if (this.whoKey() !== asked)
|
|
1067
1123
|
return;
|
|
1068
1124
|
this.mine = mine;
|
|
1069
1125
|
this.paint();
|
|
@@ -1077,7 +1133,7 @@ export class ReportWidget {
|
|
|
1077
1133
|
if (!(e instanceof VitrinkaApiError) || e.status !== 401)
|
|
1078
1134
|
throw e;
|
|
1079
1135
|
this.session = null;
|
|
1080
|
-
this.
|
|
1136
|
+
this.sessionKey = '';
|
|
1081
1137
|
const renewed = await this.refreshWho();
|
|
1082
1138
|
if (!renewed)
|
|
1083
1139
|
throw e;
|
|
@@ -1104,10 +1160,10 @@ export class ReportWidget {
|
|
|
1104
1160
|
signal: flow.abort.signal,
|
|
1105
1161
|
});
|
|
1106
1162
|
// The link names the vitrinka it belongs to: face.ts offers the pill only on that base.
|
|
1163
|
+
// Storing it notifies: linkChanged reads the new member for an open card.
|
|
1107
1164
|
storeLink({ ...linked, base });
|
|
1108
1165
|
this.linkFlow = null;
|
|
1109
1166
|
this.show('describe');
|
|
1110
|
-
await this.refreshMember();
|
|
1111
1167
|
}
|
|
1112
1168
|
catch (e) {
|
|
1113
1169
|
if (flow.abort.signal.aborted)
|
|
@@ -1626,6 +1682,7 @@ export class ReportWidget {
|
|
|
1626
1682
|
// -- sending --------------------------------------------------------------
|
|
1627
1683
|
envelope(description, capture) {
|
|
1628
1684
|
const who = this.who();
|
|
1685
|
+
const member = memberTokenFor(this.opts.base);
|
|
1629
1686
|
const loc = globalThis.location;
|
|
1630
1687
|
return {
|
|
1631
1688
|
title: titleOf(description),
|
|
@@ -1643,6 +1700,8 @@ export class ReportWidget {
|
|
|
1643
1700
|
markers: toWire(this.markers),
|
|
1644
1701
|
locale: this.locale,
|
|
1645
1702
|
...(this.kind ? { type: this.kind } : {}),
|
|
1703
|
+
// A member linked on this base co-owns the report; the `vkb_` key stays the bearer.
|
|
1704
|
+
...(member ? { memberToken: member } : {}),
|
|
1646
1705
|
};
|
|
1647
1706
|
}
|
|
1648
1707
|
/** The words the report goes with: the description, else the first mark's note — either one is enough to send. */
|
|
@@ -1684,7 +1743,8 @@ export class ReportWidget {
|
|
|
1684
1743
|
const capture = engine ? await prepareCapture(() => engine.build(frozen, this.markers, marked)) : EMPTY_CAPTURE;
|
|
1685
1744
|
this.job = new ReportJob(capture, globalThis.location?.host ?? '', { url: this.opts.base, key: this.opts.key }, this.files);
|
|
1686
1745
|
}
|
|
1687
|
-
|
|
1746
|
+
// A refused member link is handled when the create answers, even if a later leg then fails.
|
|
1747
|
+
this.result = await this.job.run(this.envelope(description, this.job.capture), (err, sent) => this.memberRefused(err, sent));
|
|
1688
1748
|
noteSent(this.opts.base, globalThis.location?.host ?? '', {
|
|
1689
1749
|
title: titleOf(description),
|
|
1690
1750
|
at: Date.now(),
|
package/build/report/wire.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The report wire (vitrinka `docs/architecture/qa-studio.md` § "The report
|
|
3
3
|
* wire"), under `Authorization: Bearer <vkb_ key>`:
|
|
4
4
|
*
|
|
5
|
-
* POST /api/v1/reports envelope → {id, custody}
|
|
5
|
+
* POST /api/v1/reports envelope → {id, custody, memberError?}
|
|
6
6
|
* PATCH /api/v1/reports/{id} {title?, description?, markers?, notify?}
|
|
7
7
|
* POST /api/v1/reports/{id}/attachment?name=<name>
|
|
8
8
|
* one file, raw body under its own Content-Type → {id, name, size, type}
|
|
@@ -25,6 +25,13 @@
|
|
|
25
25
|
* pace, so only a stalled one runs out. A create whose answer was lost after
|
|
26
26
|
* the server stored it is created again by Try again: the same risk a dropped
|
|
27
27
|
* connection already carries.
|
|
28
|
+
*
|
|
29
|
+
* OPTIONAL FIELDS NEVER COST THE REPORT: a vitrinka older than a field refuses
|
|
30
|
+
* it by name (400, `unknown field "<name>"`), and the create goes again without
|
|
31
|
+
* each optional field it names — `type`, `memberToken` — once. `memberToken`
|
|
32
|
+
* proves this browser's vitrinka member link (vt-8020), so the member co-owns
|
|
33
|
+
* the report; `memberError` says the server did not take it, and the report
|
|
34
|
+
* files regardless.
|
|
28
35
|
*/
|
|
29
36
|
import { type ApiTarget } from '../recorder/api';
|
|
30
37
|
import { type BuiltCapture, type ConsoleEntry, type NetEntry } from './engine';
|
|
@@ -57,11 +64,26 @@ export interface ReportEnvelope {
|
|
|
57
64
|
notify?: boolean;
|
|
58
65
|
/** The reporter's own word for it (vt-8020 D11), absent when they picked none. */
|
|
59
66
|
type?: ReportKind;
|
|
67
|
+
/** The vitrinka member link this browser holds for the widget's base (face.ts memberTokenFor), absent without one: the member co-owns the report. */
|
|
68
|
+
memberToken?: string;
|
|
60
69
|
}
|
|
61
70
|
export interface SubmitReply {
|
|
62
71
|
status: 'filed' | 'quarantined';
|
|
63
72
|
reportUrl?: string;
|
|
64
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Hears the create's `memberError` — the server did not take the member link
|
|
76
|
+
* it carried (revoked, another workspace, no longer a member) — with that
|
|
77
|
+
* link's token, once, as soon as the create answers.
|
|
78
|
+
*/
|
|
79
|
+
export type MemberRefusal = (error: string, sent: string) => void;
|
|
80
|
+
/**
|
|
81
|
+
* The top-level field a vitrinka refused as unknown — a 400 whose body names
|
|
82
|
+
* it (`json: unknown field "<name>"`, its quotes escaped once more inside the
|
|
83
|
+
* JSON error) — else ''. A field merely listed among the accepted ones is
|
|
84
|
+
* never it.
|
|
85
|
+
*/
|
|
86
|
+
export declare function refusedField(e: unknown): string;
|
|
65
87
|
/** How long a leg may go unanswered: `ms` for any leg, plus one ms per `bytesPerMs` bytes an upload carries. */
|
|
66
88
|
export interface LegLimits {
|
|
67
89
|
ms: number;
|
|
@@ -111,8 +133,20 @@ export declare class ReportJob {
|
|
|
111
133
|
private upload;
|
|
112
134
|
/** A file has not landed yet: the attachment leg is what a retry resumes. */
|
|
113
135
|
get filesPending(): boolean;
|
|
114
|
-
/**
|
|
115
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Run the legs from wherever the last run stopped; rejects with the failing
|
|
138
|
+
* leg's error. `onMemberRefusal` hears the create's `memberError` the moment
|
|
139
|
+
* the create answers, so a later leg failing never holds it back.
|
|
140
|
+
*/
|
|
141
|
+
run(env: ReportEnvelope, onMemberRefusal?: MemberRefusal): Promise<SubmitReply>;
|
|
142
|
+
/**
|
|
143
|
+
* The create leg, answering with the member link the accepted body carried
|
|
144
|
+
* ('' none). A vitrinka older than an optional field refuses it by name;
|
|
145
|
+
* the reporter's word (`type`) and the member link (`memberToken`) are
|
|
146
|
+
* optional, the report is not, so it goes again without each field named,
|
|
147
|
+
* once. A refusal naming nothing still in the body fails the leg.
|
|
148
|
+
*/
|
|
149
|
+
private create;
|
|
116
150
|
private sendFiles;
|
|
117
151
|
private sendCapture;
|
|
118
152
|
}
|