@thurinlabs/identity-kit 1.3.5 → 1.3.6

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.
@@ -30411,6 +30411,9 @@ ${prettyStateOverride(stateOverride)}`;
30411
30411
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IdentityKitContext.Provider, { value: config, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WagmiDetector, { rpcUrl, network, children }) });
30412
30412
  }
30413
30413
 
30414
+ // src/components/ThurinCard/ThurinCard.tsx
30415
+ var import_react9 = __toESM(require_react(), 1);
30416
+
30414
30417
  // src/core/identityError.ts
30415
30418
  function needsRpcProbe(s2) {
30416
30419
  return s2.ensEmpty || s2.ensFailed || s2.claimsFailed;
@@ -31785,7 +31788,8 @@ ${prettyStateOverride(stateOverride)}`;
31785
31788
  }
31786
31789
 
31787
31790
  // src/core/avatar.ts
31788
- var IPFS_GATEWAY = "https://ipfs.io/ipfs/";
31791
+ var IPFS_GATEWAYS = ["https://ipfs.filebase.io/ipfs/", "https://gateway.pinata.cloud/ipfs/"];
31792
+ var IPFS_GATEWAY = IPFS_GATEWAYS[0];
31789
31793
  var ARWEAVE_GATEWAY = "https://arweave.net/";
31790
31794
  function avatarUrl(uri) {
31791
31795
  if (typeof uri !== "string") return null;
@@ -31800,9 +31804,14 @@ ${prettyStateOverride(stateOverride)}`;
31800
31804
  if (m2) return IPFS_GATEWAY + m2[1];
31801
31805
  return null;
31802
31806
  }
31807
+ function avatarFallbacks(url) {
31808
+ if (!url || !url.startsWith(IPFS_GATEWAYS[0])) return [];
31809
+ const path = url.slice(IPFS_GATEWAYS[0].length);
31810
+ return IPFS_GATEWAYS.slice(1).map((g2) => g2 + path);
31811
+ }
31803
31812
  function parseNftAvatar(raw) {
31804
- const m2 = typeof raw === "string" && raw.trim().match(/^eip155:(\d+)\/(erc721|erc1155):(0x[0-9a-fA-F]{40})\/(\d+)$/);
31805
- return m2 ? { chainId: Number(m2[1]), standard: m2[2], contract: m2[3], tokenId: BigInt(m2[4]) } : null;
31813
+ const m2 = typeof raw === "string" && raw.trim().match(/^eip155:(\d+)\/(erc721|erc1155):(0x[0-9a-fA-F]{40})\/(\d+)$/i);
31814
+ return m2 ? { chainId: Number(m2[1]), standard: m2[2].toLowerCase(), contract: m2[3], tokenId: BigInt(m2[4]) } : null;
31806
31815
  }
31807
31816
  var NFT_AVATAR_ABI = [
31808
31817
  { type: "function", name: "tokenURI", stateMutability: "view", inputs: [{ type: "uint256" }], outputs: [{ type: "string" }] },
@@ -31816,9 +31825,17 @@ ${prettyStateOverride(stateOverride)}`;
31816
31825
  else {
31817
31826
  const url = uri.startsWith("data:") ? null : avatarUrl(uri);
31818
31827
  if (!url) return null;
31819
- const res = await fetchFn(url);
31820
- if (!res.ok) return null;
31821
- meta = await res.json();
31828
+ for (const candidate of [url, ...avatarFallbacks(url)]) {
31829
+ try {
31830
+ const res = await fetchFn(candidate);
31831
+ if (res.ok) {
31832
+ meta = await res.json();
31833
+ break;
31834
+ }
31835
+ } catch {
31836
+ }
31837
+ }
31838
+ if (!meta) return null;
31822
31839
  }
31823
31840
  return avatarUrl(meta?.image ?? meta?.image_url);
31824
31841
  }
@@ -31936,6 +31953,14 @@ ${prettyStateOverride(stateOverride)}`;
31936
31953
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M50 65 L50 53", fill: "none", stroke: "#c9a227", strokeWidth: "4", strokeLinecap: "round" })
31937
31954
  ] });
31938
31955
  }
31956
+ function Avatar({ src, alt }) {
31957
+ const [tries, setTries] = (0, import_react9.useState)([]);
31958
+ (0, import_react9.useEffect)(() => {
31959
+ setTries(src ? [src, ...avatarFallbacks(src)] : []);
31960
+ }, [src]);
31961
+ if (!tries.length) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ThurinLogo, {});
31962
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { className: "thurin-card-avatar", src: tries[0], alt, onError: () => setTries((t2) => t2.slice(1)) });
31963
+ }
31939
31964
  function ThurinCard({ ens, address, theme = "thurin" }) {
31940
31965
  const input = ens || address;
31941
31966
  const identity = useThurinIdentity(input);
@@ -31962,14 +31987,7 @@ ${prettyStateOverride(stateOverride)}`;
31962
31987
  const hasVerifiedPgp = identity.claims.some((c2) => c2.verification?.verified && !c2.revoked);
31963
31988
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "thurin-card", "data-thurin-theme": theme, children: [
31964
31989
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("a", { className: "thurin-card-header", href: profileUrl || void 0, target: "_blank", rel: "noopener noreferrer", children: [
31965
- identity.ensAvatar ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
31966
- "img",
31967
- {
31968
- className: "thurin-card-avatar",
31969
- src: identity.ensAvatar,
31970
- alt: identity.ensName || ""
31971
- }
31972
- ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ThurinLogo, {}),
31990
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Avatar, { src: identity.ensAvatar, alt: identity.ensName || "" }),
31973
31991
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
31974
31992
  identity.ensName && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "thurin-card-name", children: identity.ensName }),
31975
31993
  displayAddress && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "thurin-card-address", children: displayAddress })