@singi-labs/sifa-sdk 0.12.90 → 0.12.92

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.
@@ -573,6 +573,21 @@ async function fetchResolveActor(config, handleOrDid, options = {}) {
573
573
  ...options
574
574
  });
575
575
  }
576
+ async function fetchTypeaheadActors(config, query, limit = 8, options = {}) {
577
+ const q = query.trim().replace(/^@/, "");
578
+ if (!q) return [];
579
+ const params = new URLSearchParams({ q, limit: String(limit) });
580
+ try {
581
+ const res = await apiFetch(
582
+ config,
583
+ `/api/actor/typeahead?${params.toString()}`,
584
+ { cache: "no-store", ...options }
585
+ );
586
+ return res.actors ?? [];
587
+ } catch {
588
+ return [];
589
+ }
590
+ }
576
591
 
577
592
  // src/query/fetchers/keytrace-claims.ts
578
593
  function hideKeytraceClaim(config, rkey, options = {}) {
@@ -729,6 +744,30 @@ async function fetchHiddenApps(config, options = {}) {
729
744
  }
730
745
  }
731
746
 
747
+ // src/query/fetchers/accounts.ts
748
+ async function fetchAccounts(config, options = {}) {
749
+ const headers = { ...options.headers ?? {} };
750
+ if (options.cookieHeader) headers.cookie = options.cookieHeader;
751
+ try {
752
+ const data = await apiFetch(config, "/api/auth/accounts", {
753
+ credentials: "include",
754
+ ...options,
755
+ headers
756
+ });
757
+ return data.accounts;
758
+ } catch {
759
+ return [];
760
+ }
761
+ }
762
+ async function switchAccount(config, did, options = {}) {
763
+ await apiFetch(config, "/oauth/switch", {
764
+ method: "POST",
765
+ body: { did },
766
+ credentials: "include",
767
+ ...options
768
+ });
769
+ }
770
+
732
771
  // src/query/fetchers/search.ts
733
772
  var EMPTY_SEARCH = { profiles: [], total: 0, limit: 20, offset: 0 };
734
773
  var EMPTY_FILTERS = { countries: [], industries: [], apps: [], openTo: [] };
@@ -1570,6 +1609,12 @@ var sifaQueryKeys = {
1570
1609
  registry: () => ["sifa", "apps", "registry"],
1571
1610
  hidden: () => ["sifa", "apps", "hidden"]
1572
1611
  },
1612
+ auth: {
1613
+ all: () => ["sifa", "auth"],
1614
+ // Session-scoped: the AppView reads the account list from the browser's
1615
+ // cookies, so there is only ever one list per client.
1616
+ accounts: () => ["sifa", "auth", "accounts"]
1617
+ },
1573
1618
  activity: {
1574
1619
  all: () => ["sifa", "activity"],
1575
1620
  heatmap: (handleOrDid, days) => ["sifa", "activity", "heatmap", handleOrDid, days],
@@ -2602,6 +2647,14 @@ function useHiddenApps(options) {
2602
2647
  ...options
2603
2648
  });
2604
2649
  }
2650
+ function useAccounts(options) {
2651
+ const config = useSifaConfig();
2652
+ return reactQuery.useQuery({
2653
+ queryKey: sifaQueryKeys.auth.accounts(),
2654
+ queryFn: () => fetchAccounts(config),
2655
+ ...options
2656
+ });
2657
+ }
2605
2658
  function useSearchProfiles(filters, options) {
2606
2659
  const config = useSifaConfig();
2607
2660
  return reactQuery.useQuery({
@@ -3366,6 +3419,7 @@ exports.deleteSkill = deleteSkill;
3366
3419
  exports.dismissConfirmation = dismissConfirmation;
3367
3420
  exports.dismissEndorsement = dismissEndorsement;
3368
3421
  exports.effectiveContentVisibility = effectiveContentVisibility;
3422
+ exports.fetchAccounts = fetchAccounts;
3369
3423
  exports.fetchActivityFeed = fetchActivityFeed;
3370
3424
  exports.fetchActivityTeaser = fetchActivityTeaser;
3371
3425
  exports.fetchAppsRegistry = fetchAppsRegistry;
@@ -3401,6 +3455,7 @@ exports.fetchSkillSuggestions = fetchSkillSuggestions;
3401
3455
  exports.fetchStats = fetchStats;
3402
3456
  exports.fetchSuggestionCount = fetchSuggestionCount;
3403
3457
  exports.fetchSuggestions = fetchSuggestions;
3458
+ exports.fetchTypeaheadActors = fetchTypeaheadActors;
3404
3459
  exports.fetchWipePreview = fetchWipePreview;
3405
3460
  exports.followUser = followUser;
3406
3461
  exports.getAdminReviewQueues = getAdminReviewQueues;
@@ -3439,6 +3494,7 @@ exports.setPositionPrimary = setPositionPrimary;
3439
3494
  exports.shouldGateAdultMedia = shouldGateAdultMedia;
3440
3495
  exports.sifaQueryKeys = sifaQueryKeys;
3441
3496
  exports.submitOrgClaim = submitOrgClaim;
3497
+ exports.switchAccount = switchAccount;
3442
3498
  exports.unfollowUser = unfollowUser;
3443
3499
  exports.unhideKeytraceClaim = unhideKeytraceClaim;
3444
3500
  exports.unhideOrcidPublication = unhideOrcidPublication;
@@ -3462,6 +3518,7 @@ exports.updateSkill = updateSkill;
3462
3518
  exports.updateSkillSubCategories = updateSkillSubCategories;
3463
3519
  exports.uploadAvatar = uploadAvatar;
3464
3520
  exports.uploadNamePronunciationAudio = uploadNamePronunciationAudio;
3521
+ exports.useAccounts = useAccounts;
3465
3522
  exports.useActivityFeed = useActivityFeed;
3466
3523
  exports.useActivityTeaser = useActivityTeaser;
3467
3524
  exports.useAddFeatureAllowlist = useAddFeatureAllowlist;