@singi-labs/sifa-sdk 0.10.2 → 0.10.4

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.
@@ -318,4 +318,43 @@ interface Profile {
318
318
  externalAccounts?: ExternalAccount[];
319
319
  }
320
320
 
321
- export type { ActiveApp as A, ExternalAccount as E, FeedItem as F, LocationValue as L, ProfileSkill as P, SkillSuggestion as S, TrustStat as T, VerifiedAccount as V, PdsProviderInfo as a, Profile as b, Endorsement as c, EndorsementData as d, ExternalAccountKeytraceClaim as e, LanguageProficiency as f, ProfileCertification as g, ProfileCourse as h, ProfileEducation as i, ProfileHonor as j, ProfileIndustry as k, ProfileLanguage as l, ProfileLocation as m, ProfileOverrideSource as n, ProfilePosition as o, ProfileProject as p, ProfilePublication as q, ProfileVolunteering as r, PublicationContributor as s, SkillRef as t };
321
+ /**
322
+ * Adult-content gating for Bluesky activity items.
323
+ *
324
+ * Bluesky's official moderation labeler attaches content labels to
325
+ * `app.bsky.feed.defs#postView.labels`. The four sex-and-violence labels
326
+ * below are the ones we hide by default on Sifa: media is replaced with an
327
+ * `<AdultContentWarning>` placeholder card in sifa-web. Authenticated
328
+ * viewers can reveal per-card; anonymous viewers cannot.
329
+ *
330
+ * The list mirrors Bluesky's own globalLabelStrings; if the official set
331
+ * grows (e.g. a new `extreme-violence` label), update this constant.
332
+ *
333
+ * Why a constant + predicate live in the SDK: the same logic needs to run
334
+ * in sifa-web today and sifa-app tomorrow, and the API only forwards the
335
+ * raw labels — the hide decision is a client concern.
336
+ */
337
+ declare const ADULT_CONTENT_LABELS: readonly ["porn", "sexual", "nudity", "graphic-media"];
338
+ type AdultContentLabel = (typeof ADULT_CONTENT_LABELS)[number];
339
+ /**
340
+ * A single label entry as emitted by `app.bsky.feed.defs#postView.labels`.
341
+ * Matches `com.atproto.label.defs#label` (the on-wire shape after the AppView
342
+ * resolves a `postView`). `neg: true` marks a retraction.
343
+ */
344
+ interface ActivityLabel {
345
+ val: string;
346
+ src: string;
347
+ uri: string;
348
+ cts?: string;
349
+ neg?: boolean;
350
+ }
351
+ /**
352
+ * Return true if the item carries at least one adult-content label that is
353
+ * not negated. Items without a `labels` field (every non-Bluesky source,
354
+ * legacy responses) are treated as safe.
355
+ */
356
+ declare function hasAdultContent(item: {
357
+ labels?: ActivityLabel[];
358
+ }): boolean;
359
+
360
+ export { type ActivityLabel as A, type ExternalAccount as E, type FeedItem as F, type LocationValue as L, type ProfileSkill as P, type SkillSuggestion as S, type TrustStat as T, type VerifiedAccount as V, type PdsProviderInfo as a, type Profile as b, ADULT_CONTENT_LABELS as c, type ActiveApp as d, type AdultContentLabel as e, type Endorsement as f, type EndorsementData as g, type ExternalAccountKeytraceClaim as h, type LanguageProficiency as i, type ProfileCertification as j, type ProfileCourse as k, type ProfileEducation as l, type ProfileHonor as m, type ProfileIndustry as n, type ProfileLanguage as o, type ProfileLocation as p, type ProfileOverrideSource as q, type ProfilePosition as r, type ProfileProject as s, type ProfilePublication as t, type ProfileVolunteering as u, type PublicationContributor as v, type SkillRef as w, hasAdultContent as x };
@@ -318,4 +318,43 @@ interface Profile {
318
318
  externalAccounts?: ExternalAccount[];
319
319
  }
320
320
 
