@@ -21,11 +21,17 @@ export async function signCookie(
21
21
22
22
logger . debug ( `CREATE_${ type . toUpperCase ( ) } ` , { value, maxAge } )
23
23
24
+ const { name } = cookies [ type ]
24
25
const expires = new Date ( )
25
26
expires . setTime ( expires . getTime ( ) + maxAge * 1000 )
26
27
return {
27
- name : cookies [ type ] . name ,
28
- value : await jwt . encode ( { ...options . jwt , maxAge, token : { value } } ) ,
28
+ name,
29
+ value : await jwt . encode ( {
30
+ ...options . jwt ,
31
+ maxAge,
32
+ token : { value } ,
33
+ salt : name ,
34
+ } ) ,
29
35
options : { ...cookies [ type ] . options , expires } ,
30
36
}
31
37
}
@@ -71,16 +77,18 @@ export const pkce = {
71
77
if ( ! codeVerifier )
72
78
throw new TypeError ( "PKCE code_verifier cookie was missing." )
73
79
80
+ const { name } = options . cookies . pkceCodeVerifier
74
81
const value = ( await jwt . decode ( {
75
82
...options . jwt ,
76
83
token : codeVerifier ,
84
+ salt : name ,
77
85
} ) ) as any
78
86
79
87
if ( ! value ?. value )
80
88
throw new TypeError ( "PKCE code_verifier value could not be parsed." )
81
89
82
90
resCookies . push ( {
83
- name : options . cookies . pkceCodeVerifier . name ,
91
+ name,
84
92
value : "" ,
85
93
options : { ...options . cookies . pkceCodeVerifier . options , maxAge : 0 } ,
86
94
} )
@@ -121,12 +129,17 @@ export const state = {
121
129
122
130
if ( ! state ) throw new TypeError ( "State cookie was missing." )
123
131
124
- const value = ( await jwt . decode ( { ...options . jwt , token : state } ) ) as any
132
+ const { name } = options . cookies . state
133
+ const value = ( await jwt . decode ( {
134
+ ...options . jwt ,
135
+ token : state ,
136
+ salt : name ,
137
+ } ) ) as any
125
138
126
139
if ( ! value ?. value ) throw new TypeError ( "State value could not be parsed." )
127
140
128
141
resCookies . push ( {
129
- name : options . cookies . state . name ,
142
+ name,
130
143
value : "" ,
131
144
options : { ...options . cookies . state . options , maxAge : 0 } ,
132
145
} )
@@ -166,12 +179,17 @@ export const nonce = {
166
179
const nonce = cookies ?. [ options . cookies . nonce . name ]
167
180
if ( ! nonce ) throw new TypeError ( "Nonce cookie was missing." )
168
181
169
- const value = ( await jwt . decode ( { ...options . jwt , token : nonce } ) ) as any
182
+ const { name } = options . cookies . nonce
183
+ const value = ( await jwt . decode ( {
184
+ ...options . jwt ,
185
+ token : nonce ,
186
+ salt : name ,
187
+ } ) ) as any
170
188
171
189
if ( ! value ?. value ) throw new TypeError ( "Nonce value could not be parsed." )
172
190
173
191
resCookies . push ( {
174
- name : options . cookies . nonce . name ,
192
+ name,
175
193
value : "" ,
176
194
options : { ...options . cookies . nonce . options , maxAge : 0 } ,
177
195
} )
0 commit comments