tachyon-protocol 0.2.0 → 0.3.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/README.md CHANGED
@@ -4,12 +4,14 @@ Tachyon is the name of the protocol designed to replace the old [Spring Lobby Pr
4
4
 
5
5
  [Schema Reference](docs/README.md)
6
6
 
7
+ ## Authorization
8
+
9
+ See [dedicated authorization documentation page](docs/authorization.md).
10
+
7
11
  ## Connecting
8
12
 
9
13
  To connect to a Tachyon WebSocket server, the client should add a `tachyonVersion` query parameter which specifies which version of Tachyon they're using, e.g. `wss://tachyon-server.com?tachyonVersion=1.2.3`. The server should send a [`system/version/response`](docs/system.md/#version) command containing the version of the Tachyon protocol that is being served and `versionParity` field stating how it differs to the client's version. Ideally, clients should ensure their implementation is using the same version of the protocol, which can be found in this repo's [`package.json`](package.json). However, it is up to the client to decide how to handle version mismatches, and the server should not terminate clients because of a version disparity.
10
14
 
11
- TODO: document auth
12
-
13
15
  ## Terminology
14
16
 
15
17
  | Term | Meaning |
package/dist/index.d.ts CHANGED
@@ -719,55 +719,33 @@ export type MatchmakingReadyUpdateResponse =
719
719
  status: "failed";
720
720
  reason: "invalid_command";
721
721
  };
722
- export type SystemDisconnectedResponse =
722
+ export type SystemConnectedResponse =
723
723
  | {
724
724
  messageId: string;
725
- commandId: "system/disconnected/response";
726
- status: "success";
727
- }
728
- | {
729
- messageId: string;
730
- commandId: "system/disconnected/response";
731
- status: "failed";
732
- reason: "internal_error";
733
- }
734
- | {
735
- messageId: string;
736
- commandId: "system/disconnected/response";
737
- status: "failed";
738
- reason: "unauthorized";
739
- }
740
- | {
741
- messageId: string;
742
- commandId: "system/disconnected/response";
743
- status: "failed";
744
- reason: "invalid_command";
745
- };
746
- export type SystemVersionResponse =
747
- | {
748
- messageId: string;
749
- commandId: "system/version/response";
725
+ commandId: "system/connected/response";
750
726
  status: "success";
751
727
  data: {
752
- tachyonVersion: "0.2.0";
753
- versionParity: "major_mismatch" | "minor_mismatch" | "patch_mismatch" | "match" | "unknown";
728
+ accountId: number;
729
+ displayName: string;
730
+ avatarUrl: string;
731
+ countryCode?: string;
754
732
  };
755
733
  }
756
734
  | {
757
735
  messageId: string;
758
- commandId: "system/version/response";
736
+ commandId: "system/connected/response";
759
737
  status: "failed";
760
738
  reason: "internal_error";
761
739
  }
762
740
  | {
763
741
  messageId: string;
764
- commandId: "system/version/response";
742
+ commandId: "system/connected/response";
765
743
  status: "failed";
766
744
  reason: "unauthorized";
767
745
  }
768
746
  | {
769
747
  messageId: string;
770
- commandId: "system/version/response";
748
+ commandId: "system/connected/response";
771
749
  status: "failed";
772
750
  reason: "invalid_command";
773
751
  };
@@ -921,24 +899,16 @@ export interface Tachyon {
921
899
  };
