@dxos/client-protocol 0.4.10-next.71cec10 → 0.5.1-next.2ad6c47

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/client-protocol",
3
- "version": "0.4.10-next.71cec10",
3
+ "version": "0.5.1-next.2ad6c47",
4
4
  "description": "Core DXOS Client API.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -18,19 +18,19 @@
18
18
  ],
19
19
  "dependencies": {
20
20
  "base-x": "~3.0.9",
21
- "@dxos/config": "0.4.10-next.71cec10",
22
- "@dxos/async": "0.4.10-next.71cec10",
23
- "@dxos/context": "0.4.10-next.71cec10",
24
- "@dxos/echo-db": "0.4.10-next.71cec10",
25
- "@dxos/echo-schema": "0.4.10-next.71cec10",
26
- "@dxos/invariant": "0.4.10-next.71cec10",
27
- "@dxos/node-std": "0.4.10-next.71cec10",
28
- "@dxos/keys": "0.4.10-next.71cec10",
29
- "@dxos/rpc": "0.4.10-next.71cec10",
30
- "@dxos/protocols": "0.4.10-next.71cec10"
21
+ "@dxos/async": "0.5.1-next.2ad6c47",
22
+ "@dxos/context": "0.5.1-next.2ad6c47",
23
+ "@dxos/echo-schema": "0.5.1-next.2ad6c47",
24
+ "@dxos/invariant": "0.5.1-next.2ad6c47",
25
+ "@dxos/echo-db": "0.5.1-next.2ad6c47",
26
+ "@dxos/config": "0.5.1-next.2ad6c47",
27
+ "@dxos/keys": "0.5.1-next.2ad6c47",
28
+ "@dxos/node-std": "0.5.1-next.2ad6c47",
29
+ "@dxos/protocols": "0.5.1-next.2ad6c47",
30
+ "@dxos/rpc": "0.5.1-next.2ad6c47"
31
31
  },
32
32
  "devDependencies": {
33
- "@dxos/echo-typegen": "0.4.10-next.71cec10"
33
+ "@dxos/echo-typegen": "0.5.1-next.2ad6c47"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
@@ -10,42 +10,48 @@ import { describe, test } from '@dxos/test';
10
10
 
11
11
  import { InvitationEncoder } from './encoder';
12
12
 
13
+ const baseInvitation: Invitation = {
14
+ invitationId: PublicKey.random().toHex(),
15
+ type: Invitation.Type.INTERACTIVE,
16
+ kind: Invitation.Kind.SPACE,
17
+ authMethod: Invitation.AuthMethod.NONE,
18
+ state: Invitation.State.INIT,
19
+ swarmKey: PublicKey.random(),
20
+ spaceKey: PublicKey.random(),
21
+ };
22
+
13
23
  describe('Invitation utils', () => {
14
24
  test('encodes and decodes an invitation', () => {
15
- const invitation: Invitation = {
16
- invitationId: PublicKey.random().toHex(),
17
- type: Invitation.Type.INTERACTIVE,
18
- kind: Invitation.Kind.SPACE,
19
- authMethod: Invitation.AuthMethod.NONE,
20
- state: Invitation.State.INIT,
21
- swarmKey: PublicKey.random(),
22
- spaceKey: PublicKey.random(),
23
- };
24
-
25
- const encoded = InvitationEncoder.encode(invitation);
25
+ const encoded = InvitationEncoder.encode(baseInvitation);
26
26
  const decoded = InvitationEncoder.decode(encoded);
27
- expect(decoded).to.deep.eq(invitation);
27
+ expect(decoded).to.deep.eq(baseInvitation);
28
28
  });
29
29
 
30
30
  test('secrets are never encoded into invitation code', () => {
31
- const invitation: Invitation = {
32
- invitationId: PublicKey.random().toHex(),
33
- type: Invitation.Type.INTERACTIVE,
34
- kind: Invitation.Kind.SPACE,
35
- authMethod: Invitation.AuthMethod.NONE,
36
- state: Invitation.State.INIT,
37
- swarmKey: PublicKey.random(),
38
- spaceKey: PublicKey.random(),
39
- };
40
-
41
31
  const encoded = InvitationEncoder.encode({
42
- ...invitation,
32
+ ...baseInvitation,
43
33
  authCode: 'example',
44
34
  identityKey: PublicKey.random(),
45
35
  });
46
36
  const decoded = InvitationEncoder.decode(encoded);
47
37
  expect(decoded.authCode).to.not.exist;
48
38
  expect(decoded.identityKey).to.not.exist;
39
+ expect(decoded).to.deep.eq(baseInvitation);
40
+ });
41
+
42
+ test('guestKeypair for known public key auth method is encoded', () => {
43
+ const invitation: Invitation = {
44
+ ...baseInvitation,
45
+ guestKeypair: {
46
+ publicKey: PublicKey.random(),
47
+ privateKey: PublicKey.random().asBuffer(),
48
+ },
49
+ };
50
+
51
+ const encoded = InvitationEncoder.encode(invitation);
52
+ const decoded = InvitationEncoder.decode(encoded);
53
+ expect(decoded.authCode).to.not.exist;
54
+ expect(decoded.identityKey).to.not.exist;
49
55
  expect(decoded).to.deep.eq(invitation);
50
56
  });
51
57
  });