@peers-app/peers-ui 0.25.2 → 0.25.4
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/README.md +2 -1
- package/dist/components/markdown-editor/mention-node.d.ts +4 -0
- package/dist/components/markdown-editor/mention-node.js +4 -1
- package/dist/components/responsive-section-nav.d.ts +34 -0
- package/dist/components/responsive-section-nav.js +19 -0
- package/dist/components/responsive-section-nav.test.d.ts +1 -0
- package/dist/components/responsive-section-nav.test.js +45 -0
- package/dist/components/router.d.ts +2 -3
- package/dist/components/router.js +6 -9
- package/dist/globals-hash.test.d.ts +1 -0
- package/dist/globals-hash.test.js +16 -0
- package/dist/globals.d.ts +19 -0
- package/dist/globals.js +51 -12
- package/dist/hooks/use-host-contract.d.ts +18 -0
- package/dist/hooks/use-host-contract.js +53 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/peers-services-registration.d.ts +1 -5
- package/dist/peers-services-registration.js +6 -16
- package/dist/root-layout/root-layout-host.js +7 -4
- package/dist/root-layout/root-layout-host.test.js +3 -6
- package/dist/screens/account/account-screen.d.ts +1 -0
- package/dist/screens/account/account-screen.js +29 -53
- package/dist/screens/account/account-screen.test.d.ts +1 -0
- package/dist/screens/account/account-screen.test.js +47 -0
- package/dist/screens/contacts/contact-details.js +2 -23
- package/dist/screens/contacts/contact-list.d.ts +24 -1
- package/dist/screens/contacts/contact-list.js +128 -143
- package/dist/screens/contacts/contact-list.test.d.ts +1 -0
- package/dist/screens/contacts/contact-list.test.js +48 -0
- package/dist/screens/contacts/index.d.ts +0 -2
- package/dist/screens/contacts/index.js +0 -3
- package/dist/screens/device-pairing/device-pairing.js +17 -16
- package/dist/screens/device-pairing/device-pairing.test.js +4 -9
- package/dist/screens/device-pairing/identity-ipc.d.ts +11 -0
- package/dist/screens/device-pairing/identity-ipc.js +20 -0
- package/dist/screens/device-pairing/use-device-pairing-state.d.ts +2 -2
- package/dist/screens/device-pairing/use-device-pairing-state.js +7 -25
- package/dist/screens/devices/devices-list.d.ts +18 -0
- package/dist/screens/devices/devices-list.js +173 -0
- package/dist/screens/devices/devices-list.test.d.ts +1 -0
- package/dist/screens/devices/devices-list.test.js +53 -0
- package/dist/screens/devices/index.d.ts +1 -0
- package/dist/screens/devices/index.js +5 -0
- package/dist/screens/groups/group-details.d.ts +1 -0
- package/dist/screens/groups/group-details.js +4 -63
- package/dist/screens/groups/group-invite-panel.js +2 -2
- package/dist/screens/groups/group-list.d.ts +18 -1
- package/dist/screens/groups/group-list.js +107 -136
- package/dist/screens/groups/group-list.test.d.ts +1 -0
- package/dist/screens/groups/group-list.test.js +38 -0
- package/dist/screens/groups/group-members.d.ts +1 -0
- package/dist/screens/groups/group-members.js +2 -1
- package/dist/screens/groups/index.d.ts +0 -3
- package/dist/screens/groups/index.js +0 -4
- package/dist/screens/identity/identity-routes.d.ts +107 -0
- package/dist/screens/identity/identity-routes.js +245 -0
- package/dist/screens/identity/identity-routes.test.d.ts +1 -0
- package/dist/screens/identity/identity-routes.test.js +51 -0
- package/dist/screens/identity/identity-screen.d.ts +9 -0
- package/dist/screens/identity/identity-screen.js +143 -0
- package/dist/screens/identity/identity-screen.test.d.ts +1 -0
- package/dist/screens/identity/identity-screen.test.js +103 -0
- package/dist/screens/identity/index.d.ts +2 -0
- package/dist/screens/identity/index.js +6 -0
- package/dist/screens/identity/invite-contact-panel.d.ts +4 -0
- package/dist/screens/identity/invite-contact-panel.js +30 -0
- package/dist/screens/identity/profile-invite.d.ts +7 -0
- package/dist/screens/identity/profile-invite.js +62 -0
- package/dist/screens/invites/accept-invite.js +44 -2
- package/dist/screens/invites/accept-invite.test.d.ts +1 -0
- package/dist/screens/invites/accept-invite.test.js +103 -0
- package/dist/screens/invites/activity-view.d.ts +24 -0
- package/dist/screens/invites/activity-view.js +64 -0
- package/dist/screens/invites/activity-view.test.d.ts +1 -0
- package/dist/screens/invites/activity-view.test.js +108 -0
- package/dist/screens/invites/index.d.ts +1 -2
- package/dist/screens/invites/index.js +1 -3
- package/dist/screens/invites/invite-capture.d.ts +0 -2
- package/dist/screens/invites/invite-capture.js +1 -3
- package/dist/screens/invites/invite-classify.test.d.ts +1 -0
- package/dist/screens/invites/invite-classify.test.js +115 -0
- package/dist/screens/invites/invites-ipc.d.ts +1 -1
- package/dist/screens/invites/invites-ipc.js +5 -45
- package/dist/screens/invites/pending-invites-list.d.ts +35 -16
- package/dist/screens/invites/pending-invites-list.js +75 -30
- package/dist/screens/network-viewer/network-viewer-ipc.js +4 -59
- package/dist/screens/search/global-search.d.ts +1 -0
- package/dist/screens/search/global-search.js +2 -1
- package/dist/screens/settings/settings-page.js +25 -58
- package/dist/screens/setup-user.js +5 -5
- package/dist/screens/tools/tool-access-ipc.d.ts +2 -0
- package/dist/screens/tools/tool-access-ipc.js +8 -55
- package/dist/screens/welcome-modal.js +3 -2
- package/dist/system-apps/identity.app.d.ts +3 -0
- package/dist/system-apps/identity.app.js +10 -0
- package/dist/system-apps/index.d.ts +1 -4
- package/dist/system-apps/index.js +5 -17
- package/dist/tabs-layout/network-status-indicator.js +10 -3
- package/dist/tabs-layout/network-status-indicator.test.js +15 -0
- package/dist/tabs-layout/tabs-layout.js +3 -1
- package/dist/tabs-layout/tabs-state.d.ts +79 -1
- package/dist/tabs-layout/tabs-state.js +256 -79
- package/dist/tabs-layout/tabs-state.test.d.ts +1 -0
- package/dist/tabs-layout/tabs-state.test.js +110 -0
- package/package.json +3 -3
- package/src/components/markdown-editor/mention-node.ts +5 -1
- package/src/components/responsive-section-nav.test.tsx +88 -0
- package/src/components/responsive-section-nav.tsx +92 -0
- package/src/components/router.tsx +6 -9
- package/src/globals-hash.test.ts +19 -0
- package/src/globals.tsx +53 -13
- package/src/hooks/use-host-contract.ts +75 -0
- package/src/index.tsx +1 -0
- package/src/peers-services-registration.ts +6 -17
- package/src/root-layout/root-layout-host.test.tsx +4 -7
- package/src/root-layout/root-layout-host.tsx +9 -11
- package/src/screens/account/account-screen.test.tsx +61 -0
- package/src/screens/account/account-screen.tsx +116 -95
- package/src/screens/contacts/contact-details.tsx +4 -26
- package/src/screens/contacts/contact-list.test.tsx +59 -0
- package/src/screens/contacts/contact-list.tsx +246 -260
- package/src/screens/contacts/index.ts +0 -4
- package/src/screens/device-pairing/device-pairing.test.tsx +7 -9
- package/src/screens/device-pairing/device-pairing.tsx +19 -23
- package/src/screens/device-pairing/identity-ipc.ts +25 -0
- package/src/screens/device-pairing/use-device-pairing-state.ts +10 -33
- package/src/screens/devices/devices-list.test.tsx +68 -0
- package/src/screens/devices/devices-list.tsx +361 -0
- package/src/screens/devices/index.ts +1 -0
- package/src/screens/groups/group-details.tsx +8 -142
- package/src/screens/groups/group-invite-panel.tsx +2 -7
- package/src/screens/groups/group-list.test.tsx +44 -0
- package/src/screens/groups/group-list.tsx +227 -288
- package/src/screens/groups/group-members.tsx +3 -2
- package/src/screens/groups/index.ts +0 -5
- package/src/screens/identity/identity-routes.test.ts +70 -0
- package/src/screens/identity/identity-routes.ts +301 -0
- package/src/screens/identity/identity-screen.test.tsx +138 -0
- package/src/screens/identity/identity-screen.tsx +282 -0
- package/src/screens/identity/index.ts +2 -0
- package/src/screens/identity/invite-contact-panel.tsx +45 -0
- package/src/screens/identity/profile-invite.tsx +93 -0
- package/src/screens/invites/accept-invite.test.tsx +115 -0
- package/src/screens/invites/accept-invite.tsx +50 -3
- package/src/screens/invites/activity-view.test.tsx +127 -0
- package/src/screens/invites/activity-view.tsx +162 -0
- package/src/screens/invites/index.ts +1 -4
- package/src/screens/invites/invite-capture.ts +0 -3
- package/src/screens/invites/invite-classify.test.ts +129 -0
- package/src/screens/invites/invites-ipc.ts +6 -55
- package/src/screens/invites/pending-invites-list.tsx +94 -62
- package/src/screens/network-viewer/network-viewer-ipc.ts +8 -82
- package/src/screens/search/global-search.tsx +2 -1
- package/src/screens/settings/settings-page.tsx +53 -126
- package/src/screens/setup-user.tsx +5 -6
- package/src/screens/tools/tool-access-ipc.ts +13 -74
- package/src/screens/welcome-modal.tsx +3 -3
- package/src/system-apps/identity.app.ts +9 -0
- package/src/system-apps/index.ts +3 -12
- package/src/tabs-layout/network-status-indicator.test.tsx +22 -0
- package/src/tabs-layout/network-status-indicator.tsx +31 -0
- package/src/tabs-layout/tabs-layout.tsx +7 -1
- package/src/tabs-layout/tabs-state.test.ts +152 -0
- package/src/tabs-layout/tabs-state.ts +300 -83
- package/dist/screens/invites/invites-screen.d.ts +0 -9
- package/dist/screens/invites/invites-screen.js +0 -36
- package/dist/system-apps/account.app.d.ts +0 -2
- package/dist/system-apps/account.app.js +0 -8
- package/dist/system-apps/contacts.app.d.ts +0 -2
- package/dist/system-apps/contacts.app.js +0 -9
- package/dist/system-apps/groups.app.d.ts +0 -2
- package/dist/system-apps/groups.app.js +0 -9
- package/dist/system-apps/invites.app.d.ts +0 -2
- package/dist/system-apps/invites.app.js +0 -9
- package/src/screens/invites/invites-screen.tsx +0 -78
- package/src/system-apps/account.app.ts +0 -7
- package/src/system-apps/contacts.app.ts +0 -8
- package/src/system-apps/groups.app.ts +0 -8
- package/src/system-apps/invites.app.ts +0 -8
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProfileInviteSection = ProfileInviteSection;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const loading_indicator_1 = require("../../components/loading-indicator");
|
|
7
|
+
const tooltip_1 = require("../../components/tooltip");
|
|
8
|
+
const invite_share_1 = require("../invites/invite-share");
|
|
9
|
+
const invites_ipc_1 = require("../invites/invites-ipc");
|
|
10
|
+
const PROFILE_QR_INFO = `### Your profile QR
|
|
11
|
+
|
|
12
|
+
Anyone who scans this (or opens the link) can send you a contact request. Requests show up in **Identity → Activity** and nothing happens until you confirm.
|
|
13
|
+
|
|
14
|
+
### Regenerate
|
|
15
|
+
|
|
16
|
+
Regenerating invalidates this QR **and every other invite link you have issued**. Use it if the QR leaked somewhere you did not intend.`;
|
|
17
|
+
/**
|
|
18
|
+
* Reusable profile invite.
|
|
19
|
+
*
|
|
20
|
+
* Sharing it asks the other person to request a connection. Regenerating bumps
|
|
21
|
+
* the invite epoch and revokes outstanding links.
|
|
22
|
+
*/
|
|
23
|
+
function ProfileInviteSection() {
|
|
24
|
+
const [invite, setInvite] = (0, react_1.useState)(undefined);
|
|
25
|
+
const [busy, setBusy] = (0, react_1.useState)(false);
|
|
26
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
27
|
+
(0, react_1.useEffect)(() => {
|
|
28
|
+
let cancelled = false;
|
|
29
|
+
void (0, invites_ipc_1.inviteTools)()
|
|
30
|
+
.then((tools) => tools.createContactInvite({ profile: true }))
|
|
31
|
+
.then(({ invite: created }) => {
|
|
32
|
+
if (!cancelled)
|
|
33
|
+
setInvite(created);
|
|
34
|
+
})
|
|
35
|
+
.catch((err) => {
|
|
36
|
+
if (!cancelled)
|
|
37
|
+
setError(err.message || "Could not load your profile QR.");
|
|
38
|
+
});
|
|
39
|
+
return () => {
|
|
40
|
+
cancelled = true;
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
const regenerate = async () => {
|
|
44
|
+
if (!confirm("Regenerate your profile QR? Every invite link you have issued so far will stop working.")) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
setBusy(true);
|
|
48
|
+
setError(null);
|
|
49
|
+
try {
|
|
50
|
+
const tools = await (0, invites_ipc_1.inviteTools)();
|
|
51
|
+
const { invite: created } = await tools.regenerateProfileInvite();
|
|
52
|
+
setInvite(created);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
setError(err.message || "Could not regenerate.");
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
setBusy(false);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "card mb-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "card-body", children: [(0, jsx_runtime_1.jsxs)("h5", { className: "card-title d-flex align-items-center gap-2", children: ["Profile QR", (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: PROFILE_QR_INFO })] }), error ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2", children: error }) : null, invite ? ((0, jsx_runtime_1.jsx)(invite_share_1.InviteShare, { invite: invite, description: "Let people connect with you by scanning this or opening the link. You confirm each request.", shareText: "Connect with me on Peers:" })) : !error ? ((0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {})) : null, (0, jsx_runtime_1.jsx)("div", { className: "text-center mt-3", children: (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-danger btn-sm", onClick: () => void regenerate(), disabled: busy || !invite, children: busy ? "Regenerating…" : "Regenerate (revokes all invites)" }) })] }) }));
|
|
62
|
+
}
|
|
@@ -21,14 +21,17 @@ function PreviewCard(props) {
|
|
|
21
21
|
function ResultPanel(props) {
|
|
22
22
|
const { result, preview } = props;
|
|
23
23
|
const accepted = result.status === "accepted";
|
|
24
|
+
const openGroup = preview.type === "group" && preview.group?.mode === "open";
|
|
24
25
|
const message = accepted
|
|
25
26
|
? preview.type === "group"
|
|
26
27
|
? `You joined ${preview.group?.name}.`
|
|
27
28
|
: "Contact added."
|
|
28
29
|
: preview.type === "group"
|
|
29
|
-
?
|
|
30
|
+
? openGroup
|
|
31
|
+
? `Finishing your automatic join to ${preview.group?.name}.`
|
|
32
|
+
: "Join request sent. You will be added once it is approved."
|
|
30
33
|
: "Request sent. They will see it and confirm.";
|
|
31
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "text-center", children: [(0, jsx_runtime_1.jsxs)("output", { className: `alert d-block ${accepted ? "alert-success" : "alert-info"}`, children: [message, result.deliveryState === "queued" ? ((0, jsx_runtime_1.jsx)("div", { className: "small mt-1", children: "
|
|
34
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "text-center", children: [(0, jsx_runtime_1.jsxs)("output", { className: `alert d-block ${accepted ? "alert-success" : "alert-info"}`, children: [message, result.deliveryState === "queued" ? ((0, jsx_runtime_1.jsx)("div", { className: "small mt-1", children: "Waiting for a route; Peers will retry automatically." })) : null] }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2 justify-content-center", children: [accepted && result.groupId ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-primary", onClick: () => (0, globals_1.mainContentPath)(`identity/groups/${result.groupId}`), children: "Open group" })) : null, (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-secondary", onClick: props.onDone, children: "Done" })] })] }));
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
34
37
|
* Paste or scan an invite, review what it grants, then accept it. Also consumes a token
|
|
@@ -73,6 +76,45 @@ function AcceptInvite(props) {
|
|
|
73
76
|
});
|
|
74
77
|
return () => sub.dispose();
|
|
75
78
|
}, [props.initialToken, runPreview]);
|
|
79
|
+
const resultInviteId = result?.inviteId;
|
|
80
|
+
const resultStatus = result?.status;
|
|
81
|
+
(0, react_1.useEffect)(() => {
|
|
82
|
+
if (!resultInviteId || resultStatus !== "pending") {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
let disposed = false;
|
|
86
|
+
let unsubscribe;
|
|
87
|
+
void (0, peers_sdk_1.getUserContext)().then(async (userContext) => {
|
|
88
|
+
if (disposed) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const table = (0, peers_sdk_1.Invites)(userContext.userDataContext);
|
|
92
|
+
const refresh = async () => {
|
|
93
|
+
const row = await table.get(resultInviteId);
|
|
94
|
+
if (!disposed && row) {
|
|
95
|
+
setResult((current) => current?.inviteId === resultInviteId
|
|
96
|
+
? {
|
|
97
|
+
...current,
|
|
98
|
+
status: row.status,
|
|
99
|
+
deliveryState: row.deliveryState,
|
|
100
|
+
groupId: row.groupId ?? current.groupId,
|
|
101
|
+
}
|
|
102
|
+
: current);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const subscription = table.dataChanged.subscribe((event) => {
|
|
106
|
+
if (event.dataObject.inviteId === resultInviteId) {
|
|
107
|
+
void refresh();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
unsubscribe = () => subscription.unsubscribe();
|
|
111
|
+
await refresh();
|
|
112
|
+
});
|
|
113
|
+
return () => {
|
|
114
|
+
disposed = true;
|
|
115
|
+
unsubscribe?.();
|
|
116
|
+
};
|
|
117
|
+
}, [resultInviteId, resultStatus]);
|
|
76
118
|
const accept = async () => {
|
|
77
119
|
setError("");
|
|
78
120
|
setBusy(true);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
8
|
+
const react_1 = require("@testing-library/react");
|
|
9
|
+
const user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
10
|
+
const accept_invite_1 = require("./accept-invite");
|
|
11
|
+
const invites_ipc_1 = require("./invites-ipc");
|
|
12
|
+
jest.mock("@peers-app/peers-sdk", () => {
|
|
13
|
+
const actual = jest.requireActual("@peers-app/peers-sdk");
|
|
14
|
+
return {
|
|
15
|
+
...actual,
|
|
16
|
+
getUserContext: jest.fn(actual.getUserContext),
|
|
17
|
+
Invites: jest.fn(),
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
jest.mock("./invites-ipc", () => ({
|
|
21
|
+
inviteTools: jest.fn(),
|
|
22
|
+
}));
|
|
23
|
+
jest.mock("../../globals", () => ({
|
|
24
|
+
mainContentPath: jest.fn(),
|
|
25
|
+
}));
|
|
26
|
+
const preview = {
|
|
27
|
+
type: "group",
|
|
28
|
+
inviter: {
|
|
29
|
+
userId: "abcdefghijklmnopqrstuvwxy",
|
|
30
|
+
publicKey: "a".repeat(43),
|
|
31
|
+
publicBoxKey: "b".repeat(43),
|
|
32
|
+
displayName: "Ada",
|
|
33
|
+
},
|
|
34
|
+
expiresAt: "2026-10-01T00:00:00.000Z",
|
|
35
|
+
expired: false,
|
|
36
|
+
knownContact: false,
|
|
37
|
+
group: {
|
|
38
|
+
groupId: "zyxwvutsrqponmlkjihgfedcb",
|
|
39
|
+
name: "Neighbors",
|
|
40
|
+
role: 20,
|
|
41
|
+
mode: "open",
|
|
42
|
+
alreadyMember: false,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const pendingResult = {
|
|
46
|
+
inviteId: "openjoinrequest0000000001",
|
|
47
|
+
status: "pending",
|
|
48
|
+
deliveryState: "queued",
|
|
49
|
+
groupId: preview.group?.groupId,
|
|
50
|
+
};
|
|
51
|
+
function invite(status, deliveryState) {
|
|
52
|
+
return {
|
|
53
|
+
inviteId: pendingResult.inviteId,
|
|
54
|
+
direction: "in",
|
|
55
|
+
type: "group",
|
|
56
|
+
status,
|
|
57
|
+
mode: "open",
|
|
58
|
+
counterpart: preview.inviter,
|
|
59
|
+
groupId: preview.group?.groupId,
|
|
60
|
+
groupName: preview.group?.name,
|
|
61
|
+
role: preview.group?.role,
|
|
62
|
+
epoch: 0,
|
|
63
|
+
recipientUserId: preview.inviter.userId,
|
|
64
|
+
deliveryState,
|
|
65
|
+
createdAt: new Date("2026-09-22T00:00:00.000Z"),
|
|
66
|
+
expiresAt: new Date(preview.expiresAt),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
describe("AcceptInvite", () => {
|
|
70
|
+
beforeEach(() => {
|
|
71
|
+
jest.clearAllMocks();
|
|
72
|
+
});
|
|
73
|
+
it("shows automatic progress and reacts when the delayed approval arrives", async () => {
|
|
74
|
+
let row = invite("pending", "queued");
|
|
75
|
+
let onDataChanged;
|
|
76
|
+
const table = {
|
|
77
|
+
get: jest.fn(async () => row),
|
|
78
|
+
dataChanged: {
|
|
79
|
+
subscribe: jest.fn((listener) => {
|
|
80
|
+
onDataChanged = listener;
|
|
81
|
+
return { unsubscribe: jest.fn() };
|
|
82
|
+
}),
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
peers_sdk_1.getUserContext.mockResolvedValue({ userDataContext: {} });
|
|
86
|
+
peers_sdk_1.Invites.mockReturnValue(table);
|
|
87
|
+
invites_ipc_1.inviteTools.mockResolvedValue({
|
|
88
|
+
previewInvite: jest.fn().mockResolvedValue({ preview }),
|
|
89
|
+
acceptInvite: jest.fn().mockResolvedValue({ result: pendingResult }),
|
|
90
|
+
});
|
|
91
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(accept_invite_1.AcceptInvite, { initialToken: "signed-token" }));
|
|
92
|
+
await user_event_1.default.click(await react_1.screen.findByRole("button", { name: "Join" }));
|
|
93
|
+
expect(await react_1.screen.findByText("Finishing your automatic join to Neighbors.")).toBeVisible();
|
|
94
|
+
expect(react_1.screen.getByText("Waiting for a route; Peers will retry automatically.")).toBeVisible();
|
|
95
|
+
expect(react_1.screen.queryByText(/once it is approved/i)).not.toBeInTheDocument();
|
|
96
|
+
row = invite("accepted", "sent");
|
|
97
|
+
await (0, react_1.act)(async () => {
|
|
98
|
+
onDataChanged?.({ dataObject: row });
|
|
99
|
+
});
|
|
100
|
+
await (0, react_1.waitFor)(() => expect(react_1.screen.getByText("You joined Neighbors.")).toBeVisible());
|
|
101
|
+
expect(react_1.screen.getByRole("button", { name: "Open group" })).toBeEnabled();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type IdentityInviteType } from "../identity/identity-routes";
|
|
2
|
+
/** Props for {@link ActivityView}. */
|
|
3
|
+
export interface ActivityViewProps {
|
|
4
|
+
/** Optional type and group limit, taken from the route query. */
|
|
5
|
+
filter?: {
|
|
6
|
+
type?: IdentityInviteType;
|
|
7
|
+
groupId?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Unified invite inbox.
|
|
12
|
+
*
|
|
13
|
+
* Pending rows are split into decisions the user can make and items waiting
|
|
14
|
+
* on someone else. History is a separate view, not a disclosure on each list.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ActivityView(props: ActivityViewProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* Compact link from a resource screen to the matching Activity filter.
|
|
19
|
+
* Renders nothing when that filter has no pending rows.
|
|
20
|
+
*/
|
|
21
|
+
export declare function PendingWorkLink(props: {
|
|
22
|
+
type: IdentityInviteType;
|
|
23
|
+
groupId?: string;
|
|
24
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActivityView = ActivityView;
|
|
4
|
+
exports.PendingWorkLink = PendingWorkLink;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const loading_indicator_1 = require("../../components/loading-indicator");
|
|
8
|
+
const identity_routes_1 = require("../identity/identity-routes");
|
|
9
|
+
const pending_invites_list_1 = require("./pending-invites-list");
|
|
10
|
+
/** Statuses shown in Activity's History view. */
|
|
11
|
+
const TERMINAL_STATUSES = ["accepted", "declined", "expired", "revoked"];
|
|
12
|
+
/**
|
|
13
|
+
* Unified invite inbox.
|
|
14
|
+
*
|
|
15
|
+
* Pending rows are split into decisions the user can make and items waiting
|
|
16
|
+
* on someone else. History is a separate view, not a disclosure on each list.
|
|
17
|
+
*/
|
|
18
|
+
function ActivityView(props) {
|
|
19
|
+
const [view, setView] = (0, react_1.useState)("pending");
|
|
20
|
+
const filter = props.filter;
|
|
21
|
+
const query = (0, pending_invites_list_1.useInviteRows)({
|
|
22
|
+
type: filter?.type,
|
|
23
|
+
groupId: filter?.groupId,
|
|
24
|
+
statuses: view === "history" ? TERMINAL_STATUSES : ["pending"],
|
|
25
|
+
});
|
|
26
|
+
const rows = query?.rows ?? [];
|
|
27
|
+
const attention = rows.filter((row) => (0, pending_invites_list_1.classifyInvite)(row) === "attention");
|
|
28
|
+
const waiting = rows.filter((row) => (0, pending_invites_list_1.classifyInvite)(row) === "waiting");
|
|
29
|
+
const filtered = Boolean(filter?.type || filter?.groupId);
|
|
30
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex justify-content-between align-items-center gap-2 flex-wrap mb-3", children: [(0, jsx_runtime_1.jsxs)("h4", { className: "mb-0", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-inbox me-2" }), "Activity"] }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "btn-group btn-group-sm", role: "group", "aria-label": "Invite view", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: `btn ${view === "pending" ? "btn-primary" : "btn-outline-primary"}`, onClick: () => setView("pending"), children: "Pending" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: `btn ${view === "history" ? "btn-primary" : "btn-outline-primary"}`, onClick: () => setView("history"), children: "History" })] }), (0, jsx_runtime_1.jsxs)("a", { href: `#${identity_routes_1.IDENTITY_ACCEPT_PATH}`, className: "btn btn-outline-primary btn-sm", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-qr-code-scan me-1" }), "Enter or scan an invite"] })] })] }), filtered ? ((0, jsx_runtime_1.jsxs)("div", { className: "alert alert-secondary py-2 d-flex justify-content-between align-items-center", children: [(0, jsx_runtime_1.jsx)("span", { children: filterLabel(filter?.type, filter?.groupId) }), (0, jsx_runtime_1.jsx)("a", { href: "#identity/activity", children: "Show all" })] })) : null, !query ? ((0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {})) : view === "history" ? ((0, jsx_runtime_1.jsx)(InviteBucket, { title: "History", rows: rows, empty: "No invite history." })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(InviteBucket, { title: "Needs your attention", rows: attention, empty: waiting.length === 0 ? "No invites need attention." : "Nothing needs a decision." }), (0, jsx_runtime_1.jsx)(InviteBucket, { title: "Waiting on others", rows: waiting, empty: attention.length === 0 ? "" : "Nothing is waiting on someone else." })] }))] }));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Compact link from a resource screen to the matching Activity filter.
|
|
34
|
+
* Renders nothing when that filter has no pending rows.
|
|
35
|
+
*/
|
|
36
|
+
function PendingWorkLink(props) {
|
|
37
|
+
const query = (0, pending_invites_list_1.useInviteRows)({
|
|
38
|
+
type: props.type,
|
|
39
|
+
groupId: props.groupId,
|
|
40
|
+
statuses: ["pending"],
|
|
41
|
+
});
|
|
42
|
+
if (!query || query.rows.length === 0) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const noun = props.type === "contact" ? "contact" : props.type === "group" ? "group" : "device";
|
|
46
|
+
const count = query.rows.length;
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)("a", { href: `#${(0, identity_routes_1.identityActivityFilterPath)(props.type, props.groupId)}`, className: "alert alert-info py-2 px-3 d-flex justify-content-between align-items-center text-decoration-none", children: [(0, jsx_runtime_1.jsxs)("span", { children: [count, " pending ", noun, " invite", count === 1 ? "" : "s"] }), (0, jsx_runtime_1.jsx)("span", { children: "View in Activity" })] }));
|
|
48
|
+
}
|
|
49
|
+
function InviteBucket(props) {
|
|
50
|
+
if (props.rows.length === 0 && !props.empty) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)("section", { className: "mb-4", children: [(0, jsx_runtime_1.jsx)("h6", { children: props.title }), props.rows.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { className: "text-muted small mb-0", children: props.empty })) : ((0, jsx_runtime_1.jsx)("div", { className: "list-group", children: props.rows.map((row) => ((0, jsx_runtime_1.jsx)(pending_invites_list_1.InviteRow, { row: row }, row.inviteId))) }))] }));
|
|
54
|
+
}
|
|
55
|
+
function filterLabel(type, groupId) {
|
|
56
|
+
const kind = type === "contact" ? "contact" : type === "group" ? "group" : type === "device" ? "device" : "";
|
|
57
|
+
if (groupId) {
|
|
58
|
+
return "Showing invites for this group.";
|
|
59
|
+
}
|
|
60
|
+
if (kind) {
|
|
61
|
+
return `Showing ${kind} invites.`;
|
|
62
|
+
}
|
|
63
|
+
return "Showing a filtered list.";
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("@testing-library/react");
|
|
8
|
+
const user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
9
|
+
const activity_view_1 = require("./activity-view");
|
|
10
|
+
const invites_ipc_1 = require("./invites-ipc");
|
|
11
|
+
const pending_invites_list_1 = require("./pending-invites-list");
|
|
12
|
+
jest.mock("./pending-invites-list", () => {
|
|
13
|
+
const actual = jest.requireActual("./pending-invites-list");
|
|
14
|
+
return {
|
|
15
|
+
...actual,
|
|
16
|
+
useInviteRows: jest.fn(),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
jest.mock("./invites-ipc", () => ({
|
|
20
|
+
inviteTools: jest.fn(),
|
|
21
|
+
}));
|
|
22
|
+
function invite(partial) {
|
|
23
|
+
return {
|
|
24
|
+
status: "pending",
|
|
25
|
+
epoch: 1,
|
|
26
|
+
createdAt: new Date("2026-01-01T00:00:00Z"),
|
|
27
|
+
expiresAt: new Date("2026-02-01T00:00:00Z"),
|
|
28
|
+
counterpart: { userId: "abcdefghijklmnopqrstuvwxy", displayName: "Ada" },
|
|
29
|
+
...partial,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const attention = invite({
|
|
33
|
+
inviteId: "inboundcontact0000000001",
|
|
34
|
+
direction: "in",
|
|
35
|
+
type: "contact",
|
|
36
|
+
mode: "contact",
|
|
37
|
+
});
|
|
38
|
+
const waiting = invite({
|
|
39
|
+
inviteId: "outboundcontact0000000001",
|
|
40
|
+
direction: "out",
|
|
41
|
+
type: "contact",
|
|
42
|
+
mode: "contact",
|
|
43
|
+
});
|
|
44
|
+
const joinRequest = invite({
|
|
45
|
+
inviteId: "groupjoinrequest000000001",
|
|
46
|
+
direction: "in",
|
|
47
|
+
type: "group",
|
|
48
|
+
mode: "approve",
|
|
49
|
+
groupId: "zyxwvutsrqponmlkjihgfedcb",
|
|
50
|
+
groupName: "Neighbors",
|
|
51
|
+
});
|
|
52
|
+
const history = invite({
|
|
53
|
+
inviteId: "oldcontact000000000000001",
|
|
54
|
+
direction: "in",
|
|
55
|
+
type: "contact",
|
|
56
|
+
mode: "contact",
|
|
57
|
+
status: "accepted",
|
|
58
|
+
});
|
|
59
|
+
const mockedRows = pending_invites_list_1.useInviteRows;
|
|
60
|
+
const acceptInvite = jest.fn();
|
|
61
|
+
const approveJoinRequest = jest.fn();
|
|
62
|
+
describe("ActivityView", () => {
|
|
63
|
+
beforeEach(() => {
|
|
64
|
+
acceptInvite.mockReset();
|
|
65
|
+
approveJoinRequest.mockReset();
|
|
66
|
+
invites_ipc_1.inviteTools.mockResolvedValue({
|
|
67
|
+
acceptInvite,
|
|
68
|
+
declineInvite: jest.fn(),
|
|
69
|
+
approveJoinRequest,
|
|
70
|
+
denyJoinRequest: jest.fn(),
|
|
71
|
+
revokeInvite: jest.fn(),
|
|
72
|
+
});
|
|
73
|
+
mockedRows.mockImplementation((filter) => ({
|
|
74
|
+
rows: filter.statuses?.includes("accepted") ? [history] : [attention, joinRequest, waiting],
|
|
75
|
+
hasHistory: true,
|
|
76
|
+
}));
|
|
77
|
+
});
|
|
78
|
+
it("offers approval for a received group join request", async () => {
|
|
79
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(activity_view_1.ActivityView, {}));
|
|
80
|
+
expect(react_1.screen.getByText("Ada wants to join Neighbors")).toBeInTheDocument();
|
|
81
|
+
await user_event_1.default.click(react_1.screen.getByRole("button", { name: "Approve" }));
|
|
82
|
+
await (0, react_1.waitFor)(() => expect(approveJoinRequest).toHaveBeenCalledWith({ inviteId: joinRequest.inviteId }));
|
|
83
|
+
});
|
|
84
|
+
it("splits pending invites and accepts a request from the inbox", async () => {
|
|
85
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(activity_view_1.ActivityView, {}));
|
|
86
|
+
expect(react_1.screen.getByRole("heading", { name: "Needs your attention" })).toBeInTheDocument();
|
|
87
|
+
expect(react_1.screen.getByRole("heading", { name: "Waiting on others" })).toBeInTheDocument();
|
|
88
|
+
expect(react_1.screen.getByText("Ada wants to connect")).toBeInTheDocument();
|
|
89
|
+
await user_event_1.default.click(react_1.screen.getByRole("button", { name: "Accept" }));
|
|
90
|
+
await (0, react_1.waitFor)(() => expect(acceptInvite).toHaveBeenCalledWith({ inviteId: attention.inviteId }));
|
|
91
|
+
});
|
|
92
|
+
it("switches to history and shows an empty pending inbox", async () => {
|
|
93
|
+
const view = (0, react_1.render)((0, jsx_runtime_1.jsx)(activity_view_1.ActivityView, {}));
|
|
94
|
+
await user_event_1.default.click(react_1.screen.getByRole("button", { name: "History" }));
|
|
95
|
+
expect(react_1.screen.getByRole("heading", { name: "History" })).toBeInTheDocument();
|
|
96
|
+
expect(react_1.screen.getByText(/accepted/i)).toBeInTheDocument();
|
|
97
|
+
expect(react_1.screen.queryByRole("heading", { name: "Needs your attention" })).not.toBeInTheDocument();
|
|
98
|
+
mockedRows.mockReturnValue({ rows: [], hasHistory: false });
|
|
99
|
+
view.rerender((0, jsx_runtime_1.jsx)(activity_view_1.ActivityView, {}));
|
|
100
|
+
await user_event_1.default.click(react_1.screen.getByRole("button", { name: "Pending" }));
|
|
101
|
+
expect(react_1.screen.getByText("No invites need attention.")).toBeInTheDocument();
|
|
102
|
+
});
|
|
103
|
+
it("shows the active filter", () => {
|
|
104
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(activity_view_1.ActivityView, { filter: { type: "group", groupId: "zyxwvutsrqponmlkjihgfedcb" } }));
|
|
105
|
+
expect(react_1.screen.getByText("Showing invites for this group.")).toBeInTheDocument();
|
|
106
|
+
expect(react_1.screen.getByRole("link", { name: "Show all" })).toHaveAttribute("href", "#identity/activity");
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import "./invites-screen";
|
|
2
1
|
export * from "./accept-invite";
|
|
2
|
+
export * from "./activity-view";
|
|
3
3
|
export * from "./invite-capture";
|
|
4
4
|
export * from "./invite-share";
|
|
5
5
|
export * from "./invites-ipc";
|
|
6
|
-
export * from "./invites-screen";
|
|
7
6
|
export * from "./pending-invites-list";
|
|
@@ -14,11 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
// Import the screen so it registers its routes.
|
|
18
|
-
require("./invites-screen");
|
|
19
17
|
__exportStar(require("./accept-invite"), exports);
|
|
18
|
+
__exportStar(require("./activity-view"), exports);
|
|
20
19
|
__exportStar(require("./invite-capture"), exports);
|
|
21
20
|
__exportStar(require("./invite-share"), exports);
|
|
22
21
|
__exportStar(require("./invites-ipc"), exports);
|
|
23
|
-
__exportStar(require("./invites-screen"), exports);
|
|
24
22
|
__exportStar(require("./pending-invites-list"), exports);
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/** sessionStorage key for a captured token awaiting the Accept screen. */
|
|
9
9
|
export declare const PENDING_INVITE_STORAGE_KEY = "peers.pendingInviteToken";
|
|
10
|
-
/** Route of the Accept-invite screen. */
|
|
11
|
-
export declare const ACCEPT_INVITE_PATH = "invites/accept";
|
|
12
10
|
/** Fires whenever a new token is captured, so a mounted app can navigate immediately. */
|
|
13
11
|
export declare const inviteCaptured: import("@peers-app/peers-sdk").Observable<string | undefined>;
|
|
14
12
|
/**
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* startup route restoration never persists them.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.inviteCaptured = exports.
|
|
10
|
+
exports.inviteCaptured = exports.PENDING_INVITE_STORAGE_KEY = void 0;
|
|
11
11
|
exports.inviteTokenFromUrl = inviteTokenFromUrl;
|
|
12
12
|
exports.stashPendingInvite = stashPendingInvite;
|
|
13
13
|
exports.peekPendingInvite = peekPendingInvite;
|
|
@@ -17,8 +17,6 @@ exports.listenForOpenUrlInvites = listenForOpenUrlInvites;
|
|
|
17
17
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
18
18
|
/** sessionStorage key for a captured token awaiting the Accept screen. */
|
|
19
19
|
exports.PENDING_INVITE_STORAGE_KEY = "peers.pendingInviteToken";
|
|
20
|
-
/** Route of the Accept-invite screen. */
|
|
21
|
-
exports.ACCEPT_INVITE_PATH = "invites/accept";
|
|
22
20
|
/** Fires whenever a new token is captured, so a mounted app can navigate immediately. */
|
|
23
21
|
exports.inviteCaptured = (0, peers_sdk_1.observable)(undefined);
|
|
24
22
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const pending_invites_list_1 = require("./pending-invites-list");
|
|
4
|
+
function invite(partial) {
|
|
5
|
+
return {
|
|
6
|
+
status: "pending",
|
|
7
|
+
epoch: 1,
|
|
8
|
+
createdAt: new Date("2026-01-01T00:00:00Z"),
|
|
9
|
+
expiresAt: new Date("2026-02-01T00:00:00Z"),
|
|
10
|
+
...partial,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
describe("classifyInvite", () => {
|
|
14
|
+
const counterpart = {
|
|
15
|
+
userId: "abcdefghijklmnopqrstuvwxy",
|
|
16
|
+
publicKey: "pk",
|
|
17
|
+
publicBoxKey: "box",
|
|
18
|
+
};
|
|
19
|
+
it("puts received decisions in attention", () => {
|
|
20
|
+
const profileRequest = invite({
|
|
21
|
+
inviteId: "1",
|
|
22
|
+
direction: "in",
|
|
23
|
+
type: "contact",
|
|
24
|
+
mode: "profile",
|
|
25
|
+
counterpart,
|
|
26
|
+
parentInviteId: "profileinvite0000000000001",
|
|
27
|
+
});
|
|
28
|
+
const directGroupInvite = invite({
|
|
29
|
+
inviteId: "2",
|
|
30
|
+
direction: "in",
|
|
31
|
+
type: "group",
|
|
32
|
+
mode: "direct",
|
|
33
|
+
counterpart,
|
|
34
|
+
});
|
|
35
|
+
const joinRequest = invite({
|
|
36
|
+
inviteId: "3",
|
|
37
|
+
direction: "in",
|
|
38
|
+
type: "group",
|
|
39
|
+
mode: "approve",
|
|
40
|
+
counterpart,
|
|
41
|
+
parentInviteId: "groupinvite00000000000001",
|
|
42
|
+
});
|
|
43
|
+
expect((0, pending_invites_list_1.classifyInvite)(profileRequest)).toBe("attention");
|
|
44
|
+
expect((0, pending_invites_list_1.actionsForInvite)(profileRequest)).toEqual(["accept", "decline"]);
|
|
45
|
+
expect((0, pending_invites_list_1.classifyInvite)(directGroupInvite)).toBe("attention");
|
|
46
|
+
expect((0, pending_invites_list_1.actionsForInvite)(directGroupInvite)).toEqual(["accept", "decline"]);
|
|
47
|
+
expect((0, pending_invites_list_1.classifyInvite)(joinRequest)).toBe("attention");
|
|
48
|
+
expect((0, pending_invites_list_1.actionsForInvite)(joinRequest)).toEqual(["approve", "deny"]);
|
|
49
|
+
});
|
|
50
|
+
it("keeps locally initiated requests and unsupported device rows waiting", () => {
|
|
51
|
+
const contactRequest = invite({
|
|
52
|
+
inviteId: "4",
|
|
53
|
+
direction: "in",
|
|
54
|
+
type: "contact",
|
|
55
|
+
mode: "profile",
|
|
56
|
+
counterpart,
|
|
57
|
+
recipientUserId: counterpart.userId,
|
|
58
|
+
});
|
|
59
|
+
const groupRequest = invite({
|
|
60
|
+
inviteId: "5",
|
|
61
|
+
direction: "in",
|
|
62
|
+
type: "group",
|
|
63
|
+
mode: "approve",
|
|
64
|
+
counterpart,
|
|
65
|
+
recipientUserId: counterpart.userId,
|
|
66
|
+
});
|
|
67
|
+
const outbound = invite({
|
|
68
|
+
inviteId: "6",
|
|
69
|
+
direction: "out",
|
|
70
|
+
type: "group",
|
|
71
|
+
mode: "open",
|
|
72
|
+
});
|
|
73
|
+
const device = invite({
|
|
74
|
+
inviteId: "7",
|
|
75
|
+
direction: "in",
|
|
76
|
+
type: "device",
|
|
77
|
+
mode: "direct",
|
|
78
|
+
counterpart,
|
|
79
|
+
});
|
|
80
|
+
expect((0, pending_invites_list_1.classifyInvite)(contactRequest)).toBe("waiting");
|
|
81
|
+
expect((0, pending_invites_list_1.actionsForInvite)(contactRequest)).toEqual([]);
|
|
82
|
+
expect((0, pending_invites_list_1.classifyInvite)(groupRequest)).toBe("waiting");
|
|
83
|
+
expect((0, pending_invites_list_1.actionsForInvite)(groupRequest)).toEqual([]);
|
|
84
|
+
expect((0, pending_invites_list_1.classifyInvite)(outbound)).toBe("waiting");
|
|
85
|
+
expect((0, pending_invites_list_1.actionsForInvite)(outbound)).toEqual(["revoke"]);
|
|
86
|
+
expect((0, pending_invites_list_1.classifyInvite)(device)).toBe("waiting");
|
|
87
|
+
expect((0, pending_invites_list_1.actionsForInvite)(device)).toEqual([]);
|
|
88
|
+
});
|
|
89
|
+
it("puts terminal rows in history", () => {
|
|
90
|
+
expect((0, pending_invites_list_1.classifyInvite)(invite({
|
|
91
|
+
inviteId: "8",
|
|
92
|
+
direction: "in",
|
|
93
|
+
type: "contact",
|
|
94
|
+
mode: "contact",
|
|
95
|
+
status: "accepted",
|
|
96
|
+
}))).toBe("history");
|
|
97
|
+
});
|
|
98
|
+
it("describes an open join as automatic rather than approval-gated", () => {
|
|
99
|
+
const openJoin = invite({
|
|
100
|
+
inviteId: "openjoinrequest0000000001",
|
|
101
|
+
direction: "in",
|
|
102
|
+
type: "group",
|
|
103
|
+
mode: "open",
|
|
104
|
+
counterpart: { ...counterpart, displayName: "Ada" },
|
|
105
|
+
recipientUserId: counterpart.userId,
|
|
106
|
+
groupName: "Neighbors",
|
|
107
|
+
deliveryState: "queued",
|
|
108
|
+
});
|
|
109
|
+
expect((0, pending_invites_list_1.describeInviteRow)(openJoin)).toEqual({
|
|
110
|
+
title: "Joining Neighbors",
|
|
111
|
+
detail: "Completing automatically; no approval is required.",
|
|
112
|
+
});
|
|
113
|
+
expect((0, pending_invites_list_1.classifyInvite)(openJoin)).toBe("waiting");
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -3,7 +3,7 @@ import { type IInvitesConsumer } from "@peers-app/peers-sdk";
|
|
|
3
3
|
* Return the typed local-host consumer for the System Invites contract.
|
|
4
4
|
*
|
|
5
5
|
* The consumer is cached per host transport and rebuilt if the transport is replaced
|
|
6
|
-
* (
|
|
6
|
+
* (for example after a socket reconnect).
|
|
7
7
|
*/
|
|
8
8
|
export declare function getInvitesConsumer(): Promise<IInvitesConsumer>;
|
|
9
9
|
/** Shorthand for `(await getInvitesConsumer()).tools`. */
|