@flowselections/print-authenticatie-module 0.0.0-stage → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -3
- package/dist-lib/_core-safelist.d.ts +2 -0
- package/dist-lib/_core-safelist.d.ts.map +1 -0
- package/dist-lib/_core-safelist.js +15 -0
- package/dist-lib/components/PrintAuthenticatieModuleLogo.d.ts +6 -0
- package/dist-lib/components/PrintAuthenticatieModuleLogo.d.ts.map +1 -0
- package/dist-lib/components/PrintAuthenticatieModuleLogo.js +4 -0
- package/dist-lib/components/PrintAuthenticatieModulePage.d.ts +2 -0
- package/dist-lib/components/PrintAuthenticatieModulePage.d.ts.map +1 -0
- package/dist-lib/components/PrintAuthenticatieModulePage.js +44 -0
- package/dist-lib/components/settings/PrintAuthenticatieModuleSettingsCard.d.ts +2 -0
- package/dist-lib/components/settings/PrintAuthenticatieModuleSettingsCard.d.ts.map +1 -0
- package/dist-lib/components/settings/PrintAuthenticatieModuleSettingsCard.js +42 -0
- package/dist-lib/hooks/usePrintAuthenticatieModuleData.d.ts +13 -0
- package/dist-lib/hooks/usePrintAuthenticatieModuleData.d.ts.map +1 -0
- package/dist-lib/hooks/usePrintAuthenticatieModuleData.js +49 -0
- package/dist-lib/index.d.ts +6 -0
- package/dist-lib/index.d.ts.map +1 -0
- package/dist-lib/index.js +50 -0
- package/dist-lib/integrations/supabase/auth-attacher.d.ts +2 -0
- package/dist-lib/integrations/supabase/auth-attacher.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/auth-attacher.js +12 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +10 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/auth-middleware.js +52 -0
- package/dist-lib/integrations/supabase/client.d.ts +4 -0
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/client.js +14 -0
- package/dist-lib/integrations/supabase/client.server.d.ts +4 -0
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/client.server.js +30 -0
- package/dist-lib/integrations/supabase/previewAuthStorage.d.ts +12 -0
- package/dist-lib/integrations/supabase/previewAuthStorage.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/previewAuthStorage.js +135 -0
- package/dist-lib/integrations/supabase/types.d.ts +3923 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/types.js +19 -0
- package/dist-lib/lib/utils.d.ts +3 -0
- package/dist-lib/lib/utils.d.ts.map +1 -0
- package/dist-lib/lib/utils.js +5 -0
- package/dist-lib/lib/validationSchemas.d.ts +15 -0
- package/dist-lib/lib/validationSchemas.d.ts.map +1 -0
- package/dist-lib/lib/validationSchemas.js +25 -0
- package/dist-lib/styles.css +1 -0
- package/package.json +87 -4
- package/public/flowselections-assets/print-authenticatie-module/README.md +15 -0
- package/public/logo.png +0 -0
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# print-authenticatie-module
|
|
2
|
+
|
|
3
|
+
blank project start
|
|
4
|
+
|
|
5
|
+
This project was built with [Lovable](https://lovable.dev).
|
|
6
|
+
|
|
7
|
+
## Build with Lovable
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
- **Ship faster**: describe what you want to build and Lovable handles the code.
|
|
11
|
+
- **Stay in sync**: every change made in Lovable is committed straight to this repository.
|
|
12
|
+
- **Full ownership**: this code is yours. Push to `main` on GitHub and your changes sync back into Lovable, ready for your next prompt.
|
|
13
|
+
|
|
14
|
+
## Development
|
|
15
|
+
|
|
16
|
+
Prefer working locally? You need Node.js and npm — [install with nvm](https://github.com/nvm-sh/nvm#installing-and-updating).
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
git clone <this-repository-url>
|
|
20
|
+
cd <repository-name>
|
|
21
|
+
npm i
|
|
22
|
+
npm run dev
|
|
23
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_core-safelist.d.ts","sourceRoot":"","sources":["../src/_core-safelist.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Forceert Tailwind classes die uit @flowselections/core komen maar niet
|
|
2
|
+
// voorkomen in de eigen broncode van deze module.
|
|
3
|
+
// Zonder dit bestand worden deze classes weggeoptimaliseerd op de
|
|
4
|
+
// Lovable productie build.
|
|
5
|
+
const _safelist = [
|
|
6
|
+
// Layout — Sidebar en shell structuur
|
|
7
|
+
'h-full', 'flex-col', 'flex-1', 'min-h-screen', 'ml-64', 'pt-16',
|
|
8
|
+
'items-start', 'items-center', 'justify-between', 'border-t',
|
|
9
|
+
'w-64', 'h-screen', 'h-20', 'overflow-y-auto',
|
|
10
|
+
// Grid — InstellingenPage
|
|
11
|
+
'grid', 'lg:grid-cols-2', 'gap-6', 'p-6', 'space-y-6',
|
|
12
|
+
// Toggle/Switch — aan/uit zichtbaarheid
|
|
13
|
+
'data-[state=checked]:bg-primary', 'data-[state=unchecked]:bg-input',
|
|
14
|
+
];
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface PrintAuthenticatieModuleLogoProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare function PrintAuthenticatieModuleLogo({ className }: PrintAuthenticatieModuleLogoProps): import("react").JSX.Element;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=PrintAuthenticatieModuleLogo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrintAuthenticatieModuleLogo.d.ts","sourceRoot":"","sources":["../../src/components/PrintAuthenticatieModuleLogo.tsx"],"names":[],"mappings":"AAQA,UAAU,iCAAiC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,4BAA4B,CAAC,EAAE,SAAS,EAAE,EAAE,iCAAiC,+BAwB5F"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function PrintAuthenticatieModuleLogo({ className }) {
|
|
3
|
+
return (_jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, "aria-hidden": "true", children: [_jsx("rect", { width: "40", height: "40", rx: "8", fill: "currentColor", opacity: "0.1" }), _jsx("text", { x: "50%", y: "50%", dominantBaseline: "middle", textAnchor: "middle", fontSize: "18", fontWeight: "600", fill: "currentColor", children: "M" })] }));
|
|
4
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrintAuthenticatieModulePage.d.ts","sourceRoot":"","sources":["../../src/components/PrintAuthenticatieModulePage.tsx"],"names":[],"mappings":"AAsBA,wBAAgB,4BAA4B,gCAmF3C"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// src/components/PrintAuthenticatieModulePage.tsx — EXAMPLE PAGE COMPONENT
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Pagina-componenten horen in src/components/, NIET alleen in src/routes/.
|
|
6
|
+
// src/routes/ wordt NIET naar npm gepubliceerd (zie tsconfig.build.json exclude).
|
|
7
|
+
//
|
|
8
|
+
// GEEN <Header /> hier — die zit in _authenticated.tsx via staticData.title
|
|
9
|
+
// ============================================================================
|
|
10
|
+
import { useState, useEffect } from "react";
|
|
11
|
+
import { useAuth, supabase, Button, Card, CardContent, CardHeader, CardTitle, toast, } from "@flowselections/core";
|
|
12
|
+
import { PrintAuthenticatieModuleLogo } from './PrintAuthenticatieModuleLogo.js';
|
|
13
|
+
export function PrintAuthenticatieModulePage() {
|
|
14
|
+
// Auth is guaranteed — this user is already logged in
|
|
15
|
+
const { user, isAdmin } = useAuth();
|
|
16
|
+
// Example state — replace with your own
|
|
17
|
+
const [items, setItems] = useState([]);
|
|
18
|
+
const [loading, setLoading] = useState(true);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
loadData();
|
|
21
|
+
}, []);
|
|
22
|
+
const loadData = async () => {
|
|
23
|
+
setLoading(true);
|
|
24
|
+
try {
|
|
25
|
+
// Example query — replace "products" with your table
|
|
26
|
+
const { data, error } = await supabase
|
|
27
|
+
.from("products")
|
|
28
|
+
.select("*")
|
|
29
|
+
.limit(10);
|
|
30
|
+
if (error)
|
|
31
|
+
throw error;
|
|
32
|
+
// ✅ Altijd Array.isArray bewaken op server-function data
|
|
33
|
+
// const safeItems = Array.isArray(data?.items) ? data.items : [];
|
|
34
|
+
setItems(Array.isArray(data) ? data : []);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
toast.error("Fout bij het laden van gegevens");
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
setLoading(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return (_jsxs("main", { className: "p-6 space-y-6", children: [isAdmin && (_jsxs("div", { className: "text-sm text-muted-foreground", children: ["Ingelogd als admin: ", user?.email] })), _jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Overzicht" }) }), _jsxs(CardContent, { children: [loading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Laden..." })) : items.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Geen gegevens gevonden." })) : (_jsxs("p", { className: "text-sm", children: [items.length, " items geladen."] })), _jsx(Button, { onClick: loadData, className: "mt-4", disabled: loading, children: "Vernieuwen" })] })] }), _jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [_jsx(PrintAuthenticatieModuleLogo, { className: "w-6 h-6 text-primary" }), _jsx("span", { children: "SVG-component (voorkeur voor vector-logo's)" })] })] }));
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrintAuthenticatieModuleSettingsCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/PrintAuthenticatieModuleSettingsCard.tsx"],"names":[],"mappings":"AAiCA,wBAAgB,oCAAoC,gCA+CnD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// src/components/settings/PrintAuthenticatieModuleSettingsCard.tsx — EXAMPLE SETTINGS CARD
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// This is an example of a settings card for your module.
|
|
6
|
+
// It appears on the main settings page when registered in src/index.ts.
|
|
7
|
+
//
|
|
8
|
+
// RULES:
|
|
9
|
+
// - Must return a <Card> as its root element
|
|
10
|
+
// - Handles its own data fetching — no props are passed by the core
|
|
11
|
+
// - Use the same Card primitives from @flowselections/core
|
|
12
|
+
//
|
|
13
|
+
// WHAT TO DO:
|
|
14
|
+
// - Rename this file to match your card's purpose
|
|
15
|
+
// - Add your real settings UI
|
|
16
|
+
// - Register it in src/index.ts under settingsCards
|
|
17
|
+
// - Delete this file entirely if your module has no settings
|
|
18
|
+
// ============================================================================
|
|
19
|
+
import { useState } from "react";
|
|
20
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle, Button, Input, Label, toast, } from "@flowselections/core";
|
|
21
|
+
import { Settings2 } from "lucide-react";
|
|
22
|
+
export function PrintAuthenticatieModuleSettingsCard() {
|
|
23
|
+
// Replace with your real settings state
|
|
24
|
+
const [setting, setSetting] = useState("");
|
|
25
|
+
const [saving, setSaving] = useState(false);
|
|
26
|
+
const handleSave = async () => {
|
|
27
|
+
setSaving(true);
|
|
28
|
+
try {
|
|
29
|
+
// Example: save to a table — replace with your real query
|
|
30
|
+
// const { error } = await supabase.from("my_settings").upsert({ ... });
|
|
31
|
+
// if (error) throw error;
|
|
32
|
+
toast.success("Instellingen opgeslagen");
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
toast.error("Fout bij het opslaan");
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
setSaving(false);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Settings2, { className: "h-5 w-5 text-primary" }), _jsx(CardTitle, { children: "Module Instellingen" }), " "] }), _jsx(CardDescription, { children: "Beheer de instellingen voor deze module " })] }), _jsxs(CardContent, { className: "space-y-4", children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "setting", children: "Instelling" }), _jsx(Input, { id: "setting", value: setting, onChange: (e) => setSetting(e.target.value), placeholder: "Waarde..." })] }), _jsx(Button, { onClick: handleSave, disabled: saving, children: saving ? "Opslaan..." : "Opslaan" })] })] }));
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface PrintAuthenticatieModuleItem {
|
|
2
|
+
id: string;
|
|
3
|
+
created_at: string;
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
}
|
|
6
|
+
export declare function usePrintAuthenticatieModuleData(): {
|
|
7
|
+
items: PrintAuthenticatieModuleItem[];
|
|
8
|
+
loading: boolean;
|
|
9
|
+
error: string | null;
|
|
10
|
+
reload: () => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=usePrintAuthenticatieModuleData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrintAuthenticatieModuleData.d.ts","sourceRoot":"","sources":["../../src/hooks/usePrintAuthenticatieModuleData.ts"],"names":[],"mappings":"AAkBA,UAAU,4BAA4B;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,+BAA+B;;;;;EAkC9C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// src/hooks/usePrintAuthenticatieModuleData.ts — EXAMPLE DATA HOOK
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Put your data fetching logic in hooks like this, not directly in components.
|
|
5
|
+
// This keeps your pages clean and makes it easy to reuse data across pages.
|
|
6
|
+
//
|
|
7
|
+
// WHAT TO DO:
|
|
8
|
+
// - Rename to match your data (e.g. useProducts, useOrders, useSuppliers)
|
|
9
|
+
// - Replace the example query with your real Supabase query
|
|
10
|
+
// - Replace PrintAuthenticatieModuleItem with your actual table's row type
|
|
11
|
+
// - Import and use in your page components
|
|
12
|
+
// - Delete this file if you prefer a different pattern
|
|
13
|
+
// ============================================================================
|
|
14
|
+
import { useState, useEffect, useCallback } from "react";
|
|
15
|
+
import { supabase, toast } from "@flowselections/core";
|
|
16
|
+
export function usePrintAuthenticatieModuleData() {
|
|
17
|
+
const [items, setItems] = useState([]);
|
|
18
|
+
const [loading, setLoading] = useState(true);
|
|
19
|
+
const [error, setError] = useState(null);
|
|
20
|
+
const load = useCallback(async () => {
|
|
21
|
+
setLoading(true);
|
|
22
|
+
setError(null);
|
|
23
|
+
try {
|
|
24
|
+
const { data, error } = await supabase
|
|
25
|
+
.from("products") // ← CHANGE THIS to your table
|
|
26
|
+
.select("*")
|
|
27
|
+
.order("created_at", { ascending: false });
|
|
28
|
+
if (error)
|
|
29
|
+
throw error;
|
|
30
|
+
setItems(data ?? []);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
setError("Fout bij het laden van gegevens");
|
|
34
|
+
toast.error("Fout bij het laden van gegevens");
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
setLoading(false);
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
load();
|
|
42
|
+
}, [load]);
|
|
43
|
+
return {
|
|
44
|
+
items,
|
|
45
|
+
loading,
|
|
46
|
+
error,
|
|
47
|
+
reload: load,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FlowModule } from "@flowselections/core";
|
|
2
|
+
export * from './_core-safelist.js';
|
|
3
|
+
export { PrintAuthenticatieModulePage } from './components/PrintAuthenticatieModulePage.js';
|
|
4
|
+
export { PrintAuthenticatieModuleLogo } from './components/PrintAuthenticatieModuleLogo.js';
|
|
5
|
+
export declare const printAuthenticatieModuleModule: FlowModule;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAKzF,eAAO,MAAM,8BAA8B,EAAE,UAiC5C,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// src/index.ts — MODULE CONTRACT
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// This is the most important file in your module.
|
|
5
|
+
// The shell repo reads this file to know:
|
|
6
|
+
// - What nav item to show in the sidebar
|
|
7
|
+
// - What settings cards to add to the settings page
|
|
8
|
+
// - Your module's identity (id, name, version)
|
|
9
|
+
//
|
|
10
|
+
// WHAT TO DO:
|
|
11
|
+
// 1. Replace all PLACEHOLDER values below with your module's real values
|
|
12
|
+
// 2. Import your real settings card components (if any)
|
|
13
|
+
// 3. Add your nav item — use `children` if you need a dropdown
|
|
14
|
+
// 4. Done! You don't need to touch any other file for registration.
|
|
15
|
+
// ============================================================================
|
|
16
|
+
import { LayoutDashboard } from "lucide-react"; // ← Replace with your icon
|
|
17
|
+
export * from './_core-safelist.js';
|
|
18
|
+
export { PrintAuthenticatieModulePage } from './components/PrintAuthenticatieModulePage.js';
|
|
19
|
+
export { PrintAuthenticatieModuleLogo } from './components/PrintAuthenticatieModuleLogo.js';
|
|
20
|
+
// Import your settings cards here (delete if you have none)
|
|
21
|
+
// import { MySettingsCard } from "./components/settings/MySettingsCard";
|
|
22
|
+
export const printAuthenticatieModuleModule = {
|
|
23
|
+
// ─── Identity ─────────────────────────────────────────────────────────────
|
|
24
|
+
// id: unique, lowercase, snake_case. Never change this after going live.
|
|
25
|
+
id: "print-authenticatie-module", // ← CHANGE THIS
|
|
26
|
+
// name: human readable, shown in logs
|
|
27
|
+
name: "Print Authenticatie Module", // ← CHANGE THIS
|
|
28
|
+
// version: update when you ship breaking changes
|
|
29
|
+
version: "1.0.0",
|
|
30
|
+
// ─── Sidebar navigation ───────────────────────────────────────────────────
|
|
31
|
+
nav: {
|
|
32
|
+
label: "Print Authenticatie Module", // ← CHANGE THIS — shown in sidebar
|
|
33
|
+
href: "/print-authenticatie-module", // ← CHANGE THIS — must match your route
|
|
34
|
+
icon: LayoutDashboard, // ← CHANGE THIS — any lucide-react icon
|
|
35
|
+
// OPTION A: Single page (no dropdown) — delete the children array below
|
|
36
|
+
// OPTION B: Multiple pages (dropdown) — fill in the children array
|
|
37
|
+
//
|
|
38
|
+
// children: [
|
|
39
|
+
// { label: "Overzicht", href: "/print-authenticatie-module", icon: List },
|
|
40
|
+
// { label: "Instellingen", href: "/print-authenticatie-module/config", icon: Settings2 },
|
|
41
|
+
// ],
|
|
42
|
+
},
|
|
43
|
+
// ─── Settings page cards ──────────────────────────────────────────────────
|
|
44
|
+
// Add any Card components your module contributes to the settings page.
|
|
45
|
+
// Core cards use order 0-9. Start your module at 10, use steps of 10.
|
|
46
|
+
// Leave empty if your module has no settings.
|
|
47
|
+
settingsCards: [
|
|
48
|
+
// { component: MySettingsCard, order: 10 },
|
|
49
|
+
],
|
|
50
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-attacher.d.ts","sourceRoot":"","sources":["../../../src/integrations/supabase/auth-attacher.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,kBAAkB,mHAQ9B,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// This file is automatically generated. Do not edit it directly.
|
|
2
|
+
import { createMiddleware } from '@tanstack/react-start';
|
|
3
|
+
import { supabase } from './client.js';
|
|
4
|
+
// Must be registered as a global `functionMiddleware` in `src/start.ts`; otherwise
|
|
5
|
+
// the browser never attaches the bearer token to serverFn RPCs.
|
|
6
|
+
export const attachSupabaseAuth = createMiddleware({ type: 'function' }).client(async ({ next }) => {
|
|
7
|
+
const { data } = await supabase.auth.getSession();
|
|
8
|
+
const token = data.session?.access_token;
|
|
9
|
+
return next({
|
|
10
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import type { Database } from './types.js';
|
|
3
|
+
export interface AuthedSupabaseClient extends SupabaseClient<Database> {
|
|
4
|
+
}
|
|
5
|
+
export declare const requireSupabaseAuth: import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
6
|
+
supabase: AuthedSupabaseClient;
|
|
7
|
+
userId: string;
|
|
8
|
+
claims: import("@supabase/auth-js").JwtPayload;
|
|
9
|
+
}, undefined, undefined, undefined>;
|
|
10
|
+
//# sourceMappingURL=auth-middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-middleware.d.ts","sourceRoot":"","sources":["../../../src/integrations/supabase/auth-middleware.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGvC,MAAM,WAAW,oBAAqB,SAAQ,cAAc,CAAC,QAAQ,CAAC;CAAG;AAIzE,eAAO,MAAM,mBAAmB;cA8DF,oBAAoB;;;mCAMjD,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// This file is automatically generated. Do not edit it directly.
|
|
2
|
+
import { createMiddleware } from '@tanstack/react-start';
|
|
3
|
+
import { getRequest } from '@tanstack/react-start/server';
|
|
4
|
+
import { createClient } from '@supabase/supabase-js';
|
|
5
|
+
export const requireSupabaseAuth = createMiddleware({ type: 'function' }).server(async ({ next }) => {
|
|
6
|
+
const SUPABASE_URL = process.env.SUPABASE_URL;
|
|
7
|
+
const SUPABASE_PUBLISHABLE_KEY = process.env.SUPABASE_PUBLISHABLE_KEY;
|
|
8
|
+
if (!SUPABASE_URL || !SUPABASE_PUBLISHABLE_KEY) {
|
|
9
|
+
throw new Response('Missing Supabase environment variables. Ensure SUPABASE_URL and SUPABASE_PUBLISHABLE_KEY are set.', { status: 500 });
|
|
10
|
+
}
|
|
11
|
+
const request = getRequest();
|
|
12
|
+
if (!request?.headers) {
|
|
13
|
+
throw new Response('Unauthorized: No request headers available', { status: 401 });
|
|
14
|
+
}
|
|
15
|
+
const authHeader = request.headers.get('authorization');
|
|
16
|
+
if (!authHeader) {
|
|
17
|
+
throw new Response('Unauthorized: No authorization header provided', { status: 401 });
|
|
18
|
+
}
|
|
19
|
+
if (!authHeader.startsWith('Bearer ')) {
|
|
20
|
+
throw new Response('Unauthorized: Only Bearer tokens are supported', { status: 401 });
|
|
21
|
+
}
|
|
22
|
+
const token = authHeader.replace('Bearer ', '');
|
|
23
|
+
if (!token) {
|
|
24
|
+
throw new Response('Unauthorized: No token provided', { status: 401 });
|
|
25
|
+
}
|
|
26
|
+
const supabase = createClient(SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY, {
|
|
27
|
+
global: {
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${token}`,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
auth: {
|
|
33
|
+
storage: undefined,
|
|
34
|
+
persistSession: false,
|
|
35
|
+
autoRefreshToken: false,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
const { data, error } = await supabase.auth.getClaims(token);
|
|
39
|
+
if (error || !data?.claims) {
|
|
40
|
+
throw new Response('Unauthorized: Invalid token', { status: 401 });
|
|
41
|
+
}
|
|
42
|
+
if (!data.claims.sub) {
|
|
43
|
+
throw new Response('Unauthorized: No user ID found in token', { status: 401 });
|
|
44
|
+
}
|
|
45
|
+
return next({
|
|
46
|
+
context: {
|
|
47
|
+
supabase: supabase,
|
|
48
|
+
userId: data.claims.sub,
|
|
49
|
+
claims: data.claims,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/integrations/supabase/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AASxC,eAAO,MAAM,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAM5C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// This file is automatically generated. Do not edit it directly.
|
|
2
|
+
import { createClient } from '@supabase/supabase-js';
|
|
3
|
+
import { brokeredPreviewStorage } from './previewAuthStorage.js';
|
|
4
|
+
const SUPABASE_URL = "https://pdfdesbxlrbwljxpgnhj.supabase.co";
|
|
5
|
+
const SUPABASE_PUBLISHABLE_KEY = "sb_publishable_fYXoCxUdccgr6dI8ldDjrw_HF6Krrdo";
|
|
6
|
+
// Import the supabase client like this:
|
|
7
|
+
// import { supabase } from "./client.js";
|
|
8
|
+
export const supabase = createClient(SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY, {
|
|
9
|
+
auth: {
|
|
10
|
+
storage: brokeredPreviewStorage(),
|
|
11
|
+
persistSession: true,
|
|
12
|
+
autoRefreshToken: true,
|
|
13
|
+
}
|
|
14
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.server.d.ts","sourceRoot":"","sources":["../../../src/integrations/supabase/client.server.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AA0BxC,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,QAAQ,CAKjD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// This file is automatically generated. Do not edit it directly.
|
|
2
|
+
// Server-side Supabase client with service role key - bypasses RLS.
|
|
3
|
+
// Use this for admin operations in server functions and server routes only.
|
|
4
|
+
// For user-authenticated queries (with RLS), use the auth middleware instead.
|
|
5
|
+
import { createClient } from '@supabase/supabase-js';
|
|
6
|
+
function createSupabaseAdminClient() {
|
|
7
|
+
const SUPABASE_URL = process.env.SUPABASE_URL;
|
|
8
|
+
const SUPABASE_SERVICE_ROLE_KEY = process.env.SUPABASE_SERVICE_ROLE_KEY;
|
|
9
|
+
if (!SUPABASE_URL || !SUPABASE_SERVICE_ROLE_KEY) {
|
|
10
|
+
throw new Error('Missing Supabase server environment variables. Ensure SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY are set.');
|
|
11
|
+
}
|
|
12
|
+
return createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, {
|
|
13
|
+
auth: {
|
|
14
|
+
storage: undefined,
|
|
15
|
+
persistSession: false,
|
|
16
|
+
autoRefreshToken: false,
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
let _supabaseAdmin;
|
|
21
|
+
// Server-side Supabase client with service role - bypasses RLS
|
|
22
|
+
// SECURITY: Only use this for trusted server-side operations, never expose to client code
|
|
23
|
+
// Import like: import { supabaseAdmin } from "./client.server.js";
|
|
24
|
+
export const supabaseAdmin = new Proxy({}, {
|
|
25
|
+
get(_, prop, receiver) {
|
|
26
|
+
if (!_supabaseAdmin)
|
|
27
|
+
_supabaseAdmin = createSupabaseAdminClient();
|
|
28
|
+
return Reflect.get(_supabaseAdmin, prop, receiver);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Storage accepted by Supabase's `auth.storage` option; `localStorage` and the editor broker both satisfy it. */
|
|
2
|
+
export interface PreviewAuthStorage {
|
|
3
|
+
getItem: (key: string) => string | null | Promise<string | null>;
|
|
4
|
+
setItem: (key: string, value: string) => void | Promise<void>;
|
|
5
|
+
removeItem: (key: string) => void | Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* On a Lovable preview surface, broker the auth session to the editor over
|
|
9
|
+
* postMessage so the project's preview surfaces share one login; else localStorage.
|
|
10
|
+
*/
|
|
11
|
+
export declare function brokeredPreviewStorage(): PreviewAuthStorage | undefined;
|
|
12
|
+
//# sourceMappingURL=previewAuthStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"previewAuthStorage.d.ts","sourceRoot":"","sources":["../../../src/integrations/supabase/previewAuthStorage.ts"],"names":[],"mappings":"AAEA,kHAAkH;AAClH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACjE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AA6BD;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,kBAAkB,GAAG,SAAS,CAuGvE"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// This file is automatically generated. Do not edit it directly.
|
|
2
|
+
const RESULT = 'lovable-preview-auth:result';
|
|
3
|
+
function readBrokerReply(data, requestId) {
|
|
4
|
+
if (typeof data !== 'object' || data === null)
|
|
5
|
+
return null;
|
|
6
|
+
if (!('type' in data) || data.type !== RESULT)
|
|
7
|
+
return null;
|
|
8
|
+
if (!('requestId' in data) || data.requestId !== requestId)
|
|
9
|
+
return null;
|
|
10
|
+
return {
|
|
11
|
+
ok: 'ok' in data && Boolean(data.ok),
|
|
12
|
+
value: 'value' in data && typeof data.value === 'string' ? data.value : null,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* On a Lovable preview surface, broker the auth session to the editor over
|
|
17
|
+
* postMessage so the project's preview surfaces share one login; else localStorage.
|
|
18
|
+
*/
|
|
19
|
+
export function brokeredPreviewStorage() {
|
|
20
|
+
if (typeof window === 'undefined')
|
|
21
|
+
return undefined;
|
|
22
|
+
const host = location.hostname;
|
|
23
|
+
const PREVIEW_ZONES = ['lovableproject.com', 'lovableproject-dev.com', 'lovable.app', 'gpt-eng.com', 'gptengineer.run'];
|
|
24
|
+
const onPreviewZone = PREVIEW_ZONES.some((z) => host === z || host.endsWith('.' + z));
|
|
25
|
+
// Read the id only from non-user-controlled host positions, so a user-named
|
|
26
|
+
// preview--<name> host can't smuggle another project's id.
|
|
27
|
+
const UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
|
|
28
|
+
const projectId = onPreviewZone
|
|
29
|
+
? (new RegExp('^(?:id-preview(?:-[a-z0-9]+)?|project)--(' + UUID + ')(?:-dev)?(?=\\.|$)', 'i').exec(host)?.[1]
|
|
30
|
+
?? new RegExp('^live--(' + UUID + ')(?:-thr_[a-z0-9]+)?(?=\\.|$)', 'i').exec(host)?.[1]
|
|
31
|
+
?? new RegExp('^(' + UUID + ')(?=[.-])', 'i').exec(host)?.[1])
|
|
32
|
+
: undefined;
|
|
33
|
+
// lib.dom types window.parent and location.ancestorOrigins as always set, but a
|
|
34
|
+
// detached frame has no parent and not every browser implements ancestorOrigins.
|
|
35
|
+
const parentWindow = window.parent;
|
|
36
|
+
const framed = parentWindow !== null && parentWindow !== window;
|
|
37
|
+
if (!projectId || !framed)
|
|
38
|
+
return localStorage;
|
|
39
|
+
// Post only to the real editor ancestor, validated as a Lovable origin, so the
|
|
40
|
+
// session token can never reach an untrusted embedder.
|
|
41
|
+
const dev = host.endsWith('.lovableproject-dev.com') || host.endsWith('.gpt-eng.com');
|
|
42
|
+
const EDITOR = dev
|
|
43
|
+
? /^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$|^http:\/\/localhost:3000$/
|
|
44
|
+
: /^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$/;
|
|
45
|
+
const ancestorOrigins = location.ancestorOrigins;
|
|
46
|
+
const ancestor = ancestorOrigins?.[0] ?? (document.referrer ? new URL(document.referrer).origin : '');
|
|
47
|
+
const editorOrigins = ancestor && EDITOR.test(ancestor)
|
|
48
|
+
? [ancestor]
|
|
49
|
+
: (dev ? ['https://lovable.dev', 'http://localhost:3000'] : ['https://lovable.dev']);
|
|
50
|
+
const TIMEOUT = 2000;
|
|
51
|
+
const newId = () => Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
52
|
+
const request = (type, key, value) => new Promise((resolve) => {
|
|
53
|
+
const requestId = newId();
|
|
54
|
+
let done = false;
|
|
55
|
+
const finish = (reply) => {
|
|
56
|
+
if (done)
|
|
57
|
+
return;
|
|
58
|
+
done = true;
|
|
59
|
+
clearTimeout(timer);
|
|
60
|
+
window.removeEventListener('message', onMessage);
|
|
61
|
+
resolve(reply);
|
|
62
|
+
};
|
|
63
|
+
const onMessage = (e) => {
|
|
64
|
+
if (!editorOrigins.includes(e.origin))
|
|
65
|
+
return;
|
|
66
|
+
const reply = readBrokerReply(e.data, requestId);
|
|
67
|
+
if (reply)
|
|
68
|
+
finish(reply);
|
|
69
|
+
};
|
|
70
|
+
window.addEventListener('message', onMessage);
|
|
71
|
+
const timer = setTimeout(() => { finish(null); }, TIMEOUT);
|
|
72
|
+
const msg = { type, requestId, projectId, key };
|
|
73
|
+
if (value !== undefined)
|
|
74
|
+
msg.value = value;
|
|
75
|
+
// targetOrigin per trusted editor origin, so a session token never reaches an arbitrary embedder.
|
|
76
|
+
for (const origin of editorOrigins)
|
|
77
|
+
window.parent.postMessage(msg, origin);
|
|
78
|
+
});
|
|
79
|
+
// The editor may not be listening yet at the first getItem, so retry once.
|
|
80
|
+
let firstGet = true;
|
|
81
|
+
const RETRY_DELAY = 250;
|
|
82
|
+
// Blocked third-party storage throws here; seeding must not break broker reads.
|
|
83
|
+
const readLocal = (key) => { try {
|
|
84
|
+
return localStorage.getItem(key);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return undefined;
|
|
88
|
+
} };
|
|
89
|
+
return {
|
|
90
|
+
getItem: async (key) => {
|
|
91
|
+
// Sent with GET and REMOVE so an editor that never cached this session can check or revoke it.
|
|
92
|
+
const local = readLocal(key);
|
|
93
|
+
let res = await request('lovable-preview-auth:get', key, local ?? undefined);
|
|
94
|
+
if (!res && firstGet) {
|
|
95
|
+
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));
|
|
96
|
+
res = await request('lovable-preview-auth:get', key, local ?? undefined);
|
|
97
|
+
}
|
|
98
|
+
firstGet = false;
|
|
99
|
+
// '' is the logout tombstone: clear the local copy too so it can't resurrect if
|
|
100
|
+
// the broker later goes silent. A null value means never-synced -> keep local.
|
|
101
|
+
if (res?.ok && res.value !== null) {
|
|
102
|
+
if (res.value === '') {
|
|
103
|
+
if (local !== undefined && readLocal(key) === local)
|
|
104
|
+
localStorage.removeItem(key);
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
// Seed this origin so a new tab, whose editor holds no session, stays signed in.
|
|
108
|
+
if (local === null && readLocal(key) === null) {
|
|
109
|
+
try {
|
|
110
|
+
localStorage.setItem(key, res.value);
|
|
111
|
+
}
|
|
112
|
+
catch { /* storage full: still return the editor's session */ }
|
|
113
|
+
}
|
|
114
|
+
return res.value;
|
|
115
|
+
}
|
|
116
|
+
return localStorage.getItem(key);
|
|
117
|
+
},
|
|
118
|
+
setItem: (key, value) => {
|
|
119
|
+
localStorage.setItem(key, value);
|
|
120
|
+
return request('lovable-preview-auth:set', key, value).then((res) => {
|
|
121
|
+
if (res?.ok && res.value !== null && localStorage.getItem(key) === value) {
|
|
122
|
+
if (res.value === '')
|
|
123
|
+
localStorage.removeItem(key);
|
|
124
|
+
else
|
|
125
|
+
localStorage.setItem(key, res.value);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
removeItem: (key) => {
|
|
130
|
+
const local = readLocal(key);
|
|
131
|
+
localStorage.removeItem(key);
|
|
132
|
+
return request('lovable-preview-auth:remove', key, local ?? undefined).then(() => { });
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|