@thetechfossil/auth2 1.2.15 → 1.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/dist/index.components.d.mts +8 -0
- package/dist/index.components.d.ts +8 -0
- package/dist/index.components.js +171 -139
- package/dist/index.components.js.map +1 -1
- package/dist/index.components.mjs +57 -25
- package/dist/index.components.mjs.map +1 -1
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +214 -176
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -29
- package/dist/index.mjs.map +1 -1
- package/dist/index.next.d.mts +8 -0
- package/dist/index.next.d.ts +8 -0
- package/dist/index.next.js +233 -195
- package/dist/index.next.js.map +1 -1
- package/dist/index.next.mjs +67 -29
- package/dist/index.next.mjs.map +1 -1
- package/dist/index.next.server.js +5 -0
- package/dist/index.next.server.js.map +1 -1
- package/dist/index.next.server.mjs +5 -0
- package/dist/index.next.server.mjs.map +1 -1
- package/dist/index.node.js +5 -0
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +5 -0
- package/dist/index.node.mjs.map +1 -1
- package/next/index.js +0 -0
- package/next/index.mjs +0 -0
- package/next/package.json +0 -0
- package/next/server/package.json +0 -0
- package/next/server.js +0 -0
- package/next/server.mjs +0 -0
- package/package.json +102 -101
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { UpfilesClient, ImageManager } from '@thetechfossil/upfiles';
|
|
4
4
|
export { ConnectProjectDialog, ImageManager, ProjectFilesWidget, UpfilesClient, Uploader } from '@thetechfossil/upfiles';
|
|
5
|
-
import
|
|
5
|
+
import React, { createContext, forwardRef, useContext, useState, useCallback, useEffect, useRef, useMemo } from 'react';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
8
|
var __defProp = Object.defineProperty;
|
|
@@ -68,6 +68,11 @@ var HttpClient = class {
|
|
|
68
68
|
return Promise.reject(refreshError);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
if (error.response && error.response.data && error.response.data.message) {
|
|
72
|
+
const customError = new Error(error.response.data.message);
|
|
73
|
+
customError.response = error.response;
|
|
74
|
+
return Promise.reject(customError);
|
|
75
|
+
}
|
|
71
76
|
return Promise.reject(error);
|
|
72
77
|
}
|
|
73
78
|
);
|
|
@@ -504,7 +509,7 @@ var AuthService = class {
|
|
|
504
509
|
return response;
|
|
505
510
|
}
|
|
506
511
|
};
|
|
507
|
-
var ThemeContext = createContext({ theme: "light", mounted: false });
|
|
512
|
+
var ThemeContext = React.createContext({ theme: "light", mounted: false });
|
|
508
513
|
function AuthThemeProvider({ children }) {
|
|
509
514
|
const [theme, setTheme] = useState("light");
|
|
510
515
|
const [mounted, setMounted] = useState(false);
|
|
@@ -571,11 +576,17 @@ var AuthProvider = ({ children, config }) => {
|
|
|
571
576
|
const authenticated = authService.isAuthenticated();
|
|
572
577
|
if (authenticated) {
|
|
573
578
|
try {
|
|
574
|
-
const
|
|
575
|
-
setUser(
|
|
579
|
+
const freshUser = await authService.getProfile();
|
|
580
|
+
setUser(freshUser);
|
|
576
581
|
} catch (error) {
|
|
577
|
-
console.error("Failed to
|
|
578
|
-
|
|
582
|
+
console.error("Failed to fetch fresh user profile, falling back to token:", error);
|
|
583
|
+
try {
|
|
584
|
+
const currentUser = authService.getCurrentUser();
|
|
585
|
+
setUser(currentUser);
|
|
586
|
+
} catch (fallbackError) {
|
|
587
|
+
console.error("Failed to get current user from token:", fallbackError);
|
|
588
|
+
setUser(null);
|
|
589
|
+
}
|
|
579
590
|
}
|
|
580
591
|
} else {
|
|
581
592
|
setUser(null);
|
|
@@ -1034,7 +1045,7 @@ try {
|
|
|
1034
1045
|
} catch (error) {
|
|
1035
1046
|
console.warn("react-phone-number-input not available, using fallback");
|
|
1036
1047
|
}
|
|
1037
|
-
var CustomPhoneInput =
|
|
1048
|
+
var CustomPhoneInput = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(
|
|
1038
1049
|
"input",
|
|
1039
1050
|
{
|
|
1040
1051
|
...props,
|
|
@@ -3513,7 +3524,19 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3513
3524
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
3514
3525
|
},
|
|
3515
3526
|
children: [
|
|
3516
|
-
/* @__PURE__ */ jsx(
|
|
3527
|
+
user.avatar ? /* @__PURE__ */ jsx(
|
|
3528
|
+
"img",
|
|
3529
|
+
{
|
|
3530
|
+
src: user.avatar,
|
|
3531
|
+
alt: user.name,
|
|
3532
|
+
style: {
|
|
3533
|
+
width: "36px",
|
|
3534
|
+
height: "36px",
|
|
3535
|
+
borderRadius: "50%",
|
|
3536
|
+
objectFit: "cover"
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3539
|
+
) : /* @__PURE__ */ jsx("div", { style: {
|
|
3517
3540
|
width: "36px",
|
|
3518
3541
|
height: "36px",
|
|
3519
3542
|
borderRadius: "50%",
|
|
@@ -3550,7 +3573,19 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3550
3573
|
alignItems: "center",
|
|
3551
3574
|
gap: "12px"
|
|
3552
3575
|
}, children: [
|
|
3553
|
-
/* @__PURE__ */ jsx(
|
|
3576
|
+
user.avatar ? /* @__PURE__ */ jsx(
|
|
3577
|
+
"img",
|
|
3578
|
+
{
|
|
3579
|
+
src: user.avatar,
|
|
3580
|
+
alt: user.name,
|
|
3581
|
+
style: {
|
|
3582
|
+
width: "48px",
|
|
3583
|
+
height: "48px",
|
|
3584
|
+
borderRadius: "50%",
|
|
3585
|
+
objectFit: "cover"
|
|
3586
|
+
}
|
|
3587
|
+
}
|
|
3588
|
+
) : /* @__PURE__ */ jsx("div", { style: {
|
|
3554
3589
|
width: "48px",
|
|
3555
3590
|
height: "48px",
|
|
3556
3591
|
borderRadius: "50%",
|
|
@@ -4446,26 +4481,16 @@ var AvatarUploader = ({
|
|
|
4446
4481
|
const handleSelect = async (image) => {
|
|
4447
4482
|
setUploading(true);
|
|
4448
4483
|
try {
|
|
4449
|
-
const
|
|
4450
|
-
const response = await
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
} : {}
|
|
4454
|
-
});
|
|
4455
|
-
if (!response.ok) {
|
|
4456
|
-
throw new Error("Failed to fetch image");
|
|
4457
|
-
}
|
|
4458
|
-
const blob = await response.blob();
|
|
4459
|
-
const file = new File([blob], image.originalName, { type: image.contentType });
|
|
4460
|
-
const result = await uploadAndUpdateAvatar(file);
|
|
4461
|
-
if (result.success && result.user?.avatar) {
|
|
4462
|
-
onUploadComplete?.(result.user.avatar);
|
|
4484
|
+
const { updateProfile } = useAuth();
|
|
4485
|
+
const response = await updateProfile({ avatar: image.url });
|
|
4486
|
+
if (response.success && response.user?.avatar) {
|
|
4487
|
+
onUploadComplete?.(response.user.avatar);
|
|
4463
4488
|
setOpen(false);
|
|
4464
4489
|
} else {
|
|
4465
|
-
throw new Error(
|
|
4490
|
+
throw new Error(response.message || "Failed to update avatar");
|
|
4466
4491
|
}
|
|
4467
4492
|
} catch (error) {
|
|
4468
|
-
const err = error instanceof Error ? error : new Error("
|
|
4493
|
+
const err = error instanceof Error ? error : new Error("Failed to update avatar");
|
|
4469
4494
|
onError?.(err);
|
|
4470
4495
|
} finally {
|
|
4471
4496
|
setUploading(false);
|
|
@@ -4812,8 +4837,14 @@ var AvatarManager = ({
|
|
|
4812
4837
|
gridClassName,
|
|
4813
4838
|
maxFileSize = 5 * 1024 * 1024,
|
|
4814
4839
|
// 5MB default
|
|
4840
|
+
maxFiles = 10,
|
|
4815
4841
|
mode = "full",
|
|
4816
4842
|
showDelete = false,
|
|
4843
|
+
autoRecordToDb = true,
|
|
4844
|
+
fetchThumbnails = true,
|
|
4845
|
+
projectId,
|
|
4846
|
+
deleteUrl,
|
|
4847
|
+
onDelete,
|
|
4817
4848
|
upfilesConfig
|
|
4818
4849
|
}) => {
|
|
4819
4850
|
const { updateProfile } = useAuth();
|
|
@@ -4845,18 +4876,25 @@ var AvatarManager = ({
|
|
|
4845
4876
|
apiKey: upfilesConfig.apiKey,
|
|
4846
4877
|
apiKeyHeader: upfilesConfig.apiKeyHeader || "authorization",
|
|
4847
4878
|
presignUrl: upfilesConfig.presignUrl,
|
|
4848
|
-
presignPath: upfilesConfig.presignPath
|
|
4879
|
+
presignPath: upfilesConfig.presignPath,
|
|
4880
|
+
headers: upfilesConfig.headers,
|
|
4881
|
+
withCredentials: upfilesConfig.withCredentials
|
|
4849
4882
|
},
|
|
4850
|
-
|
|
4883
|
+
projectId,
|
|
4884
|
+
folderPath: upfilesConfig.folderPath || "/",
|
|
4851
4885
|
title,
|
|
4852
4886
|
description,
|
|
4853
4887
|
className,
|
|
4854
4888
|
gridClassName,
|
|
4855
4889
|
onSelect: handleSelect,
|
|
4890
|
+
onDelete,
|
|
4891
|
+
deleteUrl,
|
|
4892
|
+
autoRecordToDb,
|
|
4893
|
+
fetchThumbnails,
|
|
4856
4894
|
maxFileSize,
|
|
4895
|
+
maxFiles,
|
|
4857
4896
|
mode,
|
|
4858
|
-
showDelete
|
|
4859
|
-
fetchThumbnails: true
|
|
4897
|
+
showDelete
|
|
4860
4898
|
}
|
|
4861
4899
|
);
|
|
4862
4900
|
};
|