One Time Codes
Passlock can issue mailbox challenges for email-based one-time code flows. They work well for account signup, passwordless login, and account management scenarios such as email-change verification.
Each challenge has three important values:
challengeIdidentifies the challengesecretis kept by your app and submitted during verificationcodeis the one-time code you deliver to the user by email
How it works
Section titled “How it works”- Your app calls
createMailboxChallengewith an email address and a purpose such assignup,login, oremail-change. - Passlock returns a challenge containing
challengeId,secret,code, and a renderedmessagewithhtmlandtextcontent. - Your app stores
challengeIdandsecretin an HTTP-only cookie or server-side session, then emails the code to the user. Send the renderedmessagecontent, or use the rawcodeto generate your own message. - The user enters the code into your app.
- Your app calls
verifyMailboxChallengewithchallengeId,secret, andcode. - Passlock returns a readable challenge payload that excludes the secret and code. Your app should still validate the challenge
purposeand any expected local user before completing the flow.
Why doesn’t Passlock email the codes?
Section titled “Why doesn’t Passlock email the codes?”Passlock does everything apart from actually sending the email. There are a few reasons for this:
- The email should come from your domain - users should immediately recognise the sender. Security emails sent “on behalf of” are a red flag.
- No need for SPF, DMARC and DKIM changes - if we were to send from your domain you’d need to setup these properties for our servers.
- Flexibility - we return HTML and plain text message content. It’s responsive, supports dark mode and is tested in major email clients. We think it’s great, but you might disagree so we give you the flexibility to generate and send your own message content.
Next steps
Section titled “Next steps”- Email verification - verify mailbox ownership before creating or activating an account
- Passwordless logins - authenticate a user with an emailed one-time code
- Account management - verify a new mailbox before updating account details
- Reference - detailed
@passlock/serverfunction reference - REST API mailbox challenges - raw HTTP requests and response shapes