| … | … | @@ -915,6 +915,28 @@ export class IdentityRegistry { |
| 915 | 915 | * @param {string} devicePubkey — this device's hyperident pubkey (hex) |
| 916 | 916 | * @param {Object<string,string>} keys — { namespace: localKeyHex, ... } |
| 917 | 917 | */ |
| 918 | /** |
| 919 | * True if this peer is a writer on the identity autobase (can append). |
| 920 | * Mirrors this check straight off the underlying autobase. |
| 921 | */ |
| 922 | get writable () { |
| 923 | return this._base ? this._base.writable : false |
| 924 | } |
| 925 | |
| 926 | /** |
| 927 | * Subscribe to writable transitions. Callback fires when this peer |
| 928 | * becomes (or was already) a writer on the identity autobase — useful |
| 929 | * for apps that want to act the moment they can append. |
| 930 | * Returns an unsubscribe function. |
| 931 | */ |
| 932 | onWritable (cb) { |
| 933 | if (!this._base) return () => {} |
| 934 | if (this._base.writable) { queueMicrotask(() => { try { cb() } catch {} }) } |
| 935 | const handler = () => { try { cb() } catch {} } |
| 936 | this._base.on('writable', handler) |
| 937 | return () => this._base.off('writable', handler) |
| 938 | } |
| 939 | |
| 918 | 940 | async registerMirrorWriters (devicePubkey, keys) { |
| 919 | 941 | if (!devicePubkey || typeof devicePubkey !== 'string' || devicePubkey.length !== 64) { |
| 920 | 942 | throw new Error('registerMirrorWriters requires 64-char hex devicePubkey') |