gsmainclusivetechlab / token-backend

Tokenisation Project - Backend Services
https://token.gsmainclusivetechlab.io
MIT License
0 stars 0 forks source link

Session via OTP #68

Closed claudiotx closed 6 months ago

claudiotx commented 2 years ago

Sequence Diagram

participant Agent
participant Engine
participant MMO
participant Token Generator

participant Twillio

note over Twillio#yellow: Phone Number is the **session id**

Agent-#green>Engine:Connect Socket.io\nheaders: x-session: 9146590000

activate Engine
Engine-#red>Engine: Update sessions (socket.io http server)
deactivate Engine

Twillio-#green>Engine:SMS/USSD CASH_IN 914659000\nSMS/USSD CASH_OUT

Engine->MMO:GET accounts/msisdn/:phoneNumber/accountname
alt Account exists
Engine<--MMO:HTTP 200 (user info)
Engine->Token Generator:GET tokens/:phoneNumber
Engine<--Token Generator:HTTP 200 (token)

activate Engine
Engine-#red>Engine:Socket.io identify and broadcast to correct session client
deactivate Engine

Agent<#orange-Engine:POST /operations/notification\nheaders: x-session: 9146590000
Agent->Engine:POST /operation
Agent<--Engine:HTTP 200

alt Operation accepted
Engine->MMO:POST transactions/type/deposit \nPOST transactions/type/withdraw

alt Without open transaction 
Engine<--MMO:HTTP 200
Engine->Twillio:Notification - Request PIN
Engine<-Twillio:SMS - Send PIN
Engine->MMO:POST Validate PIN

alt Valid PIN

MMO->Engine:PUT /hooks/mmo/cash-in \nPUT /hooks/mmo/cash-out
Agent<-Engine:NOTIFICATION
Twillio<-Engine:NOTIFICATION

else Invalid PIN
Agent<-Engine:NOTIFICATION - Wrong Pin
Twillio<-Engine:NOTIFICATION - Wrong Pin
end

else With open transaction
Engine<--MMO:HTTP ERROR
Twillio<-Engine:NOTIFICATION - Can't have more than one open transaction
end

else Operation denied
Agent<-Engine:NOTIFICATION
Twillio<-Engine:NOTIFICATION
end

else Account doesn't exist
Engine<--Token Generator:HTTP 404
Twillio<--Engine:HTTP 404
end

Screen Shot 2022-01-26 at 12 52 43

claudiotx commented 2 years ago
participant Client Vue
participant User
participant Twillio
participant Engine
participant DB

User->Twillio:Send SMS Login
Twillio->Engine: User 9145446 LOGIN
Engine->Engine: Generate OTP Code
Engine->DB: Persist OTP Code
Engine->Twillio: Send OTP Code
Twillio->User: OTP Code
User->Client Vue: Input OTP
Client Vue->Engine: Authenticate
Engine->Client Vue: User Authenticated

Screen Shot 2022-01-26 at 12 56 47