523 Commits

Author SHA1 Message Date
barsa
99761b21dd refactor: enhance password reset form validation and auth store integration
- Introduced a new reset form schema that extends the domain passwordResetSchema to include a confirmPassword field with matching logic.
- Updated the PasswordResetForm component to utilize the new schema for improved validation.
- Added applyAuthResponse method to the auth store for syncing authentication responses.
- Refactored GetStartedForm to redirect users to the dashboard upon successful account setup, integrating with the auth store for session management.
- Removed unnecessary redirection logic from CompleteAccountStep and MigrateAccountStep components to streamline the flow.
2026-03-02 19:02:48 +09:00
barsa
49e9dba3a3 refactor: enhance error handling in WHMCS and signup workflows
- Introduced structured error codes in BadRequestException for better clarity in WHMCS and signup workflows.
- Updated error messages to include specific context, improving user feedback during account verification and migration processes.
- Refined validation logic to ensure consistent error handling across services.
2026-03-02 18:15:13 +09:00
barsa
230a61c520 refactor: enhance account status handling and error messaging in auth guards
- Introduced a new `AccountStatusResult` interface to standardize account status detection across systems.
- Updated the `VerificationWorkflowService` to merge handoff data with discovered account status.
- Enhanced error handling in `GlobalAuthGuard` and `LocalAuthGuard` to include structured error codes for better clarity in unauthorized responses.
- Refined WHMCS and Salesforce integration schemas to ensure consistent data validation and coercion.
2026-03-02 18:00:41 +09:00
barsa
29b511e44c refactor: update password validation requirements and messaging
- Removed special character requirement from password validation across various components and schemas.
- Updated user-facing messages to reflect the new password criteria.
- Adjusted related validation logic in the domain and portal to ensure consistency.
2026-03-02 17:40:47 +09:00
barsa
65bdadc5c8 docs: add get-started login handoff design
Cookie-based handoff pattern for existing users in the get-started
flow. After OTP verification detects portal_exists, BFF sets a
short-lived HttpOnly cookie and redirects to the login page, which
shows a password-only form (no second OTP).
2026-03-02 16:06:45 +09:00
barsa
cc8aa917c2 fix: update Salesforce connection login URL to use test environment
- Change default login URL from production to test Salesforce environment for safer development and testing.
2026-03-02 15:23:33 +09:00
barsa
49d6d21974 fix: restore lost error classifications and address code review findings
- Salesforce: add validation/duplicate/access/storage error classes and
  restore classification in error handler (400/409/403/503 vs generic 502)
- Freebit: add auth/rate-limit/validation/network error classes and
  restore result-code-based classification (215, 381, 382)
- Portal: replace unsafe string→enum casts with typed state variables
- BaseRepository: narrow orderBy from unknown to Record<string, "asc"|"desc">
- WHMCS: narrow WhmcsNotFoundError.providerCode from string to union type
- Remove unused UnitOfWork service from PrismaModule
2026-03-02 13:11:11 +09:00
barsa
98beed85c7 refactor: decompose auth module into feature-based sub-modules
Split the monolithic AuthModule (48 providers) into 7 focused
feature modules: Tokens, OTP, Sessions, Login, GetStarted,
PasswordReset, and SharedAuth (guards + rate limiting).
2026-03-02 13:11:11 +09:00
barsa
e5fe68b25e refactor: add repository + unit of work layer for database access
Add BaseRepository generic class with typed CRUD operations. Create
UnitOfWork service wrapping TransactionService for atomic multi-entity
operations. Add concrete repositories for SimVoiceOptions, IdMapping,
and AuditLog. Migrate VoiceOptionsService, MappingsService, and
AuditLogService from direct PrismaService usage to repositories.
2026-03-02 13:11:11 +09:00
barsa
2d076cf6d4 refactor: add typed provider error classes replacing string matching
Add structured error code enums to domain package for WHMCS, Salesforce,
and Freebit providers. Create BaseProviderError and typed error classes
for each provider. Update UnifiedExceptionFilter to handle provider errors.
Migrate all three error handler services from DomainHttpException with
brittle string matching to typed error classes with instanceof checks.
2026-03-02 13:11:11 +09:00
barsa
7da032fd95 refactor: tighten support schema to use defined enum validators
Replace loose z.string() fields in supportCaseSchema and supportCaseFilterSchema
with the already-defined enum schemas (status, priority, category). Add JSDoc
to intentional escape hatches in customer contract interfaces. Fix portal
type assertions for the stricter filter types.
2026-03-02 13:11:10 +09:00
ed7c167f15 feat: integrate OpenBao vault for secret management in BFF
Replace fragile .env backup/restore with Vault-based secret injection.
Secrets are preloaded via --import hook before NestJS modules evaluate,
with a 30s refresh loop and event-driven cache invalidation for services
that read secrets at init (JWT, CSRF, WHMCS).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 16:27:37 +09:00
barsa
b206de8dba refactor: enterprise-grade cleanup of BFF and domain packages
Comprehensive refactoring across 70 files (net -298 lines) improving
type safety, error handling, and code organization:

