@dxos/react-client 2.17.1 → 2.18.0
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/.rush/temp/package-deps_build:test.json +11 -10
- package/.rush/temp/shrinkwrap-deps.json +3 -3
- package/dist/src/components/ErrorBoundary.js +1 -1
- package/dist/src/components/ErrorBoundary.js.map +1 -1
- package/dist/src/containers/ClientInitializer.js +4 -4
- package/dist/src/containers/ClientInitializer.js.map +1 -1
- package/dist/src/containers/ClientProvider.js +1 -1
- package/dist/src/containers/ClientProvider.js.map +1 -1
- package/dist/src/containers/ClientProvider.test.js +6 -6
- package/dist/src/containers/ClientProvider.test.js.map +1 -1
- package/dist/src/containers/ProfileInitializer.js +3 -3
- package/dist/src/containers/ProfileInitializer.js.map +1 -1
- package/dist/src/hooks/client/client.test.js +6 -6
- package/dist/src/hooks/client/client.test.js.map +1 -1
- package/dist/src/hooks/client/config.test.js +9 -9
- package/dist/src/hooks/client/config.test.js.map +1 -1
- package/dist/src/hooks/client/context.js +1 -1
- package/dist/src/hooks/client/context.js.map +1 -1
- package/dist/src/hooks/client/useClient.js +1 -1
- package/dist/src/hooks/client/useClient.js.map +1 -1
- package/dist/src/hooks/client/useConfig.js +1 -1
- package/dist/src/hooks/client/useConfig.js.map +1 -1
- package/dist/src/hooks/client/useProfile.js +3 -3
- package/dist/src/hooks/client/useProfile.js.map +1 -1
- package/dist/src/hooks/echo-queries/index.d.ts +1 -0
- package/dist/src/hooks/echo-queries/index.d.ts.map +1 -1
- package/dist/src/hooks/echo-queries/index.js +1 -0
- package/dist/src/hooks/echo-queries/index.js.map +1 -1
- package/dist/src/hooks/echo-queries/useContacts.js +3 -3
- package/dist/src/hooks/echo-queries/useContacts.js.map +1 -1
- package/dist/src/hooks/echo-queries/useMembers.js +2 -2
- package/dist/src/hooks/echo-queries/useMembers.js.map +1 -1
- package/dist/src/hooks/echo-queries/useParties.js +5 -5
- package/dist/src/hooks/echo-queries/useParties.js.map +1 -1
- package/dist/src/hooks/echo-queries/useRemoteParties.d.ts +8 -0
- package/dist/src/hooks/echo-queries/useRemoteParties.d.ts.map +1 -0
- package/dist/src/hooks/echo-queries/useRemoteParties.js +24 -0
- package/dist/src/hooks/echo-queries/useRemoteParties.js.map +1 -0
- package/dist/src/hooks/echo-selections/useSelection.js +2 -2
- package/dist/src/hooks/echo-selections/useSelection.js.map +1 -1
- package/dist/src/hooks/invitations/useSecretGenerator.js +2 -2
- package/dist/src/hooks/invitations/useSecretGenerator.js.map +1 -1
- package/dist/src/hooks/invitations/useSecretProvider.js +1 -1
- package/dist/src/hooks/invitations/useSecretProvider.js.map +1 -1
- package/dist/src/hooks/util/useResultSet.js +1 -1
- package/dist/src/hooks/util/useResultSet.js.map +1 -1
- package/dist/src/hooks/wns/registryBotFactories.js +4 -4
- package/dist/src/hooks/wns/registryBotFactories.js.map +1 -1
- package/dist/src/hooks/wns/registryBots.js +4 -4
- package/dist/src/hooks/wns/registryBots.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/stories/client.stories.js +2 -2
- package/dist/stories/client.stories.js.map +1 -1
- package/dist/stories/halo-invitations.stories.d.ts.map +1 -1
- package/dist/stories/halo-invitations.stories.js +23 -22
- package/dist/stories/halo-invitations.stories.js.map +1 -1
- package/dist/stories/helpers/Container.js +1 -1
- package/dist/stories/helpers/Container.js.map +1 -1
- package/dist/stories/helpers/PartyJoinPanel.js +3 -3
- package/dist/stories/helpers/PartyJoinPanel.js.map +1 -1
- package/dist/stories/helpers/ThemeProvider.js +1 -1
- package/dist/stories/helpers/ThemeProvider.js.map +1 -1
- package/dist/stories/party-invitations.stories.js +14 -14
- package/dist/stories/party-invitations.stories.js.map +1 -1
- package/dist/tests/config.test.js +3 -3
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/react-client.build.log +5 -5
- package/src/hooks/client/useClient.ts +1 -1
- package/src/hooks/client/useConfig.ts +1 -1
- package/src/hooks/echo-queries/index.ts +1 -0
- package/src/hooks/echo-queries/useRemoteParties.ts +25 -0
- package/src/hooks/wns/registryBotFactories.ts +1 -1
- package/src/hooks/wns/registryBots.ts +1 -1
- package/src/index.ts +1 -0
- package/stories/halo-invitations.stories.tsx +27 -24
- package/stories/party-invitations.stories.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
"test": "toolchain test"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@dxos/async": "2.
|
|
18
|
-
"@dxos/client": "2.
|
|
19
|
-
"@dxos/config": "2.
|
|
20
|
-
"@dxos/credentials": "2.
|
|
21
|
-
"@dxos/crypto": "2.
|
|
22
|
-
"@dxos/debug": "2.
|
|
23
|
-
"@dxos/echo-db": "2.
|
|
24
|
-
"@dxos/util": "2.
|
|
17
|
+
"@dxos/async": "2.18.0",
|
|
18
|
+
"@dxos/client": "2.18.0",
|
|
19
|
+
"@dxos/config": "2.18.0",
|
|
20
|
+
"@dxos/credentials": "2.18.0",
|
|
21
|
+
"@dxos/crypto": "2.18.0",
|
|
22
|
+
"@dxos/debug": "2.18.0",
|
|
23
|
+
"@dxos/echo-db": "2.18.0",
|
|
24
|
+
"@dxos/util": "2.18.0",
|
|
25
25
|
"@types/debug": "^4.1.1",
|
|
26
26
|
"assert": "^2.0.0",
|
|
27
27
|
"debug": "^4.1.1",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"use-subscription": "^1.4.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@dxos/toolchain-node-library": "2.
|
|
32
|
+
"@dxos/toolchain-node-library": "2.18.0",
|
|
33
33
|
"@mui/material": "^5.0.1",
|
|
34
34
|
"@testing-library/react": "^11.0.4",
|
|
35
35
|
"@testing-library/react-hooks": "5.1.2",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react-docgen-typescript-loader": "^3.7.2",
|
|
47
47
|
"react-dom": "^17.0.2",
|
|
48
48
|
"react-test-renderer": "^17.0.2",
|
|
49
|
-
"typescript": "^4.
|
|
49
|
+
"typescript": "^4.5.2",
|
|
50
50
|
"webpack": "4.44.2"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
package/react-client.build.log
CHANGED
|
@@ -2,10 +2,10 @@ Invoking: toolchain build:test
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
typescript
|
|
5
|
-
OK in
|
|
5
|
+
OK in 6677 ms
|
|
6
6
|
|
|
7
7
|
eslint
|
|
8
|
-
OK in
|
|
8
|
+
OK in 6850 ms
|
|
9
9
|
|
|
10
10
|
mocha
|
|
11
11
|
This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills
|
|
@@ -26,8 +26,8 @@ This browser doesn't support cancelAnimationFrame. Make sure that you load a pol
|
|
|
26
26
|
✓ should return custom client config when used properly in a context
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
7 passing (
|
|
29
|
+
7 passing (491ms)
|
|
30
30
|
|
|
31
|
-
OK in
|
|
31
|
+
OK in 10195 ms
|
|
32
32
|
|
|
33
|
-
CHECK COMPLETE in
|
|
33
|
+
CHECK COMPLETE in 23729 ms
|
|
@@ -13,5 +13,5 @@ import { ClientContext } from './context';
|
|
|
13
13
|
* To be used with `ClientProvider` or `ClientInitializer` component wrapper.
|
|
14
14
|
*/
|
|
15
15
|
export const useClient = () => {
|
|
16
|
-
return useContext(ClientContext) ?? raise(new Error('
|
|
16
|
+
return useContext(ClientContext) ?? raise(new Error('ClientContext no set.'));
|
|
17
17
|
};
|
|
@@ -13,6 +13,6 @@ import { ClientContext } from './context';
|
|
|
13
13
|
* To be used with `ClientProvider` or `ClientInitializer` component wrapper.
|
|
14
14
|
*/
|
|
15
15
|
export const useConfig = () => {
|
|
16
|
-
const { config } = useContext(ClientContext) ?? raise(new Error('
|
|
16
|
+
const { config } = useContext(ClientContext) ?? raise(new Error('ClientContext no set.'));
|
|
17
17
|
return config;
|
|
18
18
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2020 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { useClient } from '../client';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get all Parties available to current user.
|
|
11
|
+
* To be used with `ClientProvider` or `ClientInitializer` component wrapper.
|
|
12
|
+
*/
|
|
13
|
+
export const useRemoteParties = () => {
|
|
14
|
+
const client = useClient();
|
|
15
|
+
const [parties, setParties] = useState<{key?: Uint8Array}[]>([]);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const stream = client.services.PartyService.SubscribeParties();
|
|
19
|
+
stream.subscribe(result => setParties(result.parties ?? []), console.error);
|
|
20
|
+
|
|
21
|
+
return () => stream.close();
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
return parties;
|
|
25
|
+
};
|
|
@@ -34,7 +34,7 @@ export const useRegistryBotFactories = () => {
|
|
|
34
34
|
let factoriesResult: QueryRecord[];
|
|
35
35
|
try {
|
|
36
36
|
factoriesResult = await registry.queryRecords({ type: WRN_TYPE_BOT_FACTORY });
|
|
37
|
-
} catch (e) {
|
|
37
|
+
} catch (e: any) {
|
|
38
38
|
log('Querying bot factories unsuccessful.');
|
|
39
39
|
log(e);
|
|
40
40
|
return;
|
|
@@ -42,7 +42,7 @@ export const useRegistryBots = (props: UseRegistryBotsProps = {}) => {
|
|
|
42
42
|
let botsResult: QueryRecord[];
|
|
43
43
|
try {
|
|
44
44
|
botsResult = await registry.queryRecords({ type: WRN_TYPE_BOT });
|
|
45
|
-
} catch (e) {
|
|
45
|
+
} catch (e: any) {
|
|
46
46
|
log('Querying bots unsuccessful.');
|
|
47
47
|
log(e);
|
|
48
48
|
return;
|
package/src/index.ts
CHANGED
|
@@ -8,21 +8,18 @@ import {
|
|
|
8
8
|
Box, Button, Divider, Paper, TextField, Toolbar
|
|
9
9
|
} from '@mui/material';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { Awaited } from '@dxos/async';
|
|
12
|
+
import { Client, decodeInvitation, PendingInvitation } from '@dxos/client';
|
|
12
13
|
|
|
13
14
|
import {
|
|
14
15
|
ClientInitializer,
|
|
15
16
|
ProfileInitializer,
|
|
16
17
|
useClient,
|
|
17
18
|
useParties,
|
|
18
|
-
useProfile
|
|
19
|
-
useSecretGenerator,
|
|
20
|
-
useSecretProvider
|
|
19
|
+
useProfile
|
|
21
20
|
} from '../src';
|
|
22
21
|
import {
|
|
23
|
-
ClientPanel,
|
|
24
|
-
PartyJoinPanel,
|
|
25
|
-
Container
|
|
22
|
+
ClientPanel, Container, PartyJoinPanel
|
|
26
23
|
} from './helpers';
|
|
27
24
|
|
|
28
25
|
export default {
|
|
@@ -36,18 +33,19 @@ export default {
|
|
|
36
33
|
*/
|
|
37
34
|
const HaloInvitationContainer = () => {
|
|
38
35
|
const client = useClient();
|
|
39
|
-
const [
|
|
40
|
-
const [
|
|
36
|
+
const [invitation, setInvitation] = useState<PendingInvitation | undefined>();
|
|
37
|
+
const [pin, setPin] = useState('');
|
|
41
38
|
|
|
42
39
|
const handleCreateInvitation = async () => {
|
|
43
|
-
const invitation = await client.createHaloInvitation(
|
|
40
|
+
const invitation = await client.createHaloInvitation({
|
|
44
41
|
onFinish: () => { // TODO(burdon): Normalize callbacks (error, etc.)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
42
|
+
setInvitation(undefined);
|
|
43
|
+
setPin('');
|
|
44
|
+
},
|
|
45
|
+
onPinGenerated: setPin
|
|
48
46
|
});
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
setInvitation(invitation);
|
|
51
49
|
};
|
|
52
50
|
|
|
53
51
|
if (!client.halo.hasProfile()) {
|
|
@@ -64,13 +62,13 @@ const HaloInvitationContainer = () => {
|
|
|
64
62
|
</Button>
|
|
65
63
|
</Toolbar>
|
|
66
64
|
|
|
67
|
-
{
|
|
65
|
+
{invitation && (
|
|
68
66
|
<Box sx={{ marginTop: 1 }}>
|
|
69
67
|
<TextField
|
|
70
68
|
disabled
|
|
71
69
|
multiline
|
|
72
70
|
fullWidth
|
|
73
|
-
value={invitationCode}
|
|
71
|
+
value={invitation.invitationCode}
|
|
74
72
|
maxRows={3}
|
|
75
73
|
/>
|
|
76
74
|
</Box>
|
|
@@ -89,31 +87,36 @@ const HaloInvitationContainer = () => {
|
|
|
89
87
|
);
|
|
90
88
|
};
|
|
91
89
|
|
|
90
|
+
interface Status {
|
|
91
|
+
error?: any,
|
|
92
|
+
identity?: string,
|
|
93
|
+
finishAuthentication?: Awaited<ReturnType<Client['joinHaloInvitation']>>
|
|
94
|
+
}
|
|
95
|
+
|
|
92
96
|
/**
|
|
93
97
|
* Processes device invitations/authentication.
|
|
94
98
|
*/
|
|
95
99
|
const HaloAuthenticationContainer = () => {
|
|
96
100
|
const client = useClient();
|
|
97
|
-
const [status, setStatus] = useState<
|
|
98
|
-
const [secretProvider, secretResolver] = useSecretProvider<Buffer>();
|
|
101
|
+
const [status, setStatus] = useState<Status>({});
|
|
99
102
|
|
|
100
103
|
const handleSubmit = async (invitationCode: string) => {
|
|
101
104
|
try {
|
|
102
105
|
const invitation = decodeInvitation(invitationCode);
|
|
103
106
|
|
|
104
|
-
//
|
|
107
|
+
// Claim an invitation for this device to join an existing Halo.
|
|
105
108
|
if (invitation.identityKey) {
|
|
106
|
-
await client.
|
|
107
|
-
setStatus({ identity: invitation.identityKey.toString() });
|
|
109
|
+
const finishAuthentication = await client.joinHaloInvitation(invitation);
|
|
110
|
+
setStatus({ identity: invitation.identityKey.toString(), finishAuthentication });
|
|
108
111
|
}
|
|
109
|
-
} catch (err) {
|
|
112
|
+
} catch (err: any) {
|
|
110
113
|
// TODO(burdon): Doesn't support retry. Provide hint (eg, should retry/cancel).
|
|
111
114
|
setStatus({ error: err });
|
|
112
115
|
}
|
|
113
116
|
};
|
|
114
117
|
|
|
115
|
-
const handleAuthenticate = (pin: string) => {
|
|
116
|
-
|
|
118
|
+
const handleAuthenticate = async (pin: string) => {
|
|
119
|
+
await status.finishAuthentication?.(pin);
|
|
117
120
|
};
|
|
118
121
|
|
|
119
122
|
return (
|