@vaultix.ai/react 0.2.4 → 0.3.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.js CHANGED
@@ -170,21 +170,22 @@ function VaultixProvider({
170
170
  }
171
171
  jwtRef.current = jwt;
172
172
  }
173
+ if (!jwt) {
174
+ if (!cancelled) setIsLoaded(true);
175
+ return;
176
+ }
173
177
  try {
174
178
  const headers = {
179
+ "Authorization": `Bearer ${jwt}`,
175
180
  "X-Vaultix-Publishable-Key": publishableKey
176
181
  };
177
- if (jwt) headers["Authorization"] = `Bearer ${jwt}`;
178
182
  const res = await fetch(`${apiOrigin}/api/v1/me`, {
179
- // Use Bearer token for cross-domain; fall back to cookie for same-domain
180
- credentials: jwt ? "omit" : "include",
183
+ credentials: "omit",
181
184
  headers
182
185
  });
183
186
  if (!res.ok) {
184
- if (jwt) {
185
- clearJwt();
186
- jwtRef.current = null;
187
- }
187
+ clearJwt();
188
+ jwtRef.current = null;
188
189
  if (!cancelled) setIsLoaded(true);
189
190
  return;
190
191
  }
@@ -344,13 +345,18 @@ function SignIn({
344
345
  url.searchParams.set("__vaultix_handshake", handshakeToken);
345
346
  window.location.href = url.toString();
346
347
  }
347
- function handleGoogleSignIn() {
348
+ function oauthRedirect(provider) {
348
349
  const target = resolveAfterSignInUrl(redirectUrl);
349
350
  const pk = resolvePk();
350
351
  const params = new URLSearchParams({ redirect_url: target });
351
352
  if (pk) params.set("pk", pk);
352
- window.location.href = `${apiOrigin}/api/v1/auth/oauth/google?${params}`;
353
+ window.location.href = `${apiOrigin}/api/v1/auth/oauth/${provider}?${params}`;
353
354
  }
355
+ const handleGoogleSignIn = () => oauthRedirect("google");
356
+ const handleMetaSignIn = () => oauthRedirect("meta");
357
+ const handleLinkedInSignIn = () => oauthRedirect("linkedin");
358
+ const handleXSignIn = () => oauthRedirect("x");
359
+ const handleGitHubSignIn = () => oauthRedirect("github");
354
360
  async function handleEmailSubmit(e) {
355
361
  e.preventDefault();
356
362
  setError(null);
@@ -575,6 +581,10 @@ function SignIn({
575
581
  info && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "rounded-lg bg-blue-500/10 border border-blue-500/30 px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-xs text-blue-400", children: info }) }),
576
582
  step === "email" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "space-y-3", children: [
577
583
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GoogleButton, { onClick: handleGoogleSignIn }),
584
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GitHubButton, { onClick: handleGitHubSignIn }),
585
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MetaButton, { onClick: handleMetaSignIn }),
586
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LinkedInButton, { onClick: handleLinkedInSignIn }),
587
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(XButton, { onClick: handleXSignIn }),
578
588
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Divider, {}),
579
589
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("form", { onSubmit: handleEmailSubmit, className: "space-y-3", children: [
580
590
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -740,7 +750,11 @@ function GhostButton({ children, onClick }) {
740
750
  }
741
751
  );
742
752
  }
743
- function GoogleButton({ onClick }) {
753
+ function OAuthButton({
754
+ icon,
755
+ label,
756
+ onClick
757
+ }) {
744
758
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
745
759
  "button",
746
760
  {
@@ -754,12 +768,27 @@ function GoogleButton({ onClick }) {
754
768
  "transition-all duration-150"
755
769
  ),
756
770
  children: [
757
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GoogleIcon, {}),
758
- "Continue with Google"
771
+ icon,
772
+ label
759
773
  ]
760
774
  }
761
775
  );
762
776
  }
