File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343 "@react-email/components" : " 0.0.16" ,
4444 "@total-typescript/ts-reset" : " ^0.4.2" ,
4545 "@types/cookie" : " ^0.5.1" ,
46+ "@types/jsonwebtoken" : " ^9.0.6" ,
4647 "@types/pg" : " ^8.11.5" ,
48+ "@types/react" : " ^18.2.22" ,
4749 "@typescript-eslint/eslint-plugin" : " ^5.61.0" ,
4850 "@typescript-eslint/parser" : " ^5.61.0" ,
4951 "@vitest/coverage-v8" : " ^0.33.0" ,
8688 "@pothos/plugin-tracing" : " ^0.5.8" ,
8789 "@sanity/client" : " ^6.7.0" ,
8890 "@tsndr/cloudflare-worker-jwt" : " ^2.5.3" ,
89- "@types/jsonwebtoken" : " ^9.0.6" ,
90- "@types/react" : " ^18.2.22" ,
9191 "cookie" : " ^0.5.0" ,
9292 "dataloader" : " ^2.2.2" ,
9393 "date-fns" : " ^3.6.0" ,
Original file line number Diff line number Diff line change 1- import { sign , decode , verify } from "@tsndr/cloudflare-worker-jwt" ;
1+ import { decode , verify } from "@tsndr/cloudflare-worker-jwt" ;
22import { Logger } from "pino" ;
33
44import { TokenPayload } from "~/authn/types" ;
@@ -27,20 +27,6 @@ const getAuthToken = (request: Request) => {
2727 return null ;
2828} ;
2929
30- export const createMinimalAuthToken = async ( user : USER , SECRET : string ) => {
31- const payload = {
32- audience : "retool" ,
33- user_metadata : {
34- sub : user . id ,
35- } ,
36- exp : Date . now ( ) + 60 * 60 * 24 * 1000 /* 24 hours */ ,
37- } ;
38-
39- const token = await sign ( payload , SECRET ) ;
40-
41- return token ;
42- } ;
43-
4430// Obtener el token de autorización de la solicitud, ya sea del encabezado de
4531// autorización o de la cookie "community-os-access-token"
4632const getImpersonatedUserFromRequest = async (
Original file line number Diff line number Diff line change 1+ import { sign } from "@tsndr/cloudflare-worker-jwt" ;
12import { eq } from "drizzle-orm" ;
23import { GraphQLError } from "graphql" ;
34
4- import { createMinimalAuthToken } from "~/authn" ;
55import { builder } from "~/builder" ;
66import {
77 PronounsEnum ,
88 selectUsersSchema ,
99 updateUsersSchema ,
10+ USER ,
1011 usersSchema ,
1112 usersToCommunitiesSchema ,
1213} from "~/datasources/db/schema" ;
@@ -19,6 +20,20 @@ import {
1920 isSameUser ,
2021} from "~/validations" ;
2122
23+ const createMinimalAuthToken = async ( user : USER , SECRET : string ) => {
24+ const payload = {
25+ audience : "retool" ,
26+ user_metadata : {
27+ sub : user . id ,
28+ } ,
29+ exp : Date . now ( ) + 60 * 60 * 24 * 1000 /* 24 hours */ ,
30+ } ;
31+
32+ const token = await sign ( payload , SECRET ) ;
33+
34+ return token ;
35+ } ;
36+
2237const userEditInput = builder . inputType ( "userEditInput" , {
2338 fields : ( t ) => ( {
2439 id : t . string ( { required : true } ) ,
You can’t perform that action at this time.
0 commit comments