@@ -8,7 +8,14 @@ import { BaseAuthAPI, AuthenticationClientOptions, grant } from './base-auth-api
8
8
import { IDTokenValidateOptions , IDTokenValidator } from './id-token-validator.js' ;
9
9
import { mtlsPrefix } from '../utils.js' ;
10
10
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
+ > {
12
19
/**
13
20
* The access token.
14
21
*/
@@ -29,6 +36,11 @@ export interface TokenSet {
29
36
* The duration in secs that the access token is valid.
30
37
*/
31
38
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 [ ] ;
32
44
}
33
45
34
46
export interface GrantOptions {
@@ -99,7 +111,9 @@ export interface ClientCredentialsGrantRequest extends ClientCredentials {
99
111
organization ?: string ;
100
112
}
101
113
102
- export interface PushedAuthorizationRequest extends ClientCredentials {
114
+ export interface PushedAuthorizationRequest <
115
+ TAuthorizationDetails extends AuthorizationDetails = AuthorizationDetails
116
+ > extends ClientCredentials {
103
117
/**
104
118
* URI to redirect to.
105
119
*/
@@ -162,7 +176,7 @@ export interface PushedAuthorizationRequest extends ClientCredentials {
162
176
/**
163
177
* 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}
164
178
*/
165
- authorization_details ?: string ;
179
+ authorization_details ?: string | TAuthorizationDetails [ ] ;
166
180
167
181
/**
168
182
* Allow for any custom property to be sent to Auth0
@@ -449,6 +463,15 @@ export class OAuth extends BaseAuthAPI {
449
463
options : { initOverrides ?: InitOverride } = { }
450
464
) : Promise < JSONApiResponse < PushedAuthorizationResponse > > {
451
465
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
+ }
452
475
453
476
const bodyParametersWithClientAuthentication = await this . addClientAuthentication (
454
477
bodyParameters
0 commit comments