1141 lines
53 KiB
JavaScript
1141 lines
53 KiB
JavaScript
module.exports = [
|
|
"[externals]/next/dist/compiled/next-server/app-page-turbo.runtime.dev.js [external] (next/dist/compiled/next-server/app-page-turbo.runtime.dev.js, cjs)", ((__turbopack_context__, module, exports) => {
|
|
|
|
const mod = __turbopack_context__.x("next/dist/compiled/next-server/app-page-turbo.runtime.dev.js", () => require("next/dist/compiled/next-server/app-page-turbo.runtime.dev.js"));
|
|
|
|
module.exports = mod;
|
|
}),
|
|
"[project]/Documents/00 - projet/plumeia/src/lib/api.ts [app-ssr] (ecmascript)", ((__turbopack_context__) => {
|
|
"use strict";
|
|
|
|
__turbopack_context__.s([
|
|
"default",
|
|
()=>__TURBOPACK__default__export__
|
|
]);
|
|
const API_BASE_URL = '/api';
|
|
// --- API CLIENT ---
|
|
const api = {
|
|
async request (endpoint, options = {}) {
|
|
const url = `${API_BASE_URL}${endpoint}`;
|
|
const headers = {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
};
|
|
const response = await fetch(url, {
|
|
...options,
|
|
headers
|
|
});
|
|
if (!response.ok) {
|
|
let errorMsg = `Error ${response.status}: ${response.statusText}`;
|
|
try {
|
|
const errorJson = await response.json();
|
|
if (errorJson.error) errorMsg = errorJson.error;
|
|
if (errorJson.message) errorMsg = errorJson.message;
|
|
} catch {
|
|
// Ignore json parse error
|
|
}
|
|
throw new Error(errorMsg);
|
|
}
|
|
if (response.status === 204) return null;
|
|
return response.json();
|
|
},
|
|
// --- AUTH ---
|
|
auth: {
|
|
async register (email, password, name) {
|
|
return api.request('/auth/register', {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
email,
|
|
password,
|
|
name
|
|
})
|
|
});
|
|
}
|
|
},
|
|
// --- USER ---
|
|
user: {
|
|
async updateProfile (data) {
|
|
return api.request('/user/profile', {
|
|
method: 'PUT',
|
|
body: JSON.stringify(data)
|
|
});
|
|
}
|
|
},
|
|
// --- PROJECTS ---
|
|
projects: {
|
|
async list () {
|
|
return api.request('/projects');
|
|
},
|
|
async get (id) {
|
|
return api.request(`/projects/${id}`);
|
|
},
|
|
async create (data) {
|
|
return api.request('/projects', {
|
|
method: 'POST',
|
|
body: JSON.stringify(data)
|
|
});
|
|
},
|
|
async update (id, data) {
|
|
return api.request(`/projects/${id}`, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(data)
|
|
});
|
|
},
|
|
async delete (id) {
|
|
return api.request(`/projects/${id}`, {
|
|
method: 'DELETE'
|
|
});
|
|
},
|
|
async syncWorkflow (id, data) {
|
|
return api.request(`/projects/${id}/workflow`, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(data)
|
|
});
|
|
}
|
|
},
|
|
// --- CHAPTERS ---
|
|
chapters: {
|
|
async create (data) {
|
|
return api.request('/chapters', {
|
|
method: 'POST',
|
|
body: JSON.stringify(data)
|
|
});
|
|
},
|
|
async update (id, data) {
|
|
return api.request(`/chapters/${id}`, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(data)
|
|
});
|
|
},
|
|
async delete (id) {
|
|
return api.request(`/chapters/${id}`, {
|
|
method: 'DELETE'
|
|
});
|
|
}
|
|
},
|
|
// --- ENTITIES ---
|
|
entities: {
|
|
async create (data) {
|
|
return api.request('/entities', {
|
|
method: 'POST',
|
|
body: JSON.stringify(data)
|
|
});
|
|
},
|
|
async update (id, data) {
|
|
return api.request(`/entities/${id}`, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(data)
|
|
});
|
|
},
|
|
async delete (id) {
|
|
return api.request(`/entities/${id}`, {
|
|
method: 'DELETE'
|
|
});
|
|
}
|
|
},
|
|
// --- IDEAS ---
|
|
ideas: {
|
|
async create (data) {
|
|
return api.request('/ideas', {
|
|
method: 'POST',
|
|
body: JSON.stringify(data)
|
|
});
|
|
},
|
|
async update (id, data) {
|
|
return api.request(`/ideas/${id}`, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(data)
|
|
});
|
|
},
|
|
async delete (id) {
|
|
return api.request(`/ideas/${id}`, {
|
|
method: 'DELETE'
|
|
});
|
|
}
|
|
},
|
|
// --- AI (server-side via API routes) ---
|
|
ai: {
|
|
async generate (project, chapterId, prompt, user) {
|
|
return api.request('/ai/generate', {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
project,
|
|
chapterId,
|
|
prompt,
|
|
user
|
|
})
|
|
});
|
|
},
|
|
async transform (text, mode, context, user) {
|
|
const res = await api.request('/ai/transform', {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
text,
|
|
mode,
|
|
context,
|
|
user
|
|
})
|
|
});
|
|
return res.text;
|
|
}
|
|
}
|
|
};
|
|
const __TURBOPACK__default__export__ = api;
|
|
}),
|
|
"[project]/Documents/00 - projet/plumeia/src/hooks/useAuth.ts [app-ssr] (ecmascript)", ((__turbopack_context__) => {
|
|
"use strict";
|
|
|
|
__turbopack_context__.s([
|
|
"useAuth",
|
|
()=>useAuth
|
|
]);
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react.js [app-ssr] (ecmascript)");
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next-auth/react.js [app-ssr] (ecmascript)");
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$src$2f$lib$2f$api$2e$ts__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/src/lib/api.ts [app-ssr] (ecmascript)");
|
|
'use client';
|
|
;
|
|
;
|
|
;
|
|
const useAuth = ()=>{
|
|
const { data: session, status } = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useSession"])();
|
|
const [user, setUser] = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useState"])(null);
|
|
const loading = status === 'loading';
|
|
// Fetch real profile from DB when session is available
|
|
(0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useEffect"])(()=>{
|
|
if (session?.user?.id) {
|
|
fetch('/api/user/profile', {
|
|
cache: 'no-store'
|
|
}).then((res)=>res.json()).then((dbUser)=>{
|
|
const planId = dbUser.plan || 'free';
|
|
const planDetails = dbUser.planDetails || {
|
|
id: 'free',
|
|
displayName: 'Gratuit',
|
|
maxAiActions: 100,
|
|
maxProjects: 3
|
|
};
|
|
setUser({
|
|
id: dbUser.id,
|
|
email: dbUser.email,
|
|
name: dbUser.name || 'User',
|
|
avatar: dbUser.avatar,
|
|
bio: dbUser.bio,
|
|
subscription: {
|
|
plan: planId,
|
|
planDetails: planDetails,
|
|
startDate: new Date(dbUser.createdAt).getTime(),
|
|
status: 'active'
|
|
},
|
|
usage: {
|
|
aiActionsCurrent: dbUser.aiActionsUsed || 0,
|
|
aiActionsLimit: planDetails.maxAiActions,
|
|
projectsLimit: planDetails.maxProjects
|
|
},
|
|
preferences: {
|
|
theme: 'light',
|
|
dailyWordGoal: dbUser.dailyWordGoal || 500,
|
|
language: 'fr'
|
|
},
|
|
stats: {
|
|
totalWordsWritten: dbUser.totalWords || 0,
|
|
writingStreak: dbUser.writingStreak || 0,
|
|
lastWriteDate: dbUser.lastWriteDate ? new Date(dbUser.lastWriteDate).getTime() : 0
|
|
}
|
|
});
|
|
}).catch((err)=>{
|
|
console.error('Failed to fetch user profile:', err);
|
|
// Fallback to session data
|
|
setUser({
|
|
id: session.user.id || '',
|
|
email: session.user.email || '',
|
|
name: session.user.name || 'User',
|
|
subscription: {
|
|
plan: 'free',
|
|
startDate: Date.now(),
|
|
status: 'active'
|
|
},
|
|
usage: {
|
|
aiActionsCurrent: 0,
|
|
aiActionsLimit: 100,
|
|
projectsLimit: 3
|
|
},
|
|
preferences: {
|
|
theme: 'light',
|
|
dailyWordGoal: 500,
|
|
language: 'fr'
|
|
},
|
|
stats: {
|
|
totalWordsWritten: 0,
|
|
writingStreak: 0,
|
|
lastWriteDate: 0
|
|
}
|
|
});
|
|
});
|
|
} else if (status === 'unauthenticated') {
|
|
setUser(null);
|
|
}
|
|
}, [
|
|
session,
|
|
status
|
|
]);
|
|
const login = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useCallback"])(async (email, password)=>{
|
|
const result = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["signIn"])('credentials', {
|
|
email,
|
|
password,
|
|
redirect: false
|
|
});
|
|
if (result?.error) {
|
|
throw new Error(result.error === 'CredentialsSignin' ? 'Email ou mot de passe incorrect' : result.error);
|
|
}
|
|
}, []);
|
|
const signup = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useCallback"])(async (email, password, name)=>{
|
|
await __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$src$2f$lib$2f$api$2e$ts__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["default"].auth.register(email, password, name);
|
|
const result = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["signIn"])('credentials', {
|
|
email,
|
|
password,
|
|
redirect: false
|
|
});
|
|
if (result?.error) {
|
|
throw new Error('Compte créé mais erreur de connexion automatique');
|
|
}
|
|
}, []);
|
|
const logout = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useCallback"])(async ()=>{
|
|
await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["signOut"])({
|
|
redirect: false
|
|
});
|
|
setUser(null);
|
|
}, []);
|
|
const incrementUsage = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useCallback"])((serverCount)=>{
|
|
if (user) {
|
|
setUser({
|
|
...user,
|
|
usage: {
|
|
...user.usage,
|
|
aiActionsCurrent: serverCount !== undefined ? serverCount : user.usage.aiActionsCurrent + 1
|
|
}
|
|
});
|
|
}
|
|
}, [
|
|
user
|
|
]);
|
|
const updateProfile = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useCallback"])(async (updates)=>{
|
|
if (!user) return;
|
|
try {
|
|
// Unpack everything that can be updated into a flat object for the API
|
|
const apiUpdates = {};
|
|
if (updates.name !== undefined) apiUpdates.name = updates.name;
|
|
if (updates.avatar !== undefined) apiUpdates.avatar = updates.avatar;
|
|
if (updates.bio !== undefined) apiUpdates.bio = updates.bio;
|
|
if (updates.preferences?.dailyWordGoal !== undefined) apiUpdates.dailyWordGoal = updates.preferences.dailyWordGoal;
|
|
// Make the API call to update DB
|
|
await __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$src$2f$lib$2f$api$2e$ts__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["default"].user.updateProfile(apiUpdates);
|
|
// Update local state
|
|
setUser((prev)=>prev ? {
|
|
...prev,
|
|
...updates
|
|
} : null);
|
|
} catch (err) {
|
|
console.error('Failed to update profile:', err);
|
|
throw err;
|
|
}
|
|
}, [
|
|
user
|
|
]);
|
|
return {
|
|
user,
|
|
login,
|
|
signup,
|
|
logout,
|
|
incrementUsage,
|
|
updateProfile,
|
|
loading
|
|
};
|
|
};
|
|
}),
|
|
"[project]/Documents/00 - projet/plumeia/src/providers/AuthProvider.tsx [app-ssr] (ecmascript)", ((__turbopack_context__) => {
|
|
"use strict";
|
|
|
|
__turbopack_context__.s([
|
|
"AuthProvider",
|
|
()=>AuthProvider,
|
|
"useAuthContext",
|
|
()=>useAuthContext
|
|
]);
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2d$jsx$2d$dev$2d$runtime$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-jsx-dev-runtime.js [app-ssr] (ecmascript)");
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react.js [app-ssr] (ecmascript)");
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next-auth/react.js [app-ssr] (ecmascript)");
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$src$2f$hooks$2f$useAuth$2e$ts__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/src/hooks/useAuth.ts [app-ssr] (ecmascript)");
|
|
'use client';
|
|
;
|
|
;
|
|
;
|
|
;
|
|
const AuthContext = /*#__PURE__*/ (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["createContext"])(null);
|
|
function AuthInner({ children }) {
|
|
const auth = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$src$2f$hooks$2f$useAuth$2e$ts__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useAuth"])();
|
|
return /*#__PURE__*/ (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2d$jsx$2d$dev$2d$runtime$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["jsxDEV"])(AuthContext.Provider, {
|
|
value: auth,
|
|
children: children
|
|
}, void 0, false, {
|
|
fileName: "[project]/Documents/00 - projet/plumeia/src/providers/AuthProvider.tsx",
|
|
lineNumber: 11,
|
|
columnNumber: 12
|
|
}, this);
|
|
}
|
|
const AuthProvider = ({ children })=>{
|
|
return /*#__PURE__*/ (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2d$jsx$2d$dev$2d$runtime$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["jsxDEV"])(__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["SessionProvider"], {
|
|
children: /*#__PURE__*/ (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2d$jsx$2d$dev$2d$runtime$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["jsxDEV"])(AuthInner, {
|
|
children: children
|
|
}, void 0, false, {
|
|
fileName: "[project]/Documents/00 - projet/plumeia/src/providers/AuthProvider.tsx",
|
|
lineNumber: 17,
|
|
columnNumber: 13
|
|
}, ("TURBOPACK compile-time value", void 0))
|
|
}, void 0, false, {
|
|
fileName: "[project]/Documents/00 - projet/plumeia/src/providers/AuthProvider.tsx",
|
|
lineNumber: 16,
|
|
columnNumber: 9
|
|
}, ("TURBOPACK compile-time value", void 0));
|
|
};
|
|
function useAuthContext() {
|
|
return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useContext"])(AuthContext);
|
|
}
|
|
}),
|
|
"[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/module.compiled.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
|
|
"use strict";
|
|
|
|
if ("TURBOPACK compile-time falsy", 0) //TURBOPACK unreachable
|
|
;
|
|
else {
|
|
if ("TURBOPACK compile-time falsy", 0) //TURBOPACK unreachable
|
|
;
|
|
else {
|
|
if ("TURBOPACK compile-time truthy", 1) {
|
|
if ("TURBOPACK compile-time truthy", 1) {
|
|
module.exports = __turbopack_context__.r("[externals]/next/dist/compiled/next-server/app-page-turbo.runtime.dev.js [external] (next/dist/compiled/next-server/app-page-turbo.runtime.dev.js, cjs)");
|
|
} else //TURBOPACK unreachable
|
|
;
|
|
} else //TURBOPACK unreachable
|
|
;
|
|
}
|
|
} //# sourceMappingURL=module.compiled.js.map
|
|
}),
|
|
"[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-jsx-dev-runtime.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
|
|
"use strict";
|
|
|
|
module.exports = __turbopack_context__.r("[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/module.compiled.js [app-ssr] (ecmascript)").vendored['react-ssr'].ReactJsxDevRuntime; //# sourceMappingURL=react-jsx-dev-runtime.js.map
|
|
}),
|
|
"[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
|
|
"use strict";
|
|
|
|
module.exports = __turbopack_context__.r("[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/module.compiled.js [app-ssr] (ecmascript)").vendored['react-ssr'].React; //# sourceMappingURL=react.js.map
|
|
}),
|
|
"[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-jsx-runtime.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
|
|
"use strict";
|
|
|
|
module.exports = __turbopack_context__.r("[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/module.compiled.js [app-ssr] (ecmascript)").vendored['react-ssr'].ReactJsxRuntime; //# sourceMappingURL=react-jsx-runtime.js.map
|
|
}),
|
|
"[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/errors.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
|
|
"use strict";
|
|
|
|
/**
|
|
* Base error class for all Auth.js errors.
|
|
* It's optimized to be printed in the server logs in a nicely formatted way
|
|
* via the [`logger.error`](https://authjs.dev/reference/core#logger) option.
|
|
* @noInheritDoc
|
|
*/ __turbopack_context__.s([
|
|
"AccessDenied",
|
|
()=>AccessDenied,
|
|
"AccountNotLinked",
|
|
()=>AccountNotLinked,
|
|
"AdapterError",
|
|
()=>AdapterError,
|
|
"AuthError",
|
|
()=>AuthError,
|
|
"CallbackRouteError",
|
|
()=>CallbackRouteError,
|
|
"CredentialsSignin",
|
|
()=>CredentialsSignin,
|
|
"DuplicateConditionalUI",
|
|
()=>DuplicateConditionalUI,
|
|
"EmailSignInError",
|
|
()=>EmailSignInError,
|
|
"ErrorPageLoop",
|
|
()=>ErrorPageLoop,
|
|
"EventError",
|
|
()=>EventError,
|
|
"ExperimentalFeatureNotEnabled",
|
|
()=>ExperimentalFeatureNotEnabled,
|
|
"InvalidCallbackUrl",
|
|
()=>InvalidCallbackUrl,
|
|
"InvalidCheck",
|
|
()=>InvalidCheck,
|
|
"InvalidEndpoints",
|
|
()=>InvalidEndpoints,
|
|
"InvalidProvider",
|
|
()=>InvalidProvider,
|
|
"JWTSessionError",
|
|
()=>JWTSessionError,
|
|
"MissingAdapter",
|
|
()=>MissingAdapter,
|
|
"MissingAdapterMethods",
|
|
()=>MissingAdapterMethods,
|
|
"MissingAuthorize",
|
|
()=>MissingAuthorize,
|
|
"MissingCSRF",
|
|
()=>MissingCSRF,
|
|
"MissingSecret",
|
|
()=>MissingSecret,
|
|
"MissingWebAuthnAutocomplete",
|
|
()=>MissingWebAuthnAutocomplete,
|
|
"OAuthAccountNotLinked",
|
|
()=>OAuthAccountNotLinked,
|
|
"OAuthCallbackError",
|
|
()=>OAuthCallbackError,
|
|
"OAuthProfileParseError",
|
|
()=>OAuthProfileParseError,
|
|
"OAuthSignInError",
|
|
()=>OAuthSignInError,
|
|
"SessionTokenError",
|
|
()=>SessionTokenError,
|
|
"SignInError",
|
|
()=>SignInError,
|
|
"SignOutError",
|
|
()=>SignOutError,
|
|
"UnknownAction",
|
|
()=>UnknownAction,
|
|
"UnsupportedStrategy",
|
|
()=>UnsupportedStrategy,
|
|
"UntrustedHost",
|
|
()=>UntrustedHost,
|
|
"Verification",
|
|
()=>Verification,
|
|
"WebAuthnVerificationError",
|
|
()=>WebAuthnVerificationError,
|
|
"isClientError",
|
|
()=>isClientError
|
|
]);
|
|
class AuthError extends Error {
|
|
/** @internal */ constructor(message, errorOptions){
|
|
if (message instanceof Error) {
|
|
super(undefined, {
|
|
cause: {
|
|
err: message,
|
|
...message.cause,
|
|
...errorOptions
|
|
}
|
|
});
|
|
} else if (typeof message === "string") {
|
|
if (errorOptions instanceof Error) {
|
|
errorOptions = {
|
|
err: errorOptions,
|
|
...errorOptions.cause
|
|
};
|
|
}
|
|
super(message, errorOptions);
|
|
} else {
|
|
super(undefined, message);
|
|
}
|
|
this.name = this.constructor.name;
|
|
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/3841
|
|
this.type = this.constructor.type ?? "AuthError";
|
|
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/3841
|
|
this.kind = this.constructor.kind ?? "error";
|
|
Error.captureStackTrace?.(this, this.constructor);
|
|
const url = `https://errors.authjs.dev#${this.type.toLowerCase()}`;
|
|
this.message += `${this.message ? ". " : ""}Read more at ${url}`;
|
|
}
|
|
}
|
|
class SignInError extends AuthError {
|
|
}
|
|
/** @internal */ SignInError.kind = "signIn";
|
|
class AdapterError extends AuthError {
|
|
}
|
|
AdapterError.type = "AdapterError";
|
|
class AccessDenied extends AuthError {
|
|
}
|
|
AccessDenied.type = "AccessDenied";
|
|
class CallbackRouteError extends AuthError {
|
|
}
|
|
CallbackRouteError.type = "CallbackRouteError";
|
|
class ErrorPageLoop extends AuthError {
|
|
}
|
|
ErrorPageLoop.type = "ErrorPageLoop";
|
|
class EventError extends AuthError {
|
|
}
|
|
EventError.type = "EventError";
|
|
class InvalidCallbackUrl extends AuthError {
|
|
}
|
|
InvalidCallbackUrl.type = "InvalidCallbackUrl";
|
|
class CredentialsSignin extends SignInError {
|
|
constructor(){
|
|
super(...arguments);
|
|
/**
|
|
* The error code that is set in the `code` query parameter of the redirect URL.
|
|
*
|
|
*
|
|
* ⚠ NOTE: This property is going to be included in the URL, so make sure it does not hint at sensitive errors.
|
|
*
|
|
* The full error is always logged on the server, if you need to debug.
|
|
*
|
|
* Generally, we don't recommend hinting specifically if the user had either a wrong username or password specifically,
|
|
* try rather something like "Invalid credentials".
|
|
*/ this.code = "credentials";
|
|
}
|
|
}
|
|
CredentialsSignin.type = "CredentialsSignin";
|
|
class InvalidEndpoints extends AuthError {
|
|
}
|
|
InvalidEndpoints.type = "InvalidEndpoints";
|
|
class InvalidCheck extends AuthError {
|
|
}
|
|
InvalidCheck.type = "InvalidCheck";
|
|
class JWTSessionError extends AuthError {
|
|
}
|
|
JWTSessionError.type = "JWTSessionError";
|
|
class MissingAdapter extends AuthError {
|
|
}
|
|
MissingAdapter.type = "MissingAdapter";
|
|
class MissingAdapterMethods extends AuthError {
|
|
}
|
|
MissingAdapterMethods.type = "MissingAdapterMethods";
|
|
class MissingAuthorize extends AuthError {
|
|
}
|
|
MissingAuthorize.type = "MissingAuthorize";
|
|
class MissingSecret extends AuthError {
|
|
}
|
|
MissingSecret.type = "MissingSecret";
|
|
class OAuthAccountNotLinked extends SignInError {
|
|
}
|
|
OAuthAccountNotLinked.type = "OAuthAccountNotLinked";
|
|
class OAuthCallbackError extends SignInError {
|
|
}
|
|
OAuthCallbackError.type = "OAuthCallbackError";
|
|
class OAuthProfileParseError extends AuthError {
|
|
}
|
|
OAuthProfileParseError.type = "OAuthProfileParseError";
|
|
class SessionTokenError extends AuthError {
|
|
}
|
|
SessionTokenError.type = "SessionTokenError";
|
|
class OAuthSignInError extends SignInError {
|
|
}
|
|
OAuthSignInError.type = "OAuthSignInError";
|
|
class EmailSignInError extends SignInError {
|
|
}
|
|
EmailSignInError.type = "EmailSignInError";
|
|
class SignOutError extends AuthError {
|
|
}
|
|
SignOutError.type = "SignOutError";
|
|
class UnknownAction extends AuthError {
|
|
}
|
|
UnknownAction.type = "UnknownAction";
|
|
class UnsupportedStrategy extends AuthError {
|
|
}
|
|
UnsupportedStrategy.type = "UnsupportedStrategy";
|
|
class InvalidProvider extends AuthError {
|
|
}
|
|
InvalidProvider.type = "InvalidProvider";
|
|
class UntrustedHost extends AuthError {
|
|
}
|
|
UntrustedHost.type = "UntrustedHost";
|
|
class Verification extends AuthError {
|
|
}
|
|
Verification.type = "Verification";
|
|
class MissingCSRF extends SignInError {
|
|
}
|
|
MissingCSRF.type = "MissingCSRF";
|
|
const clientErrors = new Set([
|
|
"CredentialsSignin",
|
|
"OAuthAccountNotLinked",
|
|
"OAuthCallbackError",
|
|
"AccessDenied",
|
|
"Verification",
|
|
"MissingCSRF",
|
|
"AccountNotLinked",
|
|
"WebAuthnVerificationError"
|
|
]);
|
|
function isClientError(error) {
|
|
if (error instanceof AuthError) return clientErrors.has(error.type);
|
|
return false;
|
|
}
|
|
class DuplicateConditionalUI extends AuthError {
|
|
}
|
|
DuplicateConditionalUI.type = "DuplicateConditionalUI";
|
|
class MissingWebAuthnAutocomplete extends AuthError {
|
|
}
|
|
MissingWebAuthnAutocomplete.type = "MissingWebAuthnAutocomplete";
|
|
class WebAuthnVerificationError extends AuthError {
|
|
}
|
|
WebAuthnVerificationError.type = "WebAuthnVerificationError";
|
|
class AccountNotLinked extends SignInError {
|
|
}
|
|
AccountNotLinked.type = "AccountNotLinked";
|
|
class ExperimentalFeatureNotEnabled extends AuthError {
|
|
}
|
|
ExperimentalFeatureNotEnabled.type = "ExperimentalFeatureNotEnabled";
|
|
}),
|
|
"[project]/Documents/00 - projet/plumeia/node_modules/next-auth/lib/client.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
|
|
"use strict";
|
|
|
|
__turbopack_context__.s([
|
|
"ClientSessionError",
|
|
()=>ClientSessionError,
|
|
"apiBaseUrl",
|
|
()=>apiBaseUrl,
|
|
"fetchData",
|
|
()=>fetchData,
|
|
"now",
|
|
()=>now,
|
|
"parseUrl",
|
|
()=>parseUrl,
|
|
"useOnline",
|
|
()=>useOnline
|
|
]);
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react.js [app-ssr] (ecmascript)");
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$errors$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/errors.js [app-ssr] (ecmascript)");
|
|
"use client";
|
|
;
|
|
;
|
|
/** @todo */ class ClientFetchError extends __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$errors$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["AuthError"] {
|
|
}
|
|
class ClientSessionError extends __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$errors$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["AuthError"] {
|
|
}
|
|
async function fetchData(path, __NEXTAUTH, logger, req = {}) {
|
|
const url = `${apiBaseUrl(__NEXTAUTH)}/${path}`;
|
|
try {
|
|
const options = {
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...req?.headers?.cookie ? {
|
|
cookie: req.headers.cookie
|
|
} : {}
|
|
}
|
|
};
|
|
if (req?.body) {
|
|
options.body = JSON.stringify(req.body);
|
|
options.method = "POST";
|
|
}
|
|
const res = await fetch(url, options);
|
|
const data = await res.json();
|
|
if (!res.ok) throw data;
|
|
return data;
|
|
} catch (error) {
|
|
logger.error(new ClientFetchError(error.message, error));
|
|
return null;
|
|
}
|
|
}
|
|
function apiBaseUrl(__NEXTAUTH) {
|
|
if ("TURBOPACK compile-time truthy", 1) {
|
|
// Return absolute path when called server side
|
|
return `${__NEXTAUTH.baseUrlServer}${__NEXTAUTH.basePathServer}`;
|
|
}
|
|
//TURBOPACK unreachable
|
|
;
|
|
}
|
|
function useOnline() {
|
|
const [isOnline, setIsOnline] = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useState"](typeof navigator !== "undefined" ? navigator.onLine : false);
|
|
const setOnline = ()=>setIsOnline(true);
|
|
const setOffline = ()=>setIsOnline(false);
|
|
__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useEffect"](()=>{
|
|
window.addEventListener("online", setOnline);
|
|
window.addEventListener("offline", setOffline);
|
|
return ()=>{
|
|
window.removeEventListener("online", setOnline);
|
|
window.removeEventListener("offline", setOffline);
|
|
};
|
|
}, []);
|
|
return isOnline;
|
|
}
|
|
function now() {
|
|
return Math.floor(Date.now() / 1000);
|
|
}
|
|
function parseUrl(url) {
|
|
const defaultUrl = new URL("http://localhost:3000/api/auth");
|
|
if (url && !url.startsWith("http")) {
|
|
url = `https://${url}`;
|
|
}
|
|
const _url = new URL(url || defaultUrl);
|
|
const path = (_url.pathname === "/" ? defaultUrl.pathname : _url.pathname)// Remove trailing slash
|
|
.replace(/\/$/, "");
|
|
const base = `${_url.origin}${path}`;
|
|
return {
|
|
origin: _url.origin,
|
|
host: _url.host,
|
|
path,
|
|
base,
|
|
toString: ()=>base
|
|
};
|
|
}
|
|
}),
|
|
"[project]/Documents/00 - projet/plumeia/node_modules/next-auth/react.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
|
|
"use strict";
|
|
|
|
__turbopack_context__.s([
|
|
"SessionContext",
|
|
()=>SessionContext,
|
|
"SessionProvider",
|
|
()=>SessionProvider,
|
|
"__NEXTAUTH",
|
|
()=>__NEXTAUTH,
|
|
"getCsrfToken",
|
|
()=>getCsrfToken,
|
|
"getProviders",
|
|
()=>getProviders,
|
|
"getSession",
|
|
()=>getSession,
|
|
"signIn",
|
|
()=>signIn,
|
|
"signOut",
|
|
()=>signOut,
|
|
"useSession",
|
|
()=>useSession
|
|
]);
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2d$jsx$2d$runtime$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react-jsx-runtime.js [app-ssr] (ecmascript)");
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/dist/server/route-modules/app-page/vendored/ssr/react.js [app-ssr] (ecmascript)");
|
|
var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next-auth/lib/client.js [app-ssr] (ecmascript)");
|
|
/**
|
|
*
|
|
* NextAuth.js is the official integration of Auth.js for Next.js applications. It supports both
|
|
* [Client Components](https://nextjs.org/docs/app/building-your-application/rendering/client-components) and the
|
|
* [Pages Router](https://nextjs.org/docs/pages). It includes methods for signing in, signing out, hooks, and a React
|
|
* Context provider to wrap your application and make session data available anywhere.
|
|
*
|
|
* For use in [Server Actions](https://nextjs.org/docs/app/api-reference/functions/server-actions), check out [these methods](https://authjs.dev/guides/upgrade-to-v5#methods)
|
|
*
|
|
* @module react
|
|
*/ "use client";
|
|
;
|
|
;
|
|
;
|
|
const __NEXTAUTH = {
|
|
baseUrl: (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["parseUrl"])(process.env.NEXTAUTH_URL ?? process.env.VERCEL_URL).origin,
|
|
basePath: (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["parseUrl"])(process.env.NEXTAUTH_URL).path,
|
|
baseUrlServer: (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["parseUrl"])(process.env.NEXTAUTH_URL_INTERNAL ?? process.env.NEXTAUTH_URL ?? process.env.VERCEL_URL).origin,
|
|
basePathServer: (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["parseUrl"])(process.env.NEXTAUTH_URL_INTERNAL ?? process.env.NEXTAUTH_URL).path,
|
|
_lastSync: 0,
|
|
_session: undefined,
|
|
_getSession: ()=>{}
|
|
};
|
|
// https://github.com/nextauthjs/next-auth/pull/10762
|
|
let broadcastChannel = null;
|
|
function getNewBroadcastChannel() {
|
|
if (typeof BroadcastChannel === "undefined") {
|
|
return {
|
|
postMessage: ()=>{},
|
|
addEventListener: ()=>{},
|
|
removeEventListener: ()=>{},
|
|
name: "next-auth",
|
|
onmessage: null,
|
|
onmessageerror: null,
|
|
close: ()=>{},
|
|
dispatchEvent: ()=>false
|
|
};
|
|
}
|
|
return new BroadcastChannel("next-auth");
|
|
}
|
|
function broadcast() {
|
|
if (broadcastChannel === null) {
|
|
broadcastChannel = getNewBroadcastChannel();
|
|
}
|
|
return broadcastChannel;
|
|
}
|
|
// TODO:
|
|
const logger = {
|
|
debug: console.debug,
|
|
error: console.error,
|
|
warn: console.warn
|
|
};
|
|
const SessionContext = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["createContext"]?.(undefined);
|
|
function useSession(options) {
|
|
if (!SessionContext) {
|
|
throw new Error("React Context is unavailable in Server Components");
|
|
}
|
|
// @ts-expect-error Satisfy TS if branch on line below
|
|
const value = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useContext"](SessionContext);
|
|
if (!value && ("TURBOPACK compile-time value", "development") !== "production") {
|
|
throw new Error("[next-auth]: `useSession` must be wrapped in a <SessionProvider />");
|
|
}
|
|
const { required, onUnauthenticated } = options ?? {};
|
|
const requiredAndNotLoading = required && value.status === "unauthenticated";
|
|
__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useEffect"](()=>{
|
|
if (requiredAndNotLoading) {
|
|
const url = `${__NEXTAUTH.basePath}/signin?${new URLSearchParams({
|
|
error: "SessionRequired",
|
|
callbackUrl: window.location.href
|
|
})}`;
|
|
if (onUnauthenticated) onUnauthenticated();
|
|
else window.location.href = url;
|
|
}
|
|
}, [
|
|
requiredAndNotLoading,
|
|
onUnauthenticated
|
|
]);
|
|
if (requiredAndNotLoading) {
|
|
return {
|
|
data: value.data,
|
|
update: value.update,
|
|
status: "loading"
|
|
};
|
|
}
|
|
return value;
|
|
}
|
|
async function getSession(params) {
|
|
const session = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["fetchData"])("session", __NEXTAUTH, logger, params);
|
|
if (params?.broadcast ?? true) {
|
|
// https://github.com/nextauthjs/next-auth/pull/11470
|
|
getNewBroadcastChannel().postMessage({
|
|
event: "session",
|
|
data: {
|
|
trigger: "getSession"
|
|
}
|
|
});
|
|
}
|
|
return session;
|
|
}
|
|
async function getCsrfToken() {
|
|
const response = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["fetchData"])("csrf", __NEXTAUTH, logger);
|
|
return response?.csrfToken ?? "";
|
|
}
|
|
async function getProviders() {
|
|
return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["fetchData"])("providers", __NEXTAUTH, logger);
|
|
}
|
|
async function signIn(provider, options, authorizationParams) {
|
|
const { callbackUrl, ...rest } = options ?? {};
|
|
const { redirect = true, redirectTo = callbackUrl ?? window.location.href, ...signInParams } = rest;
|
|
const baseUrl = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["apiBaseUrl"])(__NEXTAUTH);
|
|
const providers = await getProviders();
|
|
if (!providers) {
|
|
const url = `${baseUrl}/error`;
|
|
window.location.href = url;
|
|
return; // TODO: Return error if `redirect: false`
|
|
}
|
|
if (!provider || !providers[provider]) {
|
|
const url = `${baseUrl}/signin?${new URLSearchParams({
|
|
callbackUrl: redirectTo
|
|
})}`;
|
|
window.location.href = url;
|
|
return; // TODO: Return error if `redirect: false`
|
|
}
|
|
const providerType = providers[provider].type;
|
|
if (providerType === "webauthn") {
|
|
// TODO: Add docs link with explanation
|
|
throw new TypeError([
|
|
`Provider id "${provider}" refers to a WebAuthn provider.`,
|
|
'Please use `import { signIn } from "next-auth/webauthn"` instead.'
|
|
].join("\n"));
|
|
}
|
|
const signInUrl = `${baseUrl}/${providerType === "credentials" ? "callback" : "signin"}/${provider}`;
|
|
const csrfToken = await getCsrfToken();
|
|
const res = await fetch(`${signInUrl}?${new URLSearchParams(authorizationParams)}`, {
|
|
method: "post",
|
|
headers: {
|
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
"X-Auth-Return-Redirect": "1"
|
|
},
|
|
body: new URLSearchParams({
|
|
...signInParams,
|
|
csrfToken,
|
|
callbackUrl: redirectTo
|
|
})
|
|
});
|
|
const data = await res.json();
|
|
if (redirect) {
|
|
const url = data.url ?? redirectTo;
|
|
window.location.href = url;
|
|
// If url contains a hash, the browser does not reload the page. We reload manually
|
|
if (url.includes("#")) window.location.reload();
|
|
return;
|
|
}
|
|
const error = new URL(data.url).searchParams.get("error") ?? undefined;
|
|
const code = new URL(data.url).searchParams.get("code") ?? undefined;
|
|
if (res.ok) {
|
|
await __NEXTAUTH._getSession({
|
|
event: "storage"
|
|
});
|
|
}
|
|
return {
|
|
error,
|
|
code,
|
|
status: res.status,
|
|
ok: res.ok,
|
|
url: error ? null : data.url
|
|
};
|
|
}
|
|
async function signOut(options) {
|
|
const { redirect = true, redirectTo = options?.callbackUrl ?? window.location.href } = options ?? {};
|
|
const baseUrl = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["apiBaseUrl"])(__NEXTAUTH);
|
|
const csrfToken = await getCsrfToken();
|
|
const res = await fetch(`${baseUrl}/signout`, {
|
|
method: "post",
|
|
headers: {
|
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
"X-Auth-Return-Redirect": "1"
|
|
},
|
|
body: new URLSearchParams({
|
|
csrfToken,
|
|
callbackUrl: redirectTo
|
|
})
|
|
});
|
|
const data = await res.json();
|
|
broadcast().postMessage({
|
|
event: "session",
|
|
data: {
|
|
trigger: "signout"
|
|
}
|
|
});
|
|
if (redirect) {
|
|
const url = data.url ?? redirectTo;
|
|
window.location.href = url;
|
|
// If url contains a hash, the browser does not reload the page. We reload manually
|
|
if (url.includes("#")) window.location.reload();
|
|
return;
|
|
}
|
|
await __NEXTAUTH._getSession({
|
|
event: "storage"
|
|
});
|
|
return data;
|
|
}
|
|
function SessionProvider(props) {
|
|
if (!SessionContext) {
|
|
throw new Error("React Context is unavailable in Server Components");
|
|
}
|
|
const { children, basePath, refetchInterval, refetchWhenOffline } = props;
|
|
if (basePath) __NEXTAUTH.basePath = basePath;
|
|
/**
|
|
* If session was `null`, there was an attempt to fetch it,
|
|
* but it failed, but we still treat it as a valid initial value.
|
|
*/ const hasInitialSession = props.session !== undefined;
|
|
/** If session was passed, initialize as already synced */ __NEXTAUTH._lastSync = hasInitialSession ? (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["now"])() : 0;
|
|
const [session, setSession] = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useState"](()=>{
|
|
if (hasInitialSession) __NEXTAUTH._session = props.session;
|
|
return props.session;
|
|
});
|
|
/** If session was passed, initialize as not loading */ const [loading, setLoading] = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useState"](!hasInitialSession);
|
|
__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useEffect"](()=>{
|
|
__NEXTAUTH._getSession = async ({ event } = {})=>{
|
|
try {
|
|
const storageEvent = event === "storage";
|
|
// We should always update if we don't have a client session yet
|
|
// or if there are events from other tabs/windows
|
|
if (storageEvent || __NEXTAUTH._session === undefined) {
|
|
__NEXTAUTH._lastSync = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["now"])();
|
|
__NEXTAUTH._session = await getSession({
|
|
broadcast: !storageEvent
|
|
});
|
|
setSession(__NEXTAUTH._session);
|
|
return;
|
|
}
|
|
if (// If there is no time defined for when a session should be considered
|
|
// stale, then it's okay to use the value we have until an event is
|
|
// triggered which updates it
|
|
!event || // If the client doesn't have a session then we don't need to call
|
|
// the server to check if it does (if they have signed in via another
|
|
// tab or window that will come through as a "stroage" event
|
|
// event anyway)
|
|
__NEXTAUTH._session === null || // Bail out early if the client session is not stale yet
|
|
(0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["now"])() < __NEXTAUTH._lastSync) {
|
|
return;
|
|
}
|
|
// An event or session staleness occurred, update the client session.
|
|
__NEXTAUTH._lastSync = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["now"])();
|
|
__NEXTAUTH._session = await getSession();
|
|
setSession(__NEXTAUTH._session);
|
|
} catch (error) {
|
|
logger.error(new __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ClientSessionError"](error.message, error));
|
|
} finally{
|
|
setLoading(false);
|
|
}
|
|
};
|
|
__NEXTAUTH._getSession();
|
|
return ()=>{
|
|
__NEXTAUTH._lastSync = 0;
|
|
__NEXTAUTH._session = undefined;
|
|
__NEXTAUTH._getSession = ()=>{};
|
|
};
|
|
}, []);
|
|
__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useEffect"](()=>{
|
|
const handle = ()=>__NEXTAUTH._getSession({
|
|
event: "storage"
|
|
});
|
|
// Listen for storage events and update session if event fired from
|
|
// another window (but suppress firing another event to avoid a loop)
|
|
// Fetch new session data but tell it to not to fire another event to
|
|
// avoid an infinite loop.
|
|
// Note: We could pass session data through and do something like
|
|
// `setData(message.data)` but that can cause problems depending
|
|
// on how the session object is being used in the client; it is
|
|
// more robust to have each window/tab fetch it's own copy of the
|
|
// session object rather than share it across instances.
|
|
broadcast().addEventListener("message", handle);
|
|
return ()=>broadcast().removeEventListener("message", handle);
|
|
}, []);
|
|
__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useEffect"](()=>{
|
|
const { refetchOnWindowFocus = true } = props;
|
|
// Listen for when the page is visible, if the user switches tabs
|
|
// and makes our tab visible again, re-fetch the session, but only if
|
|
// this feature is not disabled.
|
|
const visibilityHandler = ()=>{
|
|
if (refetchOnWindowFocus && document.visibilityState === "visible") __NEXTAUTH._getSession({
|
|
event: "visibilitychange"
|
|
});
|
|
};
|
|
document.addEventListener("visibilitychange", visibilityHandler, false);
|
|
return ()=>document.removeEventListener("visibilitychange", visibilityHandler, false);
|
|
}, [
|
|
props.refetchOnWindowFocus
|
|
]);
|
|
const isOnline = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useOnline"])();
|
|
// TODO: Flip this behavior in next major version
|
|
const shouldRefetch = refetchWhenOffline !== false || isOnline;
|
|
__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useEffect"](()=>{
|
|
if (refetchInterval && shouldRefetch) {
|
|
const refetchIntervalTimer = setInterval(()=>{
|
|
if (__NEXTAUTH._session) {
|
|
__NEXTAUTH._getSession({
|
|
event: "poll"
|
|
});
|
|
}
|
|
}, refetchInterval * 1000);
|
|
return ()=>clearInterval(refetchIntervalTimer);
|
|
}
|
|
}, [
|
|
refetchInterval,
|
|
shouldRefetch
|
|
]);
|
|
const value = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["useMemo"](()=>({
|
|
data: session,
|
|
status: loading ? "loading" : session ? "authenticated" : "unauthenticated",
|
|
async update (data) {
|
|
if (loading) return;
|
|
setLoading(true);
|
|
const newSession = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$client$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["fetchData"])("session", __NEXTAUTH, logger, typeof data === "undefined" ? undefined : {
|
|
body: {
|
|
csrfToken: await getCsrfToken(),
|
|
data
|
|
}
|
|
});
|
|
setLoading(false);
|
|
if (newSession) {
|
|
setSession(newSession);
|
|
broadcast().postMessage({
|
|
event: "session",
|
|
data: {
|
|
trigger: "getSession"
|
|
}
|
|
});
|
|
}
|
|
return newSession;
|
|
}
|
|
}), [
|
|
session,
|
|
loading
|
|
]);
|
|
return(// @ts-expect-error
|
|
(0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$ssr$2f$react$2d$jsx$2d$runtime$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["jsx"])(SessionContext.Provider, {
|
|
value: value,
|
|
children: children
|
|
}));
|
|
}
|
|
}),
|
|
];
|
|
|
|
//# sourceMappingURL=%5Broot-of-the-server%5D__de10d535._.js.map
|