Skip to content

feat: implement subscriptions export, workspaces, teams, and merchant audit trails - #979

Merged
Smartdevs17 merged 2 commits into
Smartdevs17:mainfrom
fortezzalaboratory:implement-features-965-968
Sep 26, 2026
Merged

Smartdevs17 merged 2 commits into
Smartdevs17:mainfrom
fortezzalaboratory:implement-features-965-968

Conversation

@fortezzalaboratory

Copy link
Copy Markdown
Contributor

What

Implements core features for subscription management, multi-workspace support, team collaboration, and audit trails for merchants.

Issues Resolved

Closes #965
Closes #966
Closes #967
Closes #968

Changes

#965 - Implement export subscriptions for reports

Added subscription export endpoints supporting CSV and JSON formats with filtering by merchant ID and date ranges.

#966 - Add multi-workspace support

Created workspaces router with CRUD operations, member management, and workspace-specific analytics.

#967 - Build team collaboration features

Implemented team management with member roles, permissions, bulk invitations, and role-based access control.

#968 - Implement audit trail viewer for merchants

Added merchant-specific audit trail endpoints with export capabilities (CSV/JSON) and aggregated summary statistics.

@vercel

vercel Bot commented Sep 26, 2026

Copy link
Copy Markdown

@fortezzalaboratory is attempting to deploy a commit to the smartdevs17's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Sep 26, 2026

Copy link
Copy Markdown

@fortezzalaboratory Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Smartdevs17
Smartdevs17 merged commit 13122f4 into Smartdevs17:main Sep 26, 2026
26 of 62 checks passed
Smartdevs17 added a commit that referenced this pull request Sep 30, 2026
The #979 'merge: resolve conflicts with upstream' landed regressions
that broke `next build`:

- restore next-intl dependency + createNextIntlPlugin wiring in
  next.config.ts (i18n plugin was dropped; 12+ modules import it)
- restore rich useOnboardingStore (479-line wizard store replaced by a
  minimal one; wizard page + tests still consume selectors, initWizard,
  ROLE_STEP_PATHS, analytics, incentives)
- dedupe app/dashboard/layout.tsx (two export default DashboardLayout;
  keep the clean metadata + DashboardAuthGuard form)
- add missing @radix-ui/react-progress and
  @react-native-async-storage/async-storage (pulled by web3auth/@MetaMask)
- fix qrcode.react v4 named export (QRCodeCanvas), AlertTitle export,
  '@/frontend/lib/api' -> '@/lib/api' import paths, raw '<' in JSX,
  missing 'use client' on client pages, useSearchParams suspense boundary
Smartdevs17 pushed a commit that referenced this pull request Nov 21, 2026
…hook dispatch (#1521)

* ci: pin all GitHub Actions to commit SHAs with Dependabot automation

Every third-party action in .github/workflows (199 references, 25 actions)
now uses a full commit SHA with the release as a trailing comment, so a
moved tag or branch can no longer change what runs in CI.
dtolnay/rust-toolchain picks the toolchain from its ref, so the pinned
steps now pass toolchain: stable/nightly explicitly.

Dependabot gains a github-actions entry that bumps SHA and comment
together, grouping minor and patch updates. The top-level
security-updates block is removed: it is not a Dependabot v2 key and
made GitHub reject the entire config, so no update entry applied.

scripts/workflow-pins.test.mjs fails make test-tooling on any unpinned
reference, a missing version comment, one release pinned to two SHAs,
a pinned rust-toolchain without a toolchain input, or an invalid
Dependabot config. The CI tooling filter now also runs on any workflow
or dependabot.yml change. CONTRIBUTING documents the policy.

Closes #1468

* perf(webhooks): shard the delivery queue by destination domain

The delivery worker sent every due webhook one at a time in a single
global pass and skipped whole ticks while a pass was in flight, so one
slow or hanging endpoint (up to the 8s attempt timeout) delayed every
merchant's deliveries.

Due deliveries are now grouped by destination host and each host drains
on its own lane (services/webhooks/shard-dispatcher.ts):
- one request at a time per host, oldest first;
- up to WEBHOOK_DISPATCH_MAX_CONCURRENT_SHARDS hosts in parallel
  (default 8), oldest-waiting hosts first when lanes are saturated;
- a host still draining is skipped instead of started twice, which keeps
  the no-double-send guarantee the old global lock provided;
- at most WEBHOOK_DISPATCH_MAX_BATCH_PER_SHARD deliveries per run
  (default 25) so one backlog cannot monopolise a lane.
Invalid settings fail at worker start with the variable named.

Observability: queue-wait (due to send) and lane-run percentiles,
backlog, busy skips, saturation and deliver errors, served by
GET /api/v1/webhooks/dispatch-stats, plus a once-a-minute saturation
warning and per-shard error logs. Documented in
docs/WEBHOOK_RETRY_STRATEGY.md and ENV_VARS.md.

Closes #1462

* perf(auth): prefetch workspace scopes once per request in the auth middleware

Every requirePermission/requireRole check rescanned the whole workspace
membership store for the same user, so a route with several checks paid
for several scans. The auth middleware now loads the principal's
memberships once after a strategy succeeds and attaches them as
req.workspaceScopes ({ userId, roles }); RBAC reads the role from there.

- Decisions are unchanged: the prefetched role is what getMemberRole
  returns, and a missing workspace is still a 403.
- Scopes are bound to their user: another user falls back to a direct
  lookup, and scopes present before authentication are cleared.
- A loader failure never blocks authentication; it is logged and RBAC
  falls back to per-check lookups.
- createAuthMiddleware takes an optional loadWorkspaceScopes (custom
  loader, or false to disable); getScopePrefetchStats() reports counts,
  failures and timing.

Also fixes two latent bugs in the touched files: requireRole loaded
getMemberRole with a runtime require(), which fails under Vitest's ESM
loader (now a static import), and the API-key strategy imported
lookupApiKeyRecord, which was renamed to lookupApiKey in #979 and made
every x-api-key request throw a TypeError.

Closes #1464

* feat(frontend): enforce a strict per-request nonce CSP for the dashboard

middleware.ts now creates a fresh 128-bit nonce for every document
request and sends a policy built by lib/csp.ts:

  script-src 'self' 'nonce-<random>' 'strict-dynamic'; object-src 'none';
  base-uri 'self'; form-action 'self'; frame-ancestors 'none'; ...

The nonce and policy are set on the forwarded request (next-intl copies
request headers into its response) so Next.js stamps the nonce on every
script it renders, and on the response so the browser enforces it.
Injected scripts and inline handlers no longer run. Development adds
'unsafe-eval' and local HMR origins only under next dev.

- The root layout calls connection() so pages render per request; a
  nonce cannot be added to statically prerendered HTML.
- connect-src allows https:/wss: for wallet RPCs and WalletConnect, plus
  the configured API and realtime origins; styles keep 'unsafe-inline'
  because React/Radix/Web3Modal set inline style attributes.
- /forms/embed/:id stays frameable by merchant sites; every other page
  sends frame-ancestors 'none' and X-Frame-Options: DENY.
- CSP_REPORT_ONLY=true rolls the policy out as Report-Only; reports go
  to CSP_REPORT_URI or Sentry's security endpoint for the DSN, via
  report-uri, report-to and Reporting-Endpoints.
- next.config.ts adds nosniff and Referrer-Policy headers.

Verified on a production build: every <script> on /, /dashboard,
/es/dashboard, a 404 and the embed pages carries the request's nonce.
vitest inlines next-intl so the middleware can be tested directly.

Closes #1466
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants