@fleetless/sdk 3.0.0 → 3.0.1
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/CHANGELOG.md +60 -0
- package/CODE_OF_CONDUCT.md +83 -0
- package/CONTRIBUTING.md +130 -0
- package/README.md +102 -4
- package/SECURITY.md +100 -0
- package/dist/index.cjs +374 -499
- package/dist/index.d.cts +63 -62
- package/dist/index.d.ts +63 -62
- package/dist/index.js +374 -499
- package/package.json +13 -5
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,66 @@ All notable changes to `@fleetless/sdk`. The format follows Keep a Changelog; th
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [3.0.1] — 2026-09-07
|
|
8
|
+
|
|
9
|
+
No API change. This release exists because **3.0.0 published internal material
|
|
10
|
+
to the registry**, and the only way to withdraw it is to publish a version
|
|
11
|
+
without it.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- **The published bundle no longer carries internal text.** `tsup` inlines
|
|
16
|
+
`@fleetless/contracts` into `dist/index.js` and `dist/index.cjs` with its doc
|
|
17
|
+
comments intact, and it writes the path each inlined module came from as a
|
|
18
|
+
comment beside it. In 3.0.0 those paths encoded a `git+ssh://` dependency
|
|
19
|
+
specifier, so an internal hostname appeared **48 times** across the two
|
|
20
|
+
bundles; the inlined comments carried German paragraphs and internal defect
|
|
21
|
+
ids with them. Measured over the published tarballs, the same seventeen
|
|
22
|
+
detectors over `dist/`:
|
|
23
|
+
|
|
24
|
+
| | 3.0.0 | 3.0.1 |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| internal host or workspace name | 49 | 0 |
|
|
27
|
+
| German prose | 58 | 0 |
|
|
28
|
+
| internal wave labels | 134 | 0 |
|
|
29
|
+
| internal decision labels | 42 | 0 |
|
|
30
|
+
| internal defect ids | 14 | 0 |
|
|
31
|
+
| every other class | 62 | 0 |
|
|
32
|
+
|
|
33
|
+
None of it appeared in this repository's own source, which is why no sweep of
|
|
34
|
+
the source had found it. The fix is the contracts pin — `@fleetless/contracts`
|
|
35
|
+
is a public npm package at an exact version now — plus a sweep of this
|
|
36
|
+
repository's own comments.
|
|
37
|
+
|
|
38
|
+
- **`publishers.publish`, `commands.cancel`, `cameras.live` and the error
|
|
39
|
+
re-exports pointed at README sections that did not exist.** One of them
|
|
40
|
+
(`cancel`'s upgrade message) is a **runtime error** telling a developer to
|
|
41
|
+
read "the README's Actions section" of a README whose sections were named
|
|
42
|
+
something else. The README now has *Actions*, *Errors*, and *Publishers, and
|
|
43
|
+
no teleop helpers*, and every pointer resolves.
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- **`SECURITY.md`, `CONTRIBUTING.md` and `CODE_OF_CONDUCT.md`**, and all three
|
|
48
|
+
ship inside the tarball, so the README's links resolve from `node_modules` and
|
|
49
|
+
from the npm page. `SECURITY.md` says what is in scope here — how this package
|
|
50
|
+
handles tokens, the PKCE verifier and the `state` value — and that the cloud
|
|
51
|
+
is not in this repository. Security reports go to **security@fleetless.dev**,
|
|
52
|
+
which the README now states literally rather than only by link.
|
|
53
|
+
- **`repository` and `bugs.url`** in `package.json`, pointing at
|
|
54
|
+
<https://github.com/fleetless/sdk>.
|
|
55
|
+
- **An `Errors` section in the README**, documenting the `FleetlessError` `code`
|
|
56
|
+
you branch on, that `rate_limited` is surfaced with its `retry_after_ms` and
|
|
57
|
+
never retried, and that `token_expired` is the one retry the SDK performs.
|
|
58
|
+
- **The SPDX header `// SPDX-License-Identifier: MIT`** on every source file and
|
|
59
|
+
on all four published `dist/` files. `test/license-headers.test.ts` asserts it
|
|
60
|
+
over the repository; `pnpm run test:pack` asserts it over the tarball's own
|
|
61
|
+
bytes, which is the only place that can tell a stamped build from a stamped
|
|
62
|
+
publish.
|
|
63
|
+
- **`test/published-prose.test.ts`**, which is what stops the top item here from
|
|
64
|
+
happening again: fifteen detector classes over `dist/`, `src/`, `test/`,
|
|
65
|
+
`scripts/` and the shipped markdown, with fixtures in both directions.
|
|
66
|
+
|
|
7
67
|
## [3.0.0] — 2026-09-06
|
|
8
68
|
|
|
9
69
|
Fleetless shows an app user **no page**. The developer's own UI owns every
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
## Our Standards
|
|
10
|
+
|
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
|
12
|
+
|
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
|
18
|
+
|
|
19
|
+
Examples of unacceptable behavior include:
|
|
20
|
+
|
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
|
|
22
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
23
|
+
* Public or private harassment
|
|
24
|
+
* Publishing others' private information, such as a physical or email address, without their explicit permission
|
|
25
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
26
|
+
|
|
27
|
+
## Enforcement Responsibilities
|
|
28
|
+
|
|
29
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
30
|
+
|
|
31
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
32
|
+
|
|
33
|
+
## Scope
|
|
34
|
+
|
|
35
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
36
|
+
|
|
37
|
+
## Enforcement
|
|
38
|
+
|
|
39
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hello@fleetless.dev. All complaints will be reviewed and investigated promptly and fairly.
|
|
40
|
+
|
|
41
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
42
|
+
|
|
43
|
+
## Enforcement Guidelines
|
|
44
|
+
|
|
45
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
|
46
|
+
|
|
47
|
+
### 1. Correction
|
|
48
|
+
|
|
49
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
|
50
|
+
|
|
51
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
52
|
+
|
|
53
|
+
### 2. Warning
|
|
54
|
+
|
|
55
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
|
56
|
+
|
|
57
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
|
58
|
+
|
|
59
|
+
### 3. Temporary Ban
|
|
60
|
+
|
|
61
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
62
|
+
|
|
63
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
|
64
|
+
|
|
65
|
+
### 4. Permanent Ban
|
|
66
|
+
|
|
67
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
68
|
+
|
|
69
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
70
|
+
|
|
71
|
+
## Attribution
|
|
72
|
+
|
|
73
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
74
|
+
|
|
75
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
76
|
+
|
|
77
|
+
For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
|
|
78
|
+
|
|
79
|
+
[homepage]: https://www.contributor-covenant.org
|
|
80
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
81
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
82
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
83
|
+
[translations]: https://www.contributor-covenant.org/translations
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Contributing to `@fleetless/sdk`
|
|
2
|
+
|
|
3
|
+
This package is the TypeScript client for the Fleetless API. It is what a
|
|
4
|
+
developer's own application calls, so a change here reaches every app built on
|
|
5
|
+
it, and a change to what a method *sends* reaches the platform as well.
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
Node 22 and pnpm (through corepack):
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
nvm use 22
|
|
13
|
+
corepack enable
|
|
14
|
+
pnpm install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
There are no private dependencies. `pnpm install` works from a clean checkout
|
|
18
|
+
with nothing but a network connection to the npm registry — the wire schemas
|
|
19
|
+
come from `@fleetless/contracts`, which is a public package.
|
|
20
|
+
|
|
21
|
+
`pnpm install` runs `prepare`, which builds `dist/`. Some of the checks below
|
|
22
|
+
read the built bundle, so a fresh checkout is ready for them.
|
|
23
|
+
|
|
24
|
+
## The checks
|
|
25
|
+
|
|
26
|
+
| Command | What it does |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `pnpm typecheck` | `tsc --noEmit` over the whole project. |
|
|
29
|
+
| `pnpm test` | The vitest suite. No network beyond loopback. |
|
|
30
|
+
| `pnpm build` | `tsup` into `dist/` — ESM, CJS, and a declaration file for each. |
|
|
31
|
+
| `pnpm run test:pack` | Packs the tarball, asserts what is and is not inside it, then installs it into a scratch project and both typechecks and runs real code against it. |
|
|
32
|
+
|
|
33
|
+
To run one test file, use `pnpm vitest run test/<name>.test.ts`.
|
|
34
|
+
|
|
35
|
+
## The rule this repository is most serious about: a real server, not a mocked `fetch`
|
|
36
|
+
|
|
37
|
+
**The auth suites drive the SDK's own default `fetch` against a real
|
|
38
|
+
`node:http` server** (`test/local-api.ts`), and no `fetch` option is passed to
|
|
39
|
+
`createClient` in them.
|
|
40
|
+
|
|
41
|
+
That is not ceremony. A suite that passes its own `fetch` never enters the code
|
|
42
|
+
that actually ships: `client.ts` resolves `globalThis.fetch.bind(globalThis)`,
|
|
43
|
+
and every assertion about "what the SDK sends" becomes an assertion about what
|
|
44
|
+
a `vi.fn()` was asked to pretend to send. The two most expensive defects this
|
|
45
|
+
package has had were both invisible to a mocked `fetch` and both obvious to a
|
|
46
|
+
socket:
|
|
47
|
+
|
|
48
|
+
- `createClient` defaulted to a **detached** `globalThis.fetch`. A real
|
|
49
|
+
browser's `fetch` is a Web IDL method that throws "Illegal invocation" unless
|
|
50
|
+
its receiver is the global object. Node's undici does not enforce that check,
|
|
51
|
+
so every test passed and every browser failed on the first call.
|
|
52
|
+
- A path segment shaped like `../../../admin` reached a real server as a
|
|
53
|
+
traversal, because the encoding was asserted against a double that never
|
|
54
|
+
parsed the URL.
|
|
55
|
+
|
|
56
|
+
So: **if your change is about what leaves the process, test it against
|
|
57
|
+
`test/local-api.ts`.** A double is fine for testing branching, refcounting,
|
|
58
|
+
timers and error mapping, and most of the suite uses one for exactly that.
|
|
59
|
+
|
|
60
|
+
`test/client.test.ts` carries a test named for this property on its own, so
|
|
61
|
+
that removing it is visible in a diff rather than silent.
|
|
62
|
+
|
|
63
|
+
## Licence headers
|
|
64
|
+
|
|
65
|
+
Every source file carries the SPDX header `// SPDX-License-Identifier: MIT` as
|
|
66
|
+
its first line — a `#!` shebang is the only thing allowed above it.
|
|
67
|
+
`test/license-headers.test.ts` asserts this over the whole set, and it takes
|
|
68
|
+
that set from `git ls-files` rather than from a list of directories, so a file
|
|
69
|
+
added anywhere in the repository is swept the day it exists.
|
|
70
|
+
|
|
71
|
+
## Nothing internal reaches the published bytes
|
|
72
|
+
|
|
73
|
+
`tsup` bundles `@fleetless/contracts` **into** `dist/index.js` and
|
|
74
|
+
`dist/index.cjs`, doc comments and all, and it writes the path each inlined
|
|
75
|
+
module came from as a comment beside it. A comment written for the people who
|
|
76
|
+
build this is therefore a comment an editor shows to somebody who installed it —
|
|
77
|
+
and for four published versions that included German paragraphs, internal
|
|
78
|
+
defect ids and an internal hostname, none of which appeared anywhere in this
|
|
79
|
+
repository's source.
|
|
80
|
+
|
|
81
|
+
Write a comment as what the code does for a caller. Never as how the behaviour
|
|
82
|
+
was found, on which machine, under which internal ticket, or in which language
|
|
83
|
+
the team happened to be thinking that day.
|
|
84
|
+
|
|
85
|
+
`test/published-prose.test.ts` enforces it over `dist/`, `src/`, `test/`,
|
|
86
|
+
`scripts/` and the shipped markdown, and it will tell you which class of thing
|
|
87
|
+
came back and on which line.
|
|
88
|
+
|
|
89
|
+
## Pull requests
|
|
90
|
+
|
|
91
|
+
**Pull requests are welcome on GitHub**, at
|
|
92
|
+
<https://github.com/fleetless/sdk>. Open an issue first for anything that
|
|
93
|
+
changes an existing method signature or what a method sends, so we can say what
|
|
94
|
+
else has to move with it.
|
|
95
|
+
|
|
96
|
+
**CI runs on GitLab.** This repository is mirrored from an internal GitLab
|
|
97
|
+
instance, which is where the pipeline that verifies and publishes it lives. You
|
|
98
|
+
will not see a check run on your GitHub pull request; a maintainer runs the
|
|
99
|
+
same checks, and the result comes back as a review comment. Run
|
|
100
|
+
`pnpm typecheck && pnpm test && pnpm run test:pack` yourself before you open the
|
|
101
|
+
pull request and you will have seen everything CI would tell you.
|
|
102
|
+
|
|
103
|
+
## The CLA
|
|
104
|
+
|
|
105
|
+
The first pull request you open will ask you to sign a Contributor Licence
|
|
106
|
+
Agreement. It grants Dehne Robotik GmbH the right to license your contribution
|
|
107
|
+
under terms other than MIT in future — that is the whole of what it is for, and
|
|
108
|
+
it is why the project can relicense its own code later without having to find
|
|
109
|
+
every past contributor. It does not take your copyright away and it does not
|
|
110
|
+
stop you from using your own contribution however you like.
|
|
111
|
+
|
|
112
|
+
## Commit messages
|
|
113
|
+
|
|
114
|
+
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/):
|
|
115
|
+
`feat:`, `fix:`, `docs:`, `chore:`, `ci:`, `refactor:`, `test:`. A change that
|
|
116
|
+
alters an existing method's signature or what it sends is a breaking change;
|
|
117
|
+
say so with a `!` and a `BREAKING CHANGE:` footer, because it decides the next
|
|
118
|
+
version number.
|
|
119
|
+
|
|
120
|
+
Everything in this repository is written in **English** — code, comments,
|
|
121
|
+
commit messages, documentation.
|
|
122
|
+
|
|
123
|
+
## Code of conduct
|
|
124
|
+
|
|
125
|
+
By participating you agree to the [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
126
|
+
|
|
127
|
+
## Releasing (maintainers)
|
|
128
|
+
|
|
129
|
+
See [RELEASING.md](RELEASING.md). The pipeline publishes; `npm publish` from a
|
|
130
|
+
working tree is not how a version gets to the registry.
|
package/README.md
CHANGED
|
@@ -15,6 +15,21 @@ ships ESM and CJS with its own types, and runs wherever a `fetch` and a
|
|
|
15
15
|
`WebSocket` exist — a browser, a mobile webview, Node 20 or newer, and
|
|
16
16
|
server-side with a server key instead of a user session.
|
|
17
17
|
|
|
18
|
+
**The mental model in one paragraph.** A robot runs the Fleetless bridge, a
|
|
19
|
+
ROS 2 node. In the [Fleetless Console](https://console.fleetless.dev) a
|
|
20
|
+
developer picks which topics, services and actions that robot exposes and gives
|
|
21
|
+
each one a stable `snake_case` slug and a role that may reach it. The cloud
|
|
22
|
+
turns those into REST and realtime endpoints. This package is the client for
|
|
23
|
+
those endpoints: you address a robot by its id and a capability by its slug,
|
|
24
|
+
you sign your own users in against your own app's user directory, and you never
|
|
25
|
+
see a ROS name, a topic type or a message definition. Renaming a node on the
|
|
26
|
+
robot is invisible to your app; changing a slug is not.
|
|
27
|
+
|
|
28
|
+
New here? The [getting-started guide](https://docs.fleetless.dev/getting-started/)
|
|
29
|
+
goes from a robot that has never connected to a value on a page, and the
|
|
30
|
+
[app-auth recipe](https://docs.fleetless.dev/recipes/app-auth/) is the
|
|
31
|
+
walkthrough for every sign-in screen.
|
|
32
|
+
|
|
18
33
|
## Why
|
|
19
34
|
|
|
20
35
|
- **One connection, however many subscriptions.** Every datapoint and job
|
|
@@ -202,7 +217,7 @@ const grants = await client.auth.listMcpGrants()
|
|
|
202
217
|
await client.auth.revokeMcpGrant(grants[0].client_id)
|
|
203
218
|
```
|
|
204
219
|
|
|
205
|
-
###
|
|
220
|
+
### Actions
|
|
206
221
|
|
|
207
222
|
An action is a job with a lifecycle. `invoke` resolves as soon as the job
|
|
208
223
|
exists; feedback, progress and the result arrive over `subscribe`.
|
|
@@ -230,6 +245,35 @@ sub.unsubscribe()
|
|
|
230
245
|
`error.details.running`. A service is the same machinery with a plain result:
|
|
231
246
|
`await client.services.call(robotId, 'set_mode', { mode: 'autonomous' })`.
|
|
232
247
|
|
|
248
|
+
### Publishers, and no teleop helpers
|
|
249
|
+
|
|
250
|
+
`publishers.publish` sends **one** message. There is no `startPublishing`, no
|
|
251
|
+
rate helper, no joystick binding and no "hold this value" call, and that is a
|
|
252
|
+
decision rather than a gap.
|
|
253
|
+
|
|
254
|
+
The safety primitive lives on the robot. A publisher is configured with a
|
|
255
|
+
`timeout_ms` and a failsafe message; if messages stop arriving — including
|
|
256
|
+
because your process crashed, your tab closed, or the network went away — the
|
|
257
|
+
bridge publishes the failsafe itself. Nothing in your event loop has to survive
|
|
258
|
+
for that to happen.
|
|
259
|
+
|
|
260
|
+
A helper here would move the appearance of that guarantee into a browser, where
|
|
261
|
+
it is not true. So *how often* and *when* to publish is your application's
|
|
262
|
+
decision, made where it can see the user's intent:
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
// A control loop is yours to write, and yours to stop.
|
|
266
|
+
const timer = setInterval(() => {
|
|
267
|
+
void client.publishers.publish(robotId, 'cmd_vel', { 'linear.x': speed })
|
|
268
|
+
}, 100)
|
|
269
|
+
|
|
270
|
+
// Stop publishing and let the robot's own failsafe take over.
|
|
271
|
+
clearInterval(timer)
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
`publish` rejects `publisher_busy` while a different user holds the publisher
|
|
275
|
+
and has not been quiet for its configured timeout.
|
|
276
|
+
|
|
233
277
|
### Cameras
|
|
234
278
|
|
|
235
279
|
```ts
|
|
@@ -250,6 +294,44 @@ await room.disconnect()
|
|
|
250
294
|
await session.release()
|
|
251
295
|
```
|
|
252
296
|
|
|
297
|
+
## Errors
|
|
298
|
+
|
|
299
|
+
Every refusal arrives as a `FleetlessError` with a stable `code`. Branch on the
|
|
300
|
+
code; never parse the message, which is written for a developer reading a
|
|
301
|
+
console and may change.
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
import { FleetlessError } from '@fleetless/sdk'
|
|
305
|
+
|
|
306
|
+
try {
|
|
307
|
+
await client.actions.invoke(robotId, 'dock', {})
|
|
308
|
+
} catch (error) {
|
|
309
|
+
if (!(error instanceof FleetlessError)) throw error
|
|
310
|
+
switch (error.code) {
|
|
311
|
+
case 'busy': return showRunning(error.details?.running)
|
|
312
|
+
case 'robot_offline': return showOffline()
|
|
313
|
+
case 'forbidden': return showNotAllowed()
|
|
314
|
+
case 'rate_limited': return showRetryLater(error.details?.retry_after_ms)
|
|
315
|
+
default: return showUnexpected(error)
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
- **`rate_limited` is surfaced, never retried behind your back.** The SDK does
|
|
321
|
+
not sleep and re-send. `error.details.retry_after_ms` carries the wait the
|
|
322
|
+
platform asked for, when it sent one — read it defensively, since a refusal
|
|
323
|
+
from an intermediary may carry no `details` at all.
|
|
324
|
+
- **The one retry the SDK does perform is `token_expired`**, and only once: it
|
|
325
|
+
refreshes the session and re-sends the same request. That refresh is
|
|
326
|
+
single-flight, so ten concurrent calls meeting an expired token share one.
|
|
327
|
+
- **`command_outcome_unknown` is an honest answer, not a failure.** It means
|
|
328
|
+
the realtime connection cycled while a command was in flight and the SDK
|
|
329
|
+
cannot say whether the robot got it. Read the job back by slug through
|
|
330
|
+
`actions.subscribe` to find out.
|
|
331
|
+
- Some codes never reach the network at all — `invalid_option`,
|
|
332
|
+
`state_mismatch`, `no_session`, `untrusted_absolute_url`. They are the SDK
|
|
333
|
+
refusing to send something rather than the platform refusing to accept it.
|
|
334
|
+
|
|
253
335
|
## Documentation and help
|
|
254
336
|
|
|
255
337
|
- **[SDK reference](https://docs.fleetless.dev/reference/sdk/)** — every method,
|
|
@@ -270,10 +352,26 @@ await session.release()
|
|
|
270
352
|
Fleetless is in closed beta. The waiting list is at
|
|
271
353
|
<https://fleetless.dev/#waiting-list>.
|
|
272
354
|
|
|
355
|
+
## Reporting a security issue
|
|
356
|
+
|
|
357
|
+
Email **security@fleetless.dev**. Please do not open a public issue for a
|
|
358
|
+
security report. [SECURITY.md](SECURITY.md) says what is in scope here — how
|
|
359
|
+
this package handles tokens, the PKCE verifier and the `state` value — and what
|
|
360
|
+
belongs to the platform instead.
|
|
361
|
+
|
|
362
|
+
## Contributing
|
|
363
|
+
|
|
364
|
+
Pull requests are welcome at <https://github.com/fleetless/sdk>. Read
|
|
365
|
+
[CONTRIBUTING.md](CONTRIBUTING.md) first: it covers the setup, the checks, the
|
|
366
|
+
Contributor Licence Agreement, and the one rule this repository is strict about
|
|
367
|
+
— the auth suites drive the SDK's own `fetch` against a real `node:http`
|
|
368
|
+
server rather than a double, because a mocked `fetch` cannot see the bugs that
|
|
369
|
+
have actually shipped.
|
|
370
|
+
|
|
371
|
+
By participating you agree to the [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
372
|
+
|
|
273
373
|
## Maintainers
|
|
274
374
|
|
|
275
|
-
Maintained by [Dehne Robotik GmbH](https://dehne-robotik.de).
|
|
276
|
-
repository is private and takes no outside contributions; questions and bug
|
|
277
|
-
reports go to hello@fleetless.dev.
|
|
375
|
+
Maintained by [Dehne Robotik GmbH](https://dehne-robotik.de).
|
|
278
376
|
|
|
279
377
|
MIT licensed — see [LICENSE](LICENSE).
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
Email **security@fleetless.dev**. Please do not open a public GitHub issue for
|
|
6
|
+
a security report.
|
|
7
|
+
|
|
8
|
+
Include what you found, the SDK version and runtime it happens on (a browser
|
|
9
|
+
name and version, or a Node version), and the smallest sequence of SDK calls
|
|
10
|
+
that shows it. A reproduction against a published version of this package is
|
|
11
|
+
the most useful thing you can send.
|
|
12
|
+
|
|
13
|
+
We acknowledge every report within **3 working days** and follow up with
|
|
14
|
+
either a fix or a written plan within **30 days**. If a report leads to a
|
|
15
|
+
released fix, we credit you by name unless you ask us not to.
|
|
16
|
+
|
|
17
|
+
## What is in scope
|
|
18
|
+
|
|
19
|
+
This repository is the TypeScript SDK that client applications use to talk to
|
|
20
|
+
Fleetless. It runs **in your users' browsers and on your servers**, and it
|
|
21
|
+
holds credentials while it does. That is where its security surface is.
|
|
22
|
+
|
|
23
|
+
Specifically in scope:
|
|
24
|
+
|
|
25
|
+
### Tokens
|
|
26
|
+
|
|
27
|
+
The SDK receives an access token and a refresh token from the platform and
|
|
28
|
+
hands them to a `TokenStore` that **you** implement; the built-in default keeps
|
|
29
|
+
them in memory only and writes them nowhere. A report is in scope if the SDK:
|
|
30
|
+
|
|
31
|
+
- puts a token somewhere the caller did not ask for it to go — a global, a
|
|
32
|
+
URL, a query string, a log line, an error message, or a thrown object's
|
|
33
|
+
properties;
|
|
34
|
+
- sends a token to an origin other than the `apiUrl` the client was
|
|
35
|
+
constructed with;
|
|
36
|
+
- attaches a token to a request it should not have (the SDK refuses an
|
|
37
|
+
absolute URL it did not build — see `untrusted_absolute_url`);
|
|
38
|
+
- keeps a token reachable after `logout()`, or fails to clear the store;
|
|
39
|
+
- races its own silent refresh in a way that lets a stale or a foreign token
|
|
40
|
+
be used.
|
|
41
|
+
|
|
42
|
+
Choosing to persist tokens in `localStorage`, a cookie or a native keystore is
|
|
43
|
+
your decision and its consequences are yours; a defect in how the SDK *hands*
|
|
44
|
+
them to your store is ours.
|
|
45
|
+
|
|
46
|
+
### PKCE and `state` in the federated sign-in flow
|
|
47
|
+
|
|
48
|
+
`beginOidcLogin` generates a PKCE verifier and a `state` value and returns them
|
|
49
|
+
to you, because a redirect is a fresh page load and the SDK has nowhere of its
|
|
50
|
+
own to keep them. `completeOidcLogin` checks `state` before it exchanges
|
|
51
|
+
anything.
|
|
52
|
+
|
|
53
|
+
In scope: a verifier or a `state` with insufficient entropy or a predictable
|
|
54
|
+
source; S256 not being enforced; `completeOidcLogin` exchanging a code when
|
|
55
|
+
`state` does not match, is missing, or when `expectedState` is empty — that
|
|
56
|
+
last case is checked first and explicitly, because two empty strings compare
|
|
57
|
+
equal; any path that reaches the token exchange without the check.
|
|
58
|
+
|
|
59
|
+
**Where you store the verifier and the `state` between the two calls is your
|
|
60
|
+
application's decision**, and this policy cannot cover it. The README shows
|
|
61
|
+
`sessionStorage`, which is a reasonable default and not the only correct one.
|
|
62
|
+
|
|
63
|
+
### The rest of the package
|
|
64
|
+
|
|
65
|
+
- Request construction: path segments are percent-encoded (`pathSegment`), so
|
|
66
|
+
a slug or an identifier shaped like `../../../admin` must not escape its
|
|
67
|
+
position in the URL.
|
|
68
|
+
- The realtime channel: its authentication, its reconnection, and what it
|
|
69
|
+
resends after one.
|
|
70
|
+
- `prepareUrdfScene` and `createMeshLoader`: a robot's own URDF names the URLs
|
|
71
|
+
three.js is asked to fetch, so a reference the SDK does not own must not
|
|
72
|
+
become a network request from your users' browsers.
|
|
73
|
+
- Anything the SDK writes into browser-reachable state.
|
|
74
|
+
- The published npm package `@fleetless/sdk` and its contents, including a
|
|
75
|
+
dependency of it.
|
|
76
|
+
|
|
77
|
+
## What is not in scope
|
|
78
|
+
|
|
79
|
+
**The Fleetless cloud is not in this repository.** A server that fails to
|
|
80
|
+
enforce a permission, an authentication or authorisation flaw in the platform,
|
|
81
|
+
a rate limit, a data leak from an API endpoint, anything about how a token is
|
|
82
|
+
minted or validated — none of those live here, and none of them can be fixed by
|
|
83
|
+
a change to this package. Report them to the same address; say which service
|
|
84
|
+
you were looking at, and we will route it. What we cannot do is treat this
|
|
85
|
+
repository's issue tracker as the place where they are tracked.
|
|
86
|
+
|
|
87
|
+
Also out of scope here: the Fleetless console, the robot-side bridge, the
|
|
88
|
+
`@fleetless/contracts` schemas (they have their own repository and their own
|
|
89
|
+
policy), the documentation site, and any deployment of Fleetless operated by
|
|
90
|
+
someone else.
|
|
91
|
+
|
|
92
|
+
Out of scope in your own application: where you store tokens, how you protect
|
|
93
|
+
your own pages, and any XSS in your app — an attacker who can run script in
|
|
94
|
+
your page can read anything your page can, and no SDK design prevents that.
|
|
95
|
+
|
|
96
|
+
## Supported versions
|
|
97
|
+
|
|
98
|
+
The latest published minor of `@fleetless/sdk` receives fixes. Older minors do
|
|
99
|
+
not; a security fix is released as a new patch on the current minor, and
|
|
100
|
+
upgrading is the remedy.
|