diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index 2738dd9..94432a8 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -1,4 +1,4 @@ -import { Navigate, Outlet, Route, Routes, useSearchParams } from 'react-router'; +import { Navigate, Outlet, Route, Routes, useLocation, useSearchParams } from 'react-router'; import Layout from './Layout'; import ProtectedRoute from './components/ProtectedRoute'; @@ -7,11 +7,11 @@ import { useAuth } from './contexts/AuthContext'; import { AuthProvider } from './contexts/AuthProvider'; import { KeysProvider } from './contexts/KeysContext'; import { ThemeProvider } from './contexts/ThemeContext'; +import { Account } from './pages/Account'; import { IndexPage } from './pages/Index'; import Links from './pages/Links'; import Login from './pages/Login'; import NotFound from './pages/NotFound'; -import Plan from './pages/Plan'; import Push from './pages/Push'; import { ResetPassword } from './pages/ResetPassword'; import { ViewPush } from './pages/ViewPush'; @@ -50,6 +50,18 @@ function ImagePageOrHome() { ); } +/** + * `/plan`, the Plan page's address before it became the first section of Account. Stripe's + * checkout returns here with `?checkout=complete` and its portal returns here + * (functions/src/stripe-functions.ts, `planPageUrl`, and the portal's configuration), so the + * query goes along: the plan section reads it to confirm a subscription on arrival. Kept + * for old bookmarks once those point at `/account` too. + */ +function PlanRedirect() { + const { search } = useLocation(); + return ; +} + function App() { return ( @@ -75,7 +87,8 @@ function App() { }> } /> } /> - } /> + } /> + } /> } /> diff --git a/apps/web/src/Layout.tsx b/apps/web/src/Layout.tsx index 2e88360..bf5efe9 100644 --- a/apps/web/src/Layout.tsx +++ b/apps/web/src/Layout.tsx @@ -56,9 +56,10 @@ export default function Layout({ children }: LayoutProps) { {isMenuOpen && (
- {/* Above Logout, where the Android, iOS and macOS menus have it. It leads to the - public page, which asks for the password before anything goes. */} - + {/* The plan, the device id and deleting the account are all on the Account page, + so the menu has one way in rather than an item for each. Deleting is a link + from there to the public page, which asks for the password before anything goes. */} +
)} diff --git a/apps/web/src/components/Nav.tsx b/apps/web/src/components/Nav.tsx index c14e0e9..5370f9b 100644 --- a/apps/web/src/components/Nav.tsx +++ b/apps/web/src/components/Nav.tsx @@ -1,8 +1,6 @@ import { useEffect, useRef, useState } from 'react'; import { Link, useLocation } from 'react-router'; -import { PLAN_PAGE_LINKED } from '@/config/plan'; - import styles from './Nav.module.css'; export default function Nav() { @@ -19,6 +17,10 @@ export default function Nav() { width: offsetWidth, left: offsetLeft, }); + } else { + // A page with no item here (Account, the static pages while signed in): the + // slider shrinks away where it stood, rather than staying lit on the page left behind. + setSliderStyle((was) => ({ width: 0, left: was.left + was.width / 2 })); } }, [currentPath]); @@ -37,11 +39,6 @@ export default function Nav() { Links - {PLAN_PAGE_LINKED && ( - - Plan - - )} ); } diff --git a/apps/web/src/pages/Plan.module.css b/apps/web/src/components/PlanSection.module.css similarity index 64% rename from apps/web/src/pages/Plan.module.css rename to apps/web/src/components/PlanSection.module.css index ecbd029..9019790 100644 --- a/apps/web/src/pages/Plan.module.css +++ b/apps/web/src/components/PlanSection.module.css @@ -1,21 +1,11 @@ -.page { - max-width: 560px; -} - -.section { - margin: 2rem 0; - display: flex; - flex-direction: column; - gap: 0.75rem; -} +/* The section's own layout comes from the page, through `className`, so the plan is spaced + like the sections around it from one place. Only what is the plan's alone is here. */ -/* The gap spaces a section's contents; the global margins on p, h2 and ul would add to it */ -.section > * { - margin: 0; -} - -.section h2 { - font-size: 1.25rem; +/* This month and Pro are parts of the plan, under its heading, so they sit a step down and + a little apart from what comes before them rather than starting sections of their own. */ +.plan h3 { + font-size: 1rem; + margin-top: 0.75rem; } .row { @@ -75,8 +65,3 @@ .meterFillFull { background: var(--color-error); } - -/* A device id is 22 characters with no spaces, which would otherwise push a narrow screen sideways */ -.deviceId { - overflow-wrap: anywhere; -} diff --git a/apps/web/src/pages/Plan.tsx b/apps/web/src/components/PlanSection.tsx similarity index 65% rename from apps/web/src/pages/Plan.tsx rename to apps/web/src/components/PlanSection.tsx index 4a818d4..9d1aa88 100644 --- a/apps/web/src/pages/Plan.tsx +++ b/apps/web/src/components/PlanSection.tsx @@ -1,15 +1,14 @@ +import clsx from 'clsx'; import { useEffect, useRef, useState } from 'react'; -import { Helmet } from 'react-helmet'; import { Link, useNavigate, useSearchParams } from 'react-router'; import Button from '@/components/Button'; import { LIMITS, formatMb } from '@/config/plan'; import { usePlan } from '@/hooks/usePlan'; import { errorText } from '@/services/callable'; -import { deviceId } from '@/services/keyStore'; import { PlanReport, planApi } from '@/services/plan'; -import styles from './Plan.module.css'; +import styles from './PlanSection.module.css'; /** How often, and how many times, the plan is read back from Stripe after a checkout; see `settleCheckout`. */ const CHECKOUT_SETTLE_WAIT_MS = 1500; @@ -62,17 +61,21 @@ export function describePlan(plan: PlanReport): { title: string; sentence: strin } /** - * The account's plan: where it stands, this month's usage against its limits, and the - * two things that change it: subscribing, and managing the subscription in Stripe's - * portal. The checkout is Stripe's own page, reached by redirect from a session the - * server made; Stripe sends the person back here with `?checkout=complete` once paid, - * and the plan is then read back from Stripe at once rather than waiting on the - * webhook, so the page says "Pro" on arrival. + * The account's plan, as the first section of the Account page: where it stands, this + * month's usage against its limits, and the two things that change it: subscribing, and + * managing the subscription in Stripe's portal. The checkout is Stripe's own page, reached + * by redirect from a session the server made; Stripe sends the person back with + * `?checkout=complete` once paid, and the plan is then read back from Stripe at once + * rather than waiting on the webhook, so the page says "Pro" on arrival. * - * Not linked from the navigation until launch (`PLAN_PAGE_LINKED`): production runs on - * the Stripe sandbox's keys until then, and a test card here would give anyone Pro. + * Stripe still sends people back to `/plan`, which was this section's own page before it + * moved here; that address now redirects to `/account` with its query (App.tsx), so the + * checkout's return lands here either way. + * + * Shown only while `PLAN_SHOWN` is on: production ran on the Stripe sandbox's keys + * until launch, and a test card here would give anyone Pro. */ -export default function Plan() { +export function PlanSection({ className }: { className?: string }) { const { plan, error: readError, refresh, setPlan } = usePlan(); const [busy, setBusy] = useState<'checkout' | 'settling' | 'portal' | 'payment' | null>(null); const [error, setError] = useState(null); @@ -95,7 +98,7 @@ export default function Plan() { useEffect(() => { if (settled.current || params.get('checkout') !== 'complete') return; settled.current = true; - void navigate('/plan', { replace: true }); + void navigate('/account', { replace: true }); setBusy('settling'); void settleCheckout() .then((found) => @@ -179,11 +182,8 @@ export default function Plan() { if (!plan) { return ( -
- - Plan - -

Plan

+
+

Plan

{readError ? (

@@ -196,11 +196,7 @@ export default function Plan() { ) : (

Reading your plan…

)} - {/* Nothing in it depends on the plan, so it shows while the plan is read or cannot be. - Keyed, so that React keeps the one section when the plan arrives rather than - mounting another, which would read the device id again and blink its line. */} - -
+ ); } @@ -214,70 +210,62 @@ export default function Plan() { const limits = plan.limits; return ( -
- - Plan - -

Plan

- -
-

{title}

-

{sentence}

- {canSubscribe && ( -
- - Before tax, charged by Stripe. Cancel any time. -
- )} - {hasCustomer && ( -
- + ${plan.priceUsd} a year before tax, charged by Stripe. Cancel any time. +
+ )} + {hasCustomer && ( +
+ + {pastDue && ( + - {pastDue && ( - - )} - - {canSubscribe - ? 'Past invoices, in Stripe’s billing portal.' - : 'Invoices, the card, and cancelling, in Stripe’s billing portal.'} - -
- )} - {error && ( -

- {error} -

- )} - {notice && ( -

- {notice} -

- )} -
- -
-

This month

- - -

- Files up to {formatMb(limits.fileBytes)}, kept for {limits.keepDays} days from the moment they are pushed; a - file already pushed keeps the retention it was pushed with. The month starts on the day you{' '} - {plan.tier === 'pro' ? 'subscribed' : 'signed up'}. + )} + + {canSubscribe + ? 'Past invoices, in Stripe’s billing portal.' + : 'Invoices, the card, and cancelling, in Stripe’s billing portal.'} + +

+ )} + {error && ( +

+ {error}

- + )} + {notice && ( +

+ {notice} +

+ )} + +

