@singi-labs/sifa-sdk 0.10.14 → 0.10.15

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