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