| … | … | @@ -24,7 +24,7 @@ |
| 24 | 24 | * today joiners are read-only followers of the org's autobase. |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | | import { Room, composeSchemas, createRoomPairing, joinRoomPairing, decodeRoomPairingInvite } from 'hyper-rooms' |
| 27 | import { Room, composeSchemas, createRoomPairing, joinRoomPairing, resumeRoomPairing, decodeRoomPairingInvite } from 'hyper-rooms' |
| 28 | 28 | import { orgsSchema, validateName } from './schema.js' |
| 29 | 29 | |
| 30 | 30 | export class HyperOrgs { |
| … | … | @@ -266,7 +266,23 @@ export class HyperOrgs { |
| 266 | 266 | meta: { kind: 'org', name } |
| 267 | 267 | }) |
| 268 | 268 | this._pairings.set(pairing.invite, pairing) |
| 269 | | return { invitation: pairing.invite, close: pairing.close } |
| 269 | // descriptor lets the daemon persist + re-register this invite on restart. |
| 270 | return { invitation: pairing.invite, descriptor: pairing.descriptor, close: pairing.close } |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * Re-register a persisted org-invite pairing member after a restart so an |
| 275 | * already-shared invite keeps working. The org Room must be mounted first. |
| 276 | * @param {string} name |
| 277 | * @param {object} descriptor from a prior createOrgInvite() |
| 278 | * @param {object} swarm shared Hyperswarm (injected) |
| 279 | */ |
| 280 | async resumeOrgPairing (name, descriptor, swarm) { |
| 281 | if (!swarm) throw new Error('resumeOrgPairing requires { swarm }') |
| 282 | const room = this._requireRoom(name) |
| 283 | const pairing = resumeRoomPairing(room, descriptor, swarm) |
| 284 | this._pairings.set(descriptor.invitation || (name + ':' + descriptor.discoveryKey), pairing) |
| 285 | return pairing |
| 270 | 286 | } |
| 271 | 287 | |
| 272 | 288 | /** |