@dxos/plugin-client 0.7.5-labs.071a3e2 → 0.7.5-labs.401163d
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/dist/lib/browser/{app-graph-builder-6LOTDB4T.mjs → app-graph-builder-JRQVJHEH.mjs} +2 -2
- package/dist/lib/browser/chunk-BFNE5KCF.mjs +271 -0
- package/dist/lib/browser/chunk-BFNE5KCF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-E3OUNOEL.mjs → chunk-GYCVFUTM.mjs} +13 -1
- package/dist/lib/browser/{chunk-E3OUNOEL.mjs.map → chunk-GYCVFUTM.mjs.map} +3 -3
- package/dist/lib/browser/{client-BEJK55IM.mjs → client-BY3RGW3H.mjs} +2 -7
- package/dist/lib/browser/client-BY3RGW3H.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +12 -5
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/{intent-resolver-E6TL7E24.mjs → intent-resolver-LWSDA6RM.mjs} +110 -6
- package/dist/lib/browser/intent-resolver-LWSDA6RM.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-K5NKVCIB.mjs → react-surface-6BINNBEX.mjs} +20 -4
- package/dist/lib/browser/react-surface-6BINNBEX.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{app-graph-builder-JCND3P6G.cjs → app-graph-builder-R6QR2VLZ.cjs} +6 -6
- package/dist/lib/node/chunk-3P5BBMXO.cjs +299 -0
- package/dist/lib/node/chunk-3P5BBMXO.cjs.map +7 -0
- package/dist/lib/node/{chunk-NVYWMDF3.cjs → chunk-NZKGFE46.cjs} +16 -4
- package/dist/lib/node/{chunk-NVYWMDF3.cjs.map → chunk-NZKGFE46.cjs.map} +3 -3
- package/dist/lib/node/{client-AHIW24VM.cjs → client-JCI7A3IV.cjs} +5 -10
- package/dist/lib/node/client-JCI7A3IV.cjs.map +7 -0
- package/dist/lib/node/index.cjs +12 -5
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/{intent-resolver-DUPICQ3F.cjs → intent-resolver-ODZVEAZ2.cjs} +124 -20
- package/dist/lib/node/intent-resolver-ODZVEAZ2.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-YQ2PKXNV.cjs → react-surface-KRKGFWS3.cjs} +27 -15
- package/dist/lib/node/react-surface-KRKGFWS3.cjs.map +7 -0
- package/dist/lib/node/types.cjs +2 -2
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{app-graph-builder-ZLGKFBLY.mjs → app-graph-builder-WXXGCOJB.mjs} +2 -2
- package/dist/lib/node-esm/chunk-2FPF25KT.mjs +272 -0
- package/dist/lib/node-esm/chunk-2FPF25KT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-74T33KTB.mjs → chunk-M2NR7HNG.mjs} +13 -1
- package/dist/lib/node-esm/{chunk-74T33KTB.mjs.map → chunk-M2NR7HNG.mjs.map} +3 -3
- package/dist/lib/node-esm/{client-FY7IDNRL.mjs → client-XWK653HB.mjs} +2 -7
- package/dist/lib/node-esm/client-XWK653HB.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +12 -5
- package/dist/lib/node-esm/index.mjs.map +2 -2
- package/dist/lib/node-esm/{intent-resolver-QUQH2LS2.mjs → intent-resolver-IHYGJREB.mjs} +110 -6
- package/dist/lib/node-esm/intent-resolver-IHYGJREB.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-H34XQPWC.mjs → react-surface-OQFDVSAP.mjs} +20 -4
- package/dist/lib/node-esm/react-surface-OQFDVSAP.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +1 -1
- package/dist/types/src/capabilities/client.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/IdentityDialog.d.ts.map +1 -1
- package/dist/types/src/components/ManageCredentialsDialog.d.ts +4 -0
- package/dist/types/src/components/ManageCredentialsDialog.d.ts.map +1 -0
- package/dist/types/src/components/ManageCredentialsDialog.stories.d.ts +8 -0
- package/dist/types/src/components/ManageCredentialsDialog.stories.d.ts.map +1 -0
- package/dist/types/src/components/RecoveryCodeDialog.d.ts.map +1 -1
- package/dist/types/src/components/RecoverySetupDialog.d.ts +4 -0
- package/dist/types/src/components/RecoverySetupDialog.d.ts.map +1 -0
- package/dist/types/src/components/RecoverySetupDialog.stories.d.ts +8 -0
- package/dist/types/src/components/RecoverySetupDialog.stories.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +7 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +16 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +20 -16
- package/src/capabilities/client.ts +1 -3
- package/src/capabilities/intent-resolver.ts +69 -1
- package/src/capabilities/react-surface.tsx +15 -0
- package/src/components/IdentityDialog.tsx +12 -0
- package/src/components/ManageCredentialsDialog.stories.tsx +57 -0
- package/src/components/ManageCredentialsDialog.tsx +64 -0
- package/src/components/RecoveryCodeDialog.stories.tsx +4 -4
- package/src/components/RecoveryCodeDialog.tsx +2 -1
- package/src/components/RecoverySetupDialog.stories.tsx +77 -0
- package/src/components/RecoverySetupDialog.tsx +52 -0
- package/src/components/index.ts +1 -0
- package/src/translations.ts +10 -1
- package/src/types.ts +10 -0
- package/dist/lib/browser/chunk-PDSHZE3P.mjs +0 -162
- package/dist/lib/browser/chunk-PDSHZE3P.mjs.map +0 -7
- package/dist/lib/browser/client-BEJK55IM.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-E6TL7E24.mjs.map +0 -7
- package/dist/lib/browser/react-surface-K5NKVCIB.mjs.map +0 -7
- package/dist/lib/node/chunk-VUJ3ZPK3.cjs +0 -190
- package/dist/lib/node/chunk-VUJ3ZPK3.cjs.map +0 -7
- package/dist/lib/node/client-AHIW24VM.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-DUPICQ3F.cjs.map +0 -7
- package/dist/lib/node/react-surface-YQ2PKXNV.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-WS4CKCUR.mjs +0 -163
- package/dist/lib/node-esm/chunk-WS4CKCUR.mjs.map +0 -7
- package/dist/lib/node-esm/client-FY7IDNRL.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-QUQH2LS2.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-H34XQPWC.mjs.map +0 -7
- /package/dist/lib/browser/{app-graph-builder-6LOTDB4T.mjs.map → app-graph-builder-JRQVJHEH.mjs.map} +0 -0
- /package/dist/lib/node/{app-graph-builder-JCND3P6G.cjs.map → app-graph-builder-R6QR2VLZ.cjs.map} +0 -0
- /package/dist/lib/node-esm/{app-graph-builder-ZLGKFBLY.mjs.map → app-graph-builder-WXXGCOJB.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-client",
|
|
3
|
-
"version": "0.7.5-labs.
|
|
3
|
+
"version": "0.7.5-labs.401163d",
|
|
4
4
|
"description": "DXOS Surface plugin for DXOS Client",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -33,19 +33,18 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@preact/signals-core": "^1.6.0",
|
|
36
|
-
"@dxos/app-framework": "0.7.5-labs.
|
|
37
|
-
"@dxos/config": "0.7.5-labs.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/echo-signals": "0.7.5-labs.
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/log": "0.7.5-labs.
|
|
43
|
-
"@dxos/plugin-graph": "0.7.5-labs.
|
|
44
|
-
"@dxos/plugin-observability": "0.7.5-labs.
|
|
45
|
-
"@dxos/react-
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/shell": "0.7.5-labs.
|
|
48
|
-
"@dxos/util": "0.7.5-labs.071a3e2"
|
|
36
|
+
"@dxos/app-framework": "0.7.5-labs.401163d",
|
|
37
|
+
"@dxos/config": "0.7.5-labs.401163d",
|
|
38
|
+
"@dxos/echo-schema": "0.7.5-labs.401163d",
|
|
39
|
+
"@dxos/echo-signals": "0.7.5-labs.401163d",
|
|
40
|
+
"@dxos/invariant": "0.7.5-labs.401163d",
|
|
41
|
+
"@dxos/local-storage": "0.7.5-labs.401163d",
|
|
42
|
+
"@dxos/log": "0.7.5-labs.401163d",
|
|
43
|
+
"@dxos/plugin-graph": "0.7.5-labs.401163d",
|
|
44
|
+
"@dxos/plugin-observability": "0.7.5-labs.401163d",
|
|
45
|
+
"@dxos/react-client": "0.7.5-labs.401163d",
|
|
46
|
+
"@dxos/util": "0.7.5-labs.401163d",
|
|
47
|
+
"@dxos/shell": "0.7.5-labs.401163d"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
50
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -54,12 +53,17 @@
|
|
|
54
53
|
"react": "~18.2.0",
|
|
55
54
|
"react-dom": "~18.2.0",
|
|
56
55
|
"vite": "5.4.7",
|
|
57
|
-
"@dxos/
|
|
56
|
+
"@dxos/live-object": "0.7.5-labs.401163d",
|
|
57
|
+
"@dxos/react-ui": "0.7.5-labs.401163d",
|
|
58
|
+
"@dxos/react-ui-theme": "0.7.5-labs.401163d",
|
|
59
|
+
"@dxos/storybook-utils": "0.7.5-labs.401163d"
|
|
58
60
|
},
|
|
59
61
|
"peerDependencies": {
|
|
60
62
|
"@phosphor-icons/react": "^2.1.5",
|
|
61
63
|
"react": "~18.2.0",
|
|
62
|
-
"react-dom": "~18.2.0"
|
|
64
|
+
"react-dom": "~18.2.0",
|
|
65
|
+
"@dxos/react-ui": "0.7.5-labs.401163d",
|
|
66
|
+
"@dxos/react-ui-theme": "0.7.5-labs.401163d"
|
|
63
67
|
},
|
|
64
68
|
"publishConfig": {
|
|
65
69
|
"access": "public"
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { contributes, type PluginsContext } from '@dxos/app-framework';
|
|
6
|
-
import { Config, Defaults, Envs, Local, Storage } from '@dxos/config';
|
|
7
6
|
import { Client } from '@dxos/react-client';
|
|
8
7
|
|
|
9
8
|
import { ClientCapabilities } from './capabilities';
|
|
@@ -15,8 +14,7 @@ type ClientCapabilityOptions = Omit<ClientPluginOptions, 'appKey' | 'invitationU
|
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
export default async ({ context, onClientInitialized, ...options }: ClientCapabilityOptions) => {
|
|
18
|
-
const
|
|
19
|
-
const client = new Client({ config, ...options });
|
|
17
|
+
const client = new Client(options);
|
|
20
18
|
await client.initialize();
|
|
21
19
|
await onClientInitialized?.(context, client);
|
|
22
20
|
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from '@dxos/app-framework';
|
|
13
13
|
import { invariant } from '@dxos/invariant';
|
|
14
14
|
import { ObservabilityAction } from '@dxos/plugin-observability/types';
|
|
15
|
+
import { PublicKey } from '@dxos/react-client';
|
|
15
16
|
import { type JoinPanelProps } from '@dxos/shell/react';
|
|
16
17
|
|
|
17
18
|
import { ClientCapabilities } from './capabilities';
|
|
@@ -21,9 +22,10 @@ import { ClientAction, type ClientPluginOptions } from '../types';
|
|
|
21
22
|
|
|
22
23
|
type IntentResolverOptions = Pick<ClientPluginOptions, 'onReset'> & {
|
|
23
24
|
context: PluginsContext;
|
|
25
|
+
appName?: string;
|
|
24
26
|
};
|
|
25
27
|
|
|
26
|
-
export default ({ context, onReset }: IntentResolverOptions) =>
|
|
28
|
+
export default ({ context, appName = 'Composer', onReset }: IntentResolverOptions) =>
|
|
27
29
|
contributes(Capabilities.IntentResolver, [
|
|
28
30
|
createResolver({
|
|
29
31
|
intent: ClientAction.CreateIdentity,
|
|
@@ -127,4 +129,70 @@ export default ({ context, onReset }: IntentResolverOptions) =>
|
|
|
127
129
|
};
|
|
128
130
|
},
|
|
129
131
|
}),
|
|
132
|
+
createResolver({
|
|
133
|
+
intent: ClientAction.CreatePasskey,
|
|
134
|
+
resolve: async () => {
|
|
135
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
136
|
+
const identity = client.halo.identity.get();
|
|
137
|
+
invariant(identity, 'Identity not available');
|
|
138
|
+
|
|
139
|
+
// TODO(wittjosiah): Consider factoring out passkey creation to the halo api.
|
|
140
|
+
const credential = await navigator.credentials.create({
|
|
141
|
+
publicKey: {
|
|
142
|
+
challenge: new Uint8Array(),
|
|
143
|
+
rp: { id: location.hostname, name: appName },
|
|
144
|
+
user: {
|
|
145
|
+
id: new TextEncoder().encode(identity.did),
|
|
146
|
+
name: identity.did,
|
|
147
|
+
displayName: identity.profile?.displayName ?? '',
|
|
148
|
+
},
|
|
149
|
+
pubKeyCredParams: [
|
|
150
|
+
{ type: 'public-key', alg: -8 }, // Ed25519 (not yet supported across all browsers)
|
|
151
|
+
{ type: 'public-key', alg: -7 }, // ES256
|
|
152
|
+
],
|
|
153
|
+
// https://web.dev/articles/webauthn-discoverable-credentials#resident-key
|
|
154
|
+
authenticatorSelection: {
|
|
155
|
+
residentKey: 'required',
|
|
156
|
+
requireResidentKey: true,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
invariant(credential, 'Credential not available');
|
|
162
|
+
const recoveryKey = PublicKey.from(new Uint8Array((credential as any).response.getPublicKey()));
|
|
163
|
+
const algorithm = (credential as any).response.getPublicKeyAlgorithm() === -7 ? 'ES256' : 'ED25519';
|
|
164
|
+
|
|
165
|
+
// TODO(wittjosiah): This needs a proper api.
|
|
166
|
+
invariant(client.services.services.IdentityService, 'IdentityService not available');
|
|
167
|
+
await client.services.services.IdentityService.createRecoveryCredential({ recoveryKey, algorithm });
|
|
168
|
+
},
|
|
169
|
+
}),
|
|
170
|
+
createResolver({
|
|
171
|
+
intent: ClientAction.RedeemPasskey,
|
|
172
|
+
resolve: async () => {
|
|
173
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
174
|
+
// TODO(wittjosiah): This needs a proper api.
|
|
175
|
+
invariant(client.services.services.IdentityService, 'IdentityService not available');
|
|
176
|
+
const { deviceKey, controlFeedKey, challenge } =
|
|
177
|
+
await client.services.services.IdentityService.requestRecoveryChallenge();
|
|
178
|
+
const credential = await navigator.credentials.get({
|
|
179
|
+
publicKey: {
|
|
180
|
+
challenge: Buffer.from(challenge, 'base64'),
|
|
181
|
+
rpId: location.hostname,
|
|
182
|
+
userVerification: 'required',
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
const identityDid = new TextDecoder().decode((credential as any).response.userHandle);
|
|
186
|
+
await client.services.services.IdentityService.recoverIdentity({
|
|
187
|
+
external: {
|
|
188
|
+
identityDid,
|
|
189
|
+
deviceKey,
|
|
190
|
+
controlFeedKey,
|
|
191
|
+
signature: Buffer.from((credential as any).response.signature),
|
|
192
|
+
clientDataJson: Buffer.from((credential as any).response.clientDataJSON),
|
|
193
|
+
authenticatorData: Buffer.from((credential as any).response.authenticatorData),
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
}),
|
|
130
198
|
]);
|
|
@@ -13,9 +13,12 @@ import {
|
|
|
13
13
|
JOIN_DIALOG,
|
|
14
14
|
JoinDialog,
|
|
15
15
|
RECOVER_CODE_DIALOG,
|
|
16
|
+
RECOVER_SETUP_DIALOG,
|
|
16
17
|
RecoveryCodeDialog,
|
|
18
|
+
RecoverySetupDialog,
|
|
17
19
|
type RecoveryCodeDialogProps,
|
|
18
20
|
} from '../components';
|
|
21
|
+
import { MANAGE_CREDENTIALS_DIALOG, ManageCredentialsDialog } from '../components/ManageCredentialsDialog';
|
|
19
22
|
|
|
20
23
|
type ReactSurfaceOptions = {
|
|
21
24
|
createInvitationUrl: (invitationCode: string) => string;
|
|
@@ -41,4 +44,16 @@ export default ({ createInvitationUrl }: ReactSurfaceOptions) =>
|
|
|
41
44
|
filter: (data): data is { props: RecoveryCodeDialogProps } => data.component === RECOVER_CODE_DIALOG,
|
|
42
45
|
component: ({ data }) => <RecoveryCodeDialog {...data.props} />,
|
|
43
46
|
}),
|
|
47
|
+
createSurface({
|
|
48
|
+
id: RECOVER_SETUP_DIALOG,
|
|
49
|
+
role: 'dialog',
|
|
50
|
+
filter: (data): data is any => data.component === RECOVER_SETUP_DIALOG,
|
|
51
|
+
component: () => <RecoverySetupDialog />,
|
|
52
|
+
}),
|
|
53
|
+
createSurface({
|
|
54
|
+
id: MANAGE_CREDENTIALS_DIALOG,
|
|
55
|
+
role: 'dialog',
|
|
56
|
+
filter: (data): data is any => data.component === MANAGE_CREDENTIALS_DIALOG,
|
|
57
|
+
component: () => <ManageCredentialsDialog />,
|
|
58
|
+
}),
|
|
44
59
|
]);
|
|
@@ -9,6 +9,7 @@ import { useClient } from '@dxos/react-client';
|
|
|
9
9
|
import { Clipboard, Dialog } from '@dxos/react-ui';
|
|
10
10
|
import { IdentityPanel, type IdentityPanelProps } from '@dxos/shell/react';
|
|
11
11
|
|
|
12
|
+
import { MANAGE_CREDENTIALS_DIALOG } from './ManageCredentialsDialog';
|
|
12
13
|
import { CLIENT_PLUGIN } from '../meta';
|
|
13
14
|
import { ClientAction } from '../types';
|
|
14
15
|
|
|
@@ -44,6 +45,16 @@ export const IdentityDialog = (props: IdentityPanelProps) => {
|
|
|
44
45
|
await dispatch(createIntent(ClientAction.ResetStorage, { target: 'deviceInvitation' }));
|
|
45
46
|
}, [dispatch]);
|
|
46
47
|
|
|
48
|
+
const handleManageCredentials = useCallback(async () => {
|
|
49
|
+
await dispatch(
|
|
50
|
+
createIntent(LayoutAction.UpdateDialog, {
|
|
51
|
+
part: 'dialog',
|
|
52
|
+
subject: MANAGE_CREDENTIALS_DIALOG,
|
|
53
|
+
options: { state: true, blockAlign: 'start' },
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
}, [dispatch]);
|
|
57
|
+
|
|
47
58
|
return (
|
|
48
59
|
<Dialog.Content>
|
|
49
60
|
<Clipboard.Provider>
|
|
@@ -54,6 +65,7 @@ export const IdentityDialog = (props: IdentityPanelProps) => {
|
|
|
54
65
|
onResetStorage={handleResetStorage}
|
|
55
66
|
onRecover={handleRecover}
|
|
56
67
|
onJoinNewIdentity={handleJoinNewIdentity}
|
|
68
|
+
onManageCredentials={handleManageCredentials}
|
|
57
69
|
/>
|
|
58
70
|
</Clipboard.Provider>
|
|
59
71
|
</Dialog.Content>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { IntentPlugin } from '@dxos/app-framework';
|
|
11
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
+
import { AlertDialog } from '@dxos/react-ui';
|
|
13
|
+
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
14
|
+
|
|
15
|
+
import { ManageCredentialsDialog } from './ManageCredentialsDialog';
|
|
16
|
+
import { ClientPlugin } from '../ClientPlugin';
|
|
17
|
+
import translations from '../translations';
|
|
18
|
+
|
|
19
|
+
const Render = () => {
|
|
20
|
+
return (
|
|
21
|
+
<AlertDialog.Root open>
|
|
22
|
+
<AlertDialog.Overlay>
|
|
23
|
+
<ManageCredentialsDialog />
|
|
24
|
+
</AlertDialog.Overlay>
|
|
25
|
+
</AlertDialog.Root>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const meta: Meta = {
|
|
30
|
+
title: 'plugins/plugin-client/ManageCredentialsDialog',
|
|
31
|
+
component: ManageCredentialsDialog,
|
|
32
|
+
render: Render,
|
|
33
|
+
decorators: [
|
|
34
|
+
withPluginManager({
|
|
35
|
+
plugins: [
|
|
36
|
+
IntentPlugin(),
|
|
37
|
+
ClientPlugin({
|
|
38
|
+
onClientInitialized: async (_, client) => {
|
|
39
|
+
await client.halo.createIdentity();
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
}),
|
|
44
|
+
withTheme,
|
|
45
|
+
withLayout({ tooltips: true }),
|
|
46
|
+
],
|
|
47
|
+
parameters: {
|
|
48
|
+
layout: 'fullscreen',
|
|
49
|
+
translations,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default meta;
|
|
54
|
+
|
|
55
|
+
type Story = StoryObj<typeof ManageCredentialsDialog>;
|
|
56
|
+
|
|
57
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Receipt, Key } from '@phosphor-icons/react';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
+
import { useCredentials } from '@dxos/react-client/halo';
|
|
10
|
+
import { Dialog, Icon, List, ListItem, useTranslation } from '@dxos/react-ui';
|
|
11
|
+
import { BifurcatedAction, type ActionMenuItem } from '@dxos/shell/react';
|
|
12
|
+
|
|
13
|
+
import { CLIENT_PLUGIN } from '../meta';
|
|
14
|
+
import { ClientAction } from '../types';
|
|
15
|
+
|
|
16
|
+
export const MANAGE_CREDENTIALS_DIALOG = `${CLIENT_PLUGIN}/ManageCredentialsDialog`;
|
|
17
|
+
|
|
18
|
+
// TODO(wittjosiah): Factor panel out to @dxos/shell.
|
|
19
|
+
export const ManageCredentialsDialog = () => {
|
|
20
|
+
const { t } = useTranslation(CLIENT_PLUGIN);
|
|
21
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
22
|
+
const credentials = useCredentials();
|
|
23
|
+
const recoveryCredentials = credentials.filter(
|
|
24
|
+
(credential) => credential.subject.assertion['@type'] === 'dxos.halo.credentials.IdentityRecovery',
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// TODO(wittjosiah): Reconsile w/ RecoverySetupDialog actions.
|
|
28
|
+
const actions: Record<string, ActionMenuItem> = useMemo(
|
|
29
|
+
() => ({
|
|
30
|
+
createPasskey: {
|
|
31
|
+
label: t('create passkey label'),
|
|
32
|
+
description: t('create passkey description'),
|
|
33
|
+
// TODO(wittjosiah): Ideally this would be a `user-key` icon.
|
|
34
|
+
icon: Key,
|
|
35
|
+
onClick: () => dispatch(createIntent(ClientAction.CreatePasskey)),
|
|
36
|
+
},
|
|
37
|
+
createRecoveryCode: {
|
|
38
|
+
label: t('create recovery code label'),
|
|
39
|
+
description: t('create recovery code description'),
|
|
40
|
+
icon: Receipt,
|
|
41
|
+
onClick: () => dispatch(createIntent(ClientAction.CreateRecoveryCode)),
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
[t],
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Dialog.Content classNames='bs-content min-bs-[15rem] max-bs-full md:max-is-[25rem] overflow-hidden'>
|
|
49
|
+
<Dialog.Title>{t('manage credentials dialog title')}</Dialog.Title>
|
|
50
|
+
<List classNames='py-4'>
|
|
51
|
+
{recoveryCredentials.map((credential) => (
|
|
52
|
+
<ListItem.Root key={credential.id?.toHex()}>
|
|
53
|
+
<ListItem.Endcap>
|
|
54
|
+
<Icon icon='ph--key--regular' size={5} />
|
|
55
|
+
</ListItem.Endcap>
|
|
56
|
+
<ListItem.Heading>{credential.issuanceDate.toLocaleString()}</ListItem.Heading>
|
|
57
|
+
</ListItem.Root>
|
|
58
|
+
))}
|
|
59
|
+
</List>
|
|
60
|
+
<div className='grow' />
|
|
61
|
+
<BifurcatedAction actions={actions} />
|
|
62
|
+
</Dialog.Content>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -17,16 +17,16 @@ import translations from '../translations';
|
|
|
17
17
|
|
|
18
18
|
const Render = () => {
|
|
19
19
|
const client = useClient();
|
|
20
|
-
const [
|
|
20
|
+
const [recoveryCode, setRecoveryCode] = useState<string>();
|
|
21
21
|
useAsyncEffect(async () => {
|
|
22
22
|
const { recoveryCode } = (await client.services.services.IdentityService?.createRecoveryCredential({})) ?? {};
|
|
23
|
-
|
|
23
|
+
setRecoveryCode(recoveryCode);
|
|
24
24
|
}, [client]);
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
|
-
<AlertDialog.Root open={!!
|
|
27
|
+
<AlertDialog.Root open={!!recoveryCode}>
|
|
28
28
|
<AlertDialog.Overlay>
|
|
29
|
-
<RecoveryCodeDialog code={
|
|
29
|
+
<RecoveryCodeDialog code={recoveryCode ?? ''} />
|
|
30
30
|
</AlertDialog.Overlay>
|
|
31
31
|
</AlertDialog.Root>
|
|
32
32
|
);
|
|
@@ -14,6 +14,7 @@ export type RecoveryCodeDialogProps = {
|
|
|
14
14
|
code: string;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// TODO(wittjosiah): Factor panel out to @dxos/shell.
|
|
17
18
|
export const RecoveryCodeDialog = ({ code }: RecoveryCodeDialogProps) => {
|
|
18
19
|
const { t } = useTranslation(CLIENT_PLUGIN);
|
|
19
20
|
const [confirmation, setConfirmation] = useState(false);
|
|
@@ -59,7 +60,7 @@ const Code = ({ code }: { code: string }) => {
|
|
|
59
60
|
<Clipboard.IconButton value={code} classNames='absolute top-2 right-2 invisible group-hover:visible' />
|
|
60
61
|
<div className='grid grid-cols-4'>
|
|
61
62
|
{words.map((word, i) => (
|
|
62
|
-
<div key={i} className='flex items-center p-2 gap-2
|
|
63
|
+
<div key={i} className='flex items-center p-2 gap-2'>
|
|
63
64
|
<div className='w-4 text-xs text-center text-subdued'>{i + 1}</div>
|
|
64
65
|
<div className='text-sm'>{word}</div>
|
|
65
66
|
</div>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { createResolver, contributes, Capabilities, IntentPlugin, LayoutAction } from '@dxos/app-framework';
|
|
11
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
+
import { S } from '@dxos/echo-schema';
|
|
13
|
+
import { create } from '@dxos/live-object';
|
|
14
|
+
import { AlertDialog } from '@dxos/react-ui';
|
|
15
|
+
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
16
|
+
|
|
17
|
+
import { RECOVER_CODE_DIALOG, RecoveryCodeDialog } from './RecoveryCodeDialog';
|
|
18
|
+
import { RecoverySetupDialog } from './RecoverySetupDialog';
|
|
19
|
+
import { ClientPlugin } from '../ClientPlugin';
|
|
20
|
+
import translations from '../translations';
|
|
21
|
+
|
|
22
|
+
const state = create<{ recoveryCode?: string }>({});
|
|
23
|
+
|
|
24
|
+
const Render = () => {
|
|
25
|
+
return (
|
|
26
|
+
<AlertDialog.Root open>
|
|
27
|
+
<AlertDialog.Overlay>
|
|
28
|
+
{state.recoveryCode ? <RecoveryCodeDialog code={state.recoveryCode} /> : <RecoverySetupDialog />}
|
|
29
|
+
</AlertDialog.Overlay>
|
|
30
|
+
</AlertDialog.Root>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const meta: Meta = {
|
|
35
|
+
title: 'plugins/plugin-client/RecoverySetupDialog',
|
|
36
|
+
component: RecoverySetupDialog,
|
|
37
|
+
render: Render,
|
|
38
|
+
decorators: [
|
|
39
|
+
withPluginManager({
|
|
40
|
+
plugins: [
|
|
41
|
+
IntentPlugin(),
|
|
42
|
+
ClientPlugin({
|
|
43
|
+
onClientInitialized: async (_, client) => {
|
|
44
|
+
await client.halo.createIdentity();
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
],
|
|
48
|
+
capabilities: [
|
|
49
|
+
contributes(
|
|
50
|
+
Capabilities.IntentResolver,
|
|
51
|
+
createResolver({
|
|
52
|
+
intent: LayoutAction.UpdateLayout,
|
|
53
|
+
filter: (data): data is S.Schema.Type<typeof LayoutAction.UpdateDialog.fields.input> =>
|
|
54
|
+
S.is(LayoutAction.UpdateDialog.fields.input)(data),
|
|
55
|
+
resolve: (data) => {
|
|
56
|
+
if (data.subject === RECOVER_CODE_DIALOG) {
|
|
57
|
+
state.recoveryCode = data.options?.props?.code;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
),
|
|
62
|
+
],
|
|
63
|
+
}),
|
|
64
|
+
withTheme,
|
|
65
|
+
withLayout({ tooltips: true }),
|
|
66
|
+
],
|
|
67
|
+
parameters: {
|
|
68
|
+
layout: 'fullscreen',
|
|
69
|
+
translations,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default meta;
|
|
74
|
+
|
|
75
|
+
type Story = StoryObj<typeof RecoverySetupDialog>;
|
|
76
|
+
|
|
77
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Key, Receipt } from '@phosphor-icons/react';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { createIntent, LayoutAction, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
+
import { AlertDialog, useTranslation } from '@dxos/react-ui';
|
|
10
|
+
import { type ActionMenuItem, BifurcatedAction } from '@dxos/shell/react';
|
|
11
|
+
|
|
12
|
+
import { CLIENT_PLUGIN } from '../meta';
|
|
13
|
+
import { ClientAction } from '../types';
|
|
14
|
+
|
|
15
|
+
export const RECOVER_SETUP_DIALOG = `${CLIENT_PLUGIN}/RecoverySetupDialog`;
|
|
16
|
+
|
|
17
|
+
// TODO(wittjosiah): Factor panel out to @dxos/shell.
|
|
18
|
+
export const RecoverySetupDialog = () => {
|
|
19
|
+
const { t } = useTranslation(CLIENT_PLUGIN);
|
|
20
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
21
|
+
|
|
22
|
+
const actions: Record<string, ActionMenuItem> = useMemo(
|
|
23
|
+
() => ({
|
|
24
|
+
createPasskey: {
|
|
25
|
+
label: t('create passkey label'),
|
|
26
|
+
description: t('create passkey description'),
|
|
27
|
+
// TODO(wittjosiah): Ideally this would be a `user-key` icon.
|
|
28
|
+
icon: Key,
|
|
29
|
+
onClick: async () => {
|
|
30
|
+
await dispatch(createIntent(ClientAction.CreatePasskey));
|
|
31
|
+
await dispatch(createIntent(LayoutAction.UpdateDialog, { part: 'dialog', options: { state: false } }));
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
createRecoveryCode: {
|
|
35
|
+
label: t('create recovery code label'),
|
|
36
|
+
description: t('create recovery code description'),
|
|
37
|
+
icon: Receipt,
|
|
38
|
+
onClick: () => dispatch(createIntent(ClientAction.CreateRecoveryCode)),
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
[t],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<AlertDialog.Content classNames='bs-content min-bs-[15rem] max-bs-full md:max-is-[25rem] overflow-hidden'>
|
|
46
|
+
<AlertDialog.Title>{t('recovery setup dialog title')}</AlertDialog.Title>
|
|
47
|
+
<p className='py-4'>{t('recovery setup dialog description')}</p>
|
|
48
|
+
<div className='grow' />
|
|
49
|
+
<BifurcatedAction actions={actions} />
|
|
50
|
+
</AlertDialog.Content>
|
|
51
|
+
);
|
|
52
|
+
};
|
package/src/components/index.ts
CHANGED
package/src/translations.ts
CHANGED
|
@@ -9,7 +9,16 @@ export default [
|
|
|
9
9
|
'en-US': {
|
|
10
10
|
[CLIENT_PLUGIN]: {
|
|
11
11
|
'open shell label': 'Open HALO',
|
|
12
|
-
'
|
|
12
|
+
'manage credentials dialog title': 'Manage Account Recovery',
|
|
13
|
+
'recovery setup dialog title': 'Account Recovery',
|
|
14
|
+
'recovery setup dialog description':
|
|
15
|
+
'In order to recover your account you need to register a recovery credential. Passkeys are the recommended way to do this, they can be stored in your browser or in a password manager.',
|
|
16
|
+
'create passkey label': 'Create Passkey',
|
|
17
|
+
'create passkey description':
|
|
18
|
+
'A passkey is a secure and easy to use credential that can be used to recover your account.',
|
|
19
|
+
'create recovery code label': 'Create Recovery Code',
|
|
20
|
+
'create recovery code description': 'A recovery code is 12 word phrase representing a private key.',
|
|
21
|
+
'recovery code dialog title': 'Recovery Code',
|
|
13
22
|
'recovery code dialog description':
|
|
14
23
|
'This is your identity recovery code, store it in a safe place. You can use it to recover your identity if you ever lose access to your devices.',
|
|
15
24
|
'recovery code dialog warning 1': 'NOTE: This code will not be displayed again.',
|
package/src/types.ts
CHANGED
|
@@ -64,6 +64,16 @@ export namespace ClientAction {
|
|
|
64
64
|
input: S.Void,
|
|
65
65
|
output: S.Void,
|
|
66
66
|
}) {}
|
|
67
|
+
|
|
68
|
+
export class CreatePasskey extends S.TaggedClass<CreatePasskey>()(`${CLIENT_ACTION}/create-passkey`, {
|
|
69
|
+
input: S.Void,
|
|
70
|
+
output: S.Void,
|
|
71
|
+
}) {}
|
|
72
|
+
|
|
73
|
+
export class RedeemPasskey extends S.TaggedClass<RedeemPasskey>()(`${CLIENT_ACTION}/redeem-passkey`, {
|
|
74
|
+
input: S.Void,
|
|
75
|
+
output: S.Void,
|
|
76
|
+
}) {}
|
|
67
77
|
}
|
|
68
78
|
|
|
69
79
|
export type ClientPluginOptions = ClientOptions & {
|