msc {
# Options
hscale="1.5", wordwraparcs=1;
# Define the actors
User, Email, Server, Database;
# Title note
User note Database [
label="Describes the process of performing persistent auth", textbgcolor="aqua"];
# Define the messages
User->Server [label="Request persistent auth"];
Server->Database [label="Retrieve associated entity email"];
Server=>Server [label="Verify email safety"];
--- [label="If email unsafe, return bad email response"];
Server->User [label="Bad Email",
linecolor="red"];
--- [label="Otherwise issue a new challenge"];
Server->Database [label="Create new challenge pair"];
Server->User [label="Send challenge id"];
Server->Email [label="Send challenge code", arcskip=1];
|||;
Email->User [label="Share challenge code", arcskip=1];
|||;
User->Server [label="code & id"];
Server->Database [label="Verify challenge code & id"];
--- [label="If code expired or invalid, return bad auth response"];
Server->User [label="Bad Auth",
linecolor="red"];
--- [label="Otherwise, create and return JWT with relevant scope"];
Server->Database [label="Create JWT"];
Server->User [label="Return JWT"];
}