techne-sdk 0.13.1 → 0.15.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 (39) hide show
  1. package/CHANGELOG.md +93 -3
  2. package/README.md +66 -17
  3. package/dist/auth/hints.d.ts +14 -0
  4. package/dist/auth/hints.js +18 -0
  5. package/dist/auth/index.d.ts +19 -1
  6. package/dist/auth/index.js +48 -1
  7. package/dist/catalog/catalog.gen.d.ts +35 -29
  8. package/dist/catalog/catalog.gen.js +427 -64
  9. package/dist/generated/index.d.ts +56 -0
  10. package/dist/generated/index.js +72 -0
  11. package/dist/generated/lexicons.d.ts +164 -26
  12. package/dist/generated/lexicons.js +84 -12
  13. package/dist/generated/nsid.d.ts +8 -0
  14. package/dist/generated/nsid.js +8 -0
  15. package/dist/generated/nsid.json +8 -0
  16. package/dist/generated/records.d.ts +94 -90
  17. package/dist/generated/types/pub/techne/draft/beacon.d.ts +2 -0
  18. package/dist/generated/types/pub/techne/draft/derivation.d.ts +1 -1
  19. package/dist/generated/types/pub/techne/draft/evaluation.d.ts +3 -1
  20. package/dist/generated/types/pub/techne/draft/follow.d.ts +14 -0
  21. package/dist/generated/types/pub/techne/draft/follow.js +12 -0
  22. package/dist/generated/types/pub/techne/draft/notificationPref.d.ts +16 -0
  23. package/dist/generated/types/pub/techne/draft/notificationPref.js +12 -0
  24. package/dist/generated/types/pub/techne/draft/org.d.ts +2 -2
  25. package/dist/generated/types/pub/techne/draft/statement.d.ts +1 -1
  26. package/dist/query/index.d.ts +3 -2
  27. package/dist/react/sign-in.d.ts +34 -0
  28. package/dist/react/sign-in.js +52 -0
  29. package/dist/session/phone.d.ts +7 -6
  30. package/dist/session/phone.js +7 -6
  31. package/dist/session/relay.d.ts +1 -1
  32. package/dist/session/relay.js +1 -1
  33. package/dist/sign-in/index.d.ts +33 -0
  34. package/dist/sign-in/index.js +479 -0
  35. package/dist/sign-in/styles.d.ts +22 -0
  36. package/dist/sign-in/styles.js +108 -0
  37. package/dist/wasm/techne-wasm.gen.js +1 -1
  38. package/dist/wasm/techne-wasm2js.gen.js +7330 -7332
  39. package/package.json +14 -3
package/CHANGELOG.md CHANGED
@@ -3,10 +3,100 @@
3
3
  `techne-sdk` on npm and the `techne-sdk` crate share a version. Each entry names what changes for an app or
4
4
  a crate user.
5
5
 
6
- ## 0.13.1 (unreleased)
6
+ ## 0.15.0 (2026-12-01)
7
7
 
