@ikonai/sdk 1.3.4 → 1.3.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonai/sdk",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -14,6 +14,14 @@
14
14
  /** What the frame asks its embedder for, and what the embedder answers to claim the request. */
15
15
  export declare const EMBEDDER_SIGN_IN_REQUEST = "ikon-oauth-embedder-request";
16
16
  export declare const EMBEDDER_SIGN_IN_ACCEPTED = "ikon-oauth-embedder-accepted";
17
+ /** What a frame sends to collect a sign-in the embedder completed for it, and the answer it gets. */
18
+ export declare const EMBEDDER_RESULT_CLAIM = "ikon-oauth-embedder-claim";
19
+ export declare const EMBEDDER_RESULT = "ikon-oauth-embedder-result";
20
+ export interface EmbeddedOAuthResult {
21
+ code: string;
22
+ provider: string;
23
+ codeVerifier: string | null;
24
+ }
17
25
  /**
18
26
  * Carries the verifier back to the frame on its own URL, beside the code.
19
27
  *
@@ -34,9 +42,11 @@ export declare function isEmbedded(): boolean;
34
42
  * Asks the embedder first, because a host that is cross-origin isolated severs any popup this frame
35
43
  * opens. Falls back to the popup for a host that is not.
36
44
  *
37
- * The window is opened BEFORE either path is chosen, while the click is still what the browser sees:
38
- * asking the embedder awaits, and a popup opened after that has lost the gesture and is taken for a
39
- * pop-under. An embedder that claims the request gets it closed again immediately.
45
+ * The popup is opened only once the embedder has declined, never speculatively. Opening it up front
46
+ * left a blank window stranded on screen in exactly the case the embedder path handles: a severed
47
+ * `window.open` returns null, so there is no handle left to close the window it nonetheless opened.
48
+ * The gesture survives the wait — {@link EMBEDDER_ACK_TIMEOUT_MS} is bounded well inside the
49
+ * browser's transient-activation window, so the popup is still attributable to the click.
40
50
  *
41
51
  * The code is handed over by reloading this document with `ikon_code` on it rather than by redeeming
42
52
  * it here: that is the exact shape the unframed redirect flow already produces, so the callback
@@ -47,6 +57,23 @@ export declare function isEmbedded(): boolean;
47
57
  * to the person. Throws nothing — a failed sign-in is an outcome, not an exception.
48
58
  */
49
59
  export declare function startEmbeddedOAuthSignIn(provider: string, spaceId: string): Promise<boolean>;
60
+ /**
61
+ * Collect a sign-in the embedder ran on this frame's behalf, and hand it to `deliver`.
62
+ *
63
+ * The result travels as a message rather than on this frame's address, because an address can be
64
+ * given to any number of documents. An embedder that reassigns the frame's src while the preview
65
+ * settles hands the same single-use code to each of them, and every redemption after the first
66
+ * fails against a code the first already spent — which reports a sign-in as broken to whichever
67
+ * document is left on screen, moments after it actually succeeded. A message has one recipient, and
68
+ * the embedder drops its copy as it answers, so the code cannot be presented twice.
69
+ *
70
+ * The claim is sent on mount rather than waited for: an embedder holding nothing simply never
71
+ * answers, and the app resolves its session exactly as it would unembedded instead of pausing every
72
+ * framed boot on a timeout.
73
+ *
74
+ * Returns a function that stops listening.
75
+ */
76
+ export declare function onEmbeddedOAuthResult(spaceId: string, deliver: (result: EmbeddedOAuthResult) => void): () => void;
50
77
  /**
51
78
  * Take a verifier off this document's URL and put it back where the exchange looks for it.
52
79
  *