File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { type HttpMetaParams } from "../../interfaces" ;
12import { type TokenRepository } from "./token-repository" ;
23
4+ export interface RevokeTokenParams {
5+ /** The client ID, obtained during app registration. */
6+ readonly clientId : string ;
7+ /** The client secret, obtained during app registration. */
8+ readonly clientSecret : string ;
9+ /** The previously obtained token, to be invalidated. */
10+ readonly token : string ;
11+ }
12+
313export interface Client {
414 readonly token : TokenRepository ;
15+
16+ /**
17+ * Revoke an access token to make it no longer valid for use.
18+ * @param params Form data parameters
19+ * @param meta HTTP metadata
20+ * @see https://docs.joinmastodon.org/methods/oauth/#revoke
21+ */
22+ revoke (
23+ params : RevokeTokenParams ,
24+ meta ?: HttpMetaParams < "multipart-form" > ,
25+ ) : Promise < void > ;
526}
Original file line number Diff line number Diff line change 11/* eslint-disable @typescript-eslint/no-non-null-assertion */
22import { createOAuthAPIClient } from "../../src" ;
33
4- it ( "issues token" , async ( ) => {
4+ it ( "issues and revokes token" , async ( ) => {
55 const oauth = createOAuthAPIClient ( {
66 url : globalThis . __misc__ . url ,
77 } ) ;
@@ -12,8 +12,14 @@ it("issues token", async () => {
1212 clientSecret : global . __misc__ . app . clientSecret ! ,
1313 username : "admin@localhost" ,
1414 password : "mastodonadmin" ,
15- scope : "read write follow push admin:read admin:write " ,
15+ scope : "read" ,
1616 } ) ;
1717
1818 expect ( token ) . toHaveProperty ( "accessToken" ) ;
19+
20+ await oauth . revoke ( {
21+ clientId : global . __misc__ . app . clientId ! ,
22+ clientSecret : global . __misc__ . app . clientSecret ! ,
23+ token : token . accessToken ! ,
24+ } ) ;
1925} ) ;
You can’t perform that action at this time.
0 commit comments