@vaultix.ai/react 0.2.1 → 0.2.3
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 +37 -15
- package/dist/index.mjs +37 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -263,7 +263,11 @@ function useAuth() {
|
|
|
263
263
|
const { user, session, isLoaded, isSignedIn, signOut } = useVaultixContext();
|
|
264
264
|
const getToken = (0, import_react2.useCallback)(async () => {
|
|
265
265
|
if (!isSignedIn) return null;
|
|
266
|
-
|
|
266
|
+
try {
|
|
267
|
+
return sessionStorage.getItem("vaultix_jwt");
|
|
268
|
+
} catch {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
267
271
|
}, [isSignedIn]);
|
|
268
272
|
return {
|
|
269
273
|
isLoaded,
|
|
@@ -332,17 +336,26 @@ function SignIn({
|
|
|
332
336
|
url.searchParams.set("__vaultix_handshake", handshakeToken);
|
|
333
337
|
window.location.href = url.toString();
|
|
334
338
|
}
|
|
335
|
-
function handleGoogleSignIn() {
|
|
339
|
+
async function handleGoogleSignIn() {
|
|
336
340
|
const target = resolveAfterSignInUrl(redirectUrl);
|
|
337
341
|
const params = new URLSearchParams({ redirect_url: target });
|
|
338
|
-
|
|
342
|
+
const url = `${apiOrigin}/api/v1/auth/oauth/google?${params}`;
|
|
343
|
+
try {
|
|
344
|
+
const res = await fetch(url, { method: "HEAD", redirect: "manual" });
|
|
345
|
+
if (res.status === 503 || res.status === 0) {
|
|
346
|
+
setErr("Google login is not configured. Please sign in with email.");
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
} catch {
|
|
350
|
+
}
|
|
351
|
+
window.location.href = url;
|
|
339
352
|
}
|
|
340
353
|
async function handleEmailSubmit(e) {
|
|
341
354
|
e.preventDefault();
|
|
342
355
|
setError(null);
|
|
343
356
|
setLoading(true);
|
|
344
357
|
try {
|
|
345
|
-
const res = await fetch(`${apiOrigin}/v1/auth/lookup`, {
|
|
358
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/lookup`, {
|
|
346
359
|
method: "POST",
|
|
347
360
|
credentials: "include",
|
|
348
361
|
headers: { "Content-Type": "application/json" },
|
|
@@ -365,7 +378,7 @@ function SignIn({
|
|
|
365
378
|
setError(null);
|
|
366
379
|
setLoading(true);
|
|
367
380
|
try {
|
|
368
|
-
const res = await fetch(`${apiOrigin}/v1/auth/sign-in`, {
|
|
381
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/sign-in`, {
|
|
369
382
|
method: "POST",
|
|
370
383
|
credentials: "include",
|
|
371
384
|
headers: { "Content-Type": "application/json" },
|
|
@@ -393,7 +406,7 @@ function SignIn({
|
|
|
393
406
|
setLoading(true);
|
|
394
407
|
try {
|
|
395
408
|
const optRes = await fetch(
|
|
396
|
-
`${apiOrigin}/v1/auth/passkey/authenticate/options`,
|
|
409
|
+
`${apiOrigin}/api/v1/auth/passkey/authenticate/options`,
|
|
397
410
|
{
|
|
398
411
|
method: "POST",
|
|
399
412
|
credentials: "include",
|
|
@@ -410,7 +423,7 @@ function SignIn({
|
|
|
410
423
|
publicKey: options
|
|
411
424
|
});
|
|
412
425
|
const verifyRes = await fetch(
|
|
413
|
-
`${apiOrigin}/v1/auth/passkey/authenticate/verify`,
|
|
426
|
+
`${apiOrigin}/api/v1/auth/passkey/authenticate/verify`,
|
|
414
427
|
{
|
|
415
428
|
method: "POST",
|
|
416
429
|
credentials: "include",
|
|
@@ -453,7 +466,7 @@ function SignIn({
|
|
|
453
466
|
setError(null);
|
|
454
467
|
setLoading(true);
|
|
455
468
|
try {
|
|
456
|
-
const res = await fetch(`${apiOrigin}/v1/auth/totp/verify`, {
|
|
469
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/totp/verify`, {
|
|
457
470
|
method: "POST",
|
|
458
471
|
credentials: "include",
|
|
459
472
|
headers: { "Content-Type": "application/json" },
|
|
@@ -476,7 +489,7 @@ function SignIn({
|
|
|
476
489
|
setError(null);
|
|
477
490
|
setLoading(true);
|
|
478
491
|
try {
|
|
479
|
-
await fetch(`${apiOrigin}/v1/auth/forgot-password`, {
|
|
492
|
+
await fetch(`${apiOrigin}/api/v1/auth/forgot-password`, {
|
|
480
493
|
method: "POST",
|
|
481
494
|
credentials: "include",
|
|
482
495
|
headers: { "Content-Type": "application/json" },
|
|
@@ -501,7 +514,7 @@ function SignIn({
|
|
|
501
514
|
setError(null);
|
|
502
515
|
setLoading(true);
|
|
503
516
|
try {
|
|
504
|
-
const res = await fetch(`${apiOrigin}/v1/auth/reset-password`, {
|
|
517
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/reset-password`, {
|
|
505
518
|
method: "POST",
|
|
506
519
|
credentials: "include",
|
|
507
520
|
headers: { "Content-Type": "application/json" },
|
|
@@ -854,17 +867,26 @@ function SignUp({
|
|
|
854
867
|
url.searchParams.set("__vaultix_handshake", handshakeToken);
|
|
855
868
|
window.location.href = url.toString();
|
|
856
869
|
}
|
|
857
|
-
function handleGoogleSignUp() {
|
|
870
|
+
async function handleGoogleSignUp() {
|
|
858
871
|
const target = resolveAfterSignUpUrl(redirectUrl);
|
|
859
872
|
const params = new URLSearchParams({ redirect_url: target });
|
|
860
|
-
|
|
873
|
+
const url = `${apiOrigin}/api/v1/auth/oauth/google?${params}`;
|
|
874
|
+
try {
|
|
875
|
+
const res = await fetch(url, { method: "HEAD", redirect: "manual" });
|
|
876
|
+
if (res.status === 503 || res.status === 0) {
|
|
877
|
+
setErr("Google login is not configured. Please sign in with email.");
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
} catch {
|
|
881
|
+
}
|
|
882
|
+
window.location.href = url;
|
|
861
883
|
}
|
|
862
884
|
async function handleEmailPassword(e) {
|
|
863
885
|
e.preventDefault();
|
|
864
886
|
setError(null);
|
|
865
887
|
setLoading(true);
|
|
866
888
|
try {
|
|
867
|
-
const res = await fetch(`${apiOrigin}/v1/auth/sign-up`, {
|
|
889
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/sign-up`, {
|
|
868
890
|
method: "POST",
|
|
869
891
|
credentials: "include",
|
|
870
892
|
headers: { "Content-Type": "application/json" },
|
|
@@ -888,7 +910,7 @@ function SignUp({
|
|
|
888
910
|
setError(null);
|
|
889
911
|
setLoading(true);
|
|
890
912
|
try {
|
|
891
|
-
const res = await fetch(`${apiOrigin}/v1/auth/email/verify`, {
|
|
913
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/email/verify`, {
|
|
892
914
|
method: "POST",
|
|
893
915
|
credentials: "include",
|
|
894
916
|
headers: { "Content-Type": "application/json" },
|
|
@@ -912,7 +934,7 @@ function SignUp({
|
|
|
912
934
|
async function resendCode() {
|
|
913
935
|
if (!registrationId) return;
|
|
914
936
|
try {
|
|
915
|
-
await fetch(`${apiOrigin}/v1/auth/email/resend`, {
|
|
937
|
+
await fetch(`${apiOrigin}/api/v1/auth/email/resend`, {
|
|
916
938
|
method: "POST",
|
|
917
939
|
credentials: "include",
|
|
918
940
|
headers: { "Content-Type": "application/json" },
|
package/dist/index.mjs
CHANGED
|
@@ -231,7 +231,11 @@ function useAuth() {
|
|
|
231
231
|
const { user, session, isLoaded, isSignedIn, signOut } = useVaultixContext();
|
|
232
232
|
const getToken = useCallback2(async () => {
|
|
233
233
|
if (!isSignedIn) return null;
|
|
234
|
-
|
|
234
|
+
try {
|
|
235
|
+
return sessionStorage.getItem("vaultix_jwt");
|
|
236
|
+
} catch {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
235
239
|
}, [isSignedIn]);
|
|
236
240
|
return {
|
|
237
241
|
isLoaded,
|
|
@@ -300,17 +304,26 @@ function SignIn({
|
|
|
300
304
|
url.searchParams.set("__vaultix_handshake", handshakeToken);
|
|
301
305
|
window.location.href = url.toString();
|
|
302
306
|
}
|
|
303
|
-
function handleGoogleSignIn() {
|
|
307
|
+
async function handleGoogleSignIn() {
|
|
304
308
|
const target = resolveAfterSignInUrl(redirectUrl);
|
|
305
309
|
const params = new URLSearchParams({ redirect_url: target });
|
|
306
|
-
|
|
310
|
+
const url = `${apiOrigin}/api/v1/auth/oauth/google?${params}`;
|
|
311
|
+
try {
|
|
312
|
+
const res = await fetch(url, { method: "HEAD", redirect: "manual" });
|
|
313
|
+
if (res.status === 503 || res.status === 0) {
|
|
314
|
+
setErr("Google login is not configured. Please sign in with email.");
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
} catch {
|
|
318
|
+
}
|
|
319
|
+
window.location.href = url;
|
|
307
320
|
}
|
|
308
321
|
async function handleEmailSubmit(e) {
|
|
309
322
|
e.preventDefault();
|
|
310
323
|
setError(null);
|
|
311
324
|
setLoading(true);
|
|
312
325
|
try {
|
|
313
|
-
const res = await fetch(`${apiOrigin}/v1/auth/lookup`, {
|
|
326
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/lookup`, {
|
|
314
327
|
method: "POST",
|
|
315
328
|
credentials: "include",
|
|
316
329
|
headers: { "Content-Type": "application/json" },
|
|
@@ -333,7 +346,7 @@ function SignIn({
|
|
|
333
346
|
setError(null);
|
|
334
347
|
setLoading(true);
|
|
335
348
|
try {
|
|
336
|
-
const res = await fetch(`${apiOrigin}/v1/auth/sign-in`, {
|
|
349
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/sign-in`, {
|
|
337
350
|
method: "POST",
|
|
338
351
|
credentials: "include",
|
|
339
352
|
headers: { "Content-Type": "application/json" },
|
|
@@ -361,7 +374,7 @@ function SignIn({
|
|
|
361
374
|
setLoading(true);
|
|
362
375
|
try {
|
|
363
376
|
const optRes = await fetch(
|
|
364
|
-
`${apiOrigin}/v1/auth/passkey/authenticate/options`,
|
|
377
|
+
`${apiOrigin}/api/v1/auth/passkey/authenticate/options`,
|
|
365
378
|
{
|
|
366
379
|
method: "POST",
|
|
367
380
|
credentials: "include",
|
|
@@ -378,7 +391,7 @@ function SignIn({
|
|
|
378
391
|
publicKey: options
|
|
379
392
|
});
|
|
380
393
|
const verifyRes = await fetch(
|
|
381
|
-
`${apiOrigin}/v1/auth/passkey/authenticate/verify`,
|
|
394
|
+
`${apiOrigin}/api/v1/auth/passkey/authenticate/verify`,
|
|
382
395
|
{
|
|
383
396
|
method: "POST",
|
|
384
397
|
credentials: "include",
|
|
@@ -421,7 +434,7 @@ function SignIn({
|
|
|
421
434
|
setError(null);
|
|
422
435
|
setLoading(true);
|
|
423
436
|
try {
|
|
424
|
-
const res = await fetch(`${apiOrigin}/v1/auth/totp/verify`, {
|
|
437
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/totp/verify`, {
|
|
425
438
|
method: "POST",
|
|
426
439
|
credentials: "include",
|
|
427
440
|
headers: { "Content-Type": "application/json" },
|
|
@@ -444,7 +457,7 @@ function SignIn({
|
|
|
444
457
|
setError(null);
|
|
445
458
|
setLoading(true);
|
|
446
459
|
try {
|
|
447
|
-
await fetch(`${apiOrigin}/v1/auth/forgot-password`, {
|
|
460
|
+
await fetch(`${apiOrigin}/api/v1/auth/forgot-password`, {
|
|
448
461
|
method: "POST",
|
|
449
462
|
credentials: "include",
|
|
450
463
|
headers: { "Content-Type": "application/json" },
|
|
@@ -469,7 +482,7 @@ function SignIn({
|
|
|
469
482
|
setError(null);
|
|
470
483
|
setLoading(true);
|
|
471
484
|
try {
|
|
472
|
-
const res = await fetch(`${apiOrigin}/v1/auth/reset-password`, {
|
|
485
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/reset-password`, {
|
|
473
486
|
method: "POST",
|
|
474
487
|
credentials: "include",
|
|
475
488
|
headers: { "Content-Type": "application/json" },
|
|
@@ -822,17 +835,26 @@ function SignUp({
|
|
|
822
835
|
url.searchParams.set("__vaultix_handshake", handshakeToken);
|
|
823
836
|
window.location.href = url.toString();
|
|
824
837
|
}
|
|
825
|
-
function handleGoogleSignUp() {
|
|
838
|
+
async function handleGoogleSignUp() {
|
|
826
839
|
const target = resolveAfterSignUpUrl(redirectUrl);
|
|
827
840
|
const params = new URLSearchParams({ redirect_url: target });
|
|
828
|
-
|
|
841
|
+
const url = `${apiOrigin}/api/v1/auth/oauth/google?${params}`;
|
|
842
|
+
try {
|
|
843
|
+
const res = await fetch(url, { method: "HEAD", redirect: "manual" });
|
|
844
|
+
if (res.status === 503 || res.status === 0) {
|
|
845
|
+
setErr("Google login is not configured. Please sign in with email.");
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
} catch {
|
|
849
|
+
}
|
|
850
|
+
window.location.href = url;
|
|
829
851
|
}
|
|
830
852
|
async function handleEmailPassword(e) {
|
|
831
853
|
e.preventDefault();
|
|
832
854
|
setError(null);
|
|
833
855
|
setLoading(true);
|
|
834
856
|
try {
|
|
835
|
-
const res = await fetch(`${apiOrigin}/v1/auth/sign-up`, {
|
|
857
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/sign-up`, {
|
|
836
858
|
method: "POST",
|
|
837
859
|
credentials: "include",
|
|
838
860
|
headers: { "Content-Type": "application/json" },
|
|
@@ -856,7 +878,7 @@ function SignUp({
|
|
|
856
878
|
setError(null);
|
|
857
879
|
setLoading(true);
|
|
858
880
|
try {
|
|
859
|
-
const res = await fetch(`${apiOrigin}/v1/auth/email/verify`, {
|
|
881
|
+
const res = await fetch(`${apiOrigin}/api/v1/auth/email/verify`, {
|
|
860
882
|
method: "POST",
|
|
861
883
|
credentials: "include",
|
|
862
884
|
headers: { "Content-Type": "application/json" },
|
|
@@ -880,7 +902,7 @@ function SignUp({
|
|
|
880
902
|
async function resendCode() {
|
|
881
903
|
if (!registrationId) return;
|
|
882
904
|
try {
|
|
883
|
-
await fetch(`${apiOrigin}/v1/auth/email/resend`, {
|
|
905
|
+
await fetch(`${apiOrigin}/api/v1/auth/email/resend`, {
|
|
884
906
|
method: "POST",
|
|
885
907
|
credentials: "include",
|
|
886
908
|
headers: { "Content-Type": "application/json" },
|