- Replace .passthrough()/.catchall(z.unknown()) with .strip() in all Zod schemas
- Tighten Record<string, unknown> to bounded union types where possible
- Replace throw new Error with domain-specific exceptions (OrderException,
  FulfillmentException, WhmcsOperationException, SalesforceOperationException, etc.)
- Split AuthTokenService (625 lines) into TokenGeneratorService and
  TokenRefreshService with thin orchestrator
- Deduplicate FreebitClientService with shared makeRequest() method
- Add typed interfaces to WHMCS facade, order service, and fulfillment mapper
- Externalize hardcoded config values to ConfigService with env fallbacks
- Consolidate duplicate billing cycle enums into shared billingCycleSchema
- Standardize logger usage (nestjs-pino @Inject(Logger) everywhere)
- Move shared WHMCS number coercion helpers to whmcs-utils/schema.ts
2026-02-24 19:05:30 +09:00
barsa
1156398caa refactor: improve WHMCS account discovery error handling
- Simplify error handling in WhmcsAccountDiscoveryService by logging warnings for user sub-account lookup failures instead of throwing errors.
- Ensure that the primary client lookup remains the authoritative source while allowing supplementary checks for user accounts.
- Enhance code clarity and maintainability by removing unnecessary error checks.
2026-02-24 14:48:03 +09:00
barsa
9941250cb5 refactor: streamline authentication workflows and remove legacy services
- Replace SignupWorkflowService and GetStartedWorkflowService with new coordinator services for improved modularity and clarity.
- Update auth controller to utilize the new GetStartedCoordinator.
- Refactor account status handling in the GetStartedForm component to leverage XState for state management.
- Introduce new hooks for managing the get-started flow, enhancing the overall user experience.
- Remove deprecated services and clean up related imports to maintain code hygiene.
2026-02-24 14:37:23 +09:00
barsa
5c329bbe96 refactor: update WHMCS mappers and schemas to use numberLike for type safety
- Refactor various mappers in billing, payments, services, and subscriptions to ensure IDs are consistently converted to numbers.
- Update raw types schemas to utilize whmcsNumberLike and whmcsString for improved validation and type safety.
- Enhance the whmcs-utils to include schema exports for better modularity.
2026-02-24 13:56:02 +09:00
barsa
7bc4c14b4c refactor: consolidate error handling to safeOperation 2026-02-24 13:15:45 +09:00
barsa
9736e96cb3 refactor: consolidate error handling to safeOperation
- Enhance safeOperation with rethrow and fallbackMessage options for CRITICAL operations
- Migrate all 19 withErrorHandling calls across 5 services to safeOperation
- Remove safeAsync from error.util.ts
- Delete error-handler.util.ts (withErrorHandling, withErrorSuppression, withErrorLogging)
- Update barrel exports in core/utils/index.ts
2026-02-24 13:15:35 +09:00
barsa
058ed4765f refactor: infrastructure consolidation 2026-02-24 11:58:21 +09:00
barsa
13f1bdc658 refactor: module reorganization 2026-02-24 11:58:17 +09:00
barsa
536bdb6c87 refactor: Salesforce throttle base guard and RealtimeModule rename 2026-02-24 11:58:13 +09:00
barsa
d32a703fd3 refactor: core layer quick wins 2026-02-24 11:58:09 +09:00
barsa
34abe1981f refactor: infrastructure consolidation
- Create RollbackCoordinator shared by TransactionService and DistributedTransactionService
- Remove unused executeSimpleTransaction()
- Split AuditService into AuditLogService (writes) and AuditQueryService (reads)
- Create CacheStrategyBase with request coalescing, metrics, and getOrSet pattern
- Refactor orders and support cache services to extend CacheStrategyBase
2026-02-24 11:58:02 +09:00
barsa
1e2ff96313 refactor: module reorganization
- Move sim-orders.controller.ts into sim-orders/ sub-directory with barrel file
- Extract checkout session business logic from orders controller into checkout-session.service.ts
2026-02-24 11:58:00 +09:00
barsa
b00e7aac95 refactor: extract Salesforce throttle base guard and rename RealtimeModule
- Create SalesforceThrottleBaseGuard abstract base class (read/write guards are thin subclasses)
- Rename infra RealtimeModule to RealtimePubSubModule to distinguish from RealtimeApiModule
2026-02-24 11:57:59 +09:00
barsa
1ac5e95e08 refactor: core layer quick wins
- Rename getRequestFingerprint to getRateLimitFingerprint in rate-limit.util.ts
- Delete empty CoreConfigModule wrapper (importers use @nestjs/config directly)
- Replace inline admin role check in csrf.controller.ts with @UseGuards(AdminGuard)
- Move hashEmailForLogs() from support.logging.ts to core/logging/redaction.util.ts
2026-02-24 11:57:58 +09:00
barsa
0c63bc5c33 refactor: domain package cleanup
- Remove validation wrapper functions from common/validation.ts (use Zod schemas directly)
- Delete duplicate CheckoutItem/CheckoutTotals/CheckoutCart/OrderCreateResponse from orders/contract.ts
- Delete empty orders/checkout.ts
- Remove unused MIGRATION_STEPS/MIGRATION_TRANSFER_ITEMS UI constants from auth/forms.ts
- Standardize checkout/contract.ts to not re-export schema types
- Fix customer/providers/index.ts to not re-export contract types through providers barrel
2026-02-24 11:57:43 +09:00
barsa
6e51012d21 UAT docs and bug fixes 2026-02-24 11:09:35 +09:00
Temuulen Ankhbayar
5e5bff12da fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:

Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.

