@ikonai/sdk 1.3.3 → 1.3.5
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/index.d.ts +2 -2
- package/index.js +625 -616
- package/package.json +1 -1
- package/utils/embedded-oauth.d.ts +31 -6
- package/utils/pkce.d.ts +10 -0
package/package.json
CHANGED
|
@@ -11,23 +11,48 @@
|
|
|
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
|
|
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 popup is opened only once the embedder has declined, never speculatively. Opening it up front
|
|
38
|
+
* left a blank window stranded on screen in exactly the case the embedder path handles: a severed
|
|
39
|
+
* `window.open` returns null, so there is no handle left to close the window it nonetheless opened.
|
|
40
|
+
* The gesture survives the wait — {@link EMBEDDER_ACK_TIMEOUT_MS} is bounded well inside the
|
|
41
|
+
* browser's transient-activation window, so the popup is still attributable to the click.
|
|
21
42
|
*
|
|
22
43
|
* The code is handed over by reloading this document with `ikon_code` on it rather than by redeeming
|
|
23
44
|
* it here: that is the exact shape the unframed redirect flow already produces, so the callback
|
|
24
45
|
* consumer that reads it needs no second code path and no knowledge of how the code arrived. The
|
|
25
46
|
* reload is same-origin, so nothing frames anything it may not.
|
|
26
47
|
*
|
|
27
|
-
* Returns false when the
|
|
28
|
-
*
|
|
48
|
+
* Returns false when the sign-in could not be started or did not complete; the caller reports that
|
|
49
|
+
* to the person. Throws nothing — a failed sign-in is an outcome, not an exception.
|
|
29
50
|
*/
|
|
30
|
-
/** What the frame asks its embedder for, and what the embedder answers to claim the request. */
|
|
31
|
-
export declare const EMBEDDER_SIGN_IN_REQUEST = "ikon-oauth-embedder-request";
|
|
32
|
-
export declare const EMBEDDER_SIGN_IN_ACCEPTED = "ikon-oauth-embedder-accepted";
|
|
33
51
|
export declare function startEmbeddedOAuthSignIn(provider: string, spaceId: string): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Take a verifier off this document's URL and put it back where the exchange looks for it.
|
|
54
|
+
*
|
|
55
|
+
* Called before redeeming a code that arrived from an embedder, which is the only case where the
|
|
56
|
+
* verifier could not simply have stayed in storage.
|
|
57
|
+
*/
|
|
58
|
+
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.
|