@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.
- package/dist/index.cjs +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +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/dist/schemas/index.cjs +1 -1
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +1 -1
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.js +1 -1
- package/dist/schemas/index.js.map +1 -1
- package/package.json +1 -1
package/dist/query/index.js
CHANGED
|
@@ -16,6 +16,14 @@ var ApiError = class extends Error {
|
|
|
16
16
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
17
17
|
var MAX_RATE_LIMIT_RETRIES = 3;
|
|
18
18
|
var RATE_LIMIT_RETRY_CAP_SECONDS = 3;
|
|
19
|
+
function encodeIdentifier(value) {
|
|
20
|
+
let decoded = value;
|
|
21
|
+
try {
|
|
22
|
+
decoded = decodeURIComponent(value);
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
return encodeURIComponent(decoded);
|
|
26
|
+
}
|
|
19
27
|
async function apiFetch(config, path, options = {}) {
|
|
20
28
|
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
21
29
|
const url = `${config.baseUrl}${path}`;
|
|
@@ -117,14 +125,14 @@ function useSifaConfig() {
|
|
|
117
125
|
|
|
118
126
|
// src/query/fetchers/profile.ts
|
|
119
127
|
function fetchProfile(config, handleOrDid, options = {}) {
|
|
120
|
-
const path = `/api/profile/${
|
|
128
|
+
const path = `/api/profile/${encodeIdentifier(handleOrDid)}`;
|
|
121
129
|
return apiFetchOrNull(config, path, {
|
|
122
130
|
retryOn429: true,
|
|
123
131
|
...options
|
|
124
132
|
});
|
|
125
133
|
}
|
|
126
134
|
async function fetchAtFundLink(config, did, options = {}) {
|
|
127
|
-
const path = `/api/profiles/${
|
|
135
|
+
const path = `/api/profiles/${encodeIdentifier(did)}/at-fund-link`;
|
|
128
136
|
try {
|
|
129
137
|
const data = await apiFetch(config, path, {
|
|
130
138
|
next: { revalidate: 3600 },
|
|
@@ -300,7 +308,7 @@ function deleteProfileLocation(config, rkey, options = {}) {
|
|
|
300
308
|
|
|
301
309
|
// src/query/fetchers/external-accounts.ts
|
|
302
310
|
async function fetchExternalAccounts(config, handleOrDid, options = {}) {
|
|
303
|
-
const path = `/api/profile/${
|
|
311
|
+
const path = `/api/profile/${encodeIdentifier(handleOrDid)}/external-accounts`;
|
|
304
312
|
try {
|
|
305
313
|
const data = await apiFetch(config, path, {
|
|
306
314
|
credentials: "include",
|
|
@@ -560,7 +568,7 @@ async function searchSkills(config, query, limit = 10, options = {}) {
|
|
|
560
568
|
// src/query/fetchers/discovery.ts
|
|
561
569
|
async function fetchSimilarProfiles(config, did, opts = {}) {
|
|
562
570
|
const limit = opts.limit ?? 5;
|
|
563
|
-
const path = `/api/discover/similar/${
|
|
571
|
+
const path = `/api/discover/similar/${encodeIdentifier(did)}?limit=${limit}`;
|
|
564
572
|
try {
|
|
565
573
|
const data = await apiFetch(config, path, {
|
|
566
574
|
next: { revalidate: 300 },
|
|
@@ -638,7 +646,7 @@ function followUser(config, handle, opts = {}) {
|
|
|
638
646
|
const { note, ...rest } = opts;
|
|
639
647
|
return apiWrite(
|
|
640
648
|
config,
|
|
641
|
-
`/api/follow/${
|
|
649
|
+
`/api/follow/${encodeIdentifier(handle)}`,
|
|
642
650
|
"POST",
|
|
643
651
|
{
|
|
644
652
|
body: note !== void 0 ? { note } : void 0,
|
|
@@ -647,7 +655,7 @@ function followUser(config, handle, opts = {}) {
|
|
|
647
655
|
);
|
|
648
656
|
}
|
|
649
657
|
function unfollowUser(config, handle, opts = {}) {
|
|
650
|
-
return apiWrite(config, `/api/follow/${
|
|
658
|
+
return apiWrite(config, `/api/follow/${encodeIdentifier(handle)}`, "DELETE", opts);
|
|
651
659
|
}
|
|
652
660
|
function buildListPath(prefix, opts) {
|
|
653
661
|
const params = new URLSearchParams();
|
|
@@ -662,7 +670,7 @@ async function getFollowers(config, handle, opts = {}) {
|
|
|
662
670
|
try {
|
|
663
671
|
const res = await apiFetch(
|
|
664
672
|
config,
|
|
665
|
-
buildListPath(`/api/profile/${
|
|
673
|
+
buildListPath(`/api/profile/${encodeIdentifier(handle)}/followers`, opts),
|
|
666
674
|
{ credentials: "include", cache: "no-store", ...opts, headers }
|
|
667
675
|
);
|
|
668
676
|
return { follows: res.follows, cursor: res.cursor ?? null };
|
|
@@ -676,7 +684,7 @@ async function getFollowing(config, handle, opts = {}) {
|
|
|
676
684
|
try {
|
|
677
685
|
const res = await apiFetch(
|
|
678
686
|
config,
|
|
679
|
-
buildListPath(`/api/profile/${
|
|
687
|
+
buildListPath(`/api/profile/${encodeIdentifier(handle)}/following`, opts),
|
|
680
688
|
{ credentials: "include", cache: "no-store", ...opts, headers }
|
|
681
689
|
);
|
|
682
690
|
return { follows: res.follows, cursor: res.cursor ?? null };
|
|
@@ -731,7 +739,7 @@ async function fetchFollowProfilePage(config, path, opts) {
|
|
|
731
739
|
async function getMutuals(config, handleOrDid, opts = {}) {
|
|
732
740
|
return fetchFollowProfilePage(
|
|
733
741
|
config,
|
|
734
|
-
buildListPath2(`/api/profile/${
|
|
742
|
+
buildListPath2(`/api/profile/${encodeIdentifier(handleOrDid)}/mutuals`, opts),
|
|
735
743
|
opts
|
|
736
744
|
);
|
|
737
745
|
}
|
|
@@ -764,7 +772,7 @@ function addFeatureAllowlist(config, flag, did, opts = {}) {
|
|
|
764
772
|
function removeFeatureAllowlist(config, flag, did, opts = {}) {
|
|
765
773
|
return apiWrite(
|
|
766
774
|
config,
|
|
767
|
-
`/api/admin/feature-allowlists/${encodeURIComponent(flag)}/${
|
|
775
|
+
`/api/admin/feature-allowlists/${encodeURIComponent(flag)}/${encodeIdentifier(did)}`,
|
|
768
776
|
"DELETE",
|
|
769
777
|
opts
|
|
770
778
|
);
|
|
@@ -772,7 +780,7 @@ function removeFeatureAllowlist(config, flag, did, opts = {}) {
|
|
|
772
780
|
|
|
773
781
|
// src/query/fetchers/activity.ts
|
|
774
782
|
async function fetchHeatmapData(config, handleOrDid, days, options = {}) {
|
|
775
|
-
const path = `/api/activity/${
|
|
783
|
+
const path = `/api/activity/${encodeIdentifier(handleOrDid)}/heatmap?days=${days}`;
|
|
776
784
|
try {
|
|
777
785
|
return await apiFetch(config, path, {
|
|
778
786
|
next: { revalidate: 900, tags: [`heatmap-${handleOrDid}`] },
|
|
@@ -788,7 +796,7 @@ async function fetchActivityTeaser(config, handleOrDid, options = {}) {
|
|
|
788
796
|
try {
|
|
789
797
|
return await apiFetch(
|
|
790
798
|
config,
|
|
791
|
-
`/api/activity/${
|
|
799
|
+
`/api/activity/${encodeIdentifier(handleOrDid)}/teaser`,
|
|
792
800
|
{
|
|
793
801
|
credentials: "include",
|
|
794
802
|
timeoutMs: 8e3,
|
|
@@ -812,7 +820,7 @@ async function fetchActivityFeed(config, handleOrDid, options = {}) {
|
|
|
812
820
|
try {
|
|
813
821
|
return await apiFetch(
|
|
814
822
|
config,
|
|
815
|
-
`/api/activity/${
|
|
823
|
+
`/api/activity/${encodeIdentifier(handleOrDid)}${qs ? `?${qs}` : ""}`,
|
|
816
824
|
{
|
|
817
825
|
credentials: "include",
|
|
818
826
|
cache: "no-store",
|
|
@@ -827,7 +835,7 @@ async function fetchActivityFeed(config, handleOrDid, options = {}) {
|
|
|
827
835
|
|
|
828
836
|
// src/query/fetchers/endorsement.ts
|
|
829
837
|
async function fetchEndorsementCount(config, did, options = {}) {
|
|
830
|
-
const path = `/api/endorsement/${
|
|
838
|
+
const path = `/api/endorsement/${encodeIdentifier(did)}`;
|
|
831
839
|
try {
|
|
832
840
|
const data = await apiFetch(config, path, {
|
|
833
841
|
cache: "no-store",
|
|
@@ -851,7 +859,7 @@ async function fetchNetworkStreamCount(config, did, options = {}) {
|
|
|
851
859
|
try {
|
|
852
860
|
const data = await apiFetch(
|
|
853
861
|
config,
|
|
854
|
-
`/api/stream/network?did=${
|
|
862
|
+
`/api/stream/network?did=${encodeIdentifier(did)}`,
|
|
855
863
|
{
|
|
856
864
|
cache: "no-store",
|
|
857
865
|
timeoutMs: 5e3,
|