dredless 0.2.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/LICENSE +21 -0
- package/README.md +48 -0
- package/docs/API_REFERENCE.md +2481 -0
- package/docs/BROWSER_API.md +98 -0
- package/docs/NODE_API.md +359 -0
- package/package.json +173 -0
- package/src/browser.d.ts +212 -0
- package/src/browser.js +133 -0
- package/src/client/core.js +1202 -0
- package/src/client/domains/index.js +1818 -0
- package/src/client/index.d.ts +2 -0
- package/src/client/index.js +1 -0
- package/src/compression/lz4.d.ts +1 -0
- package/src/compression/lz4.js +112 -0
- package/src/constants.js +74 -0
- package/src/crypto/chacha-native.d.ts +9 -0
- package/src/crypto/chacha-native.js +48 -0
- package/src/crypto/chacha.d.ts +25 -0
- package/src/crypto/chacha.js +274 -0
- package/src/data/item-schema.js +2235 -0
- package/src/data/official-client-data.js +156 -0
- package/src/events.js +39 -0
- package/src/index.d.ts +2277 -0
- package/src/index.js +125 -0
- package/src/network/browser-session.js +291 -0
- package/src/network/connection.d.ts +1 -0
- package/src/network/connection.js +31 -0
- package/src/network/cookies.js +85 -0
- package/src/network/http.js +34 -0
- package/src/network/index.d.ts +4 -0
- package/src/network/index.js +4 -0
- package/src/network/servers.d.ts +7 -0
- package/src/network/servers.js +133 -0
- package/src/network/session.d.ts +7 -0
- package/src/network/session.js +320 -0
- package/src/network/ships.d.ts +12 -0
- package/src/network/ships.js +73 -0
- package/src/node.d.ts +2 -0
- package/src/node.js +8 -0
- package/src/protocol/codec/binary.d.ts +3 -0
- package/src/protocol/codec/binary.js +52 -0
- package/src/protocol/codec/msgpack.d.ts +3 -0
- package/src/protocol/codec/msgpack.js +555 -0
- package/src/protocol/inbound/frame.d.ts +1 -0
- package/src/protocol/inbound/frame.js +8 -0
- package/src/protocol/inbound/world-payload.d.ts +3 -0
- package/src/protocol/inbound/world-payload.js +21 -0
- package/src/protocol/index.d.ts +11 -0
- package/src/protocol/index.js +19 -0
- package/src/protocol/outbound/blueprint.d.ts +22 -0
- package/src/protocol/outbound/blueprint.js +36 -0
- package/src/protocol/outbound/commands.d.ts +3 -0
- package/src/protocol/outbound/commands.js +149 -0
- package/src/protocol/outbound/comms.d.ts +28 -0
- package/src/protocol/outbound/comms.js +40 -0
- package/src/protocol/outbound/inventory.d.ts +64 -0
- package/src/protocol/outbound/inventory.js +147 -0
- package/src/protocol/outbound/ship-management.d.ts +84 -0
- package/src/protocol/outbound/ship-management.js +221 -0
- package/src/protocol/outbound/sign.d.ts +18 -0
- package/src/protocol/outbound/sign.js +45 -0
- package/src/protocol/outbound/ui-config.d.ts +157 -0
- package/src/protocol/outbound/ui-config.js +578 -0
- package/src/runtime.js +36 -0
- package/src/state/generator-maze.d.ts +32 -0
- package/src/state/generator-maze.js +370 -0
- package/src/state/index.d.ts +3 -0
- package/src/state/index.js +3 -0
- package/src/state/items.js +20 -0
- package/src/state/model/decoder.js +1554 -0
- package/src/state/model/index.d.ts +33 -0
- package/src/state/model/index.js +2 -0
- package/src/state/model/loader-config.js +1020 -0
- package/src/state/model/reader.js +69 -0
- package/src/state/model/state.js +1257 -0
- package/src/state/overworld.js +72 -0
- package/src/state/tilesets.js +53 -0
- package/src/state/world/index.d.ts +29 -0
- package/src/state/world/index.js +180 -0
- package/src/state/world/state.js +297 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Dredless Browser API
|
|
2
|
+
|
|
3
|
+
This document covers the browser-specific top-level API: ambient browser sessions, browser cookie handling, and browser start/join helpers.
|
|
4
|
+
|
|
5
|
+
Use this entrypoint in browser contexts:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import Dredless, { BrowserSession } from "dredless/browser";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Normal browser usage:
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
const session = await Dredless.createAnonSession();
|
|
15
|
+
const servers = await Dredless.fetchServers();
|
|
16
|
+
const ships = await Dredless.fetchShips(servers[0]);
|
|
17
|
+
const client = await Dredless.startShip(servers[0], ships[0]);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The browser API uses the current browser cookie jar with `credentials: "include"`. Browser JavaScript cannot read `Set-Cookie`, cannot set the `Cookie` header, and cannot set custom WebSocket headers, so browser authentication is ambient rather than multi-session.
|
|
21
|
+
|
|
22
|
+
Shared input shapes such as `Server`, `ServerRef`, `Ship`, `ShipRef`, and `ShipSpec` are documented in [API_REFERENCE.md](./API_REFERENCE.md#common-input-types). Shared client/world/entity/domain APIs are also documented in [API_REFERENCE.md](./API_REFERENCE.md).
|
|
23
|
+
|
|
24
|
+
## `DredlessBrowser` Namespace
|
|
25
|
+
|
|
26
|
+
`dredless/browser` exports a browser-first namespace. It assumes the current browser cookie jar and does not expose `Session` or `AnonSession`.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
interface DredlessBrowserNamespace {
|
|
30
|
+
BrowserSession: typeof BrowserSession;
|
|
31
|
+
Connection: typeof Connection;
|
|
32
|
+
DredlessClient: typeof DredlessClient;
|
|
33
|
+
browserSession: typeof browserSession;
|
|
34
|
+
createBrowserSession: typeof createBrowserSession;
|
|
35
|
+
createSession: typeof createSession;
|
|
36
|
+
createAnonSession: typeof createAnonSession;
|
|
37
|
+
createAnonToken: typeof createAnonToken;
|
|
38
|
+
fetchAnonKey: typeof fetchAnonKey;
|
|
39
|
+
setBrowserSession: typeof setBrowserSession;
|
|
40
|
+
fetchAccountStatus: typeof fetchAccountStatus;
|
|
41
|
+
fetchNoticeVersion: typeof fetchNoticeVersion;
|
|
42
|
+
fetchGameVersion: typeof fetchGameVersion;
|
|
43
|
+
fetchServers: typeof fetchServers;
|
|
44
|
+
fetchShips: typeof fetchShips;
|
|
45
|
+
fetchShipList: typeof fetchShipList;
|
|
46
|
+
joinShip: typeof joinShip;
|
|
47
|
+
startShip: typeof startShip;
|
|
48
|
+
startNewShip: typeof startNewShip;
|
|
49
|
+
joinInvite: typeof joinInvite;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`createSession(noticeVersion?, baseUrl?)` initializes the ambient browser session, fetches account status, and returns the active `BrowserSession`.
|
|
54
|
+
|
|
55
|
+
`createAnonSession(anonKey?, noticeVersion?, baseUrl?)` creates or applies an anonymous browser session. If `anonKey` is omitted, it posts to `/account/login/anon`, then reads `anon_key` through `cookieStore` or `document.cookie`. If the key cannot be read, it throws. If `anonKey` is provided, it is written to the ambient cookie jar when possible. The return value is still the active `BrowserSession`, not an isolated cookie jar.
|
|
56
|
+
|
|
57
|
+
`fetchAnonKey(noticeVersion?, baseUrl?)` / `createAnonToken(noticeVersion?, baseUrl?)` posts to `/account/login/anon` and returns the JS-readable `anon_key`. It throws if the login succeeds but the key is not readable through `cookieStore` or `document.cookie`.
|
|
58
|
+
|
|
59
|
+
Browser support is tested in page and content-script contexts on `drednot.io`. Background pages, popups, workers, and other non-page contexts are unlikely to expose `drednot.io` cookies to this API.
|
|
60
|
+
|
|
61
|
+
`fetchShips(server)` and `fetchShipList(server)` use the default ambient `BrowserSession`. Pass an explicit `BrowserSession` as the last argument only when targeting a different `baseUrl`.
|
|
62
|
+
|
|
63
|
+
`joinShip`, `startShip`, `startNewShip`, and `joinInvite` return ready `DredlessClient` instances just like the Node helpers.
|
|
64
|
+
|
|
65
|
+
## `BrowserSession`
|
|
66
|
+
|
|
67
|
+
`BrowserSession` is the browser counterpart to `Session`, but it is ambient-cookie based. It cannot read `Set-Cookie` and cannot set websocket headers, so authentication must be accepted by the browser's cookie jar.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
class BrowserSession {
|
|
71
|
+
constructor(baseUrl?: string);
|
|
72
|
+
baseUrl: string;
|
|
73
|
+
ambientAuth: true;
|
|
74
|
+
|
|
75
|
+
readAnonKey(): Promise<string>;
|
|
76
|
+
fetchAnonKey(noticeVersion?: number | null): Promise<string>;
|
|
77
|
+
fetchAccountStatus(): Promise<unknown>;
|
|
78
|
+
fetchShips(server: ServerRef): Promise<Ship[]>;
|
|
79
|
+
fetchShipList(server: ServerRef): Promise<ShipList>;
|
|
80
|
+
|
|
81
|
+
joinShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
|
|
82
|
+
startShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
|
|
83
|
+
startNewShipConnection(server: ServerRef, name?: string, color?: string): Promise<Connection>;
|
|
84
|
+
joinInviteConnection(server: ServerRef, code: string): Promise<Connection>;
|
|
85
|
+
|
|
86
|
+
joinShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
|
|
87
|
+
startShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
|
|
88
|
+
startNewShip(server: ServerRef, name?: string, color?: string): Promise<DredlessClient>;
|
|
89
|
+
joinInvite(server: ServerRef, code: string): Promise<DredlessClient>;
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## Browser Connections
|
|
95
|
+
|
|
96
|
+
Browser start/join helpers still produce `Connection` objects internally, but a browser `Connection` may have an empty `gameToken` when the token is only available through browser-managed cookies. `DredlessClient` uses the browser `WebSocket` implementation and relies on browser-managed cookies and origin headers.
|
|
97
|
+
|
|
98
|
+
The shared `DredlessClient` API is documented in [API_REFERENCE.md](./API_REFERENCE.md#dredlessclient).
|
package/docs/NODE_API.md
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
# Dredless Node API
|
|
2
|
+
|
|
3
|
+
This document covers the Node-specific top-level API: explicit sessions, anonymous token/session creation, connection descriptors, and convenience start/join helpers.
|
|
4
|
+
|
|
5
|
+
Use this entrypoint when you want the multi-session cookie-jar API:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import Dredless, {
|
|
9
|
+
Session,
|
|
10
|
+
AnonSession,
|
|
11
|
+
Connection,
|
|
12
|
+
DredlessClient
|
|
13
|
+
} from "dredless/node";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Normal Node usage:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
const session = await Dredless.createAnonSession();
|
|
20
|
+
const servers = await Dredless.fetchServers();
|
|
21
|
+
const ships = await session.fetchShips(servers[0]);
|
|
22
|
+
const client = await session.startShip(servers[0], ships[0]);
|
|
23
|
+
|
|
24
|
+
await client.whenReady();
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Shared input shapes such as `Server`, `ServerRef`, `Ship`, `ShipRef`, and `ShipSpec` are documented in [API_REFERENCE.md](./API_REFERENCE.md#common-input-types). Shared client/world/entity/domain APIs are also documented in [API_REFERENCE.md](./API_REFERENCE.md).
|
|
28
|
+
|
|
29
|
+
## `Dredless` Namespace
|
|
30
|
+
|
|
31
|
+
The default export is a namespace of constructors and convenience factories.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
interface DredlessNamespace {
|
|
35
|
+
Session: typeof Session;
|
|
36
|
+
AnonSession: typeof AnonSession;
|
|
37
|
+
Connection: typeof Connection;
|
|
38
|
+
DredlessClient: typeof DredlessClient;
|
|
39
|
+
createSession: typeof createSession;
|
|
40
|
+
createAnonSession: typeof createAnonSession;
|
|
41
|
+
createAnonToken: typeof createAnonToken;
|
|
42
|
+
fetchNoticeVersion: typeof fetchNoticeVersion;
|
|
43
|
+
fetchGameVersion: typeof fetchGameVersion;
|
|
44
|
+
fetchServers: typeof fetchServers;
|
|
45
|
+
fetchShips: typeof fetchShips;
|
|
46
|
+
fetchShipList: typeof fetchShipList;
|
|
47
|
+
joinShip: typeof joinShip;
|
|
48
|
+
startShip: typeof startShip;
|
|
49
|
+
startNewShip: typeof startNewShip;
|
|
50
|
+
joinInvite: typeof joinInvite;
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### `Dredless.createSession(noticeVersion?)`
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
function createSession(noticeVersion?: number | null): Promise<Session>;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Creates a `Session` using the current game version lookup and optional notice
|
|
61
|
+
version. It does not create an anonymous account.
|
|
62
|
+
|
|
63
|
+
### `Dredless.createAnonSession(anonKey?, noticeVersion?, baseUrl?)`
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
function createAnonSession(
|
|
67
|
+
anonKey?: string | null,
|
|
68
|
+
noticeVersion?: number | null,
|
|
69
|
+
baseUrl?: string
|
|
70
|
+
): Promise<AnonSession>;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Creates an anonymous session. If `anonKey` is omitted, the library requests one
|
|
74
|
+
from the server.
|
|
75
|
+
|
|
76
|
+
Returns an `AnonSession`.
|
|
77
|
+
|
|
78
|
+
### `Dredless.createAnonToken(noticeVersion?, baseUrl?)`
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
function createAnonToken(
|
|
82
|
+
noticeVersion?: number | null,
|
|
83
|
+
baseUrl?: string
|
|
84
|
+
): Promise<string>;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Requests a new anonymous account token.
|
|
88
|
+
|
|
89
|
+
### `Dredless.fetchNoticeVersion()`
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
function fetchNoticeVersion(): Promise<number>;
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Scrapes the current notice version needed by anon login.
|
|
96
|
+
|
|
97
|
+
### `Dredless.fetchGameVersion()`
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
function fetchGameVersion(): Promise<string>;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Scrapes the current game version string from the site.
|
|
104
|
+
|
|
105
|
+
### `Dredless.fetchServers()`
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
function fetchServers(): Promise<Server[]>;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Scrapes and returns known game servers.
|
|
112
|
+
|
|
113
|
+
### `Dredless.fetchShips(session, server)`
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
function fetchShips(session: Session, server: ServerRef): Promise<Ship[]>;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Authenticated convenience wrapper around `session.fetchShips(server)`.
|
|
120
|
+
|
|
121
|
+
### `Dredless.fetchShipList(session, server)`
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
function fetchShipList(session: Session, server: ServerRef): Promise<ShipList>;
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Authenticated convenience wrapper around `session.fetchShipList(server)`.
|
|
128
|
+
|
|
129
|
+
### `Dredless.joinShip(server, ship?, session?)`
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
function joinShip(
|
|
133
|
+
server: ServerRef,
|
|
134
|
+
ship?: ShipRef,
|
|
135
|
+
session?: Session | null
|
|
136
|
+
): Promise<DredlessClient>;
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Starts a websocket client using `never_load: true`. This is useful when you need
|
|
140
|
+
to join without loading the full ship world.
|
|
141
|
+
|
|
142
|
+
If `session` is omitted, an anonymous session is created.
|
|
143
|
+
|
|
144
|
+
### `Dredless.startShip(server, ship?, session?)`
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
function startShip(
|
|
148
|
+
server: ServerRef,
|
|
149
|
+
ship?: ShipRef,
|
|
150
|
+
session?: Session | null
|
|
151
|
+
): Promise<DredlessClient>;
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Starts a websocket client using normal world loading.
|
|
155
|
+
|
|
156
|
+
If `session` is omitted, an anonymous session is created.
|
|
157
|
+
|
|
158
|
+
### `Dredless.startNewShip(server, name?, color?, session?)`
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
function startNewShip(
|
|
162
|
+
server: ServerRef,
|
|
163
|
+
name?: string,
|
|
164
|
+
color?: string,
|
|
165
|
+
session?: Session | null
|
|
166
|
+
): Promise<DredlessClient>;
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Creates/starts a new ship and returns a live client.
|
|
170
|
+
|
|
171
|
+
### `Dredless.joinInvite(server, code, session?)`
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
function joinInvite(
|
|
175
|
+
server: ServerRef,
|
|
176
|
+
code: string,
|
|
177
|
+
session?: Session | null
|
|
178
|
+
): Promise<DredlessClient>;
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Joins through an invite code and returns a live client.
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
## `Session`
|
|
185
|
+
|
|
186
|
+
`Session` represents an authenticated HTTP session and owns cookies, account
|
|
187
|
+
status, ship list fetches, and `/join`.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
class Session {
|
|
191
|
+
constructor(gameSession?: string | null, gameVersion?: string | null);
|
|
192
|
+
|
|
193
|
+
baseUrl: string;
|
|
194
|
+
cookies: Map<string, string>;
|
|
195
|
+
gameVersion: string | null;
|
|
196
|
+
account: Account | null;
|
|
197
|
+
geoServer: number | null;
|
|
198
|
+
upgraded: boolean;
|
|
199
|
+
isRegistered: boolean;
|
|
200
|
+
showAds: boolean;
|
|
201
|
+
forceTutorial: boolean;
|
|
202
|
+
ban: unknown;
|
|
203
|
+
|
|
204
|
+
get gameSession(): string;
|
|
205
|
+
get gameToken(): string;
|
|
206
|
+
get noticeVersion(): number | string | null;
|
|
207
|
+
set noticeVersion(value: number | string | null);
|
|
208
|
+
|
|
209
|
+
request(path: string, init?: RequestInit & {
|
|
210
|
+
body?: BodyInit | Record<string, unknown> | null
|
|
211
|
+
}): Promise<Response>;
|
|
212
|
+
|
|
213
|
+
fetchAccountStatus(): Promise<unknown>;
|
|
214
|
+
fetchShips(server: ServerRef): Promise<Ship[]>;
|
|
215
|
+
fetchShipList(server: ServerRef): Promise<ShipList>;
|
|
216
|
+
|
|
217
|
+
joinShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
|
|
218
|
+
startShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
|
|
219
|
+
startNewShipConnection(
|
|
220
|
+
server: ServerRef,
|
|
221
|
+
name?: string,
|
|
222
|
+
color?: string
|
|
223
|
+
): Promise<Connection>;
|
|
224
|
+
joinInviteConnection(server: ServerRef, code: string): Promise<Connection>;
|
|
225
|
+
|
|
226
|
+
joinShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
|
|
227
|
+
startShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
|
|
228
|
+
startNewShip(server: ServerRef, name?: string, color?: string): Promise<DredlessClient>;
|
|
229
|
+
joinInvite(server: ServerRef, code: string): Promise<DredlessClient>;
|
|
230
|
+
|
|
231
|
+
toJSON(): SessionSnapshot;
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### `new Session(gameSession?, gameVersion?)`
|
|
236
|
+
|
|
237
|
+
Constructs an existing session wrapper. Does not perform network I/O.
|
|
238
|
+
|
|
239
|
+
### `session.request(path, init?)`
|
|
240
|
+
|
|
241
|
+
Authenticated HTTP helper. The `path` is relative to `session.baseUrl` unless a
|
|
242
|
+
full URL is supplied by the implementation path handling.
|
|
243
|
+
|
|
244
|
+
Input body may be a normal `BodyInit`, an object, or `null`.
|
|
245
|
+
|
|
246
|
+
Returns the raw `Response`.
|
|
247
|
+
|
|
248
|
+
### `session.fetchAccountStatus()`
|
|
249
|
+
|
|
250
|
+
Fetches and applies account status. Returns the decoded server response as
|
|
251
|
+
`unknown` because the live shape is not fully stabilized.
|
|
252
|
+
|
|
253
|
+
### `session.fetchShips(server)`
|
|
254
|
+
|
|
255
|
+
Returns `Ship[]`.
|
|
256
|
+
|
|
257
|
+
### `session.fetchShipList(server)`
|
|
258
|
+
|
|
259
|
+
Returns `ShipList`.
|
|
260
|
+
|
|
261
|
+
### Connection factories
|
|
262
|
+
|
|
263
|
+
These return `Connection` objects and do not open the websocket:
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
session.joinShipConnection(server, ship?): Promise<Connection>;
|
|
267
|
+
session.startShipConnection(server, ship?): Promise<Connection>;
|
|
268
|
+
session.startNewShipConnection(server, name?, color?): Promise<Connection>;
|
|
269
|
+
session.joinInviteConnection(server, code): Promise<Connection>;
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Use these when you want to construct `DredlessClient` yourself.
|
|
273
|
+
|
|
274
|
+
### Client factories
|
|
275
|
+
|
|
276
|
+
These return live `DredlessClient` objects:
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
session.joinShip(server, ship?): Promise<DredlessClient>;
|
|
280
|
+
session.startShip(server, ship?): Promise<DredlessClient>;
|
|
281
|
+
session.startNewShip(server, name?, color?): Promise<DredlessClient>;
|
|
282
|
+
session.joinInvite(server, code): Promise<DredlessClient>;
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### `session.toJSON()`
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
interface SessionSnapshot {
|
|
289
|
+
baseUrl: string;
|
|
290
|
+
gameSession: string;
|
|
291
|
+
gameToken: string;
|
|
292
|
+
gameVersion: string | null;
|
|
293
|
+
noticeVersion: number | string | null;
|
|
294
|
+
cookies: Record<string, string>;
|
|
295
|
+
account: Account | null;
|
|
296
|
+
geoServer: number | null;
|
|
297
|
+
upgraded: boolean;
|
|
298
|
+
isRegistered: boolean;
|
|
299
|
+
showAds: boolean;
|
|
300
|
+
forceTutorial: boolean;
|
|
301
|
+
ban: unknown;
|
|
302
|
+
anonKey?: string;
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## `AnonSession`
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
class AnonSession extends Session {
|
|
310
|
+
constructor(
|
|
311
|
+
gameSession?: string | null,
|
|
312
|
+
anonKey?: string | null,
|
|
313
|
+
gameVersion?: string | null
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
get anonKey(): string;
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
`AnonSession` is a `Session` with anonymous account key handling.
|
|
321
|
+
|
|
322
|
+
## `Connection`
|
|
323
|
+
|
|
324
|
+
`Connection` is a no-I/O descriptor for an already joined game session.
|
|
325
|
+
|
|
326
|
+
```ts
|
|
327
|
+
class Connection {
|
|
328
|
+
constructor(
|
|
329
|
+
session: Session,
|
|
330
|
+
gameToken: string,
|
|
331
|
+
netPort: number,
|
|
332
|
+
serverId: number | Server,
|
|
333
|
+
server?: Server | null
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
session: Session;
|
|
337
|
+
baseUrl: string;
|
|
338
|
+
gameToken: string;
|
|
339
|
+
netPort: number;
|
|
340
|
+
serverId: number;
|
|
341
|
+
server: Server | null;
|
|
342
|
+
|
|
343
|
+
toJSON(): ConnectionSnapshot;
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### `connection.toJSON()`
|
|
348
|
+
|
|
349
|
+
```ts
|
|
350
|
+
interface ConnectionSnapshot {
|
|
351
|
+
baseUrl: string;
|
|
352
|
+
gameToken: string;
|
|
353
|
+
netPort: number;
|
|
354
|
+
serverId: number;
|
|
355
|
+
server: Server | null;
|
|
356
|
+
session: SessionSnapshot;
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dredless",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "A from-scratch simple headless drednot.io client.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/certainhuman/dredless#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+ssh://git@github.com/certainhuman/dredless.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/certainhuman/dredless/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"drednot",
|
|
16
|
+
"drednot.io",
|
|
17
|
+
"headless",
|
|
18
|
+
"websocket"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "src/index.js",
|
|
22
|
+
"types": "./src/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./src/index.d.ts",
|
|
26
|
+
"browser": "./src/browser.js",
|
|
27
|
+
"node": "./src/node.js",
|
|
28
|
+
"import": "./src/index.js",
|
|
29
|
+
"default": "./src/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./browser": {
|
|
32
|
+
"types": "./src/browser.d.ts",
|
|
33
|
+
"import": "./src/browser.js",
|
|
34
|
+
"default": "./src/browser.js"
|
|
35
|
+
},
|
|
36
|
+
"./node": {
|
|
37
|
+
"types": "./src/node.d.ts",
|
|
38
|
+
"import": "./src/node.js",
|
|
39
|
+
"default": "./src/node.js"
|
|
40
|
+
},
|
|
41
|
+
"./client": {
|
|
42
|
+
"types": "./src/client/index.d.ts",
|
|
43
|
+
"import": "./src/client/index.js",
|
|
44
|
+
"default": "./src/client/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./session": {
|
|
47
|
+
"types": "./src/network/session.d.ts",
|
|
48
|
+
"import": "./src/network/session.js",
|
|
49
|
+
"default": "./src/network/session.js"
|
|
50
|
+
},
|
|
51
|
+
"./servers": {
|
|
52
|
+
"types": "./src/network/servers.d.ts",
|
|
53
|
+
"import": "./src/network/servers.js",
|
|
54
|
+
"default": "./src/network/servers.js"
|
|
55
|
+
},
|
|
56
|
+
"./ships": {
|
|
57
|
+
"types": "./src/network/ships.d.ts",
|
|
58
|
+
"import": "./src/network/ships.js",
|
|
59
|
+
"default": "./src/network/ships.js"
|
|
60
|
+
},
|
|
61
|
+
"./connection": {
|
|
62
|
+
"types": "./src/network/connection.d.ts",
|
|
63
|
+
"import": "./src/network/connection.js",
|
|
64
|
+
"default": "./src/network/connection.js"
|
|
65
|
+
},
|
|
66
|
+
"./world": {
|
|
67
|
+
"types": "./src/state/world/index.d.ts",
|
|
68
|
+
"import": "./src/state/world/index.js",
|
|
69
|
+
"default": "./src/state/world/index.js"
|
|
70
|
+
},
|
|
71
|
+
"./model": {
|
|
72
|
+
"types": "./src/state/model/index.d.ts",
|
|
73
|
+
"import": "./src/state/model/index.js",
|
|
74
|
+
"default": "./src/state/model/index.js"
|
|
75
|
+
},
|
|
76
|
+
"./network": {
|
|
77
|
+
"types": "./src/network/index.d.ts",
|
|
78
|
+
"import": "./src/network/index.js",
|
|
79
|
+
"default": "./src/network/index.js"
|
|
80
|
+
},
|
|
81
|
+
"./state": {
|
|
82
|
+
"types": "./src/state/index.d.ts",
|
|
83
|
+
"import": "./src/state/index.js",
|
|
84
|
+
"default": "./src/state/index.js"
|
|
85
|
+
},
|
|
86
|
+
"./protocol": {
|
|
87
|
+
"types": "./src/protocol/index.d.ts",
|
|
88
|
+
"import": "./src/protocol/index.js",
|
|
89
|
+
"default": "./src/protocol/index.js"
|
|
90
|
+
},
|
|
91
|
+
"./game/generator-maze": {
|
|
92
|
+
"types": "./src/state/generator-maze.d.ts",
|
|
93
|
+
"import": "./src/state/generator-maze.js",
|
|
94
|
+
"default": "./src/state/generator-maze.js"
|
|
95
|
+
},
|
|
96
|
+
"./game/model": {
|
|
97
|
+
"types": "./src/state/model/index.d.ts",
|
|
98
|
+
"import": "./src/state/model/index.js",
|
|
99
|
+
"default": "./src/state/model/index.js"
|
|
100
|
+
},
|
|
101
|
+
"./protocol/msgpack": {
|
|
102
|
+
"types": "./src/protocol/codec/msgpack.d.ts",
|
|
103
|
+
"import": "./src/protocol/codec/msgpack.js",
|
|
104
|
+
"default": "./src/protocol/codec/msgpack.js"
|
|
105
|
+
},
|
|
106
|
+
"./protocol/blueprint": {
|
|
107
|
+
"types": "./src/protocol/outbound/blueprint.d.ts",
|
|
108
|
+
"import": "./src/protocol/outbound/blueprint.js",
|
|
109
|
+
"default": "./src/protocol/outbound/blueprint.js"
|
|
110
|
+
},
|
|
111
|
+
"./protocol/comms": {
|
|
112
|
+
"types": "./src/protocol/outbound/comms.d.ts",
|
|
113
|
+
"import": "./src/protocol/outbound/comms.js",
|
|
114
|
+
"default": "./src/protocol/outbound/comms.js"
|
|
115
|
+
},
|
|
116
|
+
"./protocol/commands": {
|
|
117
|
+
"types": "./src/protocol/outbound/commands.d.ts",
|
|
118
|
+
"import": "./src/protocol/outbound/commands.js",
|
|
119
|
+
"default": "./src/protocol/outbound/commands.js"
|
|
120
|
+
},
|
|
121
|
+
"./protocol/inventory": {
|
|
122
|
+
"types": "./src/protocol/outbound/inventory.d.ts",
|
|
123
|
+
"import": "./src/protocol/outbound/inventory.js",
|
|
124
|
+
"default": "./src/protocol/outbound/inventory.js"
|
|
125
|
+
},
|
|
126
|
+
"./protocol/ship-management": {
|
|
127
|
+
"types": "./src/protocol/outbound/ship-management.d.ts",
|
|
128
|
+
"import": "./src/protocol/outbound/ship-management.js",
|
|
129
|
+
"default": "./src/protocol/outbound/ship-management.js"
|
|
130
|
+
},
|
|
131
|
+
"./protocol/sign": {
|
|
132
|
+
"types": "./src/protocol/outbound/sign.d.ts",
|
|
133
|
+
"import": "./src/protocol/outbound/sign.js",
|
|
134
|
+
"default": "./src/protocol/outbound/sign.js"
|
|
135
|
+
},
|
|
136
|
+
"./protocol/ui-config": {
|
|
137
|
+
"types": "./src/protocol/outbound/ui-config.d.ts",
|
|
138
|
+
"import": "./src/protocol/outbound/ui-config.js",
|
|
139
|
+
"default": "./src/protocol/outbound/ui-config.js"
|
|
140
|
+
},
|
|
141
|
+
"./crypto/chacha": {
|
|
142
|
+
"types": "./src/crypto/chacha.d.ts",
|
|
143
|
+
"import": "./src/crypto/chacha.js",
|
|
144
|
+
"default": "./src/crypto/chacha.js"
|
|
145
|
+
},
|
|
146
|
+
"./compression/lz4": {
|
|
147
|
+
"types": "./src/compression/lz4.d.ts",
|
|
148
|
+
"import": "./src/compression/lz4.js",
|
|
149
|
+
"default": "./src/compression/lz4.js"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"dependencies": {
|
|
153
|
+
"ws": "^8.18.0"
|
|
154
|
+
},
|
|
155
|
+
"files": [
|
|
156
|
+
"src",
|
|
157
|
+
"docs",
|
|
158
|
+
"README.md"
|
|
159
|
+
],
|
|
160
|
+
"publishConfig": {
|
|
161
|
+
"access": "public"
|
|
162
|
+
},
|
|
163
|
+
"scripts": {
|
|
164
|
+
"check": "node scripts/check-syntax.js",
|
|
165
|
+
"test": "node --test \"test/*.test.js\"",
|
|
166
|
+
"pack:check": "npm pack --dry-run",
|
|
167
|
+
"prepublishOnly": "npm run check && npm test",
|
|
168
|
+
"update:item-schema": "node scripts/update-item-schema.js"
|
|
169
|
+
},
|
|
170
|
+
"devDependencies": {
|
|
171
|
+
"dsa-shipshape": "^0.1.2"
|
|
172
|
+
}
|
|
173
|
+
}
|