This month

+ + +

+ Files up to {formatMb(limits.fileBytes)}, kept for {limits.keepDays} days from the moment they are pushed; a + file already pushed keeps the retention it was pushed with. The month starts on the day you{' '} + {plan.tier === 'pro' ? 'subscribed' : 'signed up'}. +

{plan.tier === 'free' && ( -
-

Pro

+ <> +

Pro

  • {LIMITS.pro.url.toLocaleString()} URL pushes a month, up from {LIMITS.free.url} @@ -296,45 +284,7 @@ export default function Plan() { ${plan.priceUsd} a year. Refunds, cancelling and receipts are explained on the{' '} support page.

    -
- )} - - - - ); -} - -/** - * The "Encrypted" line (docs/e2ee.md, Saying so): that the pushes are encrypted, this - * device's id, and where to read what that means. On the Plan page because the web app has - * no settings page and this is the page about the account. The id is what this install - * puts on its pushes in place of the device's model name, so showing it lets someone see - * all the server is told about the device. IndexedDB can refuse (a private window in - * some browsers), and the line then goes without the id rather than not at all. - */ -function Encrypted() { - const [id, setId] = useState(null); - useEffect(() => { - let current = true; - deviceId() - .then((made) => current && setId(made)) - .catch((error) => console.error('Could not read the device id:', error)); - return () => { - current = false; - }; - }, []); - - return ( -
-

Encrypted

-

- Your pushes are encrypted on your devices with a key made from your password, and only they can read them.{' '} - How it works. -

- {id && ( -

- This device: {id} -

+ )}
); diff --git a/apps/web/src/config/plan.ts b/apps/web/src/config/plan.ts index bac856a..c62c76b 100644 --- a/apps/web/src/config/plan.ts +++ b/apps/web/src/config/plan.ts @@ -2,7 +2,7 @@ * The plan, as the pages describe it (docs/billing.md at the repository root). The * numbers the functions enforce and report are in `functions/src/plan.ts` and * the rules carry them too; these are what the front page quotes before anyone has - * signed in, and the Plan page reads its own from `getPlan`. The copies are changed + * signed in, and the Account page's plan reads its own from `getPlan`. The copies are changed * together. */ @@ -24,12 +24,13 @@ export const LIMITS: Record<'free' | 'pro', TierLimits> = { }; /** - * Whether the Plan page is reachable from the navigation. On since launch (2026-10-25), - * when production moved to the live Stripe account. Turn it off only together with a - * move back to sandbox keys: on sandbox keys, anyone who reached the page could - * subscribe with a test card and get Pro. The route exists either way. + * Whether the web app shows the plan: its section on the Account page, the Push page's link + * to it when a push is refused for the month's limit, and Support's link to it. On since + * launch (2026-10-25), when production moved to the live Stripe account. Turn it off only + * together with a move back to sandbox keys: on sandbox keys, anyone who saw the plan could + * subscribe with a test card and get Pro. The rest of the Account page shows either way. */ -export const PLAN_PAGE_LINKED = true; +export const PLAN_SHOWN = true; export const SUPPORT_EMAIL = 'hello@pushthat.link'; diff --git a/apps/web/src/pages/Account.module.css b/apps/web/src/pages/Account.module.css new file mode 100644 index 0000000..34f5860 --- /dev/null +++ b/apps/web/src/pages/Account.module.css @@ -0,0 +1,35 @@ +.page { + max-width: 560px; +} + +.section { + margin: 2rem 0; + display: flex; + flex-direction: column; + gap: 0.75rem; +} + +/* The gap spaces a section's contents; the global margins on p, headings and lists would add to it */ +.section > * { + margin: 0; +} + +.section h2 { + font-size: 1.25rem; +} + +.muted { + opacity: 0.7; + font-size: 0.9rem; +} + +.danger { + color: var(--color-error); +} + +/* An email address, or a device id (22 characters), has no spaces to break at, and a long + one would push a narrow screen sideways */ +.email, +.deviceId { + overflow-wrap: anywhere; +} diff --git a/apps/web/src/pages/Account.tsx b/apps/web/src/pages/Account.tsx new file mode 100644 index 0000000..f6d1d94 --- /dev/null +++ b/apps/web/src/pages/Account.tsx @@ -0,0 +1,92 @@ +import { useEffect, useState } from 'react'; +import { Helmet } from 'react-helmet'; +import { Link } from 'react-router'; + +import { PlanSection } from '@/components/PlanSection'; +import { PLAN_SHOWN } from '@/config/plan'; +import { useAuth } from '@/contexts/AuthContext'; +import { deviceId } from '@/services/keyStore'; + +import styles from './Account.module.css'; + +/** + * Account, `/account`: the menu's way into everything about the account. The plan, who is + * signed in, the "Encrypted" line, and the way to delete the account. + * + * The plan comes first because it is what most people open this page for, and it is all + * here rather than a line linking to a page of its own: Account was four short sections, one + * of them a link to the page with the substance, which was a click that bought nothing. + * + * One page, rather than a settings layout with the plan and deletion as tabs, because + * deletion cannot move into one: `/delete-account` is public (it is the address given to + * Google Play, read by people with no account), so this page links out to it. + */ +export function Account() { + const { user } = useAuth(); + + return ( +
+ + Account + +

Account

+ + {PLAN_SHOWN && } + +
+

Email

+

{user?.email}

+
+ + + +
+

Delete account

+

+ Deletes the account and everything pushed from it, at once and for good. The next page says exactly what goes + and asks for your password first. +

+

+ + Delete account + +

+
+
+ ); +} + +/** + * The "Encrypted" line (docs/e2ee.md, Saying so): that the pushes are encrypted, this + * device's id, and where to read what that means. The id is what this install puts on its + * pushes in place of the device's model name, so showing it lets someone see all the + * server is told about the device. IndexedDB can refuse (a private window in some + * browsers), and the line then goes without the id rather than not at all. + */ +function Encrypted() { + const [id, setId] = useState(null); + useEffect(() => { + let current = true; + deviceId() + .then((made) => current && setId(made)) + .catch((error) => console.error('Could not read the device id:', error)); + return () => { + current = false; + }; + }, []); + + return ( +
+

Encrypted

+

+ Your pushes are encrypted on your devices with a key made from your password, and only they can read them.{' '} + How it works. +

+ {id && ( +

+ This device: {id} +

+ )} +
+ ); +} diff --git a/apps/web/src/pages/DeleteAccount.tsx b/apps/web/src/pages/DeleteAccount.tsx index 6e1ce98..e791602 100644 --- a/apps/web/src/pages/DeleteAccount.tsx +++ b/apps/web/src/pages/DeleteAccount.tsx @@ -81,8 +81,8 @@ export function DeleteAccount() { extension.
  • - Choose Delete account. On the website and in the extension this opens this page: use the{' '} - form below. + Choose Delete account. On the website and in the extension, choose Account{' '} + and then Delete account, which opens this page: use the form below.
  • In the Android, iPhone and Mac apps, enter your password to confirm, and press Delete account diff --git a/apps/web/src/pages/Push.module.css b/apps/web/src/pages/Push.module.css index cf170f1..2398c5b 100644 --- a/apps/web/src/pages/Push.module.css +++ b/apps/web/src/pages/Push.module.css @@ -32,6 +32,13 @@ border: 1px solid #fecaca; } +/* The site's link color is its pink, which is hard to read on this pale red box */ +.error a { + color: inherit; + font-weight: 600; + text-decoration: underline; +} + .divider { display: flex; align-items: center; diff --git a/apps/web/src/pages/Push.tsx b/apps/web/src/pages/Push.tsx index c124cdd..ee8a4fe 100644 --- a/apps/web/src/pages/Push.tsx +++ b/apps/web/src/pages/Push.tsx @@ -1,9 +1,10 @@ import { getFirestore } from 'firebase/firestore'; import { getStorage } from 'firebase/storage'; import { useState } from 'react'; +import { Link } from 'react-router'; import Button from '@/components/Button'; -import { LIMITS, formatMb } from '@/config/plan'; +import { LIMITS, PLAN_SHOWN, formatMb } from '@/config/plan'; import { usePlan } from '@/hooks/usePlan'; import { KEYS_UNAVAILABLE, usePushKeys } from '@/hooks/usePushKeys'; import { @@ -12,7 +13,7 @@ import { atLimit, isRulesRefusal, limitMessage, - refusalMessage, + refusalReason, } from '@/services/pushRefusal'; import { PushTooLongError, @@ -30,7 +31,12 @@ export default function Push() { const [file, setFile] = useState(null); const [isSubmitting, setIsSubmitting] = useState(false); const [isUploadSubmitting, setIsUploadSubmitting] = useState(false); - const [error, setError] = useState(null); + // The message and whether it is the month's limit, which is followed by a link to the + // plan: hitting the limit is when someone on Free is most ready to upgrade, and the only + // way to the plan otherwise is the menu. One piece of state, so the link cannot stay under + // a later, unrelated error: the link and file forms submit independently and share it. + const [error, setError] = useState<{ message: string; atLimit: boolean } | null>(null); + const fail = (message: string, atLimit = false) => setError({ message, atLimit }); const { plan, refresh: refreshPlan } = usePlan(); const { keys } = usePushKeys(); @@ -40,7 +46,7 @@ export default function Push() { if (!url) return; if (!keys) { - setError(KEYS_UNAVAILABLE); + fail(KEYS_UNAVAILABLE); return; } @@ -50,7 +56,7 @@ export default function Push() { // Read once per mount, so a new period or a subscription in another tab is not seen // until it is read again; a refusal here asks for the read, so the next try is right. void refreshPlan(); - setError(limitMessage(plan, 'url')); + fail(limitMessage(plan, 'url'), true); return; } @@ -61,7 +67,7 @@ export default function Push() { try { new URL(url); } catch (error) { - setError('Invalid URL'); + fail('Invalid URL'); setIsSubmitting(false); return; } @@ -79,15 +85,18 @@ export default function Push() { console.error('Error saving link:', error); // The limit reached on another device, a key a reset replaced, or a push this copy of // PushThat cannot make (pushRefusal.ts); the plan read again stops the next try here. - setError( - isRulesRefusal(error) - ? await refusalMessage(plan, 'url', refreshPlan, () => keyIsStale(getFirestore(), keys)) - : error instanceof PushUnconfirmedError + if (isRulesRefusal(error)) { + const refusal = await refusalReason(plan, 'url', refreshPlan, () => keyIsStale(getFirestore(), keys)); + fail(refusal.message, refusal.atLimit); + } else { + fail( + error instanceof PushUnconfirmedError ? UNCONFIRMED_MESSAGE : error instanceof PushTooLongError ? TOO_LONG_LINK_MESSAGE : 'Failed to save link. Please try again.' - ); + ); + } } finally { setIsSubmitting(false); } @@ -99,7 +108,7 @@ export default function Push() { if (!file) return; if (!keys) { - setError(KEYS_UNAVAILABLE); + fail(KEYS_UNAVAILABLE); return; } @@ -110,7 +119,7 @@ export default function Push() { // `>=`, as the Storage rule has it: a file of exactly the limit is refused there. The // rule measures the encrypted object, a few bytes a megabyte larger than the file. if (encryptedSize(file.size) >= limits.fileBytes) { - setError( + fail( `File size must be under ${formatMb(limits.fileBytes)}${plan?.tier === 'free' ? ` on the free plan (${formatMb(LIMITS.pro.fileBytes)} on Pro)` : ''}.` ); return; @@ -120,7 +129,7 @@ export default function Push() { // nothing to ever delete them. Refused here first, with the plan already in hand. if (plan && atLimit(plan, 'file')) { void refreshPlan(); - setError(limitMessage(plan, 'file')); + fail(limitMessage(plan, 'file'), true); return; } @@ -139,15 +148,18 @@ export default function Push() { if (fileInput) fileInput.value = ''; } catch (error) { console.error('Error saving file:', error); - setError( - isRulesRefusal(error) - ? await refusalMessage(plan, 'file', refreshPlan, () => keyIsStale(getFirestore(), keys)) - : error instanceof PushUnconfirmedError + if (isRulesRefusal(error)) { + const refusal = await refusalReason(plan, 'file', refreshPlan, () => keyIsStale(getFirestore(), keys)); + fail(refusal.message, refusal.atLimit); + } else { + fail( + error instanceof PushUnconfirmedError ? UNCONFIRMED_MESSAGE : error instanceof PushTooLongError ? 'That file name is too long to push.' : 'Failed to upload file. Please try again.' - ); + ); + } } finally { setIsUploadSubmitting(false); } @@ -161,7 +173,17 @@ export default function Push() { return (

    Push

    - {error &&
    {error}
    } + {error && ( +
    + {error.message} + {error.atLimit && PLAN_SHOWN && ( + <> + {' '} + {plan?.tier === 'pro' ? 'See your plan' : 'Upgrade to Pro'} + + )} +
    + )}
    diff --git a/apps/web/src/pages/Security.tsx b/apps/web/src/pages/Security.tsx index 96e55a6..5a81a69 100644 --- a/apps/web/src/pages/Security.tsx +++ b/apps/web/src/pages/Security.tsx @@ -9,7 +9,7 @@ import { LIMITS, SUPPORT_EMAIL } from '@/config/plan'; * Security, `/security`: the gist of docs/e2ee.md for the people it protects. What is * encrypted, what is not, what a lost password costs, and the recovery key. Public, like * Support, since the front page and Support link here and the reader may not have an - * account yet; the Plan page links here too. + * account yet; the Account page links here too. * * It says what is not protected as plainly as what is: the reason for a key made from the * password is that the user can see what it does, and a page that only listed the @@ -134,10 +134,10 @@ export function Security() {
    YOUR DEVICE ID

    - Each install of PushThat makes a random device ID, which the web app shows on the Plan{' '} - page. It goes with every push so that the device that sent one does not notify itself, and it says nothing about - the device: it replaced the device’s name (the one you gave it, its model name, or the browser’s - user agent), which pushes used to carry. + Each install of PushThat makes a random device ID, which the web app shows on the{' '} + Account page. It goes with every push so that the device that sent one does not + notify itself, and it says nothing about the device: it replaced the device’s name (the one you gave it, + its model name, or the browser’s user agent), which pushes used to carry.

    QUESTIONS
    diff --git a/apps/web/src/pages/Support.tsx b/apps/web/src/pages/Support.tsx index 42d291e..437b46f 100644 --- a/apps/web/src/pages/Support.tsx +++ b/apps/web/src/pages/Support.tsx @@ -2,7 +2,7 @@ import { Helmet } from 'react-helmet'; import { Link } from 'react-router'; import LegalContainer from '@/components/LegalContainer'; -import { LIMITS, PLAN_PAGE_LINKED, PRO_PRICE_USD, REFUND_DAYS, SUPPORT_EMAIL, formatMb } from '@/config/plan'; +import { LIMITS, PLAN_SHOWN, PRO_PRICE_USD, REFUND_DAYS, SUPPORT_EMAIL, formatMb } from '@/config/plan'; /** * Support, `/support`: how to reach a person, and where everything else is. Written for @@ -34,8 +34,8 @@ export default function Support() {

    To change your card, download an invoice or cancel, open{' '} - {PLAN_PAGE_LINKED ? Plan : 'Plan'} in the web app and choose Manage billing. Cancelling - stops the next renewal and keeps Pro until the year already paid for ends. + {PLAN_SHOWN ? Account : 'Account'} from the web app’s menu and choose Manage billing. + Cancelling stops the next renewal and keeps Pro until the year already paid for ends.

    @@ -70,9 +70,9 @@ export default function Support() {

    - To close your account, use Delete account, here or in the app’s menu: it - deletes the account at once, with everything pushed from it. If you cannot sign in, write to us from the - account’s address and we will delete it for you. + To close your account, use Delete account, here, from Account in the website’s + menu, or in the app’s menu: it deletes the account at once, with everything pushed from it. If you cannot sign + in, write to us from the account’s address and we will delete it for you.

    BUGS AND IDEAS
    diff --git a/apps/web/src/services/pushRefusal.ts b/apps/web/src/services/pushRefusal.ts index ee7d4df..4940c54 100644 --- a/apps/web/src/services/pushRefusal.ts +++ b/apps/web/src/services/pushRefusal.ts @@ -70,20 +70,28 @@ export const outdatedMessage = () => : 'PushThat refused this push. Reload the page to update PushThat, then try again.'; /** - * The sentence for a push the rules refused. `reread` is the page's read of the plan - * (`usePlan`'s `refresh`), which also keeps what it read, so the page's next check before - * sending sees the count that refused this one. If it cannot read, the plan the page + * Why the rules refused a push: the sentence, and whether the reason was the month's limit, + * which the Push page follows with a link to the plan. `reread` is the page's read of the + * plan (`usePlan`'s `refresh`), which also keeps what it read, so the page's next check + * before sending sees the count that refused this one. If it cannot read, the plan the page * already had decides. `keyIsStale` is the page's check of the account's key version; a * check that fails counts as not stale. */ -export async function refusalMessage( +export async function refusalReason( known: PlanReport | undefined, type: 'url' | 'file', reread: () => Promise, keyIsStale: () => Promise -): Promise { +): Promise<{ message: string; atLimit: boolean }> { const plan = (await reread().catch(() => undefined)) ?? known; - if (plan && atLimit(plan, type)) return limitMessage(plan, type); - if (await keyIsStale().catch(() => false)) return STALE_KEY_MESSAGE; - return outdatedMessage(); + if (plan && atLimit(plan, type)) return { message: limitMessage(plan, type), atLimit: true }; + if (await keyIsStale().catch(() => false)) return { message: STALE_KEY_MESSAGE, atLimit: false }; + return { message: outdatedMessage(), atLimit: false }; } + +/** + * `refusalReason`'s sentence alone, for where nothing can follow it with a link: the + * extension's notice for a page pushed from its menu (pagePush.ts). + */ +export const refusalMessage = async (...args: Parameters) => + (await refusalReason(...args)).message; diff --git a/apps/web/tests/pushRefusal.mjs b/apps/web/tests/pushRefusal.mjs index f4b1cac..efe7381 100644 --- a/apps/web/tests/pushRefusal.mjs +++ b/apps/web/tests/pushRefusal.mjs @@ -12,6 +12,7 @@ import { limitMessage, outdatedMessage, refusalMessage, + refusalReason, usedMessage, } from '../src/services/pushRefusal.ts'; @@ -53,6 +54,16 @@ describe('a refused push', () => { )); }); +// The Push page follows the limit's sentence, and only that one, with a link to the plan. +describe('whether a refusal was the limit', () => { + test('at the limit', async () => + assert.equal((await refusalReason(plan(49), 'url', read(plan(50)), stale)).atLimit, true)); + test('under a key a reset replaced', async () => + assert.equal((await refusalReason(plan(1), 'url', read(plan(1)), stale)).atLimit, false)); + test('out of date', async () => + assert.equal((await refusalReason(plan(1), 'url', read(plan(1)), current)).atLimit, false)); +}); + describe('the out-of-date sentence', () => { afterEach(() => delete globalThis.chrome); test('on the site, reload the page', () => assert.match(outdatedMessage(), /Reload the page/)); diff --git a/docs/account-deletion.md b/docs/account-deletion.md index a0f7f4c..d11d0e6 100644 --- a/docs/account-deletion.md +++ b/docs/account-deletion.md @@ -173,5 +173,5 @@ the call (`services/account.ts` says why), so it works the same signed in or out who has forgotten their password resets it first; someone who cannot sign in at all writes to support. -The website's and the extension's menu item leads to this page. The Android, iOS and macOS +The website's and the extension's Account page (from the menu) links to this page. The Android, iOS and macOS apps ask for the password in a dialog of their own and call the function directly. diff --git a/docs/billing.md b/docs/billing.md index b8ad453..bbc8751 100644 --- a/docs/billing.md +++ b/docs/billing.md @@ -13,7 +13,7 @@ Checkout happens on the web app only. The Android, iOS and macOS apps show the p | File size | 25 MB | 100 MB | | Files kept | 7 days | 30 days | -A file's retention is decided when it is pushed, from the tier at that moment, and nothing moves it afterwards: subscribing does not extend files already pushed, and a lapse does not shorten them. The Plan page says so. Re-stamping on a tier change would need a composite index on `userId` and `expiresAt`, and was not worth it for a push that is a hand-off, not storage. +A file's retention is decided when it is pushed, from the tier at that moment, and nothing moves it afterwards: subscribing does not extend files already pushed, and a lapse does not shorten them. The plan section of the Account page says so. Re-stamping on a tier change would need a composite index on `userId` and `expiresAt`, and was not worth it for a push that is a hand-off, not storage. Decided 2026-10-25. A URL push costs about $0.00002 to serve, so the URL limits are abuse caps. Files cost through download egress ($0.12 per GB past the project's free 100 GB a month) and storage; a Pro account at every limit at once is 10 GB a month, $1.50 to $2.70, against $22.16 kept after Stripe's fees (about 6.4% + 30 cents). That worst case was accepted knowingly; real use is far below it. Billing is yearly only because the fixed 30 cents takes a fifth of a $2 monthly charge. @@ -30,12 +30,12 @@ Set up on 2026-10-25. - **Product:** PushThat Pro, `prod_VVWkWeG0cIT51z`, tax code `txcd_10103000` (software as a service for personal use) - **Price:** $24 a year, `tax_behavior: exclusive`, `price_1UUVggEJNixT7uDaaVEcm1i6` -- **Customer portal:** `bpc_1UUVh2EJNixT7uDa2ChCsS3U`, the default configuration. Invoice history, the card, name, email and address editable, cancelling at the period's end with a reason asked for. Plan changes are off. Returns to `https://pushthat.link/plan`; terms and privacy links are `/terms` and `/privacy`. +- **Customer portal:** `bpc_1UUVh2EJNixT7uDa2ChCsS3U`, the default configuration. Invoice history, the card, name, email and address editable, cancelling at the period's end with a reason asked for. Plan changes are off. Returns to `https://pushthat.link/plan`, which the web app redirects to `/account`, where the plan now is; terms and privacy links are `/terms` and `/privacy`. - **Webhook:** `we_1UUVhAEJNixT7uDa9cl3QtUg` at `https://us-central1-push-that.cloudfunctions.net/stripeWebhook`, API version `2025-03-31.basil`, for `customer.subscription.created`, `updated`, `deleted`, `paused` and `resumed`, `invoice.paid`, `charge.refunded` and `charge.dispute.created`. Its signing secret is shown in the endpoint's page in Workbench. There is one Firebase project, `push-that`, so the sandbox's webhook points at production's function. That is deliberate until launch (decided 2026-10-25): production runs on the sandbox's three settings while billing is tested end to end against the deployed functions, then all three are replaced with the live account's at once. The three always come from the same environment, since the key picks the account checkouts are made in, the webhook secret verifies only that account's endpoint, and the price id must be a price in it. -While production is on the sandbox, anyone who reaches the Plan page can subscribe with a test card and get Pro, so the web app does not link to it or show it until launch. +While production is on the sandbox, anyone who sees the plan on the Account page can subscribe with a test card and get Pro, so the web app does not show it until launch. | Secret | Before launch | At launch | | ----------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------- | @@ -62,7 +62,7 @@ Set in the dashboard, since the API cannot: - Checkout terms (Settings, Checkout and Payment Links): `/terms` and `/privacy`. - Revenue recovery (Billing, Revenue recovery): Smart Retries, failed-payment emails and automatic card updates on. Matters more on a yearly plan, since a card often expires within the year. -Once the three secrets hold the live values, the functions are redeployed (they read the secret versions current at deploy) and `PLAN_PAGE_LINKED` is turned on in the web app. The sandbox's webhook endpoint points at the same function, so it was disabled at the switch (2026-10-25): its deliveries fail the live signature. Re-enable it only with the sandbox's three secrets back in place. +Once the three secrets hold the live values, the functions are redeployed (they read the secret versions current at deploy) and `PLAN_SHOWN` is turned on in the web app. The sandbox's webhook endpoint points at the same function, so it was disabled at the switch (2026-10-25): its deliveries fail the live signature. Re-enable it only with the sandbox's three secrets back in place. ## How it is built diff --git a/docs/e2ee.md b/docs/e2ee.md index 7a8583b..a30de6a 100644 --- a/docs/e2ee.md +++ b/docs/e2ee.md @@ -249,7 +249,7 @@ Existing accounts have the raw password as their Firebase password and plaintext The reason for a password-derived key is that the user can see it. The surfaces: - **Sign-up:** "Your password is the key to your pushes, and we cannot reset it for you. Save your recovery key." The recovery key is shown there and then. -- **Settings and the Plan page:** an "Encrypted" line with the device's `deviceId` and a link to the security page. +- **Settings, and the web app's Account page:** an "Encrypted" line with the device's `deviceId` and a link to the security page. - **Password reset:** the recovery key prompt and, without it, the sentence that the old pushes are gone, before anything is deleted. - **The site:** a `/security` page with the gist of this document: what is encrypted, what is not, what a lost password costs.