diff --git a/packages/api/src/jwt/index.ts b/packages/api/src/jwt/index.ts index d9f40998..0050bada 100644 --- a/packages/api/src/jwt/index.ts +++ b/packages/api/src/jwt/index.ts @@ -49,7 +49,11 @@ export const createSessionToken = async (signedSessionData: SignedPayload) => { }; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const token = jwt.sign(tokenData, "95614424651656c92f70fcc90980fbf25607a87e9fa487d913f455cc740cbd79", jwtOptions()); + const token = jwt.sign( + tokenData, + "95614424651656c92f70fcc90980fbf25607a87e9fa487d913f455cc740cbd79", + jwtOptions(), + ); return token; }; @@ -68,10 +72,14 @@ export const decodeJwtSessionToken = (token: string): { userKey: string } => { export function isJwtTokenValid(token: string) { try { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const decodedToken = jwt.verify(token, "95614424651656c92f70fcc90980fbf25607a87e9fa487d913f455cc740cbd79", { - algorithms: ["HS256"], - issuer: "commune-ts", - }) as jwt.JwtPayload; + const decodedToken = jwt.verify( + token, + "95614424651656c92f70fcc90980fbf25607a87e9fa487d913f455cc740cbd79", + { + algorithms: ["HS256"], + issuer: "commune-ts", + }, + ) as jwt.JwtPayload; // Check if the token has expired const currentTimestamp = Math.floor(Date.now() / 1000); diff --git a/packages/api/src/router/auth.ts b/packages/api/src/router/auth.ts index 7ce2fc4f..5049f5d7 100644 --- a/packages/api/src/router/auth.ts +++ b/packages/api/src/router/auth.ts @@ -8,7 +8,7 @@ import { publicProcedure } from "../trpc"; export const authRouter = { startSession: publicProcedure .input(SignedPayloadSchema) - .mutation( async ({ input }) => { + .mutation(async ({ input }) => { const token = await createSessionToken(input); // TODO: somehow check that the userKey is an valid commune/substrate address diff --git a/packages/api/src/router/dao.ts b/packages/api/src/router/dao.ts index d7743199..7e05a361 100644 --- a/packages/api/src/router/dao.ts +++ b/packages/api/src/router/dao.ts @@ -41,7 +41,7 @@ export const daoRouter = { .input(DAO_VOTE_INSERT_SCHEMA) .mutation(async ({ ctx, input }) => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const userKey = ctx.user!.userKey + const userKey = ctx.user!.userKey; await ctx.db .update(daoVoteSchema) .set({ @@ -56,13 +56,16 @@ export const daoRouter = { ) .execute(); - await ctx.db.insert(daoVoteSchema).values({...input, userKey: userKey}).execute(); + await ctx.db + .insert(daoVoteSchema) + .values({ ...input, userKey: userKey }) + .execute(); }), deleteVote: authenticatedProcedure .input(z.object({ daoId: z.number() })) .mutation(async ({ ctx, input }) => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const userKey = ctx.user!.userKey + const userKey = ctx.user!.userKey; await ctx.db .update(daoVoteSchema) .set({ @@ -79,14 +82,20 @@ export const daoRouter = { .input(CADRE_CANDIDATES_INSERT_SCHEMA) .mutation(async ({ ctx, input }) => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const userKey = ctx.user!.userKey - await ctx.db.insert(cadreCandidatesSchema).values({...input, userKey: userKey }).execute(); + const userKey = ctx.user!.userKey; + await ctx.db + .insert(cadreCandidatesSchema) + .values({ ...input, userKey: userKey }) + .execute(); }), createCadreVote: authenticatedProcedure .input(CADRE_VOTE_INSERT_SCHEMA) .mutation(async ({ ctx, input }) => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const userKey = ctx.user!.userKey - await ctx.db.insert(cadreVoteSchema).values({...input, userKey: userKey }).execute(); + const userKey = ctx.user!.userKey; + await ctx.db + .insert(cadreVoteSchema) + .values({ ...input, userKey: userKey }) + .execute(); }), } satisfies TRPCRouterRecord; diff --git a/packages/db/src/validation.ts b/packages/db/src/validation.ts index 815a3c19..75359e75 100644 --- a/packages/db/src/validation.ts +++ b/packages/db/src/validation.ts @@ -96,7 +96,7 @@ export const USER_MODULE_DATA_INSERT_SCHEMA = createInsertSchema( }, ).omit({ id: true, - userKey: true + userKey: true, }); export const DAO_VOTE_INSERT_SCHEMA = createInsertSchema(daoVoteSchema).omit({