High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.

Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.

Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.

Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
Temuulen Ankhbayar
891d3aa099 feat: add MNP support for Physical SIM (PA05-19) and fix eSIM MNP bugs (PA05-41)
Physical SIM: route MNP orders through PA05-19 (semi-black registration)
instead of PA02-01. eSIM: fix PA05-41 payload — move identity fields into
mnp object (Level 2 nesting per spec), set addKind="M" and aladinOperated="20"
for MNP, map Salesforce gender "F" to Freebit "W", and pass simKind="E0".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:04:13 +09:00
Temuulen Ankhbayar
df017d520f fix: resolve SIM management modal, plan change, and voice feature issues
- Fix Tailwind v4 modal stacking bug by adding relative z-10 to modal
  content divs (CancellationFlow, ChangePlanModal, TopUpModal, SimActions)
- Add test mode for immediate plan changes (SIM_BILLING_TEST_MODE) instead
  of scheduling for 1st of next month
- Bypass rate limiter spacing/cancellation checks in test mode
- Hide voice feature toggles for data-only SIMs using hasVoice flag
- Guard BFF voice feature updates to reject early for data-only SIMs
- Fix Freebit retry logic to not retry business errors (e.g. resultCode 260)
- Add user-friendly error message for resultCode 260 (voice not active)
- Update plan change page text to reflect test mode behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 14:53:07 +09:00
Temuulen Ankhbayar
5c67fc34ea fix: resolve Order Activation Flow issues
- Fix SF Order locking by deferring Status change to final step
  - executeSfActivatedUpdate now only sets Activation_Status__c
  - executeSfRegistrationComplete sets Status: Processed atomically with WHMCS info

- Add WHMCS custom fields update step (whmcs_custom_fields)
  - AddOrder API expects field IDs, UpdateClientProduct accepts field names
  - New step updates SIM Number, Serial Number, EID after order acceptance

- Add Opportunity WH_Registeration__c field update
  - Sets productselect={serviceId} for WHMCS linking

- Add SIM Inventory assignment fields
  - Assigned_Account__c, Assigned_Order__c, SIM_Type__c now populated

- Remove PA05-18 Semi-Black SIM registration (only Black SIMs used)
  - Changed to direct PA02-01 call with createType=new

- Fix me-status to check for Status: Processed instead of Activated

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 15:38:59 +09:00
Temuuleenn
df742e50bc fix: resolve BFF TypeScript errors and improve mobile UX
BFF fixes:
- Fix pino-http type import by using Params from nestjs-pino
- Use Prisma-generated AuditAction enum instead of local duplicate
- Add null check for sfAccountId in mapping mapper

