32 lines
1016 B
TypeScript
32 lines
1016 B
TypeScript
import { GET } from "../defs";
|
|
import type { structure } from "../../apiStructure/sammoRootAPI";
|
|
import type { ExtractError, ExtractQuery, ExtractResponse } from "../../apiStructure/defs";
|
|
import { StartSession } from "../ProcDecorator/StartSession";
|
|
import { declProcDecorators } from "../ProcDecorator/base";
|
|
|
|
type BaseAPI = typeof structure.Login.ReqNonce;
|
|
type RType = ExtractResponse<BaseAPI>;
|
|
type EType = ExtractError<BaseAPI>;
|
|
type QType = ExtractQuery<BaseAPI>;
|
|
|
|
export const ReqNonce = GET<RType, EType, QType>
|
|
(undefined)
|
|
(declProcDecorators([
|
|
StartSession,
|
|
] as const))
|
|
(async (query, ctx) => {
|
|
const nonce = await ctx.getValue<string>("nonce");
|
|
if (nonce !== undefined) {
|
|
return {
|
|
loginNonce: nonce,
|
|
result: true,
|
|
}
|
|
}
|
|
|
|
const newNonce = "1234567890";
|
|
await ctx.setValue("nonce", newNonce);
|
|
return {
|
|
loginNonce: newNonce,
|
|
result: true,
|
|
}
|
|
}); |