From 56f41cf46aee832c687a69d38537903d50c5c5c6 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Fri, 27 Nov 2026 19:38:20 +0700 Subject: [PATCH 1/2] feat(pricing): send a guest who picks Team to sign in --- docs/architecture.md | 2 +- .../js/components/pricing/checkout-response.ts | 10 +++++++++- .../js/components/pricing/use-checkout.ts | 6 ++++++ resources/js/lib/problem.ts | 5 ++++- tests/js/checkout.test.ts | 18 ++++++++++++++++++ 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index 13e4134a..42638dd9 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -217,7 +217,7 @@ in production, shared with every page as the `apiOrigin` prop and read through | Endpoint | Sends | Returns | | --- | --- | --- | | `GET /v2/pricing` | nothing | `{country, plans: [{plan, cycle, currency, amount, per_seat, min_seats, max_seats, features, discount_percent, discounted_amount, discounted_total}], education: {open}}` | -| `POST /v2/checkouts` | `{plan, cycle, locale, seats?, discount_code?, attribution?}` | 201 `{url}`, opened in Polar's overlay | +| `POST /v2/checkouts` | `{plan, cycle, locale, seats?, discount_code?, attribution?}` | 201 `{url}`, opened in Polar's overlay; for a Team guest, 403 `sign_in_required` with `sign_in_url`, which the page goes to | | `POST /v2/discounts/preview` | `{code}` | `{valid, amount_type?, amount?, currency?}` | | `POST /v2/newsletter/subscriptions` | `{email, locale, turnstile_token}` | 202, whether or not the address was new | | `GET /v2/newsletter/stats` | nothing | `{subscribers}` | diff --git a/resources/js/components/pricing/checkout-response.ts b/resources/js/components/pricing/checkout-response.ts index 9e4d90a4..c6bc5089 100644 --- a/resources/js/components/pricing/checkout-response.ts +++ b/resources/js/components/pricing/checkout-response.ts @@ -9,7 +9,11 @@ export interface CheckoutStrings { seats: string; } -export type CheckoutOutcome = { kind: 'open'; url: string } | { kind: 'error'; message: string }; +export type CheckoutOutcome = + | { kind: 'open'; url: string } + // A guest's Team checkout: the portal's sign-in, which comes back to the purchase. + | { kind: 'signIn'; url: string } + | { kind: 'error'; message: string }; export function checkoutOutcome(status: number, data: unknown, strings: CheckoutStrings): CheckoutOutcome { if (status >= 200 && status < 300) { @@ -24,6 +28,10 @@ export function checkoutOutcome(status: number, data: unknown, strings: Checkout const problem = problemOf(data); + if (status === 403 && problem.code === 'sign_in_required' && problem.signInUrl?.startsWith('https://')) { + return { kind: 'signIn', url: problem.signInUrl }; + } + if (status === 422 && problem.code === 'plan_unavailable') { return { kind: 'error', message: strings.planUnavailable }; } diff --git a/resources/js/components/pricing/use-checkout.ts b/resources/js/components/pricing/use-checkout.ts index 7ae37437..a8da759c 100644 --- a/resources/js/components/pricing/use-checkout.ts +++ b/resources/js/components/pricing/use-checkout.ts @@ -104,6 +104,12 @@ export function useCheckout() { return; } + if (outcome.kind === 'signIn') { + window.location.assign(outcome.url); + + return; + } + try { await withTimeout(sdk, SDK_WAIT_MS); await openCheckoutOverlay(outcome.url, overlayTheme()); diff --git a/resources/js/lib/problem.ts b/resources/js/lib/problem.ts index 2134f786..2105d18e 100644 --- a/resources/js/lib/problem.ts +++ b/resources/js/lib/problem.ts @@ -1,9 +1,11 @@ -// tablepro-cloud answers errors as RFC 9457 problems: a stable `code`, and for `validation_failed` the fields in `errors[].location`. +// tablepro-cloud answers errors as RFC 9457 problems: a stable `code`, for `validation_failed` the fields in `errors[].location`, +// and for `sign_in_required` the `sign_in_url` to go to. // Their `title` and `detail` are English, so the pages show their own catalog's words instead. export interface Problem { code: string | null; locations: string[]; + signInUrl: string | null; } export function problemOf(data: unknown): Problem { @@ -17,5 +19,6 @@ export function problemOf(data: unknown): Problem { return typeof location === 'string' ? [location] : []; }), + signInUrl: typeof body.sign_in_url === 'string' ? body.sign_in_url : null, }; } diff --git a/tests/js/checkout.test.ts b/tests/js/checkout.test.ts index 2e685f54..e2b7d904 100644 --- a/tests/js/checkout.test.ts +++ b/tests/js/checkout.test.ts @@ -46,6 +46,24 @@ test('each problem code api.md lists for POST /v2/checkouts has its own message, assert.deepEqual(checkoutOutcome(422, null, strings), { kind: 'error', message: strings.failed }); }); +test('a guest who picks Team goes to sign in when the answer names an https sign-in URL', () => { + const signIn = 'https://account.tablepro.app/teams/new?cycle=yearly&locale=vi&seats=7'; + const failed = { kind: 'error', message: strings.failed }; + + assert.deepEqual(checkoutOutcome(403, problem(403, 'sign_in_required', { sign_in_url: signIn }), strings), { kind: 'signIn', url: signIn }); + + // Anything short of a sign_in_required 403 with an https URL is a checkout that did not start. + assert.deepEqual(checkoutOutcome(403, problem(403, 'sign_in_required'), strings), failed); + assert.deepEqual(checkoutOutcome(403, problem(403, 'sign_in_required', { sign_in_url: 'http://account.tablepro.app/teams/new' }), strings), failed); + assert.deepEqual(checkoutOutcome(403, problem(403, 'sign_in_required', { sign_in_url: 'javascript:alert(1)' }), strings), failed); + assert.deepEqual(checkoutOutcome(403, problem(403, 'sign_in_required', { sign_in_url: 42 }), strings), failed); + assert.deepEqual(checkoutOutcome(403, problem(403, 'forbidden', { sign_in_url: signIn }), strings), failed); + assert.deepEqual(checkoutOutcome(422, problem(422, 'sign_in_required', { sign_in_url: signIn }), strings), failed); + + // An API that still sells Team to guests answers with Polar's checkout, which opens as before. + assert.deepEqual(checkoutOutcome(201, { url: 'https://polar.sh/checkout/team' }, strings), { kind: 'open', url: 'https://polar.sh/checkout/team' }); +}); + test('a 422 on seats names the range only once /v2/pricing gave a maximum, and otherwise asks for fewer', () => { const range = (max: number) => `Choose between 5 and ${max} seats.`; From 18330ad5b857df7a8dbbda48b94d49180ea56811 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Fri, 27 Nov 2026 20:52:18 +0700 Subject: [PATCH 2/2] fix(deps): update symfony/http-kernel, mailer and routing for the 2026-11-25 advisories CVE-2026-133743, CVE-2026-133746, CVE-2026-133751, CVE-2026-133754, CVE-2026-133755 --- composer.lock | 96 +++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/composer.lock b/composer.lock index 4d16e7d0..7823cf43 100644 --- a/composer.lock +++ b/composer.lock @@ -446,26 +446,26 @@ }, { "name": "egulias/email-validator", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "d42c8731f0624ad6bdc8d3e5e9a4524f68801cfa" + "reference": "9bef884e12278a7b89b64adbfb9379c021d3c102" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/d42c8731f0624ad6bdc8d3e5e9a4524f68801cfa", - "reference": "d42c8731f0624ad6bdc8d3e5e9a4524f68801cfa", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/9bef884e12278a7b89b64adbfb9379c021d3c102", + "reference": "9bef884e12278a7b89b64adbfb9379c021d3c102", "shasum": "" }, "require": { - "doctrine/lexer": "^2.0 || ^3.0", + "doctrine/lexer": "^3.0.3", "php": ">=8.1", - "symfony/polyfill-intl-idn": "^1.26" + "symfony/polyfill-intl-idn": "^1.43" }, "require-dev": { - "phpunit/phpunit": "^10.2", - "vimeo/psalm": "^5.12" + "phpunit/phpunit": "^10.5.67", + "vimeo/psalm": "^5.26.1" }, "suggest": { "ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation" @@ -501,7 +501,7 @@ ], "support": { "issues": "https://github.com/egulias/EmailValidator/issues", - "source": "https://github.com/egulias/EmailValidator/tree/4.0.4" + "source": "https://github.com/egulias/EmailValidator/tree/4.0.5" }, "funding": [ { @@ -509,7 +509,7 @@ "type": "github" } ], - "time": "2025-03-06T22:45:56+00:00" + "time": "2026-11-22T16:52:20+00:00" }, { "name": "fruitcake/php-cors", @@ -4590,16 +4590,16 @@ }, { "name": "symfony/http-foundation", - "version": "v8.1.11", + "version": "v8.1.12", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "30fa3efe6e736b0d06f5331cc6abe813582c0a26" + "reference": "8061f6d6b6ec8fc5075b5f39c8ddca83110da9c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/30fa3efe6e736b0d06f5331cc6abe813582c0a26", - "reference": "30fa3efe6e736b0d06f5331cc6abe813582c0a26", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/8061f6d6b6ec8fc5075b5f39c8ddca83110da9c6", + "reference": "8061f6d6b6ec8fc5075b5f39c8ddca83110da9c6", "shasum": "" }, "require": { @@ -4647,7 +4647,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v8.1.11" + "source": "https://github.com/symfony/http-foundation/tree/v8.1.12" }, "funding": [ { @@ -4667,20 +4667,20 @@ "type": "tidelift" } ], - "time": "2026-11-04T08:39:20+00:00" + "time": "2026-11-24T18:01:43+00:00" }, { "name": "symfony/http-kernel", - "version": "v8.1.11", + "version": "v8.1.12", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "460658504e26a2794aa614b4fbe6cf9bac2076fe" + "reference": "cd6146b67375122b050c25cfb1a49b6fe6fc4adb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/460658504e26a2794aa614b4fbe6cf9bac2076fe", - "reference": "460658504e26a2794aa614b4fbe6cf9bac2076fe", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/cd6146b67375122b050c25cfb1a49b6fe6fc4adb", + "reference": "cd6146b67375122b050c25cfb1a49b6fe6fc4adb", "shasum": "" }, "require": { @@ -4689,11 +4689,11 @@ "symfony/deprecation-contracts": "^2.5|^3", "symfony/error-handler": "^7.4|^8.0", "symfony/event-dispatcher": "^7.4|^8.0", - "symfony/http-foundation": "^7.4|^8.0", + "symfony/http-foundation": "^7.4.24|^8.1.12", "symfony/polyfill-ctype": "^1.8" }, "conflict": { - "symfony/dependency-injection": "<8.1", + "symfony/dependency-injection": "<8.1.12", "symfony/flex": "<2.10", "symfony/http-client-contracts": "<2.5", "symfony/serializer": "<7.4.15|>=8.0,<8.0.15|>=8.1,<8.1.2", @@ -4757,7 +4757,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v8.1.11" + "source": "https://github.com/symfony/http-kernel/tree/v8.1.12" }, "funding": [ { @@ -4777,20 +4777,20 @@ "type": "tidelift" } ], - "time": "2026-11-04T11:29:46+00:00" + "time": "2026-11-25T09:27:11+00:00" }, { "name": "symfony/mailer", - "version": "v8.1.10", + "version": "v8.1.12", "source": { "type": "git", "url": "https://github.com/symfony/mailer.git", - "reference": "4ba81a8f04fbf0bb1691f7bff760b301f1956fd7" + "reference": "535515ab0bdc7efbfb7161fe23c6bf7434e26b93" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mailer/zipball/4ba81a8f04fbf0bb1691f7bff760b301f1956fd7", - "reference": "4ba81a8f04fbf0bb1691f7bff760b301f1956fd7", + "url": "https://api.github.com/repos/symfony/mailer/zipball/535515ab0bdc7efbfb7161fe23c6bf7434e26b93", + "reference": "535515ab0bdc7efbfb7161fe23c6bf7434e26b93", "shasum": "" }, "require": { @@ -4837,7 +4837,7 @@ "description": "Helps sending emails", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/mailer/tree/v8.1.10" + "source": "https://github.com/symfony/mailer/tree/v8.1.12" }, "funding": [ { @@ -4857,20 +4857,20 @@ "type": "tidelift" } ], - "time": "2026-10-23T17:06:53+00:00" + "time": "2026-11-24T18:01:43+00:00" }, { "name": "symfony/mime", - "version": "v8.1.10", + "version": "v8.1.12", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "8d1232052c9cdef170ed9608b3147bca4f61ff69" + "reference": "4bf4ecda5ac1f1db2e9a0793675d2fc69d7cc864" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/8d1232052c9cdef170ed9608b3147bca4f61ff69", - "reference": "8d1232052c9cdef170ed9608b3147bca4f61ff69", + "url": "https://api.github.com/repos/symfony/mime/zipball/4bf4ecda5ac1f1db2e9a0793675d2fc69d7cc864", + "reference": "4bf4ecda5ac1f1db2e9a0793675d2fc69d7cc864", "shasum": "" }, "require": { @@ -4923,7 +4923,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v8.1.10" + "source": "https://github.com/symfony/mime/tree/v8.1.12" }, "funding": [ { @@ -4943,7 +4943,7 @@ "type": "tidelift" } ], - "time": "2026-10-28T17:58:38+00:00" + "time": "2026-11-24T16:43:41+00:00" }, { "name": "symfony/polyfill-ctype", @@ -6004,16 +6004,16 @@ }, { "name": "symfony/routing", - "version": "v8.1.11", + "version": "v8.1.12", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "f3fefc6cad3748d538be970ca81b71f06d7aa8b3" + "reference": "55df7515cdd7769113e46dbeba7942c1ccab8590" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/f3fefc6cad3748d538be970ca81b71f06d7aa8b3", - "reference": "f3fefc6cad3748d538be970ca81b71f06d7aa8b3", + "url": "https://api.github.com/repos/symfony/routing/zipball/55df7515cdd7769113e46dbeba7942c1ccab8590", + "reference": "55df7515cdd7769113e46dbeba7942c1ccab8590", "shasum": "" }, "require": { @@ -6060,7 +6060,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v8.1.11" + "source": "https://github.com/symfony/routing/tree/v8.1.12" }, "funding": [ { @@ -6080,7 +6080,7 @@ "type": "tidelift" } ], - "time": "2026-11-04T08:39:20+00:00" + "time": "2026-11-24T18:01:43+00:00" }, { "name": "symfony/service-contracts", @@ -6514,16 +6514,16 @@ }, { "name": "symfony/var-dumper", - "version": "v8.1.10", + "version": "v8.1.12", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "3412a5af7d34a19515a77890fc804fe8e50d1a4f" + "reference": "f681b9e07afd027556e5b1eda96fcad5a27a2b98" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/3412a5af7d34a19515a77890fc804fe8e50d1a4f", - "reference": "3412a5af7d34a19515a77890fc804fe8e50d1a4f", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/f681b9e07afd027556e5b1eda96fcad5a27a2b98", + "reference": "f681b9e07afd027556e5b1eda96fcad5a27a2b98", "shasum": "" }, "require": { @@ -6577,7 +6577,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v8.1.10" + "source": "https://github.com/symfony/var-dumper/tree/v8.1.12" }, "funding": [ { @@ -6597,7 +6597,7 @@ "type": "tidelift" } ], - "time": "2026-10-26T21:55:04+00:00" + "time": "2026-11-12T10:29:11+00:00" }, { "name": "symfony/yaml",