321
- export type { ActiveApp as A, ExternalAccount as E, FeedItem as F, LocationValue as L, ProfileSkill as P, SkillSuggestion as S, TrustStat as T, VerifiedAccount as V, PdsProviderInfo as a, Profile as b, Endorsement as c, EndorsementData as d, ExternalAccountKeytraceClaim as e, LanguageProficiency as f, ProfileCertification as g, ProfileCourse as h, ProfileEducation as i, ProfileHonor as j, ProfileIndustry as k, ProfileLanguage as l, ProfileLocation as m, ProfileOverrideSource as n, ProfilePosition as o, ProfileProject as p, ProfilePublication as q, ProfileVolunteering as r, PublicationContributor as s, SkillRef as t };
321
+ /**
322
+ * Adult-content gating for Bluesky activity items.
323
+ *
324
+ * Bluesky's official moderation labeler attaches content labels to
325
+ * `app.bsky.feed.defs#postView.labels`. The four sex-and-violence labels
326
+ * below are the ones we hide by default on Sifa: media is replaced with an
327
+ * `<AdultContentWarning>` placeholder card in sifa-web. Authenticated
328
+ * viewers can reveal per-card; anonymous viewers cannot.
329
+ *
330
+ * The list mirrors Bluesky's own globalLabelStrings; if the official set
331
+ * grows (e.g. a new `extreme-violence` label), update this constant.
332
+ *
333
+ * Why a constant + predicate live in the SDK: the same logic needs to run
334
+ * in sifa-web today and sifa-app tomorrow, and the API only forwards the
335
+ * raw labels — the hide decision is a client concern.
336
+ */
337
+ declare const ADULT_CONTENT_LABELS: readonly ["porn", "sexual", "nudity", "graphic-media"];
338
+ type AdultContentLabel = (typeof ADULT_CONTENT_LABELS)[number];
339
+ /**
340
+ * A single label entry as emitted by `app.bsky.feed.defs#postView.labels`.
341
+ * Matches `com.atproto.label.defs#label` (the on-wire shape after the AppView
342
+ * resolves a `postView`). `neg: true` marks a retraction.
343
+ */
344
+ interface ActivityLabel {
345
+ val: string;
346
+ src: string;
347
+ uri: string;
348
+ cts?: string;
349
+ neg?: boolean;
350
+ }
351
+ /**
352
+ * Return true if the item carries at least one adult-content label that is
353
+ * not negated. Items without a `labels` field (every non-Bluesky source,
354
+ * legacy responses) are treated as safe.
355
+ */
356
+ declare function hasAdultContent(item: {
357
+ labels?: ActivityLabel[];
358
+ }): boolean;
359
+
360
+ export { type ActivityLabel as A, type ExternalAccount as E, type FeedItem as F, type LocationValue as L, type ProfileSkill as P, type SkillSuggestion as S, type TrustStat as T, type VerifiedAccount as V, type PdsProviderInfo as a, type Profile as b, ADULT_CONTENT_LABELS as c, type ActiveApp as d, type AdultContentLabel as e, type Endorsement as f, type EndorsementData as g, type ExternalAccountKeytraceClaim as h, type LanguageProficiency as i, type ProfileCertification as j, type ProfileCourse as k, type ProfileEducation as l, type ProfileHonor as m, type ProfileIndustry as n, type ProfileLanguage as o, type ProfileLocation as p, type ProfileOverrideSource as q, type ProfilePosition as r, type ProfileProject as s, type ProfilePublication as t, type ProfileVolunteering as u, type PublicationContributor as v, type SkillRef as w, hasAdultContent as x };
package/dist/index.cjs CHANGED
@@ -1749,6 +1749,96 @@ function isVisibleActivityItem(collection, record) {
1749
1749
  return rule(record);
1750
1750
  }
1751
1751
 
1752
+ // src/cards/adult-content.ts
1753
+ var ADULT_CONTENT_LABELS = ["porn", "sexual", "nudity", "graphic-media"];
1754
+ function hasAdultContent(item) {
1755
+ const labels = item.labels;
1756
+ if (!labels || labels.length === 0) return false;
1757
+ return labels.some(
1758
+ (label) => !label.neg && ADULT_CONTENT_LABELS.includes(label.val)
1759
+ );
1760
+ }
1761
+
1762
+ // src/publishers/registry.ts
1763
+ var STANDARD_PUBLISHER_ID = "standard";
1764
+ var PUBLISHERS = Object.freeze([
1765
+ {
1766
+ id: "leaflet",
1767
+ name: "Leaflet",
1768
+ hostSuffixes: ["leaflet.pub"],
1769
+ homeUrl: "https://leaflet.pub"
1770
+ },
1771
+ {
1772
+ id: "pckt",
1773
+ name: "pckt",
1774
+ hostSuffixes: ["pckt.blog"],
1775
+ homeUrl: "https://pckt.blog"
1776
+ },
1777
+ {
1778
+ id: "offprint",
1779
+ name: "Offprint",
1780
+ hostSuffixes: ["offprint.app"],
1781
+ homeUrl: "https://offprint.app"
1782
+ },
1783
+ {
1784
+ id: "whitewind",
1785
+ name: "WhiteWind",
1786
+ hostSuffixes: ["whtwnd.com"],
1787
+ homeUrl: "https://whtwnd.com"
1788
+ },
1789
+ {
1790
+ id: "unthread",
1791
+ name: "Unthread",
1792
+ hostSuffixes: ["unthread.at"],
1793
+ homeUrl: "https://unthread.at"
1794
+ },
1795
+ {
1796
+ id: "blento",
1797
+ name: "Blento",
1798
+ hostSuffixes: ["blento.io"],
1799
+ homeUrl: "https://blento.io"
1800
+ }
1801
+ ]);
1802
+ var PUBLISHERS_BY_ID = new Map(PUBLISHERS.map((p) => [p.id, p]));
1803
+ function getPublisherById(id) {
1804
+ return PUBLISHERS_BY_ID.get(id);
1805
+ }
1806
+ function getPublisherByHost(hostname) {
1807
+ const host = hostname.toLowerCase();
1808
+ for (const publisher of PUBLISHERS) {
1809
+ for (const suffix of publisher.hostSuffixes) {
1810
+ if (host === suffix || host.endsWith(`.${suffix}`)) {
1811
+ return publisher;
1812
+ }
1813
+ }
1814
+ }
1815
+ return void 0;
1816
+ }
1817
+ function getPublisherFromSiteUrl(siteUrl) {
1818
+ let hostname;
1819
+ let homeUrl;
1820
+ try {
1821
+ const parsed2 = new URL(siteUrl);
1822
+ hostname = parsed2.hostname;
1823
+ homeUrl = `${parsed2.protocol}//${parsed2.hostname}`;
1824
+ } catch {
1825
+ return {
1826
+ id: STANDARD_PUBLISHER_ID,
1827
+ name: siteUrl,
1828
+ hostSuffixes: [],
1829
+ homeUrl: siteUrl
1830
+ };
1831
+ }
1832
+ const matched = getPublisherByHost(hostname);
1833
+ if (matched) return matched;
1834
+ return {
1835
+ id: STANDARD_PUBLISHER_ID,
1836
+ name: hostname,
1837
+ hostSuffixes: [],
1838
+ homeUrl
1839
+ };
1840
+ }
1841
+
1752
1842
  // src/logic/profile-completeness.ts
