https://github.com/jayrbolton/wot-serialize
Save users and keyrings to files (part of node-wot)
https://github.com/jayrbolton/wot-serialize
Last synced: 2 months ago
JSON representation
Save users and keyrings to files (part of node-wot)
- Host: GitHub
- URL: https://github.com/jayrbolton/wot-serialize
- Owner: jayrbolton
- Created: 2017-11-10T05:39:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-07T21:05:16.000Z (over 7 years ago)
- Last Synced: 2025-01-04T23:41:20.118Z (4 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wot-serialize
## saveUser(user, directory, callback)
Save the `user` to a `directory` with `callback` getting called when done.
`directory` can exist or not and can be relative or absolute. If files exist within the directory, they may be overwritten.
`callback` receives an `err` as the first parameter, which will be null if there's no error.
Only the locked versions of the stamp and key are saved to the disk.
```js
ident.createUser(pass, {name: 'pb'}, function (err, user) {
if (err) throw err
serialize.saveUser(user, '/tmp/uzr', function (err) {
if (err) throw err
// user is saved to disk under /tmp/uzr
})
})
```## loadUser(passphrase, directory, callback)
Load a user that was saved to a directory. You must pass in the user's passphrase so that the secret keys can get decrypted.
```js
loadUser(pass, '/tmp/uzr/', function (err, user) {
if (err) throw err
// if the passphrase does not match, err will be an Error
// user will be an object that looks exactly like a user generated in wot-identity with createUser
})
```