Portal mobile UX improvements:
- DataTable: Add responsive card view for mobile with stacked layout
- Header: Increase touch targets to 44px minimum, better spacing
- PageLayout: Optimize padding and make breadcrumbs scrollable
- PublicShell: Add iOS safe area support, slide animation, language
  switcher and sign-in button visible in mobile header

Also removes "Trusted by Leading Companies" section from AboutUsView.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 18:29:55 +09:00
barsa
4c724da7ae feat: implement trusted device functionality for enhanced login experience 2026-02-03 19:21:48 +09:00
barsa
60849b59a8 chore: update dependencies and fix lint errors
- Update pnpm 10.25.0 → 10.28.2
- Update all packages to latest versions (Next.js, React, NestJS, Prisma, etc.)
- Fix 36 nested ternary lint errors (unicorn/no-nested-ternary)
- Add security overrides for lodash and hono transitive deps
- Change pinned versions to use caret (^) for auto-updates
- Update catalog versions (@types/node, typescript, zod)
- Resolve all 12 security vulnerabilities
2026-02-03 18:46:51 +09:00
barsa
70f65cedaa chore: remove IDE artifacts and update gitignore
- Remove .cursor/ folder from tracking (plans, worktrees, rules)
- Remove sim-api-test-log.csv from tracking
- Add .cursor/ and *.csv to gitignore
2026-02-03 18:35:15 +09:00
barsa
b957877c6f chore: ignore all csv files 2026-02-03 18:32:16 +09:00
barsa
7abd433d95 Refactor conditional rendering and improve code readability across multiple components
- Simplified conditional rendering in OrderSummary, ProductCard, InstallationOptions, InternetOfferingCard, DeviceCompatibility, SimPlansContent, and other components by removing unnecessary parentheses.
- Enhanced clarity in the use of ternary operators for better maintainability.
- Updated documentation to reflect changes in development setup for skipping OTP verification during login.
- Removed outdated orchestrator refactoring plan document.
- Added new environment variable for skipping OTP verification in development.
- Minor adjustments in domain contracts and mappers for consistency in conditional checks.
2026-02-03 18:28:38 +09:00
barsa
2dec0af63b fix: resolve nested ternary lint errors across codebase 2026-02-03 18:11:51 +09:00
barsa
44aa90061e refactor: remove unused metadata and sitemap configurations for cleaner code 2026-02-03 17:59:44 +09:00
barsa
4cb393bdb8 refactor: simplify order fulfillment and remove unused public pages
- Extract fulfillment step executors and factory from orchestrator
- Remove unused signup, migrate, and internet configure pages
- Simplify PublicShell and landing page components
- Standardize conditional expressions across codebase
2026-02-03 17:35:47 +09:00
barsa
ff9ee10860 Merge main into alt-design
Resolved merge conflicts between main and alt-design branches.

Key decisions:
- BFF: Adopted SIM-first workflow from main (PA05-18 → PA02-01 → PA05-05 → WHMCS)
- BFF: Kept FreebitFacade pattern, added new services (AccountRegistration, VoiceOptions, SemiBlack)
- BFF: Fixed freebit-usage.service.ts bug (quotaKb → quotaMb)
- BFF: Merged rate limiting + HTTP status parsing in WHMCS error handler
- Portal: Took main's UI implementations
- Deleted: TV page, SignupForm, ServicesGrid (as per main)
- Added whmcsRegistrationUrl to field-maps.ts (was missing after file consolidation)

