@hanzo/rooms 0.1.55 → 0.1.57

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/host.js CHANGED
@@ -25,7 +25,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
25
25
  import { createContext, useContext } from 'react';
26
26
  import { useIam, useOrganizations } from '@hanzo/iam/react';
27
27
  import { useAppearance } from '@hanzo/appearance';
28
- import { where } from './where.js';
28
+ import { iam } from './lib/api.js';
29
29
  const Plain = ({ prefetch: _prefetch, ...rest }) => _jsx("a", { ...rest });
30
30
  const Context = createContext({
31
31
  router: {
@@ -59,7 +59,7 @@ export function useLook() {
59
59
  // passing through a room on the way to sign in sends nothing to the issuer.
60
60
  return useAppearance({
61
61
  org: org.id,
62
- account: accessToken ? { base: (where().iam ?? 'https://hanzo.id').replace(/\/+$/, ''), token: accessToken } : undefined,
62
+ account: accessToken ? { base: iam(), token: accessToken } : undefined,
63
63
  });
64
64
  }
65
65
  /**
@@ -130,9 +130,16 @@ export declare const WEB = "https://hanzo.ai/chat";
130
130
  export declare const guest: (hostname: string) => boolean;
131
131
  /**
132
132
  * Whether a host is the devnet's: its production twin with `-dev` on the one
133
- * label under hanzo.ai (app-dev.hanzo.ai, api-dev.hanzo.ai, id-dev.hanzo.ai),
134
- * and dev.hanzo.ai, the devnet's sandbox checkout. A deeper name
135
- * (a.b-dev.hanzo.ai) is not one, and neither is a name that only contains the
136
- * suffix (app-dev.hanzo.ai.example.com).
133
+ * label under hanzo.ai (app-dev.hanzo.ai, api-dev.hanzo.ai, id-dev.hanzo.ai). A
134
+ * deeper name (a.b-dev.hanzo.ai) is not one, and neither is a name that only
135
+ * contains the suffix (app-dev.hanzo.ai.example.com). dev.hanzo.ai is not one
136
+ * either: it is hanzo.ai/dev's old address and redirects there.
137
137
  */
138
138
  export declare function devnet(hostname: string): boolean;
139
+ /**
140
+ * Whether a host answers IAM's sign-in and sign-out calls on its own origin, so
141
+ * a page there signs in without leaving it. Every devnet host does: app-dev's
142
+ * /v1 is the devnet cloud, whose IAM is the devnet's own (universe hanzo-devnet
143
+ * cloud.yaml).
144
+ */
145
+ export declare const answers: (hostname: string) => boolean;
package/dist/lib/host.js CHANGED
@@ -201,16 +201,30 @@ export const guest = (hostname) => hostname === 'hanzo.app' || hostname.endsWith
201
201
  const DEVNET = '-dev.hanzo.ai';
202
202
  /**
203
203
  * Whether a host is the devnet's: its production twin with `-dev` on the one
204
- * label under hanzo.ai (app-dev.hanzo.ai, api-dev.hanzo.ai, id-dev.hanzo.ai),
205
- * and dev.hanzo.ai, the devnet's sandbox checkout. A deeper name
206
- * (a.b-dev.hanzo.ai) is not one, and neither is a name that only contains the
207
- * suffix (app-dev.hanzo.ai.example.com).
204
+ * label under hanzo.ai (app-dev.hanzo.ai, api-dev.hanzo.ai, id-dev.hanzo.ai). A
205
+ * deeper name (a.b-dev.hanzo.ai) is not one, and neither is a name that only
206
+ * contains the suffix (app-dev.hanzo.ai.example.com). dev.hanzo.ai is not one
207
+ * either: it is hanzo.ai/dev's old address and redirects there.
208
208
  */
209
209
  export function devnet(hostname) {
210
- if (hostname === 'dev.hanzo.ai')
211
- return true;
212
- if (!hostname.endsWith(DEVNET))
210
+ // A fully qualified name (app-dev.hanzo.ai.) is the same host.
211
+ const host = hostname.endsWith('.') ? hostname.slice(0, -1) : hostname;
212
+ if (!host.endsWith(DEVNET))
213
213
  return false;
214
- const label = hostname.slice(0, -'.hanzo.ai'.length);
214
+ const label = host.slice(0, -'.hanzo.ai'.length);
215
215
  return label.length > '-dev'.length && !label.includes('.');
216
216
  }
217
+ /**
218
+ * The hosts that answer IAM's sign-in and sign-out calls on their own origin:
219
+ * every host this export is served on and signs in at (universe static-sites
220
+ * `iam-on-hanzo-ai` and cloud.yaml `iam-signin`), testnet's test.hanzo.ai, and
221
+ * the dev server's /v1 proxy.
222
+ */
223
+ const ANSWERS = new Set([...APEX, 'cloud.hanzo.ai', 'hanzo.bot', 'bot.hanzo.ai', 'test.hanzo.ai', 'localhost', '127.0.0.1']);
224
+ /**
225
+ * Whether a host answers IAM's sign-in and sign-out calls on its own origin, so
226
+ * a page there signs in without leaving it. Every devnet host does: app-dev's
227
+ * /v1 is the devnet cloud, whose IAM is the devnet's own (universe hanzo-devnet
228
+ * cloud.yaml).
229
+ */
230
+ export const answers = (hostname) => ANSWERS.has(hostname) || devnet(hostname);
package/dist/lib/pay.d.ts CHANGED
@@ -17,6 +17,14 @@
17
17
  * hanzo.bot, and the checkout lives on hanzo.ai.
18
18
  */
19
19
  export declare const BILLING_URL = "https://hanzo.ai/pay";
20
+ /**
21
+ * The devnet's checkout: the same /pay mount on the devnet's site host, which
22
+ * charges Square's sandbox through the devnet's cloud. A page on a devnet host
23
+ * sends a buyer here and never to production's checkout.
24
+ */
25
+ export declare const BILLING_DEV = "https://app-dev.hanzo.ai/pay";
26
+ /** The checkout for the page in front of us: the devnet's on a devnet host, hanzo.ai's everywhere else. */
27
+ export declare function billing(): string;
20
28
  /**
21
29
  * The checkout address, opened on a plan when one is named, and returning to
22
30
  * `back` once the buyer has paid. Without `back` a paid buyer lands on the pay
package/dist/lib/pay.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * Kept apart from `plans.ts`, which reads the bundled plan catalogue: a page
5
5
  * that only links the pay page or prints a price carries none of it.
6
6
  */
7
+ import { devnet } from "./host.js";
7
8
  import { org } from "./session.js";
8
9
  /**
9
10
  * Where money changes hands: the checkout, mounted at hanzo.ai/pay so a buyer
@@ -18,6 +19,16 @@ import { org } from "./session.js";
18
19
  * hanzo.bot, and the checkout lives on hanzo.ai.
19
20
  */
20
21
  export const BILLING_URL = "https://hanzo.ai/pay";
22
+ /**
23
+ * The devnet's checkout: the same /pay mount on the devnet's site host, which
24
+ * charges Square's sandbox through the devnet's cloud. A page on a devnet host
25
+ * sends a buyer here and never to production's checkout.
26
+ */
27
+ export const BILLING_DEV = "https://app-dev.hanzo.ai/pay";
28
+ /** The checkout for the page in front of us: the devnet's on a devnet host, hanzo.ai's everywhere else. */
29
+ export function billing() {
30
+ return typeof window !== "undefined" && devnet(window.location.hostname) ? BILLING_DEV : BILLING_URL;
31
+ }
21
32
  /**
22
33
  * The checkout address, opened on a plan when one is named, and returning to
23
34
  * `back` once the buyer has paid. Without `back` a paid buyer lands on the pay
@@ -50,9 +61,10 @@ export function payUrl(path, query) {
50
61
  if (v)
51
62
  q.set(k, v);
52
63
  const s = q.toString();
64
+ const at = billing();
53
65
  if (path === "/" && !s)
54
- return BILLING_URL;
55
- return `${BILLING_URL}${path}${s ? `?${s}` : ""}`;
66
+ return at;
67
+ return `${at}${path}${s ? `?${s}` : ""}`;
56
68
  }
57
69
  export const dollars = (n) => `$${n.toFixed(2)}`;
58
70
  /** Money as a sentence says it: whole dollars bare, anything else to the cent — $20, $16.67. */
package/dist/lib/plans.js CHANGED
@@ -32,7 +32,7 @@
32
32
  import { useEffect, useMemo, useState } from "react";
33
33
  import { where } from "../where.js";
34
34
  import { api } from "./api.js";
35
- import { BILLING_URL, checkoutUrl, dollars, money, payUrl } from "./pay.js";
35
+ import { billing, checkoutUrl, dollars, money, payUrl } from "./pay.js";
36
36
  /**
37
37
  * The checkout a plan's CTA opens.
38
38
  *
@@ -52,7 +52,7 @@ export function planCheckoutUrl(plan, back) {
52
52
  export function term(href, interval) {
53
53
  if (interval === "month")
54
54
  return href;
55
- const url = new URL(href, BILLING_URL);
55
+ const url = new URL(href, billing());
56
56
  url.searchParams.set("interval", "year");
57
57
  return url.toString();
58
58
  }
@@ -1,5 +1,5 @@
1
1
  import { IAM } from '@hanzo/iam';
2
- /** Whether the page in front of us is on such an origin. */
2
+ /** Whether the page in front of us is on an origin that answers IAM itself (`answers` in host.ts). */
3
3
  export declare const here: () => boolean;
4
4
  /** The IAM client for this page; the token exchange at the callback shares its PKCE store. */
5
5
  export declare function useClient(): IAM;
@@ -12,17 +12,9 @@ import { IAM } from '@hanzo/iam';
12
12
  import { useIam } from '@hanzo/iam/react';
13
13
  import { useSignOut as useUiSignOut } from '@hanzo/ui/auth';
14
14
  import { track } from './tags.js';
15
- import { APEX } from './host.js';
16
- /**
17
- * The hosts that answer IAM's sign-in and sign-out calls on their own origin:
18
- * every host this export is served on and signs in at (universe static-sites
19
- * `iam-on-hanzo-ai` and cloud.yaml `iam-signin`), each network's own
20
- * (test.hanzo.ai for testnet, dev.hanzo.ai for devnet), and the dev server's
21
- * /v1 proxy.
22
- */
23
- const HOSTS = new Set([...APEX, 'cloud.hanzo.ai', 'hanzo.bot', 'bot.hanzo.ai', 'test.hanzo.ai', 'dev.hanzo.ai', 'localhost', '127.0.0.1']);
24
- /** Whether the page in front of us is on such an origin. */
25
- export const here = () => typeof window !== 'undefined' && HOSTS.has(window.location.hostname);
15
+ import { answers } from './host.js';
16
+ /** Whether the page in front of us is on an origin that answers IAM itself (`answers` in host.ts). */
17
+ export const here = () => typeof window !== 'undefined' && answers(window.location.hostname);
26
18
  /** The IAM client for this page; the token exchange at the callback shares its PKCE store. */
27
19
  export function useClient() {
28
20
  const { config } = useIam();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/rooms",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "description": "The workspace rooms — Home, Chat, Inbox, Contacts, Meet, Cal, Drive, Board, Work, Bots — and the frame that holds them, once, for every Hanzo surface.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",