Skip to content

refactor(architecture): split auth/service.go into focused sub-services - #317

Merged
cypriannwokolo2-creator merged 10 commits into
cocor-tech:masterfrom
Chinonso-Peter:refactor/157-auth-service-split
Sep 1, 2026
Merged

refactor(architecture): split auth/service.go into focused sub-services#317
cypriannwokolo2-creator merged 10 commits into
cocor-tech:masterfrom
Chinonso-Peter:refactor/157-auth-service-split

Conversation

@Chinonso-Peter

Copy link
Copy Markdown
Contributor

Summary

Splits internal/domain/auth/service.go (523 lines) into focused auth sub-services.

Changes

  • Created internal/domain/auth/jwt for JWT generation and validation
  • Created internal/domain/auth/nonce for nonce generation and signature verification
  • Consolidated duplicate JWT signers into parameterized GenerateToken
  • Reuse Stellar SDK keypair/StrKey instead of hand-rolled CRC16

Acceptance Criteria

  • Split into JWT, nonce, session, and password-hashing concerns
  • Consolidate duplicate JWT signers into one parameterized function
  • Reuse Stellar SDK keypair/StrKey instead of hand-rolled CRC16

Closes #157

…truct

Replace the fragile NewService(..., dependencies ...any) variadic any
signature with a typed Dependencies struct. This provides compile-time
type safety and eliminates the runtime type-switch that was a footgun
for future dependencies.

- Add Dependencies struct with typed fields for all optional collaborators
- Change NewService to accept Dependencies instead of ...any
- Update all callers across service tests, handler tests, integration
  tests, attack vector tests, and main.go

Closes cocor-tech#156
Extract Stellar transaction signing (SignXDR), payment building/submission
(BuildPaymentTx), and balance queries (GetBalance) into pkg/stellar helpers.
This is part of splitting wallet/service.go to keep it focused on
orchestration and security policy.

Refs cocor-tech#158
- Created internal/domain/auth/jwt for JWT generation and validation
- Created internal/domain/auth/nonce for nonce generation and signature verification
- Consolidated duplicate JWT signers into parameterized GenerateToken
- Reuse Stellar SDK keypair/StrKey instead of hand-rolled CRC16

Closes cocor-tech#157
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Chinonso-Peter 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

Chinonso-Peter and others added 4 commits August 31, 2026 13:02
- Moved CreateSession/ValidateSession/RefreshToken/List/Revoke logic to session sub-service
- Moved Argon2id hashing to password sub-service
- auth.Service now composes nonce, session, and jwt sub-services
- Preserves existing Service interface for handler backward compatibility

Closes cocor-tech#157
…reen build

Master's merged domain refactors (incentives split, swap CAS, wallet) were
incomplete at the origin tip. Complete the split design:

- incentives: extend Repository with referral/incentive/streak lookups and
  status transitions; implement postgres + mock; define parseUUID and
  ErrIncentiveNotFound; drop duplicate legacy methods from service.go
- swap: reconcile service with SwapOfferRequest, remove duplicate Repository
  interface, restore CAS mock in handler tests, fix typo in test
- wallet: add Balance type, map service to current repo/mock APIs
- contribution/payout: integration test now mocks FindByTxnHash dedup
- webhook: clear secret before persist so only secret_hash is stored;
  dispatcher test signs/verifies with secret_hash
- handler: fix swap history envelope, stale websocket bridge test
pipe.Del(ctx, fmt.Sprintf("session:%s", hash))
}
pipe.Del(ctx, userSessionsKey)
pipe.Exec(ctx)
@cypriannwokolo2-creator
cypriannwokolo2-creator merged commit 0db6cd8 into cocor-tech:master Sep 1, 2026
5 of 6 checks passed
cypriannwokolo2-creator added a commit to Chinonso-Peter/moistello-backend that referenced this pull request Sep 1, 2026
input.OfferorAmount,
input.RequestedAsset,
input.RequestedAmount,
uint64(expiresAt.Unix()),
return fmt.Errorf("encoding trustline tx: %w", err)
}
// Bounded async funding with context and timeout
go func() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(architecture): split auth/service.go (584 lines) into focused auth sub-services

3 participants