techne-sdk 0.0.0-stage → 0.2.0

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 (335) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/LICENSE +21 -0
  3. package/README.md +115 -2
  4. package/dist/auth/index.d.ts +151 -0
  5. package/dist/auth/index.js +167 -0
  6. package/dist/auth/placement.gen.d.ts +1 -0
  7. package/dist/auth/placement.gen.js +49 -0
  8. package/dist/catalog/catalog.gen.d.ts +841 -0
  9. package/dist/catalog/catalog.gen.js +29696 -0
  10. package/dist/catalog/index.d.ts +11 -0
  11. package/dist/catalog/index.js +11 -0
  12. package/dist/connect.d.ts +38 -0
  13. package/dist/connect.js +19 -0
  14. package/dist/generated/index.d.ts +2296 -0
  15. package/dist/generated/index.js +3320 -0
  16. package/dist/generated/lexicons.d.ts +17254 -0
  17. package/dist/generated/lexicons.js +9225 -0
  18. package/dist/generated/nsid.d.ts +529 -0
  19. package/dist/generated/nsid.js +1094 -0
  20. package/dist/generated/nsid.json +1082 -0
  21. package/dist/generated/records.d.ts +143 -0
  22. package/dist/generated/records.js +1 -0
  23. package/dist/generated/types/app/bsky/richtext/facet.d.ts +44 -0
  24. package/dist/generated/types/app/bsky/richtext/facet.js +39 -0
  25. package/dist/generated/types/com/atproto/admin/defs.d.ts +10 -0
  26. package/dist/generated/types/com/atproto/admin/defs.js +11 -0
  27. package/dist/generated/types/com/atproto/label/defs.d.ts +73 -0
  28. package/dist/generated/types/com/atproto/label/defs.js +39 -0
  29. package/dist/generated/types/com/atproto/moderation/createReport.d.ts +39 -0
  30. package/dist/generated/types/com/atproto/moderation/createReport.js +7 -0
  31. package/dist/generated/types/com/atproto/moderation/defs.d.ts +15 -0
  32. package/dist/generated/types/com/atproto/moderation/defs.js +18 -0
  33. package/dist/generated/types/com/atproto/repo/applyWrites.d.ts +88 -0
  34. package/dist/generated/types/com/atproto/repo/applyWrites.js +62 -0
  35. package/dist/generated/types/com/atproto/repo/createRecord.d.ts +43 -0
  36. package/dist/generated/types/com/atproto/repo/createRecord.js +20 -0
  37. package/dist/generated/types/com/atproto/repo/defs.d.ts +11 -0
  38. package/dist/generated/types/com/atproto/repo/defs.js +11 -0
  39. package/dist/generated/types/com/atproto/repo/deleteRecord.d.ts +36 -0
  40. package/dist/generated/types/com/atproto/repo/deleteRecord.js +20 -0
  41. package/dist/generated/types/com/atproto/repo/getRecord.d.ts +35 -0
  42. package/dist/generated/types/com/atproto/repo/getRecord.js +20 -0
  43. package/dist/generated/types/com/atproto/repo/listRecords.d.ts +41 -0
  44. package/dist/generated/types/com/atproto/repo/listRecords.js +14 -0
  45. package/dist/generated/types/com/atproto/repo/putRecord.d.ts +45 -0
  46. package/dist/generated/types/com/atproto/repo/putRecord.js +20 -0
  47. package/dist/generated/types/com/atproto/repo/strongRef.d.ts +11 -0
  48. package/dist/generated/types/com/atproto/repo/strongRef.js +11 -0
  49. package/dist/generated/types/com/atproto/server/getServiceAuth.d.ts +29 -0
  50. package/dist/generated/types/com/atproto/server/getServiceAuth.js +20 -0
  51. package/dist/generated/types/community/lexicon/calendar/event.d.ts +65 -0
  52. package/dist/generated/types/community/lexicon/calendar/event.js +35 -0
  53. package/dist/generated/types/community/lexicon/calendar/rsvp.d.ts +20 -0
  54. package/dist/generated/types/community/lexicon/calendar/rsvp.js +18 -0
  55. package/dist/generated/types/community/lexicon/location/address.d.ts +22 -0
  56. package/dist/generated/types/community/lexicon/location/address.js +11 -0
  57. package/dist/generated/types/community/lexicon/location/fsq.d.ts +16 -0
  58. package/dist/generated/types/community/lexicon/location/fsq.js +11 -0
  59. package/dist/generated/types/community/lexicon/location/geo.d.ts +15 -0
  60. package/dist/generated/types/community/lexicon/location/geo.js +11 -0
  61. package/dist/generated/types/community/lexicon/location/hthree.d.ts +14 -0
  62. package/dist/generated/types/community/lexicon/location/hthree.js +11 -0
  63. package/dist/generated/types/pub/techne/draft/accessRule.d.ts +36 -0
  64. package/dist/generated/types/pub/techne/draft/accessRule.js +33 -0
  65. package/dist/generated/types/pub/techne/draft/accountLink.d.ts +16 -0
  66. package/dist/generated/types/pub/techne/draft/accountLink.js +12 -0
  67. package/dist/generated/types/pub/techne/draft/actor/profile.d.ts +20 -0
  68. package/dist/generated/types/pub/techne/draft/actor/profile.js +12 -0
  69. package/dist/generated/types/pub/techne/draft/appAccess.d.ts +25 -0
  70. package/dist/generated/types/pub/techne/draft/appAccess.js +19 -0
  71. package/dist/generated/types/pub/techne/draft/appAccessRequest.d.ts +16 -0
  72. package/dist/generated/types/pub/techne/draft/appAccessRequest.js +12 -0
  73. package/dist/generated/types/pub/techne/draft/appConfig.d.ts +24 -0
  74. package/dist/generated/types/pub/techne/draft/appConfig.js +19 -0
  75. package/dist/generated/types/pub/techne/draft/approval.d.ts +18 -0
  76. package/dist/generated/types/pub/techne/draft/approval.js +12 -0
  77. package/dist/generated/types/pub/techne/draft/assessment.d.ts +36 -0
  78. package/dist/generated/types/pub/techne/draft/assessment.js +26 -0
  79. package/dist/generated/types/pub/techne/draft/attentionPrefs.d.ts +14 -0
  80. package/dist/generated/types/pub/techne/draft/attentionPrefs.js +12 -0
  81. package/dist/generated/types/pub/techne/draft/beacon.d.ts +17 -0
  82. package/dist/generated/types/pub/techne/draft/beacon.js +12 -0
  83. package/dist/generated/types/pub/techne/draft/beaconLists.d.ts +13 -0
  84. package/dist/generated/types/pub/techne/draft/beaconLists.js +12 -0
  85. package/dist/generated/types/pub/techne/draft/beaconSpot.d.ts +17 -0
  86. package/dist/generated/types/pub/techne/draft/beaconSpot.js +12 -0
  87. package/dist/generated/types/pub/techne/draft/block.d.ts +14 -0
  88. package/dist/generated/types/pub/techne/draft/block.js +12 -0
  89. package/dist/generated/types/pub/techne/draft/channelVerification.d.ts +15 -0
  90. package/dist/generated/types/pub/techne/draft/channelVerification.js +12 -0
  91. package/dist/generated/types/pub/techne/draft/circleBeacon.d.ts +14 -0
  92. package/dist/generated/types/pub/techne/draft/circleBeacon.js +12 -0
  93. package/dist/generated/types/pub/techne/draft/collective.d.ts +29 -0
  94. package/dist/generated/types/pub/techne/draft/collective.js +12 -0
  95. package/dist/generated/types/pub/techne/draft/commons/createServiceAccount.d.ts +47 -0
  96. package/dist/generated/types/pub/techne/draft/commons/createServiceAccount.js +55 -0
  97. package/dist/generated/types/pub/techne/draft/commons/getVersions.d.ts +78 -0
  98. package/dist/generated/types/pub/techne/draft/commons/getVersions.js +41 -0
  99. package/dist/generated/types/pub/techne/draft/commons/moveAccountHandle.d.ts +45 -0
  100. package/dist/generated/types/pub/techne/draft/commons/moveAccountHandle.js +48 -0
  101. package/dist/generated/types/pub/techne/draft/commons/runChain.d.ts +53 -0
  102. package/dist/generated/types/pub/techne/draft/commons/runChain.js +34 -0
  103. package/dist/generated/types/pub/techne/draft/connection.d.ts +16 -0
  104. package/dist/generated/types/pub/techne/draft/connection.js +12 -0
  105. package/dist/generated/types/pub/techne/draft/contact.d.ts +20 -0
  106. package/dist/generated/types/pub/techne/draft/contact.js +12 -0
  107. package/dist/generated/types/pub/techne/draft/contactChannel.d.ts +18 -0
  108. package/dist/generated/types/pub/techne/draft/contactChannel.js +12 -0
  109. package/dist/generated/types/pub/techne/draft/contactList.d.ts +14 -0
  110. package/dist/generated/types/pub/techne/draft/contactList.js +12 -0
  111. package/dist/generated/types/pub/techne/draft/containedIn.d.ts +17 -0
  112. package/dist/generated/types/pub/techne/draft/containedIn.js +12 -0
  113. package/dist/generated/types/pub/techne/draft/credential.d.ts +39 -0
  114. package/dist/generated/types/pub/techne/draft/credential.js +19 -0
  115. package/dist/generated/types/pub/techne/draft/credentialRevocation.d.ts +14 -0
  116. package/dist/generated/types/pub/techne/draft/credentialRevocation.js +12 -0
  117. package/dist/generated/types/pub/techne/draft/derivation.d.ts +50 -0
  118. package/dist/generated/types/pub/techne/draft/derivation.js +26 -0
  119. package/dist/generated/types/pub/techne/draft/description.d.ts +17 -0
  120. package/dist/generated/types/pub/techne/draft/description.js +12 -0
  121. package/dist/generated/types/pub/techne/draft/distinctFrom.d.ts +15 -0
  122. package/dist/generated/types/pub/techne/draft/distinctFrom.js +12 -0
  123. package/dist/generated/types/pub/techne/draft/evaluation.d.ts +18 -0
  124. package/dist/generated/types/pub/techne/draft/evaluation.js +12 -0
  125. package/dist/generated/types/pub/techne/draft/event/config.d.ts +22 -0
  126. package/dist/generated/types/pub/techne/draft/event/config.js +12 -0
  127. package/dist/generated/types/pub/techne/draft/event/detail.d.ts +25 -0
  128. package/dist/generated/types/pub/techne/draft/event/detail.js +12 -0
  129. package/dist/generated/types/pub/techne/draft/event/listing.d.ts +14 -0
  130. package/dist/generated/types/pub/techne/draft/event/listing.js +12 -0
  131. package/dist/generated/types/pub/techne/draft/feed/recipe.d.ts +50 -0
  132. package/dist/generated/types/pub/techne/draft/feed/recipe.js +26 -0
  133. package/dist/generated/types/pub/techne/draft/geo.d.ts +19 -0
  134. package/dist/generated/types/pub/techne/draft/geo.js +12 -0
  135. package/dist/generated/types/pub/techne/draft/heldAt.d.ts +17 -0
  136. package/dist/generated/types/pub/techne/draft/heldAt.js +12 -0
  137. package/dist/generated/types/pub/techne/draft/identity/accountsForPhones.d.ts +43 -0
  138. package/dist/generated/types/pub/techne/draft/identity/accountsForPhones.js +41 -0
  139. package/dist/generated/types/pub/techne/draft/identity/attest.d.ts +48 -0
  140. package/dist/generated/types/pub/techne/draft/identity/attest.js +48 -0
  141. package/dist/generated/types/pub/techne/draft/identity/beginAddMethod.d.ts +35 -0
  142. package/dist/generated/types/pub/techne/draft/identity/beginAddMethod.js +34 -0
  143. package/dist/generated/types/pub/techne/draft/identity/checkLinkToken.d.ts +41 -0
  144. package/dist/generated/types/pub/techne/draft/identity/checkLinkToken.js +41 -0
  145. package/dist/generated/types/pub/techne/draft/identity/createCollective.d.ts +28 -0
  146. package/dist/generated/types/pub/techne/draft/identity/createCollective.js +20 -0
  147. package/dist/generated/types/pub/techne/draft/identity/createLinkToken.d.ts +47 -0
  148. package/dist/generated/types/pub/techne/draft/identity/createLinkToken.js +48 -0
  149. package/dist/generated/types/pub/techne/draft/identity/defs.d.ts +75 -0
  150. package/dist/generated/types/pub/techne/draft/identity/defs.js +53 -0
  151. package/dist/generated/types/pub/techne/draft/identity/finishAddMethod.d.ts +46 -0
  152. package/dist/generated/types/pub/techne/draft/identity/finishAddMethod.js +34 -0
  153. package/dist/generated/types/pub/techne/draft/identity/fold.d.ts +37 -0
  154. package/dist/generated/types/pub/techne/draft/identity/fold.js +34 -0
  155. package/dist/generated/types/pub/techne/draft/identity/holdForPhone.d.ts +54 -0
  156. package/dist/generated/types/pub/techne/draft/identity/holdForPhone.js +41 -0
  157. package/dist/generated/types/pub/techne/draft/identity/link.d.ts +35 -0
  158. package/dist/generated/types/pub/techne/draft/identity/link.js +34 -0
  159. package/dist/generated/types/pub/techne/draft/identity/linkRedeemed.d.ts +46 -0
  160. package/dist/generated/types/pub/techne/draft/identity/linkRedeemed.js +48 -0
  161. package/dist/generated/types/pub/techne/draft/identity/linkRedemption.d.ts +18 -0
  162. package/dist/generated/types/pub/techne/draft/identity/linkRedemption.js +12 -0
  163. package/dist/generated/types/pub/techne/draft/identity/listLinkRedemptions.d.ts +36 -0
  164. package/dist/generated/types/pub/techne/draft/identity/listLinkRedemptions.js +41 -0
  165. package/dist/generated/types/pub/techne/draft/identity/listLinkTokens.d.ts +39 -0
  166. package/dist/generated/types/pub/techne/draft/identity/listLinkTokens.js +41 -0
  167. package/dist/generated/types/pub/techne/draft/identity/listMethods.d.ts +24 -0
  168. package/dist/generated/types/pub/techne/draft/identity/listMethods.js +20 -0
  169. package/dist/generated/types/pub/techne/draft/identity/listPhoneHolds.d.ts +49 -0
  170. package/dist/generated/types/pub/techne/draft/identity/listPhoneHolds.js +34 -0
  171. package/dist/generated/types/pub/techne/draft/identity/redeemLinkToken.d.ts +47 -0
  172. package/dist/generated/types/pub/techne/draft/identity/redeemLinkToken.js +55 -0
  173. package/dist/generated/types/pub/techne/draft/identity/releasePhoneHold.d.ts +32 -0
  174. package/dist/generated/types/pub/techne/draft/identity/releasePhoneHold.js +34 -0
  175. package/dist/generated/types/pub/techne/draft/identity/resetLinkToken.d.ts +45 -0
  176. package/dist/generated/types/pub/techne/draft/identity/resetLinkToken.js +48 -0
  177. package/dist/generated/types/pub/techne/draft/identity/resolve.d.ts +39 -0
  178. package/dist/generated/types/pub/techne/draft/identity/resolve.js +34 -0
  179. package/dist/generated/types/pub/techne/draft/identity/revokeLinkToken.d.ts +36 -0
  180. package/dist/generated/types/pub/techne/draft/identity/revokeLinkToken.js +41 -0
  181. package/dist/generated/types/pub/techne/draft/identity/unlinkAccount.d.ts +29 -0
  182. package/dist/generated/types/pub/techne/draft/identity/unlinkAccount.js +27 -0
  183. package/dist/generated/types/pub/techne/draft/identity/unlinkMethod.d.ts +32 -0
  184. package/dist/generated/types/pub/techne/draft/identity/unlinkMethod.js +34 -0
  185. package/dist/generated/types/pub/techne/draft/interest.d.ts +14 -0
  186. package/dist/generated/types/pub/techne/draft/interest.js +12 -0
  187. package/dist/generated/types/pub/techne/draft/introProposal.d.ts +28 -0
  188. package/dist/generated/types/pub/techne/draft/introProposal.js +19 -0
  189. package/dist/generated/types/pub/techne/draft/invite.d.ts +16 -0
  190. package/dist/generated/types/pub/techne/draft/invite.js +12 -0
  191. package/dist/generated/types/pub/techne/draft/market/ask.d.ts +18 -0
  192. package/dist/generated/types/pub/techne/draft/market/ask.js +12 -0
  193. package/dist/generated/types/pub/techne/draft/market/offer.d.ts +14 -0
  194. package/dist/generated/types/pub/techne/draft/market/offer.js +12 -0
  195. package/dist/generated/types/pub/techne/draft/membership.d.ts +22 -0
  196. package/dist/generated/types/pub/techne/draft/membership.js +12 -0
  197. package/dist/generated/types/pub/techne/draft/notificationState.d.ts +18 -0
  198. package/dist/generated/types/pub/techne/draft/notificationState.js +12 -0
  199. package/dist/generated/types/pub/techne/draft/operator.d.ts +20 -0
  200. package/dist/generated/types/pub/techne/draft/operator.js +12 -0
  201. package/dist/generated/types/pub/techne/draft/org.d.ts +42 -0
  202. package/dist/generated/types/pub/techne/draft/org.js +19 -0
  203. package/dist/generated/types/pub/techne/draft/passage.d.ts +18 -0
  204. package/dist/generated/types/pub/techne/draft/passage.js +12 -0
  205. package/dist/generated/types/pub/techne/draft/pendingBeaconSpot.d.ts +19 -0
  206. package/dist/generated/types/pub/techne/draft/pendingBeaconSpot.js +12 -0
  207. package/dist/generated/types/pub/techne/draft/permissioned/deleteRecord.d.ts +47 -0
  208. package/dist/generated/types/pub/techne/draft/permissioned/deleteRecord.js +55 -0
  209. package/dist/generated/types/pub/techne/draft/permissioned/getGrants.d.ts +32 -0
  210. package/dist/generated/types/pub/techne/draft/permissioned/getGrants.js +34 -0
  211. package/dist/generated/types/pub/techne/draft/permissioned/getRecord.d.ts +36 -0
  212. package/dist/generated/types/pub/techne/draft/permissioned/getRecord.js +34 -0
  213. package/dist/generated/types/pub/techne/draft/permissioned/listChanges.d.ts +71 -0
  214. package/dist/generated/types/pub/techne/draft/permissioned/listChanges.js +41 -0
  215. package/dist/generated/types/pub/techne/draft/permissioned/listRecords.d.ts +53 -0
  216. package/dist/generated/types/pub/techne/draft/permissioned/listRecords.js +34 -0
  217. package/dist/generated/types/pub/techne/draft/permissioned/putRecord.d.ts +70 -0
  218. package/dist/generated/types/pub/techne/draft/permissioned/putRecord.js +76 -0
  219. package/dist/generated/types/pub/techne/draft/permissioned/putRecords.d.ts +84 -0
  220. package/dist/generated/types/pub/techne/draft/permissioned/putRecords.js +69 -0
  221. package/dist/generated/types/pub/techne/draft/place.d.ts +36 -0
  222. package/dist/generated/types/pub/techne/draft/place.js +19 -0
  223. package/dist/generated/types/pub/techne/draft/post.d.ts +30 -0
  224. package/dist/generated/types/pub/techne/draft/post.js +19 -0
  225. package/dist/generated/types/pub/techne/draft/presence.d.ts +16 -0
  226. package/dist/generated/types/pub/techne/draft/presence.js +12 -0
  227. package/dist/generated/types/pub/techne/draft/profile.d.ts +53 -0
  228. package/dist/generated/types/pub/techne/draft/profile.js +33 -0
  229. package/dist/generated/types/pub/techne/draft/provenance.d.ts +52 -0
  230. package/dist/generated/types/pub/techne/draft/provenance.js +33 -0
  231. package/dist/generated/types/pub/techne/draft/publisher.d.ts +43 -0
  232. package/dist/generated/types/pub/techne/draft/publisher.js +19 -0
  233. package/dist/generated/types/pub/techne/draft/query/countRecords.d.ts +47 -0
  234. package/dist/generated/types/pub/techne/draft/query/countRecords.js +34 -0
  235. package/dist/generated/types/pub/techne/draft/query/getRecords.d.ts +86 -0
  236. package/dist/generated/types/pub/techne/draft/query/getRecords.js +48 -0
  237. package/dist/generated/types/pub/techne/draft/query/listRecords.d.ts +83 -0
  238. package/dist/generated/types/pub/techne/draft/query/listRecords.js +34 -0
  239. package/dist/generated/types/pub/techne/draft/query/listRejections.d.ts +50 -0
  240. package/dist/generated/types/pub/techne/draft/query/listRejections.js +27 -0
  241. package/dist/generated/types/pub/techne/draft/questionSet.d.ts +31 -0
  242. package/dist/generated/types/pub/techne/draft/questionSet.js +19 -0
  243. package/dist/generated/types/pub/techne/draft/receipt.d.ts +16 -0
  244. package/dist/generated/types/pub/techne/draft/receipt.js +12 -0
  245. package/dist/generated/types/pub/techne/draft/reflection.d.ts +20 -0
  246. package/dist/generated/types/pub/techne/draft/reflection.js +12 -0
  247. package/dist/generated/types/pub/techne/draft/retirement.d.ts +16 -0
  248. package/dist/generated/types/pub/techne/draft/retirement.js +12 -0
  249. package/dist/generated/types/pub/techne/draft/rsvpNote.d.ts +16 -0
  250. package/dist/generated/types/pub/techne/draft/rsvpNote.js +12 -0
  251. package/dist/generated/types/pub/techne/draft/sameAs.d.ts +15 -0
  252. package/dist/generated/types/pub/techne/draft/sameAs.js +12 -0
  253. package/dist/generated/types/pub/techne/draft/scraper/cursor.d.ts +17 -0
  254. package/dist/generated/types/pub/techne/draft/scraper/cursor.js +12 -0
  255. package/dist/generated/types/pub/techne/draft/scraper/raw.d.ts +31 -0
  256. package/dist/generated/types/pub/techne/draft/scraper/raw.js +12 -0
  257. package/dist/generated/types/pub/techne/draft/share.d.ts +14 -0
  258. package/dist/generated/types/pub/techne/draft/share.js +12 -0
  259. package/dist/generated/types/pub/techne/draft/source.d.ts +23 -0
  260. package/dist/generated/types/pub/techne/draft/source.js +12 -0
  261. package/dist/generated/types/pub/techne/draft/sourceAttribution.d.ts +25 -0
  262. package/dist/generated/types/pub/techne/draft/sourceAttribution.js +12 -0
  263. package/dist/generated/types/pub/techne/draft/sourceRef.d.ts +23 -0
  264. package/dist/generated/types/pub/techne/draft/sourceRef.js +12 -0
  265. package/dist/generated/types/pub/techne/draft/subjectPrefs.d.ts +18 -0
  266. package/dist/generated/types/pub/techne/draft/subjectPrefs.js +12 -0
  267. package/dist/generated/types/pub/techne/draft/sync/indexRecord.d.ts +48 -0
  268. package/dist/generated/types/pub/techne/draft/sync/indexRecord.js +55 -0
  269. package/dist/generated/types/pub/techne/draft/verdict.d.ts +16 -0
  270. package/dist/generated/types/pub/techne/draft/verdict.js +12 -0
  271. package/dist/generated/types/pub/techne/draft/verification.d.ts +14 -0
  272. package/dist/generated/types/pub/techne/draft/verification.js +12 -0
  273. package/dist/generated/types/pub/techne/draft/weeklyCheckIn.d.ts +21 -0
  274. package/dist/generated/types/pub/techne/draft/weeklyCheckIn.js +12 -0
  275. package/dist/generated/types/social/scenius/approveAppAccess.d.ts +36 -0
  276. package/dist/generated/types/social/scenius/approveAppAccess.js +27 -0
  277. package/dist/generated/types/social/scenius/createCirclePost.d.ts +39 -0
  278. package/dist/generated/types/social/scenius/createCirclePost.js +41 -0
  279. package/dist/generated/types/social/scenius/createContactInvite.d.ts +41 -0
  280. package/dist/generated/types/social/scenius/createContactInvite.js +34 -0
  281. package/dist/generated/types/social/scenius/deleteCirclePost.d.ts +34 -0
  282. package/dist/generated/types/social/scenius/deleteCirclePost.js +34 -0
  283. package/dist/generated/types/social/scenius/deleteCircleProfile.d.ts +33 -0
  284. package/dist/generated/types/social/scenius/deleteCircleProfile.js +34 -0
  285. package/dist/generated/types/social/scenius/getAppAccess.d.ts +30 -0
  286. package/dist/generated/types/social/scenius/getAppAccess.js +27 -0
  287. package/dist/generated/types/social/scenius/getAppConfig.d.ts +26 -0
  288. package/dist/generated/types/social/scenius/getAppConfig.js +7 -0
  289. package/dist/generated/types/social/scenius/getCircleThread.d.ts +48 -0
  290. package/dist/generated/types/social/scenius/getCircleThread.js +41 -0
  291. package/dist/generated/types/social/scenius/getContactInvite.d.ts +37 -0
  292. package/dist/generated/types/social/scenius/getContactInvite.js +27 -0
  293. package/dist/generated/types/social/scenius/listAppAccess.d.ts +35 -0
  294. package/dist/generated/types/social/scenius/listAppAccess.js +27 -0
  295. package/dist/generated/types/social/scenius/listCirclePosts.d.ts +47 -0
  296. package/dist/generated/types/social/scenius/listCirclePosts.js +34 -0
  297. package/dist/generated/types/social/scenius/listCircleProfiles.d.ts +50 -0
  298. package/dist/generated/types/social/scenius/listCircleProfiles.js +41 -0
  299. package/dist/generated/types/social/scenius/previewContactInvite.d.ts +37 -0
  300. package/dist/generated/types/social/scenius/previewContactInvite.js +34 -0
  301. package/dist/generated/types/social/scenius/putCircleProfile.d.ts +39 -0
  302. package/dist/generated/types/social/scenius/putCircleProfile.js +41 -0
  303. package/dist/generated/types/social/scenius/redeemContactInvite.d.ts +43 -0
  304. package/dist/generated/types/social/scenius/redeemContactInvite.js +48 -0
  305. package/dist/generated/types/social/scenius/revokeContactInvite.d.ts +33 -0
  306. package/dist/generated/types/social/scenius/revokeContactInvite.js +20 -0
  307. package/dist/generated/util.d.ts +36 -0
  308. package/dist/generated/util.js +32 -0
  309. package/dist/links/index.d.ts +65 -0
  310. package/dist/links/index.js +119 -0
  311. package/dist/platform.d.ts +14 -0
  312. package/dist/platform.js +16 -0
  313. package/dist/put/contacts.d.ts +29 -0
  314. package/dist/put/contacts.js +109 -0
  315. package/dist/put/index.d.ts +148 -0
  316. package/dist/put/index.js +252 -0
  317. package/dist/query/hosts.d.ts +77 -0
  318. package/dist/query/hosts.js +227 -0
  319. package/dist/query/index.d.ts +201 -0
  320. package/dist/query/index.js +167 -0
  321. package/dist/versions/index.d.ts +121 -0
  322. package/dist/versions/index.js +90 -0
  323. package/dist/versions/react.d.ts +53 -0
  324. package/dist/versions/react.js +81 -0
  325. package/dist/wasm/index.d.ts +85 -0
  326. package/dist/wasm/index.js +51 -0
  327. package/dist/wasm/load.d.ts +2 -0
  328. package/dist/wasm/load.js +16 -0
  329. package/dist/wasm/load.native.d.ts +11 -0
  330. package/dist/wasm/load.native.js +3 -0
  331. package/dist/wasm/techne-wasm.gen.d.ts +2 -0
  332. package/dist/wasm/techne-wasm.gen.js +3 -0
  333. package/dist/wasm/techne-wasm2js.gen.d.ts +6 -0
  334. package/dist/wasm/techne-wasm2js.gen.js +90467 -0
  335. package/package.json +136 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,54 @@