TODO post-merge:
- Refactor order-fulfillment-orchestrator.service.ts to use buildTransactionSteps abstraction
- Fix ESLint errors from main's code (skipped pre-commit for merge)
2026-02-03 16:12:05 +09:00
Temuuleenn
35619f24d1 Simplify physical SIM activation and enhance order fulfillment
- Remove PA05-18 semi-black step from physical SIM flow, use PA02-01 directly
- Add WHMCS client ID fallback from Salesforce WH_Account__c field
- Return service IDs from WHMCS AcceptOrder for proper linking
- Add phone number to WHMCS domain field and WHMCS admin URL to Salesforce
- Change SIM Inventory status from "In Use" to "Assigned"
- Fix SIM services query case sensitivity ("SIM" → "Sim")
- Add bash 3.2 compatibility to dev-watch.sh
- Add "Most Popular Services" section to landing page
- Add "Trusted By" company carousel to About page

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 15:41:32 +09:00
barsa
61d2236b68 refactor: standardize conditional expressions for improved readability 2026-02-03 15:21:45 +09:00
barsa
f257ffe35a Refactor SupportCaseDetailView for improved state management and component structure
- Extracted case detail logic into a custom hook `useCaseDetailState` for better separation of concerns.
- Created sub-components: `CaseNotFoundView`, `CaseHeaderCard`, `CaseMetaInfoRow`, `CaseConversationSection`, `ReplyForm`, and `ClosedCaseNotice` to enhance readability and maintainability.
- Updated message bubble rendering to use `MessageBubbleHeader` and `MessageBubbleStatus` for clearer status indication.
- Improved loading and error handling in `ResidenceCardVerificationSettingsView` by creating dedicated content components for different states.
- Refactored `transformWhmcsSubscriptionListResponse` to enhance readability and maintainability.
- Minor code style adjustments for consistency and clarity across various files.
2026-02-03 13:12:08 +09:00
barsa
d5e22f14f5 feat: add address reconciliation queue service for Salesforce integration
- Implement AddressReconcileQueueService to handle address reconciliation jobs between WHMCS and Salesforce.
- Define job data structure and queue configuration for retries and error handling.
- Add methods for enqueueing reconciliation jobs and retrieving queue health metrics.

feat: create loading components for various services in the portal

- Add loading skeletons for Internet, SIM, VPN, and public services configuration.
- Implement loading states for account-related views including account details, services, and verification settings.
- Introduce loading states for support case details and subscription actions.

feat: implement OTP input component for user verification

- Create OtpInput component to handle 6-digit OTP input with auto-focus and navigation.
- Add LoginOtpStep component for OTP verification during login, including countdown timer and error handling.

feat: define address domain constants for validation

- Establish constants for address field length limits to ensure compliance with WHMCS API constraints.
- Include maximum lengths for address fields and user input fields to maintain data integrity.
2026-02-03 11:48:49 +09:00
Temuulen Ankhbayar
9fbb6ed61e Add PA05-18 semi-black registration before PA02-01 for physical SIM activation
Physical SIM activation was failing with error 210 "アカウント不在エラー"
(Account not found) because PA02-01 requires the SIM to be pre-registered
in Freebit's system. This adds PA05-18 (Semi-Black Account Registration)
as the first step before PA02-01.

New flow: PA05-18 → PA02-01 → PA05-05

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 11:02:15 +09:00
tema
b400b982f3 Improve section transitions with gradient bleed effect
- Replace animated blob hero background with dot grid pattern
- Add gradient bleed transitions between all landing page sections
- Apply same gradient bleed technique to About page sections
- Remove unused blob-float animations from globals.css
- Make Trust and Values sections full-width for visual consistency

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 17:05:54 +09:00
tema
1283880f7d Revamp Physical SIM activation to use PA02-01 + PA05-05
Replace PA05-33 OTA API with the proper two-step activation flow:
- PA02-01: Account Registration (/master/addAcnt/)
- PA05-05: Voice Options Registration (/mvno/talkoption/addOrder/)

Changes:
- Add FreebitAccountRegistrationService for PA02-01 account registration
- Add FreebitVoiceOptionsService for PA05-05 voice options
- Update SimFulfillmentService to use new APIs instead of PA05-33 OTA
- Add SalesforceSIMInventoryService for fetching SIM inventory data
- Remove deprecated FreebitOtaService (PA05-33 no longer used)
- Remove debug console.log statements

The new flow:
1. Fetch SIM inventory from Salesforce (phone number, PT number)
2. Call PA02-01 to register MVNO account with plan code
3. Call PA05-05 to configure voice options with customer identity
4. Update SIM inventory status to "In Use"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 18:22:00 +09:00
tema
c9d568d22f Enhance Homepage UX with Mobile Navigation and Form Improvements
- Add mobile hamburger menu with full navigation
- Fix touch support for Services dropdown
- Add form validation and accessibility labels to contact form
- Add carousel position indicators and swipe support
- Add scroll-triggered animations with useInView hook
- Add sticky mobile CTA bar
- Improve Remote Support section mobile layout
- Add animated background blobs
- Add language selector (EN indicator)
- Optimize hero image with priority flag

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 17:42:19 +09:00