dredless 0.6.3 → 1.0.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 +22 -57
- package/dist/browser/dredless.global.js +827 -1058
- package/dist/browser/dredless.global.js.map +4 -4
- package/docs/ACCOUNT.md +146 -0
- package/docs/API_REFERENCE.md +63 -2550
- package/docs/BROWSER_API.md +151 -70
- package/docs/CLIENT.md +183 -0
- package/docs/EVENTS.md +136 -0
- package/docs/GETTING_STARTED.md +135 -0
- package/docs/MACHINES.md +351 -0
- package/docs/MANAGEMENT.md +285 -0
- package/docs/NODE_API.md +120 -318
- package/docs/PLAYER_INVENTORY.md +235 -0
- package/docs/PROTOCOL.md +227 -0
- package/docs/README.md +44 -0
- package/docs/TROUBLESHOOTING.md +91 -0
- package/docs/WORLD_STATE.md +183 -0
- package/package.json +1 -2
- package/src/browser.d.ts +31 -1
- package/src/browser.js +10 -0
- package/src/client/core.js +302 -15
- package/src/client/domains/index.js +57 -7
- package/src/client/index.d.ts +1 -1
- package/src/index.d.ts +303 -14
- package/src/index.js +10 -0
- package/src/network/account.js +182 -0
- package/src/network/disconnect.d.ts +2 -0
- package/src/network/disconnect.js +53 -0
- package/src/network/index.d.ts +1 -0
- package/src/network/index.js +1 -0
- package/src/network/invites.d.ts +0 -3
- package/src/network/invites.js +3 -40
- package/src/network/session.d.ts +2 -0
- package/src/network/session.js +21 -0
- package/src/protocol/outbound/ship-management.d.ts +66 -1
- package/src/protocol/outbound/ship-management.js +83 -0
- package/src/state/model/decoder.js +101 -56
- package/src/state/model/index.d.ts +4 -0
- package/src/state/model/loader-config.js +0 -997
- package/src/state/model/state.js +28 -80
- package/src/state/world/index.js +27 -1
package/docs/ACCOUNT.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Account details, clan tags, and perk ships
|
|
2
|
+
|
|
3
|
+
[Documentation index](README.md) · [Node authentication](NODE_API.md#authentication-and-reuse) · [Browser setup](BROWSER_API.md)
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- [Methods and authentication](#methods-and-authentication)
|
|
8
|
+
- [Read account details](#read-account-details)
|
|
9
|
+
- [Read and change clan tags](#read-and-change-clan-tags)
|
|
10
|
+
- [Ships with patron perks](#ships-with-patron-perks)
|
|
11
|
+
- [Failures and data lifetime](#failures-and-data-lifetime)
|
|
12
|
+
|
|
13
|
+
## Methods and authentication
|
|
14
|
+
|
|
15
|
+
These methods live on `Session` and are inherited by `AnonSession` and `BrowserSession`. They use the authenticated
|
|
16
|
+
account page at the session's base URL. A session object does not by itself guarantee that the server exposes the
|
|
17
|
+
registered-account fields or forms.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
session.fetchAccountDetails(): Promise<AccountDetails>;
|
|
21
|
+
session.fetchClanTag(): Promise<ClanTagDetails>;
|
|
22
|
+
session.setClanTag(tag: string): Promise<ClanTagDetails>;
|
|
23
|
+
session.clearClanTag(): Promise<ClanTagDetails>;
|
|
24
|
+
session.removeShipPerks(shipId: string | number): Promise<AccountPerkShip[]>;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Use [Node session cookies](NODE_API.md#authentication-and-reuse)
|
|
28
|
+
or [browser ambient authentication](BROWSER_API.md#execution-context). Dredless does not automate identity-provider
|
|
29
|
+
login. Account operations use HTTP and do not require a game WebSocket.
|
|
30
|
+
|
|
31
|
+
## Read account details
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
interface ClanTagDetails {
|
|
35
|
+
tag: string | null;
|
|
36
|
+
otherUsers: number | null;
|
|
37
|
+
}
|
|
38
|
+
interface AccountPerkShip {
|
|
39
|
+
shipId: string;
|
|
40
|
+
name: string;
|
|
41
|
+
hexCode: string | null;
|
|
42
|
+
}
|
|
43
|
+
interface AccountDetails {
|
|
44
|
+
name: string | null;
|
|
45
|
+
color: number | null;
|
|
46
|
+
email: string | null;
|
|
47
|
+
identity: string | null;
|
|
48
|
+
identityService: string | null;
|
|
49
|
+
clan: ClanTagDetails;
|
|
50
|
+
shipsWithPerks: AccountPerkShip[] | null;
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Fragment:** `session` is authenticated using the runtime setup guide:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
const details = await session.fetchAccountDetails();
|
|
58
|
+
console.log(details.name, details.color, details.clan.tag);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
| Field | Source and meaning |
|
|
62
|
+
|-------------------|---------------------------------------------------------------------------------------------|
|
|
63
|
+
| `name` | The account page's “You are” label, preserving name text spacing |
|
|
64
|
+
| `color` | Label background as packed RGB, matching `session.account.color`; not foreground text color |
|
|
65
|
+
| `email` | Actual value in the email element's `data-info` attribute |
|
|
66
|
+
| `identity` | Identity value from `data-info`, with final parenthesized service removed |
|
|
67
|
+
| `identityService` | That service label, such as `Discord`, preserving displayed spelling |
|
|
68
|
+
| `clan` | Current tag and the number of other users sharing it |
|
|
69
|
+
| `shipsWithPerks` | This account's applied ship contributions, described below |
|
|
70
|
+
|
|
71
|
+
Missing/unrecognized scalar fields return `null`. Color parsing recognizes hexadecimal background/background-color
|
|
72
|
+
styles, not arbitrary CSS expressions. Email/identity values are read from attributes despite their visible masked text.
|
|
73
|
+
|
|
74
|
+
`fetchAccountStatus()` is separate: it reads JSON, updates `session.account` and status flags, and returns the decoded
|
|
75
|
+
response. It does not expose email, identity service, clan data, or applied perk ships. `fetchAccountDetails()` does not
|
|
76
|
+
refresh that status cache.
|
|
77
|
+
|
|
78
|
+
## Read and change clan tags
|
|
79
|
+
|
|
80
|
+
**Fragment:** these setters change the account's clan tag:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
const before = await session.fetchClanTag();
|
|
84
|
+
const updated = await session.setClanTag("Example Clan");
|
|
85
|
+
const cleared = await session.clearClanTag();
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`fetchClanTag()` returns only the `clan` object from a fresh account-page read. Empty tags become `null`. `otherUsers`
|
|
89
|
+
excludes the current account and is `null` if the page does not report a count; it is not a member roster or a directory
|
|
90
|
+
of clans.
|
|
91
|
+
|
|
92
|
+
`setClanTag()` requires a string, submits a URL-encoded `tag` field, then reads the page to confirm the stored tag. The
|
|
93
|
+
helper preserves the submitted value; server validation/normalization can cause exact-value confirmation to fail. No
|
|
94
|
+
local length rule is imposed here. `clearClanTag()` sends the official empty clear form; `setClanTag("")` does the same.
|
|
95
|
+
Both resolve with the confirmed `ClanTagDetails`.
|
|
96
|
+
|
|
97
|
+
Clan tags are for leaderboard attribution. They are not an in-game identity marker or proof of clan membership.
|
|
98
|
+
|
|
99
|
+
## Ships with patron perks
|
|
100
|
+
|
|
101
|
+
`details.shipsWithPerks` contains one entry per parsed account removal form. A recognized empty list is `[]`; a missing
|
|
102
|
+
section is `null`. Malformed present lists reject rather than silently becoming empty.
|
|
103
|
+
|
|
104
|
+
| Field | Example | Use |
|
|
105
|
+
|-----------|--------------------|-------------------------------------------------------------|
|
|
106
|
+
| `shipId` | `"1844458"` | Decimal form identifier; pass this to `removeShipPerks()` |
|
|
107
|
+
| `hexCode` | `"ABD1C2"` | Human-visible code without braces; not the removal selector |
|
|
108
|
+
| `name` | `"⏰ Out of Time"` | Displayed ship name |
|
|
109
|
+
|
|
110
|
+
These form/display IDs are distinct identifiers, not decimal/hex conversions. Names preserve spacing when the displayed
|
|
111
|
+
code can be parsed; fallback label parsing trims the label and returns `hexCode: null`.
|
|
112
|
+
|
|
113
|
+
**Fragment:** this removes the current account's contribution from a selected listed ship:
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
const details = await session.fetchAccountDetails();
|
|
117
|
+
const ship = details.shipsWithPerks?.find((entry) => entry.hexCode === selectedHexCode);
|
|
118
|
+
if (!ship) throw new Error("Selected ship is not in the account's applied-perks list");
|
|
119
|
+
const remaining = await session.removeShipPerks(ship.shipId);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`removeShipPerks()` accepts the positive decimal string from the form, or a positive safe integer. It posts the form's
|
|
123
|
+
`ship` field, reads account details again, and resolves with the remaining list only if that ID is absent. It rejects if
|
|
124
|
+
the ship is still listed or a readable list is unavailable. This confirms the page's observed state, not which request
|
|
125
|
+
caused it; an already-absent ship can also satisfy confirmation.
|
|
126
|
+
|
|
127
|
+
This account-page action does not require joining the ship and removes only the caller's contribution. It does not
|
|
128
|
+
directly edit a connected client's management cache. Current-ship perk controls and events are documented
|
|
129
|
+
in [management](MANAGEMENT.md#patron-perks).
|
|
130
|
+
|
|
131
|
+
## Failures and data lifetime
|
|
132
|
+
|
|
133
|
+
These methods scrape website HTML, not a stable JSON account API. They depend on the account form, field labels, and
|
|
134
|
+
applied-ships markup. A login/challenge page or a page without the expected clan form rejects. An unreadable perks
|
|
135
|
+
section can also cause account/clan reads to reject because they share the full parser.
|
|
136
|
+
|
|
137
|
+
Setters check HTTP results and read back state. Redirects alone are not success confirmation. A rejected confirmation
|
|
138
|
+
does not undo an account action the server already processed. The methods have no built-in per-call timeout or
|
|
139
|
+
cancellation option and do not serialize concurrent mutations; coordinate conflicting writes in your application.
|
|
140
|
+
|
|
141
|
+
Each read makes fresh requests; email, identity, clan details, and perk-ship lists are returned directly, not added to
|
|
142
|
+
`session.account` or `session.toJSON()`. Choose which fields to retain or log.
|
|
143
|
+
|
|
144
|
+
The perk-removal request is based on the official account form; a completed removal transaction was not available in the
|
|
145
|
+
reference capture. Success therefore depends on the live endpoint accepting that form and the subsequent page exposing a
|
|
146
|
+
readable list.
|