An extension to gundb.
Allows marking node as append only, this means fields of AO nodes (or refs from AO nodes) can only be added and their value can't be modify. There is an exception that if the ref is to a SEA signed node then the user of the signed node can change the ref.
For example its a way to claim a username that reference a profile. gun.rootAO('indexbyusername').get(username).put(profileId). This makes the node 'indexbyusername' append only and thus once the key is set to it can not be modified. But other keys could be added to 'indexbyusername'. Once that username is defined no one else could change where it points to. Currently in gundb evereything is world writable, so theoretically anyone could change it.
- npm i gun @gooddollar/gun-appendOnly --save
- import Gun from '@gooddollar/gun-appendOnly'
- gun = new Gun()
gun.rootAO(key) - creates a root gundb node that is marked as append only
gun.get(key).putAO(node) - put a ref to at making the node append only
Behind the scenes it appends '!@' to the soul of the node (souls in gundb are like ids) Extends gun wire protocol to check if the node being written to is marked with '!@' and if the put request contains an existing field. (check out the source code)