Masked email: Fastmail's Masked Email API, MaskedEmail/get and /set (ME-1, ME-7a, ME-16)

Advertised as https://www.fastmail.com/dev/maskedemail in the session and on
every account that may hold masks. Masks created through it start pending
unless the create sets a state; pending can't be set again once left; state
and the other mutable fields map onto the same records the x: API uses.
This commit is contained in:
2026-09-18 16:29:47 -07:00
parent 7080028437
commit d04aafd3d7
16 changed files with 626 additions and 5 deletions
@@ -98,6 +98,9 @@ pub enum Capability {
// inbuxa: the fork's own capability (contract C-1, multi-tenancy MT-22)
#[serde(rename(serialize = "urn:inbuxa:jmap"))]
Inbuxa = 1 << 20,
// inbuxa: Fastmail's Masked Email API (masked email)
#[serde(rename(serialize = "https://www.fastmail.com/dev/maskedemail"))]
FastmailMaskedEmail = 1 << 21,
}
#[derive(Debug, Clone, Copy, Default)]
@@ -347,6 +350,7 @@ impl Capability {
Capability::WebPushVapid => "urn:ietf:params:jmap:webpush-vapid",
Capability::EmailPush => "urn:ietf:params:jmap:emailpush",
Capability::Inbuxa => "urn:inbuxa:jmap",
Capability::FastmailMaskedEmail => "https://www.fastmail.com/dev/maskedemail",
}
}
@@ -494,6 +498,7 @@ impl Capability {
"urn:ietf:params:jmap:webpush-vapid" => Capability::WebPushVapid,
"urn:ietf:params:jmap:emailpush" => Capability::EmailPush,
"urn:inbuxa:jmap" => Capability::Inbuxa,
"https://www.fastmail.com/dev/maskedemail" => Capability::FastmailMaskedEmail,
)
}
}
+9
View File
@@ -41,6 +41,8 @@ pub enum MethodObject {
ParticipantIdentity,
ShareNotification,
Registry(ObjectType),
// inbuxa: Fastmail's MaskedEmail
MaskedEmail,
}
impl MethodObject {
@@ -64,6 +66,7 @@ impl MethodObject {
MethodObject::AddressBook | MethodObject::ContactCard => Capability::Contacts,
MethodObject::FileNode => Capability::FileNode,
MethodObject::Registry(_) => Capability::Stalwart,
MethodObject::MaskedEmail => Capability::FastmailMaskedEmail,
}
}
}
@@ -235,6 +238,8 @@ impl MethodName {
(MethodFunction::Set, MethodObject::ParticipantIdentity) => "ParticipantIdentity/set",
(MethodFunction::Echo, MethodObject::Core) => "Core/echo",
(MethodFunction::Get, MethodObject::MaskedEmail) => "MaskedEmail/get",
(MethodFunction::Set, MethodObject::MaskedEmail) => "MaskedEmail/set",
(method, MethodObject::Registry(obj)) => {
return Cow::Owned(format!("x:{}/{}", obj.as_str(), method.as_str()));
}
@@ -354,6 +359,9 @@ impl MethodName {
"Core/echo" => (MethodObject::Core, MethodFunction::Echo),
"MaskedEmail/get" => (MethodObject::MaskedEmail, MethodFunction::Get),
"MaskedEmail/set" => (MethodObject::MaskedEmail, MethodFunction::Set),
).or_else(|| {
let (obj, fnc) = s.strip_prefix("x:")?.split_once('/')?;
let obj = ObjectType::parse(obj)?;
@@ -401,6 +409,7 @@ impl Display for MethodObject {
MethodObject::CalendarEvent => "CalendarEvent",
MethodObject::CalendarEventNotification => "CalendarEventNotification",
MethodObject::ShareNotification => "ShareNotification",
MethodObject::MaskedEmail => "MaskedEmail",
MethodObject::Registry(obj) => {
f.write_str("x:")?;
return f.write_str(obj.as_str());
+2
View File
@@ -111,6 +111,7 @@ pub enum GetRequestMethod {
ParticipantIdentity(Box<GetRequest<ParticipantIdentity>>),
ShareNotification(Box<GetRequest<ShareNotification>>),
Registry(Box<GetRequest<Registry>>),
MaskedEmail(Box<GetRequest<crate::object::fastmail_masked_email::FastmailMaskedEmail>>),
}
#[derive(Debug)]
@@ -131,6 +132,7 @@ pub enum SetRequestMethod<'x> {
CalendarEventNotification(Box<SetRequest<'x, CalendarEventNotification>>),
ParticipantIdentity(Box<SetRequest<'x, ParticipantIdentity>>),
Registry(Box<SetRequest<'x, Registry>>),
MaskedEmail(Box<SetRequest<'x, crate::object::fastmail_masked_email::FastmailMaskedEmail>>),
}
#[derive(Debug)]
+14
View File
@@ -146,6 +146,13 @@ impl<'de> Visitor<'de> for CallVisitor {
return Err(de::Error::invalid_length(1, &self));
}
},
(MethodFunction::Get, MethodObject::MaskedEmail) => match seq.next_element() {
Ok(Some(value)) => RequestMethod::Get(GetRequestMethod::MaskedEmail(value)),
Err(err) => RequestMethod::invalid(err),
Ok(None) => {
return Err(de::Error::invalid_length(1, &self));
}
},
(MethodFunction::Get, MethodObject::VacationResponse) => match seq.next_element() {
Ok(Some(value)) => RequestMethod::Get(GetRequestMethod::VacationResponse(value)),
Err(err) => RequestMethod::invalid(err),
@@ -290,6 +297,13 @@ impl<'de> Visitor<'de> for CallVisitor {
return Err(de::Error::invalid_length(1, &self));
}
},
(MethodFunction::Set, MethodObject::MaskedEmail) => match seq.next_element() {
Ok(Some(value)) => RequestMethod::Set(SetRequestMethod::MaskedEmail(value)),
Err(err) => RequestMethod::invalid(err),
Ok(None) => {
return Err(de::Error::invalid_length(1, &self));
}
},
(MethodFunction::Set, MethodObject::VacationResponse) => match seq.next_element() {
Ok(Some(value)) => RequestMethod::Set(SetRequestMethod::VacationResponse(value)),
Err(err) => RequestMethod::invalid(err),