Skip to content
Merged
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
1 change: 1 addition & 0 deletions apps/billing-web/e2e/fixtures/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ const POST_REPLIES = new Map<string, ScenarioReply>([
body: {
token: 'e2e-workspace-jwt',
expires_at: inAnHour(),
user_id: 'uid-1',
permissions: ['workspace:read', 'billing:write'],
role: 'owner',
workspace: {
Expand Down
1 change: 1 addition & 0 deletions apps/billing-web/e2e/fixtures/scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function capabilitiesWith(
can_manage_auto_top_up: false,
can_manage_members: false,
can_manage_subscription: true,
can_open_plans: true,
can_delete_workspace: false,
can_leave_workspace: false,
can_manage_billing: false,
Expand Down
1 change: 1 addition & 0 deletions apps/billing-web/e2e/full-page-reconciliation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ for (const { name, pending, lands } of [
body: {
token: 'e2e-workspace-jwt-2',
expires_at: new Date(Date.now() + 3_600_000).toISOString(),
user_id: 'uid-1',
permissions: ['workspace:read', 'billing:write'],
role: 'owner',
workspace: {
Expand Down
2 changes: 2 additions & 0 deletions apps/billing-web/e2e/workspace-binding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test('an entry link naming a workspace mints for it, names it in the shell, and
body: {
token: 'e2e-team-jwt',
expires_at: new Date(Date.now() + 3_600_000).toISOString(),
user_id: 'uid-1',
permissions: ['workspace:read', 'billing:write'],
role: 'owner',
workspace: { id: 'ws_team_e2e', name: 'Acme Team', type: 'team' }
Expand Down Expand Up @@ -93,6 +94,7 @@ test('reloading a tab whose workspace was deleted surfaces that reason instead o
body: {
token: 'e2e-team-jwt',
expires_at: new Date(Date.now() + 3_600_000).toISOString(),
user_id: 'uid-1',
permissions: ['workspace:read', 'billing:write'],
role: 'owner',
workspace: { id: 'ws_team_e2e', name: 'Acme Team', type: 'team' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const MINTED = {
token: 'jwt-1',
permissions: ['workspace:read'],
expires_at: new Date(Date.now() + 90 * 60_000).toISOString(),
user_id: 'uid-1',
workspace: { id: 'ws-1', name: 'Personal', type: 'personal' },
role: 'owner'
}
Expand Down
1 change: 1 addition & 0 deletions apps/billing-web/src/session/billingWebSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function mintedResponse(): Response {
token: 'jwt-1',
permissions: ['workspace:read'],
expires_at: new Date(Date.now() + 90 * 60_000).toISOString(),
user_id: 'uid-1',
workspace: { id: 'ws-1', name: 'Personal', type: 'personal' },
role: 'owner'
})
Expand Down
1 change: 1 addition & 0 deletions apps/billing-web/src/test/fakeBillingClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export function createFakeBillingClient(
can_manage_auto_top_up: false,
can_manage_members: false,
can_manage_subscription: false,
can_open_plans: false,
can_delete_workspace: false,
can_leave_workspace: false,
can_manage_billing: false,
Expand Down
1 change: 1 addition & 0 deletions apps/website/e2e/fixtures/buyCredits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const CAPABILITIES: BillingCapabilitiesResponse = {
can_manage_auto_top_up: false,
can_manage_members: false,
can_manage_subscription: false,
can_open_plans: false,
can_delete_workspace: false,
can_leave_workspace: false,
can_manage_billing: false,
Expand Down
1 change: 1 addition & 0 deletions apps/website/e2e/fixtures/modelsAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const test = base.extend<{
jsonRoute({
token: MODELS_WORKSPACE_TOKEN,
expires_at: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
user_id: 'uid-1',
workspace: {
id: MODELS_WORKSPACE_ID,
name: 'Personal',
Expand Down
1 change: 1 addition & 0 deletions apps/website/e2e/fixtures/workshopAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export async function mockWorkspaceMint(page: Page) {
jsonRoute({
token: 'mock-workspace-jwt',
expires_at: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
user_id: 'uid-1',
workspace: { id: 'ws-personal', name: 'Personal', type: 'personal' },
role: 'owner',
permissions: []
Expand Down
1 change: 1 addition & 0 deletions apps/website/e2e/workshop-api-key-workspace-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async function mockWorkspaces(page: Page) {
body: JSON.stringify({
token: 'mock-team-jwt',
expires_at: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
user_id: 'uid-1',
workspace: { id: TEAM.id, name: TEAM.name, type: TEAM.type },
role: TEAM.role,
permissions: []
Expand Down
1 change: 1 addition & 0 deletions apps/website/e2e/workshop-workspace-switch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ async function mockWorkspaces(page: Page) {
body: JSON.stringify({
token: 'mock-team-jwt',
expires_at: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
user_id: 'uid-1',
workspace: { id: TEAM.id, name: TEAM.name, type: TEAM.type },
role: TEAM.role,
permissions: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function mintBody(token: string) {
token,
permissions: ['workspace:read'],
expires_at: new Date(Date.now() + 90 * 60 * 1000).toISOString(),
user_id: 'uid-1',
workspace: { id: 'ws-1', name: 'Personal', type: 'personal' },
role: 'owner'
}
Expand Down
1 change: 1 addition & 0 deletions apps/website/src/config/workshop-billing-sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const CLOUD_BODIES: Readonly<Record<string, unknown>> = {
can_edit_workspace: false,
can_manage_auto_top_up: false,
can_manage_subscription: false,
can_open_plans: false,
can_run_workflows: false,
can_upgrade: false,
can_subscribe_self_serve: false,
Expand Down
2 changes: 2 additions & 0 deletions browser_tests/fixtures/data/billingCapabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function createBillingCapabilities(
can_edit_workspace: false,
can_manage_auto_top_up: false,
can_manage_subscription: true,
can_open_plans: true,
can_run_workflows: false,
can_upgrade: false,
can_reactivate: false,
Expand Down Expand Up @@ -71,6 +72,7 @@ export function createWorkspaceBillingCapabilities(
can_invite_members: isOwner,
can_manage_members: isOwner,
can_manage_subscription: isOwner,
can_open_plans: isOwner,
can_reactivate: isOwner,
can_subscribe_self_serve: isOwner,
can_top_up: isOwner,
Expand Down
1 change: 1 addition & 0 deletions browser_tests/fixtures/data/webSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const WEB_SESSION: WebSessionResponse = {
export const WEB_SESSION_MINT: ExchangeTokenResponse = {
token: 'session-jwt-e2e',
expires_at: '2099-01-01T00:00:00Z',
user_id: 'uid-1',
workspace: {
id: TEAM_WORKSPACE.id,
name: TEAM_WORKSPACE.name,
Expand Down
1 change: 1 addition & 0 deletions browser_tests/fixtures/data/workspaceAuthFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function makeWorkspaceTokenResponse(
return {
token,
expires_at: new Date(Date.now() + expiresInMs).toISOString(),
user_id: 'uid-1',
workspace: {
id: workspace.id,
name: workspace.name,
Expand Down
1 change: 1 addition & 0 deletions browser_tests/fixtures/utils/workspaceMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function mockWorkspaceTokenMint(
jsonRoute({
token: 'mock-workspace-token',
expires_at: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
user_id: 'uid-1',
workspace: { id: ws.id, name: ws.name, type: ws.type },
role: ws.role,
permissions: []
Expand Down
1 change: 1 addition & 0 deletions browser_tests/fixtures/workspaceSwitcherFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const workspaceSwitcherTest = comfyPageFixture.extend<{
const response: WorkspaceTokenResponse = {
token: `mock-workspace-token-${workspace.id}`,
expires_at: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
user_id: 'uid-1',
workspace: {
id: workspace.id,
name: workspace.name,
Expand Down
1 change: 1 addition & 0 deletions browser_tests/tests/agent/agentPanelMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ async function mockAgentBoot(
jsonRoute({
token: 'mock-workspace-token',
expires_at: '2100-01-01T00:00:00.000Z',
user_id: 'uid-1',
workspace: { id: 'ws-personal', name: 'Personal', type: 'personal' },
role: 'owner',
permissions: ['owner:*']
Expand Down
1 change: 1 addition & 0 deletions browser_tests/tests/authAccountSwitch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ test.describe('Cloud account switch', { tag: '@cloud' }, () => {
const response = {
token: `workspace-jwt-${account.id}`,
expires_at: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
user_id: 'uid-1',
workspace: {
id: TEAM_WORKSPACE.id,
name: TEAM_WORKSPACE.name,
Expand Down
1 change: 1 addition & 0 deletions browser_tests/tests/currentUserPopoverCredits.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const mockListWorkspacesResponse: { workspaces: WorkspaceWithRole[] } = {
const mockTokenResponse: WorkspaceTokenResponse = {
token: 'mock-workspace-token',
expires_at: FUTURE_DATE,
user_id: 'uid-1',
workspace: {
id: 'ws-personal',
name: PERSONAL_WORKSPACE_NAME,
Expand Down
1 change: 1 addition & 0 deletions browser_tests/tests/dialogs/topUpDeepLink.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ test.describe('Top-up deep link', { tag: '@cloud' }, () => {
],
billingCapabilities: createBillingCapabilities(teamWorkspace.id, {
can_manage_subscription: false,
can_open_plans: false,
can_top_up: false,
can_subscribe_self_serve: false
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export function mintBody(overrides: Record<string, unknown> = {}) {
token: 'workspace-jwt',
permissions: ['workspace:read'],
expires_at: new Date(Date.now() + NINETY_MINUTES_MS).toISOString(),
user_id: 'uid-1',
workspace: { id: 'ws-1', name: 'Personal', type: 'personal' },
role: 'owner',
...overrides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const CAPABILITIES = {
can_edit_workspace: false,
can_manage_auto_top_up: false,
can_manage_subscription: false,
can_open_plans: false,
can_run_workflows: false,
can_upgrade: false,
can_subscribe_self_serve: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const NO_RIGHTS: BillingCapabilities = {
can_manage_members: false,
can_manage_partner_node_access: false,
can_manage_subscription: false,
can_open_plans: false,
can_view_pending_invites: false,
can_view_team_usage: false,
can_reactivate: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function capabilities(): Capabilities {
can_manage_auto_top_up: true,
can_manage_members: true,
can_manage_subscription: true,
can_open_plans: true,
can_delete_workspace: false,
can_leave_workspace: false,
can_manage_billing: false,
Expand Down Expand Up @@ -65,6 +66,7 @@ expectTypeOf<keyof CapabilitiesResponse>().toEqualTypeOf<
| 'denied_reason_params'
| 'denied_reasons'
| 'expires_at'
| 'has_parked_billing_operation'
| 'payment_recovery_available'
| 'plan_kind'
| 'recovery_route'
Expand All @@ -86,6 +88,7 @@ expectTypeOf<Capabilities>().toEqualTypeOf<{
can_manage_members: boolean
can_manage_partner_node_access: boolean
can_manage_subscription: boolean
can_open_plans: boolean
can_reactivate: boolean
can_revert_scheduled_change: boolean
can_run_workflows: boolean
Expand Down
8 changes: 6 additions & 2 deletions packages/account-core/src/core/billing/operationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
zBillingOpChargeBreakdown,
zBillingOpChargeReason,
zBillingOpReceiptPlan,
zBillingOpStatusResponse
zBillingOpStatusResponse,
zTopUpPurchaseAmount
} from '@comfyorg/ingest-types/zod'
import { z } from 'zod'

Expand All @@ -42,7 +43,10 @@ export const BillingOpStatusSchema = zBillingOpStatusResponse.extend({
amount_charged_cents: wireCents.optional(),
credits_added: wireCents.optional(),
charge_breakdown: ChargeBreakdownSchema.optional(),
plan: ReceiptPlanSchema.optional()
plan: ReceiptPlanSchema.optional(),
topup_purchase_amount: zTopUpPurchaseAmount
.extend({ amount_cents: wireCents })
.optional()
})

export type BillingOpStatus = z.infer<typeof BillingOpStatusSchema>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ function capabilitiesBody(overrides: Record<string, unknown> = {}) {
can_edit_workspace: false,
can_manage_auto_top_up: false,
can_manage_subscription: false,
can_open_plans: false,
can_run_workflows: false,
can_upgrade: false,
can_subscribe_self_serve: false,
Expand Down
1 change: 1 addition & 0 deletions packages/account-core/src/core/billing/topup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const CAPABILITIES = {
can_edit_workspace: false,
can_manage_auto_top_up: false,
can_manage_subscription: false,
can_open_plans: false,
can_run_workflows: false,
can_upgrade: false,
can_subscribe_self_serve: false,
Expand Down
3 changes: 2 additions & 1 deletion packages/account-core/src/core/credentialCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export interface CredentialStorage {

/** The generated contract for POST /api/auth/token, never a local copy of it. */
const CachedCredentialSchema = CredentialResponseSchema.omit({
expires_at: true
expires_at: true,
user_id: true
}).extend({
// Storage and broadcast are untrusted boundaries: an empty token can never
// authorize and a non-finite expiry can never lapse, so neither is a session.
Expand Down
5 changes: 5 additions & 0 deletions packages/account-core/src/core/session.scheduler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ describe('opt-in refresh scheduler', () => {
permissions: [],
// Already inside the buffer: a zero delay would loop the mint.
expires_at: new Date(Date.now() + 60_000).toISOString(),
user_id: 'uid-1',
workspace: { id: 'ws-1', name: 'Personal', type: 'personal' },
role: 'owner'
}),
Expand Down Expand Up @@ -238,6 +239,7 @@ describe('opt-in refresh scheduler', () => {
token,
permissions: ['workspace:read'],
expires_at: new Date(Date.now() + NINETY_MINUTES_MS).toISOString(),
user_id: 'uid-1',
workspace: { id: wsId, name: 'Team', type: 'team' },
role: 'member'
}),
Expand Down Expand Up @@ -457,6 +459,7 @@ describe('opt-in refresh scheduler', () => {
token: 'jwt-team',
permissions: ['workspace:read'],
expires_at: new Date(Date.now() + NINETY_MINUTES_MS).toISOString(),
user_id: 'uid-1',
workspace: { id: 'ws-team', name: 'Team', type: 'team' },
role: 'member'
}),
Expand Down Expand Up @@ -497,6 +500,7 @@ describe('opt-in refresh scheduler', () => {
expires_at: new Date(
Date.now() + NINETY_MINUTES_MS
).toISOString(),
user_id: 'uid-1',
workspace: { id: 'ws-team', name: 'Team', type: 'team' },
role: 'member'
}),
Expand Down Expand Up @@ -1055,6 +1059,7 @@ describe('cross-tab refresh coordination', () => {
token: 'jwt-team',
permissions: ['workspace:read'],
expires_at: new Date(Date.now() + NINETY_MINUTES_MS).toISOString(),
user_id: 'uid-1',
workspace: { id: 'ws-team', name: 'Team', type: 'team' },
role: 'member'
}),
Expand Down
1 change: 1 addition & 0 deletions packages/account-core/src/core/sessionTokenMint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function tokenBody(token: string, expiresAt: number) {
return {
token,
expires_at: new Date(expiresAt).toISOString(),
user_id: 'uid-1',
workspace: { id: 'ws-personal', name: 'Personal', type: 'personal' },
role: 'owner',
permissions: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const CAPABILITIES = {
can_edit_workspace: false,
can_manage_auto_top_up: false,
can_manage_subscription: false,
can_open_plans: false,
can_run_workflows: false,
can_upgrade: false,
can_subscribe_self_serve: true,
Expand Down
Loading
Loading