@insforge/nextjs 0.7.9 → 0.8.0

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/dist/index.mjs CHANGED
@@ -1,24 +1,11 @@
1
1
  "use client";
2
2
 
3
- // Auto-inject InsForge styles
4
- if (typeof document !== 'undefined' && typeof window !== 'undefined') {
5
- const styleId = 'insforge-nextjs-styles';
6
- if (!document.getElementById(styleId)) {
7
- const style = document.createElement('style');
8
- style.id = styleId;
9
- style.textContent = "/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */\n@import \"https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap\";@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial;--tw-content:\"\"}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-blue-50:oklch(97% .014 254.604);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-blue-900:oklch(37.9% .146 265.522);--color-purple-600:oklch(55.8% .288 302.321);--color-purple-700:oklch(49.6% .265 301.924);--color-purple-900:oklch(38.1% .176 304.987);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-neutral-400:oklch(70.8% 0 0);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-md:28rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height:calc(1.5/1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25/1.875);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--leading-normal:1.5;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--font-manrope:\"Manrope\",sans-serif}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.absolute{position:absolute}.relative{position:relative}.top-1\\/2{top:50%}.top-full{top:100%}.right-0{right:calc(var(--spacing)*0)}.right-2{right:calc(var(--spacing)*2)}.z-50{z-index:50}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.mx-auto{margin-inline:auto}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.ml-auto{margin-left:auto}.flex{display:flex}.grid{display:grid}.inline{display:inline}.inline-block{display:inline-block}.h-3{height:calc(var(--spacing)*3)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-\\[18px\\]{height:18px}.h-full{height:100%}.min-h-screen{min-height:100vh}.w-3{width:calc(var(--spacing)*3)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-\\[18px\\]{width:18px}.w-full{width:100%}.max-w-\\[400px\\]{max-width:400px}.max-w-md{max-width:var(--container-md)}.min-w-40{min-width:calc(var(--spacing)*40)}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.-translate-y-1\\/2{--tw-translate-y:calc(calc(1/2*100%)*-1);translate:var(--tw-translate-x)var(--tw-translate-y)}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.items-center{align-items:center}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-start{justify-content:flex-start}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}.gap-2\\.5{gap:calc(var(--spacing)*2.5)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-6{gap:calc(var(--spacing)*6)}.self-stretch{align-self:stretch}.overflow-hidden{overflow:hidden}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-none{--tw-border-style:none;border-style:none}.border-\\[\\#D4D4D4\\]{border-color:#d4d4d4}.border-\\[\\#E0E0E0\\]{border-color:#e0e0e0}.border-\\[\\#E4E4E7\\]{border-color:#e4e4e7}.border-blue-500{border-color:var(--color-blue-500)}.border-blue-600{border-color:var(--color-blue-600)}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-700{border-color:var(--color-gray-700)}.border-neutral-400{border-color:var(--color-neutral-400)}.border-red-600{border-color:var(--color-red-600)}.border-transparent{border-color:#0000}.bg-\\[\\#059669\\]{background-color:#059669}.bg-\\[\\#FAFAFA\\]{background-color:#fafafa}.bg-black{background-color:var(--color-black)}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-600{background-color:var(--color-blue-600)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-purple-600{background-color:var(--color-purple-600)}.bg-red-50{background-color:var(--color-red-50)}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.object-cover{object-fit:cover}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.py-2{padding-block:calc(var(--spacing)*2)}.py-4{padding-block:calc(var(--spacing)*4)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-8{padding-right:calc(var(--spacing)*8)}.pl-3{padding-left:calc(var(--spacing)*3)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-manrope{font-family:var(--font-manrope)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.leading-4{--tw-leading:calc(var(--spacing)*4);line-height:calc(var(--spacing)*4)}.leading-5{--tw-leading:calc(var(--spacing)*5);line-height:calc(var(--spacing)*5)}.leading-6{--tw-leading:calc(var(--spacing)*6);line-height:calc(var(--spacing)*6)}.leading-8{--tw-leading:calc(var(--spacing)*8);line-height:calc(var(--spacing)*8)}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-\\[\\#09090B\\]{color:#09090b}.text-\\[\\#525252\\]{color:#525252}.text-\\[\\#737373\\]{color:#737373}.text-\\[\\#828282\\]{color:#828282}.text-\\[\\#A3A3A3\\]{color:#a3a3a3}.text-\\[\\#A6A6A6\\]{color:#a6a6a6}.text-black{color:var(--color-black)}.text-blue-500{color:var(--color-blue-500)}.text-blue-900{color:var(--color-blue-900)}.text-gray-300{color:var(--color-gray-300)}.text-gray-500{color:var(--color-gray-500)}.text-gray-900{color:var(--color-gray-900)}.text-purple-700{color:var(--color-purple-700)}.text-purple-900{color:var(--color-purple-900)}.text-red-500{color:var(--color-red-500)}.text-red-600{color:var(--color-red-600)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[0_1px_2px_0_rgba\\(0\\,0\\,0\\,0\\.10\\)\\]{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.outline-none{--tw-outline-style:none;outline-style:none}.placeholder\\:font-normal::placeholder{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.placeholder\\:text-\\[\\#A3A3A3\\]::placeholder{color:#a3a3a3}.before\\:h-px:before{content:var(--tw-content);height:1px}.before\\:flex-1:before{content:var(--tw-content);flex:1}.before\\:bg-\\[\\#E5E5E5\\]:before{content:var(--tw-content);background-color:#e5e5e5}.before\\:content-\\[\\'\\'\\]:before{--tw-content:\"\";content:var(--tw-content)}.after\\:h-px:after{content:var(--tw-content);height:1px}.after\\:flex-1:after{content:var(--tw-content);flex:1}.after\\:bg-\\[\\#E5E5E5\\]:after{content:var(--tw-content);background-color:#e5e5e5}.after\\:content-\\[\\'\\'\\]:after{--tw-content:\"\";content:var(--tw-content)}@media (hover:hover){.hover\\:border-\\[\\#9ca3af\\]:hover{border-color:#9ca3af}.hover\\:bg-\\[\\#f9fafb\\]:hover{background-color:#f9fafb}.hover\\:bg-black\\/5:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-black\\/5:hover{background-color:color-mix(in oklab,var(--color-black)5%,transparent)}}.hover\\:bg-blue-50:hover{background-color:var(--color-blue-50)}.hover\\:bg-blue-700:hover{background-color:var(--color-blue-700)}.hover\\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\\:bg-gray-800:hover{background-color:var(--color-gray-800)}.hover\\:bg-purple-700:hover{background-color:var(--color-purple-700)}.hover\\:bg-red-50:hover{background-color:var(--color-red-50)}.hover\\:bg-white\\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-white\\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.hover\\:text-gray-600:hover{color:var(--color-gray-600)}}.focus\\:border-black:focus{border-color:var(--color-black)}.focus\\:shadow-\\[0_0_0_2px_rgba\\(0\\,0\\,0\\,0\\.1\\)\\]:focus{--tw-shadow:0 0 0 2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\\:ring-blue-500:focus{--tw-ring-color:var(--color-blue-500)}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:bg-\\[\\#F5F5F5\\]:disabled{background-color:#f5f5f5}.disabled\\:opacity-50:disabled{opacity:.5}.disabled\\:opacity-60:disabled{opacity:.6}}@property --tw-translate-x{syntax:\"*\";inherits:false;initial-value:0}@property --tw-translate-y{syntax:\"*\";inherits:false;initial-value:0}@property --tw-translate-z{syntax:\"*\";inherits:false;initial-value:0}@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}@property --tw-leading{syntax:\"*\";inherits:false}@property --tw-font-weight{syntax:\"*\";inherits:false}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:\"*\";inherits:false}@property --tw-content{syntax:\"*\";inherits:false;initial-value:\"\"}@keyframes spin{to{transform:rotate(360deg)}}";
10
- if (document.head) {
11
- document.head.appendChild(style);
12
- }
13
- }
14
- }
15
-
3
+ // src/index.ts
4
+ export * from "@insforge/react/types";
16
5
 
17
6
  // src/provider/InsforgeProvider.tsx
18
- import { createContext, useContext, useEffect, useState, useCallback, useRef } from "react";
19
- import { createClient } from "@insforge/sdk";
7
+ import { InsforgeProvider as ReactInsforgeProvider, useInsforge as useReactInsforge } from "@insforge/react";
20
8
  import { jsx } from "react/jsx-runtime";
