@thetechfossil/auth2 1.2.17 → 1.2.18

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.
@@ -4199,6 +4199,34 @@ var injectModalStyles = () => {
4199
4199
  `;
4200
4200
  document.head.appendChild(styleElement);
4201
4201
  };
4202
+
4203
+ // src/react/components/utils/getAnonymousUserId.ts
4204
+ var ANONYMOUS_USER_ID_KEY = "ttf_auth_anonymous_user_id";
4205
+ function generateUUID() {
4206
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
4207
+ return crypto.randomUUID();
4208
+ }
4209
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
4210
+ const r = Math.random() * 16 | 0;
4211
+ const v = c === "x" ? r : r & 3 | 8;
4212
+ return v.toString(16);
4213
+ });
4214
+ }
4215
+ function getAnonymousUserId() {
4216
+ if (typeof window === "undefined" || typeof localStorage === "undefined") {
4217
+ return null;
4218
+ }
4219
+ try {
4220
+ let anonymousId = localStorage.getItem(ANONYMOUS_USER_ID_KEY);
4221
+ if (!anonymousId) {
4222
+ anonymousId = generateUUID();
4223
+ localStorage.setItem(ANONYMOUS_USER_ID_KEY, anonymousId);
4224
+ }
4225
+ return anonymousId;
4226
+ } catch {
4227
+ return generateUUID();
4228
+ }
4229
+ }
4202
4230
  var AvatarUploader = ({
4203
4231
  onUploadComplete,
4204
4232
  onError,
@@ -4219,6 +4247,10 @@ var AvatarUploader = ({
4219
4247
  if (user?.id) {
4220
4248
  return `users/${user.id}/`;
4221
4249
  }
4250
+ const anonymousId = getAnonymousUserId();
4251
+ if (anonymousId) {
4252
+ return `anonymous/${anonymousId}/`;
4253
+ }
4222
4254
  return upfilesConfig.folderPath || "/";
4223
4255
  }, [user?.id, upfilesConfig.folderPath]);
4224
4256
  const handleSelect = async (image) => {
@@ -4598,6 +4630,10 @@ var AvatarManager = ({
4598
4630
  if (user?.id) {
4599
4631
  return `users/${user.id}/`;
4600
4632
  }
4633
+ const anonymousId = getAnonymousUserId();
4634
+ if (anonymousId) {
4635
+ return `anonymous/${anonymousId}/`;
4636
+ }
4601
4637
  return upfilesConfig.folderPath || "/";
4602
4638
  }, [user?.id, upfilesConfig.folderPath]);
4603
4639
  const handleSelect = async (image) => {