@hanzo/app 0.3.64 → 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.
@@ -7,19 +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
- /** Where a sign-out lands: this site's sign-in, which does not ask IAM for the session just ended. */
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 /login?from=logout (or `to`: the account
16
- * chooser, which signs everyone out and stays on the request it was drawn for),
17
- * where the person can sign straight back in. IAM's own logout page is never
18
- * visited.
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).
19
36
  *
20
37
  * EVERY HANZO SITE AT ONCE (`everywhere`). hanzo.ai and platform.hanzo.ai sign in
21
38
  * from one session, so leaving one of them must leave the other: IAM retires the
22
39
  * person's grant to every application of this client's organization along with
23
40
  * the session. A third-party app the person signed into keeps its own.
41
+ *
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).
24
47
  */
25
48
  export declare function useSignOut(to?: string): () => Promise<void>;
@@ -5,14 +5,15 @@
5
5
  * answered on this origin where it answers them (universe static-sites
6
6
  * `iam-on-hanzo-ai`): that is also where IAM keeps its session cookie, so the
7
7
  * session a person signs in with here is the one a later visit finds, and the
8
- * one sign-out ends. Nobody is sent to hanzo.id for any of it.
8
+ * one sign-out ends. Nobody is sent to hanzo.id to sign in; a plain sign-out
9
+ * passes through its end-session page on the way out (`useSignOut`).
9
10
  */
10
11
  import { useCallback, useMemo } from 'react';
11
12
  import { IAM } from '@hanzo/iam';
12
13
  import { useIam } from '@hanzo/iam/react';
13
14
  import { useSignOut as useUiSignOut } from '@hanzo/ui/auth';
14
15
  import { track } from './tags.js';
15
- import { answers } from './host.js';
16
+ import { answers, SIGNIN } from './host.js';
16
17
  import { where } from '../where.js';
17
18
  /**
18
19
  * Whether the page in front of us is on an origin that answers IAM itself: one of
@@ -26,23 +27,63 @@ export function useClient() {
26
27
  const local = here();
27
28
  return useMemo(() => new IAM(local ? { ...config, proxyBaseUrl: window.location.origin } : config), [config, local]);
28
29
  }
29
- /** Where a sign-out lands: this site's sign-in, which does not ask IAM for the session just ended. */
30
+ /** This site's sign-in after a sign-out, which does not ask IAM for the session just ended. */
30
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
+ }
31
64
  /**
32
65
  * Sign-out on this site: @hanzo/ui/auth's `signOut` — the tokens handed back to
33
66
  * IAM's /v1/iam routes, IAM's session here ended, the local session cleared —
34
- * counted as logout_completed, and then /login?from=logout (or `to`: the account
35
- * chooser, which signs everyone out and stays on the request it was drawn for),
36
- * where the person can sign straight back in. IAM's own logout page is never
37
- * visited.
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.
75
+ *
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).
43
81
  */
44
- export function useSignOut(to = OUT) {
45
- const signOut = useUiSignOut({ to, track, everywhere: true });
82
+ export function useSignOut(to = HOME) {
83
+ const { config } = useIam();
84
+ const plain = to === HOME || to === OUT;
85
+ const issuer = plain && typeof window !== 'undefined' ? endsAt(config.serverUrl, window.location.hostname) : '';
86
+ const signOut = useUiSignOut({ to, track, everywhere: true, issuer });
46
87
  return useCallback(async () => {
47
88
  // Google One Tap signs a returning person in on its own (`auto_select`), which
48
89
  // would put them straight back in the account they just left. Leaving says so.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/app",
3
- "version": "0.3.64",
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",
@@ -61,7 +61,7 @@
61
61
  "@hanzo/logo": ">=1.0.26",
62
62
  "@hanzo/studio": ">=0.1.0",
63
63
  "@hanzo/tabs": ">=0.1.8",
64
- "@hanzo/ui": ">=8.30.4",
64
+ "@hanzo/ui": ">=8.31.0",
65
65
  "@hanzo/usage": ">=0.1.18",
66
66
  "@hanzo/voice": ">=0.1.16",
67
67
  "@hanzogui/shell": "^8.3.20",
@@ -82,7 +82,7 @@
82
82
  "@hanzo/logo": "1.0.26",
83
83
  "@hanzo/studio": "0.1.0",
84
84
  "@hanzo/tabs": "github:hanzo-inc/tabs",
85
- "@hanzo/ui": "8.30.4",
85
+ "@hanzo/ui": "8.31.0",
86
86
  "@hanzo/usage": "0.1.18",
87
87
  "@hanzo/voice": "0.1.19",
88
88
  "@hanzogui/config": "8.3.5",