@singi-labs/sifa-sdk 0.12.91 → 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.
@@ -744,6 +744,30 @@ async function fetchHiddenApps(config, options = {}) {
744
744
  }
745
745
  }
746
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
+
747
771
  // src/query/fetchers/search.ts
748
772
  var EMPTY_SEARCH = { profiles: [], total: 0, limit: 20, offset: 0 };
749
773
  var EMPTY_FILTERS = { countries: [], industries: [], apps: [], openTo: [] };
@@ -1585,6 +1609,12 @@ var sifaQueryKeys = {
1585
1609
  registry: () => ["sifa", "apps", "registry"],
1586
1610
  hidden: () => ["sifa", "apps", "hidden"]
1587
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
+ },
1588
1618
  activity: {
1589
1619
  all: () => ["sifa", "activity"],
1590
1620
  heatmap: (handleOrDid, days) => ["sifa", "activity", "heatmap", handleOrDid, days],
@@ -2617,6 +2647,14 @@ function useHiddenApps(options) {
2617
2647
  ...options
2618
2648
  });
2619
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
+ }
2620
2658
  function useSearchProfiles(filters, options) {
2621
2659
  const config = useSifaConfig();
2622
2660
  return reactQuery.useQuery({
@@ -3381,6 +3419,7 @@ exports.deleteSkill = deleteSkill;
3381
3419
  exports.dismissConfirmation = dismissConfirmation;
3382
3420
  exports.dismissEndorsement = dismissEndorsement;
3383
3421
  exports.effectiveContentVisibility = effectiveContentVisibility;
3422
+ exports.fetchAccounts = fetchAccounts;
3384
3423
  exports.fetchActivityFeed = fetchActivityFeed;
3385
3424
  exports.fetchActivityTeaser = fetchActivityTeaser;
3386
3425
  exports.fetchAppsRegistry = fetchAppsRegistry;
@@ -3455,6 +3494,7 @@ exports.setPositionPrimary = setPositionPrimary;
3455
3494
  exports.shouldGateAdultMedia = shouldGateAdultMedia;
3456
3495
  exports.sifaQueryKeys = sifaQueryKeys;
3457
3496
  exports.submitOrgClaim = submitOrgClaim;
3497
+ exports.switchAccount = switchAccount;
3458
3498
  exports.unfollowUser = unfollowUser;
3459
3499
  exports.unhideKeytraceClaim = unhideKeytraceClaim;
3460
3500
  exports.unhideOrcidPublication = unhideOrcidPublication;
@@ -3478,6 +3518,7 @@ exports.updateSkill = updateSkill;
3478
3518
  exports.updateSkillSubCategories = updateSkillSubCategories;
3479
3519
  exports.uploadAvatar = uploadAvatar;
3480
3520
  exports.uploadNamePronunciationAudio = uploadNamePronunciationAudio;
3521
+ exports.useAccounts = useAccounts;
3481
3522
  exports.useActivityFeed = useActivityFeed;
3482
3523
  exports.useActivityTeaser = useActivityTeaser;
3483
3524
  exports.useAddFeatureAllowlist = useAddFeatureAllowlist;