Group: GNU Social P2P/Design/Agent2LocalCore
(Created page with '< User:Miron2/Social_Design == UI to Core Protocol == === Keys === The UI has a public key and a root control key. All values are opaque to the Core and are decrypted on …') |
|||
| Line 5: | Line 5: | ||
=== Keys === | === Keys === | ||
| − | The UI has a public key | + | The UI has a public key which controls the identity of the user. All values are opaque to the Core and are decrypted on the UI side. The UI should have a local cache for performance. |
=== Core Side === | === Core Side === | ||
| Line 11: | Line 11: | ||
Data manipulation: | Data manipulation: | ||
| − | * put(path, value) - performs store[path] = value | + | * put(path, value, push) - performs store[path] = value, and notifies any friends if push = true |
* get(path) - returns store[path] | * get(path) - returns store[path] | ||
* delete(path) - performs delete store[path] | * delete(path) - performs delete store[path] | ||
| Line 21: | Line 21: | ||
Mounting allows accessing a friend's store as if it was local. Mounts are read-only and are cached on the Core. The UI notifies others of changes to their store with ''send'' - see below. | Mounting allows accessing a friend's store as if it was local. Mounts are read-only and are cached on the Core. The UI notifies others of changes to their store with ''send'' - see below. | ||
| − | * mount( | + | * mount(friend_path, remote_path, local_path) - attach friend store |
* unmount(local_path) - detach friend store | * unmount(local_path) - detach friend store | ||
| − | * | + | * set_permission_keys(subject_path, [ { friend: $friend_path, dkey: $permission_dkey, push: $push } ]) - allow access to subject_path to a set of friends |
| − | '' | + | ''friend_path'' includes: friend_id, information required to route to the friend, such as domain or IP |
| − | '' | + | ''permission_dkey'' is the key used to encrypt the data at the path, encrypted with a friend's public key |
| − | + | All nodes will be encrypted with a permission_dkey corresponding to the owner, so that the UI can read its own store. | |
| − | |||
| − | |||
| − | |||
| − | All nodes will be | ||
Notification: | Notification: | ||
| − | + | * request(local_prefix, max, order) - request a subtree under a mount point to be retrieved from the remote | |
| − | * request(local_prefix, max, order) - request a subtree | ||
=== UI Side === | === UI Side === | ||
| Line 44: | Line 39: | ||
* on_receive(route, local_prefix) - notification that a ''send'' was received | * on_receive(route, local_prefix) - notification that a ''send'' was received | ||
| − | on_receive is a result of | + | on_receive is a result of a push from a friend. |
* on_mount_done(local_prefix, result) | * on_mount_done(local_prefix, result) | ||
| Line 55: | Line 50: | ||
Data manipulation: | Data manipulation: | ||
| − | put(path, value) | + | put(path, value, push) |
| − | -> PUT '/store/$path', { value: $value } | + | -> PUT '/store/$path?push=$push', { value: $value } |
get(path) | get(path) | ||
-> GET '/store/$path' | -> GET '/store/$path' | ||
| − | returns { value: $value | + | returns { value: $value } |
delete(path) | delete(path) | ||
| Line 72: | Line 67: | ||
multiget(max, start_path [, end_path]) | multiget(max, start_path [, end_path]) | ||
-> GET '/store/$start_path#multi?end=$end_path&max=$max' | -> GET '/store/$start_path#multi?end=$end_path&max=$max' | ||
| − | returns [ {path: $path, value: $value | + | returns [ {path: $path, value: $value}* ] |
Sharing: | Sharing: | ||
| − | + | set_permission_keys(subject_path, [ { friend: $friend_path, dkey: $permission_dkey, push: $push } ]) - allow access to subject_path to a set of friends | |
| − | -> PUT '/store/$subject_path# | + | -> PUT '/store/$subject_path#permit', [ { ... } ] |
| − | |||
mount(route, remote_path, local_path) | mount(route, remote_path, local_path) | ||
| Line 87: | Line 81: | ||
Communication: | Communication: | ||
| − | |||
| − | |||
| − | |||
request(local_path, max, order) | request(local_path, max, order) | ||
| Line 105: | Line 96: | ||
-> { type: 'receive', path: $path, success: true, $route } | -> { type: 'receive', path: $path, success: true, $route } | ||
-> { type: 'receive', path: $path, success: false, $route, message: "..." } | -> { type: 'receive', path: $path, success: false, $route, message: "..." } | ||
| − | |||
| − | |||
on_send_done(route, path, result) | on_send_done(route, path, result) | ||
Revision as of 18:34, 31 May 2010
UI to Core Protocol
Keys
The UI has a public key which controls the identity of the user. All values are opaque to the Core and are decrypted on the UI side. The UI should have a local cache for performance.
Core Side
Data manipulation:
- put(path, value, push) - performs store[path] = value, and notifies any friends if push = true
- get(path) - returns store[path]
- delete(path) - performs delete store[path]
- scan(max, start_path[, end_path]) - returns paths in range [start_path, end_path)
- multiget(max, start_path [, end_path]) - returns paths, values in range
Sharing:
Mounting allows accessing a friend's store as if it was local. Mounts are read-only and are cached on the Core. The UI notifies others of changes to their store with send - see below.
- mount(friend_path, remote_path, local_path) - attach friend store
- unmount(local_path) - detach friend store
- set_permission_keys(subject_path, [ { friend: $friend_path, dkey: $permission_dkey, push: $push } ]) - allow access to subject_path to a set of friends
friend_path includes: friend_id, information required to route to the friend, such as domain or IP
permission_dkey is the key used to encrypt the data at the path, encrypted with a friend's public key
All nodes will be encrypted with a permission_dkey corresponding to the owner, so that the UI can read its own store.
Notification:
- request(local_prefix, max, order) - request a subtree under a mount point to be retrieved from the remote
UI Side
- on_receive(route, local_prefix) - notification that a send was received
on_receive is a result of a push from a friend.
- on_mount_done(local_prefix, result)
- on_send_done(local_prefix, result) - notification of a send completed or failed
REST HTTP binding
A simple binding of the Core to UI protocol over HTTP REST. All {} enclosed structures are JSON encoded.
Data manipulation:
put(path, value, push)
-> PUT '/store/$path?push=$push', { value: $value }
get(path) -> GET '/store/$path'
returns { value: $value }
delete(path) -> DELETE '/store/$path'
returns number deleted (0 or 1)
scan(start_path, end_path, max) -> GET '/store/$start_path#scan?end=$end_path&max=$max'
returns [ $path* ]
multiget(max, start_path [, end_path]) -> GET '/store/$start_path#multi?end=$end_path&max=$max'
returns [ {path: $path, value: $value}* ]
Sharing:
set_permission_keys(subject_path, [ { friend: $friend_path, dkey: $permission_dkey, push: $push } ]) - allow access to subject_path to a set of friends
-> PUT '/store/$subject_path#permit', [ { ... } ]
mount(route, remote_path, local_path)
-> POST '/store/$local_path#mount', { route: $route, remote: $remote_path }
unmount(local_path) -> DELETE '/store/$local_path#mount'
Communication:
request(local_path, max, order)
-> POST '/store/$local_path#request', { max: $max, order: $order }
Callbacks to UI:
UI performs:
GET '/event'
This is a blocking call. Possible results:
on_receive(route, path)
-> { type: 'receive', path: $path, success: true, $route }
-> { type: 'receive', path: $path, success: false, $route, message: "..." }
on_send_done(route, path, result)
-> { type: 'send_done', path: $path, success: true }
-> { type: 'send_done', path: $path, success: false, message: "..." }
on_mount_done(route, path, result)
-> { type: 'mount_done', path: $path, success: true }
-> { type: 'mount_done', path: $path, success: false, message: "..." }
NOTES: