readme.md 4.3 KB
Newer Older
Aral Balkan's avatar
Aral Balkan committed
1
2
3
4
# Waystone

> But mostly because it felt like the right thing to do, and that is reason enough.

Aral Balkan's avatar
Aral Balkan committed
5
# REST API
Aral Balkan's avatar
Aral Balkan committed
6

Aral Balkan's avatar
Aral Balkan committed
7
Traditional REST API. Messages received are not trusted and replies should not be trusted either. For trusted messages, we use [Pulse](https://ind.ie/pulse) and the [Teleportation API](#teleportation-api).
Aral Balkan's avatar
Aral Balkan committed
8
9
10
11
12
13
14

All methods receive and return serialised JSON.

### GET

#### isHandleAvailable

Aral Balkan's avatar
Aral Balkan committed
15
16
*Checks if the passed handle is available for use.*

Aral Balkan's avatar
Aral Balkan committed
17
18
19
20
21
22
23
24
25
26
27
28
Expects a handle to check:
 
	{
		"handle": "String"
	}

Returns:

	{
		"handleIsAvailable": Boolean
	}

Aral Balkan's avatar
Aral Balkan committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#### getDeviceId

*Returns the device ID of the Waystone instance.*

Expects: 

	{}

Returns:

	{
		"deviceId": "String"
	}

Aral Balkan's avatar
Aral Balkan committed
43
44
45
46
### POST 

#### addPerson

Aral Balkan's avatar
Aral Balkan committed
47
48
*Adds the passed person to Waystone* 

Aral Balkan's avatar
Aral Balkan committed
49
50
51
52
53
54
55
Expects a person:

	{
		"handle": "String",
		"name": "String",
		"bio": "String",
		"photo": "Base64EncodedString",
Aral Balkan's avatar
Aral Balkan committed
56
		"deviceId": "String",
Aral Balkan's avatar
Aral Balkan committed
57
58
59
60
61
62
63
64
65
66
67
68
69
70
		"email": "(optional) String"
	}

Returns:
	
	{
		"success": Boolean,
		"error (optional)": 
		{
			"code": Number,
			"message": "String"
		}		
	}

Aral Balkan's avatar
Aral Balkan committed
71
72
73
#### confirmNewDeviceForPerson

*Registers a request to confirm that a new device should be added to the person’s account.* 
Aral Balkan's avatar
Aral Balkan committed
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

Expects a device to add to a person:

	{	
		device:
		{
			"id": "String",
			"name": "String",

		},
		person:
		{
			"handle": "String"
		}
	}

Returns:

	{
		"success": Boolean,
		"error (optional)": 
		{
			"code": Number,
			"message": "String"
		}		
	}

Aral Balkan's avatar
Aral Balkan committed
101
102
103
**Note:** *`success = true` means that the request to register the new device has been successfully stored and will be relayed to the user via the Teleportation API for confirmation. The person will have to approve the request either via a notification on the native client (by way of the Teleportation API) or via email if they have that option enabled as a backup.*

# <a name='teleportation-api'></a>Teleportation API 
Aral Balkan's avatar
Aral Balkan committed
104

Aral Balkan's avatar
Aral Balkan committed
105
Messages dropped in specific folders are teleported automatically by Pulse to the recipients. These are trusted messages between authenticated devices. The message are files. The message names are the file names and the message bodies are the file contents. All message bodies are in serialised JSON format.
Aral Balkan's avatar
Aral Balkan committed
106

Aral Balkan's avatar
Aral Balkan committed
107
Message names are automatically prefixed with a timestamp and the handle of the sender in the following format:
Aral Balkan's avatar
Aral Balkan committed
108

Aral Balkan's avatar
Aral Balkan committed
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
	<datetime>__<messageName>

Where:

	<datetime> = 	ISO 8601 combined date and time string with timezone 
					with colons escaped by underscores for better cross-platform
					file name compability.

Example:

	1980-10-14T00_59_59-04_00__confirm_new_device

## From Waystone to a person

### Adding a new device.
Aral Balkan's avatar
Aral Balkan committed
124
125
126
127
128
129
130
131
132
133
134
135
136
137

#### verify_new_device

Asks person to verify that they asked for the device with the presented ID and name.

Message body:

	{
		"id": "String",
		"name": "String"
	}

Reply with (either):

Aral Balkan's avatar
Aral Balkan committed
138
139
 * [confirm_new_device](#confirm-new-device)
 * [deny_new_device](#deny-new-device)
Aral Balkan's avatar
Aral Balkan committed
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156

*Notes:*

  1. Not replying will eventually result in the request being forgotten.
  2. If you confirm the new device, its device ID will be added to the list of approved devices for that person and the person will get a `new_device_verified` message.

#### new_device_verified

Confirms that the person’s new device has been verified.

Message body:

	{
		"id": "String",
		"name": "String"
	}

Aral Balkan's avatar
Aral Balkan committed
157
158
159
### Friendship

#### friendship_request
Aral Balkan's avatar
Aral Balkan committed
160

Aral Balkan's avatar
Aral Balkan committed
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
A notification that the sender is requesting friendship.

Message body:
	
	{
		"from": "handle"
	}

#### friendship_acceptance

A notification that your friendship request has been accepted by sender.

Message body:

	{
		"from": "handle"
	}

## From a person to Waystone

### Adding a new device

#### <a name='confirm-new-device'></a>confirm_new_device
Aral Balkan's avatar
Aral Balkan committed
184
185
186
187
188
189
190
191
192

Confirm that you want to add the device with the passed ID to your Ind.ie account. The device will gain full access to your Ind.ie account. This is a response to the `verify_new_device` message.

Message body:

	{
		"id": "String"
	}

Aral Balkan's avatar
Aral Balkan committed
193
#### <a name='deny-new-device'></a>deny_new_device
Aral Balkan's avatar
Aral Balkan committed
194
195
196
197
198
199
200
201
202

Deny access to the device with the passed ID to your Ind.ie account. This is a response to the `verify_new_device` message.

Message body:

	{
		"id": "String"
	}

Aral Balkan's avatar
Aral Balkan committed
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
### Friendship

#### friendship_request

A friendship request to be relayed to the specified person.

Message body:
	
	{
		"to": "handle"
	}

#### friendship_acceptance

A request to relay that you have accepted the specified person’s friendship request.

Message body:
Aral Balkan's avatar
Aral Balkan committed
220

Aral Balkan's avatar
Aral Balkan committed
221
222
223
	{
		"to": "handle"
	}