Skip to content

API Events

Identity is a pull-based JWKS issuer; it does not participate in Kafka. Async surfaces are mail (Nodemailer), SMS (MQ-SMS), and WebSocket broadcasts.

1. Inbound

N/A. Identity exposes a HTTP REST surface only. No Kafka, BullMQ, or webhook ingestion.

2. Outbound — Mail

TriggerTemplateLocaleDelivery
AuthenticationService.signUp (post-create)welcome-{en|vi}from userProfile.localeNodemailerComponent → SMTP
VerifyEmailService.requestVerificationverify-email-{en|vi}from requestcode (6 digits) + verification URL
ForgotPasswordService.requestResetforgot-password-{en|vi}from requestreset code/token
AuthenticationService.changePassword (post-update)password-changed-{en|vi}from userconfirmation notice

Templates seeded by identity-0004-seed-mail-configurations.ts. Editable at runtime via Configuration table (group=MAIL).

3. Outbound — SMS

TriggerTemplateLocale
PhoneOtpService.send (namespace=phone-auth)phone-auth-{en|vi}from request
LinkAccountService.send (namespace=add-phone)add-phone-{en|vi}from request

Provider: VN Pay SMS via MQSMSComponent. Templates seeded by identity-0007-seed-sms-templates.ts. Provider config via Configuration (group=SMS).

4. Outbound — WebSocket

IdentitySocketEventService broadcasts identity-domain events. Topics emitted via ApplicationWebSocketComponent (Redis-backed).

Topic familyTriggerAudience
User auth statesign-in, sign-out, status changemerchant admin / observability
Role/permission updatepolicy definition mutationdashboards
Profile updateuser profile changesself + admin

Specific topic constants are defined in IdentityWebSocketTopics (in components/websocket/); consult source for exact strings.

5. OTP State (Redis, not "events" but worth noting)

OTP services persist state in Redis (not Kafka):

Key patternPurposeTTL
{namespace}:otp:{identifier}Hashed code5–15 min per flow
{namespace}:lock:{identifier}Account-level lock after max attempts10–15 min
{namespace}:session:{token}Verified-session token1–24 h per flow
{namespace}:cooldown:{identifier}Resend cooldown60s
{namespace}:daily:{identifier}Daily quota counter24h

Namespaces: verify-email, verify-phone, forgot-password, phone-auth, add-phone, add-email.

6. Request-Response Patterns

The "real" inbound surface is JWKS pull from sister services:

FromToSurfaceCadence
Sister VerifierApplicationIdentity /jw-certsHTTP GETAt service boot + on key-id mismatch

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.