2023-11-16 16:38:15 +01:00
|
|
|
import { errors } from '@strapi/utils';
|
2024-03-01 14:41:47 +01:00
|
|
|
import type { Data } from '@strapi/types';
|
2023-11-16 16:38:15 +01:00
|
|
|
|
2023-11-21 18:12:49 +01:00
|
|
|
export type ApiToken = {
|
|
|
|
accessKey: string;
|
2025-05-05 11:06:33 +03:00
|
|
|
encryptedKey: string;
|
2023-11-21 18:12:49 +01:00
|
|
|
createdAt: string;
|
|
|
|
description: string;
|
|
|
|
expiresAt: string;
|
2024-03-01 14:41:47 +01:00
|
|
|
id: Data.ID;
|
2023-11-21 18:12:49 +01:00
|
|
|
lastUsedAt: string | null;
|
2024-02-29 14:32:37 +01:00
|
|
|
lifespan: string | number | null;
|
2023-11-21 18:12:49 +01:00
|
|
|
name: string;
|
|
|
|
permissions: string[];
|
|
|
|
type: 'custom' | 'full-access' | 'read-only';
|
|
|
|
updatedAt: string;
|
|
|
|
};
|
2023-11-16 16:38:15 +01:00
|
|
|
|
2023-11-21 18:12:49 +01:00
|
|
|
export interface ApiTokenBody extends Pick<ApiToken, 'description' | 'name'> {
|
|
|
|
lifespan?: ApiToken['lifespan'] | null;
|
|
|
|
permissions?: ApiToken['permissions'] | null;
|
|
|
|
type: ApiToken['type'] | undefined;
|
|
|
|
}
|
2023-11-16 16:38:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* POST /api-tokens - Create an api token
|
|
|
|
*/
|
|
|
|
export declare namespace Create {
|
|
|
|
export interface Request {
|
|
|
|
body: ApiTokenBody;
|
|
|
|
query: {};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Response {
|
|
|
|
data: ApiToken;
|
|
|
|
error?: errors.ApplicationError | errors.YupValidationError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GET /api-tokens - List api tokens
|
|
|
|
*/
|
|
|
|
export declare namespace List {
|
|
|
|
export interface Request {
|
|
|
|
body: {};
|
|
|
|
query: {};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Response {
|
2023-11-21 18:12:49 +01:00
|
|
|
data: ApiToken[];
|
2023-11-16 16:38:15 +01:00
|
|
|
error?: errors.ApplicationError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DELETE /api-tokens/:id - Delete an API token
|
|
|
|
*/
|
|
|
|
export declare namespace Revoke {
|
|
|
|
export interface Request {
|
|
|
|
body: {};
|
|
|
|
query: {};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Params {
|
2024-03-01 14:41:47 +01:00
|
|
|
id: Data.ID;
|
2023-11-16 16:38:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface Response {
|
2023-11-21 18:12:49 +01:00
|
|
|
data: ApiToken;
|
2023-11-16 16:38:15 +01:00
|
|
|
error?: errors.ApplicationError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GET /api-tokens/:id - Get an API token
|
|
|
|
*/
|
|
|
|
export declare namespace Get {
|
|
|
|
export interface Request {
|
|
|
|
body: {};
|
|
|
|
query: {};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Params {
|
2024-03-01 14:41:47 +01:00
|
|
|
id: Data.ID;
|
2023-11-16 16:38:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface Response {
|
2023-11-21 18:12:49 +01:00
|
|
|
data: ApiToken;
|
2023-11-16 16:38:15 +01:00
|
|
|
error?: errors.ApplicationError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* POST /api-tokens/:id - Update an API token
|
|
|
|
*/
|
|
|
|
export declare namespace Update {
|
|
|
|
export interface Request {
|
|
|
|
body: ApiTokenBody;
|
|
|
|
query: {};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Params {
|
2024-03-01 14:41:47 +01:00
|
|
|
id: Data.ID;
|
2023-11-16 16:38:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface Response {
|
2023-11-21 18:12:49 +01:00
|
|
|
data: ApiToken;
|
2023-11-16 16:38:15 +01:00
|
|
|
error?: errors.ApplicationError | errors.YupValidationError;
|
|
|
|
}
|
|
|
|
}
|