8
- Inputs only. No export is added, removed or renamed, and no function changes. npm 0.13.1 and crate 0.13.1 are
9
- built from the same commit; the crate's code is unchanged and moves to check 0.3.37.
8
+ Inputs: the hidden guest list, curator follows and notification switches, an evaluation's photo. Exports are
9
+ added; none is removed or renamed, and no function changes meaning. Ship after the platform that reads these lexicons is on prod: an
10
+ older platform refuses a write to `pub.techne.draft.space.audience`, `pub.techne.draft.follow` or
11
+ `pub.techne.draft.notificationPref`, and its policy check denies a `policy#sharedWithIn` leaf. npm 0.15.0
12
+ and crate 0.15.0 are built from the same commit; the crate's code is unchanged and moves to check 0.3.44.
13
+
14
+ ### Added
15
+
16
+ - **`NSID.SPACE_AUDIENCE` and `NSID.SPACE_AUDIENCE_POLICY`** (`pub.techne.draft.space.audience`): the
17
+ kept-apart audience of another space. The shares that admit people to a space sit in its authority's
18
+ audience space at the same key, which only the authority reads, so guests are not listed to each other.
19
+ - **`NSID.POLICY_SHARED_WITH_IN`** (`pub.techne.draft.policy#sharedWithIn`): a policy leaf that admits V when
20
+ the authority's share naming V is in the named sibling space at the same key.
21
+ - **`NSID.FOLLOW`** (`pub.techne.draft.follow`, key = the followed DID; `subject`, `createdAt`) and
22
+ **`NSID.NOTIFICATION_PREF`** (`pub.techne.draft.notificationPref`, key = the kind; `kind`, `enabled`,
23
+ `createdAt`), with their record types. Both are private: write them with `put` and
24
+ `space: at://<your DID>/pub.techne.draft.space.personal/self` (`put` refuses a private record that names no
25
+ space).
26
+ - **`pub.techne.draft.beacon` `guestsHidden`** (optional boolean): the beacon's guests do not see who else it
27
+ was shared with or how they answered. `pub.techne.draft.space.beaconDecline` then holds every answer (its
28
+ name is now "Beacon answer"), and the `space.beacon` read policy gains a `sharedWithIn` leaf naming
29
+ `space.audience`.
30
+ - **NSID constants for the phone sign-in attestation** (`NSID.START_PHONE_SIGNUP_ATTEST`, `_IOS_ATTEST`,
31
+ `_ANDROID_ATTEST`), from the platform's published API. Constants only: `startPhoneSignIn` sends no
32
+ attestation (the platform records it and does not require it).
33
+ - `pub.techne.draft.derivation` signal `name` gains the known value `ladderRung` (the field stays open).
34
+ - **`pub.techne.draft.evaluation` `image`** (optional blob: PNG, JPEG or WebP, at most 2,000,000 bytes): a
35
+ photo of the subject, set by the evaluator and kept in the evaluator's repo. Show it only when the subject
36
+ has no picture of its own. The platform serves it through `getAvatar` (`did` = the evaluator) while a
37
+ public evaluation names it.
38
+
39
+ ### Changed
40
+
41
+ - **Phone sign-in refusals** (`OwnSessionError.code`, the platform's error name passed through). On the
42
+ platform this release pins, `startPhoneSignIn` answers `Unavailable` where it answered
43
+ `OwnSessionUnavailable` (no code could be sent: try again), and `finishPhoneSignIn` drops
44
+ `NewCodeSent` and `OwnSessionUnavailable` and adds `AccountUnavailable` (the number can't sign in here) and
45
+ `NumberRemoved` (sign in with the current number). `created` is true when the platform records the account
46
+ for the first time. The SDK's code is unchanged: these come from the platform, so an app gets them from
47
+ that platform whatever SDK it pins. `addBeaconAudience`, `addGroupMembers`, `createGroup` and `lightBeacon`
48
+ name `RateLimitExceeded`.
49
+ - **`techne-sdk/query` docs**: a query naming no `view` is answered with the old default through 2027-03-01
50
+ (UTC) and refused with `ViewRequired` from 2027-03-02 (the docs said it was refused already). The types
51
+ still require a view.
52
+
53
+ ### Inputs
54
+
55
+ - **Lexicons `v0.1.22-techne.109`, check crate `techne-lexicon-check` 0.3.44** (exact). Also description
56
+ fixes: `space.beaconDecline` (an answer counts for the lighter only from someone they shared the beacon
57
+ with), `placement` (`unbuilt` covers app-written placements), `query` `view` (a query naming no view gets
58
+ the old default until 2027-03-01), `org` and `statement#locations` (curated location statements), `geo`,
59
+ `placeV2` (same-rkey replaces `place`).
60
+ - **Platform API at platform `main` `50a33d887`**. Adds the phone sign-in
61
+ attestation and the refusals above; the other method lexicons change only in descriptions.
62
+
63
+ ## 0.14.0 (2026-11-30)
64
+
65
+ The sign-in form and the "Sign in with Techne" button. Needs the Techne sign-in page (ePDS) that reads a phone
66
+ `login_hint` and `epds_other_ways=1`: ePDS `main` `0831c41`, on prod since 2026-11-30. Exports are added; none
67
+ is removed or renamed, and no function changes meaning. npm only: nothing in the crate's code changed since
68
+ 0.13.1 (only its manifest `description`), so the crate stays 0.13.1.
69
+
70
+ ### Added
71
+
72
+ - **`techne-sdk/sign-in`: `mountSignIn(target, options)` and `mountSignInButton(target, options)`**, each
73
+ answering `{ unmount() }`. The form is the Techne sign-in card for any web page: your logo and name, Email and
74
+ Phone tabs (a country picker inside the card), "Send me a code", "Other ways to sign in" and "Powered by
75
+ Techne". It has one look for every app and keeps one size in every view. It lives in a shadow root, so no
76
+ styles leak either way. README: "The sign-in form".
77
+ - **`techne-sdk/react/sign-in`: `SignInForm` and `SignInButton`**, the same as React components.
78
+ - **`signIn` takes `email`, `phone` (E.164) or `otherWays: true`.** An address or number goes to the sign-in
79
+ page as `login_hint`, so the page sends the code and opens on the code step. `otherWays` opens the page
80
+ with "Other ways to sign in" already open (`epds_other_ways=1`). Both are set on the authorization URL,
81
+ because `@atproto/oauth-client` replaces a `login_hint` passed in its options with its own. The Techne
82
+ sign-in page reads the URL's `login_hint` before the PAR request's.
83
+ - **`OAuthClientLike` gains optional `authorize` and `abortRequest`** (BrowserOAuthClient has both). A client
84
+ injected with `setOAuthClientFactory` needs `authorize` for the three new options.
85
+ - **Dependency: `libphonenumber-js`** (`min` metadata), for the phone field. It is the same reading the
86
+ Techne sign-in page makes.
87
+
88
+ ### Fixed
89
+
90
+ - **`techne-sdk/catalog`: adopted lexicons group under their own authority.** `org.hypercerts.funding.receipt`
91
+ (and its query document) now have `group: 'org.hypercerts'`, and `app.certified.defs` and
92
+ `app.certified.signature.defs` have `group: 'app.certified'`; they had `'pub.techne'`. Every record's group is
93
+ now a prefix of its NSID. A browse list that grouped by `group` showed them under pub.techne.
94
+
95
+ ## 0.13.1 (2026-11-28)
96
+
97
+ Inputs. No export is added, removed or renamed, and no function
98
+ changes. npm 0.13.1 and crate 0.13.1 are built from the same commit; the crate's code is unchanged and moves to
99
+ check 0.3.37.
10
100
 
11
101
  ### Inputs
12
102
 
package/README.md CHANGED
@@ -2,8 +2,10 @@
2
2
 
3
3
  TechneSDK for apps on the Techne platform: sign in, `put`, query, `useEvent` and the read-time check.
4
4
 
5
+ Roadmap: [where Techne is heading](https://github.com/technefoundation/sdk/blob/main/.claude/skills/techne-platform/roadmap.md), shared by every Techne repo: what is live today, the agreed direction, and what is still open.
6
+
5
7
  - **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.
8
+ - **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, `net` for DID resolution, verified record fetches and PDS password sessions, and `tap` for the stock client of a Tap's `/channel`.
7
9
 
8
10
  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
11
 
@@ -27,11 +29,13 @@ Every import goes through the package's `exports`, so the resolver has to read t
27
29
  | `techne-sdk/react/query` | the client's reads as hooks over TanStack Query (`useRecordQuery`, `useRecord`, `useVersions`, `defaultQueryClient`); needs `@tanstack/react-query` |
28
30
  | `techne-sdk/versions` | the same state without React: `eventState`, `verifyAnswer`, version labels |
29
31
  | `techne-sdk/auth` | sign-in ("Sign in with Techne"): `signIn`, `signUp`, `restore`, `signOut`, `clientMetadata`, `scopes`, `appKey`, `appSpace`, `ownAppSpace`, `WHOLE_STORE` (browser OAuth); the account page: `openAccountSettings`, `accountSettingsUrl` |
32
+ | `techne-sdk/sign-in` | the sign-in form and the "Sign in with Techne" button for any web page: `mountSignIn`, `mountSignInButton` (no framework; [below](#the-sign-in-form)) |
33
+ | `techne-sdk/react/sign-in` | the same as React components: `SignInForm`, `SignInButton` |
30
34
  | `techne-sdk/session` | a session the app holds itself, for React Native as well as the browser (plain JS, no native module): phone sign-in through the platform's door (`startPhoneSignIn`, `finishPhoneSignIn`), `OwnSession` (`did` + `fetchHandler` for `connect`, refresh, `signOut`, the device credential's proofs), DPoP helpers; `adoptHeldSession` (deprecated) |
31
35
  | `techne-sdk/connect` | `connect(session, platform?)` / `connectHosted(did, fetchHandler)` / `connectAnonymous(platform?)`: the client over one session, with its reads (`query`, `get`, `versions`, their options forms) and `put`; `bind(clients)` over clients made elsewhere |
32
36
  | `techne-sdk/put` | `put(techne, records, { deletes })`: the one write, deletes included (public deletes hinted to the platform); each of `records` is `{ record, rkey?, space? }` (`record` the body with its `$type`; `rkey` derived when absent: the lexicon's literal key, else a TID from the record's `createdAt` and CID, and with neither `put` throws before writing anything; `space` only for a private record); `put(techne, [], { deletes })` for deletes alone. Its `status` is never `valid`: `invalid` with the reason (not counted; `not curated: no lexicon`, another app's own type, is written all the same) or `pending` (not refused: indexed when the hint answered, so it reads back by URI, but not yet in the commons' curated view; a failed hint is `pending` too, and the record comes by the relay); `curation` says per record whether it is `curated`, `notCurated` (why) or still `pending`, and `{ wait: ms }` waits for the curated record |
33
37
  | `techne-sdk/query` | the platform's generic queries: `listRecords`, `getRecords`, `compose` (several steps in one `composeRecords` call), hosts (`hostsOf`, `hostSteps`/`hostsFrom`) |
34
- | `techne-sdk/links` | link tokens: create, redeem, check, revoke |
38
+ | `techne-sdk/links` | link tokens: create, reset, redeem, check, revoke, list your links for an app and target, and a link's redemptions |
35
39
  | `techne-sdk/wasm` | the check itself: `validate`, `decide`, `verify` (`validate` knows the built-in lexicons only; a runtime type is checked by the platform on write) |
36
40
  | `techne-sdk/catalog` | the browsable lexicon catalog |
37
41
  | `techne-sdk/nsid`, `techne-sdk/nsid.json` | every NSID as a constant (`NSID`, `METHOD`) |
@@ -82,9 +86,12 @@ for (;;) {
82
86
  - **Paging:** `limit` defaults to 50. Keep it at 500 or less: `query` accepts up to 50000, but past 500 the
83
87
  platform reads page after page and charges every row to your budget (below). Keep paging until `cursor` is absent: a page can be shorter than
84
88
  `limit` and still have one. `{ count: true }` adds `count` and `capped` (counting stops at 1000).
85
- - **Two views:** every query names its view, and there is no default (a query naming none is refused with
86
- `ViewRequired`). `view: 'curated'` reads the commons' listed records: one curated record per thing, merged
87
- from its sources by a curator the commons root trusts, moderated (an event only inside the supported areas).
89
+ - **Two views:** every query names its view (the types require it). The platform answers a query naming
90
+ none the way it did before views (curated, except as written for a branch scoped to named authors,
91
+ subjects or URIs, or with `curated: false`) through 2027-03-01 (UTC), whoever sends it, and refuses it
92
+ with `ViewRequired` from 2027-03-02; a query naming a view on some branches only is refused now. `view: 'curated'` reads the
93
+ commons' listed records: one curated record per thing, merged from its sources by a curator the commons
94
+ root trusts, moderated (an event only inside the supported areas).
88
95
  A type no curator covers is refused with `NotCurated`, naming the type, rather than answered as an empty list.
89
96
  `view: 'asWritten'` reads every public record as its author wrote it: each source copy and the curated record
90
97
  (counts in this view hold both copies of a curated thing). A private record reads the same in both. To mix
@@ -94,17 +101,12 @@ for (;;) {
94
101
  - **Limits:** each statement times out after 5 s (`query` then throws a `ComposeStepError` with status 500 and a
95
102
  message starting `query read:`); a `near` over a dense area can approach it, so page `near` small. `query` sends `composeRecords`, which has a row
96
103
  budget per signed-in DID and answers 429 `RateLimitExceeded` past it; `query` retries twice, then throws.
97
- Anonymous callers get one such budget per client IP only where the server is set up to know the client's IP
98
- (the platform's `AUTH_RATE_LIMIT_CLIENT_IP`); where it is not, all anonymous callers share one budget ten times
99
- that size, so another anonymous reader can use up yours.
104
+ Anonymous callers may share one budget; the guide's Limits section below says when.
100
105
  - **Without the SDK:** `/xrpc/*` (and `/.well-known/did.json`) on the platform answers CORS for any origin, so a page can `fetch`
101
- `https://techne.computer/xrpc/pub.techne.draft.query.listRecords?query=<JSON>&limit=10` directly. The routes
102
- under `/xrpc/_*` (the agent consent flow and the change stream) are not methods and get no CORS. (CORS is live
103
- on staging since 2026-11-24 and reaches techne.computer with the first platform release after that; until
104
- then a browser page reads techne.computer through its own server.)
106
+ `https://techne.computer/xrpc/pub.techne.draft.query.listRecords?query=<JSON>&limit=10` directly.
105
107
 
106
108
  The builder guide's `reading-public-data` section (https://techne.computer/docs/reading-public-data.md) has the
107
- query rules and the other read servers.
109
+ query rules, the Limits and the other read servers.
108
110
 
109
111
  ## Scripts and agents
110
112
 
@@ -162,13 +164,13 @@ const metadata = clientMetadata({ clientId, clientName: 'Cafe finder' })
162
164
 
163
165
  // On every page load: finishes a sign-in when the page is the redirect back, else restores a kept session.
164
166
  const session = await restore({ clientId })
165
- if (!session) await signIn({ clientId, handle: 'alice' }) // alice.techne.town, once techne.town is live (see below)
167
+ if (!session) await signIn({ clientId, handle: 'alice' }) // alice.techne.town
166
168
  else {
167
169
  const techne = connect(session, TECHNE_PLATFORM_DID)
168
170
  }
169
171
  ```
170
172
 
171
- - **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.
173
+ - **Who:** with no `handle`, the sign-in starts at the default PDS (techne.town), which asks who you are. An app that asked for the address or number itself passes `email` or `phone` (E.164, `+15024429492`) instead: the sign-in page sends the code at once and opens on the code step. `otherWays: true` opens the sign-in page with "Other ways to sign in" (passkey, Nostr key, a handle on another server) already open. One of `handle`, `email`, `phone` and `otherWays` at a time. The [sign-in form](#the-sign-in-form) does all this for you. 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.
172
174
  - **Scopes:** `scopes({ clientId })` is what it asks for by default, least privilege: `atproto`; the platform's `authPermissioned` permission set with the platform as its audience (the `permissioned.*` calls: private writes, reads and deletes); the app's own private space by its exact key, `ownAppSpace(clientId)` = `space:pub.techne.draft.space.private?skey=<appKey>` (ask for your own space this way: a keyless `space.private` scope, or `skey=*`, is every app's private data, and the consent page shows it as a red warning); and an `rpc:<nsid>?aud=<platform>%23atproto_appview` scope for each generic read the SDK makes signed in: `query.listRecords`, `query.countRecords` and `query.getRecords` (`techne-sdk/query`, `put`'s curation answer) and `registry.getType` and `registry.listTypes`. The platform narrows those reads by the token's space scopes, so they reach public data and the app's own space. An app passes the types it writes as `types: [nsid, ...]`, and each adds a `repo:<nsid>` scope (create, update, delete), as the platform's own least-privilege list does, plus `rpc:pub.techne.draft.sync.indexRecord` so `put` can hint the platform what it wrote (a pending type's records are indexed no other way); without `types` the app writes no public record. `query.composeRecords` is not in the default (the SDK makes no such call); an app that calls it asks for `everything: 'read'`. Everything the person can reach (their personal space, their circles, beacons shared with them) is an opt-in: `everything: 'read'` adds the `authRead` set and `space:*?authority=*&action=read` (`WHOLE_STORE_READ`), `everything: 'write'` adds `authRead`, `authWrite`, `space:*?authority=*&manage=create&manage=update` (`WHOLE_STORE`) and a `repo:` scope for the public records outside `pub.techne.*` (`community.lexicon.*`, `org.hypercerts.funding.receipt`; then our own public types need no `types` entry). The sets reach no space on Techne's PDS; the `space:` scope, asked for by name, does. The consent page shows those with a large warning; ask only if the app needs them. Pass the same `types` and `everything` to `signIn` and `clientMetadata`, since the PDS refuses a request beyond what the metadata declares. Pass `scope` to ask for other scopes, and pass it to both. An app that publishes its own community type (`pub.techne.draft.c.*`) as the signed-in person passes `publish: true`, which adds `rpc:pub.techne.draft.registry.publishType` (publishing a type is a public act). The type's NSID is the registry's answer, so its `repo:` scope can be asked for only after publishing: publish once (a setup sign-in with `publish: true`), then sign in with the published NSID in `types`.
173
175
  - **A private record names its space:** a record of a type with no public home is written privately, and it must name the `space` it is for; `put` throws `PutError` (`InvalidRequest`) with nothing written when one does not, as the platform's `permissioned.putRecords` refuses it. A record only the person reads goes in their own `space.personal`: `` { record, space: `at://${did}/pub.techne.draft.space.personal/self` } ``. Public records name no space and go to the person's PDS.
174
176
  - **The app's private space:** `appSpace(session.did, clientId)` is `at://{did}/pub.techne.draft.space.private/{appKey}`, where `appKey(clientId)` is the client id hashed (base32, lowercase, no padding, of its SHA-256; the platform's `sidecar_rkey`). Write there with `put(techne, [{ record, space: appSpace(did, clientId) }])` and read with `permissioned.listRecords({ space })`. Only that person reads it, through a token whose `space:` scopes cover it or one with no scope claim at all (below). In development the client id is the loopback client's, `resolveClientId(options)` with the same options `signIn` took: it carries the scope, so it changes with the port, `types` and `everything`, and so does the space. Its scope names the space type without a key (an id cannot carry its own hash), which is every app's private space: Techne's PDS no longer narrows it to the loopback app's own, and the consent page shows the red every-app warning. That is development only; a hosted app asks with `ownAppSpace(clientId)`. The browser keeps one stored session per origin, so a page that switches between client ids (other `types`, another port's id) signs out first; `restore` hands back whichever session the origin holds.
@@ -178,7 +180,54 @@ else {
178
180
  - **The account page and Delete account:** people manage their account (profile, ways to sign in, devices and apps, Delete account) on the account page at their PDS's sign-in host, never inside an app. `openAccountSettings()` opens it in a new tab; call it from the tap's handler. `openAccountSettings({ section: 'delete' })` opens it at Delete account: that is the link for Apple's account-deletion rule (the app still deletes its own data itself). There is no API that deletes an account. Sections are `'profile'`, `'methods'` and `'delete'`. Pass `session` (from `restore`) and it answers `false` without opening anything when the person signed in at another server, which has no Techne account page. Pass `open: (url) => …` to open it elsewhere (an in-app browser sheet in React Native). `accountSettingsUrl(options)` is the address alone. The host comes from the PDS's OAuth metadata, so a move of the sign-in host changes nothing for you. An app on a platform session (`connectHosted`) passes `techne` too, and the page opens already signed in through the platform's one-time link (`identity.openAccountPage`) where the platform and this SDK carry it; otherwise the page asks for a code.
179
181
  - **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 `techne-sdk/auth` call that takes them (`signIn`, `signUp`, `restore`, `signOut`, `redirectState`, …): the OAuth client is made once per client id with the first call's values. `connect(session, platform)` takes only the platform: the user's PDS resolves its DID. `connectAnonymous(platform, { plcUrl })` takes the PLC directory too, since it resolves a did:plc platform itself.
180
182
 
181
- **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.
183
+ ## The sign-in form
184
+
185
+ `techne-sdk/sign-in` puts the Techne sign-in form on any page of your app, so people start signing in without leaving it:
186
+
187
+ ```ts
188
+ import { mountSignIn } from 'techne-sdk/sign-in'
189
+
190
+ const form = mountSignIn(document.getElementById('sign-in')!, {
191
+ clientId: 'https://cafes.example/oauth-client-metadata.json',
192
+ appName: 'Cafe finder',
193
+ logo: '/logo.png', // a square image; shown 44 px with rounded corners
194
+ })
195
+ // form.unmount() takes it away again.
196
+ ```
197
+
198
+ In React:
199
+
200
+ ```tsx
201
+ import { SignInForm } from 'techne-sdk/react/sign-in'
202
+
203
+ <SignInForm clientId={clientId} appName="Cafe finder" logo="/logo.png" />
204
+ ```
205
+
206
+ **What the person sees.** One card: your logo and name at the top, "Sign in", and a line that says your app uses their Techne account and that the code makes an account for someone new. Below that are Email and Phone tabs. The phone field has a country picker, and its list opens inside the card. Then come a "Send me a code" button, a line of fine print ("We email you a code. No password."), a quiet "Other ways to sign in" link, and "Powered by Techne".
207
+
208
+ - **Send me a code** takes them to the Techne sign-in page with the code already sent, on the step where they type it (it calls `signIn` with `email` or `phone`). After the code they come back to your redirect URI, where `restore` answers the session, as for any sign-in.
209
+ - **Other ways to sign in** takes them to the Techne sign-in page with passkey, Nostr key and a handle on another server open (`signIn` with `otherWays`).
210
+ - A malformed address or number is caught in the form, and the fine print says what is wrong. When the sign-in cannot start (the PDS is unreachable), the fine print says so and `onError` gets the error.
211
+
212
+ **One look for every app.** Your logo and name are the only things that change. The card is 420 px wide, or narrower in a narrower container, and it keeps one size in every view (each tab, the country list), so nothing on your page moves. Put it in a container at least about 320 px wide.
213
+
214
+ **It can't break your page, and your page can't break it.** The form lives in a shadow root on its own element (`<techne-sign-in>`, appended to the element you give). Its styles stay inside, and your page's styles don't reach in. The brand fonts load from the home PDS (`https://pds.techne.town/static/fonts/`), declared once in your document's head under names of its own (`Techne Octave`, `Techne Public Sans`). If they can't load, Georgia and Arial stand in.
215
+
216
+ **Options.** Everything `signIn` takes except who is signing in (`clientId`, `types`, `everything`, `publish`, `scope`, `state`, `platform`, `pds`, `plcUrl`, `handleDomain`, `location`). Pass the same values as to `clientMetadata` and `restore`. Add `appName` (required), `logo` and `onError`. The React components also take `className` and `style` for the `<div>` they mount in, and they mount again when an option changes (not when only `onError` or `onClick` changes).
217
+
218
+ **Accessible.** The inputs have labels. The tabs are a `tablist`: arrow keys, Home and End move between them, and only the selected tab is in the tab order. The country picker is a searchable `listbox`: type to filter, use the arrows and Enter to pick, and Escape or Back to close. The country picked last is kept on the browser (`localStorage`, `techne-sdk:phone-country`). Otherwise the browser's language picks the first one.
219
+
220
+ ### The button
221
+
222
+ Use `mountSignInButton` (`SignInButton` in React) for a "Sign in with Techne" button in a navigation bar or anywhere else a form won't fit:
223
+
224
+ ```ts
225
+ import { mountSignInButton } from 'techne-sdk/sign-in'
226
+
227
+ mountSignInButton(navSlot, { clientId, theme: 'dark', size: 'small' })
228
+ ```
229
+
230
+ `theme: 'dark'` (the default) is black, for light backgrounds. `'light'` is white with a black edge, for dark backgrounds. `size: 'medium'` is 44 px tall and `'small'` is 36 px. A click calls `signIn` with no hint, which opens the Techne sign-in page at its first step. Pass `onClick` to do something else instead, such as showing the form. The button shows the name only, in Techne's type. Don't put the Techne mark beside it.
182
231
 
183
232
  ## A session the app holds (React Native)
184
233
 
@@ -203,7 +252,7 @@ const techne = connect(session, TECHNE_PLATFORM_DID)
203
252
  - **Sign-in:** the device makes the DPoP key and the PKCE pair and signs every proof; the platform runs the
204
253
  door and answers the tokens bound to that key, plus a narrow device credential. A `UseDpopNonce` answer is
205
254
  signed again once, with the same code. A refusal is an `OwnSessionError` whose `code` is the platform's error
206
- (`OwnSessionUnavailable`: sign in the old way; `InvalidRequest`: wrong code; `CodeExpired`; `RateLimitExceeded`
255
+ (`Unavailable`: no code could be sent, try again; `InvalidRequest`: wrong code; `CodeExpired`; `RateLimitExceeded`
207
256
  with `retryAfter`).
208
257
  - **Calls** to the PDS carry the access token and a proof per request; a `use_dpop_nonce` answer is signed again
209
258
  once, an `invalid_token` one refreshes and sends again.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * What `signIn` and the sign-in form (`techne-sdk/sign-in`) share about who is signing in and how a redirect
3
+ * ends. Internal: not a package export.
4
+ */
5
+ /** An E.164 number: `+`, then 7 to 15 digits, the first not 0. */
6
+ export declare const E164: RegExp;
7
+ /** An email address as the form and `signIn` take it: something, `@`, a domain with a dot. */
8
+ export declare const isEmailAddress: (s: string) => boolean;
9
+ /** The rejection of a sign-in redirect when the person comes back to the page without signing in (the
10
+ * library's `signInRedirect`, and ours): `Error('User navigated back')`, or an AggregateError holding it when
11
+ * cancelling the pushed request failed too. */
12
+ export declare const NAVIGATED_BACK = "User navigated back";
13
+ /** Whether `err` is that rejection. */
14
+ export declare function isNavigatedBack(err: unknown): boolean;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * What `signIn` and the sign-in form (`techne-sdk/sign-in`) share about who is signing in and how a redirect
3
+ * ends. Internal: not a package export.
4
+ */
5
+ /** An E.164 number: `+`, then 7 to 15 digits, the first not 0. */
6
+ export const E164 = /^\+[1-9]\d{6,14}$/;
7
+ /** An email address as the form and `signIn` take it: something, `@`, a domain with a dot. */
8
+ export const isEmailAddress = (s) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s);
9
+ /** The rejection of a sign-in redirect when the person comes back to the page without signing in (the
10
+ * library's `signInRedirect`, and ours): `Error('User navigated back')`, or an AggregateError holding it when
11
+ * cancelling the pushed request failed too. */
12
+ export const NAVIGATED_BACK = 'User navigated back';
13
+ /** Whether `err` is that rejection. */
14
+ export function isNavigatedBack(err) {
15
+ if (err instanceof AggregateError)
16
+ return err.errors.some(isNavigatedBack);
17
+ return err?.message === NAVIGATED_BACK;
18
+ }
@@ -35,7 +35,9 @@
35
35
  * Where it starts: no handle starts at the techne.town PDS ({@link TECHNE_TOWN_PDS}), which asks who you
36
36
  * are; a bare name (`alice`) is a techne.town handle (`alice.techne.town`); a full handle, a DID or a PDS
37
37
  * URL from any PDS goes as given. `signUp` goes to the techne.town PDS with `prompt: 'create'`, its
38
- * create-account screen. An app whose people live on another PDS (a test deployment's) names it with the `pds`
38
+ * create-account screen. An address or number the app asked for itself goes as `email` or `phone` (the sign-in page
39
+ * sends the code and opens on the code step), and `otherWays` opens it with "Other ways to sign in" open: both set
40
+ * on the authorization URL ({@link SignInOptions.email}); `techne-sdk/sign-in` is the form that does it. An app whose people live on another PDS (a test deployment's) names it with the `pds`
39
41
  * option, and its PLC directory with `plcUrl`: handles then resolve at that PDS, a sign-in with no
40
42
  * handle and every sign-up start there, a bare name takes `handleDomain`, and DIDs resolve at that PLC.
41
43
  *
@@ -88,6 +90,12 @@ export interface OAuthClientLike {
88
90
  state?: string | null;
89
91
  } | undefined>;
90
92
  signInRedirect(input: string, options?: AuthorizeOptions): Promise<unknown>;
93
+ /** The authorization URL a sign-in navigates to (BrowserOAuthClient's, through PAR): {@link signIn} adds
94
+ * `login_hint` and `epds_other_ways` to it, which the library would drop. Needed for `email`, `phone` and
95
+ * `otherWays`. */
96
+ authorize?(input: string, options?: AuthorizeOptions): Promise<URL>;
97
+ /** Cancel the PAR request behind an authorization URL (the person came back without signing in). */
98
+ abortRequest?(url: URL): Promise<void>;
91
99
  revoke(sub: string): Promise<void>;
92
100
  /** The metadata the client signs in with (BrowserOAuthClient's): its `scope` is what a restarted sign-in asks for. */
93
101
  readonly clientMetadata?: {
@@ -206,6 +214,16 @@ export interface SignInOptions extends ClientOptions {
206
214
  signUp?: boolean;
207
215
  /** Handed back by the redirect: {@link redirectState} answers it there. */
208
216
  state?: string;
217
+ /** The person's email address, typed in the app (the sign-in form, `techne-sdk/sign-in`): the Techne sign-in
218
+ * page skips its first step, sends a code to it, and opens on the code step. Sent as `login_hint`. Not with
219
+ * `handle`, `phone` or `otherWays`. */
220
+ email?: string;
221
+ /** The person's phone number, E.164 (`+15024429492`): as `email`, by text message. Not with `handle`,
222
+ * `email` or `otherWays`. */
223
+ phone?: string;
224
+ /** Open the Techne sign-in page with "Other ways to sign in" (passkey, Nostr key, a handle on another server)
225
+ * already open (`epds_other_ways=1`). Not with `handle`, `email` or `phone`. */
226
+ otherWays?: boolean;
209
227
  }
210
228
  /** Sign in: redirects to the person's PDS, and comes back to the app's redirect URI (then {@link restore}).
211
229
  * When the sign-in page hands the person back because their account is on another server, {@link restore}
@@ -3,6 +3,7 @@ import { isValidDid, isValidHandle, isValidNsid } from '@atproto/syntax';
3
3
  import { NSID } from '../generated/nsid.js';
4
4
  import { appviewRef, TECHNE_PLATFORM_DID } from '../platform.js';
5
5
  import { ownAppSpace } from './app-key.js';
6
+ import { E164, isEmailAddress, NAVIGATED_BACK } from './hints.js';
6
7
  import { TECHNE_TOWN, TECHNE_TOWN_PDS } from './hosts.js';
7
8
  import { PUBLIC_HOMES } from './placement.gen.js';
8
9
  export { appKey, appSpace, ownAppSpace } from './app-key.js';
@@ -179,6 +180,48 @@ export function onSessionDeleted(o, listener) {
179
180
  deletedListeners.delete(clientId);
180
181
  };
181
182
  }
183
+ /** What a sign-in adds to the authorization URL (the library sets `login_hint` itself, from the handle it
184
+ * resolved, and drops one passed in its options, so a typed email or number goes on the URL, which the
185
+ * Techne sign-in page reads before the PAR request's). Throws a TypeError on a combination that makes no sense. */
186
+ function pageParams(o) {
187
+ const email = o.email?.trim();
188
+ const phone = o.phone?.trim();
189
+ const asked = [email && 'email', phone && 'phone', o.otherWays && 'otherWays'].filter(Boolean);
190
+ if (!asked.length)
191
+ return null;
192
+ if (asked.length > 1)
193
+ throw new TypeError(`techne-sdk/auth: signIn takes one of email, phone and otherWays (got ${asked.join(' and ')})`);
194
+ if (o.handle?.trim())
195
+ throw new TypeError(`techne-sdk/auth: signIn takes handle or ${asked[0]}, not both`);
196
+ if (email && !isEmailAddress(email))
197
+ throw new TypeError(`techne-sdk/auth: email is an address (got ${JSON.stringify(o.email)})`);
198
+ if (phone && !E164.test(phone))
199
+ throw new TypeError(`techne-sdk/auth: phone is an E.164 number, +<country code><number> (got ${JSON.stringify(o.phone)})`);
200
+ const hint = email || phone;
201
+ if (hint)
202
+ return { login_hint: hint };
203
+ return { epds_other_ways: '1' };
204
+ }
205
+ /** What BrowserOAuthClient's signInRedirect does, with `params` on the URL: navigate, and if the page is still
206
+ * here 5 s later (the person came back), cancel the request and reject. */
207
+ async function redirectWith(client, input, options, params) {
208
+ if (typeof client.authorize !== 'function')
209
+ throw new Error('techne-sdk/auth: this OAuth client cannot build an authorization URL (email, phone and otherWays need authorize())');
210
+ const url = await client.authorize(input, options);
211
+ for (const [k, v] of Object.entries(params))
212
+ url.searchParams.set(k, v);
213
+ const location = globalThis.location;
214
+ if (!location)
215
+ throw new Error('techne-sdk/auth: signIn navigates, so it needs a browser page');
216
+ location.assign(url.href);
217
+ await new Promise((_, reject) => {
218
+ const timer = setTimeout(() => {
219
+ const err = new Error(NAVIGATED_BACK);
220
+ Promise.resolve(client.abortRequest?.(url)).then(() => reject(err), (reason) => reject(new AggregateError([err, reason])));
221
+ }, 5e3);
222
+ timer.unref?.();
223
+ });
224
+ }
182
225
  /** Where a sign-in for `handle` starts: see the module doc. */
183
226
  function signInTarget(handle, o = {}) {
184
227
  const h = handle?.trim().replace(/^@/, '');
@@ -192,6 +235,7 @@ function signInTarget(handle, o = {}) {
192
235
  * When the sign-in page hands the person back because their account is on another server, {@link restore}
193
236
  * starts this sign-in again there (see {@link MAX_HANDBACKS}). */
194
237
  export async function signIn(o = {}) {
238
+ const params = pageParams(o);
195
239
  const { scope } = resolveClient(o);
196
240
  const client = await oauthClient(o);
197
241
  // A sign-up is at the home PDS unless the app names another PDS by its URL.
@@ -199,7 +243,10 @@ export async function signIn(o = {}) {
199
243
  const options = { scope, state: wrapState(0, o.state) };
200
244
  if (o.signUp)
201
245
  options.prompt = 'create';
202
- await client.signInRedirect(input, options);
246
+ if (params)
247
+ await redirectWith(client, input, options, params);
248
+ else
249
+ await client.signInRedirect(input, options);
203
250
  }
204
251
  /**
205
252
  * How many times one sign-in is started again at another server. The Techne sign-in page (ePDS) hands a
@@ -125,6 +125,35 @@ export declare const catalog: {
125
125
  homes?: undefined;
126
126
  })[];
127
127
  spaces: ({
128
+ nsid: string;
129
+ name: string;
130
+ kind: string;
131
+ key: string;
132
+ description: string;
133
+ collections: string[];
134
+ policy: {
135
+ read: {
136
+ $type: string;
137
+ of?: undefined;
138
+ atLeast?: undefined;
139
+ includeMemberCollectives?: undefined;
140
+ };
141
+ write: {
142
+ $type: string;
143
+ of?: undefined;
144
+ atLeast?: undefined;
145
+ };
146
+ manage: {
147
+ $type: string;
148
+ of?: undefined;
149
+ atLeast?: undefined;
150
+ };
151
+ };
152
+ doc: unknown;
153
+ policyNsid: string;
154
+ policyDescription: string;
155
+ policyDoc: unknown;
156
+ } | {
128
157
  nsid: string;
129
158
  name: string;
130
159
  kind: string;
@@ -137,9 +166,15 @@ export declare const catalog: {
137
166
  of: ({
138
167
  $type: string;
139
168
  of?: undefined;
169
+ spaceType?: undefined;
140
170
  } | {
141
171
  $type: string;
142
172
  of: string;
173
+ spaceType?: undefined;
174
+ } | {
175
+ $type: string;
176
+ spaceType: string;
177
+ of?: undefined;
143
178
  })[];
144
179
  atLeast?: undefined;
145
180
  includeMemberCollectives?: undefined;
@@ -437,35 +472,6 @@ export declare const catalog: {
437
472
  policyNsid: string;
438
473
  policyDescription: string;
439
474
  policyDoc: unknown;
440
- } | {
441
- nsid: string;
442
- name: string;
443
- kind: string;
444
- key: string;
445
- description: string;
446
- collections: string[];
447
- policy: {
448
- read: {
449
- $type: string;
450
- of?: undefined;
451
- atLeast?: undefined;
452
- includeMemberCollectives?: undefined;
453
- };
454
- write: {
455
- $type: string;
456
- of?: undefined;
457
- atLeast?: undefined;
458
- };
459
- manage: {
460
- $type: string;
461
- of?: undefined;
462
- atLeast?: undefined;
463
- };
464
- };
465
- doc: unknown;
466
- policyNsid: string;
467
- policyDescription: string;
468
- policyDoc: unknown;
469
475
  })[];
470
476
  algebra: {
471
477
  nsid: string;