File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 "main" : " dist/index.js" ,
77 "files" : [" dist" ],
88 "license" : " WTFPL" ,
9- "version" : " 1.1.0 " ,
9+ "version" : " 1.1.1 " ,
1010 "type" : " module" ,
1111 "keywords" : [
1212 " auth" ,
Original file line number Diff line number Diff line change 11"use client" ;
22
33import { type ClientSession } from "./index" ;
4- import { getSession } from "./server-actions" ;
54import { createContext , useContext , type ReactNode } from "react" ;
65import useSWR from "swr" ;
76
@@ -66,16 +65,3 @@ export function useUserInfo() {
6665
6766 return context ;
6867}
69-
70- export const createSessionProviderRoute = ( ) => {
71- return async ( _request : Request ) => {
72- const session = await getSession ( ) ;
73-
74- if ( ! session ) {
75- return Response . json ( { error : "Not logged in" } , { status : 401 } ) ;
76- } else {
77- const { accessToken, refreshToken, ...clientSession } = session ;
78- return Response . json ( clientSession ) ;
79- }
80- } ;
81- } ;
Original file line number Diff line number Diff line change 11import { headers } from "next/headers" ;
22import { cookies } from "next/headers" ;
33import { redirect } from "next/navigation" ;
4- import { type Session , getGlobalConfig } from "./index" ;
4+ import { type Session , type ClientSession , getGlobalConfig } from "./index" ;
55import { RefreshAccessToken } from "./lib/oauth" ;
66import jwt from "jsonwebtoken" ;
77
@@ -82,3 +82,16 @@ export const signOut = async (): Promise<Response> => {
8282 { status : 200 } ,
8383 ) ;
8484} ;
85+
86+ export const createSessionProviderRoute = async (
87+ _request : Request ,
88+ ) : Promise < Response > => {
89+ const session = await getSession ( ) ;
90+
91+ if ( ! session ) {
92+ return Response . json ( { error : "Not logged in" } , { status : 401 } ) ;
93+ } else {
94+ const { accessToken, refreshToken, ...clientSession } = session ;
95+ return Response . json ( clientSession ) ;
96+ }
97+ } ;
Original file line number Diff line number Diff line change @@ -14,7 +14,3 @@ export declare function UserInfoProvider(props: {
1414} ) : JSX . Element ;
1515
1616export declare function useUserInfo ( ) : UserInfoContextType ;
17-
18- export declare function createSessionProviderRoute (
19- request : Request ,
20- ) : Promise < Response > ;
Original file line number Diff line number Diff line change @@ -5,3 +5,7 @@ export declare function getSession(): Promise<Session | null>;
55export declare function signIn ( ) : Promise < Response > ;
66
77export declare function signOut ( ) : Promise < Response > ;
8+
9+ export declare function createSessionProviderRoute (
10+ request : Request ,
11+ ) : Promise < Response > ;
You can’t perform that action at this time.
0 commit comments