@singi-labs/sifa-sdk 0.19.108 → 0.19.109

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.
Files changed (37) hide show
  1. package/dist/germ-declaration-BQBocGww.d.cts +33 -0
  2. package/dist/germ-declaration-BQBocGww.d.ts +33 -0
  3. package/dist/index.cjs +82 -1
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +61 -1
  6. package/dist/index.d.ts +61 -1
  7. package/dist/index.js +18 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/logic/germ.js +71 -0
  10. package/dist/logic/germ.js.map +1 -0
  11. package/dist/logic/index.js +14 -0
  12. package/dist/logic/index.js.map +1 -1
  13. package/dist/{network-map-DTlhFNIf.d.ts → network-map-DVzGiX2h.d.ts} +36 -1
  14. package/dist/{network-map-CVr1LskK.d.cts → network-map-DsxrigjL.d.cts} +36 -1
  15. package/dist/query/fetchers/germ.js +46 -0
  16. package/dist/query/fetchers/germ.js.map +1 -0
  17. package/dist/query/fetchers/index.cjs +50 -0
  18. package/dist/query/fetchers/index.cjs.map +1 -1
  19. package/dist/query/fetchers/index.d.cts +2 -1
  20. package/dist/query/fetchers/index.d.ts +2 -1
  21. package/dist/query/fetchers/index.js +6 -0
  22. package/dist/query/fetchers/index.js.map +1 -1
  23. package/dist/query/index.cjs +50 -0
  24. package/dist/query/index.cjs.map +1 -1
  25. package/dist/query/index.d.cts +3 -2
  26. package/dist/query/index.d.ts +3 -2
  27. package/dist/query/index.js +6 -0
  28. package/dist/query/index.js.map +1 -1
  29. package/dist/schemas/germ-declaration.js +17 -0
  30. package/dist/schemas/germ-declaration.js.map +1 -0
  31. package/dist/schemas/index.cjs +12 -0
  32. package/dist/schemas/index.cjs.map +1 -1
  33. package/dist/schemas/index.d.cts +1 -0
  34. package/dist/schemas/index.d.ts +1 -0
  35. package/dist/schemas/index.js +6 -0
  36. package/dist/schemas/index.js.map +1 -1
  37. package/package.json +1 -1
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * `showButtonTo` values the Germ lexicon declares. The lexicon lists them as
5
+ * `knownValues`, not an enum, so the schema accepts any string; consumers must
6
+ * treat an unknown value as "no button" (see `germButtonAudience`).
7
+ */
8
+ declare const GERM_SHOW_BUTTON_TO_VALUES: readonly ["none", "usersIFollow", "everyone"];
9
+ type GermShowButtonTo = (typeof GERM_SHOW_BUTTON_TO_VALUES)[number];
10
+ /**
11
+ * Zod schema for `com.germnetwork.declaration` (rkey `self`), the record a Germ
12
+ * DM user publishes in their own repo.
13
+ *
14
+ * Only the fields an AppView reads are typed. The key material (`currentKey`,
15
+ * `keyPackage`, `continuityProofs`) is opaque; `currentKey` is checked for shape
16
+ * only, because an empty key means the DID is no longer bound to Germ. Unknown
17
+ * keys pass through so a newer record version still parses.
18
+ *
19
+ * @see https://lexicon.garden/lexicon/did:plc:qyqmmncrm6qx33kpy7vqndik/com.germnetwork.declaration
20
+ */
21
+ declare const GermDeclarationRecordSchema: z.ZodObject<{
22
+ version: z.ZodString;
23
+ currentKey: z.ZodUnion<readonly [z.ZodObject<{
24
+ $bytes: z.ZodString;
25
+ }, z.core.$strip>, z.ZodInstanceOf<Uint8Array<ArrayBuffer>>]>;
26
+ messageMe: z.ZodOptional<z.ZodObject<{
27
+ showButtonTo: z.ZodString;
28
+ messageMeUrl: z.ZodString;
29
+ }, z.core.$strip>>;
30
+ }, z.core.$loose>;
31
+ type GermDeclarationRecord = z.infer<typeof GermDeclarationRecordSchema>;
32
+
33
+ export { type GermDeclarationRecord as G, GERM_SHOW_BUTTON_TO_VALUES as a, GermDeclarationRecordSchema as b, type GermShowButtonTo as c };
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * `showButtonTo` values the Germ lexicon declares. The lexicon lists them as
5
+ * `knownValues`, not an enum, so the schema accepts any string; consumers must
6
+ * treat an unknown value as "no button" (see `germButtonAudience`).
7
+ */
8
+ declare const GERM_SHOW_BUTTON_TO_VALUES: readonly ["none", "usersIFollow", "everyone"];
9
+ type GermShowButtonTo = (typeof GERM_SHOW_BUTTON_TO_VALUES)[number];
10
+ /**
11
+ * Zod schema for `com.germnetwork.declaration` (rkey `self`), the record a Germ
12
+ * DM user publishes in their own repo.
13
+ *
14
+ * Only the fields an AppView reads are typed. The key material (`currentKey`,
15
+ * `keyPackage`, `continuityProofs`) is opaque; `currentKey` is checked for shape
16
+ * only, because an empty key means the DID is no longer bound to Germ. Unknown
17
+ * keys pass through so a newer record version still parses.
18
+ *
19
+ * @see https://lexicon.garden/lexicon/did:plc:qyqmmncrm6qx33kpy7vqndik/com.germnetwork.declaration
20
+ */
21
+ declare const GermDeclarationRecordSchema: z.ZodObject<{
22
+ version: z.ZodString;
23
+ currentKey: z.ZodUnion<readonly [z.ZodObject<{
24
+ $bytes: z.ZodString;
25
+ }, z.core.$strip>, z.ZodInstanceOf<Uint8Array<ArrayBuffer>>]>;
26
+ messageMe: z.ZodOptional<z.ZodObject<{
27
+ showButtonTo: z.ZodString;
28
+ messageMeUrl: z.ZodString;
29
+ }, z.core.$strip>>;
30
+ }, z.core.$loose>;
31
+ type GermDeclarationRecord = z.infer<typeof GermDeclarationRecordSchema>;
32
+
33
+ export { type GermDeclarationRecord as G, GERM_SHOW_BUTTON_TO_VALUES as a, GermDeclarationRecordSchema as b, type GermShowButtonTo as c };
package/dist/index.cjs CHANGED
@@ -6534,6 +6534,69 @@ function excludeSelfApp(apps) {
6534
6534
  return apps.filter((app) => app.id !== SELF_APP_ID);
6535
6535
  }
