@@ -8,7 +8,14 @@ import { BaseAuthAPI, AuthenticationClientOptions, grant } from './base-auth-api
88import { IDTokenValidateOptions , IDTokenValidator } from './id-token-validator.js' ;
99import { mtlsPrefix } from '../utils.js' ;
1010
11- export interface TokenSet {
11+ interface AuthorizationDetails {
12+ readonly type : string ;
13+ readonly [ parameter : string ] : unknown ;
14+ }
15+
16+ export interface TokenSet <
17+ TAuthorizationDetails extends AuthorizationDetails = AuthorizationDetails
18+ > {
1219 /**
1320 * The access token.
1421 */
@@ -29,6 +36,11 @@ export interface TokenSet {
2936 * The duration in secs that the access token is valid.
3037 */
3138 expires_in : number ;
39+ /**
40+ * The authorization details when using Rich Authorization Requests (RAR).
41+ * @see https://auth0.com/docs/get-started/apis/configure-rich-authorization-requests
42+ */
43+ authorization_details ?: TAuthorizationDetails [ ] ;
3244}
3345
3446export interface GrantOptions {
@@ -99,7 +111,9 @@ export interface ClientCredentialsGrantRequest extends ClientCredentials {
99111 organization ?: string ;
100112}
101113
102- export interface PushedAuthorizationRequest extends ClientCredentials {
114+ export interface PushedAuthorizationRequest <
115+ TAuthorizationDetails extends AuthorizationDetails = AuthorizationDetails
116+ > extends ClientCredentials {
103117 /**
104118 * URI to redirect to.
105119 */
@@ -162,7 +176,7 @@ export interface PushedAuthorizationRequest extends ClientCredentials {
162176 /**
163177 * A JSON stringified array of objects. It can carry fine-grained authorization data in OAuth messages as part of Rich Authorization Requests (RAR) {@link https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow/authorization-code-flow-with-rar | Reference}
164178 */
165- authorization_details ?: string ;
179+ authorization_details ?: string | TAuthorizationDetails [ ] ;
166180
167181 /**
168182 * Allow for any custom property to be sent to Auth0
@@ -449,6 +463,15 @@ export class OAuth extends BaseAuthAPI {
449463 options : { initOverrides ?: InitOverride } = { }
450464 ) : Promise < JSONApiResponse < PushedAuthorizationResponse > > {
451465 validateRequiredRequestParams ( bodyParameters , [ 'client_id' , 'response_type' , 'redirect_uri' ] ) ;
466+ const { authorization_details } = bodyParameters ;
467+
468+ if ( authorization_details ) {
469+ // Convert to string if not already
470+ bodyParameters . authorization_details =
471+ typeof authorization_details !== 'string'
472+ ? JSON . stringify ( authorization_details )
473+ : authorization_details ;
474+ }
452475
453476 const bodyParametersWithClientAuthentication = await this . addClientAuthentication (
454477 bodyParameters
0 commit comments