21
- var InsforgeContext = createContext(void 0);
22
9
  async function syncTokenToCookie(token) {
23
10
  try {
24
11
  const response = await fetch("/api/auth", {
@@ -39,311 +26,29 @@ async function syncTokenToCookie(token) {
39
26
  return false;
40
27
  }
41
28
  }
29
+ async function clearCookie() {
30
+ try {
31
+ await fetch("/api/auth", { method: "DELETE" });
32
+ } catch (error) {
33
+ }
34
+ }
42
35
  function InsforgeProvider({
43
36
  children,
44
37
  baseUrl,
45
38
  onAuthChange
46
39
  }) {
47
- const [user, setUser] = useState(null);
48
- const [isLoaded, setIsLoaded] = useState(false);
49
- const refreshIntervalRef = useRef(null);
50
- const [insforge] = useState(() => createClient({ baseUrl }));
51
- const loadAuthState = useCallback(async () => {
52
- try {
53
- const sessionResult = insforge.auth.getCurrentSession();
54
- const session = sessionResult.data?.session;
55
- const token = session?.accessToken || null;
56
- if (!token) {
57
- setUser(null);
58
- if (onAuthChange) {
59
- onAuthChange(null);
60
- }
61
- setIsLoaded(true);
62
- return { success: false, error: "no_session" };
63
- }
64
- try {
65
- await syncTokenToCookie(token);
66
- } catch (error) {
67
- }
68
- const userResult = await insforge.auth.getCurrentUser();
69
- console.log("userResult", userResult);
70
- if (userResult.data) {
71
- const userData = {
72
- id: userResult.data.user.id,
73
- email: userResult.data.user.email,
74
- name: userResult.data.profile?.nickname || "",
75
- avatarUrl: userResult.data.profile?.avatarUrl || ""
76
- };
77
- setUser(userData);
78
- if (onAuthChange) {
79
- onAuthChange(userData);
80
- }
81
- setIsLoaded(true);
82
- return { success: true };
83
- } else {
84
- await insforge.auth.signOut();
85
- try {
86
- await fetch("/api/auth", { method: "DELETE" });
87
- } catch (error) {
88
- }
89
- setUser(null);
90
- if (onAuthChange) {
91
- onAuthChange(null);
92
- }
93
- setIsLoaded(true);
94
- return { success: false, error: "invalid_token" };
95
- }
96
- } catch (error) {
97
- console.error("[InsforgeProvider] Token validation failed:", error);
98
- await insforge.auth.signOut();
99
- try {
100
- await fetch("/api/auth", { method: "DELETE" });
101
- } catch (error2) {
102
- }
103
- setUser(null);
104
- if (onAuthChange) {
105
- onAuthChange(null);
106
- }
107
- setIsLoaded(true);
108
- return {
109
- success: false,
110
- error: error instanceof Error ? error.message : "authentication_failed"
111
- };
112
- }
113
- }, [insforge, onAuthChange]);
114
- useEffect(() => {
115
- loadAuthState();
116
- return () => {
117
- if (refreshIntervalRef.current) {
118
- clearInterval(refreshIntervalRef.current);
119
- }
120
- };
121
- }, []);
122
- const handleAuthSuccess = useCallback(
123
- async (authToken, fallbackUser) => {
124
- const userResult = await insforge.auth.getCurrentUser();
125
- if (userResult.data) {
126
- const userData = {
127
- id: userResult.data.user.id,
128
- email: userResult.data.user.email,
129
- name: userResult.data.profile?.nickname || "",
130
- avatarUrl: userResult.data.profile?.avatarUrl || ""
131
- };
132
- setUser(userData);
133
- if (onAuthChange) {
134
- onAuthChange(userData);
135
- }
136
- try {
137
- await syncTokenToCookie(authToken);
138
- } catch (error) {
139
- }
140
- } else if (fallbackUser) {
141
- const userData = {
142
- id: fallbackUser.id || "",
143
- email: fallbackUser.email || "",
144
- name: fallbackUser.name || "",
145
- avatarUrl: ""
146
- };
147
- setUser(userData);
148
- if (onAuthChange) {
149
- onAuthChange(userData);
150
- }
151
- }
152
- },
153
- [insforge, onAuthChange]
154
- );
155
- const signIn = useCallback(
156
- async (email, password) => {
157
- const sdkResult = await insforge.auth.signInWithPassword({ email, password });
158
- if (sdkResult.data) {
159
- await handleAuthSuccess(
160
- sdkResult.data.accessToken || "",
161
- sdkResult.data.user ? {
162
- id: sdkResult.data.user.id,
163
- email: sdkResult.data.user.email,
164
- name: sdkResult.data.user.name
165
- } : void 0
166
- );
167
- } else {
168
- const errorMessage = sdkResult.error?.message || "Invalid email or password";
169
- throw new Error(errorMessage);
170
- }
171
- },
172
- [insforge, handleAuthSuccess]
173
- );
174
- const signUp = useCallback(
175
- async (email, password) => {
176
- const sdkResult = await insforge.auth.signUp({ email, password });
177
- if (sdkResult.data) {
178
- await handleAuthSuccess(
179
- sdkResult.data.accessToken || "",
180
- sdkResult.data.user ? {
181
- id: sdkResult.data.user.id,
182
- email: sdkResult.data.user.email,
183
- name: sdkResult.data.user.name
184
- } : void 0
185
- );
186
- } else {
187
- const errorMessage = sdkResult.error?.message || "Sign up failed";
188
- throw new Error(errorMessage);
189
- }
190
- },
191
- [insforge, handleAuthSuccess]
192
- );
193
- const signOut = useCallback(async () => {
194
- await insforge.auth.signOut();
195
- await fetch("/api/auth", { method: "DELETE" }).catch(() => {
196
- });
197
- if (refreshIntervalRef.current) {
198
- clearInterval(refreshIntervalRef.current);
199
- }
200
- setUser(null);
201
- if (onAuthChange) {
202
- onAuthChange(null);
203
- }
204
- }, [insforge, onAuthChange]);
205
- const updateUser = useCallback(
206
- async (data) => {
207
- if (!user) throw new Error("No user signed in");
208
- const result = await insforge.auth.setProfile({
209
- nickname: data.name || "",
210
- avatarUrl: data.avatarUrl || ""
211
- });
212
- if (result.data) {
213
- const updatedUser = { ...user, ...result.data };
214
- setUser(updatedUser);
215
- if (onAuthChange) {
216
- onAuthChange(updatedUser);
217
- }
218
- }
219
- },
220
- [user, onAuthChange, insforge]
221
- );
222
40
  return /* @__PURE__ */ jsx(
223
- InsforgeContext.Provider,
41
+ ReactInsforgeProvider,
224
42
  {
225
- value: {
226
- // Auth
227
- user,
228
- isLoaded,
229
- isSignedIn: !!user,
230
- setUser,
231
- signIn,
232
- signUp,
233
- signOut,
234
- updateUser,
235
- reloadAuth: loadAuthState,
236
- // Email verification (commented out - verification disabled for now)
237
- // sendVerificationCode,
238
- // verifySignUpCode,
239
- // verifySignInCode,
240
- // Base
241
- baseUrl
242
- },
43
+ baseUrl,
44
+ onAuthChange,
45
+ syncTokenToCookie,
46
+ clearCookie,
243
47
  children
244
48
  }
245
49
  );
246
50
  }
247
- function useInsforge() {
248
- const context = useContext(InsforgeContext);
249
- if (!context) {
250
- throw new Error("useInsforge must be used within InsforgeProvider");
251
- }
252
- return context;
253
- }
254
-
255
- // src/hooks/useAuth.ts
256
- function useAuth() {
257
- const { signIn, signUp, signOut, isLoaded, isSignedIn } = useInsforge();
258
- return { signIn, signUp, signOut, isLoaded, isSignedIn };
259
- }
260
-
261
- // src/hooks/useUser.ts
262
- function useUser() {
263
- const { user, isLoaded, updateUser, setUser } = useInsforge();
264
- return { user, isLoaded, updateUser, setUser };
265
- }
266
-
267
- // src/components/SignIn.tsx
268
- import { useState as useState5 } from "react";
269
- import { createClient as createClient4 } from "@insforge/sdk";
270
-
271
- // src/hooks/useOAuthProviders.ts
272
- import { useState as useState2, useEffect as useEffect2 } from "react";
273
- import { createClient as createClient2 } from "@insforge/sdk";
274
- function useOAuthProviders() {
275
- const { baseUrl } = useInsforge();
276
- const [providers, setProviders] = useState2([]);
277
- const [isLoaded, setIsLoaded] = useState2(false);
278
- useEffect2(() => {
279
- let mounted = true;
280
- async function fetchProviders() {
281
- try {
282
- const insforge = createClient2({ baseUrl });
283
- const { data, error } = await insforge.auth.getOAuthProviders();
284
- if (!mounted) return;
285
- if (error) {
286
- console.warn("[useOAuthProviders] Failed to fetch OAuth providers:", error);
287
- setProviders([]);
288
- } else if (data) {
289
- const providerNames = data.map((p) => p.provider);
290
- setProviders(providerNames);
291
- } else {
292
- setProviders([]);
293
- }
294
- setIsLoaded(true);
295
- } catch (error) {
296
- console.warn("[useOAuthProviders] Unexpected error:", error);
297
- if (mounted) {
298
- setProviders([]);
299
- setIsLoaded(true);
300
- }
301
- }
302
- }
303
- fetchProviders();
304
- return () => {
305
- mounted = false;
306
- };
307
- }, [baseUrl]);
308
- return { providers, isLoaded };
309
- }
310
-
311
- // src/hooks/useEmailAuthConfig.ts
312
- import { useState as useState3, useEffect as useEffect3 } from "react";
313
- import { createClient as createClient3 } from "@insforge/sdk";
314
- function useEmailAuthConfig() {
315
- const { baseUrl } = useInsforge();
316
- const [config, setConfig] = useState3(null);
317
- const [isLoaded, setIsLoaded] = useState3(false);
318
- useEffect3(() => {
319
- let mounted = true;
320
- async function fetchConfig() {
321
- try {
322
- const insforge = createClient3({ baseUrl });
323
- const { data, error } = await insforge.auth.getEmailAuthConfig();
324
- if (!mounted) return;
325
- if (error) {
326
- console.warn("[useEmailAuthConfig] Failed to fetch email auth config:", error);
327
- setConfig(null);
328
- } else {
329
- setConfig(data);
330
- }
331
- setIsLoaded(true);
332
- } catch (error) {
333
- console.warn("[useEmailAuthConfig] Unexpected error:", error);
334
- if (mounted) {
335
- setConfig(null);
336
- setIsLoaded(true);
337
- }
338
- }
339
- }
340
- fetchConfig();
341
- return () => {
342
- mounted = false;
343
- };
344
- }, [baseUrl]);
345
- return { config, isLoaded };
346
- }
51
+ var useInsforge = useReactInsforge;
347
52
 
348
53
  // src/lib/utils.ts
349
54
  import { clsx } from "clsx";
@@ -352,1339 +57,12 @@ function cn(...inputs) {
352
57
  return twMerge(clsx(inputs));
353
58
  }
354
59
 
355
- // src/components/auth/AuthBranding.tsx
356
- import Link from "next/link";
357
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
358
- function AuthBranding() {
359
- return /* @__PURE__ */ jsxs("div", { className: "bg-[#FAFAFA] px-2 py-4 flex flex-row justify-center items-center gap-1", children: [
360
- /* @__PURE__ */ jsx2("p", { className: "text-xs font-medium text-black font-manrope", children: "Secured by" }),
361
- /* @__PURE__ */ jsx2(Link, { href: "https://insforge.dev", target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ jsxs("svg", { width: "83", height: "20", viewBox: "0 0 83 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
362
- /* @__PURE__ */ jsx2(
363
- "path",
364
- {
365
- d: "M2.16783 8.46797C1.9334 8.23325 1.9334 7.85269 2.16783 7.61797L8.11049 1.66797L16.6 1.66797L6.41259 11.868C6.17815 12.1027 5.79807 12.1027 5.56363 11.868L2.16783 8.46797Z",
366
- fill: "url(#paint0_linear_2976_9475)"
367
- }
368
- ),
369
- /* @__PURE__ */ jsx2(
370
- "path",
371
- {
372
- d: "M12.8858 6.44922L16.6 10.168V18.668L8.64108 10.6992L12.8858 6.44922Z",
373
- fill: "url(#paint1_linear_2976_9475)"
374
- }
375
- ),
376
- /* @__PURE__ */ jsx2(
377
- "path",
378
- {
379
- d: "M67.5439 6.48828C68.2894 6.48828 68.9145 6.67064 69.418 7.03516C69.5229 7.10943 69.6214 7.1907 69.7158 7.27637V6.70703H71.248V14.959C71.248 15.1583 71.2381 15.3485 71.2188 15.5283C71.2042 15.7129 71.1774 15.8925 71.1387 16.0674C71.0225 16.5776 70.7998 16.9957 70.4707 17.3213C70.1415 17.6518 69.7321 17.8972 69.2432 18.0576C68.7592 18.2179 68.2222 18.2988 67.6318 18.2988C67.1962 18.2988 66.7768 18.2308 66.375 18.0947C65.9782 17.9587 65.6202 17.7614 65.3008 17.5039C64.9813 17.2512 64.7199 16.9446 64.5166 16.585L66.1289 15.7832C66.2789 16.0698 66.4888 16.2819 66.7598 16.418C67.0356 16.5589 67.3289 16.6289 67.6387 16.6289C68.0016 16.6289 68.3258 16.5628 68.6113 16.4316C68.8969 16.3053 69.1176 16.116 69.2725 15.8633C69.4321 15.6155 69.5077 15.3047 69.498 14.9307V14.1797C69.4665 14.2037 69.4359 14.229 69.4033 14.252C68.8855 14.6164 68.2441 14.7988 67.4795 14.7988C66.7582 14.7988 66.1281 14.6165 65.5908 14.252C65.0537 13.8875 64.637 13.3915 64.3418 12.7646C64.0467 12.1378 63.8994 11.4307 63.8994 10.6436C63.8994 9.84651 64.0465 9.13673 64.3418 8.51465C64.6419 7.88768 65.0663 7.39481 65.6133 7.03516C66.1601 6.67077 66.8036 6.48836 67.5439 6.48828ZM37.5 6.48828C38.1099 6.48828 38.6496 6.58294 39.1191 6.77246C39.5935 6.96201 39.9762 7.2321 40.2666 7.58203C40.5569 7.93184 40.7359 8.34227 40.8037 8.81348L39.0176 9.13477C38.974 8.79951 38.8218 8.53424 38.5605 8.33984C38.304 8.14547 37.96 8.03605 37.5293 8.01172C37.1178 7.98742 36.7859 8.05051 36.5342 8.20117C36.2825 8.34698 36.1562 8.55398 36.1562 8.82129C36.1563 8.97184 36.208 9.10017 36.3096 9.20703C36.4112 9.31394 36.614 9.42141 36.9189 9.52832C37.2288 9.63524 37.6889 9.76635 38.2988 9.92188C38.9232 10.0823 39.4222 10.2666 39.7949 10.4756C40.1722 10.6796 40.4428 10.9254 40.6074 11.2119C40.7768 11.4987 40.8623 11.8466 40.8623 12.2549C40.8623 13.047 40.574 13.6691 39.998 14.1211C39.4268 14.5731 38.6348 14.7988 37.623 14.7988C36.6551 14.7988 35.8687 14.5799 35.2637 14.1426C34.6587 13.7052 34.2909 13.0908 34.1602 12.2988L35.9463 12.0215C36.0383 12.4102 36.2411 12.7169 36.5557 12.9404C36.8703 13.164 37.2678 13.2754 37.7471 13.2754C38.1681 13.2754 38.4922 13.1926 38.7197 13.0273C38.9521 12.8572 39.0684 12.6266 39.0684 12.335C39.0684 12.1552 39.0245 12.0122 38.9375 11.9053C38.8552 11.7935 38.6713 11.686 38.3857 11.584C38.1001 11.4819 37.6618 11.3528 37.0713 11.1973C36.4131 11.0223 35.8901 10.8359 35.5029 10.6367C35.1158 10.4327 34.8374 10.192 34.668 9.91504C34.4985 9.63801 34.4141 9.30188 34.4141 8.9082C34.4141 8.41746 34.5423 7.98943 34.7988 7.625C35.0553 7.26073 35.4135 6.98146 35.873 6.78711C36.3329 6.58784 36.8755 6.48828 37.5 6.48828ZM53.3047 6.48828C54.0937 6.48828 54.7815 6.66572 55.3672 7.02051C55.9527 7.37528 56.4072 7.86634 56.7314 8.49316C57.0558 9.11525 57.2187 9.83193 57.2188 10.6436C57.2188 11.46 57.0537 12.1817 56.7246 12.8086C56.4003 13.4307 55.9451 13.9196 55.3594 14.2744C54.7737 14.6242 54.0888 14.7988 53.3047 14.7988C52.5205 14.7988 51.8357 14.6214 51.25 14.2666C50.6643 13.9118 50.2091 13.4238 49.8848 12.8018C49.5653 12.1748 49.4053 11.4552 49.4053 10.6436C49.4053 9.81735 49.5703 9.09279 49.8994 8.4707C50.2286 7.8488 50.6859 7.36255 51.2715 7.0127C51.8572 6.66281 52.5351 6.48828 53.3047 6.48828ZM76.7471 6.48828C77.5603 6.48828 78.25 6.68053 78.8164 7.06445C79.3876 7.44351 79.812 7.97991 80.0879 8.6748C80.3638 9.36976 80.4672 10.189 80.3994 11.1318H74.7256C74.7843 11.6972 74.949 12.1516 75.2227 12.4951C75.5711 12.9325 76.0792 13.1513 76.7471 13.1514C77.1779 13.1514 77.5486 13.0567 77.8584 12.8672C78.173 12.6728 78.4146 12.3928 78.584 12.0283L80.3125 12.5537C80.0124 13.2633 79.5473 13.8153 78.918 14.209C78.2936 14.6025 77.6036 14.7988 76.8486 14.7988C76.0549 14.7988 75.358 14.6263 74.7578 14.2812C74.1576 13.9362 73.6875 13.458 73.3486 12.8457C73.0147 12.2334 72.8477 11.5284 72.8477 10.7314C72.8477 9.87126 73.0127 9.12495 73.3418 8.49316C73.671 7.85651 74.1282 7.36263 74.7139 7.0127C75.2995 6.6628 75.9775 6.48832 76.7471 6.48828ZM23.3301 14.5801H21.5801V4.08203H23.3301V14.5801ZM29.6152 6.48047C30.1959 6.48052 30.6753 6.5781 31.0527 6.77246C31.4301 6.96681 31.7305 7.21443 31.9531 7.51562C32.1758 7.81695 32.3398 8.13831 32.4463 8.47852C32.5528 8.81873 32.6213 9.14205 32.6504 9.44824C32.6843 9.74946 32.7012 9.99508 32.7012 10.1846V14.5801H30.9287V10.7891C30.9287 10.5413 30.9118 10.2669 30.8779 9.96582C30.844 9.66449 30.7645 9.37469 30.6387 9.09766C30.5177 8.81592 30.3337 8.58503 30.0869 8.40527C29.8449 8.22551 29.5157 8.13579 29.0996 8.13574C28.8769 8.13574 28.6563 8.17221 28.4385 8.24512C28.2206 8.31802 28.0219 8.4442 27.8428 8.62402C27.6685 8.79899 27.5284 9.04249 27.4219 9.35352C27.3154 9.65965 27.2617 10.0532 27.2617 10.5342V14.5801H25.4902V6.70703H27.0518V7.58301C27.2521 7.34675 27.486 7.14172 27.7559 6.96973C28.2593 6.64409 28.8794 6.48047 29.6152 6.48047ZM48.748 5.83887H44.2021V8.45605H47.876V10.2061H44.2021V14.5801H42.4521V4.08203H48.748V5.83887ZM62.5137 6.67773C62.7606 6.65829 63.001 6.66815 63.2334 6.70703V8.34766C63.001 8.27961 62.7317 8.25695 62.4268 8.28125C62.1267 8.30557 61.8553 8.39134 61.6133 8.53711C61.3715 8.66829 61.1733 8.83606 61.0186 9.04004C60.8686 9.24404 60.7572 9.47701 60.6846 9.73926C60.612 9.99685 60.5752 10.2768 60.5752 10.5781V14.5801H58.8184V6.70703H60.3652V7.96582C60.4243 7.85986 60.4888 7.75824 60.5605 7.66211C60.7251 7.4434 60.9219 7.26302 61.1494 7.12207C61.3429 6.99098 61.5559 6.88926 61.7881 6.81641C62.0251 6.73869 62.267 6.69235 62.5137 6.67773ZM67.8057 8.0625C67.3362 8.06252 66.9485 8.17982 66.6436 8.41309C66.3389 8.64144 66.1139 8.95232 65.9688 9.3457C65.8235 9.7345 65.751 10.1673 65.751 10.6436C65.751 11.1247 65.8215 11.5624 65.9619 11.9561C66.1071 12.3447 66.3269 12.6535 66.6221 12.8818C66.9174 13.1103 67.293 13.2246 67.748 13.2246C68.2174 13.2246 68.5953 13.1171 68.8809 12.9033C69.1711 12.6846 69.3811 12.3808 69.5117 11.9922C69.6473 11.6034 69.7158 11.1539 69.7158 10.6436C69.7158 10.1284 69.6473 9.67886 69.5117 9.29492C69.381 8.90617 69.1753 8.60445 68.8945 8.39062C68.6138 8.17213 68.2508 8.0625 67.8057 8.0625ZM53.3047 8.13574C52.8351 8.13574 52.4475 8.24222 52.1426 8.45605C51.8425 8.66504 51.6198 8.95977 51.4746 9.33887C51.3295 9.71303 51.2568 10.148 51.2568 10.6436C51.2568 11.4066 51.4288 12.0168 51.7725 12.4736C52.121 12.9256 52.6318 13.1514 53.3047 13.1514C54.0017 13.1514 54.5196 12.9177 54.8584 12.4512C55.1971 11.9846 55.3672 11.3822 55.3672 10.6436C55.3672 9.8807 55.1951 9.27324 54.8516 8.82129C54.5079 8.36444 53.9921 8.13575 53.3047 8.13574ZM76.8203 8.02637C76.1039 8.02637 75.5712 8.25013 75.2227 8.69727C74.9987 8.98144 74.8476 9.35094 74.7676 9.80566H78.6221C78.5589 9.29301 78.4236 8.89686 78.2139 8.61719C77.9186 8.22359 77.4543 8.02645 76.8203 8.02637Z",
380
- fill: "black"
381
- }
382
- ),
383
- /* @__PURE__ */ jsxs("defs", { children: [
384
- /* @__PURE__ */ jsxs(
385
- "linearGradient",
386
- {
387
- id: "paint0_linear_2976_9475",
388
- x1: "1.85883",
389
- y1: "1.92425",
390
- x2: "24.3072",
391
- y2: "9.64016",
392
- gradientUnits: "userSpaceOnUse",
393
- children: [
394
- /* @__PURE__ */ jsx2("stop", {}),
395
- /* @__PURE__ */ jsx2("stop", { offset: "1", stopOpacity: "0.4" })
396
- ]
397
- }
398
- ),
399
- /* @__PURE__ */ jsxs(
400
- "linearGradient",
401
- {
402
- id: "paint1_linear_2976_9475",
403
- x1: "25.6475",
404
- y1: "8.65468",
405
- x2: "10.7901",
406
- y2: "8.65468",
407
- gradientUnits: "userSpaceOnUse",
408
- children: [
409
- /* @__PURE__ */ jsx2("stop", {}),
410
- /* @__PURE__ */ jsx2("stop", { offset: "1", stopOpacity: "0.4" })
411
- ]
412
- }
413
- )
414
- ] })
415
- ] }) })
416
- ] });
417
- }
418
-
419
- // src/components/auth/AuthContainer.tsx
420
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
421
- function AuthContainer({ children, appearance = {} }) {
422
- return /* @__PURE__ */ jsxs2(
423
- "div",
424
- {
425
- className: cn(
426
- "w-full max-w-[400px] rounded-xl overflow-hidden shadow-lg",
427
- appearance.containerClassName
428
- ),
429
- children: [
430
- /* @__PURE__ */ jsx3("div", { className: cn(
431
- "bg-white p-6 flex flex-col justify-center items-stretch gap-6",
432
- appearance.cardClassName
433
- ), children }),
434
- /* @__PURE__ */ jsx3(AuthBranding, {})
435
- ]
436
- }
437
- );
438
- }
439
-
440
- // src/components/auth/AuthHeader.tsx
441
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
442
- function AuthHeader({
443
- title,
444
- subtitle,
445
- appearance = {}
446
- }) {
447
- return /* @__PURE__ */ jsxs3("div", { className: cn(
448
- "flex flex-col justify-start items-start gap-2",
449
- appearance.containerClassName
450
- ), children: [
451
- /* @__PURE__ */ jsx4("h1", { className: cn(
452
- "text-2xl font-semibold text-black leading-8",
453
- appearance.titleClassName
454
- ), children: title }),
455
- subtitle && /* @__PURE__ */ jsx4("p", { className: cn(
456
- "text-sm font-normal text-[#828282] leading-6",
457
- appearance.subtitleClassName
458
- ), children: subtitle })
459
- ] });
460
- }
461
-
462
- // src/components/auth/AuthErrorBanner.tsx
463
- import { AlertTriangle } from "lucide-react";
464
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
465
- function AuthErrorBanner({ error, className }) {
466
- if (!error) return null;
467
- return /* @__PURE__ */ jsxs4(
468
- "div",
469
- {
470
- className: cn(
471
- "flex items-center gap-2 mb-4 pl-3 py-2 pr-2 bg-red-50 border-2 border-red-600 rounded",
472
- className
473
- ),
474
- children: [
475
- /* @__PURE__ */ jsx5(AlertTriangle, { className: "w-6 h-6 text-red-500 flex-shrink-0" }),
476
- /* @__PURE__ */ jsx5("span", { className: "text-sm text-red-600 flex-1", children: error })
477
- ]
478
- }
479
- );
480
- }
481
-
482
- // src/components/auth/AuthFormField.tsx
483
- import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
484
- function AuthFormField({
485
- label,
486
- id,
487
- appearance = {},
488
- ...props
489
- }) {
490
- return /* @__PURE__ */ jsxs5("div", { className: cn(
491
- "flex flex-col justify-center items-stretch gap-1",
492
- appearance.containerClassName
493
- ), children: [
494
- /* @__PURE__ */ jsx6(
495
- "label",
496
- {
497
- htmlFor: id,
498
- className: cn(
499
- "text-sm font-normal text-black leading-6",
500
- appearance.labelClassName
501
- ),
502
- children: label
503
- }
504
- ),
505
- /* @__PURE__ */ jsx6(
506
- "input",
507
- {
508
- id,
509
- className: cn(
510
- "w-full flex items-center gap-2 self-stretch",
511
- "pl-3 pr-2 py-2 rounded-sm border border-[#D4D4D4] bg-white",
512
- "text-sm font-normal leading-5",
513
- "placeholder:text-[#A3A3A3] placeholder:font-sm placeholder:font-normal",
514
- "focus:outline-none focus:border-black",
515
- appearance.inputClassName
516
- ),
517
- ...props
518
- }
519
- )
520
- ] });
521
- }
522
-
523
- // src/components/auth/AuthPasswordField.tsx
524
- import { useState as useState4 } from "react";
525
- import { Eye, EyeOff } from "lucide-react";
526
-
527
- // src/components/auth/AuthPasswordStrengthIndicator.tsx
528
- import { Check } from "lucide-react";
529
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
530
- function AuthPasswordStrengthIndicator({
531
- password,
532
- config,
533
- appearance = {}
534
- }) {
535
- const requirements = createRequirements(config);
536
- return /* @__PURE__ */ jsx7(
537
- "div",
538
- {
539
- className: cn("mt-3 flex flex-col gap-3", appearance.containerClassName),
540
- children: requirements.map((req) => /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
541
- /* @__PURE__ */ jsx7(
542
- "div",
543
- {
544
- className: cn(
545
- "flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",
546
- req.test(password) ? "bg-[#059669] border-transparent" : "border-neutral-400 bg-white"
547
- ),
548
- children: req.test(password) && /* @__PURE__ */ jsx7(Check, { className: "w-3 h-3 text-white" })
549
- }
550
- ),
551
- /* @__PURE__ */ jsx7(
552
- "span",
553
- {
554
- className: cn(
555
- "text-sm font-normal leading-5 text-[#525252]",
556
- appearance.requirementClassName
557
- ),
558
- children: req.label
559
- }
560
- )
561
- ] }, req.label))
562
- }
563
- );
564
- }
565
- function createRequirements(config) {
566
- const requirements = [];
567
- const minLength = config.passwordMinLength;
568
- const requireUppercase = config.requireUppercase;
569
- const requireLowercase = config.requireLowercase;
570
- const requireNumber = config.requireNumber;
571
- const requireSpecialChar = config.requireSpecialChar;
572
- if (requireUppercase) {
573
- requirements.push({
574
- label: "At least 1 Uppercase letter",
575
- test: (pwd) => /[A-Z]/.test(pwd)
576
- });
577
- }
578
- if (requireLowercase) {
579
- requirements.push({
580
- label: "At least 1 Lowercase letter",
581
- test: (pwd) => /[a-z]/.test(pwd)
582
- });
583
- }
584
- if (requireNumber) {
585
- requirements.push({
586
- label: "At least 1 Number",
587
- test: (pwd) => /\d/.test(pwd)
588
- });
589
- }
590
- if (requireSpecialChar) {
591
- requirements.push({
592
- label: "Special character (e.g. !?<>@#$%)",
593
- test: (pwd) => /[!@#$%^&*()_+\-=[\]{};\\|,.<>/?]/.test(pwd)
594
- });
595
- }
596
- requirements.push({
597
- label: `${minLength} characters or more`,
598
- test: (pwd) => pwd.length >= minLength
599
- });
600
- return requirements;
601
- }
602
- function validatePasswordStrength(password, config) {
603
- if (!password) return false;
604
- const requirements = createRequirements(config);
605
- return requirements.every((req) => req.test(password));
606
- }
607
-
608
- // src/components/auth/AuthPasswordField.tsx
609
- import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
610
- function AuthPasswordField({
611
- label,
612
- id,
613
- showStrengthIndicator = false,
614
- emailAuthConfig,
615
- forgotPasswordLink,
616
- value,
617
- appearance = {},
618
- onFocus,
619
- ...props
620
- }) {
621
- const [showPassword, setShowPassword] = useState4(false);
622
- const [showStrength, setShowStrength] = useState4(false);
623
- const handleFocus = (e) => {
624
- if (showStrengthIndicator) {
625
- setShowStrength(true);
626
- }
627
- onFocus?.(e);
628
- };
629
- return /* @__PURE__ */ jsxs7(
630
- "div",
631
- {
632
- className: cn(
633
- "flex flex-col justify-center items-stretch gap-1",
634
- appearance.containerClassName
635
- ),
636
- children: [
637
- (label || forgotPasswordLink) && /* @__PURE__ */ jsxs7("div", { className: "flex justify-between items-center", children: [
638
- /* @__PURE__ */ jsx8(
639
- "label",
640
- {
641
- htmlFor: id,
642
- className: cn(
643
- "text-sm font-normal text-black leading-6",
644
- appearance.labelClassName
645
- ),
646
- children: label
647
- }
648
- ),
649
- forgotPasswordLink && /* @__PURE__ */ jsx8(
650
- "a",
651
- {
652
- href: forgotPasswordLink.href,
653
- className: "text-right text-sm font-normal text-[#737373] leading-6",
654
- children: forgotPasswordLink.text || "Forget Password?"
655
- }
656
- )
657
- ] }),
658
- /* @__PURE__ */ jsxs7("div", { className: "relative", children: [
659
- /* @__PURE__ */ jsx8(
660
- "input",
661
- {
662
- id,
663
- type: showPassword ? "text" : "password",
664
- className: cn(
665
- "w-full flex items-center gap-2 self-stretch",
666
- "pl-3 py-2 pr-8 rounded border border-[#D4D4D4] bg-white",
667
- "text-sm font-normal leading-5",
668
- "placeholder:text-[#A3A3A3] placeholder:font-sm placeholder:font-normal",
669
- "focus:outline-none focus:border-black",
670
- appearance.inputClassName
671
- ),
672
- value,
673
- onFocus: handleFocus,
674
- ...props
675
- }
676
- ),
677
- /* @__PURE__ */ jsx8(
678
- "button",
679
- {
680
- type: "button",
681
- onClick: () => setShowPassword(!showPassword),
682
- className: "absolute right-2 top-1/2 -translate-y-1/2 bg-transparent border-none text-[#A6A6A6] cursor-pointer transition-colors hover:text-gray-600 flex items-center justify-center",
683
- "aria-label": showPassword ? "Hide password" : "Show password",
684
- children: showPassword ? /* @__PURE__ */ jsx8(EyeOff, { size: 20 }) : /* @__PURE__ */ jsx8(Eye, { size: 20 })
685
- }
686
- )
687
- ] }),
688
- showStrengthIndicator && showStrength && /* @__PURE__ */ jsx8(
689
- AuthPasswordStrengthIndicator,
690
- {
691
- password: String(value || ""),
692
- config: emailAuthConfig
693
- }
694
- )
695
- ]
696
- }
697
- );
698
- }
699
-
700
- // src/components/auth/AuthSubmitButton.tsx
701
- import { CircleCheck, Loader2 } from "lucide-react";
702
- import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
703
- function AuthSubmitButton({
704
- children,
705
- isLoading = false,
706
- confirmed = false,
707
- disabled = false,
708
- className
709
- }) {
710
- return /* @__PURE__ */ jsxs8(
711
- "button",
712
- {
713
- type: "submit",
714
- className: cn(
715
- "rounded-sm bg-black w-full flex mt-4 px-4 py-2",
716
- "justify-center items-center gap-2.5 self-stretch",
717
- "text-white font-semibold font-manrope text-base leading-normal",
718
- "border-none cursor-pointer transition-colors",
719
- "hover:bg-gray-800",
720
- "disabled:opacity-50 disabled:cursor-not-allowed",
721
- className
722
- ),
723
- disabled: disabled || isLoading || confirmed,
724
- children: [
725
- isLoading && /* @__PURE__ */ jsx9(Loader2, { className: "w-5 h-5 animate-spin", size: 20 }),
726
- confirmed && /* @__PURE__ */ jsx9(CircleCheck, { className: "w-5 h-5", size: 20 }),
727
- children
728
- ]
729
- }
730
- );
731
- }
732
-
733
- // src/components/auth/AuthDivider.tsx
734
- import { jsx as jsx10 } from "react/jsx-runtime";
735
- function AuthDivider({ text = "or", className }) {
736
- return /* @__PURE__ */ jsx10("div", { className: cn(
737
- "flex justify-center items-center gap-6 self-stretch",
738
- "before:content-[''] before:flex-1 before:h-px before:bg-[#E5E5E5]",
739
- "after:content-[''] after:flex-1 after:h-px after:bg-[#E5E5E5]",
740
- className
741
- ), children: /* @__PURE__ */ jsx10("span", { className: "text-sm font-semibold font-manrope text-[#A3A3A3] leading-normal", children: text }) });
742
- }
743
-
744
- // src/components/auth/AuthLink.tsx
745
- import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
746
- function AuthLink({ text, linkText, href, appearance = {} }) {
747
- return /* @__PURE__ */ jsxs9("p", { className: cn(
748
- "text-center text-sm font-normal text-[#828282] leading-6",
749
- appearance.containerClassName
750
- ), children: [
751
- text,
752
- " ",
753
- /* @__PURE__ */ jsx11(
754
- "a",
755
- {
756
- href,
757
- className: cn(
758
- "text-sm font-medium text-black leading-6",
759
- appearance.linkClassName
760
- ),
761
- children: linkText
762
- }
763
- )
764
- ] });
765
- }
766
-
767
- // src/components/auth/AuthOAuthButton.tsx
768
- import { Loader2 as Loader22 } from "lucide-react";
769
-
770
- // src/config/oauth-providers.tsx
771
- import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
772
- var OAUTH_PROVIDER_CONFIG = {
773
- google: {
774
- name: "Google",
775
- svg: /* @__PURE__ */ jsxs10("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", children: [
776
- /* @__PURE__ */ jsx12(
777
- "path",
778
- {
779
- d: "M17.64 9.2c0-.637-.057-1.251-.164-1.84H9v3.481h4.844c-.209 1.125-.843 2.078-1.796 2.717v2.258h2.908c1.702-1.567 2.684-3.874 2.684-6.615z",
780
- fill: "#4285F4"
781
- }
782
- ),
783
- /* @__PURE__ */ jsx12(
784
- "path",
785
- {
786
- d: "M9 18c2.43 0 4.467-.806 5.956-2.184l-2.908-2.258c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.584-5.036-3.711H.957v2.332C2.438 15.983 5.482 18 9 18z",
787
- fill: "#34A853"
788
- }
789
- ),
790
- /* @__PURE__ */ jsx12(
791
- "path",
792
- {
793
- d: "M3.964 10.707c-.18-.54-.282-1.117-.282-1.707 0-.593.102-1.17.282-1.709V4.958H.957C.347 6.173 0 7.548 0 9c0 1.452.348 2.827.957 4.042l3.007-2.335z",
794
- fill: "#FBBC05"
795
- }
796
- ),
797
- /* @__PURE__ */ jsx12(
798
- "path",
799
- {
800
- d: "M9 3.58c1.321 0 2.508.454 3.44 1.345l2.582-2.58C13.463.891 11.426 0 9 0 5.482 0 2.438 2.017.957 4.958L3.964 7.29C4.672 5.163 6.656 3.58 9 3.58z",
801
- fill: "#EA4335"
802
- }
803
- )
804
- ] }),
805
- className: "insforge-oauth-google"
806
- },
807
- github: {
808
- name: "GitHub",
809
- svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ jsx12("path", { d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" }) }),
810
- className: "insforge-oauth-github"
811
- },
812
- discord: {
813
- name: "Discord",
814
- svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx12(
815
- "path",
816
- {
817
- d: "M20.317 4.37a19.791 19.791 0 00-4.885-1.515.074.074 0 00-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 00-5.487 0 12.64 12.64 0 00-.617-1.25.077.077 0 00-.079-.037A19.736 19.736 0 003.677 4.37a.07.07 0 00-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 00.031.057 19.9 19.9 0 005.993 3.03.078.078 0 00.084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 00-.041-.106 13.107 13.107 0 01-1.872-.892.077.077 0 01-.008-.128 10.2 10.2 0 00.372-.292.074.074 0 01.077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 01.078.01c.12.098.246.198.373.292a.077.077 0 01-.006.127 12.299 12.299 0 01-1.873.892.077.077 0 00-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 00.084.028 19.839 19.839 0 006.002-3.03.077.077 0 00.032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 00-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z",
818
- fill: "#5865F2"
819
- }
820
- ) }),
821
- className: "insforge-oauth-discord"
822
- },
823
- facebook: {
824
- name: "Facebook",
825
- svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx12(
826
- "path",
827
- {
828
- d: "M24 12.073C24 5.405 18.627 0 12 0S0 5.405 0 12.073C0 18.1 4.388 23.094 10.125 24v-8.437H7.078v-3.49h3.047v-2.66c0-3.025 1.792-4.697 4.533-4.697 1.312 0 2.686.236 2.686.236v2.971H15.83c-1.49 0-1.955.93-1.955 1.886v2.264h3.328l-.532 3.49h-2.796V24C19.612 23.094 24 18.1 24 12.073z",
829
- fill: "#1877F2"
830
- }
831
- ) }),
832
- className: "insforge-oauth-facebook"
833
- },
834
- linkedin: {
835
- name: "LinkedIn",
836
- svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx12(
837
- "path",
838
- {
839
- d: "M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z",
840
- fill: "#0A66C2"
841
- }
842
- ) }),
843
- className: "insforge-oauth-linkedin"
844
- },
845
- microsoft: {
846
- name: "Microsoft",
847
- svg: /* @__PURE__ */ jsxs10("svg", { width: "18", height: "18", viewBox: "0 0 23 23", fill: "none", children: [
848
- /* @__PURE__ */ jsx12("path", { d: "M0 0h11v11H0z", fill: "#F25022" }),
849
- /* @__PURE__ */ jsx12("path", { d: "M12 0h11v11H12z", fill: "#7FBA00" }),
850
- /* @__PURE__ */ jsx12("path", { d: "M0 12h11v11H0z", fill: "#00A4EF" }),
851
- /* @__PURE__ */ jsx12("path", { d: "M12 12h11v11H12z", fill: "#FFB900" })
852
- ] }),
853
- className: "insforge-oauth-microsoft"
854
- },
855
- apple: {
856
- name: "Apple",
857
- svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx12("path", { d: "M17.05 20.28c-.98.95-2.05.8-3.08.35-1.09-.46-2.09-.48-3.24 0-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09l.01-.01zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z" }) }),
858
- className: "insforge-oauth-apple"
859
- },
860
- x: {
861
- name: "X",
862
- svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx12("path", { d: "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" }) }),
863
- className: "insforge-oauth-x"
864
- },
865
- instagram: {
866
- name: "Instagram",
867
- svg: /* @__PURE__ */ jsxs10("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: [
868
- /* @__PURE__ */ jsx12(
869
- "path",
870
- {
871
- d: "M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z",
872
- fill: "url(#instagram-gradient)"
873
- }
874
- ),
875
- /* @__PURE__ */ jsx12("defs", { children: /* @__PURE__ */ jsxs10("linearGradient", { id: "instagram-gradient", x1: "0%", y1: "100%", x2: "100%", y2: "0%", children: [
876
- /* @__PURE__ */ jsx12("stop", { offset: "0%", stopColor: "#FD5949" }),
877
- /* @__PURE__ */ jsx12("stop", { offset: "50%", stopColor: "#D6249F" }),
878
- /* @__PURE__ */ jsx12("stop", { offset: "100%", stopColor: "#285AEB" })
879
- ] }) })
880
- ] }),
881
- className: "insforge-oauth-instagram"
882
- },
883
- tiktok: {
884
- name: "TikTok",
885
- svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx12(
886
- "path",
887
- {
888
- d: "M19.589 6.686a4.793 4.793 0 01-3.77-4.245V2h-3.445v13.672a2.896 2.896 0 01-5.201 1.743l-.002-.001.002.001a2.895 2.895 0 013.183-4.51v-3.5a6.329 6.329 0 00-5.394 10.692 6.33 6.33 0 0010.857-4.424V8.687a8.182 8.182 0 004.773 1.526V6.79a4.831 4.831 0 01-1.003-.104z",
889
- fill: "currentColor"
890
- }
891
- ) }),
892
- className: "insforge-oauth-tiktok"
893
- },
894
- spotify: {
895
- name: "Spotify",
896
- svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx12(
897
- "path",
898
- {
899
- d: "M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z",
900
- fill: "#1DB954"
901
- }
902
- ) }),
903
- className: "insforge-oauth-spotify"
904
- }
905
- };
906
- function getProviderConfig(provider) {
907
- return OAUTH_PROVIDER_CONFIG[provider] || null;
908
- }
909
- function getProviderName(provider) {
910
- return OAUTH_PROVIDER_CONFIG[provider]?.name || provider;
911
- }
912
- function isProviderSupported(provider) {
913
- return provider in OAUTH_PROVIDER_CONFIG;
914
- }
915
-
916
- // src/components/auth/AuthOAuthButton.tsx
917
- import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
918
- function AuthOAuthButton({
919
- provider,
920
- onClick,
921
- disabled,
922
- loading,
923
- displayMode = "full",
924
- style,
925
- className
926
- }) {
927
- const config = getProviderConfig(provider);
928
- if (!config) {
929
- return null;
930
- }
931
- const getButtonText = () => {
932
- if (loading) return "Authenticating...";
933
- if (displayMode === "full") return `Continue with ${config.name}`;
934
- if (displayMode === "short") return config.name;
935
- return "";
936
- };
937
- return /* @__PURE__ */ jsxs11(
938
- "button",
939
- {
940
- type: "button",
941
- onClick: () => onClick(provider),
942
- className: cn(
943
- "flex w-full h-9 px-3 py-2",
944
- "flex-row justify-center items-center gap-3",
945
- "rounded-md border border-[#E4E4E7] bg-white",
946
- "shadow-[0_1px_2px_0_rgba(0,0,0,0.10)]",
947
- "text-[#09090B] text-center text-sm font-medium leading-5",
948
- "cursor-pointer transition-all duration-200",
949
- "hover:bg-[#f9fafb] hover:border-[#9ca3af]",
950
- "disabled:opacity-60 disabled:cursor-not-allowed",
951
- displayMode === "full" && "justify-center",
952
- displayMode === "short" && "justify-center px-2 gap-2",
953
- displayMode === "icon" && "justify-center gap-0",
954
- className
955
- ),
956
- disabled: disabled || loading,
957
- style,
958
- children: [
959
- loading ? /* @__PURE__ */ jsx13(Loader22, { className: "w-[18px] h-[18px] animate-spin", size: 18 }) : /* @__PURE__ */ jsx13("span", { className: "flex items-center justify-center flex-shrink-0", children: config.svg }),
960
- getButtonText() && /* @__PURE__ */ jsx13("span", { children: getButtonText() })
961
- ]
962
- }
963
- );
964
- }
965
-
966
- // src/components/auth/AuthOAuthProviders.tsx
967
- import { jsx as jsx14 } from "react/jsx-runtime";
968
- function AuthOAuthProviders({
969
- providers,
970
- onClick,
971
- disabled,
972
- loading,
973
- appearance = {}
974
- }) {
975
- if (!providers || providers.length === 0) {
976
- return null;
977
- }
978
- const count = providers.length;
979
- const getDisplayMode = () => {
980
- if (count === 1) return "full";
981
- if (count === 2 || count === 4) return "short";
982
- return "icon";
983
- };
984
- const getGridColumnStyle = (index) => {
985
- if (count <= 4) {
986
- return {};
987
- }
988
- const totalRows = Math.ceil(count / 3);
989
- const lastRowStartIndex = (totalRows - 1) * 3;
990
- const isInLastRow = index >= lastRowStartIndex;
991
- if (!isInLastRow) {
992
- return { gridColumn: "span 2" };
993
- }
994
- const positionInLastRow = index - lastRowStartIndex;
995
- const itemsInLastRow = count - lastRowStartIndex;
996
- if (itemsInLastRow === 1) {
997
- return { gridColumn: "3 / 5" };
998
- } else if (itemsInLastRow === 2) {
999
- if (positionInLastRow === 0) {
1000
- return { gridColumn: "2 / 4" };
1001
- } else {
1002
- return { gridColumn: "4 / 6" };
1003
- }
1004
- } else {
1005
- return { gridColumn: "span 2" };
1006
- }
1007
- };
1008
- const getGridClass = () => {
1009
- if (count === 1) return "grid-cols-1";
1010
- if (count === 2) return "grid-cols-2";
1011
- if (count === 3) return "grid-cols-3";
1012
- if (count === 4) return "grid-cols-2";
1013
- return "grid-cols-6";
1014
- };
1015
- return /* @__PURE__ */ jsx14("div", { className: cn(
1016
- "grid gap-3 w-full",
1017
- getGridClass(),
1018
- appearance.containerClassName
1019
- ), children: providers.map((provider, index) => /* @__PURE__ */ jsx14(
1020
- AuthOAuthButton,
1021
- {
1022
- provider,
1023
- onClick,
1024
- disabled,
1025
- loading: loading === provider,
1026
- displayMode: getDisplayMode(),
1027
- style: getGridColumnStyle(index),
1028
- className: appearance.buttonClassName
1029
- },
1030
- provider
1031
- )) });
1032
- }
1033
-
1034
- // src/components/auth/AuthVerificationCodeInput.tsx
1035
- import {
1036
- useRef as useRef2
1037
- } from "react";
1038
- import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
1039
- function AuthVerificationCodeInput({
1040
- length = 6,
1041
- value,
1042
- email,
1043
- onChange,
1044
- disabled = false,
1045
- appearance = {}
1046
- }) {
1047
- const inputRefs = useRef2([]);
1048
- const handleChange = (index, digit) => {
1049
- if (digit.length > 1) return;
1050
- if (digit && !/^\d$/.test(digit)) return;
1051
- const newValue = value.split("");
1052
- newValue[index] = digit;
1053
- const updatedValue = newValue.join("");
1054
- onChange(updatedValue);
1055
- if (digit && index < length - 1) {
1056
- inputRefs.current[index + 1]?.focus();
1057
- }
1058
- };
1059
- const handleKeyDown = (index, e) => {
1060
- if (e.key === "Backspace") {
1061
- if (!value[index] && index > 0) {
1062
- inputRefs.current[index - 1]?.focus();
1063
- } else {
1064
- handleChange(index, "");
1065
- }
1066
- } else if (e.key === "ArrowLeft" && index > 0) {
1067
- inputRefs.current[index - 1]?.focus();
1068
- } else if (e.key === "ArrowRight" && index < length - 1) {
1069
- inputRefs.current[index + 1]?.focus();
1070
- }
1071
- };
1072
- const handlePaste = (e) => {
1073
- e.preventDefault();
1074
- const pastedData = e.clipboardData.getData("text/plain").trim();
1075
- if (/^\d+$/.test(pastedData) && pastedData.length === length) {
1076
- onChange(pastedData);
1077
- inputRefs.current[length - 1]?.focus();
1078
- }
1079
- };
1080
- return /* @__PURE__ */ jsxs12("div", { className: cn(
1081
- "flex flex-col justify-center items-center gap-6",
1082
- appearance.containerClassName
1083
- ), children: [
1084
- /* @__PURE__ */ jsxs12("p", { className: "text-sm font-normal text-[#525252] leading-5", children: [
1085
- "We've sent a verification code to your inbox at",
1086
- " ",
1087
- /* @__PURE__ */ jsx15("span", { className: "text-sm font-semibold text-black leading-5", children: email }),
1088
- ". Enter it below to proceed."
1089
- ] }),
1090
- /* @__PURE__ */ jsx15("div", { className: "flex flex-row gap-3 justify-center items-center", children: Array.from({ length }).map((_, index) => /* @__PURE__ */ jsx15(
1091
- "input",
1092
- {
1093
- ref: (el) => {
1094
- inputRefs.current[index] = el;
1095
- },
1096
- type: "text",
1097
- inputMode: "numeric",
1098
- maxLength: 1,
1099
- value: value[index] || "",
1100
- onChange: (e) => handleChange(index, e.target.value),
1101
- onKeyDown: (e) => handleKeyDown(index, e),
1102
- onPaste: handlePaste,
1103
- disabled,
1104
- className: cn(
1105
- "w-full h-12 px-3 py-2 rounded border border-[#E0E0E0] bg-white",
1106
- "text-center text-base font-semibold leading-5 text-black",
1107
- "transition-all duration-200 outline-none",
1108
- "focus:border-black focus:shadow-[0_0_0_2px_rgba(0,0,0,0.1)]",
1109
- "disabled:bg-[#F5F5F5] disabled:cursor-not-allowed disabled:opacity-60",
1110
- appearance.inputClassName
1111
- ),
1112
- autoComplete: "one-time-code"
1113
- },
1114
- index
1115
- )) })
1116
- ] });
1117
- }
1118
-
1119
- // src/components/SignIn.tsx
1120
- import { Fragment, jsx as jsx16, jsxs as jsxs13 } from "react/jsx-runtime";
1121
- function SignIn({
1122
- afterSignInUrl = "/",
1123
- appearance = {},
1124
- title = "Welcome Back",
1125
- subtitle = "Login to your account",
1126
- emailLabel = "Email",
1127
- emailPlaceholder = "example@email.com",
1128
- passwordLabel = "Password",
1129
- passwordPlaceholder = "\u2022\u2022\u2022\u2022\u2022\u2022",
1130
- submitButtonText = "Sign In",
1131
- loadingButtonText = "Signing in...",
1132
- signUpText = "Don't have an account?",
1133
- signUpLinkText = "Sign Up Now",
1134
- signUpUrl = "/sign-up",
1135
- dividerText = "or",
1136
- onSuccess,
1137
- onError
1138
- }) {
1139
- const { signIn, baseUrl } = useInsforge();
1140
- const { providers: oauthProviders } = useOAuthProviders();
1141
- const { config: emailAuthConfig } = useEmailAuthConfig();
1142
- const [email, setEmail] = useState5("");
1143
- const [password, setPassword] = useState5("");
1144
- const [error, setError] = useState5("");
1145
- const [loading, setLoading] = useState5(false);
1146
- const [oauthLoading, setOauthLoading] = useState5(
1147
- null
1148
- );
1149
- const insforge = useState5(() => createClient4({ baseUrl }))[0];
1150
- async function handleSubmit(e) {
1151
- e.preventDefault();
1152
- setLoading(true);
1153
- setError("");
1154
- try {
1155
- await signIn(email, password);
1156
- if (onSuccess) {
1157
- const userResult = await insforge.auth.getCurrentUser();
1158
- if (userResult.data) onSuccess(userResult.data);
1159
- }
1160
- window.location.href = afterSignInUrl;
1161
- } catch (err) {
1162
- const errorMessage = err.message || "Sign in failed";
1163
- setError(errorMessage);
1164
- if (onError) onError(new Error(errorMessage));
1165
- } finally {
1166
- setLoading(false);
1167
- }
1168
- }
1169
- async function handleOAuth(provider) {
1170
- try {
1171
- setOauthLoading(provider);
1172
- const redirectTo = `${window.location.origin}/auth/callback`;
1173
- sessionStorage.setItem("oauth_final_destination", afterSignInUrl || "/");
1174
- const result = await insforge.auth.signInWithOAuth({
1175
- provider,
1176
- redirectTo
1177
- });
1178
- } catch (err) {
1179
- const errorMessage = err.message || `${provider} sign in failed`;
1180
- setError(errorMessage);
1181
- if (onError) onError(new Error(errorMessage));
1182
- setOauthLoading(null);
1183
- }
1184
- }
1185
- return /* @__PURE__ */ jsxs13(AuthContainer, { appearance: { containerClassName: appearance.containerClassName }, children: [
1186
- /* @__PURE__ */ jsx16(AuthHeader, { title, subtitle }),
1187
- /* @__PURE__ */ jsx16(AuthErrorBanner, { error }),
1188
- /* @__PURE__ */ jsxs13(
1189
- "form",
1190
- {
1191
- onSubmit: handleSubmit,
1192
- noValidate: true,
1193
- className: "flex flex-col items-stretch justify-center gap-6",
1194
- children: [
1195
- /* @__PURE__ */ jsx16(
1196
- AuthFormField,
1197
- {
1198
- id: "email",
1199
- type: "email",
1200
- label: emailLabel,
1201
- placeholder: emailPlaceholder,
1202
- value: email,
1203
- onChange: (e) => setEmail(e.target.value),
1204
- required: true,
1205
- autoComplete: "email"
1206
- }
1207
- ),
1208
- /* @__PURE__ */ jsx16(
1209
- AuthPasswordField,
1210
- {
1211
- id: "password",
1212
- label: passwordLabel,
1213
- placeholder: passwordPlaceholder,
1214
- value: password,
1215
- onChange: (e) => setPassword(e.target.value),
1216
- required: true,
1217
- autoComplete: "current-password",
1218
- emailAuthConfig: emailAuthConfig || {
1219
- requireEmailVerification: false,
1220
- passwordMinLength: 6,
1221
- requireNumber: false,
1222
- requireLowercase: false,
1223
- requireUppercase: false,
1224
- requireSpecialChar: false
1225
- }
1226
- }
1227
- ),
1228
- /* @__PURE__ */ jsx16(
1229
- AuthSubmitButton,
1230
- {
1231
- isLoading: loading,
1232
- disabled: loading || oauthLoading !== null,
1233
- className: appearance.buttonClassName,
1234
- children: loading ? loadingButtonText : submitButtonText
1235
- }
1236
- )
1237
- ]
1238
- }
1239
- ),
1240
- /* @__PURE__ */ jsx16(AuthLink, { text: signUpText, linkText: signUpLinkText, href: signUpUrl }),
1241
- oauthProviders.length > 0 && /* @__PURE__ */ jsxs13(Fragment, { children: [
1242
- /* @__PURE__ */ jsx16(AuthDivider, { text: dividerText }),
1243
- /* @__PURE__ */ jsx16(
1244
- AuthOAuthProviders,
1245
- {
1246
- providers: oauthProviders,
1247
- onClick: handleOAuth,
1248
- disabled: loading || oauthLoading !== null,
1249
- loading: oauthLoading
1250
- }
1251
- )
1252
- ] })
1253
- ] });
1254
- }
1255
-
1256
- // src/components/SignUp.tsx
1257
- import { useState as useState6 } from "react";
1258
- import { createClient as createClient5 } from "@insforge/sdk";
1259
- import { Fragment as Fragment2, jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
1260
- function SignUp({
1261
- afterSignUpUrl = "/",
1262
- appearance = {},
1263
- title = "Get Started",
1264
- subtitle = "Create account",
1265
- emailLabel = "Email",
1266
- emailPlaceholder = "example@email.com",
1267
- passwordLabel = "Password",
1268
- passwordPlaceholder = "\u2022\u2022\u2022\u2022\u2022\u2022",
1269
- submitButtonText = "Sign Up",
1270
- loadingButtonText = "Creating account...",
1271
- // verifyButtonText = "Continue", // Commented out - email verification disabled for now
1272
- // loadingVerifyButtonText = "Verifying...", // Commented out - email verification disabled for now
1273
- // verifiedButtonText = "Verified", // Commented out - email verification disabled for now
1274
- signInText = "Already have an account?",
1275
- signInLinkText = "Login Now",
1276
- signInUrl = "/sign-in",
1277
- dividerText = "or",
1278
- onSuccess,
1279
- onError
1280
- }) {
1281
- const { signUp, baseUrl } = useInsforge();
1282
- const { providers: oauthProviders } = useOAuthProviders();
1283
- const { config: emailAuthConfig } = useEmailAuthConfig();
1284
- const [email, setEmail] = useState6("");
1285
- const [password, setPassword] = useState6("");
1286
- const [error, setError] = useState6("");
1287
- const [loading, setLoading] = useState6(false);
1288
- const [oauthLoading, setOauthLoading] = useState6(
1289
- null
1290
- );
1291
- const insforge = useState6(() => createClient5({ baseUrl }))[0];
1292
- async function handleCredentialsSubmit(e) {
1293
- e.preventDefault();
1294
- setLoading(true);
1295
- setError("");
1296
- if (emailAuthConfig && !validatePasswordStrength(password, emailAuthConfig)) {
1297
- setError("Password does not meet all requirements");
1298
- setLoading(false);
1299
- return;
1300
- }
1301
- try {
1302
- await signUp(email, password);
1303
- if (onSuccess) {
1304
- const userResult = await insforge.auth.getCurrentUser();
1305
- if (userResult.data) onSuccess(userResult.data);
1306
- }
1307
- window.location.href = afterSignUpUrl;
1308
- } catch (err) {
1309
- const errorMessage = err.message || "Sign up failed";
1310
- setError(errorMessage);
1311
- if (onError) onError(new Error(errorMessage));
1312
- } finally {
1313
- setLoading(false);
1314
- }
1315
- }
1316
- async function handleOAuth(provider) {
1317
- try {
1318
- setOauthLoading(provider);
1319
- const redirectTo = `${window.location.origin}/auth/callback`;
1320
- sessionStorage.setItem("oauth_final_destination", afterSignUpUrl || "/");
1321
- const result = await insforge.auth.signInWithOAuth({
1322
- provider,
1323
- redirectTo
1324
- });
1325
- if (result.data?.url) {
1326
- window.location.href = result.data.url;
1327
- }
1328
- } catch (err) {
1329
- const errorMessage = err.message || `${provider} sign up failed`;
1330
- setError(errorMessage);
1331
- if (onError) onError(new Error(errorMessage));
1332
- setOauthLoading(null);
1333
- }
1334
- }
1335
- return /* @__PURE__ */ jsxs14(AuthContainer, { appearance: { containerClassName: appearance.containerClassName }, children: [
1336
- /* @__PURE__ */ jsx17(AuthHeader, { title, subtitle }),
1337
- /* @__PURE__ */ jsx17(AuthErrorBanner, { error }),
1338
- /* @__PURE__ */ jsxs14(
1339
- "form",
1340
- {
1341
- onSubmit: handleCredentialsSubmit,
1342
- noValidate: true,
1343
- className: "flex flex-col items-stretch justify-center gap-6",
1344
- children: [
1345
- /* @__PURE__ */ jsx17(
1346
- AuthFormField,
1347
- {
1348
- id: "email",
1349
- type: "email",
1350
- label: emailLabel,
1351
- placeholder: emailPlaceholder,
1352
- value: email,
1353
- onChange: (e) => setEmail(e.target.value),
1354
- required: true,
1355
- autoComplete: "email"
1356
- }
1357
- ),
1358
- /* @__PURE__ */ jsx17(
1359
- AuthPasswordField,
1360
- {
1361
- id: "password",
1362
- label: passwordLabel,
1363
- placeholder: passwordPlaceholder,
1364
- value: password,
1365
- onChange: (e) => setPassword(e.target.value),
1366
- required: true,
1367
- minLength: emailAuthConfig?.passwordMinLength ?? 8,
1368
- autoComplete: "new-password",
1369
- showStrengthIndicator: true,
1370
- emailAuthConfig: emailAuthConfig || {
1371
- requireEmailVerification: false,
1372
- passwordMinLength: 6,
1373
- requireNumber: false,
1374
- requireLowercase: false,
1375
- requireUppercase: false,
1376
- requireSpecialChar: false
1377
- }
1378
- }
1379
- ),
1380
- /* @__PURE__ */ jsx17(
1381
- AuthSubmitButton,
1382
- {
1383
- isLoading: loading,
1384
- disabled: loading || oauthLoading !== null,
1385
- className: appearance.buttonClassName,
1386
- children: loading ? loadingButtonText : submitButtonText
1387
- }
1388
- )
1389
- ]
1390
- }
1391
- ),
1392
- /* @__PURE__ */ jsx17(AuthLink, { text: signInText, linkText: signInLinkText, href: signInUrl }),
1393
- oauthProviders.length > 0 && /* @__PURE__ */ jsxs14(Fragment2, { children: [
1394
- /* @__PURE__ */ jsx17(AuthDivider, { text: dividerText }),
1395
- /* @__PURE__ */ jsx17(
1396
- AuthOAuthProviders,
1397
- {
1398
- providers: oauthProviders,
1399
- onClick: handleOAuth,
1400
- disabled: loading || oauthLoading !== null,
1401
- loading: oauthLoading
1402
- }
1403
- )
1404
- ] })
1405
- ] });
1406
- }
1407
-
1408
- // src/components/UserButton.tsx
1409
- import { useState as useState7, useRef as useRef3, useEffect as useEffect4 } from "react";
1410
- import { LogOut } from "lucide-react";
1411
- import { jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
1412
- function UserButton({
1413
- afterSignOutUrl = "/",
1414
- mode = "detailed",
1415
- appearance = {}
1416
- }) {
1417
- const { user, signOut } = useInsforge();
1418
- const [isOpen, setIsOpen] = useState7(false);
1419
- const [imageError, setImageError] = useState7(false);
1420
- const dropdownRef = useRef3(null);
1421
- useEffect4(() => {
1422
- setImageError(false);
1423
- const avatarUrl = user?.avatarUrl;
1424
- if (!avatarUrl) return;
1425
- const checkImageUrl = async () => {
1426
- try {
1427
- const response = await fetch(avatarUrl, {
1428
- method: "HEAD",
1429
- // Only fetch headers, not the full image
1430
- cache: "no-cache"
1431
- });
1432
- if (!response.ok) {
1433
- setImageError(true);
1434
- }
1435
- } catch (error) {
1436
- setImageError(true);
1437
- }
1438
- };
1439
- checkImageUrl();
1440
- }, [user?.avatarUrl]);
1441
- useEffect4(() => {
1442
- function handleClickOutside(event) {
1443
- if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
1444
- setIsOpen(false);
1445
- }
1446
- }
1447
- if (isOpen) {
1448
- document.addEventListener("mousedown", handleClickOutside);
1449
- }
1450
- return () => {
1451
- document.removeEventListener("mousedown", handleClickOutside);
1452
- };
1453
- }, [isOpen]);
1454
- async function handleSignOut() {
1455
- await signOut();
1456
- setIsOpen(false);
1457
- window.location.href = afterSignOutUrl;
1458
- }
1459
- if (!user) return null;
1460
- const initials = user.name ? user.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
1461
- return /* @__PURE__ */ jsxs15(
1462
- "div",
1463
- {
1464
- className: cn("relative inline-block", appearance.containerClassName),
1465
- ref: dropdownRef,
1466
- children: [
1467
- /* @__PURE__ */ jsxs15(
1468
- "button",
1469
- {
1470
- className: cn(
1471
- // Base styles
1472
- "p-1 bg-transparent border-0 rounded-full cursor-pointer transition-all duration-200",
1473
- "flex items-center justify-center gap-2",
1474
- "hover:bg-black/5",
1475
- // Detailed mode styles
1476
- mode === "detailed" && "rounded-lg p-2",
1477
- // User override
1478
- appearance.buttonClassName
1479
- ),
1480
- onClick: () => setIsOpen(!isOpen),
1481
- "aria-expanded": isOpen,
1482
- "aria-haspopup": "true",
1483
- children: [
1484
- /* @__PURE__ */ jsx18("div", { className: "flex items-center justify-center w-10 h-10 bg-blue-500 rounded-full", children: user.avatarUrl && !imageError ? /* @__PURE__ */ jsx18(
1485
- "img",
1486
- {
1487
- src: user.avatarUrl,
1488
- alt: user.email,
1489
- onError: () => setImageError(true),
1490
- className: "rounded-full object-cover w-full h-full"
1491
- }
1492
- ) : /* @__PURE__ */ jsx18("span", { className: "text-white font-semibold text-sm", children: initials }) }),
1493
- mode === "detailed" && /* @__PURE__ */ jsxs15("div", { className: "flex flex-col items-start gap-0.5", children: [
1494
- user.name && /* @__PURE__ */ jsx18(
1495
- "div",
1496
- {
1497
- className: cn(
1498
- "text-sm font-semibold text-gray-900 leading-5 text-left",
1499
- appearance.nameClassName
1500
- ),
1501
- children: user.name
1502
- }
1503
- ),
1504
- /* @__PURE__ */ jsx18(
1505
- "div",
1506
- {
1507
- className: cn(
1508
- "text-xs text-gray-500 leading-4 text-left",
1509
- appearance.emailClassName
1510
- ),
1511
- children: user.email
1512
- }
1513
- )
1514
- ] })
1515
- ]
1516
- }
1517
- ),
1518
- isOpen && /* @__PURE__ */ jsx18(
1519
- "div",
1520
- {
1521
- className: cn(
1522
- "absolute top-full right-0 mt-2 min-w-40",
1523
- "bg-white border border-gray-200 rounded-lg",
1524
- "shadow-lg z-50 overflow-hidden p-1",
1525
- appearance.dropdownClassName
1526
- ),
1527
- children: /* @__PURE__ */ jsxs15(
1528
- "button",
1529
- {
1530
- onClick: handleSignOut,
1531
- className: "flex items-center justify-start gap-2 w-full px-3 py-2 text-sm font-normal text-red-600 bg-transparent border-0 rounded-md cursor-pointer transition-colors hover:bg-red-50 text-left",
1532
- children: [
1533
- /* @__PURE__ */ jsx18(LogOut, { className: "w-5 h-5" }),
1534
- "Sign out"
1535
- ]
1536
- }
1537
- )
1538
- }
1539
- )
1540
- ]
1541
- }
1542
- );
1543
- }
1544
-
1545
- // src/components/SignedIn.tsx
1546
- import { Fragment as Fragment3, jsx as jsx19 } from "react/jsx-runtime";
1547
- function SignedIn({ children }) {
1548
- const { isSignedIn, isLoaded } = useInsforge();
1549
- if (!isLoaded) return null;
1550
- if (!isSignedIn) return null;
1551
- return /* @__PURE__ */ jsx19(Fragment3, { children });
1552
- }
1553
-
1554
- // src/components/SignedOut.tsx
1555
- import { Fragment as Fragment4, jsx as jsx20 } from "react/jsx-runtime";
1556
- function SignedOut({ children }) {
1557
- const { isSignedIn, isLoaded } = useInsforge();
1558
- if (!isLoaded) return null;
1559
- if (isSignedIn) return null;
1560
- return /* @__PURE__ */ jsx20(Fragment4, { children });
1561
- }
1562
-
1563
- // src/components/Protect.tsx
1564
- import { useEffect as useEffect5 } from "react";
1565
- import { useRouter } from "next/navigation";
1566
- import { Fragment as Fragment5, jsx as jsx21 } from "react/jsx-runtime";
1567
- function Protect({
1568
- children,
1569
- fallback,
1570
- redirectTo = "/sign-in",
1571
- condition
1572
- }) {
1573
- const { isSignedIn, isLoaded, user } = useInsforge();
1574
- const router = useRouter();
1575
- useEffect5(() => {
1576
- if (isLoaded && !isSignedIn) {
1577
- router.push(redirectTo);
1578
- } else if (isLoaded && isSignedIn && condition && user) {
1579
- if (!condition(user)) {
1580
- router.push(redirectTo);
1581
- }
1582
- }
1583
- }, [isLoaded, isSignedIn, redirectTo, router, condition, user]);
1584
- if (!isLoaded) {
1585
- return fallback || /* @__PURE__ */ jsx21("div", { className: "insforge-loading", children: "Loading..." });
1586
- }
1587
- if (!isSignedIn) {
1588
- return fallback || null;
1589
- }
1590
- if (condition && user && !condition(user)) {
1591
- return fallback || null;
1592
- }
1593
- return /* @__PURE__ */ jsx21(Fragment5, { children });
1594
- }
1595
-
1596
- // src/components/InsforgeCallback.tsx
1597
- import { useEffect as useEffect6, useRef as useRef4, Suspense } from "react";
1598
- import { useRouter as useRouter2, useSearchParams } from "next/navigation";
1599
- import { jsx as jsx22, jsxs as jsxs16 } from "react/jsx-runtime";
1600
- function CallbackContent({
1601
- redirectTo,
1602
- onSuccess,
1603
- onError
1604
- }) {
1605
- const router = useRouter2();
1606
- const searchParams = useSearchParams();
1607
- const isProcessingRef = useRef4(false);
1608
- const { reloadAuth } = useInsforge();
1609
- useEffect6(() => {
1610
- const processCallback = async () => {
1611
- if (isProcessingRef.current) return;
1612
- isProcessingRef.current = true;
1613
- const error = searchParams.get("error");
1614
- if (error) {
1615
- if (onError) {
1616
- onError(error);
1617
- } else {
1618
- router.push("/?error=" + encodeURIComponent(error));
1619
- }
1620
- return;
1621
- }
1622
- const result = await reloadAuth();
1623
- if (!result.success) {
1624
- const errorMsg = result.error || "authentication_failed";
1625
- if (onError) {
1626
- onError(errorMsg);
1627
- } else {
1628
- router.push("/?error=" + encodeURIComponent(errorMsg));
1629
- }
1630
- return;
1631
- }
1632
- window.history.replaceState({}, "", window.location.pathname);
1633
- if (onSuccess) {
1634
- onSuccess();
1635
- }
1636
- const destination = redirectTo || sessionStorage.getItem("auth_destination") || sessionStorage.getItem("oauth_final_destination") || "/";
1637
- sessionStorage.removeItem("auth_destination");
1638
- sessionStorage.removeItem("oauth_final_destination");
1639
- router.push(destination);
1640
- };
1641
- processCallback();
1642
- }, [searchParams, router, redirectTo, onSuccess, onError, reloadAuth]);
1643
- return null;
1644
- }
1645
- function InsforgeCallback({
1646
- loadingComponent,
1647
- ...props
1648
- }) {
1649
- const defaultLoading = /* @__PURE__ */ jsx22("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxs16("div", { className: "text-center", children: [
1650
- /* @__PURE__ */ jsx22("h2", { className: "text-2xl font-semibold mb-4", children: "Completing authentication..." }),
1651
- /* @__PURE__ */ jsx22("div", { className: "animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto" })
1652
- ] }) });
1653
- return /* @__PURE__ */ jsxs16(Suspense, { fallback: loadingComponent || defaultLoading, children: [
1654
- /* @__PURE__ */ jsx22(CallbackContent, { ...props }),
1655
- loadingComponent || defaultLoading
1656
- ] });
1657
- }
60
+ // src/index.ts
61
+ export * from "@insforge/react/hooks";
62
+ export * from "@insforge/react/components";
1658
63
  export {
1659
- AuthBranding,
1660
- AuthContainer,
1661
- AuthDivider,
1662
- AuthErrorBanner,
1663
- AuthFormField,
1664
- AuthHeader,
1665
- AuthLink,
1666
- AuthOAuthButton,
1667
- AuthOAuthProviders,
1668
- AuthPasswordField,
1669
- AuthPasswordStrengthIndicator,
1670
- AuthSubmitButton,
1671
- AuthVerificationCodeInput,
1672
- InsforgeCallback,
1673
64
  InsforgeProvider,
1674
- OAUTH_PROVIDER_CONFIG,
1675
- Protect,
1676
- SignIn,
1677
- SignUp,
1678
- SignedIn,
1679
- SignedOut,
1680
- UserButton,
1681
65
  cn,
1682
- getProviderConfig,
1683
- getProviderName,
1684
- isProviderSupported,
1685
- useAuth,
1686
- useInsforge,
1687
- useUser,
1688
- validatePasswordStrength
66
+ useInsforge
1689
67
  };
1690
68
  //# sourceMappingURL=index.mjs.map