922
900
  system: {
923
901
  /**
924
- * Ask the server to terminate the connection. The server will send a [disconnected](#disconnected) response.
902
+ * Sent immediately by the server on connection.
925
903
  */
926
- disconnect: {
927
- request: SystemDisconnectRequest;
904
+ connected: {
905
+ response: SystemConnectedResponse;
928
906
  };
929
907
  /**
930
- * Sent when the server terminates the WebSocket connection with the client.
908
+ * Ask the server to terminate the connection.
931
909
  */
932
- disconnected: {
933
- response: SystemDisconnectedResponse;
934
- };
935
- /**
936
- * Sends the current version of the protocol to new Websocket clients as soon as they connect.
937
- *
938
- * Clients should send the version they're using in the WS connection URL, e.g. ?tachyonVersion=1.1.2.
939
- */
940
- version: {
941
- response: SystemVersionResponse;
910
+ disconnect: {
911
+ request: SystemDisconnectRequest;
942
912
  };
943
913
  };
944
914
  }
@@ -1016,8 +986,6 @@ export interface SystemDisconnectRequest {
1016
986
  messageId: string;
1017
987
  commandId: "system/disconnect/request";
1018
988
  }
1019
- export type Email = string;
1020
-
1021
989
  export interface BattleStatus {
1022
990
  lobbyId: number | null;
1023
991
  inGame: boolean;
@@ -1096,7 +1064,6 @@ export interface PrivateUserClient {
1096
1064
  partyId: number | null;
1097
1065
  muted: boolean;
1098
1066
  } | null;
1099
- email: string;
1100
1067
  friends: number[];
1101
1068
  friendRequests: number[];
1102
1069
  ignores: number[];
package/dist/meta.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.0",
2
+ "version": "0.3.0",
3
3
  "ids": {
4
4
  "bot": {
5
5
  "slave": [
@@ -85,14 +85,11 @@
85
85
  ]
86
86
  },
87
87
  "system": {
88
- "disconnect": [
89
- "request"
90
- ],
91
- "disconnected": [
88
+ "connected": [
92
89
  "response"
93
90
  ],
94
- "version": [
95
- "response"
91
+ "disconnect": [
92
+ "request"
96
93
  ]
97
94
  }
98
95
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "system/disconnected/response",
2
+ "$id": "system/connected/response",
3
3
  "requiresLogin": false,
4
4
  "anyOf": [
5
5
  {
@@ -9,18 +9,41 @@
9
9
  "type": "string"
10
10
  },
11
11
  "commandId": {
12
- "const": "system/disconnected/response",
12
+ "const": "system/connected/response",
13
13
  "type": "string"
14
14
  },
15
15
  "status": {
16
16
  "const": "success",
17
17
  "type": "string"
18
+ },
19
+ "data": {
20
+ "type": "object",
21
+ "properties": {
22
+ "accountId": {
23
+ "type": "integer"
24
+ },
25
+ "displayName": {
26
+ "type": "string"
27
+ },
28
+ "avatarUrl": {
29
+ "type": "string"
30
+ },
31
+ "countryCode": {
32
+ "type": "string"
33
+ }
34
+ },
35
+ "required": [
36
+ "accountId",
37
+ "displayName",
38
+ "avatarUrl"
39
+ ]
18
40
  }
19
41
  },
20
42
  "required": [
21
43
  "messageId",
22
44
  "commandId",
23
- "status"
45
+ "status",
46
+ "data"
24
47
  ]
25
48
  },
26
49
  {
@@ -30,7 +53,7 @@
30
53
  "type": "string"
31
54
  },
32
55
  "commandId": {
33
- "const": "system/disconnected/response",
56
+ "const": "system/connected/response",
34
57
  "type": "string"
35
58
  },
36
59
  "status": {
@@ -56,7 +79,7 @@
56
79
  "type": "string"
57
80
  },
58
81
  "commandId": {
59
- "const": "system/disconnected/response",
82
+ "const": "system/connected/response",
60
83
  "type": "string"
61
84
  },
62
85
  "status": {
@@ -82,7 +105,7 @@
82
105
  "type": "string"
83
106
  },
84
107
  "commandId": {
85
- "const": "system/disconnected/response",
108
+ "const": "system/connected/response",
86
109
  "type": "string"
87
110
  },
88
111
  "status": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tachyon-protocol",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "nodemon --watch src/** --ext ts --exec npm run build",
@@ -1,143 +0,0 @@
1
- {
2
- "$id": "system/version/response",
3
- "requiresLogin": false,
4
- "anyOf": [
5
- {
6
- "type": "object",
7
- "properties": {
8
- "messageId": {
9
- "type": "string"
10
- },
11
- "commandId": {
12
- "const": "system/version/response",
13
- "type": "string"
14
- },
15
- "status": {
16
- "const": "success",
17
- "type": "string"
18
- },
19
- "data": {
20
- "type": "object",
21
- "properties": {
22
- "tachyonVersion": {
23
- "const": "0.2.0",
24
- "type": "string"
25
- },
26
- "versionParity": {
27
- "anyOf": [
28
- {
29
- "const": "major_mismatch",
30
- "type": "string"
31
- },
32
- {
33
- "const": "minor_mismatch",
34
- "type": "string"
35
- },
36
- {
37
- "const": "patch_mismatch",
38
- "type": "string"
39
- },
40
- {
41
- "const": "match",
42
- "type": "string"
43
- },
44
- {
45
- "const": "unknown",
46
- "type": "string"
47
- }
48
- ]
49
- }
50
- },
51
- "required": [
52
- "tachyonVersion",
53
- "versionParity"
54
- ]
55
- }
56
- },
57
- "required": [
58
- "messageId",
59
- "commandId",
60
- "status",
61
- "data"
62
- ]
63
- },
64
- {
65
- "type": "object",
66
- "properties": {
67
- "messageId": {
68
- "type": "string"
69
- },
70
- "commandId": {
71
- "const": "system/version/response",
72
- "type": "string"
73
- },
74
- "status": {
75
- "const": "failed",
76
- "type": "string"
77
- },
78
- "reason": {
79
- "const": "internal_error",
80
- "type": "string"
81
- }
82
- },
83
- "required": [
84
- "messageId",
85
- "commandId",
86
- "status",
87
- "reason"
88
- ]
89
- },
90
- {
91
- "type": "object",
92
- "properties": {
93
- "messageId": {
94
- "type": "string"
95
- },
96
- "commandId": {
97
- "const": "system/version/response",
98
- "type": "string"
99
- },
100
- "status": {
101
- "const": "failed",
102
- "type": "string"
103
- },
104
- "reason": {
105
- "const": "unauthorized",
106
- "type": "string"
107
- }
108
- },
109
- "required": [
110
- "messageId",
111
- "commandId",
112
- "status",
113
- "reason"
114
- ]
115
- },
116
- {
117
- "type": "object",
118
- "properties": {
119
- "messageId": {
120
- "type": "string"
121
- },
122
- "commandId": {
123
- "const": "system/version/response",
124
- "type": "string"
125
- },
126
- "status": {
127
- "const": "failed",
128
- "type": "string"
129
- },
130
- "reason": {
131
- "const": "invalid_command",
132
- "type": "string"
133
- }
134
- },
135
- "required": [
136
- "messageId",
137
- "commandId",
138
- "status",
139
- "reason"
140
- ]
141
- }
142
- ]
143
- }