Skip to content

Commit 11b06b4

Browse files
committed
Support deleting refresh tokens by Id.
1 parent ef46b96 commit 11b06b4

File tree

1 file changed

+96
-2
lines changed

1 file changed

+96
-2
lines changed

src/FusionAuthClient.ts

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,8 +2861,30 @@ export class FusionAuthClient {
28612861
}
28622862

28632863
/**
2864-
* Revokes a single refresh token, all tokens for a user or all tokens for an application. If you provide a user id
2865-
* and an application id, this will delete all the refresh tokens for that user for that application.
2864+
* Revokes refresh tokens.
2865+
*
2866+
* Usage examples:
2867+
* - Delete a single refresh token, pass in only the token.
2868+
* revokeRefreshToken(token)
2869+
*
2870+
* - Delete all refresh tokens for a user, pass in only the userId.
2871+
* revokeRefreshToken(null, userId)
2872+
*
2873+
* - Delete all refresh tokens for a user for a specific application, pass in both the userId and the applicationId.
2874+
* revokeRefreshToken(null, userId, applicationId)
2875+
*
2876+
* - Delete all refresh tokens for an application
2877+
* revokeRefreshToken(null, null, applicationId)
2878+
*
2879+
* Note: <code>null</code> may be handled differently depending upon the programming language.
2880+
*
2881+
* See also: (method names may vary by language... but you'll figure it out)
2882+
*
2883+
* - revokeRefreshTokenById
2884+
* - revokeRefreshTokenByToken
2885+
* - revokeRefreshTokensByUserId
2886+
* - revokeRefreshTokensByApplicationId
2887+
* - revokeRefreshTokensByUserIdForApplication
28662888
*
28672889
* @param {string} token (Optional) The refresh token to delete.
28682890
* @param {UUID} userId (Optional) The user id whose tokens to delete.
@@ -2879,6 +2901,78 @@ export class FusionAuthClient {
28792901
.go();
28802902
}
28812903

2904+
/**
2905+
* Revokes a single refresh token by the unique Id. The unique Id is not sensitive as it cannot be used to obtain another JWT.
2906+
*
2907+
* @param {UUID} tokenId The unique Id of the token to delete.
2908+
* @returns {Promise<ClientResponse<void>>}
2909+
*/
2910+
revokeRefreshTokenById(tokenId: UUID): Promise<ClientResponse<void>> {
2911+
return this.start<void, Errors>()
2912+
.withUri('/api/jwt/refresh')
2913+
.withUriSegment(tokenId)
2914+
.withMethod("DELETE")
2915+
.go();
2916+
}
2917+
2918+
/**
2919+
* Revokes a single refresh token by using the actual refresh token value. This refresh token value is sensitive, so be careful with this API request.
2920+
*
2921+
* @param {string} token The refresh token to delete.
2922+
* @returns {Promise<ClientResponse<void>>}
2923+
*/
2924+
revokeRefreshTokenByToken(token: string): Promise<ClientResponse<void>> {
2925+
return this.start<void, Errors>()
2926+
.withUri('/api/jwt/refresh')
2927+
.withParameter('token', token)
2928+
.withMethod("DELETE")
2929+
.go();
2930+
}
2931+
2932+
/**
2933+
* Revoke all refresh tokens that belong to an application by applicationId.
2934+
*
2935+
* @param {UUID} applicationId The unique Id of the application that you want to delete all refresh tokens for.
2936+
* @returns {Promise<ClientResponse<void>>}
2937+
*/
2938+
revokeRefreshTokensByApplicationId(applicationId: UUID): Promise<ClientResponse<void>> {
2939+
return this.start<void, Errors>()
2940+
.withUri('/api/jwt/refresh')
2941+
.withParameter('applicationId', applicationId)
2942+
.withMethod("DELETE")
2943+
.go();
2944+
}
2945+
2946+
/**
2947+
* Revoke all refresh tokens that belong to a user by user Id.
2948+
*
2949+
* @param {UUID} userId The unique Id of the user that you want to delete all refresh tokens for.
2950+
* @returns {Promise<ClientResponse<void>>}
2951+
*/
2952+
revokeRefreshTokensByUserId(userId: UUID): Promise<ClientResponse<void>> {
2953+
return this.start<void, Errors>()
2954+
.withUri('/api/jwt/refresh')
2955+
.withParameter('userId', userId)
2956+
.withMethod("DELETE")
2957+
.go();
2958+
}
2959+
2960+
/**
2961+
* Revoke all refresh tokens that belong to a user by user Id for a specific application by applicationId.
2962+
*
2963+
* @param {UUID} userId The unique Id of the user that you want to delete all refresh tokens for.
2964+
* @param {UUID} applicationId The unique Id of the application that you want to delete refresh tokens for.
2965+
* @returns {Promise<ClientResponse<void>>}
2966+
*/
2967+
revokeRefreshTokensByUserIdForApplication(userId: UUID, applicationId: UUID): Promise<ClientResponse<void>> {
2968+
return this.start<void, Errors>()
2969+
.withUri('/api/jwt/refresh')
2970+
.withParameter('userId', userId)
2971+
.withParameter('applicationId', applicationId)
2972+
.withMethod("DELETE")
2973+
.go();
2974+
}
2975+
28822976
/**
28832977
* Revokes a single User consent by Id.
28842978
*

0 commit comments

Comments
 (0)