@ikonai/sdk 1.0.44 → 1.0.46

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,4 @@
1
+ export { getLoginPromptState, setLoginPromptRequired, clearLoginPrompt, subscribe, setLoginPendingCall, consumeLoginPendingCall, PENDING_CALL_KEY } from './login-store';
2
+ export type { LoginPromptState, LoginPendingCall } from './login-store';
3
+ export { loginErrorInterceptor } from './login-error-interceptor';
4
+ export { reprovisionAfterLogin, consumeLoginHandoff } from './reprovision';
@@ -0,0 +1,13 @@
1
+ import { ErrorInterceptor } from '../functions/function-registry';
2
+ /**
3
+ * Error interceptor for the deferred-login flow.
4
+ *
5
+ * When a function call fails with code "login_required":
6
+ * 1. Stashes the pending call in sessionStorage (for replay after page reload).
7
+ * 2. Sets the login prompt state to required (triggers the login dialog).
8
+ * 3. Returns null so the original promise rejects normally with the error.
9
+ *
10
+ * After the user logs in, the page reloads against the new endpoint.
11
+ * The app's mount logic reads the pending call from sessionStorage and auto-invokes it.
12
+ */
13
+ export declare const loginErrorInterceptor: ErrorInterceptor;
@@ -0,0 +1,17 @@
1
+ export declare const PENDING_CALL_KEY = "ikon.login.pendingCall";
2
+ export interface LoginPromptState {
3
+ required: boolean;
4
+ reason: string | null;
5
+ }
6
+ export interface LoginPendingCall {
7
+ functionName: string;
8
+ args: unknown[];
9
+ }
10
+ type Listener = () => void;
11
+ export declare function getLoginPromptState(): LoginPromptState;
12
+ export declare function setLoginPromptRequired(reason: string | null): void;
13
+ export declare function clearLoginPrompt(): void;
14
+ export declare function subscribe(listener: Listener): () => void;
15
+ export declare function setLoginPendingCall(pending: LoginPendingCall): void;
16
+ export declare function consumeLoginPendingCall(): LoginPendingCall | null;
17
+ export {};
@@ -0,0 +1,22 @@
1
+ import { consumeLoginPendingCall } from './login-store';
2
+ /**
3
+ * Reprovision the client by reloading the page against a new server endpoint.
4
+ *
5
+ * The deferred-login handoff data (pending call, app route) lives in sessionStorage
6
+ * and survives the page reload. On reload, the app boots against the new endpoint
7
+ * (which now has a real user identity) and the app's mount logic can replay the
8
+ * pending call from sessionStorage via {@link consumeLoginHandoff}.
9
+ *
10
+ * This follows the same pattern as `ikon.client.logout` (clear + reload).
11
+ *
12
+ * @param connectUrl The full connect URL for the authenticated session.
13
+ */
14
+ export declare function reprovisionAfterLogin(connectUrl: string): void;
15
+ /**
16
+ * Check on app mount whether we just came back from a login reprovision.
17
+ * Returns the app route to restore and any pending call to replay.
18
+ */
19
+ export declare function consumeLoginHandoff(): {
20
+ appRoute: string | null;
21
+ pendingCall: ReturnType<typeof consumeLoginPendingCall>;
22
+ };
@@ -63,6 +63,12 @@ export interface IkonAudioCaptureRequest {
63
63
  bitrate?: number;
64
64
  targetIds?: number[];
65
65
  };
66
+ /**
67
+ * Optional correlation identifier embedded in the AudioStreamBegin payload. Used by the
68
+ * server-side CaptureButton to derive onCaptureStart/onCaptureStop from the audio path
69
+ * itself, eliminating any race between UI action dispatch and the audio stream.
70
+ */
71
+ correlationId?: string;
66
72
  onStopped?: () => void;
67
73
  /**
68
74
  * Called when capture encounters an error.
@@ -87,8 +93,15 @@ export interface IkonAudioCaptureHandle {
87
93
  readonly currentConstraints: MediaTrackConstraints;
88
94
  /** The current audio options (bitrate, etc.) applied to the capture. */
89
95
  readonly currentOptions: IkonAudioCaptureOptions;
90
- startSegment(): void;
91
- endSegment(): void;
96
+ /**
97
+ * Start a new logical recording segment. Optional correlationId identifies the originator
98
+ * (e.g., a CaptureButton instance) and is propagated to the server so the
99
+ * CaptureCorrelationBridge can fire onCaptureStart for the right registration. For the
100
+ * worker-encoded path the correlationId is fixed at startMic time and this argument is
101
+ * ignored; for the WebRTC path it is sent with each segment-start signal.
102
+ */
103
+ startSegment(correlationId?: string): void;
104
+ endSegment(correlationId?: string): void;
92
105
  stop(): Promise<void>;
93
106
  /** Update audio constraints on the active capture. Returns true if successful. */
94
107
  updateConstraints(constraints: MediaTrackConstraints): Promise<boolean>;
@@ -7,6 +7,13 @@ export interface IkonVideoCaptureRequest {
7
7
  options?: IkonVideoCaptureOptions;
8
8
  userGesture?: boolean;
9
9
  constraints?: MediaTrackConstraints;
10
+ /**
11
+ * Optional correlation identifier sent to the server-side WebRtcMediaBridge so the next
12
+ * VideoStreamBegin it emits for this sender carries it. Used by the CaptureCorrelationBridge
13
+ * to route onCaptureStart/onCaptureStop dispatches to the originating CaptureButton without
14
+ * racing with the UI action channel.
15
+ */
16
+ correlationId?: string;
10
17
  onStopped?: () => void;
11
18
  }
