@fleetless/sdk 4.6.0 → 4.6.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 CHANGED
@@ -4,6 +4,23 @@ All notable changes to `@fleetless/sdk`. The format follows Keep a Changelog; th
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [4.6.1] — 2026-11-03
8
+
9
+ ### Fixed
10
+
11
+ - **`auth.signInMethods()` checks `twoFactor` instead of passing the wire value through.** A cloud that predates the policy field sends none, and a value outside `off | optional | required` was handed on unchecked under a type that promised one of the three. Both now come back as `twoFactor: null`, and the type is `'off' | 'optional' | 'required' | null`; the SDK never substitutes a default. Treat `null` as a failed policy read — offer no two-factor action and let the person retry, never read it as `'off'`; the cloud still enforces its own policy at sign-in. `password` and `emailCode` are mapped as before, so a login screen keeps working against an older cloud, and `listProviders()` is unchanged. Code that assigns `twoFactor` to the three-value union now has to handle `null`.
12
+
13
+ ### Also in 4.6.0
14
+
15
+ 4.6.0 moved the bundled `@fleetless/contracts` from 6.2.0 to 12.0.0 and named only `twoFactor`. For code using this SDK, the jump also brought:
16
+
17
+ - **`FleetlessErrorCode` gains eight codes through `ErrorCode`:** `operator_verified_stopped`, `job_state_conflict`, `billing_unavailable`, `payment_provider_unavailable`, `history_migrating`, `billing_documents_unavailable`, `support_read_only` and `support_forbidden`. Only `operator_verified_stopped` reaches an app through this SDK: it is the `error.code` of a final `lost` job that an org Owner released after verifying that the robot is physically stopped. The other seven refuse org billing, slug renames, held-job recovery and console support sessions; an app user's session or a server key does not receive them. An exhaustive `switch` over `ErrorCode` gains the cases.
18
+ - **`ClientRobotListItem.bridge_state`**, as `robots.list()` resolves it, gains an optional, nullable `health_reason`; its one value, `'job_query_unanswered'`, means the cloud saw the bridge leave a job query unanswered. Older clouds omit it.
19
+ - **`job_lost` is defined more precisely:** a final `lost` job whose terminal goal result could not be recovered within the bounded wait, or a loss with no more specific cause; `error.message` says which. `action_server_lost` and `job_unknown_to_bridge` keep their meaning. No code or shape changed.
20
+ - Doc comments name the MCP actions `robots.list` and `robots.describe` instead of the former tool names. No shape changed.
21
+
22
+ Nothing else this SDK re-exports or parses at runtime changed.
23
+
7
24
  ## [4.6.0] — 2026-11-03
8
25
 
9
26
  ### Added
package/README.md CHANGED
@@ -96,6 +96,8 @@ Before drawing your app's sign-in screen, read its public policy:
96
96
  ```ts
97
97
  const { password, emailCode, twoFactor } = await client.auth.signInMethods()
98
98
  // twoFactor is 'off', 'optional' or 'required'; it is app policy, not enrollment.
99
+ // It is null when the cloud sends no policy the SDK recognises (an older cloud):
100
+ // treat that as a failed read and offer no two-factor action, never as 'off'.
99
101
  // listProviders() separately returns only federated sign-in buttons.
100
102
  ```
101
103
 
package/dist/index.cjs CHANGED
@@ -11354,7 +11354,7 @@ function createSessionAuth(http, tokenStore, appIdentifier2) {
11354
11354
  async signInMethods() {
11355
11355
  const query = new URLSearchParams({ app_identifier: appIdentifier2 });
11356
11356
  const response = await http.request(`/api/client/providers?${query.toString()}`, { skipAuth: true });
11357
- return { password: response.sign_in_methods.password, emailCode: response.sign_in_methods.email_code, twoFactor: response.two_factor };
11357
+ return signInMethodsFrom(response);
11358
11358
  },
11359
11359
  async beginOidcLogin(input) {
11360
11360
  const state = generateState();
@@ -11406,6 +11406,14 @@ function createSessionAuth(http, tokenStore, appIdentifier2) {
11406
11406
  }
11407
11407
  };
11408
11408
  }
