File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 1
1
# Token Handler Assistant Changelog
2
2
3
+ ## [ Pending]
4
+
5
+ - Add support for extra parameters in refresh requests
6
+
3
7
## [ 1.1.0] - 2024-08-12
4
8
5
9
- Send ` token-handler-version ` header in all requests
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
16
16
EndLoginRequest ,
17
17
LogoutResponse ,
18
18
OAuthAgentRemoteError ,
19
+ RefreshRequest ,
19
20
RefreshResponse ,
20
21
SessionResponse ,
21
22
StartLoginRequest ,
@@ -48,13 +49,16 @@ export class OAuthAgentClient {
48
49
49
50
/**
50
51
* Refreshes the access token. Calls the `/refresh` endpoint.
52
+ *
53
+ * @param request the refresh request possibly containing extra parameters
51
54
*
52
55
* @return the refresh token response possibly containing the new access token's expiration time
53
- *
56
+ *
54
57
* @throws OAuthAgentRemoteError when OAuth Agent responded with an error
55
58
*/
56
- async refresh ( ) : Promise < RefreshResponse > {
57
- const refreshResponse = await this . fetch ( "POST" , "refresh" )
59
+ async refresh ( request ?: RefreshRequest ) : Promise < RefreshResponse > {
60
+ const urlSearchParams = this . toUrlSearchParams ( request ?. extraRefreshParameters )
61
+ const refreshResponse = await this . fetch ( "POST" , "refresh" , urlSearchParams )
58
62
59
63
return {
60
64
accessTokenExpiresIn : refreshResponse . access_token_expires_in
@@ -175,7 +179,7 @@ export class OAuthAgentClient {
175
179
'token-handler-version' : '1'
176
180
} as Record < string , string >
177
181
178
- if ( path == 'login/start' || path == 'login/end' ) {
182
+ if ( content && content . size ! == 0 ) {
179
183
headers [ "content-type" ] = 'application/x-www-form-urlencoded'
180
184
}
181
185
Original file line number Diff line number Diff line change 17
17
* (such as `scope`, `login_hint` or `ui_locales`). These parameters will be used in the authorization request.
18
18
* Each parameter has to be explicitly allowed in the configuration of the token handler application
19
19
* in the Curity server.
20
- *
21
20
*/
22
21
export interface StartLoginRequest {
23
22
readonly extraAuthorizationParameters ?: { [ key : string ] : string } ;
@@ -54,6 +53,17 @@ export interface SessionResponse {
54
53
readonly accessTokenExpiresIn ?: number ;
55
54
}
56
55
56
+ /**
57
+ * Passed to {@link OAuthAgentClient#refresh} function.
58
+ */
59
+ export interface RefreshRequest {
60
+ /**
61
+ * Extra parameters to be used in the token refresh request.
62
+ * Each parameter has to be explicitly allowed in the configuration of the token handler application
63
+ * in the Curity server.
64
+ */
65
+ readonly extraRefreshParameters ?: { [ key : string ] : string } ;
66
+ }
57
67
58
68
/**
59
69
* Returned from the {@link OAuthAgentClient#refresh} function. Contains:
You can’t perform that action at this time.
0 commit comments