@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.js CHANGED
@@ -4533,6 +4533,34 @@ var injectModalStyles = () => {
4533
4533
  `;
4534
4534
  document.head.appendChild(styleElement);
4535
4535
  };
4536
+
4537
+ // src/react/components/utils/getAnonymousUserId.ts
4538
+ var ANONYMOUS_USER_ID_KEY = "ttf_auth_anonymous_user_id";
4539
+ function generateUUID() {
4540
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
4541
+ return crypto.randomUUID();
4542
+ }
4543
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
4544
+ const r = Math.random() * 16 | 0;
4545
+ const v = c === "x" ? r : r & 3 | 8;
4546
+ return v.toString(16);
4547
+ });
4548
+ }
4549
+ function getAnonymousUserId() {
4550
+ if (typeof window === "undefined" || typeof localStorage === "undefined") {
4551
+ return null;
4552
+ }
4553
+ try {
4554
+ let anonymousId = localStorage.getItem(ANONYMOUS_USER_ID_KEY);
4555
+ if (!anonymousId) {
4556
+ anonymousId = generateUUID();
4557
+ localStorage.setItem(ANONYMOUS_USER_ID_KEY, anonymousId);
4558
+ }
4559
+ return anonymousId;
4560
+ } catch {
4561
+ return generateUUID();
4562
+ }
4563
+ }
4536
4564
  var AvatarUploader = ({
4537
4565
  onUploadComplete,
4538
4566
  onError,
@@ -4553,6 +4581,10 @@ var AvatarUploader = ({
4553
4581
  if (user?.id) {
4554
4582
  return `users/${user.id}/`;
4555
4583
  }
4584
+ const anonymousId = getAnonymousUserId();
4585
+ if (anonymousId) {
4586
+ return `anonymous/${anonymousId}/`;
4587
+ }
4556
4588
  return upfilesConfig.folderPath || "/";
4557
4589
  }, [user?.id, upfilesConfig.folderPath]);
4558
4590
  const handleSelect = async (image) => {
@@ -4932,6 +4964,10 @@ var AvatarManager = ({
4932
4964
  if (user?.id) {
4933
4965
  return `users/${user.id}/`;
4934
4966
  }
4967
+ const anonymousId = getAnonymousUserId();
4968
+ if (anonymousId) {
4969
+ return `anonymous/${anonymousId}/`;
4970
+ }
4935
4971
  return upfilesConfig.folderPath || "/";
4936
4972
  }, [user?.id, upfilesConfig.folderPath]);
4937
4973
  const handleSelect = async (image) => {