12
19
  export interface IkonVideoCaptureHandle {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonai/sdk",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -36,9 +36,8 @@ export interface TransportCallbacks {
36
36
  * Called when the connection is closed.
37
37
  * @param reason - Optional reason for the close
38
38
  * @param wasClean - Whether the close was clean (normal)
39
- * @param isServerClose - Whether the close code was 1000 or 1001, indicating server-initiated close
40
39
  */
41
- onClose: (reason?: string, wasClean?: boolean, isServerClose?: boolean) => void;
40
+ onClose: (reason?: string, wasClean?: boolean) => void;
42
41
  /**
43
42
  * Called when an error occurs.
44
43
  */
@@ -8,7 +8,7 @@
8
8
  * Supported parameters:
9
9
  * - ikon-proxy Force proxy mode on (true) or off (false)
10
10
  * - ikon-websocket Force WebSocket transport on (true) or off (false)
11
- * - ikon-webtransport Force WebTransport on (true) or off (false)
11
+ * - ikon-webtransport Force WebTransport on (true); default is off. `false` is accepted for parity.
12
12
  * - ikon-debug Enable SDK debug logging (true)
13
13
  * - ikon-lang Override language detection (e.g., "en", "fi")
14
14
  * - ikon-server-url External connect URL for shareable preview links
@@ -18,6 +18,8 @@
18
18
  * - ikon-video Force video on (true) or off (false)
19
19
  * - ikon-webrtc Force WebRTC on (true) or off (false)
20
20
  * - ikon-inspect Enable element inspection overlay (true)
21
+ * - ikon-retry Enable retry loops in auth/channel connect (default true; set false to fail fast)
22
+ * - ikon-api Route backend API calls through same-origin /ikon/api (default true on deployed apps; false to force direct calls to api.{env}.ikon.live; always off in local dev)
21
23
  */
22
24
  export declare const IKON_PARAM_PROXY = "ikon-proxy";
23
25
  export declare const IKON_PARAM_WEBSOCKET = "ikon-websocket";
@@ -31,6 +33,8 @@ export declare const IKON_PARAM_AUDIO = "ikon-audio";
31
33
  export declare const IKON_PARAM_VIDEO = "ikon-video";
32
34
  export declare const IKON_PARAM_WEBRTC = "ikon-webrtc";
33
35
  export declare const IKON_PARAM_INSPECT = "ikon-inspect";
36
+ export declare const IKON_PARAM_RETRY = "ikon-retry";
37
+ export declare const IKON_PARAM_API = "ikon-api";
34
38
  /**
35
39
  * Set an SDK query parameter in the URL via history.replaceState.
36
40
  */
@@ -45,3 +49,5 @@ export declare function getAudioParam(): boolean | null;
45
49
  export declare function getVideoParam(): boolean | null;
46
50
  export declare function getWebRtcParam(): boolean | null;
47
51
  export declare function getInspectParam(): boolean;
52
+ export declare function getRetryParam(): boolean;
53
+ export declare function getApiParam(): boolean | null;
@@ -37,11 +37,23 @@ export declare class WebRTCSignaling {
37
37
  * Returns the first active video capture MediaStream, if any.
38
38
  */
39
39
  getActiveVideoCaptureStream(): MediaStream | null;
40
+ /**
41
+ * Look up a local video capture MediaStream by its app-level streamId.
42
+ * Capture streamId format: `webrtc_video_${sessionId}_${trackIndex}` (see sendVideoStreamBegin).
43
+ * Returns null if no local capture matches.
44
+ */
45
+ getLocalVideoCaptureStreamByStreamId(streamId: string): MediaStream | null;
40
46
  startAudioCapture(constraints?: MediaTrackConstraints): Promise<void>;
41
- startAudioSegment(): void;
42
- endAudioSegment(): void;
43
- startVideoCapture(constraints?: MediaTrackConstraints, bitrate?: number, senderIndex?: number): Promise<void>;
44
- startScreenCapture(constraints?: MediaTrackConstraints, bitrate?: number, senderIndex?: number): Promise<MediaStream>;
47
+ startAudioSegment(correlationId?: string): void;
48
+ endAudioSegment(correlationId?: string): void;
49
+ /**
50
+ * Communicate the originator's correlation id for a video capture sender to the server-side
51
+ * WebRtcMediaBridge so the next VideoStreamBegin it emits for this sender carries it.
52
+ * Called by the video capture path when starting a CaptureButton-initiated stream.
53
+ */
54
+ sendVideoCaptureCorrelation(senderIndex: number, correlationId?: string): void;
55
+ startVideoCapture(constraints?: MediaTrackConstraints, bitrate?: number, senderIndex?: number, correlationId?: string): Promise<void>;
56
+ startScreenCapture(constraints?: MediaTrackConstraints, bitrate?: number, senderIndex?: number, correlationId?: string): Promise<MediaStream>;
45
57
  stopVideoCapture(senderIndex: number): Promise<void>;
46
58
  private sendVideoStreamBegin;
47
59
  private sendVideoStreamEnd;