@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.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/query/fetchers/index.cjs +23 -15
- package/dist/query/fetchers/index.cjs.map +1 -1
- package/dist/query/fetchers/index.js +23 -15
- package/dist/query/fetchers/index.js.map +1 -1
- package/dist/query/hooks/index.cjs +23 -15
- package/dist/query/hooks/index.cjs.map +1 -1
- package/dist/query/hooks/index.js +23 -15
- package/dist/query/hooks/index.js.map +1 -1
- package/dist/query/index.cjs +23 -15
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.js +23 -15
- package/dist/query/index.js.map +1 -1
- package/package.json +1 -1
package/dist/query/index.cjs
CHANGED
|
@@ -18,6 +18,14 @@ var ApiError = class extends Error {
|
|
|
18
18
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
19
19
|
var MAX_RATE_LIMIT_RETRIES = 3;
|
|
20
20
|
var RATE_LIMIT_RETRY_CAP_SECONDS = 3;
|
|
21
|
+
function encodeIdentifier(value) {
|
|
22
|
+
let decoded = value;
|
|
23
|
+
try {
|
|
24
|
+
decoded = decodeURIComponent(value);
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
return encodeURIComponent(decoded);
|
|
28
|
+
}
|
|
21
29
|
async function apiFetch(config, path, options = {}) {
|
|
22
30
|
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
23
31
|
const url = `${config.baseUrl}${path}`;
|
|
@@ -119,14 +127,14 @@ function useSifaConfig() {
|
|
|
119
127
|
|
|
120
128
|
// src/query/fetchers/profile.ts
|
|
121
129
|
function fetchProfile(config, handleOrDid, options = {}) {
|
|
122
|
-
const path = `/api/profile/${
|
|
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/${
|
|
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 },
|
|
@@ -302,7 +310,7 @@ function deleteProfileLocation(config, rkey, options = {}) {
|
|
|
302
310
|
|
|
303
311
|
// src/query/fetchers/external-accounts.ts
|
|
304
312
|
async function fetchExternalAccounts(config, handleOrDid, options = {}) {
|
|
305
|
-
const path = `/api/profile/${
|
|
313
|
+
const path = `/api/profile/${encodeIdentifier(handleOrDid)}/external-accounts`;
|
|
306
314
|
try {
|
|
307
315
|
const data = await apiFetch(config, path, {
|
|
308
316
|
credentials: "include",
|
|
@@ -562,7 +570,7 @@ async function searchSkills(config, query, limit = 10, options = {}) {
|
|
|
562
570
|
// src/query/fetchers/discovery.ts
|
|
563
571
|
async function fetchSimilarProfiles(config, did, opts = {}) {
|
|
564
572
|
const limit = opts.limit ?? 5;
|
|
565
|
-
const path = `/api/discover/similar/${
|
|
573
|
+
const path = `/api/discover/similar/${encodeIdentifier(did)}?limit=${limit}`;
|
|
566
574
|
try {
|
|
567
575
|
const data = await apiFetch(config, path, {
|
|
568
576
|
next: { revalidate: 300 },
|
|
@@ -640,7 +648,7 @@ function followUser(config, handle, opts = {}) {
|
|
|
640
648
|
const { note, ...rest } = opts;
|
|
641
649
|
return apiWrite(
|
|
642
650
|
config,
|
|
643
|
-
`/api/follow/${
|
|
651
|
+
`/api/follow/${encodeIdentifier(handle)}`,
|
|
644
652
|
"POST",
|
|
645
653
|
{
|
|
646
654
|
body: note !== void 0 ? { note } : void 0,
|
|
@@ -649,7 +657,7 @@ function followUser(config, handle, opts = {}) {
|
|
|
649
657
|
);
|
|
650
658
|
}
|
|
651
659
|
function unfollowUser(config, handle, opts = {}) {
|
|
652
|
-
return apiWrite(config, `/api/follow/${
|
|
660
|
+
return apiWrite(config, `/api/follow/${encodeIdentifier(handle)}`, "DELETE", opts);
|
|
653
661
|
}
|
|
654
662
|
function buildListPath(prefix, opts) {
|
|
655
663
|
const params = new URLSearchParams();
|
|
@@ -664,7 +672,7 @@ async function getFollowers(config, handle, opts = {}) {
|
|
|
664
672
|
try {
|
|
665
673
|
const res = await apiFetch(
|
|
666
674
|
config,
|
|
667
|
-
buildListPath(`/api/profile/${
|
|
675
|
+
buildListPath(`/api/profile/${encodeIdentifier(handle)}/followers`, opts),
|
|
668
676
|
{ credentials: "include", cache: "no-store", ...opts, headers }
|
|
669
677
|
);
|
|
670
678
|
return { follows: res.follows, cursor: res.cursor ?? null };
|
|
@@ -678,7 +686,7 @@ async function getFollowing(config, handle, opts = {}) {
|
|
|
678
686
|
try {
|
|
679
687
|
const res = await apiFetch(
|
|
680
688
|
config,
|
|
681
|
-
buildListPath(`/api/profile/${
|
|
689
|
+
buildListPath(`/api/profile/${encodeIdentifier(handle)}/following`, opts),
|
|
682
690
|
{ credentials: "include", cache: "no-store", ...opts, headers }
|
|
683
691
|
);
|
|
684
692
|
return { follows: res.follows, cursor: res.cursor ?? null };
|
|
@@ -733,7 +741,7 @@ async function fetchFollowProfilePage(config, path, opts) {
|
|
|
733
741
|
async function getMutuals(config, handleOrDid, opts = {}) {
|
|
734
742
|
return fetchFollowProfilePage(
|
|
735
743
|
config,
|
|
736
|
-
buildListPath2(`/api/profile/${
|
|
744
|
+
buildListPath2(`/api/profile/${encodeIdentifier(handleOrDid)}/mutuals`, opts),
|
|
737
745
|
opts
|
|
738
746
|
);
|
|
739
747
|
}
|
|
@@ -766,7 +774,7 @@ function addFeatureAllowlist(config, flag, did, opts = {}) {
|
|
|
766
774
|
function removeFeatureAllowlist(config, flag, did, opts = {}) {
|
|
767
775
|
return apiWrite(
|
|
768
776
|
config,
|
|
769
|
-
`/api/admin/feature-allowlists/${encodeURIComponent(flag)}/${
|
|
777
|
+
`/api/admin/feature-allowlists/${encodeURIComponent(flag)}/${encodeIdentifier(did)}`,
|
|
770
778
|
"DELETE",
|
|
771
779
|
opts
|
|
772
780
|
);
|
|
@@ -774,7 +782,7 @@ function removeFeatureAllowlist(config, flag, did, opts = {}) {
|
|
|
774
782
|
|
|
775
783
|
// src/query/fetchers/activity.ts
|
|
776
784
|
async function fetchHeatmapData(config, handleOrDid, days, options = {}) {
|
|
777
|
-
const path = `/api/activity/${
|
|
785
|
+
const path = `/api/activity/${encodeIdentifier(handleOrDid)}/heatmap?days=${days}`;
|
|
778
786
|
try {
|
|
779
787
|
return await apiFetch(config, path, {
|
|
780
788
|
next: { revalidate: 900, tags: [`heatmap-${handleOrDid}`] },
|
|
@@ -790,7 +798,7 @@ async function fetchActivityTeaser(config, handleOrDid, options = {}) {
|
|
|
790
798
|
try {
|
|
791
799
|
return await apiFetch(
|
|
792
800
|
config,
|
|
793
|
-
`/api/activity/${
|
|
801
|
+
`/api/activity/${encodeIdentifier(handleOrDid)}/teaser`,
|
|
794
802
|
{
|
|
795
803
|
credentials: "include",
|
|
796
804
|
timeoutMs: 8e3,
|
|
@@ -814,7 +822,7 @@ async function fetchActivityFeed(config, handleOrDid, options = {}) {
|
|
|
814
822
|
try {
|
|
815
823
|
return await apiFetch(
|
|
816
824
|
config,
|
|
817
|
-
`/api/activity/${
|
|
825
|
+
`/api/activity/${encodeIdentifier(handleOrDid)}${qs ? `?${qs}` : ""}`,
|
|
818
826
|
{
|
|
819
827
|
credentials: "include",
|
|
820
828
|
cache: "no-store",
|
|
@@ -829,7 +837,7 @@ async function fetchActivityFeed(config, handleOrDid, options = {}) {
|
|
|
829
837
|
|
|
830
838
|
// src/query/fetchers/endorsement.ts
|
|
831
839
|
async function fetchEndorsementCount(config, did, options = {}) {
|
|
832
|
-
const path = `/api/endorsement/${
|
|
840
|
+
const path = `/api/endorsement/${encodeIdentifier(did)}`;
|
|
833
841
|
try {
|
|
834
842
|
const data = await apiFetch(config, path, {
|
|
835
843
|
cache: "no-store",
|
|
@@ -853,7 +861,7 @@ async function fetchNetworkStreamCount(config, did, options = {}) {
|
|
|
853
861
|
try {
|
|
854
862
|
const data = await apiFetch(
|
|
855
863
|
config,
|
|
856
|
-
`/api/stream/network?did=${
|
|
864
|
+
`/api/stream/network?did=${encodeIdentifier(did)}`,
|
|
857
865
|
{
|
|
858
866
|
cache: "no-store",
|
|
859
867
|
timeoutMs: 5e3,
|