@singi-labs/sifa-sdk 0.10.4 → 0.10.6
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/{adult-content-BjbP46ad.d.cts → adult-content-DxasJdot.d.cts} +1 -1
- package/dist/{adult-content-BjbP46ad.d.ts → adult-content-DxasJdot.d.ts} +1 -1
- package/dist/index.cjs +16 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/{keys-DPeDdYki.d.cts → keys-GSG0egRE.d.cts} +7 -3
- package/dist/{keys-Ba4_wCnj.d.ts → keys-G_SErFOu.d.ts} +7 -3
- package/dist/query/fetchers/index.cjs +4 -0
- package/dist/query/fetchers/index.cjs.map +1 -1
- package/dist/query/fetchers/index.d.cts +3 -3
- package/dist/query/fetchers/index.d.ts +3 -3
- package/dist/query/fetchers/index.js +4 -0
- package/dist/query/fetchers/index.js.map +1 -1
- package/dist/query/hooks/index.cjs +4 -0
- package/dist/query/hooks/index.cjs.map +1 -1
- package/dist/query/hooks/index.d.cts +3 -3
- package/dist/query/hooks/index.d.ts +3 -3
- package/dist/query/hooks/index.js +4 -0
- package/dist/query/hooks/index.js.map +1 -1
- package/dist/query/index.cjs +87 -0
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +101 -3
- package/dist/query/index.d.ts +101 -3
- package/dist/query/index.js +82 -1
- package/dist/query/index.js.map +1 -1
- package/package.json +1 -1
package/dist/query/index.d.cts
CHANGED
|
@@ -1,9 +1,107 @@
|
|
|
1
|
-
|
|
1
|
+
import { S as SifaApiConfig, A as ApiFetchOptions, W as WriteResult, s as sifaQueryKeys } from '../keys-GSG0egRE.cjs';
|
|
2
|
+
export { a as AccountCheckResult, b as ActivityFeedResponse, c as ActivityItem, d as ActivityItemLinkHealth, e as ActivityTeaserResponse, f as ApiError, g as AppRegistryEntry, B as BulkHideProfileItemInput, C as CheckAppAccountOptions, h as CreateExternalAccountResult, i as CreateResult, D as DeleteAccountResult, E as EndorsementInput, j as ExternalAccountInput, F as FeatureAllowlistResponse, k as FeaturedProfile, l as FetchActivityFeedOptions, m as FetchActivityTeaserOptions, n as FetchFollowListOptions, o as FetchFollowProfilePageOptions, p as FetchFollowingFeedOptions, q as FetchHiddenAppsOptions, r as FetchMyRoadmapVotesOptions, t as FetchReactionStatusOptions, u as FetchSuggestionsOptions, v as FilterOptions, w as FollowListPage, x as FollowProfile, y as FollowProfilePageResponse, z as FollowUserResult, G as FollowingResponse, H as HIDDEN_ITEM_SOURCES, I as HIDDEN_ITEM_TYPES, J as HeatmapDay, K as HeatmapResponse, L as HiddenApp, M as HiddenItemSource, N as HiddenItemType, O as HideProfileItemInput, P as ListFeatureAllowlistOptions, Q as ProfileIndustryInput, R as ProfileLocationAddress, T as ProfileLocationInput, U as ProfileSearchResult, V as ProfileSelfLocation, X as QUOTED_POSTS_BATCH_MAX, Y as QuotedPostAuthor, Z as QuotedPostImage, _ as QuotedPostResult, $ as QuotedPostView, a0 as ReactionError, a1 as ReactionResult, a2 as ReactionStatus, a3 as RefreshOrcidPublicationsResult, a4 as RefreshPdsResult, a5 as ResolveQuotedPostsOptions, a6 as RoadmapVoter, a7 as RoadmapVotesResponse, a8 as SearchFilters, a9 as SearchResponse, aa as SifaQueryKey, ab as SimilarProfile, ac as SkillSearchResult, ad as StatsResponse, ae as SuggestionProfile, af as SuggestionsResponse, ag as UpdateProfileOverrideInput, ah as UpdateProfileSelfInput, ai as UploadAvatarResult, aj as VerifyExternalAccountResult, ak as addFeatureAllowlist, al as apiFetch, am as apiFetchOrNull, an as apiWrite, ao as apiWriteCreate, ap as bulkHideProfileItems, aq as bulkHideStandardPublications, ar as bulkUnhideProfileItems, as as bulkUnhideStandardPublications, at as castRoadmapVote, au as checkAppAccount, av as createEndorsement, aw as createExternalAccount, ax as createProfileLocation, ay as createReaction, az as deleteAccount, aA as deleteAvatarOverride, aB as deleteExternalAccount, aC as deleteProfileLocation, aD as deleteReaction, aE as fetchActivityFeed, aF as fetchActivityTeaser, aG as fetchAppsRegistry, aH as fetchExternalAccounts, aI as fetchFeaturedProfile, aJ as fetchFollowing, aK as fetchHeatmapData, aL as fetchHiddenApps, aM as fetchMyRoadmapVotes, aN as fetchReactionStatus, aO as fetchRoadmapVotes, aP as fetchSearchFilters, aQ as fetchSearchProfiles, aR as fetchSimilarProfiles, aS as fetchSkillSuggestions, aT as fetchStats, aU as fetchSuggestionCount, aV as fetchSuggestions, aW as followUser, aX as getBlueskySuggestions, aY as getFollowers, aZ as getFollowing, a_ as getFollowingFeed, a$ as getMutuals, b0 as hideOrcidPublication, b1 as hideProfileItem, b2 as hideSifaPublication, b3 as hideStandardPublication, b4 as listFeatureAllowlist, b5 as refreshOrcidPublications, b6 as refreshPds, b7 as removeFeatureAllowlist, b8 as resetProfile, b9 as resolveQuotedPosts, ba as retractRoadmapVote, bb as searchSkills, bc as setExternalAccountPrimary, bd as unfollowUser, be as unhideOrcidPublication, bf as unhideProfileItem, bg as unhideSifaPublication, bh as unhideStandardPublication, bi as unsetExternalAccountPrimary, bj as updateExternalAccount, bk as updateProfileLocation, bl as updateProfileOverride, bm as updateProfileSelf, bn as uploadAvatar, bo as verifyExternalAccount } from '../keys-GSG0egRE.cjs';
|
|
2
3
|
export { AddFeatureAllowlistVariables, CreateReactionVariables, CreateRecordVariables, DeleteReactionVariables, DeleteRecordVariables, FollowVariables, PositionSkillLinkVariables, RemoveFeatureAllowlistVariables, SifaProvider, SifaProviderProps, UnfollowVariables, UpdateEducationVariables, UpdateExternalAccountVariables, UpdatePositionVariables, UpdateProfileLocationVariables, UpdateRecordVariables, UpdateSkillVariables, useActivityFeed, useActivityTeaser, useAddFeatureAllowlist, useAppAccountCheck, useAppsRegistry, useAtFundLink, useBlueskySuggestions, useBulkHideProfileItems, useBulkHideStandardPublications, useBulkUnhideProfileItems, useBulkUnhideStandardPublications, useCanonicalSkillSearch, useCastRoadmapVote, useCreateEducation, useCreateEndorsement, useCreateExternalAccount, useCreatePosition, useCreateProfileLocation, useCreateReaction, useCreateRecord, useCreateSkill, useDeleteAccount, useDeleteAvatarOverride, useDeleteEducation, useDeleteExternalAccount, useDeletePosition, useDeleteProfileLocation, useDeleteReaction, useDeleteRecord, useDeleteSkill, useEndorsementCount, useExternalAccounts, useFeatureAllowlist, useFeaturedProfile, useFollow, useFollowers, useFollowing, useFollowingFeed, useFollowingList, useHeatmapData, useHiddenApps, useHideKeytraceClaim, useHideOrcidPublication, useHideProfileItem, useHideSifaPublication, useHideStandardPublication, useLinkSkillToPosition, useMutuals, useMyRoadmapVotes, useNetworkStreamCount, useProfile, useReactionStatus, useRefreshOrcidPublications, useRefreshPds, useRemoveFeatureAllowlist, useResetProfile, useRetractRoadmapVote, useRoadmapVotes, useSearchFilters, useSearchProfiles, useSetExternalAccountPrimary, useSetPositionPrimary, useSifaConfig, useSimilarProfiles, useSkillSuggestions, useStats, useSuggestionCount, useSuggestions, useUnfollow, useUnhideKeytraceClaim, useUnhideOrcidPublication, useUnhideProfileItem, useUnhideSifaPublication, useUnhideStandardPublication, useUnlinkSkillFromPosition, useUnsetExternalAccountPrimary, useUnsetPositionPrimary, useUpdateEducation, useUpdateExternalAccount, useUpdatePosition, useUpdateProfileLocation, useUpdateProfileOverride, useUpdateProfileSelf, useUpdateRecord, useUpdateSkill, useUploadAvatar, useVerifyExternalAccount } from './hooks/index.cjs';
|
|
3
4
|
export { FetchNetworkStreamCountOptions, NetworkMapEdge, NetworkMapGenerationJob, NetworkMapGraphData, NetworkMapNode, NetworkMapPendingJob, NetworkMapResponse, checkNetworkMapJobStatus, createEducation, createPosition, createRecord, createSkill, deleteEducation, deletePosition, deleteRecord, deleteSkill, fetchAtFundLink, fetchEndorsementCount, fetchNetworkMap, fetchNetworkStreamCount, fetchProfile, hideKeytraceClaim, initiateNetworkMapGeneration, isNetworkMapResponse, linkSkillToPosition, setPositionPrimary, unhideKeytraceClaim, unlinkSkillFromPosition, unsetPositionPrimary, updateEducation, updatePosition, updateRecord, updateSkill } from './fetchers/index.cjs';
|
|
4
|
-
import '../adult-content-
|
|
5
|
+
import { A as AdultContentLabel } from '../adult-content-DxasJdot.cjs';
|
|
6
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
5
8
|
import '../feed-DHTy7fUN.cjs';
|
|
6
9
|
import 'zod';
|
|
7
10
|
import 'react/jsx-runtime';
|
|
8
11
|
import 'react';
|
|
9
|
-
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Visibility values defined by `app.bsky.actor.defs#contentLabelPref`.
|
|
15
|
+
* `null` means the viewer has no explicit pref for that label — call sites
|
|
16
|
+
* decide a default (Sifa hides by default; Bluesky's own client defaults
|
|
17
|
+
* to `warn` for adult labels on new accounts).
|
|
18
|
+
*/
|
|
19
|
+
type BskyContentLabelVisibility = 'ignore' | 'warn' | 'hide';
|
|
20
|
+
type BskyContentLabelPrefs = Record<AdultContentLabel, BskyContentLabelVisibility | null>;
|
|
21
|
+
interface BskyContentLabelPrefsResponse {
|
|
22
|
+
contentLabels: BskyContentLabelPrefs;
|
|
23
|
+
}
|
|
24
|
+
interface BskyPrefsScopeError {
|
|
25
|
+
error: 'InsufficientScope';
|
|
26
|
+
message?: string;
|
|
27
|
+
needsScope: 'bsky-preferences';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Read the viewer's Bluesky content-label preferences via sifa-api's
|
|
31
|
+
* proxy. Returns `null` when the viewer's OAuth grant doesn't include the
|
|
32
|
+
* read scope — sifa-web treats this as "needs scope upgrade" and triggers
|
|
33
|
+
* a granular re-auth.
|
|
34
|
+
*
|
|
35
|
+
* Any other failure (network, upstream PDS error) also resolves to `null`
|
|
36
|
+
* so callers always have a safe default (hide everything).
|
|
37
|
+
*/
|
|
38
|
+
declare function fetchBskyContentLabelPrefs(config: SifaApiConfig, options?: ApiFetchOptions & {
|
|
39
|
+
onNeedsScope?: () => void;
|
|
40
|
+
}): Promise<BskyContentLabelPrefs | null>;
|
|
41
|
+
interface UpdateBskyContentLabelPrefsBody {
|
|
42
|
+
contentLabels: Array<{
|
|
43
|
+
label: AdultContentLabel;
|
|
44
|
+
visibility: BskyContentLabelVisibility;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Update one or more of the viewer's adult content-label preferences. The
|
|
49
|
+
* sifa-api endpoint merges these into the viewer's existing prefs and
|
|
50
|
+
* writes the whole array back to their PDS — entries we don't touch are
|
|
51
|
+
* preserved.
|
|
52
|
+
*
|
|
53
|
+
* On insufficient-scope returns `{ success: false, error: ..., needsScope }`
|
|
54
|
+
* so the caller can drive a granular re-auth.
|
|
55
|
+
*/
|
|
56
|
+
declare function updateBskyContentLabelPrefs(config: SifaApiConfig, body: UpdateBskyContentLabelPrefsBody): Promise<WriteResult & {
|
|
57
|
+
contentLabels?: BskyContentLabelPrefs;
|
|
58
|
+
needsScope?: 'bsky-preferences';
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Compute the effective visibility for a Bluesky adult label.
|
|
62
|
+
*
|
|
63
|
+
* - Anonymous viewer (no prefs): always `hide` — matches Bluesky's logged-out
|
|
64
|
+
* behaviour; sifa-web won't even render a Show button.
|
|
65
|
+
* - Authenticated viewer with no explicit pref: `hide` by default, so Sifa
|
|
66
|
+
* stays safe-by-default and matches the gate that ships in sifa-web#1240
|
|
67
|
+
* today.
|
|
68
|
+
* - Authenticated viewer with an explicit pref: use it directly.
|
|
69
|
+
*
|
|
70
|
+
* Returns `'ignore'` to mean "render media inline", `'warn'` and `'hide'`
|
|
71
|
+
* both mean "placeholder card + reveal button" — Sifa doesn't distinguish
|
|
72
|
+
* the two today, but keeping them separate matches the lexicon and lets the
|
|
73
|
+
* UI evolve (e.g. blur for warn, full hide for hide) without an SDK change.
|
|
74
|
+
*/
|
|
75
|
+
declare function effectiveContentVisibility(label: AdultContentLabel, prefs: BskyContentLabelPrefs | null, isAuthenticated: boolean): BskyContentLabelVisibility;
|
|
76
|
+
/**
|
|
77
|
+
* Whether a labeled item should render its media inline. Convenience over
|
|
78
|
+
* `effectiveContentVisibility` for the common "any adult label hides
|
|
79
|
+
* everything" case in BlueskyPostCard.
|
|
80
|
+
*/
|
|
81
|
+
declare function shouldGateAdultMedia(labels: ReadonlyArray<{
|
|
82
|
+
val: string;
|
|
83
|
+
neg?: boolean;
|
|
84
|
+
}> | undefined, prefs: BskyContentLabelPrefs | null, isAuthenticated: boolean): boolean;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Read the viewer's Bluesky adult content-label preferences. The fetcher
|
|
88
|
+
* returns `null` when the OAuth grant doesn't include the read scope
|
|
89
|
+
* (sifa-api responds 403 with `needsScope: 'bsky-preferences'`); call
|
|
90
|
+
* sites should treat `null` as "needs scope upgrade" and route through
|
|
91
|
+
* the granular re-auth flow before retrying.
|
|
92
|
+
*
|
|
93
|
+
* Pass `enabled: false` for anonymous viewers — TanStack will skip the
|
|
94
|
+
* fetch entirely and the gate will fall through to its default-hide path.
|
|
95
|
+
*/
|
|
96
|
+
declare function useBskyContentLabelPrefs(options?: Omit<UseQueryOptions<BskyContentLabelPrefs | null, Error, BskyContentLabelPrefs | null, ReturnType<typeof sifaQueryKeys.bskyPreferences.contentLabels>>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<NoInfer<BskyContentLabelPrefs | null>, Error>;
|
|
97
|
+
/**
|
|
98
|
+
* Mutation that updates one or more adult-content prefs on the viewer's
|
|
99
|
+
* PDS via sifa-api, then writes the merged result back into the prefs
|
|
100
|
+
* cache so the next render reflects the change without a refetch.
|
|
101
|
+
*/
|
|
102
|
+
declare function useUpdateBskyContentLabelPrefs(): _tanstack_react_query.UseMutationResult<WriteResult & {
|
|
103
|
+
contentLabels?: BskyContentLabelPrefs;
|
|
104
|
+
needsScope?: "bsky-preferences";
|
|
105
|
+
}, Error, UpdateBskyContentLabelPrefsBody, unknown>;
|
|
106
|
+
|
|
107
|
+
export { ApiFetchOptions, type BskyContentLabelPrefs, type BskyContentLabelPrefsResponse, type BskyContentLabelVisibility, type BskyPrefsScopeError, SifaApiConfig, type UpdateBskyContentLabelPrefsBody, WriteResult, effectiveContentVisibility, fetchBskyContentLabelPrefs, shouldGateAdultMedia, sifaQueryKeys, updateBskyContentLabelPrefs, useBskyContentLabelPrefs, useUpdateBskyContentLabelPrefs };
|
package/dist/query/index.d.ts
CHANGED
|
@@ -1,9 +1,107 @@
|
|
|
1
|
-
|
|
1
|
+
import { S as SifaApiConfig, A as ApiFetchOptions, W as WriteResult, s as sifaQueryKeys } from '../keys-G_SErFOu.js';
|
|
2
|
+
export { a as AccountCheckResult, b as ActivityFeedResponse, c as ActivityItem, d as ActivityItemLinkHealth, e as ActivityTeaserResponse, f as ApiError, g as AppRegistryEntry, B as BulkHideProfileItemInput, C as CheckAppAccountOptions, h as CreateExternalAccountResult, i as CreateResult, D as DeleteAccountResult, E as EndorsementInput, j as ExternalAccountInput, F as FeatureAllowlistResponse, k as FeaturedProfile, l as FetchActivityFeedOptions, m as FetchActivityTeaserOptions, n as FetchFollowListOptions, o as FetchFollowProfilePageOptions, p as FetchFollowingFeedOptions, q as FetchHiddenAppsOptions, r as FetchMyRoadmapVotesOptions, t as FetchReactionStatusOptions, u as FetchSuggestionsOptions, v as FilterOptions, w as FollowListPage, x as FollowProfile, y as FollowProfilePageResponse, z as FollowUserResult, G as FollowingResponse, H as HIDDEN_ITEM_SOURCES, I as HIDDEN_ITEM_TYPES, J as HeatmapDay, K as HeatmapResponse, L as HiddenApp, M as HiddenItemSource, N as HiddenItemType, O as HideProfileItemInput, P as ListFeatureAllowlistOptions, Q as ProfileIndustryInput, R as ProfileLocationAddress, T as ProfileLocationInput, U as ProfileSearchResult, V as ProfileSelfLocation, X as QUOTED_POSTS_BATCH_MAX, Y as QuotedPostAuthor, Z as QuotedPostImage, _ as QuotedPostResult, $ as QuotedPostView, a0 as ReactionError, a1 as ReactionResult, a2 as ReactionStatus, a3 as RefreshOrcidPublicationsResult, a4 as RefreshPdsResult, a5 as ResolveQuotedPostsOptions, a6 as RoadmapVoter, a7 as RoadmapVotesResponse, a8 as SearchFilters, a9 as SearchResponse, aa as SifaQueryKey, ab as SimilarProfile, ac as SkillSearchResult, ad as StatsResponse, ae as SuggestionProfile, af as SuggestionsResponse, ag as UpdateProfileOverrideInput, ah as UpdateProfileSelfInput, ai as UploadAvatarResult, aj as VerifyExternalAccountResult, ak as addFeatureAllowlist, al as apiFetch, am as apiFetchOrNull, an as apiWrite, ao as apiWriteCreate, ap as bulkHideProfileItems, aq as bulkHideStandardPublications, ar as bulkUnhideProfileItems, as as bulkUnhideStandardPublications, at as castRoadmapVote, au as checkAppAccount, av as createEndorsement, aw as createExternalAccount, ax as createProfileLocation, ay as createReaction, az as deleteAccount, aA as deleteAvatarOverride, aB as deleteExternalAccount, aC as deleteProfileLocation, aD as deleteReaction, aE as fetchActivityFeed, aF as fetchActivityTeaser, aG as fetchAppsRegistry, aH as fetchExternalAccounts, aI as fetchFeaturedProfile, aJ as fetchFollowing, aK as fetchHeatmapData, aL as fetchHiddenApps, aM as fetchMyRoadmapVotes, aN as fetchReactionStatus, aO as fetchRoadmapVotes, aP as fetchSearchFilters, aQ as fetchSearchProfiles, aR as fetchSimilarProfiles, aS as fetchSkillSuggestions, aT as fetchStats, aU as fetchSuggestionCount, aV as fetchSuggestions, aW as followUser, aX as getBlueskySuggestions, aY as getFollowers, aZ as getFollowing, a_ as getFollowingFeed, a$ as getMutuals, b0 as hideOrcidPublication, b1 as hideProfileItem, b2 as hideSifaPublication, b3 as hideStandardPublication, b4 as listFeatureAllowlist, b5 as refreshOrcidPublications, b6 as refreshPds, b7 as removeFeatureAllowlist, b8 as resetProfile, b9 as resolveQuotedPosts, ba as retractRoadmapVote, bb as searchSkills, bc as setExternalAccountPrimary, bd as unfollowUser, be as unhideOrcidPublication, bf as unhideProfileItem, bg as unhideSifaPublication, bh as unhideStandardPublication, bi as unsetExternalAccountPrimary, bj as updateExternalAccount, bk as updateProfileLocation, bl as updateProfileOverride, bm as updateProfileSelf, bn as uploadAvatar, bo as verifyExternalAccount } from '../keys-G_SErFOu.js';
|
|
2
3
|
export { AddFeatureAllowlistVariables, CreateReactionVariables, CreateRecordVariables, DeleteReactionVariables, DeleteRecordVariables, FollowVariables, PositionSkillLinkVariables, RemoveFeatureAllowlistVariables, SifaProvider, SifaProviderProps, UnfollowVariables, UpdateEducationVariables, UpdateExternalAccountVariables, UpdatePositionVariables, UpdateProfileLocationVariables, UpdateRecordVariables, UpdateSkillVariables, useActivityFeed, useActivityTeaser, useAddFeatureAllowlist, useAppAccountCheck, useAppsRegistry, useAtFundLink, useBlueskySuggestions, useBulkHideProfileItems, useBulkHideStandardPublications, useBulkUnhideProfileItems, useBulkUnhideStandardPublications, useCanonicalSkillSearch, useCastRoadmapVote, useCreateEducation, useCreateEndorsement, useCreateExternalAccount, useCreatePosition, useCreateProfileLocation, useCreateReaction, useCreateRecord, useCreateSkill, useDeleteAccount, useDeleteAvatarOverride, useDeleteEducation, useDeleteExternalAccount, useDeletePosition, useDeleteProfileLocation, useDeleteReaction, useDeleteRecord, useDeleteSkill, useEndorsementCount, useExternalAccounts, useFeatureAllowlist, useFeaturedProfile, useFollow, useFollowers, useFollowing, useFollowingFeed, useFollowingList, useHeatmapData, useHiddenApps, useHideKeytraceClaim, useHideOrcidPublication, useHideProfileItem, useHideSifaPublication, useHideStandardPublication, useLinkSkillToPosition, useMutuals, useMyRoadmapVotes, useNetworkStreamCount, useProfile, useReactionStatus, useRefreshOrcidPublications, useRefreshPds, useRemoveFeatureAllowlist, useResetProfile, useRetractRoadmapVote, useRoadmapVotes, useSearchFilters, useSearchProfiles, useSetExternalAccountPrimary, useSetPositionPrimary, useSifaConfig, useSimilarProfiles, useSkillSuggestions, useStats, useSuggestionCount, useSuggestions, useUnfollow, useUnhideKeytraceClaim, useUnhideOrcidPublication, useUnhideProfileItem, useUnhideSifaPublication, useUnhideStandardPublication, useUnlinkSkillFromPosition, useUnsetExternalAccountPrimary, useUnsetPositionPrimary, useUpdateEducation, useUpdateExternalAccount, useUpdatePosition, useUpdateProfileLocation, useUpdateProfileOverride, useUpdateProfileSelf, useUpdateRecord, useUpdateSkill, useUploadAvatar, useVerifyExternalAccount } from './hooks/index.js';
|
|
3
4
|
export { FetchNetworkStreamCountOptions, NetworkMapEdge, NetworkMapGenerationJob, NetworkMapGraphData, NetworkMapNode, NetworkMapPendingJob, NetworkMapResponse, checkNetworkMapJobStatus, createEducation, createPosition, createRecord, createSkill, deleteEducation, deletePosition, deleteRecord, deleteSkill, fetchAtFundLink, fetchEndorsementCount, fetchNetworkMap, fetchNetworkStreamCount, fetchProfile, hideKeytraceClaim, initiateNetworkMapGeneration, isNetworkMapResponse, linkSkillToPosition, setPositionPrimary, unhideKeytraceClaim, unlinkSkillFromPosition, unsetPositionPrimary, updateEducation, updatePosition, updateRecord, updateSkill } from './fetchers/index.js';
|
|
4
|
-
import '../adult-content-
|
|
5
|
+
import { A as AdultContentLabel } from '../adult-content-DxasJdot.js';
|
|
6
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
5
8
|
import '../feed-DHTy7fUN.js';
|
|
6
9
|
import 'zod';
|
|
7
10
|
import 'react/jsx-runtime';
|
|
8
11
|
import 'react';
|
|
9
|
-
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Visibility values defined by `app.bsky.actor.defs#contentLabelPref`.
|
|
15
|
+
* `null` means the viewer has no explicit pref for that label — call sites
|
|
16
|
+
* decide a default (Sifa hides by default; Bluesky's own client defaults
|
|
17
|
+
* to `warn` for adult labels on new accounts).
|
|
18
|
+
*/
|
|
19
|
+
type BskyContentLabelVisibility = 'ignore' | 'warn' | 'hide';
|
|
20
|
+
type BskyContentLabelPrefs = Record<AdultContentLabel, BskyContentLabelVisibility | null>;
|
|
21
|
+
interface BskyContentLabelPrefsResponse {
|
|
22
|
+
contentLabels: BskyContentLabelPrefs;
|
|
23
|
+
}
|
|
24
|
+
interface BskyPrefsScopeError {
|
|
25
|
+
error: 'InsufficientScope';
|
|
26
|
+
message?: string;
|
|
27
|
+
needsScope: 'bsky-preferences';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Read the viewer's Bluesky content-label preferences via sifa-api's
|
|
31
|
+
* proxy. Returns `null` when the viewer's OAuth grant doesn't include the
|
|
32
|
+
* read scope — sifa-web treats this as "needs scope upgrade" and triggers
|
|
33
|
+
* a granular re-auth.
|
|
34
|
+
*
|
|
35
|
+
* Any other failure (network, upstream PDS error) also resolves to `null`
|
|
36
|
+
* so callers always have a safe default (hide everything).
|
|
37
|
+
*/
|
|
38
|
+
declare function fetchBskyContentLabelPrefs(config: SifaApiConfig, options?: ApiFetchOptions & {
|
|
39
|
+
onNeedsScope?: () => void;
|
|
40
|
+
}): Promise<BskyContentLabelPrefs | null>;
|
|
41
|
+
interface UpdateBskyContentLabelPrefsBody {
|
|
42
|
+
contentLabels: Array<{
|
|
43
|
+
label: AdultContentLabel;
|
|
44
|
+
visibility: BskyContentLabelVisibility;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Update one or more of the viewer's adult content-label preferences. The
|
|
49
|
+
* sifa-api endpoint merges these into the viewer's existing prefs and
|
|
50
|
+
* writes the whole array back to their PDS — entries we don't touch are
|
|
51
|
+
* preserved.
|
|
52
|
+
*
|
|
53
|
+
* On insufficient-scope returns `{ success: false, error: ..., needsScope }`
|
|
54
|
+
* so the caller can drive a granular re-auth.
|
|
55
|
+
*/
|
|
56
|
+
declare function updateBskyContentLabelPrefs(config: SifaApiConfig, body: UpdateBskyContentLabelPrefsBody): Promise<WriteResult & {
|
|
57
|
+
contentLabels?: BskyContentLabelPrefs;
|
|
58
|
+
needsScope?: 'bsky-preferences';
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Compute the effective visibility for a Bluesky adult label.
|
|
62
|
+
*
|
|
63
|
+
* - Anonymous viewer (no prefs): always `hide` — matches Bluesky's logged-out
|
|
64
|
+
* behaviour; sifa-web won't even render a Show button.
|
|
65
|
+
* - Authenticated viewer with no explicit pref: `hide` by default, so Sifa
|
|
66
|
+
* stays safe-by-default and matches the gate that ships in sifa-web#1240
|
|
67
|
+
* today.
|
|
68
|
+
* - Authenticated viewer with an explicit pref: use it directly.
|
|
69
|
+
*
|
|
70
|
+
* Returns `'ignore'` to mean "render media inline", `'warn'` and `'hide'`
|
|
71
|
+
* both mean "placeholder card + reveal button" — Sifa doesn't distinguish
|
|
72
|
+
* the two today, but keeping them separate matches the lexicon and lets the
|
|
73
|
+
* UI evolve (e.g. blur for warn, full hide for hide) without an SDK change.
|
|
74
|
+
*/
|
|
75
|
+
declare function effectiveContentVisibility(label: AdultContentLabel, prefs: BskyContentLabelPrefs | null, isAuthenticated: boolean): BskyContentLabelVisibility;
|
|
76
|
+
/**
|
|
77
|
+
* Whether a labeled item should render its media inline. Convenience over
|
|
78
|
+
* `effectiveContentVisibility` for the common "any adult label hides
|
|
79
|
+
* everything" case in BlueskyPostCard.
|
|
80
|
+
*/
|
|
81
|
+
declare function shouldGateAdultMedia(labels: ReadonlyArray<{
|
|
82
|
+
val: string;
|
|
83
|
+
neg?: boolean;
|
|
84
|
+
}> | undefined, prefs: BskyContentLabelPrefs | null, isAuthenticated: boolean): boolean;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Read the viewer's Bluesky adult content-label preferences. The fetcher
|
|
88
|
+
* returns `null` when the OAuth grant doesn't include the read scope
|
|
89
|
+
* (sifa-api responds 403 with `needsScope: 'bsky-preferences'`); call
|
|
90
|
+
* sites should treat `null` as "needs scope upgrade" and route through
|
|
91
|
+
* the granular re-auth flow before retrying.
|
|
92
|
+
*
|
|
93
|
+
* Pass `enabled: false` for anonymous viewers — TanStack will skip the
|
|
94
|
+
* fetch entirely and the gate will fall through to its default-hide path.
|
|
95
|
+
*/
|
|
96
|
+
declare function useBskyContentLabelPrefs(options?: Omit<UseQueryOptions<BskyContentLabelPrefs | null, Error, BskyContentLabelPrefs | null, ReturnType<typeof sifaQueryKeys.bskyPreferences.contentLabels>>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<NoInfer<BskyContentLabelPrefs | null>, Error>;
|
|
97
|
+
/**
|
|
98
|
+
* Mutation that updates one or more adult-content prefs on the viewer's
|
|
99
|
+
* PDS via sifa-api, then writes the merged result back into the prefs
|
|
100
|
+
* cache so the next render reflects the change without a refetch.
|
|
101
|
+
*/
|
|
102
|
+
declare function useUpdateBskyContentLabelPrefs(): _tanstack_react_query.UseMutationResult<WriteResult & {
|
|
103
|
+
contentLabels?: BskyContentLabelPrefs;
|
|
104
|
+
needsScope?: "bsky-preferences";
|
|
105
|
+
}, Error, UpdateBskyContentLabelPrefsBody, unknown>;
|
|
106
|
+
|
|
107
|
+
export { ApiFetchOptions, type BskyContentLabelPrefs, type BskyContentLabelPrefsResponse, type BskyContentLabelVisibility, type BskyPrefsScopeError, SifaApiConfig, type UpdateBskyContentLabelPrefsBody, WriteResult, effectiveContentVisibility, fetchBskyContentLabelPrefs, shouldGateAdultMedia, sifaQueryKeys, updateBskyContentLabelPrefs, useBskyContentLabelPrefs, useUpdateBskyContentLabelPrefs };
|
package/dist/query/index.js
CHANGED
|
@@ -1122,6 +1122,10 @@ var sifaQueryKeys = {
|
|
|
1122
1122
|
all: () => ["sifa", "roadmap"],
|
|
1123
1123
|
votes: () => ["sifa", "roadmap", "votes"],
|
|
1124
1124
|
myVotes: () => ["sifa", "roadmap", "my-votes"]
|
|
1125
|
+
},
|
|
1126
|
+
bskyPreferences: {
|
|
1127
|
+
all: () => ["sifa", "bsky-preferences"],
|
|
1128
|
+
contentLabels: () => ["sifa", "bsky-preferences", "content-labels"]
|
|
1125
1129
|
}
|
|
1126
1130
|
};
|
|
1127
1131
|
|
|
@@ -2200,6 +2204,83 @@ function useDeleteAccount(options) {
|
|
|
2200
2204
|
});
|
|
2201
2205
|
}
|
|
2202
2206
|
|
|
2203
|
-
|
|
2207
|
+
// src/cards/adult-content.ts
|
|
2208
|
+
var ADULT_CONTENT_LABELS = ["porn", "sexual", "nudity", "graphic-media"];
|
|
2209
|
+
|
|
2210
|
+
// src/query/fetchers/bsky-preferences.ts
|
|
2211
|
+
async function fetchBskyContentLabelPrefs(config, options = {}) {
|
|
2212
|
+
const { onNeedsScope, ...fetchOptions } = options;
|
|
2213
|
+
try {
|
|
2214
|
+
const res = await apiFetch(
|
|
2215
|
+
config,
|
|
2216
|
+
"/api/bsky/preferences/content-labels",
|
|
2217
|
+
{ credentials: "include", ...fetchOptions }
|
|
2218
|
+
);
|
|
2219
|
+
return res.contentLabels;
|
|
2220
|
+
} catch (err) {
|
|
2221
|
+
if (err && typeof err === "object" && "status" in err && err.status === 403) {
|
|
2222
|
+
onNeedsScope?.();
|
|
2223
|
+
}
|
|
2224
|
+
return null;
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
async function updateBskyContentLabelPrefs(config, body) {
|
|
2228
|
+
const result = await apiWrite(config, "/api/bsky/preferences/content-labels", "PUT", {
|
|
2229
|
+
headers: { "Content-Type": "application/json" },
|
|
2230
|
+
body: JSON.stringify(body)
|
|
2231
|
+
});
|
|
2232
|
+
return result;
|
|
2233
|
+
}
|
|
2234
|
+
function effectiveContentVisibility(label, prefs, isAuthenticated) {
|
|
2235
|
+
if (!isAuthenticated) return "hide";
|
|
2236
|
+
const value = prefs?.[label] ?? null;
|
|
2237
|
+
return value ?? "hide";
|
|
2238
|
+
}
|
|
2239
|
+
function shouldGateAdultMedia(labels, prefs, isAuthenticated) {
|
|
2240
|
+
if (!labels || labels.length === 0) return false;
|
|
2241
|
+
for (const label of labels) {
|
|
2242
|
+
if (label.neg) continue;
|
|
2243
|
+
if (!ADULT_CONTENT_LABELS.includes(label.val)) continue;
|
|
2244
|
+
const visibility = effectiveContentVisibility(
|
|
2245
|
+
label.val,
|
|
2246
|
+
prefs,
|
|
2247
|
+
isAuthenticated
|
|
2248
|
+
);
|
|
2249
|
+
if (visibility !== "ignore") return true;
|
|
2250
|
+
}
|
|
2251
|
+
return false;
|
|
2252
|
+
}
|
|
2253
|
+
function useBskyContentLabelPrefs(options) {
|
|
2254
|
+
const config = useSifaConfig();
|
|
2255
|
+
return useQuery({
|
|
2256
|
+
queryKey: sifaQueryKeys.bskyPreferences.contentLabels(),
|
|
2257
|
+
queryFn: () => fetchBskyContentLabelPrefs(config),
|
|
2258
|
+
// Prefs change rarely; long stale time keeps the gate snappy on
|
|
2259
|
+
// navigation. Invalidation after a write is explicit.
|
|
2260
|
+
staleTime: 5 * 6e4,
|
|
2261
|
+
...options
|
|
2262
|
+
});
|
|
2263
|
+
}
|
|
2264
|
+
function useUpdateBskyContentLabelPrefs() {
|
|
2265
|
+
const config = useSifaConfig();
|
|
2266
|
+
const queryClient = useQueryClient();
|
|
2267
|
+
return useMutation({
|
|
2268
|
+
mutationFn: (body) => updateBskyContentLabelPrefs(config, body),
|
|
2269
|
+
onSuccess: (result) => {
|
|
2270
|
+
if (result.success && result.contentLabels) {
|
|
2271
|
+
queryClient.setQueryData(
|
|
2272
|
+
sifaQueryKeys.bskyPreferences.contentLabels(),
|
|
2273
|
+
result.contentLabels
|
|
2274
|
+
);
|
|
2275
|
+
} else {
|
|
2276
|
+
void queryClient.invalidateQueries({
|
|
2277
|
+
queryKey: sifaQueryKeys.bskyPreferences.all()
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
});
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
export { ApiError, HIDDEN_ITEM_SOURCES, HIDDEN_ITEM_TYPES, QUOTED_POSTS_BATCH_MAX, SifaProvider, addFeatureAllowlist, apiFetch, apiFetchOrNull, apiWrite, apiWriteCreate, bulkHideProfileItems, bulkHideStandardPublications, bulkUnhideProfileItems, bulkUnhideStandardPublications, castRoadmapVote, checkAppAccount, checkNetworkMapJobStatus, createEducation, createEndorsement, createExternalAccount, createPosition, createProfileLocation, createReaction, createRecord, createSkill, deleteAccount, deleteAvatarOverride, deleteEducation, deleteExternalAccount, deletePosition, deleteProfileLocation, deleteReaction, deleteRecord, deleteSkill, effectiveContentVisibility, fetchActivityFeed, fetchActivityTeaser, fetchAppsRegistry, fetchAtFundLink, fetchBskyContentLabelPrefs, fetchEndorsementCount, fetchExternalAccounts, fetchFeaturedProfile, fetchFollowing, fetchHeatmapData, fetchHiddenApps, fetchMyRoadmapVotes, fetchNetworkMap, fetchNetworkStreamCount, fetchProfile, fetchReactionStatus, fetchRoadmapVotes, fetchSearchFilters, fetchSearchProfiles, fetchSimilarProfiles, fetchSkillSuggestions, fetchStats, fetchSuggestionCount, fetchSuggestions, followUser, getBlueskySuggestions, getFollowers, getFollowing, getFollowingFeed, getMutuals, hideKeytraceClaim, hideOrcidPublication, hideProfileItem, hideSifaPublication, hideStandardPublication, initiateNetworkMapGeneration, isNetworkMapResponse, linkSkillToPosition, listFeatureAllowlist, refreshOrcidPublications, refreshPds, removeFeatureAllowlist, resetProfile, resolveQuotedPosts, retractRoadmapVote, searchSkills, setExternalAccountPrimary, setPositionPrimary, shouldGateAdultMedia, sifaQueryKeys, unfollowUser, unhideKeytraceClaim, unhideOrcidPublication, unhideProfileItem, unhideSifaPublication, unhideStandardPublication, unlinkSkillFromPosition, unsetExternalAccountPrimary, unsetPositionPrimary, updateBskyContentLabelPrefs, updateEducation, updateExternalAccount, updatePosition, updateProfileLocation, updateProfileOverride, updateProfileSelf, updateRecord, updateSkill, uploadAvatar, useActivityFeed, useActivityTeaser, useAddFeatureAllowlist, useAppAccountCheck, useAppsRegistry, useAtFundLink, useBlueskySuggestions, useBskyContentLabelPrefs, useBulkHideProfileItems, useBulkHideStandardPublications, useBulkUnhideProfileItems, useBulkUnhideStandardPublications, useCanonicalSkillSearch, useCastRoadmapVote, useCreateEducation, useCreateEndorsement, useCreateExternalAccount, useCreatePosition, useCreateProfileLocation, useCreateReaction, useCreateRecord, useCreateSkill, useDeleteAccount, useDeleteAvatarOverride, useDeleteEducation, useDeleteExternalAccount, useDeletePosition, useDeleteProfileLocation, useDeleteReaction, useDeleteRecord, useDeleteSkill, useEndorsementCount, useExternalAccounts, useFeatureAllowlist, useFeaturedProfile, useFollow, useFollowers, useFollowing, useFollowingFeed, useFollowingList, useHeatmapData, useHiddenApps, useHideKeytraceClaim, useHideOrcidPublication, useHideProfileItem, useHideSifaPublication, useHideStandardPublication, useLinkSkillToPosition, useMutuals, useMyRoadmapVotes, useNetworkStreamCount, useProfile, useReactionStatus, useRefreshOrcidPublications, useRefreshPds, useRemoveFeatureAllowlist, useResetProfile, useRetractRoadmapVote, useRoadmapVotes, useSearchFilters, useSearchProfiles, useSetExternalAccountPrimary, useSetPositionPrimary, useSifaConfig, useSimilarProfiles, useSkillSuggestions, useStats, useSuggestionCount, useSuggestions, useUnfollow, useUnhideKeytraceClaim, useUnhideOrcidPublication, useUnhideProfileItem, useUnhideSifaPublication, useUnhideStandardPublication, useUnlinkSkillFromPosition, useUnsetExternalAccountPrimary, useUnsetPositionPrimary, useUpdateBskyContentLabelPrefs, useUpdateEducation, useUpdateExternalAccount, useUpdatePosition, useUpdateProfileLocation, useUpdateProfileOverride, useUpdateProfileSelf, useUpdateRecord, useUpdateSkill, useUploadAvatar, useVerifyExternalAccount, verifyExternalAccount };
|
|
2204
2285
|
//# sourceMappingURL=index.js.map
|
|
2205
2286
|
//# sourceMappingURL=index.js.map
|