Files
NapCatQQ/packages/napcat-onebot/action/system/GetCSRF.ts
T
手瓜一十雪 974528fe7e Apply formatting and minor style fixes across repo
Normalize code style across multiple packages: whitespace cleanup, consistent commas and trailing commas in arrays/enums/objects, fix table markdown lines in CI comment template, ensure newline at EOF, normalize header/object property quoting and spacing, remove stray blank lines and minor non-functional comment tweaks. These are formatting-only changes and small type/annotation spacing adjustments; no functional behavior changes intended.
2026-03-05 18:45:50 +08:00

33 lines
1019 B
TypeScript

import { OneBotAction } from '@/napcat-onebot/action/OneBotAction';
import { ActionName } from '@/napcat-onebot/action/router';
import { Type, Static } from '@sinclair/typebox';
export const GetCSRFReturnSchema = Type.Object({
token: Type.Number({ description: 'CSRF Token' }),
});
export type GetCSRFReturnType = Static<typeof GetCSRFReturnSchema>;
export class GetCSRF extends OneBotAction<void, GetCSRFReturnType> {
override actionName = ActionName.GetCSRF;
override payloadSchema = Type.Object({});
override returnSchema = GetCSRFReturnSchema;
override actionSummary = '获取 CSRF Token';
override actionDescription = '获取 CSRF Token';
override actionTags = ['系统接口'];
override payloadExample = {};
override returnExample = {
token: 123456789,
};
async _handle () {
const sKey = await this.core.apis.UserApi.getSKey();
if (!sKey) {
throw new Error('SKey is undefined');
}
return {
token: +this.core.apis.WebApi.getBknFromSKey(sKey),
};
}
}