Commit Graph

4523 Commits

Author SHA1 Message Date
Ahmed Bouhuolia
d7d1783eee wip 2026-05-27 23:28:17 +02:00
Ahmed Bouhuolia
4a84d5996e wip 2026-05-27 17:37:39 +02:00
Ahmed Bouhuolia
f7d9ac765b Merge branch 'develop' into feat/query-hooks-refactor-kebab-case 2026-05-22 17:12:01 +02:00
Ahmed Bouhuolia
2faafb2617 Merge pull request #1101 from bigcapitalhq/refactor/webapp-withx-hoc-types
refactor(webapp): standardize withX HOC types with shared MapState generic and props interfaces
2026-05-22 17:07:38 +02:00
Ahmed Bouhuolia
fa98b06a09 refactor(webapp): standardize withX HOC types with shared MapState generic and props interfaces
- Extract shared `MapState<MappedProps, OwnProps>` generic into `containers/hoc.types.ts`,
  replacing 57 per-file local type duplicates
- Add exported `WithXProps` interfaces to all state HOCs that lacked them, replacing
  `MapState<Record<string, unknown>, Props>` with the properly typed generic
- Add exported `WithXActionsProps` interfaces to all action HOCs, annotating
  `mapDispatchToProps` return types and ensuring consistent exports
- Fix TS errors in `withAlertStoreConnect`, `withDrawers`, `withAuthentication`,
  `withCurrentOrganization`, and `withOrganization` (missing args and missing casts)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 15:25:45 +02:00
Ahmed Bouhuolia
bae7222230 Merge pull request #1100 from bigcapitalhq/refactor/store-kebab-case-rename
refactor(webapp): rename store files and folders to kebab-case
2026-05-20 21:58:34 +02:00
Ahmed Bouhuolia
d44ced73ad wip 2026-05-20 21:47:41 +02:00
Ahmed Bouhuolia
5edc3e4723 wip 2026-05-20 21:30:39 +02:00
Ahmed Bouhuolia
f77baaa84f wip 2026-05-20 20:57:29 +02:00
Ahmed Bouhuolia
a1a2f86e86 refactor(webapp/store): update all import paths to match kebab-case renames
Update ~112 files across packages/webapp/src to use the new
kebab-case folder and file names introduced in the previous commit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 00:48:46 +02:00
Ahmed Bouhuolia
3d529833d5 refactor(webapp/store): rename store files/folders to kebab-case and .ts extension
- Rename 19 PascalCase/camelCase folders to kebab-case
  (e.g. CashflowAccounts → cashflow-accounts, financialStatement → financial-statement)
- Rename all .tsx store files to .ts (no JSX in any store file)
- Rename camelCase/PascalCase file base names to kebab-case
  (e.g. paymentMades.reducer.tsx → payment-mades.reducer.ts)
- Rename 9 root-level store files to kebab-case
  (createStore.tsx → create-store.ts, reducers.tsx → reducers.ts, etc.)
