( state: string | undefined, options: InternalOptions<"oauth"> )
| 43 | * and clears the container cookie afterwards. |
| 44 | */ |
| 45 | export async function useState( |
| 46 | state: string | undefined, |
| 47 | options: InternalOptions<"oauth"> |
| 48 | ): Promise<{ value: string; cookie: Cookie } | undefined> { |
| 49 | const { cookies, provider, jwt } = options |
| 50 | |
| 51 | if (!provider.checks?.includes("state") || !state) return |
| 52 | |
| 53 | const value = (await jwt.decode({ ...options.jwt, token: state })) as any |
| 54 | |
| 55 | return { |
| 56 | value: value?.state ?? undefined, |
| 57 | cookie: { |
| 58 | name: cookies.state.name, |
| 59 | value: "", |
| 60 | options: { ...cookies.pkceCodeVerifier.options, maxAge: 0 }, |
| 61 | }, |
| 62 | } |
| 63 | } |
no outgoing calls
searching dependent graphs…