From 8d56a42970ecfb5db75fb658a8cadb95b7f8d0d8 Mon Sep 17 00:00:00 2001 From: "auth0-actions-type-automation[bot]" <266111309+auth0-actions-type-automation[bot]@users.noreply.github.com> Date: Thu, 27 Aug 2026 17:53:39 +0000 Subject: [PATCH] feat: update Actions types --- src/custom-token-exchange/v1/index.d.ts | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/custom-token-exchange/v1/index.d.ts b/src/custom-token-exchange/v1/index.d.ts index 3eb5e44..316c488 100644 --- a/src/custom-token-exchange/v1/index.d.ts +++ b/src/custom-token-exchange/v1/index.d.ts @@ -241,6 +241,10 @@ type CustomTokenExchangeV1Event = { } & { [additionalProperties: string]: any; }; + /** [Early Access] An object containing shared data across custom Actions for the duration of a transaction. */ + metadata?: { + [additionalProperties: string]: string | number | boolean; + }; /** The scopes requested (if any) provided in the token exchange request. */ requested_scopes: string[]; /** The type of token to be generated by Auth0. For example: urn:ietf:params:oauth:token-type:access_token. */ @@ -287,6 +291,7 @@ type CustomTokenExchangeSetUserByConnectionUserAttributes = { } & { [additionalProperties: string]: any; }; +type TxMetadataValue = string | boolean | number; /** Recursively defines nested actor levels, terminating when the depth tuple is exhausted. */ type NestedActor = D extends [unknown, ...infer Rest] ? { @@ -569,6 +574,34 @@ interface AuthenticationAPI { */ setActor(actor: ActorParams): void; } +interface TransactionAPI { + /** + * [Early Access] Store or update the value in the transaction metadata for a specified key. + * + * Metadata modified using this method is updated in real-time in the + * `event.transaction.metadata` object. + * + * @param key The key of the property to be set. + * @param value The value of the property. This may be set to `null` to remove the + * metadata property. + * + * @example + * ```js + * exports.onExecuteCustomTokenExchange = async (event, api) => { + * // Store data to share across Actions for the duration of the transaction. + * api.transaction.setMetadata('subject_verified', true); + * api.transaction.setMetadata('risk_score', 42); + * + * // Read it back from the event in real-time. + * console.log(event.transaction.metadata.risk_score); // 42 + * + * // Remove a previously set property by passing `null`. + * api.transaction.setMetadata('risk_score', null); + * }; + * ``` + */ + setMetadata(key: string, value: TxMetadataValue | null): void; +} interface UserAPI { /** * Set application-specific metadata for the user corresponding to the subject token. @@ -639,6 +672,10 @@ interface CustomTokenExchangeAPI { * Store and retrieve data that persists across executions. */ readonly cache: CacheAPI; + /** + * [Early Access] Make changes to the transaction. + */ + readonly transaction: TransactionAPI; } interface CustomTokenExchangeAction { (event: Event, api: CustomTokenExchangeAPI): Promise;