@bridgebrew/invitations 0.0.3 → 0.0.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/browser/browser.tsx +51 -15
- package/package.json +3 -3
package/browser/browser.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Invitations (SPEC multi-instance CAP-1, CAP-7, a Connections settings screen): a screen of Admin's System
|
|
2
2
|
// section. "Create invite" asks the host for a single-use Full invite (`POST /_bridge/host/invitations`, 5 minutes) and
|
|
3
|
-
// shows its link to copy, with what Full gives and what plain HTTP risks; the paired clients (`GET /_bridge/host/clients
|
|
4
|
-
// with their device, OS, pairing date and
|
|
5
|
-
// next request is refused.
|
|
3
|
+
// shows its link to copy, with what Full gives and what plain HTTP risks; the paired clients (`GET /_bridge/host/clients`:
|
|
4
|
+
// browsers and apps, bridge#663) with their device, OS, kind, pairing date, last use and who invited them, each revoked
|
|
5
|
+
// after a confirmation (`DELETE …/clients/<id>`): its next request is refused, and only it.
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import {
|
|
8
8
|
Badge,
|
|
@@ -36,11 +36,17 @@ export const inject = ['slots', 'workspace'];
|
|
|
36
36
|
interface Client {
|
|
37
37
|
id: string;
|
|
38
38
|
scope: 'full';
|
|
39
|
+
/** A browser signed in with a code or a launch link, or an app joined with an invite (bridge#663; absent: an app). */
|
|
40
|
+
kind?: 'browser' | 'app';
|
|
41
|
+
/** The client whose invite it came from, or `owner` (the CLI, the local app). */
|
|
42
|
+
invitedBy?: string;
|
|
39
43
|
label: string;
|
|
40
44
|
deviceType: string;
|
|
41
45
|
os: string;
|
|
42
46
|
issuedAt: string;
|
|
43
47
|
lastSeenAt: string;
|
|
48
|
+
/** 30 days past its last use (bridge#663). */
|
|
49
|
+
expiresAt: string;
|
|
44
50
|
}
|
|
45
51
|
interface Invite {
|
|
46
52
|
code: string;
|
|
@@ -80,7 +86,7 @@ const day = (iso: string) => formatDate(iso, { day: 'numeric', month: 'short', y
|
|
|
80
86
|
const deviceIcon = (type: string) =>
|
|
81
87
|
type === 'mobile' || type === 'tablet' ? 'phone' : type === 'bot' ? 'bot' : 'monitor';
|
|
82
88
|
|
|
83
|
-
/** The invite just created: its link to copy, its expiry (counting down), and the warnings. */
|
|
89
|
+
/** The invite just created: its link and its code to copy, its expiry (counting down), and the warnings. */
|
|
84
90
|
function InviteDialog({ invite, onClose }: { invite: Invite; onClose: () => void }) {
|
|
85
91
|
const { toast } = useToast();
|
|
86
92
|
const [now, setNow] = React.useState(Date.now());
|
|
@@ -89,14 +95,14 @@ function InviteDialog({ invite, onClose }: { invite: Invite; onClose: () => void
|
|
|
89
95
|
return () => clearInterval(timer);
|
|
90
96
|
}, []);
|
|
91
97
|
const left = Math.max(0, Math.round((Date.parse(invite.expiresAt) - now) / 1000));
|
|
92
|
-
const copy = () =>
|
|
93
|
-
void copyText(
|
|
94
|
-
() => toast({ variant: 'success', title:
|
|
98
|
+
const copy = (text: string, what: 'link' | 'code') =>
|
|
99
|
+
void copyText(text).then(
|
|
100
|
+
() => toast({ variant: 'success', title: `Invite ${what} copied` }),
|
|
95
101
|
() =>
|
|
96
102
|
toast({
|
|
97
103
|
variant: 'error',
|
|
98
104
|
title: 'Not copied',
|
|
99
|
-
description:
|
|
105
|
+
description: `Select the ${what} and copy it by hand.`,
|
|
100
106
|
}),
|
|
101
107
|
);
|
|
102
108
|
return (
|
|
@@ -112,8 +118,9 @@ function InviteDialog({ invite, onClose }: { invite: Invite; onClose: () => void
|
|
|
112
118
|
</DialogHeader>
|
|
113
119
|
<DialogBody className="flex flex-col gap-3 pb-5">
|
|
114
120
|
<DialogDescription className="m-0 leading-5">
|
|
115
|
-
|
|
116
|
-
Bridge). It
|
|
121
|
+
Open this link on the other device, or enter the code on its Sign in to Bridge page. In
|
|
122
|
+
the Bridge app of another machine, paste the link (the + of its rail, Join a Bridge). It
|
|
123
|
+
works once.
|
|
117
124
|
</DialogDescription>
|
|
118
125
|
<div className="flex items-center gap-2">
|
|
119
126
|
<code
|
|
@@ -122,7 +129,31 @@ function InviteDialog({ invite, onClose }: { invite: Invite; onClose: () => void
|
|
|
122
129
|
>
|
|
123
130
|
{invite.link}
|
|
124
131
|
</code>
|
|
125
|
-
<Button
|
|
132
|
+
<Button
|
|
133
|
+
size="sm"
|
|
134
|
+
variant="outline"
|
|
135
|
+
disabled={left === 0}
|
|
136
|
+
onClick={() => copy(invite.link, 'link')}
|
|
137
|
+
>
|
|
138
|
+
<Icon name="copy" size={13} />
|
|
139
|
+
Copy
|
|
140
|
+
</Button>
|
|
141
|
+
</div>
|
|
142
|
+
<div className="flex items-center gap-2">
|
|
143
|
+
<span className="text-[13px] text-secondary">Code</span>
|
|
144
|
+
<code
|
|
145
|
+
data-invite-code
|
|
146
|
+
className="min-w-0 flex-1 select-all rounded-sm bg-hover px-2 py-1.5 font-mono text-sm tracking-widest text-foreground"
|
|
147
|
+
>
|
|
148
|
+
{invite.code}
|
|
149
|
+
</code>
|
|
150
|
+
<Button
|
|
151
|
+
size="sm"
|
|
152
|
+
variant="outline"
|
|
153
|
+
aria-label="Copy code"
|
|
154
|
+
disabled={left === 0}
|
|
155
|
+
onClick={() => copy(invite.code, 'code')}
|
|
156
|
+
>
|
|
126
157
|
<Icon name="copy" size={13} />
|
|
127
158
|
Copy
|
|
128
159
|
</Button>
|
|
@@ -306,7 +337,7 @@ function Invitations({ ctx }: { ctx: Context }) {
|
|
|
306
337
|
<Section
|
|
307
338
|
size="lg"
|
|
308
339
|
title="Invite a client"
|
|
309
|
-
description="
|
|
340
|
+
description="Sign another device in to this Bridge: a browser enters the code or opens the link; the Bridge app of another machine joins with the link, and this Bridge's workspaces show in its rail. A paired client has Full access."
|
|
310
341
|
actions={
|
|
311
342
|
<Button variant="primary" disabled={creating} onClick={() => void create()}>
|
|
312
343
|
{creating ? (
|
|
@@ -353,8 +384,8 @@ function Invitations({ ctx }: { ctx: Context }) {
|
|
|
353
384
|
data-empty
|
|
354
385
|
className="rounded-default border border-dashed border-border py-6"
|
|
355
386
|
>
|
|
356
|
-
No paired client yet. Create an invite, then
|
|
357
|
-
other machine.
|
|
387
|
+
No paired client yet. Create an invite, then enter its code in a browser, or paste
|
|
388
|
+
its link in the Bridge app of the other machine.
|
|
358
389
|
</EmptyState>
|
|
359
390
|
) : (
|
|
360
391
|
<Card className="p-0">
|
|
@@ -383,8 +414,13 @@ function Invitations({ ctx }: { ctx: Context }) {
|
|
|
383
414
|
]
|
|
384
415
|
.filter(Boolean)
|
|
385
416
|
.join(' · ') || 'Unknown device'}
|
|
417
|
+
{' · '}
|
|
418
|
+
{client.kind === 'browser' ? 'Browser' : 'App'}
|
|
386
419
|
{' · '}Paired {day(client.issuedAt)} · Last seen{' '}
|
|
387
|
-
{ago(client.lastSeenAt)}
|
|
420
|
+
{ago(client.lastSeenAt)} · Expires {day(client.expiresAt)}
|
|
421
|
+
{client.invitedBy &&
|
|
422
|
+
client.invitedBy !== 'owner' &&
|
|
423
|
+
` · Invited by ${clients.find(({ id }) => id === client.invitedBy)?.label ?? 'a revoked client'}`}
|
|
388
424
|
</span>
|
|
389
425
|
</div>
|
|
390
426
|
<Badge className="shrink-0">Full</Badge>
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bridgebrew/invitations",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "Invites another Bridge client (the desktop app on another machine) with Full access, and lists the paired clients with revoke. Admin only.",
|
|
5
|
+
"description": "Invites another Bridge client (a browser, or the desktop app on another machine) with Full access, and lists the paired clients with revoke. Admin only.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"bridge-plugin"
|
|
8
8
|
],
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"typecheck": "bridge plugin check ."
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
|
-
"bridge": ">=0.0.1-nightly.
|
|
43
|
+
"bridge": ">=0.0.1-nightly.20261123.1"
|
|
44
44
|
}
|
|
45
45
|
}
|