notify actions send mail.
A rule mails its account through a notify action on the email channel. Every notify of a document mails global.notification_email. The engine refuses a stage of a document whose notification_email is not the verified inbox of the account (NotificationEmailNotVerifiedError). So verify the inbox first, then put it in the document. See the notification email flow.
The flow
requestNotificationEmailCode({ aa, adapter, email, eoa }). The owner signs one sign-in. The engine mails a six-digit code and returns acode_token.- The owner reads the code in the mail.
verifyNotificationEmailCode({ aa, codeToken, code }). No prompt.- On
verified, set the inbox in the document withdocumentWithNotificationEmail(yaml, canonicalEmail), then stage and commit.
requestNotificationEmailCode
Steps:
canonicalNotificationEmail(email). Anullresult throwsError("notification email must be a bare ASCII address without whitespace or display-name syntax").- Render the sign-in with
notificationEmailCodeSiweMessage. It expires 300 seconds afterIssued At. - Prompt:
walletClient.signMessage({ account: eoa, message }). - Seal
{ "adapter", "email", "siwe_message", "signature" }to the engine key undernotificationEmailSealInfo("request_code", network, aa).emailis the text as typed. POST /api/wallets/:aa/notification_email/request_codewith{ sealed }.- Open and read the reply. Throw when the reply names another account.
NotificationEmailCodeRequestReply
Throws:
BackendRequestError for a failed request (for example 422 for a refused sign-in), Error for a reply of the wrong shape, and the error of the wallet when the owner rejects the prompt.
verifyNotificationEmailCode
code_token and the code from the mail prove the request.
Steps: seal { "code_token", "code" } under notificationEmailSealInfo("verify_code", network, aa), then POST /api/wallets/:aa/notification_email/verify_code with { sealed }, then open and read the reply. It throws when the reply names another account.
NotificationEmailCodeVerifyReply
recover as verified_notification_email.
Helpers
canonicalNotificationEmail
null for an empty text, any non-ASCII character, inner ASCII whitespace, and any of <, >, ,, ;, ". It does not check the mailbox syntax or whether the address can get mail.
notificationEmailCodeSiweMessage
Error("canonicalEmail must already be in notification-email canonical form") when canonicalEmail is not canonical. The statement is Verify <canonicalEmail> to receive notifications from wallet <aa lowercase>., and the one resource is notificationEmailCodeResourceUri(aa, canonicalEmail).
notificationEmailCodeResourceUri
notificationEmailSealInfo
info of a request: the UTF-8 text anafi/notification-email/request-code/<network>/ or anafi/notification-email/verify-code/<network>/, then the 20 raw bytes of the account. A request sealed for one route, network or account does not open for another.
Reply readers
kind, or an email that does not fit the outcome (for example invalid_email with an email).
NotificationEmailNotVerifiedError
The stage methods throw it when the document names a notification_email that is not the verified inbox of the account. It extends DslStageRefusedError. See errors.