11409
+ function signInMethodsFrom(response) {
11410
+ const policy = appTwoFactorPolicy.safeParse(response.two_factor);
11411
+ return {
11412
+ password: response.sign_in_methods.password,
11413
+ emailCode: response.sign_in_methods.email_code,
11414
+ twoFactor: policy.success ? policy.data : null
11415
+ };
11416
+ }
11409
11417
  async function decide(http, id, decision) {
11410
11418
  const response = await http.request(
11411
11419
  `/api/client/mcp/interactions/${pathSegment(id)}/${decision}`,
@@ -11492,7 +11500,7 @@ function createServerKeyAuth(http, appIdentifier2, option = "serverKey") {
11492
11500
  async signInMethods() {
11493
11501
  const query = new URLSearchParams({ app_identifier: appIdentifier2 });
11494
11502
  const response = await http.request(`/api/client/providers?${query.toString()}`, { skipAuth: true });
11495
- return { password: response.sign_in_methods.password, emailCode: response.sign_in_methods.email_code, twoFactor: response.two_factor };
11503
+ return signInMethodsFrom(response);
11496
11504
  },
11497
11505
  async beginOidcLogin() {
11498
11506
  serverKeyRefusal("beginOidcLogin", "a federated sign-in is inherently an app user's browser flow");
package/dist/index.d.cts CHANGED
@@ -1713,8 +1713,18 @@ interface SignInMethods {
1713
1713
  password: boolean;
1714
1714
  /** Whether `requestLoginCode`/`verifyLoginCode` is on for this app. */
1715
1715
  emailCode: boolean;
1716
- /** The app policy, not the signed-in person's enrollment state. */
1717
- twoFactor: 'off' | 'optional' | 'required';
1716
+ /**
1717
+ * The app's two-factor policy — `'off'`, `'optional'` or `'required'` —
1718
+ * not the signed-in person's enrollment state.
1719
+ *
1720
+ * **`null` when the cloud answered no policy this SDK recognises**: a cloud
1721
+ * that predates the field, or a value outside those three. Treat `null` as
1722
+ * a failed policy read — offer no two-factor action, let the person retry —
1723
+ * and never as `'off'`: the SDK does not guess a policy, and the cloud
1724
+ * still enforces the real one at sign-in. `password` and `emailCode` are
1725
+ * read either way, so a login screen keeps working against such a cloud.
1726
+ */
1727
+ twoFactor: 'off' | 'optional' | 'required' | null;
1718
1728
  }
1719
1729
  /** One sign-in button on the app's own login screen, as `listProviders()` lists it. */
1720
1730
  interface ProviderButton {
@@ -2027,6 +2037,10 @@ interface AuthApi {
2027
2037
  * (`GET /api/client/providers`) — each call is its own request, picking a
2028
2038
  * different field out of the same response; call both if your login
2029
2039
  * screen needs both.
2040
+ *
2041
+ * `twoFactor` is `null` when the cloud's answer carries no policy this SDK
2042
+ * recognises (an older cloud, or an unknown value) — a failed policy read,
2043
+ * not `'off'`. `password` and `emailCode` are answered either way.
2030
2044
  */
2031
2045
  signInMethods(): Promise<SignInMethods>;
2032
2046
  /**
package/dist/index.d.ts CHANGED
@@ -1713,8 +1713,18 @@ interface SignInMethods {
1713
1713
  password: boolean;
1714
1714
  /** Whether `requestLoginCode`/`verifyLoginCode` is on for this app. */
1715
1715
  emailCode: boolean;
1716
- /** The app policy, not the signed-in person's enrollment state. */
1717
- twoFactor: 'off' | 'optional' | 'required';
1716
+ /**
1717
+ * The app's two-factor policy — `'off'`, `'optional'` or `'required'` —
1718
+ * not the signed-in person's enrollment state.
1719
+ *
1720
+ * **`null` when the cloud answered no policy this SDK recognises**: a cloud
1721
+ * that predates the field, or a value outside those three. Treat `null` as
1722
+ * a failed policy read — offer no two-factor action, let the person retry —
1723
+ * and never as `'off'`: the SDK does not guess a policy, and the cloud
1724
+ * still enforces the real one at sign-in. `password` and `emailCode` are
1725
+ * read either way, so a login screen keeps working against such a cloud.
1726
+ */
1727
+ twoFactor: 'off' | 'optional' | 'required' | null;
1718
1728
  }
1719
1729
  /** One sign-in button on the app's own login screen, as `listProviders()` lists it. */
1720
1730
  interface ProviderButton {
@@ -2027,6 +2037,10 @@ interface AuthApi {
2027
2037
  * (`GET /api/client/providers`) — each call is its own request, picking a
2028
2038
  * different field out of the same response; call both if your login
2029
2039
  * screen needs both.
2040
+ *
2041
+ * `twoFactor` is `null` when the cloud's answer carries no policy this SDK
2042
+ * recognises (an older cloud, or an unknown value) — a failed policy read,
2043
+ * not `'off'`. `password` and `emailCode` are answered either way.
2030
2044
  */
2031
2045
  signInMethods(): Promise<SignInMethods>;
2032
2046
  /**
package/dist/index.js CHANGED
@@ -11322,7 +11322,7 @@ function createSessionAuth(http, tokenStore, appIdentifier2) {
11322
11322
  async signInMethods() {
11323
11323
  const query = new URLSearchParams({ app_identifier: appIdentifier2 });
11324
11324
  const response = await http.request(`/api/client/providers?${query.toString()}`, { skipAuth: true });
11325
- return { password: response.sign_in_methods.password, emailCode: response.sign_in_methods.email_code, twoFactor: response.two_factor };
11325
+ return signInMethodsFrom(response);
11326
11326
  },
11327
11327
  async beginOidcLogin(input) {
11328
11328
  const state = generateState();
@@ -11374,6 +11374,14 @@ function createSessionAuth(http, tokenStore, appIdentifier2) {
11374
11374
  }
11375
11375
  };
11376
11376
  }
11377
+ function signInMethodsFrom(response) {
11378
+ const policy = appTwoFactorPolicy.safeParse(response.two_factor);
11379
+ return {
11380
+ password: response.sign_in_methods.password,
11381
+ emailCode: response.sign_in_methods.email_code,
11382
+ twoFactor: policy.success ? policy.data : null
11383
+ };
11384
+ }
11377
11385
  async function decide(http, id, decision) {
11378
11386
  const response = await http.request(
11379
11387
  `/api/client/mcp/interactions/${pathSegment(id)}/${decision}`,
@@ -11460,7 +11468,7 @@ function createServerKeyAuth(http, appIdentifier2, option = "serverKey") {
11460
11468
  async signInMethods() {
11461
11469
  const query = new URLSearchParams({ app_identifier: appIdentifier2 });
11462
11470
  const response = await http.request(`/api/client/providers?${query.toString()}`, { skipAuth: true });
11463
- return { password: response.sign_in_methods.password, emailCode: response.sign_in_methods.email_code, twoFactor: response.two_factor };
11471
+ return signInMethodsFrom(response);
11464
11472
  },
11465
11473
  async beginOidcLogin() {
11466
11474
  serverKeyRefusal("beginOidcLogin", "a federated sign-in is inherently an app user's browser flow");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetless/sdk",
3
- "version": "4.6.0",
3
+ "version": "4.6.1",
4
4
  "description": "The official TypeScript SDK for Fleetless client apps — a ROS 2 robot as a REST and realtime API, cameras, jobs, and the app's own user accounts, federated sign-in and MCP consent.",
5
5
  "license": "MIT",
6
6
  "author": {