diff --git a/packages/pl-api/lib/client.ts b/packages/pl-api/lib/client.ts index 8d0f1089f..8285dff92 100644 --- a/packages/pl-api/lib/client.ts +++ b/packages/pl-api/lib/client.ts @@ -1475,11 +1475,23 @@ class PlApiClient { * Requires features{@link Features.sessions}. * @see {@link https://docs.pleroma.social/backend/development/API/pleroma_api/#get-apioauth_tokens} */ - getOauthTokens: () => this.#paginatedGet( - this.features.version.software === GOTOSOCIAL ? '/api/v1/tokens' : '/api/oauth_tokens', - {}, - oauthTokenSchema, - ), + getOauthTokens: () => { + let url; + + switch (this.features.version.software) { + case GOTOSOCIAL: + url = '/api/v1/tokens'; + break; + case MITRA: + url = '/api/v1/settings/sessions'; + break; + default: + url = '/api/oauth_tokens'; + break; + } + + return this.#paginatedGet(url, {}, oauthTokenSchema); + }, /** * Revoke a user session by its ID @@ -1494,6 +1506,9 @@ class PlApiClient { case GOTOSOCIAL: response = await this.request(`/api/v1/tokens/${oauthTokenId}/invalidate`, { method: 'POST' }); break; + case MITRA: + response = await this.request(`/api/v1/settings/sessions/${oauthTokenId}`, { method: 'DELETE' }); + break; default: response = await this.request(`/api/oauth_tokens/${oauthTokenId}`, { method: 'DELETE' }); break; diff --git a/packages/pl-api/lib/entities/oauth-token.ts b/packages/pl-api/lib/entities/oauth-token.ts index ea1488d81..7830f196c 100644 --- a/packages/pl-api/lib/entities/oauth-token.ts +++ b/packages/pl-api/lib/entities/oauth-token.ts @@ -9,6 +9,13 @@ import { datetimeSchema } from './utils'; const oauthTokenSchema = v.pipe( v.any(), v.transform((token: any) => { + if (token.client_name) { + return { + ...token, + app_name: token.client_name, + }; + } + if (token.application) { return { ...token, @@ -31,6 +38,7 @@ const oauthTokenSchema = v.pipe( valid_until: v.fallback(v.nullable(datetimeSchema), null), last_used: v.fallback(v.nullable(datetimeSchema), null), scopes: v.fallback(v.array(v.string()), []), + is_current: v.fallback(v.nullable(v.boolean()), null), }), ); diff --git a/packages/pl-api/lib/features.ts b/packages/pl-api/lib/features.ts index dc004b82a..305c223f9 100644 --- a/packages/pl-api/lib/features.ts +++ b/packages/pl-api/lib/features.ts @@ -1696,6 +1696,7 @@ const getFeatures = (instance: Instance) => { sessions: any([ v.software === AKKOMA, v.software === ICESHRIMP_NET, + v.software === MITRA && gt(v.version, '4.13.1'), v.software === PLEROMA, v.software === GOTOSOCIAL && gte(v.version, '0.18.2'), ]),