- Update all ~112 import paths across packages/webapp/src to match new paths

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 00:46:06 +02:00
Ahmed Bouhuolia
445bc8a582 Merge pull request #1078 from bigcapitalhq/feat/ee-workspaces-multi-org-pr
feat(ee): add multi-organization workspaces feature
2026-05-19 21:03:31 +02:00
Ahmed Bouhuolia
a8431da447 wip 2026-05-19 20:59:21 +02:00
Ahmed Bouhuolia
dede2b03ce wip 2026-05-19 20:58:04 +02:00
Ahmed Bouhuolia
0971b3c9ce update pnpm-lock.yaml 2026-05-18 23:54:21 +02:00
Ahmed Bouhuolia
e9b5974182 wip 2026-05-18 23:52:45 +02:00
Ahmed Bouhuolia
73578ab902 wip 2026-05-18 16:08:33 +02:00
Ahmed Bouhuolia
c69515f618 wip 2026-05-18 13:29:16 +02:00
Ahmed Bouhuolia
b1766a9c6f Merge branch 'develop' into feat/ee-workspaces-multi-org-pr 2026-05-18 13:25:35 +02:00
Ahmed Bouhuolia
7f3fbdc57d Merge pull request #1095 from bigcapitalhq/fix/plaid-webhook-signature-verification
fix(server): verify Plaid webhook signatures (GHSA-g56w-g54f-whq5)
2026-05-17 23:04:30 +02:00
Ahmed Bouhuolia
ef7cd6a284 Merge pull request #1098 from bigcapitalhq/chore/update-openapi-sdk-types 2026-05-17 21:22:42 +02:00
abouolia
bc1dad56ca chore(sdk): update OpenAPI spec and generated types 2026-05-17 19:20:32 +00:00
Ahmed Bouhuolia
40d306f39b Merge pull request #1076 from bigcapitalhq/feat/financial-audit-trail
feat(ee): audit logs domain level
2026-05-17 21:18:03 +02:00
Ahmed Bouhuolia
1a4f2e5b5d wip 2026-05-17 21:12:31 +02:00
Ahmed Bouhuolia
64e1221640 wip 2026-05-17 20:46:34 +02:00
Ahmed Bouhuolia
19d8aec2aa Merge remote-tracking branch 'refs/remotes/origin/feat/financial-audit-trail' into feat/financial-audit-trail 2026-05-17 20:46:03 +02:00
Ahmed Bouhuolia
8c8e5138df wip 2026-05-17 20:38:56 +02:00
Ahmed Bouhuolia
d74e02c21a Merge branch 'develop' into feat/financial-audit-trail 2026-05-17 19:55:15 +02:00
Ahmed Bouhuolia
00feae58a7 wip 2026-05-17 19:50:00 +02:00
Ahmed Bouhuolia
54dd475ec3 Merge pull request #1097 from bigcapitalhq/fix/sortorder-sql-injection
fix(server): prevent SQL injection via sortOrder in DynamicListing (GHSA-hcp2-qqg6-jjpm)
2026-05-16 21:42:43 +02:00
Ahmed Bouhuolia
c23bc76afa fix(server): prevent SQL injection via sortOrder in DynamicListing (GHSA-hcp2-qqg6-jjpm)
Validate sortOrder against an allowlist at the DTO layer, normalize the
direction centrally in DynamicFilterSortBy.buildQuery, and re-sanitize
inside every orderByRaw modifier so attacker-controlled SQL cannot reach
the ORDER BY clause.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 21:35:22 +02:00
Ahmed Bouhuolia
9f5aebec1d Merge pull request #1096 from bigcapitalhq/fix/predictable-s3-attachment-keys
fix(server): use CSPRNG for attachment S3 keys (GHSA-gj48-p5ff-g67f)
2026-05-16 19:59:22 +02:00
Ahmed Bouhuolia
ace15dbdeb fix(server): use CSPRNG for attachment S3 keys (GHSA-gj48-p5ff-g67f)
The multer-s3 storage factory used `Date.now().toString()` as the S3 key
for every upload, yielding a 13-digit ms-epoch key. The keyspace for any
time window equals the millisecond count of that window, so an attacker
holding a registered account can enumerate keys for known upload moments
(e.g. ~10 minutes for a 10-second window with a 10-proxy rotation), then
download files via `GET /attachments/:id/presigned-url`. Two uploads in
the same millisecond also collide and silently overwrite each other.

Replace the key callback with `${organizationId}/${randomUUID()}`:

  * `randomUUID()` from `node:crypto` is a v4 UUID with 122 bits of
    entropy, making brute-force enumeration infeasible.
  * The `<organizationId>/` prefix (read from the `nestjs-cls` store
    populated by `ClsModule` middleware in `App.module.ts`) limits the
    blast radius of any hypothetical bucket-listing leak to a single
    tenant.

Add a tenant migration applying `unique` to `documents.key` so any future
key collision surfaces as a DB error instead of a silent S3 overwrite.

Legacy 13-digit numeric keys remain accessible via their stored values;
only new uploads use the new format.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 19:38:39 +02:00
Ahmed Bouhuolia
78fb158b98 fix(server): verify Plaid webhook signatures (GHSA-g56w-g54f-whq5)
POST /api/banking/plaid/webhooks was @PublicRoute() and processed the
body without verifying Plaid's Plaid-Verification JWT, letting any
unauthenticated client replay or fabricate webhook events for a tenant
by guessing a plaidItemId.

Add PlaidWebhookVerificationService that verifies the Plaid-Verification
ES256 JWS using a JWK fetched from plaidClient.webhookVerificationKeyGet
(cached per kid via lru-cache for 24h), enforces a 5-minute iat replay
window through jose.jwtVerify({ maxTokenAge }), and timing-safe compares
the body's SHA-256 against the request_body_sha256 claim. The webhook
controller now consumes the raw body and the plaid-verification header,
runs verification before setupPlaidTenant, and returns 400 Bad Request
on any failure - so no tenant context is ever set for an unsigned or
tampered request.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 12:19:30 +02:00
Ahmed Bouhuolia
cd8d10afc0 Merge pull request #1094 from bigcapitalhq/fix/tenant-bypass-organization-id-header
fix(server): prevent cross-tenant access via organization-id header
2026-05-15 21:19:36 +02:00
Ahmed Bouhuolia
7efac090a9 fix(server): prevent cross-tenant access via organization-id header
Resolve a CLS middleware in App.module.ts to copy the request
`organization-id` header straight into `cls.organizationId`, which the
TenancyDB factory used to pick the per-tenant database. The JWT path
never set `organizationId` from the authenticated user, and
TenancyGlobalGuard only checked that the header was present — so any
authenticated user could read or write another tenant's database by
sending their own JWT plus the victim's `organization-id`.

