Extend Transaction Metadata to the Custom Token Exchange flow

Feature: Allow transaction metadata set in a Custom Token Exchange Action to be read by the following Post Login Action

Description: The Transaction Metadata feature is an obviously superior method of passing data between actions than previous techniques (shoving it in user metadata or the api cache) and a welcome addition. But it isn’t available in the CTE Action (yet?).

Use-case: I want to use use CTE to re-use another identity provider for some things, but the subject_token has some necessary information inside it that I need to be carried over as a custom claim in the issued token.

Example:

It would be great if we could do this:

// The Custom Token Exchange Trigger
exports.onExecuteCustomTokenExchange = async (event, api) => {
  const { isValid, payload } = await validateToken(
    event.transaction.subject_token,
  );
  if (isValid) {
    api.authentication.setUserById(payload.sub);
    api.transaction.setMetadata('my_custom_claim', payload.my_custom_claim);
  }
  // etc.
};

// A post-login trigger
exports.onExecutePostLogin = async (event, api) => {
  // etc. etc.
  if (event.transaction.protocol === 'oauth2-token-exchange') {
    api.accessToken.setCustomClaim('urn:blah:custom', event.transaction?.metadata?.my_custom_claim);
  }
};