@fleetless/sdk 3.1.1 → 4.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/CHANGELOG.md +15 -1
- package/README.md +4 -4
- package/dist/index.cjs +359 -202
- package/dist/index.d.cts +68 -11
- package/dist/index.d.ts +68 -11
- package/dist/index.js +359 -202
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -352,8 +352,8 @@ declare const historySamplesResponse: z.ZodObject<{
|
|
|
352
352
|
}, z.core.$strip>>;
|
|
353
353
|
truncated: z.ZodBoolean;
|
|
354
354
|
truncated_by: z.ZodNullable<z.ZodEnum<{
|
|
355
|
-
limit: "limit";
|
|
356
355
|
bytes: "bytes";
|
|
356
|
+
limit: "limit";
|
|
357
357
|
}>>;
|
|
358
358
|
}, z.core.$strip>;
|
|
359
359
|
type HistorySamplesResponse = z.infer<typeof historySamplesResponse>;
|
|
@@ -577,6 +577,7 @@ declare const clientRobotListItem: z.ZodObject<{
|
|
|
577
577
|
bridge_state: z.ZodObject<{
|
|
578
578
|
online: z.ZodBoolean;
|
|
579
579
|
latency_ms: z.ZodNullable<z.ZodNumber>;
|
|
580
|
+
low_bandwidth: z.ZodBoolean;
|
|
580
581
|
}, z.core.$strip>;
|
|
581
582
|
published_version: z.ZodNullable<z.ZodNumber>;
|
|
582
583
|
id: z.ZodUUID;
|
|
@@ -593,7 +594,6 @@ declare const asset: z.ZodObject<{
|
|
|
593
594
|
urdf: "urdf";
|
|
594
595
|
mesh: "mesh";
|
|
595
596
|
texture: "texture";
|
|
596
|
-
other: "other";
|
|
597
597
|
}>;
|
|
598
598
|
name: z.ZodString;
|
|
599
599
|
media_type: z.ZodString;
|
|
@@ -649,14 +649,16 @@ declare const assetSyncStatus: z.ZodObject<{
|
|
|
649
649
|
unresolvable: "unresolvable";
|
|
650
650
|
upload_failed: "upload_failed";
|
|
651
651
|
refused: "refused";
|
|
652
|
-
too_large: "too_large";
|
|
653
652
|
}>;
|
|
654
653
|
details: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
655
|
-
|
|
654
|
+
store_bytes: z.ZodNumber;
|
|
655
|
+
used_bytes: z.ZodNumber;
|
|
656
656
|
size_bytes: z.ZodNumber;
|
|
657
657
|
}, z.core.$strip>>>;
|
|
658
658
|
}, z.core.$strip>>;
|
|
659
659
|
reason: z.ZodNullable<z.ZodString>;
|
|
660
|
+
stored: z.ZodNullable<z.ZodNumber>;
|
|
661
|
+
announced: z.ZodNumber;
|
|
660
662
|
started_at: z.ZodISODateTime;
|
|
661
663
|
updated_at: z.ZodISODateTime;
|
|
662
664
|
}, z.core.$strip>;
|
|
@@ -669,7 +671,6 @@ declare const assetListResponse: z.ZodObject<{
|
|
|
669
671
|
urdf: "urdf";
|
|
670
672
|
mesh: "mesh";
|
|
671
673
|
texture: "texture";
|
|
672
|
-
other: "other";
|
|
673
674
|
}>;
|
|
674
675
|
name: z.ZodString;
|
|
675
676
|
media_type: z.ZodString;
|
|
@@ -693,14 +694,16 @@ declare const assetListResponse: z.ZodObject<{
|
|
|
693
694
|
unresolvable: "unresolvable";
|
|
694
695
|
upload_failed: "upload_failed";
|
|
695
696
|
refused: "refused";
|
|
696
|
-
too_large: "too_large";
|
|
697
697
|
}>;
|
|
698
698
|
details: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
699
|
-
|
|
699
|
+
store_bytes: z.ZodNumber;
|
|
700
|
+
used_bytes: z.ZodNumber;
|
|
700
701
|
size_bytes: z.ZodNumber;
|
|
701
702
|
}, z.core.$strip>>>;
|
|
702
703
|
}, z.core.$strip>>;
|
|
703
704
|
reason: z.ZodNullable<z.ZodString>;
|
|
705
|
+
stored: z.ZodNullable<z.ZodNumber>;
|
|
706
|
+
announced: z.ZodNumber;
|
|
704
707
|
started_at: z.ZodISODateTime;
|
|
705
708
|
updated_at: z.ZodISODateTime;
|
|
706
709
|
}, z.core.$strip>>;
|
|
@@ -716,6 +719,11 @@ declare const assetListResponse: z.ZodObject<{
|
|
|
716
719
|
}, z.core.$strip>>;
|
|
717
720
|
}, z.core.$strip>;
|
|
718
721
|
urdf_available: z.ZodNullable<z.ZodBoolean>;
|
|
722
|
+
store: z.ZodObject<{
|
|
723
|
+
bytes: z.ZodNumber;
|
|
724
|
+
used_bytes: z.ZodNumber;
|
|
725
|
+
}, z.core.$strip>;
|
|
726
|
+
joint_state_slug: z.ZodNullable<z.ZodString>;
|
|
719
727
|
}, z.core.$strip>;
|
|
720
728
|
type AssetListResponse = z.infer<typeof assetListResponse>;
|
|
721
729
|
|
|
@@ -758,7 +766,7 @@ type ParameterInvalidDetails = z.infer<typeof parameterInvalidDetails>;
|
|
|
758
766
|
* list is the shared vocabulary, not a closed set, so a new refusal never
|
|
759
767
|
* needs a contracts release before it can be reported honestly.
|
|
760
768
|
*/
|
|
761
|
-
declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "job_lost", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "
|
|
769
|
+
declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "job_lost", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "dynamic_registration_disabled", "client_limit_reached", "idp_unavailable", "mcp_disabled", "tool_not_available", "capability_required", "last_owner", "target_state_conflict", "signup_closed", "draft_not_a_document", "internal_error", "not_cancellable", "unsupported_media_type", "wrong_browser", "invalid_yaml", "unstorable_yaml", "registration_closed", "domain_not_allowed", "email_unverified", "origin_not_allowed", "template_invalid", "provider_disabled", "provider_misconfigured", "invalid_redirect_uri", "interaction_expired"];
|
|
762
770
|
type ErrorCode = (typeof ERROR_CODES)[number];
|
|
763
771
|
|
|
764
772
|
/**
|
|
@@ -912,6 +920,34 @@ declare class FleetlessError extends Error {
|
|
|
912
920
|
constructor(code: FleetlessErrorCode, message: string, options?: FleetlessErrorOptions);
|
|
913
921
|
}
|
|
914
922
|
|
|
923
|
+
/**
|
|
924
|
+
* Supplies the `Authorization` header value for a request, and knows what to
|
|
925
|
+
* do when the server says the token has expired. `HttpClient` is agnostic to
|
|
926
|
+
* *what* is authenticating it — an end-user session with silent refresh, or
|
|
927
|
+
* a static server key — so both can share one request path.
|
|
928
|
+
*/
|
|
929
|
+
interface CredentialSource {
|
|
930
|
+
/**
|
|
931
|
+
* The current raw bearer credential — a JWT or a server key (`flk_...`) —
|
|
932
|
+
* or null if not authenticated. Raw, not `Bearer <token>`: REST forms the
|
|
933
|
+
* `Authorization` header from it, and the realtime auth frame
|
|
934
|
+
* carries the very same value unprefixed, so there is exactly one place
|
|
935
|
+
* that knows what "the token" currently is.
|
|
936
|
+
*/
|
|
937
|
+
token(): Promise<string | null>;
|
|
938
|
+
/**
|
|
939
|
+
* Called once when a request comes back `token_expired`. Three outcomes:
|
|
940
|
+
* - resolves `true` — a fresh credential is ready, retry the request;
|
|
941
|
+
* - resolves `false` — nothing to do (e.g. a server key, which cannot be
|
|
942
|
+
* refreshed at all), propagate the original `token_expired`;
|
|
943
|
+
* - throws a `FleetlessError` — refreshing itself failed for a specific,
|
|
944
|
+
* more useful reason (e.g. `token_revoked`, a reused refresh token);
|
|
945
|
+
* that error propagates instead of the original `token_expired`, so the
|
|
946
|
+
* caller learns what actually happened, not just that a retry was tried.
|
|
947
|
+
*/
|
|
948
|
+
handleExpired(): Promise<boolean>;
|
|
949
|
+
}
|
|
950
|
+
|
|
915
951
|
/**
|
|
916
952
|
* The options every realtime command accepts — `actions.cancel` and
|
|
917
953
|
* `publishers.publish` take exactly these; `InvokeOptions` extends them for
|
|
@@ -2253,6 +2289,25 @@ interface FleetlessClientOptions {
|
|
|
2253
2289
|
* with a server key never calls `auth.login`/`auth.logout`.
|
|
2254
2290
|
*/
|
|
2255
2291
|
serverKey?: string;
|
|
2292
|
+
/**
|
|
2293
|
+
* **A credential this client does not own.** The caller answers both
|
|
2294
|
+
* questions a bearer raises: what the token is right now (`token()`), and
|
|
2295
|
+
* what to do when the server says it expired (`handleExpired()`).
|
|
2296
|
+
*
|
|
2297
|
+
* For an embedder that already holds a session and refreshes it itself —
|
|
2298
|
+
* the Fleetless console is the case this exists for. Without it such a
|
|
2299
|
+
* caller had to impersonate a `TokenStore`, and a cloud-side
|
|
2300
|
+
* `token_expired` arriving while its own clock still read live posted one
|
|
2301
|
+
* empty refresh whose `validation_error` had to be translated back into a
|
|
2302
|
+
* session message. A source that answers `handleExpired: false` never
|
|
2303
|
+
* builds a refresh request at all.
|
|
2304
|
+
*
|
|
2305
|
+
* Mutually exclusive with `tokenStore` and `serverKey`, which each own a
|
|
2306
|
+
* credential of their own; a client acts as exactly one identity.
|
|
2307
|
+
* `auth.login`/`auth.logout` refuse here for the same reason they refuse
|
|
2308
|
+
* on a server key: there is no session for this client to start or end.
|
|
2309
|
+
*/
|
|
2310
|
+
credentials?: CredentialSource;
|
|
2256
2311
|
/** Injectable for tests, or a non-global `fetch` implementation. */
|
|
2257
2312
|
fetch?: typeof fetch;
|
|
2258
2313
|
/** Injectable for tests, or a non-global `WebSocket` implementation. */
|
|
@@ -2322,12 +2377,14 @@ interface FleetlessClient {
|
|
|
2322
2377
|
* Builds a client for one app. Pass `tokenStore` (or nothing — the default
|
|
2323
2378
|
* keeps the session in memory) for an app-user client that signs in with
|
|
2324
2379
|
* `auth.login` or a federated provider; pass `serverKey` for a server-side
|
|
2325
|
-
* caller that never holds a user session
|
|
2326
|
-
*
|
|
2380
|
+
* caller that never holds a user session; pass `credentials` when the
|
|
2381
|
+
* embedder already holds the bearer and refreshes it itself. Passing more
|
|
2382
|
+
* than one throws, because each is a different identity and a client acts
|
|
2383
|
+
* as exactly one.
|
|
2327
2384
|
*
|
|
2328
2385
|
* Nothing is fetched here: the realtime channel opens on the first
|
|
2329
2386
|
* subscription and closes on `close()` or `auth.logout()`.
|
|
2330
2387
|
*/
|
|
2331
2388
|
declare function createClient(options: FleetlessClientOptions): FleetlessClient;
|
|
2332
2389
|
|
|
2333
|
-
export { type AcceptInvitationOptions, type ActionsApi, type Asset, type AssetBytes, type AssetListResponse, type AssetsApi, type AuthApi, type BeginOidcLoginOptions, type BusyDetails, type CameraDescriptor, type CameraLiveSession, type CameraSnapshot, type CameraSnapshotMeta, type CamerasApi, type ClientIdentity, type ClientMcpInteraction, type ClientOidcErrorCode, type ClientRobotListItem, type CompleteOidcLoginOptions, type CreateMeshLoaderOptions, type DatapointEvent, type DatapointSubscription, type DatapointSubscriptionHandlers, type DatapointValue, type DatapointsApi, type FleetlessClient, type FleetlessClientConfig, type FleetlessClientOptions, FleetlessError, type FleetlessErrorCode, type FleetlessErrorOptions, type HistoryAggregation, type HistoryBucketsResponse, type HistoryOptions, type HistorySamplesResponse, InMemoryTokenStore, type InvokeOptions, type Job, type JobEvent, type JobHistoryOptions, type JobRun, type JobRunListResponse, type JobState, type JobSubscription, type JobSubscriptionHandlers, type JobsApi, type McpCapabilities, type McpConsentGrant, type McpExposure, type McpInteractionDecision, type McpRobotDatasheet, type MeshLoaderDelegate, type OidcLoginRequest, type ParameterInvalidDetails, type ParameterViolation, type PrepareUrdfSceneOptions, type ProviderButton, type PublishersApi, type RateLimitDetails, type RegisterOptions, type RobotsApi, SDK_ERROR_CODES, type SdkErrorCode, type SendCommandOptions, type ServicesApi, type StoredSession, type TokenStore, type UrdfCompleteness, type UrdfSceneManager, type UrdfSceneResources, createClient, parameterInvalidDetails };
|
|
2390
|
+
export { type AcceptInvitationOptions, type ActionsApi, type Asset, type AssetBytes, type AssetListResponse, type AssetsApi, type AuthApi, type BeginOidcLoginOptions, type BusyDetails, type CameraDescriptor, type CameraLiveSession, type CameraSnapshot, type CameraSnapshotMeta, type CamerasApi, type ClientIdentity, type ClientMcpInteraction, type ClientOidcErrorCode, type ClientRobotListItem, type CompleteOidcLoginOptions, type CreateMeshLoaderOptions, type CredentialSource, type DatapointEvent, type DatapointSubscription, type DatapointSubscriptionHandlers, type DatapointValue, type DatapointsApi, type FleetlessClient, type FleetlessClientConfig, type FleetlessClientOptions, FleetlessError, type FleetlessErrorCode, type FleetlessErrorOptions, type HistoryAggregation, type HistoryBucketsResponse, type HistoryOptions, type HistorySamplesResponse, InMemoryTokenStore, type InvokeOptions, type Job, type JobEvent, type JobHistoryOptions, type JobRun, type JobRunListResponse, type JobState, type JobSubscription, type JobSubscriptionHandlers, type JobsApi, type McpCapabilities, type McpConsentGrant, type McpExposure, type McpInteractionDecision, type McpRobotDatasheet, type MeshLoaderDelegate, type OidcLoginRequest, type ParameterInvalidDetails, type ParameterViolation, type PrepareUrdfSceneOptions, type ProviderButton, type PublishersApi, type RateLimitDetails, type RegisterOptions, type RobotsApi, SDK_ERROR_CODES, type SdkErrorCode, type SendCommandOptions, type ServicesApi, type StoredSession, type TokenStore, type UrdfCompleteness, type UrdfSceneManager, type UrdfSceneResources, createClient, parameterInvalidDetails };
|
package/dist/index.d.ts
CHANGED
|
@@ -352,8 +352,8 @@ declare const historySamplesResponse: z.ZodObject<{
|
|
|
352
352
|
}, z.core.$strip>>;
|
|
353
353
|
truncated: z.ZodBoolean;
|
|
354
354
|
truncated_by: z.ZodNullable<z.ZodEnum<{
|
|
355
|
-
limit: "limit";
|
|
356
355
|
bytes: "bytes";
|
|
356
|
+
limit: "limit";
|
|
357
357
|
}>>;
|
|
358
358
|
}, z.core.$strip>;
|
|
359
359
|
type HistorySamplesResponse = z.infer<typeof historySamplesResponse>;
|
|
@@ -577,6 +577,7 @@ declare const clientRobotListItem: z.ZodObject<{
|
|
|
577
577
|
bridge_state: z.ZodObject<{
|
|
578
578
|
online: z.ZodBoolean;
|
|
579
579
|
latency_ms: z.ZodNullable<z.ZodNumber>;
|
|
580
|
+
low_bandwidth: z.ZodBoolean;
|
|
580
581
|
}, z.core.$strip>;
|
|
581
582
|
published_version: z.ZodNullable<z.ZodNumber>;
|
|
582
583
|
id: z.ZodUUID;
|
|
@@ -593,7 +594,6 @@ declare const asset: z.ZodObject<{
|
|
|
593
594
|
urdf: "urdf";
|
|
594
595
|
mesh: "mesh";
|
|
595
596
|
texture: "texture";
|
|
596
|
-
other: "other";
|
|
597
597
|
}>;
|
|
598
598
|
name: z.ZodString;
|
|
599
599
|
media_type: z.ZodString;
|
|
@@ -649,14 +649,16 @@ declare const assetSyncStatus: z.ZodObject<{
|
|
|
649
649
|
unresolvable: "unresolvable";
|
|
650
650
|
upload_failed: "upload_failed";
|
|
651
651
|
refused: "refused";
|
|
652
|
-
too_large: "too_large";
|
|
653
652
|
}>;
|
|
654
653
|
details: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
655
|
-
|
|
654
|
+
store_bytes: z.ZodNumber;
|
|
655
|
+
used_bytes: z.ZodNumber;
|
|
656
656
|
size_bytes: z.ZodNumber;
|
|
657
657
|
}, z.core.$strip>>>;
|
|
658
658
|
}, z.core.$strip>>;
|
|
659
659
|
reason: z.ZodNullable<z.ZodString>;
|
|
660
|
+
stored: z.ZodNullable<z.ZodNumber>;
|
|
661
|
+
announced: z.ZodNumber;
|
|
660
662
|
started_at: z.ZodISODateTime;
|
|
661
663
|
updated_at: z.ZodISODateTime;
|
|
662
664
|
}, z.core.$strip>;
|
|
@@ -669,7 +671,6 @@ declare const assetListResponse: z.ZodObject<{
|
|
|
669
671
|
urdf: "urdf";
|
|
670
672
|
mesh: "mesh";
|
|
671
673
|
texture: "texture";
|
|
672
|
-
other: "other";
|
|
673
674
|
}>;
|
|
674
675
|
name: z.ZodString;
|
|
675
676
|
media_type: z.ZodString;
|
|
@@ -693,14 +694,16 @@ declare const assetListResponse: z.ZodObject<{
|
|
|
693
694
|
unresolvable: "unresolvable";
|
|
694
695
|
upload_failed: "upload_failed";
|
|
695
696
|
refused: "refused";
|
|
696
|
-
too_large: "too_large";
|
|
697
697
|
}>;
|
|
698
698
|
details: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
699
|
-
|
|
699
|
+
store_bytes: z.ZodNumber;
|
|
700
|
+
used_bytes: z.ZodNumber;
|
|
700
701
|
size_bytes: z.ZodNumber;
|
|
701
702
|
}, z.core.$strip>>>;
|
|
702
703
|
}, z.core.$strip>>;
|
|
703
704
|
reason: z.ZodNullable<z.ZodString>;
|
|
705
|
+
stored: z.ZodNullable<z.ZodNumber>;
|
|
706
|
+
announced: z.ZodNumber;
|
|
704
707
|
started_at: z.ZodISODateTime;
|
|
705
708
|
updated_at: z.ZodISODateTime;
|
|
706
709
|
}, z.core.$strip>>;
|
|
@@ -716,6 +719,11 @@ declare const assetListResponse: z.ZodObject<{
|
|
|
716
719
|
}, z.core.$strip>>;
|
|
717
720
|
}, z.core.$strip>;
|
|
718
721
|
urdf_available: z.ZodNullable<z.ZodBoolean>;
|
|
722
|
+
store: z.ZodObject<{
|
|
723
|
+
bytes: z.ZodNumber;
|
|
724
|
+
used_bytes: z.ZodNumber;
|
|
725
|
+
}, z.core.$strip>;
|
|
726
|
+
joint_state_slug: z.ZodNullable<z.ZodString>;
|
|
719
727
|
}, z.core.$strip>;
|
|
720
728
|
type AssetListResponse = z.infer<typeof assetListResponse>;
|
|
721
729
|
|
|
@@ -758,7 +766,7 @@ type ParameterInvalidDetails = z.infer<typeof parameterInvalidDetails>;
|
|
|
758
766
|
* list is the shared vocabulary, not a closed set, so a new refusal never
|
|
759
767
|
* needs a contracts release before it can be reported honestly.
|
|
760
768
|
*/
|
|
761
|
-
declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "job_lost", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "
|
|
769
|
+
declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "job_lost", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "dynamic_registration_disabled", "client_limit_reached", "idp_unavailable", "mcp_disabled", "tool_not_available", "capability_required", "last_owner", "target_state_conflict", "signup_closed", "draft_not_a_document", "internal_error", "not_cancellable", "unsupported_media_type", "wrong_browser", "invalid_yaml", "unstorable_yaml", "registration_closed", "domain_not_allowed", "email_unverified", "origin_not_allowed", "template_invalid", "provider_disabled", "provider_misconfigured", "invalid_redirect_uri", "interaction_expired"];
|
|
762
770
|
type ErrorCode = (typeof ERROR_CODES)[number];
|
|
763
771
|
|
|
764
772
|
/**
|
|
@@ -912,6 +920,34 @@ declare class FleetlessError extends Error {
|
|
|
912
920
|
constructor(code: FleetlessErrorCode, message: string, options?: FleetlessErrorOptions);
|
|
913
921
|
}
|
|
914
922
|
|
|
923
|
+
/**
|
|
924
|
+
* Supplies the `Authorization` header value for a request, and knows what to
|
|
925
|
+
* do when the server says the token has expired. `HttpClient` is agnostic to
|
|
926
|
+
* *what* is authenticating it — an end-user session with silent refresh, or
|
|
927
|
+
* a static server key — so both can share one request path.
|
|
928
|
+
*/
|
|
929
|
+
interface CredentialSource {
|
|
930
|
+
/**
|
|
931
|
+
* The current raw bearer credential — a JWT or a server key (`flk_...`) —
|
|
932
|
+
* or null if not authenticated. Raw, not `Bearer <token>`: REST forms the
|
|
933
|
+
* `Authorization` header from it, and the realtime auth frame
|
|
934
|
+
* carries the very same value unprefixed, so there is exactly one place
|
|
935
|
+
* that knows what "the token" currently is.
|
|
936
|
+
*/
|
|
937
|
+
token(): Promise<string | null>;
|
|
938
|
+
/**
|
|
939
|
+
* Called once when a request comes back `token_expired`. Three outcomes:
|
|
940
|
+
* - resolves `true` — a fresh credential is ready, retry the request;
|
|
941
|
+
* - resolves `false` — nothing to do (e.g. a server key, which cannot be
|
|
942
|
+
* refreshed at all), propagate the original `token_expired`;
|
|
943
|
+
* - throws a `FleetlessError` — refreshing itself failed for a specific,
|
|
944
|
+
* more useful reason (e.g. `token_revoked`, a reused refresh token);
|
|
945
|
+
* that error propagates instead of the original `token_expired`, so the
|
|
946
|
+
* caller learns what actually happened, not just that a retry was tried.
|
|
947
|
+
*/
|
|
948
|
+
handleExpired(): Promise<boolean>;
|
|
949
|
+
}
|
|
950
|
+
|
|
915
951
|
/**
|
|
916
952
|
* The options every realtime command accepts — `actions.cancel` and
|
|
917
953
|
* `publishers.publish` take exactly these; `InvokeOptions` extends them for
|
|
@@ -2253,6 +2289,25 @@ interface FleetlessClientOptions {
|
|
|
2253
2289
|
* with a server key never calls `auth.login`/`auth.logout`.
|
|
2254
2290
|
*/
|
|
2255
2291
|
serverKey?: string;
|
|
2292
|
+
/**
|
|
2293
|
+
* **A credential this client does not own.** The caller answers both
|
|
2294
|
+
* questions a bearer raises: what the token is right now (`token()`), and
|
|
2295
|
+
* what to do when the server says it expired (`handleExpired()`).
|
|
2296
|
+
*
|
|
2297
|
+
* For an embedder that already holds a session and refreshes it itself —
|
|
2298
|
+
* the Fleetless console is the case this exists for. Without it such a
|
|
2299
|
+
* caller had to impersonate a `TokenStore`, and a cloud-side
|
|
2300
|
+
* `token_expired` arriving while its own clock still read live posted one
|
|
2301
|
+
* empty refresh whose `validation_error` had to be translated back into a
|
|
2302
|
+
* session message. A source that answers `handleExpired: false` never
|
|
2303
|
+
* builds a refresh request at all.
|
|
2304
|
+
*
|
|
2305
|
+
* Mutually exclusive with `tokenStore` and `serverKey`, which each own a
|
|
2306
|
+
* credential of their own; a client acts as exactly one identity.
|
|
2307
|
+
* `auth.login`/`auth.logout` refuse here for the same reason they refuse
|
|
2308
|
+
* on a server key: there is no session for this client to start or end.
|
|
2309
|
+
*/
|
|
2310
|
+
credentials?: CredentialSource;
|
|
2256
2311
|
/** Injectable for tests, or a non-global `fetch` implementation. */
|
|
2257
2312
|
fetch?: typeof fetch;
|
|
2258
2313
|
/** Injectable for tests, or a non-global `WebSocket` implementation. */
|
|
@@ -2322,12 +2377,14 @@ interface FleetlessClient {
|
|
|
2322
2377
|
* Builds a client for one app. Pass `tokenStore` (or nothing — the default
|
|
2323
2378
|
* keeps the session in memory) for an app-user client that signs in with
|
|
2324
2379
|
* `auth.login` or a federated provider; pass `serverKey` for a server-side
|
|
2325
|
-
* caller that never holds a user session
|
|
2326
|
-
*
|
|
2380
|
+
* caller that never holds a user session; pass `credentials` when the
|
|
2381
|
+
* embedder already holds the bearer and refreshes it itself. Passing more
|
|
2382
|
+
* than one throws, because each is a different identity and a client acts
|
|
2383
|
+
* as exactly one.
|
|
2327
2384
|
*
|
|
2328
2385
|
* Nothing is fetched here: the realtime channel opens on the first
|
|
2329
2386
|
* subscription and closes on `close()` or `auth.logout()`.
|
|
2330
2387
|
*/
|
|
2331
2388
|
declare function createClient(options: FleetlessClientOptions): FleetlessClient;
|
|
2332
2389
|
|
|
2333
|
-
export { type AcceptInvitationOptions, type ActionsApi, type Asset, type AssetBytes, type AssetListResponse, type AssetsApi, type AuthApi, type BeginOidcLoginOptions, type BusyDetails, type CameraDescriptor, type CameraLiveSession, type CameraSnapshot, type CameraSnapshotMeta, type CamerasApi, type ClientIdentity, type ClientMcpInteraction, type ClientOidcErrorCode, type ClientRobotListItem, type CompleteOidcLoginOptions, type CreateMeshLoaderOptions, type DatapointEvent, type DatapointSubscription, type DatapointSubscriptionHandlers, type DatapointValue, type DatapointsApi, type FleetlessClient, type FleetlessClientConfig, type FleetlessClientOptions, FleetlessError, type FleetlessErrorCode, type FleetlessErrorOptions, type HistoryAggregation, type HistoryBucketsResponse, type HistoryOptions, type HistorySamplesResponse, InMemoryTokenStore, type InvokeOptions, type Job, type JobEvent, type JobHistoryOptions, type JobRun, type JobRunListResponse, type JobState, type JobSubscription, type JobSubscriptionHandlers, type JobsApi, type McpCapabilities, type McpConsentGrant, type McpExposure, type McpInteractionDecision, type McpRobotDatasheet, type MeshLoaderDelegate, type OidcLoginRequest, type ParameterInvalidDetails, type ParameterViolation, type PrepareUrdfSceneOptions, type ProviderButton, type PublishersApi, type RateLimitDetails, type RegisterOptions, type RobotsApi, SDK_ERROR_CODES, type SdkErrorCode, type SendCommandOptions, type ServicesApi, type StoredSession, type TokenStore, type UrdfCompleteness, type UrdfSceneManager, type UrdfSceneResources, createClient, parameterInvalidDetails };
|
|
2390
|
+
export { type AcceptInvitationOptions, type ActionsApi, type Asset, type AssetBytes, type AssetListResponse, type AssetsApi, type AuthApi, type BeginOidcLoginOptions, type BusyDetails, type CameraDescriptor, type CameraLiveSession, type CameraSnapshot, type CameraSnapshotMeta, type CamerasApi, type ClientIdentity, type ClientMcpInteraction, type ClientOidcErrorCode, type ClientRobotListItem, type CompleteOidcLoginOptions, type CreateMeshLoaderOptions, type CredentialSource, type DatapointEvent, type DatapointSubscription, type DatapointSubscriptionHandlers, type DatapointValue, type DatapointsApi, type FleetlessClient, type FleetlessClientConfig, type FleetlessClientOptions, FleetlessError, type FleetlessErrorCode, type FleetlessErrorOptions, type HistoryAggregation, type HistoryBucketsResponse, type HistoryOptions, type HistorySamplesResponse, InMemoryTokenStore, type InvokeOptions, type Job, type JobEvent, type JobHistoryOptions, type JobRun, type JobRunListResponse, type JobState, type JobSubscription, type JobSubscriptionHandlers, type JobsApi, type McpCapabilities, type McpConsentGrant, type McpExposure, type McpInteractionDecision, type McpRobotDatasheet, type MeshLoaderDelegate, type OidcLoginRequest, type ParameterInvalidDetails, type ParameterViolation, type PrepareUrdfSceneOptions, type ProviderButton, type PublishersApi, type RateLimitDetails, type RegisterOptions, type RobotsApi, SDK_ERROR_CODES, type SdkErrorCode, type SendCommandOptions, type ServicesApi, type StoredSession, type TokenStore, type UrdfCompleteness, type UrdfSceneManager, type UrdfSceneResources, createClient, parameterInvalidDetails };
|