@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.
package/dist/index.mjs CHANGED
@@ -4527,6 +4527,34 @@ var injectModalStyles = () => {
4527
4527
  `;
4528
4528
  document.head.appendChild(styleElement);
4529
4529
  };
4530
+
4531
+ // src/react/components/utils/getAnonymousUserId.ts
4532
+ var ANONYMOUS_USER_ID_KEY = "ttf_auth_anonymous_user_id";
4533
+ function generateUUID() {
4534
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
4535
+ return crypto.randomUUID();
4536
+ }
4537
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
4538
+ const r = Math.random() * 16 | 0;
4539
+ const v = c === "x" ? r : r & 3 | 8;
4540
+ return v.toString(16);
4541
+ });
4542
+ }
4543
+ function getAnonymousUserId() {
4544
+ if (typeof window === "undefined" || typeof localStorage === "undefined") {
4545
+ return null;
4546
+ }
4547
+ try {
4548
+ let anonymousId = localStorage.getItem(ANONYMOUS_USER_ID_KEY);
4549
+ if (!anonymousId) {
4550
+ anonymousId = generateUUID();
4551
+ localStorage.setItem(ANONYMOUS_USER_ID_KEY, anonymousId);
4552
+ }
4553
+ return anonymousId;
4554
+ } catch {
4555
+ return generateUUID();
4556
+ }
4557
+ }
4530
4558
  var AvatarUploader = ({
4531
4559
  onUploadComplete,
4532
4560
  onError,
@@ -4547,6 +4575,10 @@ var AvatarUploader = ({
4547
4575
  if (user?.id) {
4548
4576
  return `users/${user.id}/`;
4549
4577
  }
4578
+ const anonymousId = getAnonymousUserId();
4579
+ if (anonymousId) {
4580
+ return `anonymous/${anonymousId}/`;
4581
+ }
4550
4582
  return upfilesConfig.folderPath || "/";
4551
4583
  }, [user?.id, upfilesConfig.folderPath]);
4552
4584
  const handleSelect = async (image) => {
@@ -4926,6 +4958,10 @@ var AvatarManager = ({
4926
4958
  if (user?.id) {
4927
4959
  return `users/${user.id}/`;
4928
4960
  }
4961
+ const anonymousId = getAnonymousUserId();
4962
+ if (anonymousId) {
4963
+ return `anonymous/${anonymousId}/`;
4964
+ }
4929
4965
  return upfilesConfig.folderPath || "/";
4930
4966
  }, [user?.id, upfilesConfig.folderPath]);
4931
4967
  const handleSelect = async (image) => {