@hanzo/app 0.3.65 → 0.3.66
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/dist/lib/signout.d.ts +27 -10
- package/dist/lib/signout.js +45 -13
- package/package.json +1 -1
package/dist/lib/signout.d.ts
CHANGED
|
@@ -7,25 +7,42 @@ import { IAM } from '@hanzo/iam';
|
|
|
7
7
|
export declare const here: () => boolean;
|
|
8
8
|
/** The IAM client for this page; the token exchange at the callback shares its PKCE store. */
|
|
9
9
|
export declare function useClient(): IAM;
|
|
10
|
-
/**
|
|
10
|
+
/** This site's sign-in after a sign-out, which does not ask IAM for the session just ended. */
|
|
11
11
|
export declare const OUT = "/login?from=logout";
|
|
12
|
+
/**
|
|
13
|
+
* Where a plain sign-out lands: this site's home page. Every host this export is
|
|
14
|
+
* served on (hanzo.ai, hanzo.app, hanzo.bot) has a marketing page there, and a
|
|
15
|
+
* person who signed out is brought back to it rather than to a sign-in form. IAM
|
|
16
|
+
* returns the browser to it when the client registered it (universe
|
|
17
|
+
* iam-provision.yaml); otherwise it lands on hanzo.ai/login.
|
|
18
|
+
*/
|
|
19
|
+
export declare const HOME = "/";
|
|
20
|
+
/**
|
|
21
|
+
* The end-session page a sign-out everywhere leaves through: hanzo.ai's, the
|
|
22
|
+
* origin every Hanzo site signs in on and so the one holding the person's session.
|
|
23
|
+
* IAM ends the session there and walks the issuer's other sign-in origins
|
|
24
|
+
* (hanzo.id, hanzo.market) by the request's own Host, so the page has to be one of
|
|
25
|
+
* them: the configured `serverUrl` (api.hanzo.ai, where the token calls go) is
|
|
26
|
+
* none, and an end-session there ends nothing past it. A brand with an issuer of
|
|
27
|
+
* its own ends on that issuer; a dev server on this machine ends here ('').
|
|
28
|
+
*/
|
|
29
|
+
export declare function endsAt(serverUrl: string, hostname: string): string;
|
|
12
30
|
/**
|
|
13
31
|
* Sign-out on this site: @hanzo/ui/auth's `signOut` — the tokens handed back to
|
|
14
32
|
* IAM's /v1/iam routes, IAM's session here ended, the local session cleared —
|
|
15
|
-
* counted as logout_completed, and then
|
|
16
|
-
* chooser, which signs everyone out and stays on the request it was drawn
|
|
17
|
-
*
|
|
33
|
+
* counted as logout_completed, and then this site's home page (or `to`: the
|
|
34
|
+
* account chooser, which signs everyone out and stays on the request it was drawn
|
|
35
|
+
* for).
|
|
18
36
|
*
|
|
19
37
|
* EVERY HANZO SITE AT ONCE (`everywhere`). hanzo.ai and platform.hanzo.ai sign in
|
|
20
38
|
* from one session, so leaving one of them must leave the other: IAM retires the
|
|
21
39
|
* person's grant to every application of this client's organization along with
|
|
22
40
|
* the session. A third-party app the person signed into keeps its own.
|
|
23
41
|
*
|
|
24
|
-
* AND EVERY SIGN-IN ORIGIN (D3). A plain sign-out ends through
|
|
25
|
-
* end-session page (`
|
|
26
|
-
* and hanzo.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* only (an empty issuer).
|
|
42
|
+
* AND EVERY SIGN-IN ORIGIN (D3). A plain sign-out ends through hanzo.ai's
|
|
43
|
+
* end-session page (`endsAt`, passed to @hanzo/ui 8.31 as `issuer`), which ends
|
|
44
|
+
* the session there and on hanzo.id and hanzo.market too, as well as this
|
|
45
|
+
* origin's. A sign-out with its own `to` is the account chooser's, which must stay
|
|
46
|
+
* on the request in flight, so it ends here only (an empty issuer).
|
|
30
47
|
*/
|
|
31
48
|
export declare function useSignOut(to?: string): () => Promise<void>;
|
package/dist/lib/signout.js
CHANGED
|
@@ -13,7 +13,7 @@ import { IAM } from '@hanzo/iam';
|
|
|
13
13
|
import { useIam } from '@hanzo/iam/react';
|
|
14
14
|
import { useSignOut as useUiSignOut } from '@hanzo/ui/auth';
|
|
15
15
|
import { track } from './tags.js';
|
|
16
|
-
import { answers } from './host.js';
|
|
16
|
+
import { answers, SIGNIN } from './host.js';
|
|
17
17
|
import { where } from '../where.js';
|
|
18
18
|
/**
|
|
19
19
|
* Whether the page in front of us is on an origin that answers IAM itself: one of
|
|
@@ -27,30 +27,62 @@ export function useClient() {
|
|
|
27
27
|
const local = here();
|
|
28
28
|
return useMemo(() => new IAM(local ? { ...config, proxyBaseUrl: window.location.origin } : config), [config, local]);
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
30
|
+
/** This site's sign-in after a sign-out, which does not ask IAM for the session just ended. */
|
|
31
31
|
export const OUT = '/login?from=logout';
|
|
32
|
+
/**
|
|
33
|
+
* Where a plain sign-out lands: this site's home page. Every host this export is
|
|
34
|
+
* served on (hanzo.ai, hanzo.app, hanzo.bot) has a marketing page there, and a
|
|
35
|
+
* person who signed out is brought back to it rather than to a sign-in form. IAM
|
|
36
|
+
* returns the browser to it when the client registered it (universe
|
|
37
|
+
* iam-provision.yaml); otherwise it lands on hanzo.ai/login.
|
|
38
|
+
*/
|
|
39
|
+
export const HOME = '/';
|
|
40
|
+
/** A dev server on this machine, which keeps its sign-out local. */
|
|
41
|
+
const loopback = (hostname) => hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]' || hostname.endsWith('.localhost');
|
|
42
|
+
/**
|
|
43
|
+
* The end-session page a sign-out everywhere leaves through: hanzo.ai's, the
|
|
44
|
+
* origin every Hanzo site signs in on and so the one holding the person's session.
|
|
45
|
+
* IAM ends the session there and walks the issuer's other sign-in origins
|
|
46
|
+
* (hanzo.id, hanzo.market) by the request's own Host, so the page has to be one of
|
|
47
|
+
* them: the configured `serverUrl` (api.hanzo.ai, where the token calls go) is
|
|
48
|
+
* none, and an end-session there ends nothing past it. A brand with an issuer of
|
|
49
|
+
* its own ends on that issuer; a dev server on this machine ends here ('').
|
|
50
|
+
*/
|
|
51
|
+
export function endsAt(serverUrl, hostname) {
|
|
52
|
+
if (loopback(hostname))
|
|
53
|
+
return '';
|
|
54
|
+
try {
|
|
55
|
+
const host = new URL(serverUrl).hostname;
|
|
56
|
+
if (host === 'api.hanzo.ai' || host === 'hanzo.id' || host === 'hanzo.ai')
|
|
57
|
+
return SIGNIN;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
return serverUrl;
|
|
63
|
+
}
|
|
32
64
|
/**
|
|
33
65
|
* Sign-out on this site: @hanzo/ui/auth's `signOut` — the tokens handed back to
|
|
34
66
|
* IAM's /v1/iam routes, IAM's session here ended, the local session cleared —
|
|
35
|
-
* counted as logout_completed, and then
|
|
36
|
-
* chooser, which signs everyone out and stays on the request it was drawn
|
|
37
|
-
*
|
|
67
|
+
* counted as logout_completed, and then this site's home page (or `to`: the
|
|
68
|
+
* account chooser, which signs everyone out and stays on the request it was drawn
|
|
69
|
+
* for).
|
|
38
70
|
*
|
|
39
71
|
* EVERY HANZO SITE AT ONCE (`everywhere`). hanzo.ai and platform.hanzo.ai sign in
|
|
40
72
|
* from one session, so leaving one of them must leave the other: IAM retires the
|
|
41
73
|
* person's grant to every application of this client's organization along with
|
|
42
74
|
* the session. A third-party app the person signed into keeps its own.
|
|
43
75
|
*
|
|
44
|
-
* AND EVERY SIGN-IN ORIGIN (D3). A plain sign-out ends through
|
|
45
|
-
* end-session page (`
|
|
46
|
-
* and hanzo.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* only (an empty issuer).
|
|
76
|
+
* AND EVERY SIGN-IN ORIGIN (D3). A plain sign-out ends through hanzo.ai's
|
|
77
|
+
* end-session page (`endsAt`, passed to @hanzo/ui 8.31 as `issuer`), which ends
|
|
78
|
+
* the session there and on hanzo.id and hanzo.market too, as well as this
|
|
79
|
+
* origin's. A sign-out with its own `to` is the account chooser's, which must stay
|
|
80
|
+
* on the request in flight, so it ends here only (an empty issuer).
|
|
50
81
|
*/
|
|
51
|
-
export function useSignOut(to =
|
|
82
|
+
export function useSignOut(to = HOME) {
|
|
52
83
|
const { config } = useIam();
|
|
53
|
-
const
|
|
84
|
+
const plain = to === HOME || to === OUT;
|
|
85
|
+
const issuer = plain && typeof window !== 'undefined' ? endsAt(config.serverUrl, window.location.hostname) : '';
|
|
54
86
|
const signOut = useUiSignOut({ to, track, everywhere: true, issuer });
|
|
55
87
|
return useCallback(async () => {
|
|
56
88
|
// Google One Tap signs a returning person in on its own (`auto_select`), which
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.66",
|
|
4
4
|
"description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|