6536
6536
 
6537
+ // src/logic/germ.ts
6538
+ var GERM_MESSAGE_HOSTS = ["landing.ger.mx"];
6539
+ var MAX_DID_LENGTH = 2048;
6540
+ var STRICT_DID = /^did:[a-z]+:(?:[A-Za-z0-9._:-]|%3A)*(?:[A-Za-z0-9._-]|%3A)$/;
6541
+ function isStrictDid(value) {
6542
+ return value.length <= MAX_DID_LENGTH && STRICT_DID.test(value);
6543
+ }
6544
+ function parseGermMessageUrl(raw) {
6545
+ let url;
6546
+ try {
6547
+ url = new URL(raw);
6548
+ } catch {
6549
+ return null;
6550
+ }
6551
+ if (url.protocol !== "https:") return null;
6552
+ if (url.username !== "" || url.password !== "" || url.port !== "") return null;
6553
+ if (!GERM_MESSAGE_HOSTS.includes(url.hostname)) return null;
6554
+ if (url.hash !== "") return null;
6555
+ return url;
6556
+ }
6557
+ function germButtonAudience(declaration) {
6558
+ if (!declaration) return null;
6559
+ const key = declaration.currentKey;
6560
+ if (key instanceof Uint8Array ? key.length === 0 : key.$bytes === "") return null;
6561
+ const messageMe = declaration.messageMe;
6562
+ if (!messageMe) return null;
6563
+ if (!parseGermMessageUrl(messageMe.messageMeUrl)) return null;
6564
+ if (messageMe.showButtonTo === "everyone" || messageMe.showButtonTo === "usersIFollow") {
6565
+ return messageMe.showButtonTo;
6566
+ }
6567
+ return null;
6568
+ }
6569
+ function shouldShowGermButton(input) {
6570
+ const { audience, ownerDid, viewerDid, ownerFollowsViewer } = input;
6571
+ if (!audience) return false;
6572
+ if (!isStrictDid(ownerDid)) return false;
6573
+ if (viewerDid !== null && !isStrictDid(viewerDid)) return false;
6574
+ if (viewerDid === ownerDid) return false;
6575
+ if (audience === "everyone") return true;
6576
+ return viewerDid !== null && ownerFollowsViewer === true;
6577
+ }
6578
+ function buildGermMessageUrl(input) {
6579
+ const { messageMeUrl, ownerDid, viewerDid, platform } = input;
6580
+ if (!isStrictDid(ownerDid)) return null;
6581
+ if (viewerDid !== null && !isStrictDid(viewerDid)) return null;
6582
+ const url = parseGermMessageUrl(messageMeUrl);
6583
+ if (!url) return null;
6584
+ if (platform) {
6585
+ const path = url.pathname;
6586
+ let end = path.length;
6587
+ while (end > 0 && path[end - 1] === "/") end--;
6588
+ url.pathname = `${path.slice(0, end)}/${platform}`;
6589
+ }
6590
+ url.hash = viewerDid ? `${ownerDid}+${viewerDid}` : ownerDid;
6591
+ return url.toString();
6592
+ }
6593
+ function germPlatformFromUserAgent(userAgent) {
6594
+ if (!userAgent) return "web";
6595
+ if (/\b(iPhone|iPad|iPod)\b/.test(userAgent)) return "iOS";
6596
+ if (/\bAndroid\b/i.test(userAgent)) return "android";
6597
+ return "web";
6598
+ }
6599
+
6537
6600
  // src/logic/actor-identity.ts