Make the JWT-resolved tenant the source of truth and validate the
header at the edge:

- AuthSigninService.verifyPayload now loads the user's tenant and sets
  `cls.organizationId` from `tenant.organizationId`, mirroring the
  API-key path in AuthApiKeyAuthorizeService.
- TenancyGlobalGuard rejects with `Organization mismatch.` when the
  request header disagrees with the CLS value set by the auth guard.
- App.module.ts no longer seeds `cls.organizationId` from the
  attacker-controlled request header.

GHSA-2g96-86rw-qmvg

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 20:43:14 +02:00
Ahmed Bouhuolia
a9d2316fc2 Merge pull request #1093 from bigcapitalhq/fix/attachment-tenant-isolation
fix(server): prevent cross-tenant attachment access (IDOR)
2026-05-15 14:54:19 +02:00
Ahmed Bouhuolia
e18e61000d fix(server): prevent cross-tenant attachment access (IDOR)
Add tenant-scoped document lookup with throwIfNotFound() before S3
operations in GetAttachment, DeleteAttachment, and
GetAttachmentPresignedUrl services. This prevents users from reading,
deleting, or generating presigned URLs for attachments belonging to
other tenants.

Also adds RequirePermission decorators to the three attachment
endpoints and introduces Attachment ability subject with View and
Delete actions.

GHSA-rc4v-wq22-v6cf

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 14:47:18 +02:00
Ahmed Bouhuolia
c53bf60406 wip 2026-05-12 18:25:52 +02:00
Ahmed Bouhuolia
3c87abd34e Merge pull request #1091 from bigcapitalhq/chore/update-openapi-sdk-types
chore(sdk): update OpenAPI spec and generated types
2026-05-12 18:24:55 +02:00
abouolia
66ffff5b8d chore(sdk): update OpenAPI spec and generated types 2026-05-12 08:56:28 +00:00
Ahmed Bouhuolia
f8afa00f29 Merge pull request #1089 from c-premus/fix/dynamic-filter-pagination 2026-05-12 10:53:54 +02:00
Ahmed Bouhuolia
f3cb3b9722 Merge pull request #1090 from rebekah-create/fix/liabilties-typo 2026-05-12 08:53:45 +02:00
rebekah-create
3cbc4842b9 fix(server): correct "Liabilties" typo to "Liabilities" in balance sheet
The balance sheet rendered "Current Liabilties" in the Liabilities
section because of a typo in the i18n key, the schema reference, the
swagger example responses, and the generated SDK fixtures. Fixed all
five locations so PDF/HTML/JSON renders all read "Current Liabilities".

- packages/server/src/i18n/en/balance_sheet.json: rename key and value
- packages/server/src/modules/FinancialStatements/modules/BalanceSheet/
  BalanceSheetSchema.ts: update i18n key reference
- packages/server/src/modules/FinancialStatements/modules/BalanceSheet/
  BalanceSheet.swagger.ts: fix three example response strings
- shared/sdk-ts/openapi.json + schema.ts: regenerate to match
2026-05-12 00:10:44 -04:00
Chris
46012a1b1c Fix pagination params silently ignored on collection GET endpoints
Hoist `page` and `pageSize` declarations from the per-module DTOs into
the shared DynamicFilterQueryDto base class. Without these declarations,
the global ValidationPipe (whitelist: true) strips the params from the
request before the service layer sees them, so list services fall back
to their default page=1, pageSize=12 regardless of what the client sent.

Affects 10 collection GET endpoints whose query DTOs are empty subclasses
of DynamicFilterQueryDto: expenses, bills, credit-notes, manual-journals,
payments-received, sale-invoices, sale-estimates, sale-receipts,
vendor-credits, item-categories.

The 3 already-working DTOs (Customers, Vendors, Items) keep their local
page/pageSize declarations as redundant overrides — no behavior change.

Closes #1088
2026-04-29 11:51:49 +00:00
Ahmed Bouhuolia
6ef1a6a651 wip 2026-04-17 01:10:27 +02:00
Ahmed Bouhuolia
91f3c28737 wip 2026-04-15 22:09:25 +02:00
Ahmed Bouhuolia
a1430db37e wip 2026-04-15 00:35:17 +02:00
Ahmed Bouhuolia
70ff1fc179 wip 2026-04-14 21:36:40 +02:00
Ahmed Bouhuolia
ff1cfb63bf chore: update pnpm-lock.yaml dependency resolutions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 23:54:45 +02:00