@dxos/react-client 0.7.5-labs.e27f9b9 → 0.7.5-labs.f400bbc
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/{chunk-LVTCEDI2.mjs → chunk-72QD3PXL.mjs} +3 -3
- package/dist/lib/browser/{chunk-LVTCEDI2.mjs.map → chunk-72QD3PXL.mjs.map} +2 -2
- package/dist/lib/browser/devtools/index.mjs +1 -1
- package/dist/lib/browser/echo/index.mjs +44 -9
- package/dist/lib/browser/echo/index.mjs.map +4 -4
- package/dist/lib/browser/halo/index.mjs +1 -1
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/mesh/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-Y2HFUT7P.cjs → chunk-5RUIFUEC.cjs} +5 -5
- package/dist/lib/node/{chunk-Y2HFUT7P.cjs.map → chunk-5RUIFUEC.cjs.map} +2 -2
- package/dist/lib/node/devtools/index.cjs +2 -2
- package/dist/lib/node/echo/index.cjs +47 -13
- package/dist/lib/node/echo/index.cjs.map +4 -4
- package/dist/lib/node/halo/index.cjs +6 -6
- package/dist/lib/node/index.cjs +12 -12
- package/dist/lib/node/mesh/index.cjs +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +4 -4
- package/dist/lib/node-esm/{chunk-MXY3GJGN.mjs → chunk-NBTZZNQ5.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-MXY3GJGN.mjs.map → chunk-NBTZZNQ5.mjs.map} +2 -2
- package/dist/lib/node-esm/devtools/index.mjs +1 -1
- package/dist/lib/node-esm/echo/index.mjs +44 -9
- package/dist/lib/node-esm/echo/index.mjs.map +4 -4
- package/dist/lib/node-esm/halo/index.mjs +1 -1
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/mesh/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/types/src/client/AgentHostingProvider.d.ts +1 -1
- package/dist/types/src/client/AgentHostingProvider.d.ts.map +1 -1
- package/dist/types/src/client/useClient.d.ts +1 -1
- package/dist/types/src/client/useClient.d.ts.map +1 -1
- package/dist/types/src/client/useConfig.d.ts +1 -1
- package/dist/types/src/client/useConfig.d.ts.map +1 -1
- package/dist/types/src/echo/index.d.ts +1 -0
- package/dist/types/src/echo/index.d.ts.map +1 -1
- package/dist/types/src/echo/useQuery.d.ts +1 -1
- package/dist/types/src/echo/useQuery.d.ts.map +1 -1
- package/dist/types/src/echo/useSchema.d.ts +7 -0
- package/dist/types/src/echo/useSchema.d.ts.map +1 -0
- package/dist/types/src/halo/Passkey.stories.d.ts +2 -3
- package/dist/types/src/halo/Passkey.stories.d.ts.map +1 -1
- package/dist/types/src/playwright/{playwright.config.d.ts → playwright.config.d.cts} +1 -1
- package/dist/types/src/playwright/playwright.config.d.cts.map +1 -0
- package/dist/types/src/testing/ClientRepeater.d.ts +2 -2
- package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
- package/dist/types/src/testing/ClientRepeater.stories.d.ts +3 -4
- package/dist/types/src/testing/ClientRepeater.stories.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +2 -3
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.stories.d.ts +3 -4
- package/dist/types/src/testing/withClientProvider.stories.d.ts.map +1 -1
- package/package.json +24 -23
- package/project.json +1 -0
- package/src/client/ClientProvider.tsx +2 -2
- package/src/echo/index.ts +1 -0
- package/src/echo/useQuery.ts +8 -7
- package/src/echo/useSchema.ts +39 -0
- package/src/halo/Passkey.stories.tsx +58 -30
- package/tsconfig.json +1 -7
- package/dist/types/src/playwright/playwright.config.d.ts.map +0 -1
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
- /package/src/playwright/{playwright.config.ts → playwright.config.cts} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useMemo, useSyncExternalStore } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Space } from '@dxos/client/echo';
|
|
8
|
+
import { type EchoSchema } from '@dxos/echo-schema';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Subscribe to and retrieve schema changes from a space's schema registry.
|
|
12
|
+
*/
|
|
13
|
+
export const useSchema = (space: Space | undefined, typename: string | undefined): EchoSchema | undefined => {
|
|
14
|
+
const { subscribe, getSchema } = useMemo(() => {
|
|
15
|
+
if (!typename || !space) {
|
|
16
|
+
return {
|
|
17
|
+
subscribe: () => () => {},
|
|
18
|
+
getSchema: () => undefined,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const query = space.db.schemaRegistry.query({ typename });
|
|
23
|
+
const initialResult = query.runSync()[0];
|
|
24
|
+
let currentSchema = initialResult;
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
subscribe: (onStoreChange: () => void) => {
|
|
28
|
+
const unsubscribe = query.subscribe(() => {
|
|
29
|
+
currentSchema = query.results[0];
|
|
30
|
+
onStoreChange();
|
|
31
|
+
});
|
|
32
|
+
return unsubscribe;
|
|
33
|
+
},
|
|
34
|
+
getSchema: () => currentSchema,
|
|
35
|
+
};
|
|
36
|
+
}, [typename, space]);
|
|
37
|
+
|
|
38
|
+
return useSyncExternalStore(subscribe, getSchema);
|
|
39
|
+
};
|
|
@@ -8,6 +8,7 @@ import React, { useCallback } from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { Config, PublicKey } from '@dxos/client';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
|
+
import { log } from '@dxos/log';
|
|
11
12
|
import { Button } from '@dxos/react-ui';
|
|
12
13
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
13
14
|
import { withTheme } from '@dxos/storybook-utils';
|
|
@@ -24,54 +25,80 @@ const Test = () => {
|
|
|
24
25
|
const identity = useIdentity();
|
|
25
26
|
const credentials = useCredentials();
|
|
26
27
|
|
|
27
|
-
const handleCreateIdentity = useCallback(() =>
|
|
28
|
+
const handleCreateIdentity = useCallback(async () => {
|
|
29
|
+
await client.halo.createIdentity();
|
|
30
|
+
invariant(client.services.services.EdgeAgentService, 'Missing EdgeAgentService');
|
|
31
|
+
await client.services.services.EdgeAgentService.createAgent(null as any, { timeout: 10_000 });
|
|
32
|
+
}, [client]);
|
|
33
|
+
|
|
28
34
|
// TODO(wittjosiah): Consider factoring out passkey creation to the halo api.
|
|
29
35
|
const handleCreatePassKey = useCallback(async () => {
|
|
30
36
|
invariant(identity, 'Identity not available');
|
|
31
37
|
const challenge = getNewChallenge();
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const lookupKey = PublicKey.random();
|
|
39
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions
|
|
40
|
+
const credential = await navigator.credentials
|
|
41
|
+
.create({
|
|
42
|
+
publicKey: {
|
|
43
|
+
challenge: new TextEncoder().encode(challenge),
|
|
44
|
+
rp: { id: location.hostname, name: 'Test' },
|
|
45
|
+
user: {
|
|
46
|
+
id: lookupKey.asUint8Array(),
|
|
47
|
+
name: identity.did,
|
|
48
|
+
displayName: identity.profile?.displayName ?? '',
|
|
49
|
+
},
|
|
50
|
+
pubKeyCredParams: [
|
|
51
|
+
{ type: 'public-key', alg: -8 }, // Ed25519 (not yet supported across all browsers)
|
|
52
|
+
{ type: 'public-key', alg: -7 }, // ES256
|
|
53
|
+
],
|
|
54
|
+
// https://web.dev/articles/webauthn-discoverable-credentials#resident-key
|
|
55
|
+
authenticatorSelection: {
|
|
56
|
+
residentKey: 'required',
|
|
57
|
+
requireResidentKey: true,
|
|
58
|
+
},
|
|
40
59
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{ type: 'public-key', alg: -7 }, // ES256
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
});
|
|
60
|
+
})
|
|
61
|
+
.catch(log.error);
|
|
47
62
|
|
|
48
63
|
invariant(credential, 'Credential not available');
|
|
49
64
|
const recoveryKey = PublicKey.from(new Uint8Array((credential as any).response.getPublicKey()));
|
|
50
|
-
const algorithm
|
|
65
|
+
const algorithm = (credential as any).response.getPublicKeyAlgorithm() === -7 ? 'ES256' : 'ED25519';
|
|
51
66
|
|
|
52
67
|
invariant(client.services.services.IdentityService, 'IdentityService not available');
|
|
53
68
|
// TODO(wittjosiah): This needs a proper api.
|
|
54
69
|
await client.services.services.IdentityService.createRecoveryCredential({
|
|
55
70
|
recoveryKey,
|
|
56
71
|
algorithm,
|
|
72
|
+
lookupKey,
|
|
57
73
|
});
|
|
58
74
|
}, [client, identity]);
|
|
59
75
|
|
|
60
76
|
const handleAuthenticate = useCallback(async () => {
|
|
61
|
-
|
|
62
|
-
const challenge =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
invariant(client.services.services.IdentityService, 'IdentityService not available');
|
|
78
|
+
const { deviceKey, controlFeedKey, challenge } =
|
|
79
|
+
await client.services.services.IdentityService.requestRecoveryChallenge();
|
|
80
|
+
const credential = await navigator.credentials
|
|
81
|
+
.get({
|
|
82
|
+
publicKey: {
|
|
83
|
+
challenge: Buffer.from(challenge, 'base64'),
|
|
84
|
+
rpId: location.hostname,
|
|
85
|
+
// NOTE: Don't prompt for password in storybook for test purposes.
|
|
86
|
+
// In practice, this should be set to 'required' for identity recovery.
|
|
87
|
+
userVerification: 'discouraged',
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
.catch(log.error);
|
|
91
|
+
const lookupKey = PublicKey.from(new Uint8Array((credential as any).response.userHandle));
|
|
92
|
+
await client.services.services.IdentityService.recoverIdentity({
|
|
93
|
+
external: {
|
|
94
|
+
lookupKey,
|
|
95
|
+
deviceKey,
|
|
96
|
+
controlFeedKey,
|
|
97
|
+
signature: Buffer.from((credential as any).response.signature),
|
|
98
|
+
clientDataJson: Buffer.from((credential as any).response.clientDataJSON),
|
|
99
|
+
authenticatorData: Buffer.from((credential as any).response.authenticatorData),
|
|
70
100
|
},
|
|
71
101
|
});
|
|
72
|
-
const did = new TextDecoder().decode((credential as any).response.userHandle);
|
|
73
|
-
console.log({ credential, did });
|
|
74
|
-
// TODO(wittjosiah): Send signature to edge for verification and admission.
|
|
75
102
|
}, []);
|
|
76
103
|
|
|
77
104
|
return (
|
|
@@ -113,9 +140,10 @@ const config = new Config({
|
|
|
113
140
|
},
|
|
114
141
|
services: {
|
|
115
142
|
edge: {
|
|
116
|
-
url: 'wss://edge.dxos.workers.dev/',
|
|
143
|
+
url: 'wss://edge-main.dxos.workers.dev/',
|
|
144
|
+
// url: 'ws://localhost:8787',
|
|
117
145
|
},
|
|
118
|
-
iceProviders: [{ urls: 'https://edge.dxos.workers.dev/ice' }],
|
|
146
|
+
iceProviders: [{ urls: 'https://edge-production.dxos.workers.dev/ice' }],
|
|
119
147
|
},
|
|
120
148
|
},
|
|
121
149
|
});
|
package/tsconfig.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"playwright.config.d.ts","sourceRoot":"","sources":["../../../../src/playwright/playwright.config.ts"],"names":[],"mappings":";AASA,wBAQG"}
|
|
File without changes
|
|
File without changes
|