@singi-labs/sifa-sdk 0.10.13 → 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.
@@ -12,6 +12,14 @@ var ApiError = class extends Error {
12
12
  var DEFAULT_TIMEOUT_MS = 1e4;
13
13
  var MAX_RATE_LIMIT_RETRIES = 3;
14
14
  var RATE_LIMIT_RETRY_CAP_SECONDS = 3;
15
+ function encodeIdentifier(value) {
16
+ let decoded = value;
17
+ try {
18
+ decoded = decodeURIComponent(value);
19
+ } catch {
20
+ }
21
+ return encodeURIComponent(decoded);
22
+ }
15
23
  async function apiFetch(config, path, options = {}) {
16
24
  const fetchFn = config.fetch ?? globalThis.fetch;
17
25
  const url = `${config.baseUrl}${path}`;
@@ -100,14 +108,14 @@ function apiWriteCreate(config, path, body, options = {}) {
100
108
 
101
109
  // src/query/fetchers/profile.ts
102
110
  function fetchProfile(config, handleOrDid, options = {}) {
103
- const path = `/api/profile/${encodeURIComponent(handleOrDid)}`;
111
+ const path = `/api/profile/${encodeIdentifier(handleOrDid)}`;
104
112
  return apiFetchOrNull(config, path, {
105
113
  retryOn429: true,
106
114
  ...options
107
115
  });
108
116
  }
109
117
  async function fetchAtFundLink(config, did, options = {}) {
110
- const path = `/api/profiles/${encodeURIComponent(did)}/at-fund-link`;
118
+ const path = `/api/profiles/${encodeIdentifier(did)}/at-fund-link`;
111
119
  try {
112
120
  const data = await apiFetch(config, path, {
113
121
  next: { revalidate: 3600 },
@@ -283,7 +291,7 @@ function deleteProfileLocation(config, rkey, options = {}) {
283
291
 
284
292
  // src/query/fetchers/external-accounts.ts
285
293
  async function fetchExternalAccounts(config, handleOrDid, options = {}) {
286
- const path = `/api/profile/${encodeURIComponent(handleOrDid)}/external-accounts`;
294
+ const path = `/api/profile/${encodeIdentifier(handleOrDid)}/external-accounts`;
287
295
  try {
288
296
  const data = await apiFetch(config, path, {
289
297
  credentials: "include",
@@ -543,7 +551,7 @@ async function searchSkills(config, query, limit = 10, options = {}) {
543
551
  // src/query/fetchers/discovery.ts
544
552
  async function fetchSimilarProfiles(config, did, opts = {}) {
545
553
  const limit = opts.limit ?? 5;
546
- const path = `/api/discover/similar/${encodeURIComponent(did)}?limit=${limit}`;
554
+ const path = `/api/discover/similar/${encodeIdentifier(did)}?limit=${limit}`;
547
555
  try {
548
556
  const data = await apiFetch(config, path, {
549
557
  next: { revalidate: 300 },
@@ -621,7 +629,7 @@ function followUser(config, handle, opts = {}) {
621
629
  const { note, ...rest } = opts;
622
630
  return apiWrite(
623
631
  config,
624
- `/api/follow/${encodeURIComponent(handle)}`,
632
+ `/api/follow/${encodeIdentifier(handle)}`,
625
633
  "POST",
626
634
  {
627
635
  body: note !== void 0 ? { note } : void 0,
@@ -630,7 +638,7 @@ function followUser(config, handle, opts = {}) {
630
638
  );
631
639
  }
632
640
  function unfollowUser(config, handle, opts = {}) {
633
- return apiWrite(config, `/api/follow/${encodeURIComponent(handle)}`, "DELETE", opts);
641
+ return apiWrite(config, `/api/follow/${encodeIdentifier(handle)}`, "DELETE", opts);
634
642
  }
635
643
  function buildListPath(prefix, opts) {
636
644
  const params = new URLSearchParams();
@@ -645,7 +653,7 @@ async function getFollowers(config, handle, opts = {}) {
645
653
  try {
646
654
  const res = await apiFetch(
647
655
  config,
648
- buildListPath(`/api/profile/${encodeURIComponent(handle)}/followers`, opts),
656
+ buildListPath(`/api/profile/${encodeIdentifier(handle)}/followers`, opts),
649
657
  { credentials: "include", cache: "no-store", ...opts, headers }
650
658
  );
651
659
  return { follows: res.follows, cursor: res.cursor ?? null };
@@ -659,7 +667,7 @@ async function getFollowing(config, handle, opts = {}) {
659
667
  try {
660
668
  const res = await apiFetch(
661
669
  config,
662
- buildListPath(`/api/profile/${encodeURIComponent(handle)}/following`, opts),
670
+ buildListPath(`/api/profile/${encodeIdentifier(handle)}/following`, opts),
663
671
  { credentials: "include", cache: "no-store", ...opts, headers }
664
672
  );
665
673
  return { follows: res.follows, cursor: res.cursor ?? null };
@@ -714,7 +722,7 @@ async function fetchFollowProfilePage(config, path, opts) {
714
722
  async function getMutuals(config, handleOrDid, opts = {}) {
715
723
  return fetchFollowProfilePage(
716
724
  config,
717
- buildListPath2(`/api/profile/${encodeURIComponent(handleOrDid)}/mutuals`, opts),
725
+ buildListPath2(`/api/profile/${encodeIdentifier(handleOrDid)}/mutuals`, opts),
718
726
  opts
719
727
  );
720
728
  }
@@ -747,7 +755,7 @@ function addFeatureAllowlist(config, flag, did, opts = {}) {
747
755
  function removeFeatureAllowlist(config, flag, did, opts = {}) {
748
756
  return apiWrite(
749
757
  config,
750
- `/api/admin/feature-allowlists/${encodeURIComponent(flag)}/${encodeURIComponent(did)}`,
758
+ `/api/admin/feature-allowlists/${encodeURIComponent(flag)}/${encodeIdentifier(did)}`,
751
759
  "DELETE",
752
760
  opts
753
761
  );
@@ -755,7 +763,7 @@ function removeFeatureAllowlist(config, flag, did, opts = {}) {
755
763
 
756
764
  // src/query/fetchers/activity.ts
757
765
  async function fetchHeatmapData(config, handleOrDid, days, options = {}) {
758
- const path = `/api/activity/${encodeURIComponent(handleOrDid)}/heatmap?days=${days}`;
766
+ const path = `/api/activity/${encodeIdentifier(handleOrDid)}/heatmap?days=${days}`;
759
767
  try {
760
768
  return await apiFetch(config, path, {
761
769
  next: { revalidate: 900, tags: [`heatmap-${handleOrDid}`] },
@@ -771,7 +779,7 @@ async function fetchActivityTeaser(config, handleOrDid, options = {}) {
771
779
  try {
772
780
  return await apiFetch(
773
781
  config,
774
- `/api/activity/${encodeURIComponent(handleOrDid)}/teaser`,
782
+ `/api/activity/${encodeIdentifier(handleOrDid)}/teaser`,
775
783
  {
776
784
  credentials: "include",
777
785
  timeoutMs: 8e3,
@@ -795,7 +803,7 @@ async function fetchActivityFeed(config, handleOrDid, options = {}) {
795
803
  try {
796
804
  return await apiFetch(
797
805
  config,
798
- `/api/activity/${encodeURIComponent(handleOrDid)}${qs ? `?${qs}` : ""}`,
806
+ `/api/activity/${encodeIdentifier(handleOrDid)}${qs ? `?${qs}` : ""}`,
799
807
  {
800
808
  credentials: "include",
801
809
  cache: "no-store",
@@ -810,7 +818,7 @@ async function fetchActivityFeed(config, handleOrDid, options = {}) {
810
818
 
811
819
  // src/query/fetchers/endorsement.ts
812
820
  async function fetchEndorsementCount(config, did, options = {}) {
813
- const path = `/api/endorsement/${encodeURIComponent(did)}`;
821
+ const path = `/api/endorsement/${encodeIdentifier(did)}`;
814
822
  try {
815
823
  const data = await apiFetch(config, path, {
816
824
  cache: "no-store",
@@ -834,7 +842,7 @@ async function fetchNetworkStreamCount(config, did, options = {}) {
834
842
  try {
835
843
  const data = await apiFetch(
836
844
  config,
837
- `/api/stream/network?did=${encodeURIComponent(did)}`,
845
+ `/api/stream/network?did=${encodeIdentifier(did)}`,
838
846
  {
839
847
  cache: "no-store",
840
848
  timeoutMs: 5e3,