@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
2
|
+
import React, { createContext, forwardRef, useContext, useState, useMemo, useEffect, useRef, useCallback } from 'react';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { ImageManager, UpfilesClient } from '@thetechfossil/upfiles';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -62,6 +62,11 @@ var HttpClient = class {
|
|
|
62
62
|
return Promise.reject(refreshError);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
if (error.response && error.response.data && error.response.data.message) {
|
|
66
|
+
const customError = new Error(error.response.data.message);
|
|
67
|
+
customError.response = error.response;
|
|
68
|
+
return Promise.reject(customError);
|
|
69
|
+
}
|
|
65
70
|
return Promise.reject(error);
|
|
66
71
|
}
|
|
67
72
|
);
|
|
@@ -643,7 +648,7 @@ var useAuth = (config) => {
|
|
|
643
648
|
uploadAndUpdateAvatar
|
|
644
649
|
};
|
|
645
650
|
};
|
|
646
|
-
var ThemeContext = createContext({ theme: "light", mounted: false });
|
|
651
|
+
var ThemeContext = React.createContext({ theme: "light", mounted: false });
|
|
647
652
|
function useAuthTheme() {
|
|
648
653
|
return useContext(ThemeContext);
|
|
649
654
|
}
|
|
@@ -697,7 +702,7 @@ try {
|
|
|
697
702
|
} catch (error) {
|
|
698
703
|
console.warn("react-phone-number-input not available, using fallback");
|
|
699
704
|
}
|
|
700
|
-
var CustomPhoneInput =
|
|
705
|
+
var CustomPhoneInput = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(
|
|
701
706
|
"input",
|
|
702
707
|
{
|
|
703
708
|
...props,
|
|
@@ -3184,7 +3189,19 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3184
3189
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
3185
3190
|
},
|
|
3186
3191
|
children: [
|
|
3187
|
-
/* @__PURE__ */ jsx(
|
|
3192
|
+
user.avatar ? /* @__PURE__ */ jsx(
|
|
3193
|
+
"img",
|
|
3194
|
+
{
|
|
3195
|
+
src: user.avatar,
|
|
3196
|
+
alt: user.name,
|
|
3197
|
+
style: {
|
|
3198
|
+
width: "36px",
|
|
3199
|
+
height: "36px",
|
|
3200
|
+
borderRadius: "50%",
|
|
3201
|
+
objectFit: "cover"
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
) : /* @__PURE__ */ jsx("div", { style: {
|
|
3188
3205
|
width: "36px",
|
|
3189
3206
|
height: "36px",
|
|
3190
3207
|
borderRadius: "50%",
|
|
@@ -3221,7 +3238,19 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
3221
3238
|
alignItems: "center",
|
|
3222
3239
|
gap: "12px"
|
|
3223
3240
|
}, children: [
|
|
3224
|
-
/* @__PURE__ */ jsx(
|
|
3241
|
+
user.avatar ? /* @__PURE__ */ jsx(
|
|
3242
|
+
"img",
|
|
3243
|
+
{
|
|
3244
|
+
src: user.avatar,
|
|
3245
|
+
alt: user.name,
|
|
3246
|
+
style: {
|
|
3247
|
+
width: "48px",
|
|
3248
|
+
height: "48px",
|
|
3249
|
+
borderRadius: "50%",
|
|
3250
|
+
objectFit: "cover"
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
) : /* @__PURE__ */ jsx("div", { style: {
|
|
3225
3254
|
width: "48px",
|
|
3226
3255
|
height: "48px",
|
|
3227
3256
|
borderRadius: "50%",
|
|
@@ -4117,26 +4146,16 @@ var AvatarUploader = ({
|
|
|
4117
4146
|
const handleSelect = async (image) => {
|
|
4118
4147
|
setUploading(true);
|
|
4119
4148
|
try {
|
|
4120
|
-
const
|
|
4121
|
-
const response = await
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
} : {}
|
|
4125
|
-
});
|
|
4126
|
-
if (!response.ok) {
|
|
4127
|
-
throw new Error("Failed to fetch image");
|
|
4128
|
-
}
|
|
4129
|
-
const blob = await response.blob();
|
|
4130
|
-
const file = new File([blob], image.originalName, { type: image.contentType });
|
|
4131
|
-
const result = await uploadAndUpdateAvatar(file);
|
|
4132
|
-
if (result.success && result.user?.avatar) {
|
|
4133
|
-
onUploadComplete?.(result.user.avatar);
|
|
4149
|
+
const { updateProfile } = useAuth2();
|
|
4150
|
+
const response = await updateProfile({ avatar: image.url });
|
|
4151
|
+
if (response.success && response.user?.avatar) {
|
|
4152
|
+
onUploadComplete?.(response.user.avatar);
|
|
4134
4153
|
setOpen(false);
|
|
4135
4154
|
} else {
|
|
4136
|
-
throw new Error(
|
|
4155
|
+
throw new Error(response.message || "Failed to update avatar");
|
|
4137
4156
|
}
|
|
4138
4157
|
} catch (error) {
|
|
4139
|
-
const err = error instanceof Error ? error : new Error("
|
|
4158
|
+
const err = error instanceof Error ? error : new Error("Failed to update avatar");
|
|
4140
4159
|
onError?.(err);
|
|
4141
4160
|
} finally {
|
|
4142
4161
|
setUploading(false);
|
|
@@ -4483,8 +4502,14 @@ var AvatarManager = ({
|
|
|
4483
4502
|
gridClassName,
|
|
4484
4503
|
maxFileSize = 5 * 1024 * 1024,
|
|
4485
4504
|
// 5MB default
|
|
4505
|
+
maxFiles = 10,
|
|
4486
4506
|
mode = "full",
|
|
4487
4507
|
showDelete = false,
|
|
4508
|
+
autoRecordToDb = true,
|
|
4509
|
+
fetchThumbnails = true,
|
|
4510
|
+
projectId,
|
|
4511
|
+
deleteUrl,
|
|
4512
|
+
onDelete,
|
|
4488
4513
|
upfilesConfig
|
|
4489
4514
|
}) => {
|
|
4490
4515
|
const { updateProfile } = useAuth2();
|
|
@@ -4516,18 +4541,25 @@ var AvatarManager = ({
|
|
|
4516
4541
|
apiKey: upfilesConfig.apiKey,
|
|
4517
4542
|
apiKeyHeader: upfilesConfig.apiKeyHeader || "authorization",
|
|
4518
4543
|
presignUrl: upfilesConfig.presignUrl,
|
|
4519
|
-
presignPath: upfilesConfig.presignPath
|
|
4544
|
+
presignPath: upfilesConfig.presignPath,
|
|
4545
|
+
headers: upfilesConfig.headers,
|
|
4546
|
+
withCredentials: upfilesConfig.withCredentials
|
|
4520
4547
|
},
|
|
4521
|
-
|
|
4548
|
+
projectId,
|
|
4549
|
+
folderPath: upfilesConfig.folderPath || "/",
|
|
4522
4550
|
title,
|
|
4523
4551
|
description,
|
|
4524
4552
|
className,
|
|
4525
4553
|
gridClassName,
|
|
4526
4554
|
onSelect: handleSelect,
|
|
4555
|
+
onDelete,
|
|
4556
|
+
deleteUrl,
|
|
4557
|
+
autoRecordToDb,
|
|
4558
|
+
fetchThumbnails,
|
|
4527
4559
|
maxFileSize,
|
|
4560
|
+
maxFiles,
|
|
4528
4561
|
mode,
|
|
4529
|
-
showDelete
|
|
4530
|
-
fetchThumbnails: true
|
|
4562
|
+
showDelete
|
|
4531
4563
|
}
|
|
4532
4564
|
);
|
|
4533
4565
|
};
|