feat(route-management): add programmatic route management API with API tokens and admin UI

This commit is contained in:
2026-02-23 12:40:26 +00:00
parent 90016d1217
commit f5028ffb60
33 changed files with 2183 additions and 30 deletions

View File

@@ -0,0 +1,83 @@
import * as plugins from '../plugins.js';
import type * as authInterfaces from '../data/auth.js';
import type { IApiTokenInfo, TApiTokenScope } from '../data/route-management.js';
// ============================================================================
// API Token Management Endpoints
// ============================================================================
/**
* Create a new API token. Returns the raw token value once (never shown again).
* Admin JWT only — tokens cannot create tokens.
*/
export interface IReq_CreateApiToken extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_CreateApiToken
> {
method: 'createApiToken';
request: {
identity?: authInterfaces.IIdentity;
name: string;
scopes: TApiTokenScope[];
expiresInDays?: number | null;
};
response: {
success: boolean;
tokenId?: string;
tokenValue?: string;
message?: string;
};
}
/**
* List all API tokens (without hashes).
*/
export interface IReq_ListApiTokens extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_ListApiTokens
> {
method: 'listApiTokens';
request: {
identity?: authInterfaces.IIdentity;
};
response: {
tokens: IApiTokenInfo[];
};
}
/**
* Revoke (delete) an API token.
*/
export interface IReq_RevokeApiToken extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_RevokeApiToken
> {
method: 'revokeApiToken';
request: {
identity?: authInterfaces.IIdentity;
id: string;
};
response: {
success: boolean;
message?: string;
};
}
/**
* Enable or disable an API token.
*/
export interface IReq_ToggleApiToken extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_ToggleApiToken
> {
method: 'toggleApiToken';
request: {
identity?: authInterfaces.IIdentity;
id: string;
enabled: boolean;
};
response: {
success: boolean;
message?: string;
};
}