@ikonai/sdk 1.3.2 → 1.3.4

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.2",
3
+ "version": "1.3.4",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -11,20 +11,46 @@
11
11
  * `ikon.client.login` client function. They used to build the same redirect URL separately, and
12
12
  * keeping two copies in step is exactly what failed once already.
13
13
  */
14
+ /** What the frame asks its embedder for, and what the embedder answers to claim the request. */
15
+ export declare const EMBEDDER_SIGN_IN_REQUEST = "ikon-oauth-embedder-request";
16
+ export declare const EMBEDDER_SIGN_IN_ACCEPTED = "ikon-oauth-embedder-accepted";
17
+ /**
18
+ * Carries the verifier back to the frame on its own URL, beside the code.
19
+ *
20
+ * It has to travel because the frame that minted it does not survive the embedder's navigation, and
21
+ * returns on a different origin whenever its address is assigned per session — so the sessionStorage
22
+ * it wrote to is not the one it can read. Same-origin, spent immediately, and stripped from the
23
+ * address bar with the rest of the callback params.
24
+ */
25
+ export declare const PKCE_URL_PARAM = "ikon_pkce";
14
26
  /**
15
27
  * True when this document is nested in another. A cross-origin parent makes the property access
16
28
  * itself throw, which is the embedded case too.
17
29
  */
18
30
  export declare function isEmbedded(): boolean;
19
31
  /**
20
- * Sign in through a popup and land the result on this page's URL.
32
+ * Sign in from a framed app, and land the result on this page's URL.
33
+ *
34
+ * Asks the embedder first, because a host that is cross-origin isolated severs any popup this frame
35
+ * opens. Falls back to the popup for a host that is not.
36
+ *
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.
21
40
  *
22
41
  * The code is handed over by reloading this document with `ikon_code` on it rather than by redeeming
23
42
  * it here: that is the exact shape the unframed redirect flow already produces, so the callback
24
43
  * consumer that reads it needs no second code path and no knowledge of how the code arrived. The
25
44
  * reload is same-origin, so nothing frames anything it may not.
26
45
  *
27
- * Returns false when the popup could not be opened or the sign-in did not complete; the caller
28
- * reports that to the person. Throws nothing — a failed sign-in is an outcome, not an exception.
46
+ * Returns false when the sign-in could not be started or did not complete; the caller reports that
47
+ * to the person. Throws nothing — a failed sign-in is an outcome, not an exception.
29
48
  */
30
49
  export declare function startEmbeddedOAuthSignIn(provider: string, spaceId: string): Promise<boolean>;
50
+ /**
51
+ * Take a verifier off this document's URL and put it back where the exchange looks for it.
52
+ *
53
+ * Called before redeeming a code that arrived from an embedder, which is the only case where the
54
+ * verifier could not simply have stayed in storage.
55
+ */
56
+ export declare function adoptPkceVerifierFromUrl(): void;
package/utils/pkce.d.ts CHANGED
@@ -6,6 +6,16 @@ export declare function isPkceSupported(): boolean;
6
6
  * flow rather than starting a sign-in it will not be able to finish.
7
7
  */
8
8
  export declare function createPkceChallenge(): Promise<string | null>;
9
+ /**
10
+ * Put back a verifier that had to travel to finish its sign-in.
11
+ *
12
+ * The frame that minted one does not always survive to redeem it: an embedded app whose host runs
13
+ * the redirect is destroyed by that navigation, and comes back on a different origin whenever its
14
+ * address is assigned per session — a preview's relay port is. sessionStorage is keyed on that
15
+ * origin, so the verifier written before the navigation is unreachable after it, and the exchange
16
+ * fails as though the sign-in had started in another browser.
17
+ */
18
+ export declare function restorePkceVerifier(verifier: string): void;
9
19
  /**
10
20
  * Returns the verifier for this browser's pending sign-in and forgets it. One-shot on purpose: a
11
21
  * verifier that outlived its redemption is only useful to whoever finds it later.