1753
1843
  var COMPLETENESS_MAX_SCORE = 6;
1754
1844
  function completenessScore(c) {
@@ -2068,10 +2158,11 @@ var ProfileVolunteeringRecordSchema = zod.z.object({
2068
2158
  });
2069
2159
 
2070
2160
  // src/index.ts
2071
- var SIFA_SDK_VERSION = "0.10.2";
2161
+ var SIFA_SDK_VERSION = "0.10.4";
2072
2162
 
2073
2163
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
2074
2164
  exports.ACTIVITY_VISIBILITY_RULES = ACTIVITY_VISIBILITY_RULES;
2165
+ exports.ADULT_CONTENT_LABELS = ADULT_CONTENT_LABELS;
2075
2166
  exports.APP_CATEGORIES = APP_CATEGORIES;
2076
2167
  exports.APP_CATEGORY_IDS = APP_CATEGORY_IDS;
2077
2168
  exports.APP_CATEGORY_MAP = APP_CATEGORY_MAP;
@@ -2101,6 +2192,7 @@ exports.MIN_SKILLS = MIN_SKILLS;
2101
2192
  exports.OPEN_TO_OPTIONS = OPEN_TO_OPTIONS;
2102
2193
  exports.PLATFORM_LABELS = PLATFORM_LABELS;
2103
2194
  exports.PLATFORM_OPTIONS = PLATFORM_OPTIONS;
2195
+ exports.PUBLISHERS = PUBLISHERS;
2104
2196
  exports.ProfileCertificationRecordSchema = ProfileCertificationRecordSchema;
2105
2197
  exports.ProfileCourseRecordSchema = ProfileCourseRecordSchema;
2106
2198
  exports.ProfileEducationRecordSchema = ProfileEducationRecordSchema;
@@ -2116,6 +2208,7 @@ exports.ProfileVolunteeringRecordSchema = ProfileVolunteeringRecordSchema;
2116
2208
  exports.PublicationAuthorSchema = PublicationAuthorSchema;
2117
2209
  exports.SIFA_SDK_VERSION = SIFA_SDK_VERSION;
2118
2210
  exports.SKILL_CATEGORIES = SKILL_CATEGORIES;
2211
+ exports.STANDARD_PUBLISHER_ID = STANDARD_PUBLISHER_ID;
2119
2212
  exports.SifaFeedItemSchema = SifaFeedItemSchema;
2120
2213
  exports.WORKPLACE_TYPE_LABELS = WORKPLACE_TYPE_LABELS;
2121
2214
  exports.WORKPLACE_TYPE_OPTIONS = WORKPLACE_TYPE_OPTIONS;
@@ -2155,9 +2248,13 @@ exports.getLexiconEntry = getLexiconEntry;
2155
2248
  exports.getOpenToLabelKey = getOpenToLabelKey;
2156
2249
  exports.getPdsDisplayName = getPdsDisplayName;
2157
2250
  exports.getPlatformLabel = getPlatformLabel;
2251
+ exports.getPublisherByHost = getPublisherByHost;
2252
+ exports.getPublisherById = getPublisherById;
2253
+ exports.getPublisherFromSiteUrl = getPublisherFromSiteUrl;
2158
2254
  exports.getTierMeta = getTierMeta;
2159
2255
  exports.getWorkplaceTypeLabel = getWorkplaceTypeLabel;
2160
2256
  exports.groupSkillsByCategory = groupSkillsByCategory;
2257
+ exports.hasAdultContent = hasAdultContent;
2161
2258
  exports.isAppCategory = isAppCategory;
2162
2259
  exports.isKnownAppId = isKnownAppId;
2163
2260
  exports.isKnownPlatform = isKnownPlatform;