Help converting a rule to an action

I am trying to answer the same question as this commenter: Convert rules to action help

For certain flows I want to map either user.email or user.upn to a custom email claim in the ID token that my app uses in lieu of email in some cases. How do I access user.upn? I have been reading the documentation and it seems like the previous limitation has been removed but I still cannot find a clear way to access the UPN attribute.

function (user, context, callback) {
  const namespace = "https://example.com/"
  context.idToken[namespace + 'email'] = user.email || user.upn;
  callback(null, user, context);
}

Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!