@dxos/react-client 0.7.5-labs.e27f9b9 → 0.7.5-labs.f5080a1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Passkey.stories.d.ts","sourceRoot":"","sources":["../../../../src/halo/Passkey.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAsB,MAAM,OAAO,CAAC;;;;;
|
|
1
|
+
{"version":3,"file":"Passkey.stories.d.ts","sourceRoot":"","sources":["../../../../src/halo/Passkey.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAsB,MAAM,OAAO,CAAC;;;;;AAqH3C,wBAGE;AAsBF,eAAO,MAAM,OAAO;;CAEnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-client",
|
|
3
|
-
"version": "0.7.5-labs.
|
|
3
|
+
"version": "0.7.5-labs.f5080a1",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -77,40 +77,40 @@
|
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"react-error-boundary": "^4.0.13",
|
|
80
|
-
"@dxos/async": "0.7.5-labs.
|
|
81
|
-
"@dxos/client": "0.7.5-labs.
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/
|
|
85
|
-
"@dxos/echo-
|
|
86
|
-
"@dxos/echo-
|
|
87
|
-
"@dxos/
|
|
88
|
-
"@dxos/
|
|
89
|
-
"@dxos/
|
|
90
|
-
"@dxos/
|
|
91
|
-
"@dxos/react-hooks": "0.7.5-labs.
|
|
92
|
-
"@dxos/util": "0.7.5-labs.
|
|
80
|
+
"@dxos/async": "0.7.5-labs.f5080a1",
|
|
81
|
+
"@dxos/client": "0.7.5-labs.f5080a1",
|
|
82
|
+
"@dxos/codec-protobuf": "0.7.5-labs.f5080a1",
|
|
83
|
+
"@dxos/config": "0.7.5-labs.f5080a1",
|
|
84
|
+
"@dxos/debug": "0.7.5-labs.f5080a1",
|
|
85
|
+
"@dxos/echo-schema": "0.7.5-labs.f5080a1",
|
|
86
|
+
"@dxos/echo-signals": "0.7.5-labs.f5080a1",
|
|
87
|
+
"@dxos/invariant": "0.7.5-labs.f5080a1",
|
|
88
|
+
"@dxos/log": "0.7.5-labs.f5080a1",
|
|
89
|
+
"@dxos/protocols": "0.7.5-labs.f5080a1",
|
|
90
|
+
"@dxos/node-std": "0.7.5-labs.f5080a1",
|
|
91
|
+
"@dxos/react-hooks": "0.7.5-labs.f5080a1",
|
|
92
|
+
"@dxos/util": "0.7.5-labs.f5080a1"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@types/react": "~18.2.0",
|
|
96
96
|
"@types/react-dom": "~18.2.0",
|
|
97
97
|
"react": "~18.2.0",
|
|
98
98
|
"react-dom": "~18.2.0",
|
|
99
|
-
"@dxos/random": "0.7.5-labs.
|
|
100
|
-
"@dxos/react-ui": "0.7.5-labs.
|
|
101
|
-
"@dxos/react-ui-syntax-highlighter": "0.7.5-labs.
|
|
102
|
-
"@dxos/
|
|
103
|
-
"@dxos/
|
|
104
|
-
"@dxos/
|
|
99
|
+
"@dxos/random": "0.7.5-labs.f5080a1",
|
|
100
|
+
"@dxos/react-ui": "0.7.5-labs.f5080a1",
|
|
101
|
+
"@dxos/react-ui-syntax-highlighter": "0.7.5-labs.f5080a1",
|
|
102
|
+
"@dxos/react-ui-theme": "0.7.5-labs.f5080a1",
|
|
103
|
+
"@dxos/storybook-utils": "0.7.5-labs.f5080a1",
|
|
104
|
+
"@dxos/test-utils": "0.7.5-labs.f5080a1"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
107
|
"react": "~18.2.0",
|
|
108
108
|
"react-dom": "~18.2.0"
|
|
109
109
|
},
|
|
110
110
|
"optionalDependencies": {
|
|
111
|
-
"@dxos/random": "0.7.5-labs.
|
|
112
|
-
"@dxos/react-ui": "0.7.5-labs.
|
|
113
|
-
"@dxos/react-ui-theme": "0.7.5-labs.
|
|
111
|
+
"@dxos/random": "0.7.5-labs.f5080a1",
|
|
112
|
+
"@dxos/react-ui": "0.7.5-labs.f5080a1",
|
|
113
|
+
"@dxos/react-ui-theme": "0.7.5-labs.f5080a1"
|
|
114
114
|
},
|
|
115
115
|
"publishConfig": {
|
|
116
116
|
"access": "public"
|
|
@@ -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,30 +25,43 @@ 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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
id:
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions
|
|
39
|
+
const credential = await navigator.credentials
|
|
40
|
+
.create({
|
|
41
|
+
publicKey: {
|
|
42
|
+
challenge: new TextEncoder().encode(challenge),
|
|
43
|
+
rp: { id: location.hostname, name: 'Test' },
|
|
44
|
+
user: {
|
|
45
|
+
id: new TextEncoder().encode(identity.did),
|
|
46
|
+
name: identity.did,
|
|
47
|
+
displayName: identity.profile?.displayName ?? '',
|
|
48
|
+
},
|
|
49
|
+
pubKeyCredParams: [
|
|
50
|
+
{ type: 'public-key', alg: -8 }, // Ed25519 (not yet supported across all browsers)
|
|
51
|
+
{ type: 'public-key', alg: -7 }, // ES256
|
|
52
|
+
],
|
|
53
|
+
// https://web.dev/articles/webauthn-discoverable-credentials#resident-key
|
|
54
|
+
authenticatorSelection: {
|
|
55
|
+
residentKey: 'required',
|
|
56
|
+
requireResidentKey: true,
|
|
57
|
+
},
|
|
40
58
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{ type: 'public-key', alg: -7 }, // ES256
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
});
|
|
59
|
+
})
|
|
60
|
+
.catch(log.error);
|
|
47
61
|
|
|
48
62
|
invariant(credential, 'Credential not available');
|
|
49
63
|
const recoveryKey = PublicKey.from(new Uint8Array((credential as any).response.getPublicKey()));
|
|
50
|
-
const algorithm
|
|
64
|
+
const algorithm = (credential as any).response.getPublicKeyAlgorithm() === -7 ? 'ES256' : 'ED25519';
|
|
51
65
|
|
|
52
66
|
invariant(client.services.services.IdentityService, 'IdentityService not available');
|
|
53
67
|
// TODO(wittjosiah): This needs a proper api.
|
|
@@ -58,20 +72,31 @@ const Test = () => {
|
|
|
58
72
|
}, [client, identity]);
|
|
59
73
|
|
|
60
74
|
const handleAuthenticate = useCallback(async () => {
|
|
61
|
-
|
|
62
|
-
const challenge =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
invariant(client.services.services.IdentityService, 'IdentityService not available');
|
|
76
|
+
const { deviceKey, controlFeedKey, challenge } =
|
|
77
|
+
await client.services.services.IdentityService.requestRecoveryChallenge();
|
|
78
|
+
const credential = await navigator.credentials
|
|
79
|
+
.get({
|
|
80
|
+
publicKey: {
|
|
81
|
+
challenge: Buffer.from(challenge, 'base64'),
|
|
82
|
+
rpId: location.hostname,
|
|
83
|
+
// NOTE: Don't prompt for password in storybook for test purposes.
|
|
84
|
+
// In practice, this should be set to 'required' for identity recovery.
|
|
85
|
+
userVerification: 'discouraged',
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
.catch(log.error);
|
|
89
|
+
const identityDid = new TextDecoder().decode((credential as any).response.userHandle);
|
|
90
|
+
await client.services.services.IdentityService.recoverIdentity({
|
|
91
|
+
external: {
|
|
92
|
+
identityDid,
|
|
93
|
+
deviceKey,
|
|
94
|
+
controlFeedKey,
|
|
95
|
+
signature: Buffer.from((credential as any).response.signature),
|
|
96
|
+
clientDataJson: Buffer.from((credential as any).response.clientDataJSON),
|
|
97
|
+
authenticatorData: Buffer.from((credential as any).response.authenticatorData),
|
|
70
98
|
},
|
|
71
99
|
});
|
|
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
100
|
}, []);
|
|
76
101
|
|
|
77
102
|
return (
|
|
@@ -113,9 +138,10 @@ const config = new Config({
|
|
|
113
138
|
},
|
|
114
139
|
services: {
|
|
115
140
|
edge: {
|
|
116
|
-
url: 'wss://edge.dxos.workers.dev/',
|
|
141
|
+
// url: 'wss://edge.dxos.workers.dev/',
|
|
142
|
+
url: 'ws://localhost:8787',
|
|
117
143
|
},
|
|
118
|
-
iceProviders: [{ urls: 'https://edge.dxos.workers.dev/ice' }],
|
|
144
|
+
iceProviders: [{ urls: 'https://edge-production.dxos.workers.dev/ice' }],
|
|
119
145
|
},
|
|
120
146
|
},
|
|
121
147
|
});
|