/
PROTOCOL
105 lines (77 loc) · 2.68 KB
/
PROTOCOL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
PSYLIGHTBOOKMARK PROTOCOL
Well, this project is not supposed to be taken too seriously, so I'm not
really investing on security for the time being. Passwords will be salted and
hashed and an authentication system similar to http (token based auth.) will
be provided. Treat the software as insecure.
The protocol is plaintext. Fields are delimited by the pipe '|' symbol.
REGISTRATION
(Any symbol but pipe)
<symbols> ::= [!@#$%^&*()_+-={}[]\":;'/?,.<>]
(So usernames are any chars, but pipes, and range from 1 to 50 chars)
<username> ::= ([:alphanum:]|<symbols>){1,50}
Registration request:
<reg>|<username>|<password>
Registration response (success):
<regok>
Registration response (failure):
<username-taken>
Registration response (failure):
<bad-username>
AUTHENTICATION
(A token is a sha256 hashed value)
Login request:
<auth>|<username>|<password>
Success response:
<auth>|<token>
Failure:
<auth>|<fail>
INSERT
A <bookmark-name> is a unique name that the user gives to the bookmark in
order to discern it from other bookmarks (for example, same bookmark on same
book, page, chapter, volume, but different names).
In an insert request, if an id is specified, it means that we wish to update a
<bookmark-name> in that given request.
<bookmark> ::= <bookmark-name>|<book-title>|<volume>|<chapter>|<page>
Insert request:
<ins>|<bookmark>|<token>[|<id>]
Insert response (success):
<ins>|<ok>|<id>
Insert response (failure):
<ins>|<fail>
DELETE
Delete request:
<del>|<bookmark-id>|<token>
Delete response (success):
<del>|<ok>
Delete response (fail):
<del>|<fail>
PURGE
Used for deleting all bookmarks of a specific user.
Purge request:
<purge>|<token>
Purge response (success):
<purge>|<ok>
Purge response (failure):
<purge>|<fail>
SYNCHRONIZATION
<bookmark-amount> is an unsigned 32-bit integer, which is the number of
bookmarks the user has stored.
Sync request:
<sync>|<token>
Sync response:
<sync>|<bookmark-amount>
The above should be executed in order to get an amount of books to be
received. This way the user of the protocol can somewhat troubleshoot if all
the packets do not make it.
The bookmarks should be split up in the outgoing packets, as many as they may
be - the bookmark amount should give a clue to the client on the amount of
data that one is expecting.
Sync request data:
<syncdata>|<token>
Sync data response:
[<bookmark-id>|<bookmark>]*
MISUSE
If the client sent something malformed, or something that makes no sense, a
<badrequest> is sent back. Might help client devs for debugging.
Response:
<badrequest>