Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 88 additions & 120 deletions bun.lock

Large diffs are not rendered by default.

70 changes: 35 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@
},
"dependencies": {
"@ai-sdk/svelte": "^1.1.24",
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@297fbee",
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@a1b2dc2",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@df765cc",
"@appwrite.io/pink-legacy": "^1.0.3",
"@appwrite.io/pink-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-svelte@df765cc",
"@faker-js/faker": "^9.9.0",
"@plausible-analytics/tracker": "^0.4.4",
"@popperjs/core": "^2.11.8",
"@sentry/sveltekit": "^8.38.0",
"@sentry/sveltekit": "^8.55.0",
"@stripe/stripe-js": "^3.5.0",
"@threlte/core": "^8.3.1",
"@threlte/extras": "^9.7.1",
"ai": "^6.0.67",
"analytics": "^0.8.16",
"@threlte/core": "^8.4.1",
"@threlte/extras": "^9.8.1",
"ai": "^6.0.116",
"analytics": "^0.8.19",
"cron-parser": "^4.9.0",
"dayjs": "^1.11.13",
"dayjs": "^1.11.19",
"deep-equal": "^2.2.3",
"echarts": "^5.6.0",
"ignore": "^6.0.2",
"nanoid": "^5.1.5",
"nanoid": "^5.1.6",
"nanotar": "^0.1.1",
"pretty-bytes": "^6.1.1",
"remarkable": "^2.0.1",
Expand All @@ -48,43 +48,43 @@
"tippy.js": "^6.3.7"
},
"devDependencies": {
"@eslint/compat": "^1.3.1",
"@eslint/js": "^9.31.0",
"@eslint/compat": "^1.4.1",
"@eslint/js": "^9.39.4",
"@melt-ui/pp": "^0.3.2",
"@melt-ui/svelte": "^0.86.5",
"@playwright/test": "^1.55.1",
"@sveltejs/adapter-static": "^3.0.8",
"@sveltejs/kit": "^2.49.5",
"@sveltejs/vite-plugin-svelte": "^5.0.3",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/svelte": "^5.2.8",
"@melt-ui/svelte": "^0.86.6",
"@playwright/test": "^1.58.2",
"@sveltejs/adapter-static": "^3.0.10",
"@sveltejs/kit": "^2.53.4",
"@sveltejs/vite-plugin-svelte": "^5.1.1",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/svelte": "^5.3.1",
"@testing-library/user-event": "^14.6.1",
"@types/deep-equal": "^1.0.4",
"@types/remarkable": "^2.0.8",
"@types/three": "^0.182.0",
"@typescript-eslint/eslint-plugin": "^8.28.0",
"@typescript-eslint/parser": "^8.28.0",
"@typescript-eslint/eslint-plugin": "^8.56.1",
"@typescript-eslint/parser": "^8.56.1",
"@vitest/ui": "^3.2.4",
"color": "^5.0.0",
"eslint": "^9.31.0",
"eslint-config-prettier": "^10.1.0",
"eslint-plugin-svelte": "^3.3.3",
"globals": "^16.0.0",
"color": "^5.0.3",
"eslint": "^9.39.4",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-svelte": "^3.15.0",
"globals": "^16.5.0",
"jsdom": "^26.1.0",
"kleur": "^4.1.5",
"prettier": "^3.5.3",
"prettier-plugin-svelte": "^3.3.3",
"sass": "^1.86.0",
"svelte": "^5.25.3",
"svelte-check": "^4.1.5",
"prettier": "^3.8.1",
"prettier-plugin-svelte": "^3.5.1",
"sass": "^1.97.3",
"svelte": "^5.53.7",
"svelte-check": "^4.4.5",
"svelte-preprocess": "^6.0.3",
"svelte-sequential-preprocessor": "^2.0.2",
"tldts": "^7.0.7",
"svelte-sequential-preprocessor": "^2.0.3",
"tldts": "^7.0.25",
"tslib": "^2.8.1",
"typescript": "^5.8.2",
"typescript-eslint": "^8.30.1",
"vite": "^7.0.6",
"typescript": "^5.9.3",
"typescript-eslint": "^8.56.1",
"vite": "^7.3.1",
"vitest": "^3.2.4"
},
"overrides": {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/actions/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ export enum Submit {
MessagingTopicSubscriberDelete = 'submit_messaging_topic_subscriber_delete',
ApplyQuickFilter = 'submit_apply_quick_filter',
RequestBAA = 'submit_request_baa',
BAAAddonEnable = 'submit_baa_addon_enable',
BAAAddonDisable = 'submit_baa_addon_disable',
RequestSoc2 = 'submit_request_soc2',
SiteCreate = 'submit_site_create',
SiteDelete = 'submit_site_delete',
Expand Down
3 changes: 2 additions & 1 deletion src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ export enum Dependencies {
MESSAGING_TOPIC_SUBSCRIBERS = 'dependency:messaging_topic_subscribers',
SITE = 'dependency:site',
SITES = 'dependency:sites',
SITES_DOMAINS = 'dependency:sites_domains'
SITES_DOMAINS = 'dependency:sites_domains',
ADDONS = 'dependency:addons'
}

export const defaultScopes: string[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const load: PageLoad = async ({ parent, depends, url, route }) => {
depends(Dependencies.CREDIT);
depends(Dependencies.INVOICES);
depends(Dependencies.ADDRESS);
depends(Dependencies.ADDONS);
// aggregation reloads on page param changes
depends(Dependencies.BILLING_AGGREGATION);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,17 @@
};

// addons (additional members, projects, etc.)
const billingAddonNames: Record<string, string> = {
addon_baa: 'HIPAA BAA'
};

const addons = (currentAggregation?.resources || [])
.filter((r) => r.amount > 0 && currentPlan?.addons?.[r.resourceId]?.price > 0)
.filter(
(r) =>
r.amount > 0 &&
(currentPlan?.addons?.[r.resourceId]?.price > 0 ||
r.resourceId.startsWith('addon_'))
)
.map((addon) => ({
id: `addon-${addon.resourceId}`,
expandable: false,
Expand All @@ -260,7 +269,8 @@
? 'Additional members'
: addon.resourceId === 'projects'
? 'Additional projects'
: `${addon.resourceId} overage (${formatNum(addon.value)})`,
: (billingAddonNames[addon.resourceId] ??
`${addon.resourceId} overage (${formatNum(addon.value)})`),
usage: '',
price: formatCurrency(addon.amount)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import { sdk } from '$lib/stores/sdk';
import { members, organization } from '$lib/stores/organization';
import { projects } from '../store';
import { invalidate } from '$app/navigation';
import { goto, invalidate } from '$app/navigation';
import { resolve } from '$app/paths';
import { Dependencies } from '$lib/constants';
import { onMount } from 'svelte';
import { page } from '$app/state';
import Delete from './deleteOrganizationModal.svelte';
import DownloadDPA from './downloadDPA.svelte';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
Expand All @@ -22,8 +24,66 @@
let name: string;
let showDelete = false;

onMount(() => {
onMount(async () => {
name = $organization.name;

if (page.url.searchParams.get('type') === 'validate-addon') {
let addonId = page.url.searchParams.get('addonId');

// Fall back to listing addons if addonId is missing or invalid
if (!addonId || addonId === 'undefined') {
try {
const addons = await sdk.forConsole.organizations.listAddons({
organizationId: $organization.$id
});
const pending = addons.addons.find(
(a) => a.key === 'baa' && a.status === 'pending'
);
addonId = pending?.$id ?? null;
} catch {
addonId = null;
}
Comment on lines +35 to +45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid reporting success when addon lookup fails.

If listAddons fails (network/5xx/auth), the code sets addonId = null and then shows “BAA addon has been enabled” in the fallback branch. That can hide real failures and mislead users.

Proposed fix
 onMount(async () => {
     name = $organization.name;

     if (page.url.searchParams.get('type') === 'validate-addon') {
         let addonId = page.url.searchParams.get('addonId');
+        let lookupFailed = false;

         // Fall back to listing addons if addonId is missing or invalid
         if (!addonId || addonId === 'undefined') {
             try {
                 const addons = await sdk.forConsole.organizations.listAddons({
                     organizationId: $organization.$id
                 });
                 const pending = addons.addons.find(
                     (a) => a.key === 'baa' && a.status === 'pending'
                 );
                 addonId = pending?.$id ?? null;
-            } catch {
-                addonId = null;
+            } catch (e) {
+                lookupFailed = true;
+                addNotification({
+                    message: e?.message ?? 'Unable to verify BAA addon status. Please retry.',
+                    type: 'error'
+                });
             }
         }
+
+        if (lookupFailed) {
+            const settingsUrl = resolve('/(console)/organization-[organization]/settings', {
+                organization: $organization.$id
+            });
+            await goto(settingsUrl, { replaceState: true });
+            return;
+        }

         if (addonId) {
             // existing logic...

Also applies to: 80-89

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/`(console)/organization-[organization]/settings/+page.svelte
around lines 35 - 45, The current try/catch around
sdk.forConsole.organizations.listAddons swallows errors and sets addonId = null,
which later causes the UI to show “BAA addon has been enabled” incorrectly;
instead, catch should record the failure (e.g., set an addonLookupError flag or
store the caught error) rather than conflating “no addon” and “lookup failed”,
and update the UI logic that reads addonId/pending to check this failure flag
before rendering the success/fallback branch; specifically, modify the block
using listAddons, pending, and addonId so the catch saves the error (or boolean)
and the downstream rendering avoids reporting success when addonLookupError is
set.

}

if (addonId) {
try {
await sdk.forConsole.organizations.validateAddonPayment({
organizationId: $organization.$id,
addonId
});
await Promise.all([
invalidate(Dependencies.ADDONS),
invalidate(Dependencies.ORGANIZATION)
]);
addNotification({
message: 'BAA addon has been enabled',
type: 'success'
});
} catch (e) {
// If addon not found, payment webhook may have already activated it
if (e?.type === 'addon_not_found' || e?.code === 404) {
await Promise.all([
invalidate(Dependencies.ADDONS),
invalidate(Dependencies.ORGANIZATION)
]);
addNotification({
message: 'BAA addon has been enabled',
type: 'success'
});
} else {
addNotification({
message: e.message,
type: 'error'
});
}
}
}

const settingsUrl = resolve('/(console)/organization-[organization]/settings', {
organization: $organization.$id
});
await goto(settingsUrl, { replaceState: true });
Comment on lines +48 to +85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a user returns from the 3DS payment flow with ?type=validate-addon in the URL but no valid addonId can be resolved (either missing from the URL or no pending BAA addon exists), the code silently redirects to settings without showing any notification. The user has no indication of whether their BAA setup succeeded or failed.

Consider adding an error notification when addonId is null:

Suggested change
if (addonId) {
try {
await sdk.forConsole.organizations.validateAddonPayment({
organizationId: $organization.$id,
addonId
});
await Promise.all([
invalidate(Dependencies.ADDONS),
invalidate(Dependencies.ORGANIZATION)
]);
addNotification({
message: 'BAA addon has been enabled',
type: 'success'
});
} catch (e) {
// If addon not found, payment webhook may have already activated it
if (e?.type === 'addon_not_found' || e?.code === 404) {
await Promise.all([
invalidate(Dependencies.ADDONS),
invalidate(Dependencies.ORGANIZATION)
]);
addNotification({
message: 'BAA addon has been enabled',
type: 'success'
});
} else {
addNotification({
message: e.message,
type: 'error'
});
}
}
}
const settingsUrl = resolve('/(console)/organization-[organization]/settings', {
organization: $organization.$id
});
await goto(settingsUrl, { replaceState: true });
if (addonId) {
try {
await sdk.forConsole.organizations.validateAddonPayment({
organizationId: $organization.$id,
addonId
});
await Promise.all([
invalidate(Dependencies.ADDONS),
invalidate(Dependencies.ORGANIZATION)
]);
addNotification({
message: 'BAA addon has been enabled',
type: 'success'
});
} catch (e) {
// If addon not found, payment webhook may have already activated it
if (e?.type === 'addon_not_found' || e?.code === 404) {
await Promise.all([
invalidate(Dependencies.ADDONS),
invalidate(Dependencies.ORGANIZATION)
]);
addNotification({
message: 'BAA addon has been enabled',
type: 'success'
});
} else {
addNotification({
message: e.message,
type: 'error'
});
}
}
} else {
addNotification({
message: 'Could not verify BAA payment. Please check your BAA status or contact support.',
type: 'error'
});
}

}
});

async function updateName() {
Expand Down Expand Up @@ -75,7 +135,7 @@

{#if isCloud}
<DownloadDPA />
<Baa locale={data.locale} countryList={data.countryList} />
<Baa addons={data.addons} />
<Soc2 locale={data.locale} countryList={data.countryList} />
{/if}

Expand Down
13 changes: 11 additions & 2 deletions src/routes/(console)/organization-[organization]/settings/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,30 @@ import { isCloud } from '$lib/system';
export const load: PageLoad = async ({ depends, params, parent }) => {
const { countryList, locale } = await parent();
depends(Dependencies.ORGANIZATION);
depends(Dependencies.ADDONS);

const [projects, invoices] = await Promise.all([
const [projects, invoices, addons] = await Promise.all([
sdk.forConsole.projects.list({
queries: [Query.equal('teamId', params.organization), Query.select(['$id', 'name'])]
}),
isCloud
? sdk.forConsole.organizations.listInvoices({
organizationId: params.organization
})
: undefined
: undefined,
isCloud
? sdk.forConsole.organizations
.listAddons({
organizationId: params.organization
})
.catch(() => null)
: null
]);

return {
projects,
invoices,
addons,
countryList,
locale
};
Expand Down
Loading
Loading