@singi-labs/sifa-sdk 0.10.14 → 0.10.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.
@@ -33,6 +33,14 @@ var ApiError = class extends Error {
33
33
  var DEFAULT_TIMEOUT_MS = 1e4;
34
34
  var MAX_RATE_LIMIT_RETRIES = 3;
35
35
  var RATE_LIMIT_RETRY_CAP_SECONDS = 3;
36
+ function encodeIdentifier(value) {
37
+ let decoded = value;
38
+ try {
39
+ decoded = decodeURIComponent(value);
40
+ } catch {
41
+ }
42
+ return encodeURIComponent(decoded);
43
+ }
36
44
  async function apiFetch(config, path, options = {}) {
37
45
  const fetchFn = config.fetch ?? globalThis.fetch;
38
46
  const url = `${config.baseUrl}${path}`;
@@ -121,14 +129,14 @@ function apiWriteCreate(config, path, body, options = {}) {
121
129
 
122
130
  // src/query/fetchers/profile.ts
123
131
  function fetchProfile(config, handleOrDid, options = {}) {
124
- const path = `/api/profile/${encodeURIComponent(handleOrDid)}`;
132
+ const path = `/api/profile/${encodeIdentifier(handleOrDid)}`;
125
133
  return apiFetchOrNull(config, path, {
126
134
  retryOn429: true,
127
135
  ...options
128
136
  });
129
137
  }
130
138
  async function fetchAtFundLink(config, did, options = {}) {
131
- const path = `/api/profiles/${encodeURIComponent(did)}/at-fund-link`;
139
+ const path = `/api/profiles/${encodeIdentifier(did)}/at-fund-link`;
132
140
  try {
133
141
  const data = await apiFetch(config, path, {
134
142
  next: { revalidate: 3600 },
@@ -785,7 +793,7 @@ function useDeleteProfileLocation(ownerHandleOrDid, options) {
785
793
 
786
794
  // src/query/fetchers/external-accounts.ts
787
795
  async function fetchExternalAccounts(config, handleOrDid, options = {}) {
788
- const path = `/api/profile/${encodeURIComponent(handleOrDid)}/external-accounts`;
796
+ const path = `/api/profile/${encodeIdentifier(handleOrDid)}/external-accounts`;
789
797
  try {
790
798
  const data = await apiFetch(config, path, {
791
799
  credentials: "include",
@@ -1351,7 +1359,7 @@ function useSearchFilters(options) {
1351
1359
  // src/query/fetchers/discovery.ts
1352
1360
  async function fetchSimilarProfiles(config, did, opts = {}) {
1353
1361
  const limit = opts.limit ?? 5;
1354
- const path = `/api/discover/similar/${encodeURIComponent(did)}?limit=${limit}`;
1362
+ const path = `/api/discover/similar/${encodeIdentifier(did)}?limit=${limit}`;
1355
1363
  try {
1356
1364
  const data = await apiFetch(config, path, {
1357
1365
  next: { revalidate: 300 },
@@ -1465,7 +1473,7 @@ function followUser(config, handle, opts = {}) {
1465
1473
  const { note, ...rest } = opts;
1466
1474
  return apiWrite(
1467
1475
  config,
1468
- `/api/follow/${encodeURIComponent(handle)}`,
1476
+ `/api/follow/${encodeIdentifier(handle)}`,
1469
1477
  "POST",
1470
1478
  {
1471
1479
  body: note !== void 0 ? { note } : void 0,
@@ -1474,7 +1482,7 @@ function followUser(config, handle, opts = {}) {
1474
1482
  );
1475
1483
  }
1476
1484
  function unfollowUser(config, handle, opts = {}) {
1477
- return apiWrite(config, `/api/follow/${encodeURIComponent(handle)}`, "DELETE", opts);
1485
+ return apiWrite(config, `/api/follow/${encodeIdentifier(handle)}`, "DELETE", opts);
1478
1486
  }
1479
1487
  function buildListPath(prefix, opts) {
1480
1488
  const params = new URLSearchParams();
@@ -1489,7 +1497,7 @@ async function getFollowers(config, handle, opts = {}) {
1489
1497
  try {
1490
1498
  const res = await apiFetch(
1491
1499
  config,
1492
- buildListPath(`/api/profile/${encodeURIComponent(handle)}/followers`, opts),
1500
+ buildListPath(`/api/profile/${encodeIdentifier(handle)}/followers`, opts),
1493
1501
  { credentials: "include", cache: "no-store", ...opts, headers }
1494
1502
  );
1495
1503
  return { follows: res.follows, cursor: res.cursor ?? null };
@@ -1503,7 +1511,7 @@ async function getFollowing(config, handle, opts = {}) {
1503
1511
  try {
1504
1512
  const res = await apiFetch(
1505
1513
  config,
1506
- buildListPath(`/api/profile/${encodeURIComponent(handle)}/following`, opts),
1514
+ buildListPath(`/api/profile/${encodeIdentifier(handle)}/following`, opts),
1507
1515
  { credentials: "include", cache: "no-store", ...opts, headers }
1508
1516
  );
1509
1517
  return { follows: res.follows, cursor: res.cursor ?? null };
@@ -1640,7 +1648,7 @@ async function fetchFollowProfilePage(config, path, opts) {
1640
1648
  async function getMutuals(config, handleOrDid, opts = {}) {
1641
1649
  return fetchFollowProfilePage(
1642
1650
  config,
1643
- buildListPath2(`/api/profile/${encodeURIComponent(handleOrDid)}/mutuals`, opts),
1651
+ buildListPath2(`/api/profile/${encodeIdentifier(handleOrDid)}/mutuals`, opts),
1644
1652
  opts
1645
1653
  );
1646
1654
  }
@@ -1696,7 +1704,7 @@ function addFeatureAllowlist(config, flag, did, opts = {}) {
1696
1704
  function removeFeatureAllowlist(config, flag, did, opts = {}) {
1697
1705
  return apiWrite(
1698
1706
  config,
1699
- `/api/admin/feature-allowlists/${encodeURIComponent(flag)}/${encodeURIComponent(did)}`,
1707
+ `/api/admin/feature-allowlists/${encodeURIComponent(flag)}/${encodeIdentifier(did)}`,
1700
1708
  "DELETE",
1701
1709
  opts
1702
1710
  );
@@ -1788,7 +1796,7 @@ function useRemoveFeatureAllowlist(flag, options) {
1788
1796
 
1789
1797
  // src/query/fetchers/activity.ts
1790
1798
  async function fetchHeatmapData(config, handleOrDid, days, options = {}) {
1791
- const path = `/api/activity/${encodeURIComponent(handleOrDid)}/heatmap?days=${days}`;
1799
+ const path = `/api/activity/${encodeIdentifier(handleOrDid)}/heatmap?days=${days}`;
1792
1800
  try {
1793
1801
  return await apiFetch(config, path, {
1794
1802
  next: { revalidate: 900, tags: [`heatmap-${handleOrDid}`] },
@@ -1804,7 +1812,7 @@ async function fetchActivityTeaser(config, handleOrDid, options = {}) {
1804
1812
  try {
1805
1813
  return await apiFetch(
1806
1814
  config,
1807
- `/api/activity/${encodeURIComponent(handleOrDid)}/teaser`,
1815
+ `/api/activity/${encodeIdentifier(handleOrDid)}/teaser`,
1808
1816
  {
1809
1817
  credentials: "include",
1810
1818
  timeoutMs: 8e3,
@@ -1828,7 +1836,7 @@ async function fetchActivityFeed(config, handleOrDid, options = {}) {
1828
1836
  try {
1829
1837
  return await apiFetch(
1830
1838
  config,
1831
- `/api/activity/${encodeURIComponent(handleOrDid)}${qs ? `?${qs}` : ""}`,
1839
+ `/api/activity/${encodeIdentifier(handleOrDid)}${qs ? `?${qs}` : ""}`,
1832
1840
  {
1833
1841
  credentials: "include",
1834
1842
  cache: "no-store",
@@ -1872,7 +1880,7 @@ function useActivityFeed(handleOrDid, opts = {}, options) {
1872
1880
 
1873
1881
  // src/query/fetchers/endorsement.ts
1874
1882
  async function fetchEndorsementCount(config, did, options = {}) {
1875
- const path = `/api/endorsement/${encodeURIComponent(did)}`;
1883
+ const path = `/api/endorsement/${encodeIdentifier(did)}`;
1876
1884
  try {
1877
1885
  const data = await apiFetch(config, path, {
1878
1886
  cache: "no-store",
@@ -1907,7 +1915,7 @@ async function fetchNetworkStreamCount(config, did, options = {}) {
1907
1915
  try {
1908
1916
  const data = await apiFetch(
1909
1917
  config,
1910
- `/api/stream/network?did=${encodeURIComponent(did)}`,
1918
+ `/api/stream/network?did=${encodeIdentifier(did)}`,
1911
1919
  {
1912
1920
  cache: "no-store",
1913
1921
  timeoutMs: 5e3,