File tree Expand file tree Collapse file tree 3 files changed +19
-18
lines changed Expand file tree Collapse file tree 3 files changed +19
-18
lines changed Original file line number Diff line number Diff line change 43
43
"@react-email/components" : " 0.0.16" ,
44
44
"@total-typescript/ts-reset" : " ^0.4.2" ,
45
45
"@types/cookie" : " ^0.5.1" ,
46
+ "@types/jsonwebtoken" : " ^9.0.6" ,
46
47
"@types/pg" : " ^8.11.5" ,
48
+ "@types/react" : " ^18.2.22" ,
47
49
"@typescript-eslint/eslint-plugin" : " ^5.61.0" ,
48
50
"@typescript-eslint/parser" : " ^5.61.0" ,
49
51
"@vitest/coverage-v8" : " ^0.33.0" ,
86
88
"@pothos/plugin-tracing" : " ^0.5.8" ,
87
89
"@sanity/client" : " ^6.7.0" ,
88
90
"@tsndr/cloudflare-worker-jwt" : " ^2.5.3" ,
89
- "@types/jsonwebtoken" : " ^9.0.6" ,
90
- "@types/react" : " ^18.2.22" ,
91
91
"cookie" : " ^0.5.0" ,
92
92
"dataloader" : " ^2.2.2" ,
93
93
"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" ;
2
2
import { Logger } from "pino" ;
3
3
4
4
import { TokenPayload } from "~/authn/types" ;
@@ -27,20 +27,6 @@ const getAuthToken = (request: Request) => {
27
27
return null ;
28
28
} ;
29
29
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
-
44
30
// Obtener el token de autorización de la solicitud, ya sea del encabezado de
45
31
// autorización o de la cookie "community-os-access-token"
46
32
const getImpersonatedUserFromRequest = async (
Original file line number Diff line number Diff line change
1
+ import { sign } from "@tsndr/cloudflare-worker-jwt" ;
1
2
import { eq } from "drizzle-orm" ;
2
3
import { GraphQLError } from "graphql" ;
3
4
4
- import { createMinimalAuthToken } from "~/authn" ;
5
5
import { builder } from "~/builder" ;
6
6
import {
7
7
PronounsEnum ,
8
8
selectUsersSchema ,
9
9
updateUsersSchema ,
10
+ USER ,
10
11
usersSchema ,
11
12
usersToCommunitiesSchema ,
12
13
} from "~/datasources/db/schema" ;
@@ -19,6 +20,20 @@ import {
19
20
isSameUser ,
20
21
} from "~/validations" ;
21
22
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
+
22
37
const userEditInput = builder . inputType ( "userEditInput" , {
23
38
fields : ( t ) => ( {
24
39
id : t . string ( { required : true } ) ,
You can’t perform that action at this time.
0 commit comments