readme.md 2.77 KB
Newer Older
Aral Balkan's avatar
Aral Balkan committed
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Waystone

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

## REST API

Traditional REST API. Messages received are not trusted and replies should not be trusted either. For trusted messages, we use Pulse and the Teleportation API.

All methods receive and return serialised JSON.

### GET

#### isHandleAvailable

Expects a handle to check:
 
	{
		"handle": "String"
	}

Returns:

	{
		"handleIsAvailable": Boolean
	}

### POST 

#### addPerson

Expects a person:

	{
		"handle": "String",
		"name": "String",
		"bio": "String",
		"photo": "Base64EncodedString",
		"deviceID": "String",
		"email": "(optional) String"
	}

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

#### sendRequestToRegisterNewDeviceForPerson

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"
		}		
	}

**Note:** *`success = true` means that the request to register the new device has been successfully stored for relay to the user via the Teleportation API. 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.*

## Teleportation API 

Messages dropped in specific folders are teleported by Pulse. These are trusted messages between authenticated devices. The message names are the file names and the message bodies are the file contents. All message bodies are in serialised JSON.

### From Waystone (to person)

#### 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):

 * confirm_new_device
 * deny_new_device

*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"
	}

### From person (to Waystone)

#### confirm_new_device

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"
	}

#### deny_new_device

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"
	}