6538
6601
  function actorShowsIdentity(actor) {
6539
6602
  return !!(actor.confirmed || actor.claimed);
@@ -7069,6 +7132,16 @@ var EndorsementRecordSchema = zod.z.object({
7069
7132
  comment: zod.z.string().refine(maxGraphemes(300)).max(3e3).optional(),
7070
7133
  createdAt: datetimeSchema
7071
7134
  });
7135
+ var GERM_SHOW_BUTTON_TO_VALUES = ["none", "usersIFollow", "everyone"];
7136
+ var GermDeclarationRecordSchema = zod.z.object({
7137
+ version: zod.z.string().min(5).max(14),
7138
+ // JSON form (`{ $bytes }`, PDS and Jetstream) or decoded CBOR (`Uint8Array`).
7139
+ currentKey: zod.z.union([zod.z.object({ $bytes: zod.z.string() }), zod.z.instanceof(Uint8Array)]),
7140
+ messageMe: zod.z.object({
7141
+ showButtonTo: zod.z.string().min(1).max(100),
7142
+ messageMeUrl: zod.z.string().min(1).max(2047)
7143
+ }).optional()
7144
+ }).passthrough();
7072
7145
  var OrgEmploymentAttestationRecordSchema = zod.z.object({
7073
7146
  subject: didSchema,
7074
7147
  position: strongRefSchema.optional(),
@@ -7855,7 +7928,7 @@ function describeSifaRecord(collection, value) {
7855
7928
  }
7856
7929
 
7857
7930
  // src/index.ts
7858
- var SIFA_SDK_VERSION = "0.19.108";
7931
+ var SIFA_SDK_VERSION = "0.19.109";
7859
7932
 
7860
7933
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
7861
7934
  exports.ACTIVITY_VERBS = ACTIVITY_VERBS;
@@ -7915,6 +7988,9 @@ exports.FollowFeedItemSchema = FollowFeedItemSchema;
7915
7988
  exports.FollowFeedPageSchema = FollowFeedPageSchema;
7916
7989
  exports.FollowProfilePageSchema = FollowProfilePageSchema;
7917
7990
  exports.FollowProfileSchema = FollowProfileSchema;
7991
+ exports.GERM_MESSAGE_HOSTS = GERM_MESSAGE_HOSTS;
7992
+ exports.GERM_SHOW_BUTTON_TO_VALUES = GERM_SHOW_BUTTON_TO_VALUES;
7993
+ exports.GermDeclarationRecordSchema = GermDeclarationRecordSchema;
7918
7994
  exports.GraphFollowRecordSchema = GraphFollowRecordSchema;
7919
7995
  exports.INDUSTRY_LABELS = INDUSTRY_LABELS;
7920
7996
  exports.INDUSTRY_OPTIONS = INDUSTRY_OPTIONS;
@@ -8000,6 +8076,7 @@ exports.agentRefSchema = agentRefSchema;
8000
8076
  exports.appLinksItems = appLinksItems;
8001
8077
  exports.atUriSchema = atUriSchema;
8002
8078
  exports.blobProxyUrl = blobProxyUrl;
8079
+ exports.buildGermMessageUrl = buildGermMessageUrl;
8003
8080
  exports.buildMetaDescription = buildMetaDescription;
8004
8081
  exports.buildProfileHighlights = buildProfileHighlights;
8005
8082
  exports.buildTalkSlug = buildTalkSlug;
@@ -8048,6 +8125,8 @@ exports.formatRelativeTime = formatRelativeTime;
8048
8125
  exports.formatSingleDate = formatSingleDate;
8049
8126
  exports.formatSpanDate = formatSpanDate;
8050
8127
  exports.formatTimelineDate = formatTimelineDate;
8128
+ exports.germButtonAudience = germButtonAudience;
8129
+ exports.germPlatformFromUserAgent = germPlatformFromUserAgent;
8051
8130
  exports.getActivityTaxonomyVersion = getActivityTaxonomyVersion;
8052
8131
  exports.getActivityTier = getActivityTier;
8053
8132
  exports.getActivityVerbsVersion = getActivityVerbsVersion;
@@ -8111,6 +8190,7 @@ exports.isRoleLineRedundant = isRoleLineRedundant;
8111
8190
  exports.isSectionPopulated = isSectionPopulated;
8112
8191
  exports.isSelfAuthoredRich = isSelfAuthoredRich;
8113
8192
  exports.isSiteActivityPresetActive = isSiteActivityPresetActive;
8193
+ exports.isStrictDid = isStrictDid;
8114
8194
  exports.isTeachingCourse = isTeachingCourse;
8115
8195
  exports.isTimelineWorthy = isTimelineWorthy;
8116
8196
  exports.isUpcomingStart = isUpcomingStart;
@@ -8178,6 +8258,7 @@ exports.sanitizeHandleInput = sanitizeHandleInput;
8178
8258
  exports.searchResultDisambiguation = searchResultDisambiguation;
8179
8259
  exports.selfLabelsSchema = selfLabelsSchema;
8180
8260
  exports.shouldRenderHighlights = shouldRenderHighlights;
8261
+ exports.shouldShowGermButton = shouldShowGermButton;
8181
8262
  exports.singleDateExtractor = singleDateExtractor;
8182
8263
  exports.siteActivityPresetSchema = siteActivityPresetSchema;
8183
8264
  exports.siteActivityPresetUpdateSchema = siteActivityPresetUpdateSchema;