@opengeni/sdk 0.29.0 → 0.32.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.
@@ -0,0 +1,71 @@
1
+ import type { DesktopStreamCapability, StreamUrlRotatedPayload } from "./types";
2
+ /**
3
+ * Translate the negotiated desktop capability into the WebSocket URL the noVNC
4
+ * RFB client connects to. The scoped provider token is ALREADY embedded in the
5
+ * minted `url` (Modal tunnel host, Blaxel `bl_preview_token`, Daytona signed
6
+ * preview) by `session.resolveExposedPort(6080)` — we do NOT append `cap.token`
7
+ * as a query param (that double-auth was an adversarial-review bug: the box runs
8
+ * `-nopw` in v1, so the RFB password is meaningless and the real auth is the
9
+ * tunnel token in the host). We only normalize the scheme to `ws`/`wss` and, when
10
+ * the minted URL points at a `vnc.html` viewer page, rewrite it to the
11
+ * websockify socket path noVNC actually dials.
12
+ */
13
+ export declare function desktopSocketUrl(cap: Pick<DesktopStreamCapability, "url">): string;
14
+ /**
15
+ * The minimal RFB surface the React component drives. Lets tests (and 3rd
16
+ * parties swapping noVNC for a WebRTC client in v3) provide a fake without the
17
+ * DOM. Matches `@novnc/novnc`'s RFB constructor + lifecycle.
18
+ */
19
+ export interface DesktopRfbLike {
20
+ viewOnly: boolean;
21
+ scaleViewport: boolean;
22
+ /**
23
+ * 1:1 viewport clipping. We always drive this FALSE: with clipping on, noVNC
24
+ * paints the framebuffer pixel-for-pixel and scrolls/crops to the container
25
+ * (the "zoomed in" look). FALSE lets `scaleViewport` shrink the 1280x800 frame
26
+ * to fit the panel (aspect-preserved). Declared so the hook can pin it instead
27
+ * of relying on noVNC's default — `scaleViewport=true` forces clip off
28
+ * internally, but a stale/partial state on reconnect could leave it on.
29
+ */
30
+ clipViewport: boolean;
31
+ addEventListener(type: "connect" | "disconnect" | "securityfailure", cb: (e?: unknown) => void): void;
32
+ removeEventListener?: (type: "connect" | "disconnect" | "securityfailure", cb: (e?: unknown) => void) => void;
33
+ disconnect(): void;
34
+ }
35
+ export type DesktopRfbFactory = (target: HTMLElement, url: string, opts: {
36
+ credentials?: {
37
+ password?: string | undefined;
38
+ } | undefined;
39
+ }) => DesktopRfbLike;
40
+ export type DesktopConnectionState = "idle" | "negotiating" | "connecting" | "connected" | "rotating" | "reconnecting" | "error" | "ended";
41
+ export type DesktopStreamEvent = {
42
+ type: "negotiated";
43
+ } | {
44
+ type: "connected";
45
+ } | {
46
+ type: "disconnected";
47
+ } | {
48
+ type: "rotate";
49
+ } | {
50
+ type: "fail";
51
+ } | {
52
+ type: "abort";
53
+ };
54
+ /**
55
+ * Pure reducer for the desktop connection lifecycle. The component owns the RFB
56
+ * object + DOM; this owns the transitions so they are unit-testable. Mirrors the
57
+ * Channel-A stream reducer discipline.
58
+ */
59
+ export declare function nextDesktopState(current: DesktopConnectionState, ev: DesktopStreamEvent): DesktopConnectionState;
60
+ export type DesktopStreamCapabilityLike = {
61
+ url: string | null;
62
+ token: string | null;
63
+ expiresAt: string | null;
64
+ };
65
+ /**
66
+ * Apply a `stream.url.rotated` event onto a desktop capability, fencing on
67
+ * leaseEpoch (split-brain). A rotation minted under an epoch the client has
68
+ * already advanced PAST is from a superseded owner and is dropped (returns
69
+ * null); otherwise the fresh url/token/expiresAt are folded in.
70
+ */
71
+ export declare function applyUrlRotation<T extends DesktopStreamCapabilityLike>(cap: T, payload: StreamUrlRotatedPayload, knownEpoch: number): T | null;
@@ -0,0 +1,39 @@
1
+ /** Error for a non-2xx OpenGeni API response. */
2
+ export declare class OpenGeniApiError extends Error {
3
+ readonly status: number;
4
+ readonly code: string | undefined;
5
+ readonly retryable: boolean;
6
+ readonly correlationId: string | undefined;
7
+ /** True only when an uncontrolled transport failed after a mutation may have been accepted. */
8
+ readonly outcomeUnknown: boolean;
9
+ readonly body: string;
10
+ constructor(status: number, body: string, options?: {
11
+ code?: string | undefined;
12
+ retryable?: boolean | undefined;
13
+ correlationId?: string | undefined;
14
+ outcomeUnknown?: boolean | undefined;
15
+ displayMessage?: string | undefined;
16
+ mutation?: boolean | undefined;
17
+ });
18
+ }
19
+ /** A short-lived session-list snapshot cursor can no longer be continued. */
20
+ export declare class OpenGeniSessionListCursorError extends OpenGeniApiError {
21
+ }
22
+ /** The browser bundle and API disagree about their state-changing wire contract. */
23
+ export declare class OpenGeniApiContractMismatchError extends Error {
24
+ readonly expected: string;
25
+ readonly actual: string;
26
+ constructor(expected: string, actual: string);
27
+ }
28
+ /** Error for an unrecoverable event-stream condition (not a transient drop). */
29
+ export declare class OpenGeniStreamError extends Error {
30
+ constructor(message: string);
31
+ }
32
+ export declare function isAbortError(error: unknown): boolean;
33
+ /**
34
+ * Transient conditions worth a reconnect: network-level failures (`fetch`
35
+ * rejects with `TypeError`) and HTTP statuses that signal a temporary server
36
+ * or contention condition. Auth/validation failures (401/403/404/...) are
37
+ * permanent and surface to the caller instead.
38
+ */
39
+ export declare function isRetryableStreamError(error: unknown): boolean;