@vaultix.ai/react 0.2.3 → 0.2.4
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 +19 -23
- package/dist/index.mjs +19 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -236,6 +236,7 @@ function VaultixProvider({
|
|
|
236
236
|
"data-vaultix-after-sign-in": afterSignInUrl ?? "",
|
|
237
237
|
"data-vaultix-after-sign-up": afterSignUpUrl ?? "",
|
|
238
238
|
"data-vaultix-api": apiOrigin,
|
|
239
|
+
"data-vaultix-pk": publishableKey,
|
|
239
240
|
style: { display: "contents" },
|
|
240
241
|
children
|
|
241
242
|
}
|
|
@@ -295,6 +296,13 @@ function resolveApiOrigin2(prop) {
|
|
|
295
296
|
}
|
|
296
297
|
return "";
|
|
297
298
|
}
|
|
299
|
+
function resolvePk() {
|
|
300
|
+
if (typeof document !== "undefined") {
|
|
301
|
+
const el = document.querySelector("[data-vaultix-pk]");
|
|
302
|
+
if (el) return el.getAttribute("data-vaultix-pk") ?? "";
|
|
303
|
+
}
|
|
304
|
+
return "";
|
|
305
|
+
}
|
|
298
306
|
function resolveAfterSignInUrl(redirectUrlProp) {
|
|
299
307
|
if (redirectUrlProp) return redirectUrlProp;
|
|
300
308
|
if (typeof document !== "undefined") {
|
|
@@ -336,19 +344,12 @@ function SignIn({
|
|
|
336
344
|
url.searchParams.set("__vaultix_handshake", handshakeToken);
|
|
337
345
|
window.location.href = url.toString();
|
|
338
346
|
}
|
|
339
|
-
|
|
347
|
+
function handleGoogleSignIn() {
|
|
340
348
|
const target = resolveAfterSignInUrl(redirectUrl);
|
|
349
|
+
const pk = resolvePk();
|
|
341
350
|
const params = new URLSearchParams({ redirect_url: target });
|
|
342
|
-
|
|
343
|
-
|
|
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;
|
|
351
|
+
if (pk) params.set("pk", pk);
|
|
352
|
+
window.location.href = `${apiOrigin}/api/v1/auth/oauth/google?${params}`;
|
|
352
353
|
}
|
|
353
354
|
async function handleEmailSubmit(e) {
|
|
354
355
|
e.preventDefault();
|
|
@@ -378,10 +379,14 @@ function SignIn({
|
|
|
378
379
|
setError(null);
|
|
379
380
|
setLoading(true);
|
|
380
381
|
try {
|
|
382
|
+
const pk = resolvePk();
|
|
381
383
|
const res = await fetch(`${apiOrigin}/api/v1/auth/sign-in`, {
|
|
382
384
|
method: "POST",
|
|
383
385
|
credentials: "include",
|
|
384
|
-
headers: {
|
|
386
|
+
headers: {
|
|
387
|
+
"Content-Type": "application/json",
|
|
388
|
+
...pk ? { "x-vaultix-pk": pk } : {}
|
|
389
|
+
},
|
|
385
390
|
body: JSON.stringify({ email, password })
|
|
386
391
|
});
|
|
387
392
|
const data = await res.json();
|
|
@@ -867,19 +872,10 @@ function SignUp({
|
|
|
867
872
|
url.searchParams.set("__vaultix_handshake", handshakeToken);
|
|
868
873
|
window.location.href = url.toString();
|
|
869
874
|
}
|
|
870
|
-
|
|
875
|
+
function handleGoogleSignUp() {
|
|
871
876
|
const target = resolveAfterSignUpUrl(redirectUrl);
|
|
872
877
|
const params = new URLSearchParams({ redirect_url: target });
|
|
873
|
-
|
|
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;
|
|
878
|
+
window.location.href = `${apiOrigin}/api/v1/auth/oauth/google?${params}`;
|
|
883
879
|
}
|
|
884
880
|
async function handleEmailPassword(e) {
|
|
885
881
|
e.preventDefault();
|
package/dist/index.mjs
CHANGED
|
@@ -204,6 +204,7 @@ function VaultixProvider({
|
|
|
204
204
|
"data-vaultix-after-sign-in": afterSignInUrl ?? "",
|
|
205
205
|
"data-vaultix-after-sign-up": afterSignUpUrl ?? "",
|
|
206
206
|
"data-vaultix-api": apiOrigin,
|
|
207
|
+
"data-vaultix-pk": publishableKey,
|
|
207
208
|
style: { display: "contents" },
|
|
208
209
|
children
|
|
209
210
|
}
|
|
@@ -263,6 +264,13 @@ function resolveApiOrigin2(prop) {
|
|
|
263
264
|
}
|
|
264
265
|
return "";
|
|
265
266
|
}
|
|
267
|
+
function resolvePk() {
|
|
268
|
+
if (typeof document !== "undefined") {
|
|
269
|
+
const el = document.querySelector("[data-vaultix-pk]");
|
|
270
|
+
if (el) return el.getAttribute("data-vaultix-pk") ?? "";
|
|
271
|
+
}
|
|
272
|
+
return "";
|
|
273
|
+
}
|
|
266
274
|
function resolveAfterSignInUrl(redirectUrlProp) {
|
|
267
275
|
if (redirectUrlProp) return redirectUrlProp;
|
|
268
276
|
if (typeof document !== "undefined") {
|
|
@@ -304,19 +312,12 @@ function SignIn({
|
|
|
304
312
|
url.searchParams.set("__vaultix_handshake", handshakeToken);
|
|
305
313
|
window.location.href = url.toString();
|
|
306
314
|
}
|
|
307
|
-
|
|
315
|
+
function handleGoogleSignIn() {
|
|
308
316
|
const target = resolveAfterSignInUrl(redirectUrl);
|
|
317
|
+
const pk = resolvePk();
|
|
309
318
|
const params = new URLSearchParams({ redirect_url: target });
|
|
310
|
-
|
|
311
|
-
|
|
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;
|
|
319
|
+
if (pk) params.set("pk", pk);
|
|
320
|
+
window.location.href = `${apiOrigin}/api/v1/auth/oauth/google?${params}`;
|
|
320
321
|
}
|
|
321
322
|
async function handleEmailSubmit(e) {
|
|
322
323
|
e.preventDefault();
|
|
@@ -346,10 +347,14 @@ function SignIn({
|
|
|
346
347
|
setError(null);
|
|
347
348
|
setLoading(true);
|
|
348
349
|
try {
|
|
350
|
+
const pk = resolvePk();
|
|
349
351
|
const res = await fetch(`${apiOrigin}/api/v1/auth/sign-in`, {
|
|
350
352
|
method: "POST",
|
|
351
353
|
credentials: "include",
|
|
352
|
-
headers: {
|
|
354
|
+
headers: {
|
|
355
|
+
"Content-Type": "application/json",
|
|
356
|
+
...pk ? { "x-vaultix-pk": pk } : {}
|
|
357
|
+
},
|
|
353
358
|
body: JSON.stringify({ email, password })
|
|
354
359
|
});
|
|
355
360
|
const data = await res.json();
|
|
@@ -835,19 +840,10 @@ function SignUp({
|
|
|
835
840
|
url.searchParams.set("__vaultix_handshake", handshakeToken);
|
|
836
841
|
window.location.href = url.toString();
|
|
837
842
|
}
|
|
838
|
-
|
|
843
|
+
function handleGoogleSignUp() {
|
|
839
844
|
const target = resolveAfterSignUpUrl(redirectUrl);
|
|
840
845
|
const params = new URLSearchParams({ redirect_url: target });
|
|
841
|
-
|
|
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;
|
|
846
|
+
window.location.href = `${apiOrigin}/api/v1/auth/oauth/google?${params}`;
|
|
851
847
|
}
|
|
852
848
|
async function handleEmailPassword(e) {
|
|
853
849
|
e.preventDefault();
|