1
+ # Changelog
2
+
3
+ `techne-sdk` on npm and the `techne-sdk` crate share a version. Each entry names what changes for an app or
4
+ a crate user.
5
+
6
+ ## 0.2.0
7
+
8
+ ### Changed: the verifier trusts operator-issued credentials (option (b))
9
+
10
+ `verify` (Rust `techne_sdk::verify`, `techne-sdk/wasm` in TypeScript) now trusts what the platform trusts
11
+ (regenOS `ee38bb7d7`, `provenancePolicy#vouchedWriter` at lexicons `v0.1.22-techne.45`):
12
+
13
+ - **Operator-issued credentials.** A credential counts when its issuer is the commons root, or an operator
14
+ named by one of the root's intact `pub.techne.draft.operator` records for a period that holds at the
15
+ credential's first-seen time (`validFrom` inclusive, `validUntil` exclusive, an absent `validUntil` is
16
+ open). With no first-seen time, only an open period holds. 0.1.0 trusted root-issued credentials only.
17
+ - **Root same-rkey revocation.** A credential is revoked by a record at its own revocation address, as
18
+ before, or at the same rkey in the root's repo.
19
+ - Both apply to `decide`'s `vouchedWriter` verdicts and to `chainVerified`.
20
+
21
+ **Breaking (Rust):** `verify::Record` gains `pub first_seen: Option<String>` (`firstSeen` in JSON,
22
+ absent by default). Code that builds a `Record` with a struct literal no longer compiles until it adds the
23
+ field, e.g. `first_seen: None`. That is why this release is 0.2.0: a `techne-sdk = "0.1"` requirement does
24
+ not pick it up; move to `"0.2"` and add the field. JSON input without `firstSeen` still parses. In TypeScript `ReadRecord` gains an
25
+ optional `firstSeen`, so nothing breaks there.
26
+
27
+ ### Added: `techne-sdk/auth`
28
+
29
+ Browser OAuth sign-in ("Sign in with Techne"): `signIn`, `signUp`, `restore`, `signOut`,
30
+ `onSessionDeleted`, `clientMetadata`, `scopes`, `includeScope`, `resolveClientId`,
31
+ `setOAuthClientFactory`, `redirectState` (the `state` a sign-in sent, after its redirect), and the
32
+ constants `TECHNE_PLATFORM_DID`, `TECHNE_TOWN`, `TECHNE_TOWN_PDS`. `clientMetadata` answers
33
+ `@atproto/oauth-types`' `OAuthClientMetadataInput`. The React half (`techne-sdk/auth/react`:
34
+ `TechneProvider`, `SignInWithTechne`) is not included yet.
35
+
36
+ New dependencies for every install, whether or not an app imports `techne-sdk/auth`:
37
+ `@atproto/oauth-client-browser` (loaded only on first use, so it stays out of bundles that do not sign
38
+ in) and `@atproto/oauth-types`. Some of what they pull in declares Node >= 22, as this repo already
39
+ requires; npm warns (or fails under `engine-strict`) on older Node.
40
+
41
+ ### Changed: inputs
42
+
43
+ - Lexicons pinned at `v0.1.22-techne.45` (check `techne-lexicon-check` 0.3.0) and the platform's published
44
+ API at regenOS `ee38bb7d7`. Types and clients are regenerated from them.
45
+
46
+ ### Docs
47
+
48
+ - The techne.town defaults go live at the Techne release. Until then, pass `pds` (and `plcUrl`,
49
+ `handleDomain`, `platform`) explicitly; ask the Techne team for the current staging values. Neither the
50
+ package nor the crate names a staging host.
51
+
52
+ ## 0.1.0
53
+
54
+ First release, on npm and crates.io.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Techne Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,116 @@
1
- # Temporary Holding Version
1
+ # techne-sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ TechneSDK for apps on the Techne platform: sign in, `put`, query, `useEvent` and the read-time check.
4
+
5
+ - **npm:** one package, `techne-sdk`, with subpaths.
6
+ - **Rust:** the crate `techne-sdk` (`crates/techne-sdk`). It holds the logic that must give the platform's answers exactly: the check, the version ranking (`eventState`) and `put`'s private-first, public-last plan. The npm package runs the same crate as WebAssembly, or as wasm2js on hosts without WebAssembly (Hermes). Opt-in features add the atproto plumbing services share (no platform crate either): `crypto` for service-auth JWTs, signed labels, record proofs and service-account passwords, and `net` for DID resolution, verified record fetches and PDS password sessions.
7
+
8
+ The SDK depends on two things only: the published lexicons (the `lexicons` repo at a tag) and the platform's published API. It contains no platform code.
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ npm i techne-sdk # react >= 19 is an optional peer, needed only for techne-sdk/react
14
+ ```
15
+
16
+ Every import goes through the package's `exports`, so the resolver has to read them:
17
+
18
+ - TypeScript: `moduleResolution` `node16`, `nodenext` or `bundler`. Under the old `node` (node10) mode the subpath types do not resolve.
19
+ - React Native: Metro with package exports on (`unstable_enablePackageExports`, the default from Expo SDK 53). `techne-sdk/wasm` loads the check through `techne-sdk/wasm/load`, whose `react-native` condition picks the wasm2js build (Hermes has no WebAssembly); that file is ESM that calls Metro's `require`.
20
+
21
+ | Import | What it holds |
22
+ |---|---|
23
+ | `techne-sdk` (also `techne-sdk/generated`) | the generated XRPC client (`AtpBaseClient`) and every lexicon type |
24
+ | `techne-sdk/lexicons` | the generated lexicon dictionary (`schemaDict`, `schemas`, `lexicons`, `ids`): every lexicon document the client was built from, for reading descriptions at run time (large; keep it server side) |
25
+ | `techne-sdk/types/<nsid path>` | one lexicon's types, e.g. `techne-sdk/types/social/scenius/getContactInvite` |
26
+ | `techne-sdk/react` | `useEvent(uri)`: one commons event or place as its versions, with the check's verdict |
27
+ | `techne-sdk/versions` | the same state without React: `eventState`, `verifyAnswer`, version labels |
28
+ | `techne-sdk/auth` | sign-in ("Sign in with Techne"): `signIn`, `signUp`, `restore`, `signOut`, `clientMetadata`, `scopes` (browser OAuth) |
29
+ | `techne-sdk/connect` | `connect(session, platform)` / `connectHosted(did, fetchHandler)`: the clients over one session |
30
+ | `techne-sdk/put` | `put(techne, records, { deletes })`: the one write, deletes included |
31
+ | `techne-sdk/query` | the platform's generic queries: `listRecords`, `getRecords`, hosts |
32
+ | `techne-sdk/links` | link tokens: create, redeem, check, revoke |
33
+ | `techne-sdk/wasm` | the check itself: `validate`, `decide`, `verify` |
34
+ | `techne-sdk/catalog` | the browsable lexicon catalog |
35
+ | `techne-sdk/nsid`, `techne-sdk/nsid.json` | every NSID as a constant (`NSID`, `METHOD`) |
36
+
37
+ Datetime fields are plain strings: send `Date.prototype.toISOString()` (UTC, trailing `Z`).
38
+
39
+ Reading one event (the platform's `getVersions` is public, so an anonymous client will do):
40
+
41
+ ```tsx
42
+ import { AtpBaseClient } from 'techne-sdk'
43
+ import { useEvent } from 'techne-sdk/react'
44
+
45
+ const platform = new AtpBaseClient({ service: 'https://<platform host>' })
46
+ const load = async (uri: string) => (await platform.pub.techne.draft.commons.getVersions({ uri })).data
47
+
48
+ function Event({ uri }: { uri: string }) {
49
+ const { loading, error, fields } = useEvent(uri, { load })
50
+ if (loading) return <p>Loading</p>
51
+ if (error) return <p>Could not load it</p>
52
+ return <h1>{String(fields?.name?.value ?? '')}</h1>
53
+ }
54
+ ```
55
+
56
+ Pass `{ claims }` too, and `verification` holds the check's answer for every record (valid, signer, chain verified).
57
+
58
+ ## Sign in with Techne
59
+
60
+ `techne-sdk/auth` signs a person in from the browser. Each app is its own atproto OAuth client, the way "Sign in with Google" works: the app serves its client metadata at its client id, the person signs in at their own PDS, and the app keeps the session (an `OAuthSession`, with `did` and `fetchHandler`) that `connect` takes. It runs on `@atproto/oauth-client-browser`, loaded the first time it is used.
61
+
62
+ ```ts
63
+ import { clientMetadata, restore, signIn, TECHNE_PLATFORM_DID } from 'techne-sdk/auth'
64
+ import { connect } from 'techne-sdk/connect'
65
+
66
+ const clientId = 'https://cafes.example/oauth-client-metadata.json'
67
+
68
+ // Serve this JSON at clientId (a static file or a route).
69
+ const metadata = clientMetadata({ clientId, clientName: 'Cafe finder' })
70
+
71
+ // On every page load: finishes a sign-in when the page is the redirect back, else restores a kept session.
72
+ const session = await restore({ clientId })
73
+ if (!session) await signIn({ clientId, handle: 'alice' }) // alice.techne.town, once techne.town is live (see below)
74
+ else {
75
+ const techne = connect(session, TECHNE_PLATFORM_DID)
76
+ }
77
+ ```
78
+
79
+ - **Who:** with no `handle`, the sign-in starts at the default PDS (techne.town), which asks who you are. A bare name (`alice`) is a handle on the default handle domain. A full handle, a DID or a PDS URL from any PDS is used as given. `signUp({ clientId })` opens the PDS's create-account screen.
80
+ - **Scopes:** `scopes()` is what it asks for by default: `atproto`, the platform's `authRead` and `authWrite` permission sets with the platform as their audience, and a `repo:` scope for the public `community.lexicon.*` records. `clientMetadata` lists the same scopes, so the two always match. Pass `scope` to ask for other scopes, and pass it to both.
81
+ - **Development:** on `localhost` or `127.0.0.1` you can leave `clientId` out. The SDK then uses atproto's loopback client, so you don't need to host anything.
82
+ - **Sessions:** the library refreshes tokens itself. `restore` returns the session, `null` when nobody is signed in, and rejects when a sign-in or refresh failed. `signOut({ clientId, session })` revokes the session. `onSessionDeleted` tells you when the library drops a session. A `state` passed to `signIn` comes back from `redirectState({ clientId })` on the page the redirect lands on.
83
+ - **Another deployment:** `platform` names the platform's DID (`TECHNE_PLATFORM_DID` by default). `pds`, `plcUrl` and `handleDomain` name the PDS people sign in at, its PLC directory and its handle domain. Pass them the same way to every call.
84
+
85
+ **Before the Techne release:** the techne.town defaults (`TECHNE_PLATFORM_DID`, the techne.town PDS and handle domain) go live at the Techne release. Until then, `signIn()` without `pds` fails: pass `pds`, `plcUrl`, `handleDomain` and `platform` explicitly, and ask the Techne team for the current staging values.
86
+
87
+ ## Layout
88
+
89
+ | Path | What |
90
+ |---|---|
91
+ | `src/` | the TypeScript package. `src/generated/`, `src/catalog/catalog.gen.ts` and `src/wasm/*.gen.*` are generated and committed |
92
+ | `crates/techne-sdk/` | the Rust crate, with the shared fixtures (`fixtures/cases.json`) both languages must answer identically |
93
+ | `inputs/` | the codegen inputs, copied by `scripts/inputs-sync.mjs` and pinned in `inputs.pin.json`: `inputs/lexicons/` (the lexicons repo at `lexicons.tag`) and `inputs/platform-api/` (the platform's routed method lexicons, the atproto methods it serves and its NSID rename map, at `platformApi.rev`) |
94
+ | `lexicons-base/` | standard atproto repo-op lexicons the generated client needs |
95
+ | `dev-pds/` | a real atproto PDS and PLC in one Node process, for end-to-end runs against a platform |
96
+ | `scripts/` | codegen (`gen.sh`), the WebAssembly build (`build-wasm.sh`), the package build (`build.mjs`), the gate |
97
+
98
+ ## Changing it
99
+
100
+ - **A lexicon changed:** tag the lexicons repo. Set `lexicons.tag` and `lexicons.commit` in `inputs.pin.json` and the `techne-lexicon-check` tag in `Cargo.toml`, then run `cargo update -p techne-lexicon-check` and `node scripts/inputs-sync.mjs --lexicons <lexicons checkout> --platform <platform checkout>`. Then run `npm run codegen` and commit.
101
+ - **The platform's API changed:** set `platformApi.rev` (a platform tag for releases), then run the same sync and codegen.
102
+ - **The Rust logic changed:** edit `crates/techne-sdk` and run `npm run codegen` (it rebuilds the WebAssembly). The fixtures must still agree.
103
+
104
+ `npm run codegen` needs the pinned Rust toolchain (`rust-toolchain.toml`) with the `wasm32-unknown-unknown` target, and `npx` for binaryen. The build is reproducible, so the gate can diff it against the committed one.
105
+
106
+ ## The gate
107
+
108
+ ```sh
109
+ bash scripts/gate.sh # inputs, codegen (no drift), typecheck, test, package, rust
110
+ ```
111
+
112
+ `package` builds `dist/`, then loads every subpath through `exports` in plain Node and runs the fixtures through the built WebAssembly and wasm2js modules. It also checks the `npm pack` file list with a dry run. `rust` runs the same fixtures through the crate.
113
+
114
+ ## Releasing
115
+
116
+ See [RELEASING.md](RELEASING.md).
@@ -0,0 +1,151 @@
1
+ /**
2
+ * techne-sdk/auth — sign-in for an app on Techne ("Sign in with Techne"). Each app is its own atproto OAuth client, the
3
+ * "Sign in with Google" shape: it serves its own client metadata ({@link clientMetadata}) at its client id,
4
+ * the person signs in at their own PDS, and the app holds the session (an OAuthSession: `did` and
5
+ * `fetchHandler`) that `connect` takes. Browser only, over `@atproto/oauth-client-browser`.
6
+ *
7
+ * ```ts
8
+ * const clientId = 'https://cafes.example/oauth-client-metadata.json'
9
+ * const session = await restore({ clientId }) // after the redirect back, or a later visit
10
+ * if (!session) await signIn({ clientId, handle: 'alice' }) // redirects; alice.techne.town
11
+ * const techne = connect(session, TECHNE_PLATFORM_DID)
12
+ * ```
13
+ *
14
+ * What it asks for ({@link scopes}): `atproto`, the platform's two permission sets with the platform's
15
+ * appview as their audience (`include:…authRead?aud=<platform>%23atproto_appview`, and authWrite), and a
16
+ * `repo:` scope for the public homes outside our namespace (`community.lexicon.*`, which a pub.techne set
17
+ * may not name), read from the placement manifest (`placement.gen.ts`). The platform is
18
+ * {@link TECHNE_PLATFORM_DID} unless a `platform` option names another (a test deployment's did:plc).
19
+ *
20
+ * Where it starts: no handle starts at the techne.town PDS ({@link TECHNE_TOWN_PDS}), which asks who you
21
+ * are; a bare name (`alice`) is a techne.town handle (`alice.techne.town`); a full handle, a DID or a PDS
22
+ * URL from any PDS goes as given. `signUp` goes to the techne.town PDS with `prompt: 'create'`, its
23
+ * create-account screen. An app whose people live on another PDS (a test deployment's) names it with the `pds`
24
+ * option, and its PLC directory with `plcUrl`: handles then resolve at that PDS, a sign-in with no
25
+ * handle and every sign-up start there, a bare name takes `handleDomain`, and DIDs resolve at that PLC.
26
+ *
27
+ * On localhost (or 127.0.0.1), or with no client id, the client is atproto's loopback client
28
+ * (`http://localhost?redirect_uri=http://127.0.0.1:<port>/&scope=…`), so an app runs in development with
29
+ * nothing hosted. A page elsewhere with no client id cannot sign in.
30
+ *
31
+ * Restore and refresh. {@link restore} is the library's `init()`: it finishes a sign-in when the page is
32
+ * the redirect back, else restores the session kept in IndexedDB. It does not force a refresh: the
33
+ * library refreshes the tokens when they are about to expire, and again on every request whose token has
34
+ * expired (the session's `fetchHandler` does it), so a restored session is used as it is. It answers the
35
+ * session, `null` when nobody is signed in, and rejects when the sign-in failed (the person said no) or the
36
+ * kept session could not be refreshed (the library has then deleted it); what signed out looks like is the
37
+ * caller's (the React provider shows the anonymous client). One `init()` runs per client however many ask
38
+ * (the redirect's code can be used once), until {@link signOut}. A session the library deletes later (its
39
+ * refresh token revoked) is announced to {@link onSessionDeleted} listeners. The `state` a {@link signIn}
40
+ * sent comes back from {@link redirectState} on the page the redirect lands on (the same `init()`).
41
+ *
42
+ * One BrowserOAuthClient per client id, made on first use. Tests (and other runtimes) inject their own
43
+ * with {@link setOAuthClientFactory}.
44
+ */
45
+ import type { AuthorizeOptions, OAuthSession } from '@atproto/oauth-client-browser';
46
+ import { type OAuthClientMetadataInput } from '@atproto/oauth-types';
47
+ import { TECHNE_PLATFORM_DID } from '../platform.js';
48
+ export { TECHNE_PLATFORM_DID };
49
+ export type { OAuthSession };
50
+ /** The techne.town handle domain: a bare name signs in as `<name>.techne.town`. */
51
+ export declare const TECHNE_TOWN = "techne.town";
52
+ /** The techne.town PDS: where a sign-in with no handle, and every sign-up, starts. */
53
+ export declare const TECHNE_TOWN_PDS = "https://pds.techne.town";
54
+ /** The OAuth client the module drives: what it uses of BrowserOAuthClient. */
55
+ export interface OAuthClientLike {
56
+ init(refresh?: boolean): Promise<{
57
+ session: OAuthSession;
58
+ state?: string | null;
59
+ } | undefined>;
60
+ signInRedirect(input: string, options?: AuthorizeOptions): Promise<unknown>;
61
+ revoke(sub: string): Promise<void>;
62
+ }
63
+ /** What a factory is given to make a client. */
64
+ export interface ClientConfig {
65
+ /** The client id: the app's https metadata URL, or a loopback id. */
66
+ clientId: string;
67
+ /** Where handles are resolved: the home PDS (`pds`, techne.town by default), which answers `resolveHandle`. */
68
+ handleResolver: string;
69
+ /** The PLC directory a did:plc resolves at; the library's (plc.directory) when absent. */
70
+ plcDirectoryUrl?: string;
71
+ /** Call when the library deletes a session (a failed refresh, a revocation). */
72
+ onSessionDeleted: (sub: string, cause: unknown) => void;
73
+ }
74
+ export type OAuthClientFactory = (config: ClientConfig) => OAuthClientLike | Promise<OAuthClientLike>;
75
+ /** Make every client with `make` instead of BrowserOAuthClient (tests, other runtimes); `undefined` goes
76
+ * back to the default. Forgets every client made so far. */
77
+ export declare function setOAuthClientFactory(make: OAuthClientFactory | undefined): void;
78
+ /** What every call takes to name its client. */
79
+ export interface ClientOptions {
80
+ /** The app's client id: the https URL of the metadata it serves (conventionally ending
81
+ * `/oauth-client-metadata.json`). Omitted, or on a loopback page, the loopback client. */
82
+ clientId?: string;
83
+ /** The platform's service DID: the audience of the scopes. {@link TECHNE_PLATFORM_DID} by default. */
84
+ platform?: string;
85
+ /** The scopes to ask for; {@link scopes} by default. */
86
+ scope?: string | readonly string[];
87
+ /** The page's location; `globalThis.location` by default. */
88
+ location?: Pick<Location, 'protocol' | 'hostname' | 'port'>;
89
+ /** The home PDS: where handles resolve, and where a sign-in with no handle and every sign-up start.
90
+ * {@link TECHNE_TOWN_PDS} by default. Read when the client id's client is first made. */
91
+ pds?: string;
92
+ /** The PLC directory a did:plc resolves at (a test deployment may run its own); plc.directory by default. Read when
93
+ * the client id's client is first made. */
94
+ plcUrl?: string;
95
+ /** The handle domain a bare name signs in under; {@link TECHNE_TOWN} by default. */
96
+ handleDomain?: string;
97
+ }
98
+ /** The `include:` scope for the permission set `nsid` with `platform`'s appview as its audience:
99
+ * `include:<nsid>?aud=<platform>%23atproto_appview`. {@link TECHNE_PLATFORM_DID} by default; another
100
+ * platform (a local stack, a test deployment) passes its own DID. */
101
+ export declare function includeScope(nsid: string, platform?: string): string;
102
+ /** The scopes signIn asks for by default (see the module doc). */
103
+ export declare function scopes({ platform }?: {
104
+ platform?: string;
105
+ }): string[];
106
+ /** What {@link clientMetadata} takes. */
107
+ export interface ClientMetadataOptions {
108
+ /** The https URL the document is served at. */
109
+ clientId: string;
110
+ /** Where the sign-in comes back to; `[<origin of clientId>/]` by default. */
111
+ redirectUris?: [string, ...string[]];
112
+ clientName?: string;
113
+ clientUri?: string;
114
+ logoUri?: string;
115
+ /** The scopes, as {@link ClientOptions.scope}. */
116
+ scope?: string | readonly string[];
117
+ platform?: string;
118
+ }
119
+ /** The client-metadata document an app serves at its client id: a public browser client (no secret,
120
+ * DPoP-bound tokens), asking for {@link scopes} by default. */
121
+ export declare function clientMetadata(o: ClientMetadataOptions): OAuthClientMetadataInput;
122
+ /** The client id a call signs in as: the loopback client on a loopback page or with no client id, else
123
+ * `clientId`. */
124
+ export declare function resolveClientId(o: ClientOptions): string;
125
+ /** Listen for the library deleting a session of this client (a refresh that failed, a revocation
126
+ * elsewhere). Answers the unsubscribe. */
127
+ export declare function onSessionDeleted(o: ClientOptions, listener: (sub: string, cause: unknown) => void): () => void;
128
+ /** What {@link signIn} takes. */
129
+ export interface SignInOptions extends ClientOptions {
130
+ /** Who: a bare name (under `handleDomain`), a full handle, a DID or a PDS URL. None starts at the home PDS.
131
+ * With `signUp` only an https PDS URL is used (the PDS to create the account at); any other handle is
132
+ * ignored and the sign-up starts at the home PDS, which asks for the new handle itself. */
133
+ handle?: string;
134
+ /** Create an account at the home PDS (`prompt: 'create'`). */
135
+ signUp?: boolean;
136
+ /** Handed back by the redirect: {@link redirectState} answers it there. */
137
+ state?: string;
138
+ }
139
+ /** Sign in: redirects to the person's PDS, and comes back to the app's redirect URI (then {@link restore}). */
140
+ export declare function signIn(o?: SignInOptions): Promise<void>;
141
+ /** {@link signIn} with `signUp: true`. */
142
+ export declare function signUp(o?: Omit<SignInOptions, 'signUp'>): Promise<void>;
143
+ /** The signed-in session, or `null` (see the module doc for the redirect, refresh and errors). */
144
+ export declare function restore(o?: ClientOptions): Promise<OAuthSession | null>;
145
+ /** The `state` the {@link signIn} that led here sent, on the page its redirect lands on; `null` when the
146
+ * page is not that redirect (a session restored from storage, or nobody signed in). */
147
+ export declare function redirectState(o?: ClientOptions): Promise<string | null>;
148
+ /** Sign out: revokes `session` at its PDS and forgets it here. */
149
+ export declare function signOut(o: ClientOptions & {
150
+ session: Pick<OAuthSession, 'did'>;
151
+ }): Promise<void>;
@@ -0,0 +1,167 @@
1
+ import { buildAtprotoLoopbackClientId, isLoopbackHost } from '@atproto/oauth-types';
2
+ import { NSID } from '../generated/nsid.js';
3
+ import { appviewRef, TECHNE_PLATFORM_DID } from '../platform.js';
4
+ import { PUBLIC_HOMES } from './placement.gen.js';
5
+ export { TECHNE_PLATFORM_DID };
6
+ /** The techne.town handle domain: a bare name signs in as `<name>.techne.town`. */
7
+ export const TECHNE_TOWN = 'techne.town';
8
+ /** The techne.town PDS: where a sign-in with no handle, and every sign-up, starts. */
9
+ export const TECHNE_TOWN_PDS = 'https://pds.techne.town';
10
+ /** The default: a BrowserOAuthClient, loaded on first use (so the module imports under node). For an https
11
+ * client id the library fetches the metadata the app serves; for a loopback id it builds it. */
12
+ const browserFactory = async (config) => {
13
+ const { BrowserOAuthClient } = await import('@atproto/oauth-client-browser');
14
+ return BrowserOAuthClient.load(config);
15
+ };
16
+ let factory = browserFactory;
17
+ const clients = new Map();
18
+ const restoring = new Map();
19
+ const deletedListeners = new Map();
20
+ /** Make every client with `make` instead of BrowserOAuthClient (tests, other runtimes); `undefined` goes
21
+ * back to the default. Forgets every client made so far. */
22
+ export function setOAuthClientFactory(make) {
23
+ factory = make ?? browserFactory;
24
+ clients.clear();
25
+ restoring.clear();
26
+ }
27
+ /** The `include:` scope for the permission set `nsid` with `platform`'s appview as its audience:
28
+ * `include:<nsid>?aud=<platform>%23atproto_appview`. {@link TECHNE_PLATFORM_DID} by default; another
29
+ * platform (a local stack, a test deployment) passes its own DID. */
30
+ export function includeScope(nsid, platform = TECHNE_PLATFORM_DID) {
31
+ return `include:${nsid}?aud=${appviewRef(platform).replace('#', '%23')}`;
32
+ }
33
+ /** The scopes signIn asks for by default (see the module doc). */
34
+ export function scopes({ platform = TECHNE_PLATFORM_DID } = {}) {
35
+ const community = PUBLIC_HOMES.filter((c) => c.startsWith(`${NSID.COMMUNITY_AUTHORITY}.`));
36
+ return ['atproto', includeScope(NSID.AUTH_READ, platform), includeScope(NSID.AUTH_WRITE, platform), ...(community.length ? [repoScope(community)] : [])];
37
+ }
38
+ /** A `repo` scope for `collections`, every action (Rust `nsid_rewrite::repo_scope`). */
39
+ function repoScope(collections) {
40
+ const actions = 'action=create&action=update&action=delete';
41
+ return collections.length === 1 ? `repo:${collections[0]}?${actions}` : `repo?${collections.map((c) => `collection=${c}`).join('&')}&${actions}`;
42
+ }
43
+ const scopeString = (o) => typeof o.scope === 'string' ? o.scope : (o.scope ?? scopes({ platform: o.platform })).join(' ');
44
+ /** The client-metadata document an app serves at its client id: a public browser client (no secret,
45
+ * DPoP-bound tokens), asking for {@link scopes} by default. */
46
+ export function clientMetadata(o) {
47
+ const url = new URL(o.clientId);
48
+ if (url.protocol !== 'https:')
49
+ throw new TypeError(`techne-sdk/auth: a client id is an https URL (got ${o.clientId}); in development leave it out for the loopback client`);
50
+ return {
51
+ client_id: o.clientId,
52
+ ...(o.clientName !== undefined && { client_name: o.clientName }),
53
+ ...(o.clientUri !== undefined && { client_uri: o.clientUri }),
54
+ ...(o.logoUri !== undefined && { logo_uri: o.logoUri }),
55
+ application_type: 'web',
56
+ token_endpoint_auth_method: 'none',
57
+ dpop_bound_access_tokens: true,
58
+ grant_types: ['authorization_code', 'refresh_token'],
59
+ response_types: ['code'],
60
+ scope: scopeString(o),
61
+ redirect_uris: o.redirectUris ?? [`${url.origin}/`],
62
+ };
63
+ }
64
+ /** The client id a call signs in as: the loopback client on a loopback page or with no client id, else
65
+ * `clientId`. */
66
+ export function resolveClientId(o) {
67
+ const location = o.location ?? globalThis.location;
68
+ if (location && isLoopbackHost(location.hostname)) {
69
+ const host = location.hostname === 'localhost' ? '127.0.0.1' : location.hostname;
70
+ const redirect = `http://${host}${location.port ? `:${location.port}` : ''}/`;
71
+ return buildAtprotoLoopbackClientId({ scope: scopeString(o), redirect_uris: [redirect] });
72
+ }
73
+ if (!o.clientId)
74
+ throw new Error('techne-sdk/auth: no clientId (the https URL of the client metadata the app serves); only a localhost page may leave it out');
75
+ return o.clientId;
76
+ }
77
+ const homePds = (o) => o.pds ?? TECHNE_TOWN_PDS;
78
+ /** The OAuth client for these options: one per client id (made with the first call's `pds` and `plcUrl`;
79
+ * a later call naming others for the same client id gets that client). */
80
+ async function oauthClient(o) {
81
+ const clientId = resolveClientId(o);
82
+ let client = clients.get(clientId);
83
+ if (!client) {
84
+ const onSessionDeleted = (sub, cause) => {
85
+ restoring.delete(clientId);
86
+ for (const fn of deletedListeners.get(clientId) ?? [])
87
+ fn(sub, cause);
88
+ };
89
+ const config = { clientId, handleResolver: homePds(o), onSessionDeleted, ...(o.plcUrl && { plcDirectoryUrl: o.plcUrl }) };
90
+ client = Promise.resolve(factory(config));
91
+ client.catch(() => clients.delete(clientId));
92
+ clients.set(clientId, client);
93
+ }
94
+ return client;
95
+ }
96
+ /** Listen for the library deleting a session of this client (a refresh that failed, a revocation
97
+ * elsewhere). Answers the unsubscribe. */
98
+ export function onSessionDeleted(o, listener) {
99
+ const clientId = resolveClientId(o);
100
+ const set = deletedListeners.get(clientId) ?? new Set();
101
+ deletedListeners.set(clientId, set);
102
+ set.add(listener);
103
+ return () => {
104
+ set.delete(listener);
105
+ if (!set.size && deletedListeners.get(clientId) === set)
106
+ deletedListeners.delete(clientId);
107
+ };
108
+ }
109
+ /** Where a sign-in for `handle` starts: see the module doc. */
110
+ function signInTarget(handle, o = {}) {
111
+ const h = handle?.trim().replace(/^@/, '');
112
+ if (!h)
113
+ return homePds(o);
114
+ if (h.startsWith('did:') || /^https?:\/\//.test(h) || h.includes('.'))
115
+ return h;
116
+ return `${h}.${o.handleDomain ?? TECHNE_TOWN}`;
117
+ }
118
+ /** Sign in: redirects to the person's PDS, and comes back to the app's redirect URI (then {@link restore}). */
119
+ export async function signIn(o = {}) {
120
+ const client = await oauthClient(o);
121
+ // A sign-up is at the home PDS unless the app names another PDS by its URL.
122
+ const input = o.signUp ? (o.handle && /^https:\/\//.test(o.handle) ? o.handle : homePds(o)) : signInTarget(o.handle, o);
123
+ const options = { scope: scopeString(o) };
124
+ if (o.signUp)
125
+ options.prompt = 'create';
126
+ if (o.state !== undefined)
127
+ options.state = o.state;
128
+ await client.signInRedirect(input, options);
129
+ }
130
+ /** {@link signIn} with `signUp: true`. */
131
+ export function signUp(o = {}) {
132
+ return signIn({ ...o, signUp: true });
133
+ }
134
+ /** The one `init()` per client id that {@link restore} and {@link redirectState} share. */
135
+ function restored(o) {
136
+ let clientId;
137
+ try {
138
+ clientId = resolveClientId(o);
139
+ }
140
+ catch (e) {
141
+ return Promise.reject(e);
142
+ }
143
+ let pending = restoring.get(clientId);
144
+ if (!pending) {
145
+ pending = oauthClient(o)
146
+ .then((c) => c.init())
147
+ .then((r) => (r ? { session: r.session, state: r.state ?? null } : null));
148
+ pending.catch(() => restoring.delete(clientId));
149
+ restoring.set(clientId, pending);
150
+ }
151
+ return pending;
152
+ }
153
+ /** The signed-in session, or `null` (see the module doc for the redirect, refresh and errors). */
154
+ export function restore(o = {}) {
155
+ return restored(o).then((r) => r?.session ?? null);
156
+ }
157
+ /** The `state` the {@link signIn} that led here sent, on the page its redirect lands on; `null` when the
158
+ * page is not that redirect (a session restored from storage, or nobody signed in). */
159
+ export function redirectState(o = {}) {
160
+ return restored(o).then((r) => r?.state ?? null);
161
+ }
162
+ /** Sign out: revokes `session` at its PDS and forgets it here. */
163
+ export async function signOut(o) {
164
+ const client = await oauthClient(o);
165
+ restoring.delete(resolveClientId(o));
166
+ await client.revoke(o.session.did);
167
+ }
@@ -0,0 +1 @@
1
+ export declare const PUBLIC_HOMES: readonly ["pub.techne.draft.appConfig", "pub.techne.draft.approval", "pub.techne.draft.connection", "pub.techne.draft.contactChannel", "pub.techne.draft.channelVerification", "pub.techne.draft.containedIn", "pub.techne.draft.derivation", "pub.techne.draft.distinctFrom", "pub.techne.draft.geo", "pub.techne.draft.heldAt", "pub.techne.draft.operator", "pub.techne.draft.org", "pub.techne.draft.profile", "pub.techne.draft.assessment", "pub.techne.draft.provenance", "pub.techne.draft.questionSet", "pub.techne.draft.receipt", "pub.techne.draft.verdict", "pub.techne.draft.verification", "pub.techne.draft.retirement", "pub.techne.draft.credential", "pub.techne.draft.credentialRevocation", "pub.techne.draft.publisher", "pub.techne.draft.sameAs", "pub.techne.draft.source", "pub.techne.draft.sourceAttribution", "pub.techne.draft.sourceRef", "pub.techne.draft.evaluation", "pub.techne.draft.event.config", "pub.techne.draft.event.listing", "pub.techne.draft.feed.recipe", "pub.techne.draft.query", "pub.techne.draft.invite", "pub.techne.draft.market.ask", "pub.techne.draft.market.offer", "pub.techne.draft.membership", "pub.techne.draft.place", "pub.techne.draft.presence", "pub.techne.draft.actor.profile", "pub.techne.draft.collective", "community.lexicon.calendar.event", "community.lexicon.calendar.rsvp"];
@@ -0,0 +1,49 @@
1
+ // @generated by scripts/gen-placement.mjs from the placement manifest. DO NOT EDIT BY HAND.
2
+ // The record collections whose legal homes include the public firehose (the placement manifest's
3
+ // `public` list), in the manifest's order. Regenerate: npm run codegen:placement.
4
+ /* eslint-disable */
5
+ import { NSID } from '../generated/nsid.js';
6
+ export const PUBLIC_HOMES = [
7
+ NSID.APP_CONFIG,
8
+ NSID.APPROVAL,
9
+ NSID.CONNECTION,
10
+ NSID.CONTACT_CHANNEL,
11
+ NSID.CHANNEL_VERIFICATION,
12
+ NSID.CONTAINED_IN,
13
+ NSID.DERIVATION,
14
+ NSID.DISTINCT_FROM,
15
+ NSID.GEO,
16
+ NSID.HELD_AT,
17
+ NSID.OPERATOR,
18
+ NSID.ORG,
19
+ NSID.PROFILE,
20
+ NSID.ASSESSMENT,
21
+ NSID.PROVENANCE,
22
+ NSID.QUESTION_SET,
23
+ NSID.RECEIPT,
24
+ NSID.VERDICT,
25
+ NSID.VERIFICATION,
26
+ NSID.RETIREMENT,
27
+ NSID.CREDENTIAL,
28
+ NSID.CREDENTIAL_REVOCATION,
29
+ NSID.PUBLISHER,
30
+ NSID.SAME_AS,
31
+ NSID.SOURCE,
32
+ NSID.SOURCE_ATTRIBUTION,
33
+ NSID.SOURCE_REF,
34
+ NSID.EVALUATION,
35
+ NSID.EVENT_CONFIG,
36
+ NSID.EVENT_LISTING,
37
+ NSID.FEED_RECIPE,
38
+ NSID.QUERY,
39
+ NSID.INVITE,
40
+ NSID.MARKET_ASK,
41
+ NSID.MARKET_OFFER,
42
+ NSID.MEMBERSHIP,
43
+ NSID.PLACE,
44
+ NSID.PRESENCE,
45
+ NSID.ACTOR_PROFILE,
46
+ NSID.COLLECTIVE,
47
+ NSID.CALENDAR_EVENT,
48
+ NSID.CALENDAR_RSVP,
49
+ ];