777
+ function GoogleButton({ onClick }) {
778
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OAuthButton, { icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GoogleIcon, {}), label: "Continue with Google", onClick });
779
+ }
780
+ function MetaButton({ onClick }) {
781
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OAuthButton, { icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MetaIcon, {}), label: "Continue with Facebook", onClick });
782
+ }
783
+ function LinkedInButton({ onClick }) {
784
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OAuthButton, { icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LinkedInIcon, {}), label: "Continue with LinkedIn", onClick });
785
+ }
786
+ function GitHubButton({ onClick }) {
787
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OAuthButton, { icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GitHubIcon, {}), label: "Continue with GitHub", onClick });
788
+ }
789
+ function XButton({ onClick }) {
790
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OAuthButton, { icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(XIcon, {}), label: "Continue with X", onClick });
791
+ }
763
792
  function Divider() {
764
793
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-3", children: [
765
794
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex-1 h-px bg-white/8" }),
@@ -821,6 +850,18 @@ function GoogleIcon() {
821
850
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })
822
851
  ] });
823
852
  }
853
+ function MetaIcon() {
854
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "#1877F2", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z" }) });
855
+ }
856
+ function LinkedInIcon() {
857
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "#0A66C2", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { 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.063 2.063 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" }) });
858
+ }
859
+ function GitHubIcon() {
860
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "white", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844a9.59 9.59 0 0 1 2.504.337c1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.02 10.02 0 0 0 22 12.017C22 6.484 17.522 2 12 2z" }) });
861
+ }
862
+ function XIcon() {
863
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "white", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.744l7.737-8.835L1.254 2.25H8.08l4.253 5.622 5.911-5.622zm-1.161 17.52h1.833L7.084 4.126H5.117z" }) });
864
+ }
824
865
 
825
866
  // src/components/SignUp.tsx
826
867
  var import_clsx2 = require("clsx");
package/dist/index.mjs CHANGED
@@ -138,21 +138,22 @@ function VaultixProvider({
138
138
  }
139
139
  jwtRef.current = jwt;
140
140
  }
141
+ if (!jwt) {
142
+ if (!cancelled) setIsLoaded(true);
143
+ return;
144
+ }
141
145
  try {
142
146
  const headers = {
147
+ "Authorization": `Bearer ${jwt}`,
143
148
  "X-Vaultix-Publishable-Key": publishableKey
144
149
  };
145
- if (jwt) headers["Authorization"] = `Bearer ${jwt}`;
146
150
  const res = await fetch(`${apiOrigin}/api/v1/me`, {
147
- // Use Bearer token for cross-domain; fall back to cookie for same-domain
148
- credentials: jwt ? "omit" : "include",
151
+ credentials: "omit",
149
152
  headers
150
153
  });
151
154
  if (!res.ok) {
152
- if (jwt) {
153
- clearJwt();
154
- jwtRef.current = null;
155
- }
155
+ clearJwt();
156
+ jwtRef.current = null;
156
157
  if (!cancelled) setIsLoaded(true);
157
158
  return;
158
159
  }
@@ -312,13 +313,18 @@ function SignIn({
312
313
  url.searchParams.set("__vaultix_handshake", handshakeToken);
313
314
  window.location.href = url.toString();
314
315
  }
315
- function handleGoogleSignIn() {
316
+ function oauthRedirect(provider) {
316
317
  const target = resolveAfterSignInUrl(redirectUrl);
317
318
  const pk = resolvePk();
318
319
  const params = new URLSearchParams({ redirect_url: target });
319
320
  if (pk) params.set("pk", pk);
320
- window.location.href = `${apiOrigin}/api/v1/auth/oauth/google?${params}`;
321
+ window.location.href = `${apiOrigin}/api/v1/auth/oauth/${provider}?${params}`;
321
322
  }
323
+ const handleGoogleSignIn = () => oauthRedirect("google");
324
+ const handleMetaSignIn = () => oauthRedirect("meta");
325
+ const handleLinkedInSignIn = () => oauthRedirect("linkedin");
326
+ const handleXSignIn = () => oauthRedirect("x");
327
+ const handleGitHubSignIn = () => oauthRedirect("github");
322
328
  async function handleEmailSubmit(e) {
323
329
  e.preventDefault();
324
330
  setError(null);
@@ -543,6 +549,10 @@ function SignIn({
543
549
  info && /* @__PURE__ */ jsx2("div", { className: "rounded-lg bg-blue-500/10 border border-blue-500/30 px-3 py-2", children: /* @__PURE__ */ jsx2("p", { className: "text-xs text-blue-400", children: info }) }),
544
550
  step === "email" && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
545
551
  /* @__PURE__ */ jsx2(GoogleButton, { onClick: handleGoogleSignIn }),
552
+ /* @__PURE__ */ jsx2(GitHubButton, { onClick: handleGitHubSignIn }),
553
+ /* @__PURE__ */ jsx2(MetaButton, { onClick: handleMetaSignIn }),
554
+ /* @__PURE__ */ jsx2(LinkedInButton, { onClick: handleLinkedInSignIn }),
555
+ /* @__PURE__ */ jsx2(XButton, { onClick: handleXSignIn }),
546
556
  /* @__PURE__ */ jsx2(Divider, {}),
547
557
  /* @__PURE__ */ jsxs("form", { onSubmit: handleEmailSubmit, className: "space-y-3", children: [
548
558
  /* @__PURE__ */ jsx2(
@@ -708,7 +718,11 @@ function GhostButton({ children, onClick }) {
708
718
  }
709
719
  );
710
720
  }
711
- function GoogleButton({ onClick }) {
721
+ function OAuthButton({
722
+ icon,
723
+ label,
724
+ onClick
725
+ }) {
712
726
  return /* @__PURE__ */ jsxs(
713
727
  "button",
714
728
  {
@@ -722,12 +736,27 @@ function GoogleButton({ onClick }) {
722
736
  "transition-all duration-150"
723
737
  ),
724
738
  children: [
725
- /* @__PURE__ */ jsx2(GoogleIcon, {}),
726
- "Continue with Google"
739
+ icon,
740
+ label
727
741
  ]
728
742
  }
729
743
  );
730
744
  }
745
+ function GoogleButton({ onClick }) {
746
+ return /* @__PURE__ */ jsx2(OAuthButton, { icon: /* @__PURE__ */ jsx2(GoogleIcon, {}), label: "Continue with Google", onClick });
747
+ }
748
+ function MetaButton({ onClick }) {
749
+ return /* @__PURE__ */ jsx2(OAuthButton, { icon: /* @__PURE__ */ jsx2(MetaIcon, {}), label: "Continue with Facebook", onClick });
750
+ }
751
+ function LinkedInButton({ onClick }) {
752
+ return /* @__PURE__ */ jsx2(OAuthButton, { icon: /* @__PURE__ */ jsx2(LinkedInIcon, {}), label: "Continue with LinkedIn", onClick });
753
+ }
754
+ function GitHubButton({ onClick }) {
755
+ return /* @__PURE__ */ jsx2(OAuthButton, { icon: /* @__PURE__ */ jsx2(GitHubIcon, {}), label: "Continue with GitHub", onClick });
756
+ }
757
+ function XButton({ onClick }) {
758
+ return /* @__PURE__ */ jsx2(OAuthButton, { icon: /* @__PURE__ */ jsx2(XIcon, {}), label: "Continue with X", onClick });
759
+ }
731
760
  function Divider() {
732
761
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
733
762
  /* @__PURE__ */ jsx2("div", { className: "flex-1 h-px bg-white/8" }),
@@ -789,6 +818,18 @@ function GoogleIcon() {
789
818
  /* @__PURE__ */ jsx2("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })
790
819
  ] });
791
820
  }
821
+ function MetaIcon() {
822
+ return /* @__PURE__ */ jsx2("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "#1877F2", children: /* @__PURE__ */ jsx2("path", { d: "M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z" }) });
823
+ }
824
+ function LinkedInIcon() {
825
+ return /* @__PURE__ */ jsx2("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "#0A66C2", children: /* @__PURE__ */ jsx2("path", { 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.063 2.063 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" }) });
826
+ }
827
+ function GitHubIcon() {
828
+ return /* @__PURE__ */ jsx2("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "white", children: /* @__PURE__ */ jsx2("path", { d: "M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844a9.59 9.59 0 0 1 2.504.337c1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.02 10.02 0 0 0 22 12.017C22 6.484 17.522 2 12 2z" }) });
829
+ }
830
+ function XIcon() {
831
+ return /* @__PURE__ */ jsx2("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "white", children: /* @__PURE__ */ jsx2("path", { d: "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.744l7.737-8.835L1.254 2.25H8.08l4.253 5.622 5.911-5.622zm-1.161 17.52h1.833L7.084 4.126H5.117z" }) });
832
+ }
792
833
 
793
834
  // src/components/SignUp.tsx
794
835
  import { clsx as clsx2 } from "clsx";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaultix.ai/react",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "description": "Vaultix-ID React SDK — drop-in auth components for any React app",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",