| … | … | @@ -33,9 +33,12 @@ function roomSecrets (did, signingKey) { |
| 33 | 33 | const hex = (k) => (typeof k === 'string' ? k : b4a.toString(k, 'hex')) |
| 34 | 34 | |
| 35 | 35 | // The community's atproto identity from its ROOT mnemonic (the founder holds it; the recovery key stays |
| 36 | | // root-side — devices never receive it). Returns { did, signedOp, signingKey, recoveryKey, didKey }. |
| 37 | | export function communityIdentity (rootMnemonic, { handle, pdsUrl } = {}) { |
| 38 | | return createSwarmIdentity(rootMnemonic, { handle, pdsUrl }) |
| 36 | // root-side — devices never receive it). feedGenEndpoint/labelerEndpoint declare the community DID as a |
| 37 | // self-custody feed-generator + labeler in its genesis op (#bsky_fg / #atproto_labeler services + |
| 38 | // #atproto_label VM — spec/lens-export.md §5), pointing at the membrane that proxies the XRPC. Returns |
| 39 | // { did, signedOp, signingKey, recoveryKey, didKey }. |
| 40 | export function communityIdentity (rootMnemonic, { handle, pdsUrl, feedGenEndpoint = null, labelerEndpoint = null } = {}) { |
| 41 | return createSwarmIdentity(rootMnemonic, { handle, pdsUrl, feedGenEndpoint, labelerEndpoint }) |
| 39 | 42 | } |
| 40 | 43 | |
| 41 | 44 | // ROOT-side: attest an admin device into the community (a keet root→device chain). The founder (root |
| … | … | @@ -77,9 +80,11 @@ export async function openCommunityRepo ({ storage, did, signingKey, rootPub, de |
| 77 | 80 | // adminDeviceKeys: pre-known co-admin device pubkeys (hex/Buffer) to seed into the roster now (attest + |
| 78 | 81 | // hand them their bundles separately via attestAdmin). Returns everything a caller needs to add records + |
| 79 | 82 | // admins. roomStore/repoStorage are separate (the room is plaintext/keyless; the repo is encrypted). |
| 80 | | export async function createCommunity ({ rootMnemonic, founderDeviceMnemonic, adminDeviceKeys = [], name, roomStore, repoStorage, handle, pdsUrl = 'https://pds.7rnx.net', swarmOpts = null, network = true } = {}) { |
| 83 | export async function createCommunity ({ rootMnemonic, founderDeviceMnemonic, adminDeviceKeys = [], name, roomStore, repoStorage, handle, pdsUrl = 'https://pds.7rnx.net', feedGenEndpoint = null, labelerEndpoint = null, swarmOpts = null, network = true } = {}) { |
| 81 | 84 | if (!rootMnemonic || !founderDeviceMnemonic || !roomStore || !repoStorage) throw new Error('createCommunity: rootMnemonic, founderDeviceMnemonic, roomStore, repoStorage required') |
| 82 | | const identity = communityIdentity(rootMnemonic, { handle, pdsUrl }) |
| 85 | // Default the lens-export endpoints to the same membrane that fronts the PDS (it proxies the feed/label |
| 86 | // XRPC to favela-web — spec §4). A community DID thus declares its feed-generator + labeler at genesis. |
| 87 | const identity = communityIdentity(rootMnemonic, { handle, pdsUrl, feedGenEndpoint: feedGenEndpoint || pdsUrl, labelerEndpoint: labelerEndpoint || pdsUrl }) |
| 83 | 88 | const signingKey = b4a.toString(identity.signingKey.privateKey, 'hex') |
| 84 | 89 | const rootPub = b4a.toString(await rootIdentityPublicKey(rootMnemonic), 'hex') |
| 85 | 90 | const founderKp = await deviceKeetKeyPair(founderDeviceMnemonic) |