-
Notifications
You must be signed in to change notification settings - Fork 0
API Protocol
This api registers your long-term identity key, your device, and the device's prekeys.
POST /api/v1/key/initial
Authorization: basic_auth
Body (application/json):
{
lastResortKey : {
id : "{keyId}",
signature : "{signature}",
preKey : "{publicKey}",
},
prekeys : [
{
id : "{keyId}",
signature : "{signature}",
preKey : "{publicKey}",
},
...
]
}
- basic_auth credentials are described here
-
keyIdis an integer that is the prekey's id. It is created by the axolotl library. - `signature' is a base64 encoded string of the signature of the public key, signed by the client's long term identity key.
-
publicKeyis a base64 encoded string from the keyPair's public array buffer
-
200request succeeded. -
401, signatureinvalid authentication credentials (bad signature) -
401, timeinvalid authentication credentials (stale timestamp)- this response will also include the server's unix time in the header
Server-Time
- this response will also include the server's unix time in the header
-
401, registeredinvalid authentication credentials (identityKey & deviceId already registered) -
401, badly formed credentialsinvalid authentication credentials (basic_auth username & password missing or malformed) -
415badly formatted request body.
This api adds the prekeys included in the body to an already registered device
PUT /api/v1/key/update/
Authorization: basic_auth
Body (application/json):
{
lastResortKey : {
id : "{keyId}",
signature: "{signature}",
preKey : "{publicKey}"
},
prekeys : [
{
id : "{keyId}",
signature : "{signature}",
preKey : "{publicKey}"
},
...
]
}
- basic_auth credentials are described here
-
keyIdis an integer that is the prekey's id. It is created by the axolotl library. - `signature' is a base64 encoded string of the signature of the public key, signed by the client's long term identity key.
-
publicKeyis a base64 encoded string from the keyPair's public array buffer
-
200request succeeded. -
401, signatureinvalid authentication credentials (bad signature) -
401, timeinvalid authentication credentials (stale timestamp)- this response will also include the server's unix time in the header
Server-Time
- this response will also include the server's unix time in the header
-
401, not registeredinvalid authentication credentials (identityKey & deviceId not registered) -
401, badly formed credentialsinvalid authentication credentials (basic_auth username & password missing or malformed) -
401, revokedinvalid authentication credentials (identityKey revoked) -
415badly formatted request body.
POST /api/v1/key/addDevice
Authorization: basic_auth
This api removes a device and its prekeys from an associated identity key. If the last device is deleted, then the identity key is revoked.
DELETE /api/v1/key/
Authorization: basic_auth
-
200request succeeded. -
401, signatureinvalid authentication credentials (bad signature) -
401, timeinvalid authentication credentials (stale timestamp)- this response will also include the server's unix time in the header
Server-Time
- this response will also include the server's unix time in the header
-
401, not registeredinvalid authentication credentials (identityKey & deviceId not registered) -
401, badly formed credentialsinvalid authentication credentials (basic_auth username & password missing or malformed) -
401, revokedinvalid authentication credentials (identityKey revoked)
If a client does not have an existing session with a recipient, the client will need to retrieve a PreKey for the recipient in order to start one.
GET /api/v1/key/"{identity_key}"
Authorization: basic_auth
- basic_auth credentials are described here
-
identity_keyis a base64 encoded Curve25519 public key that belongs to the user who's key you are fetching. Each client should have a single identity key generated at install time. NOTE: in this context, the base64 string must be escaped and made url safe
-
401, signatureinvalid authentication credentials (bad signature) -
401, timeinvalid authentication credentials (stale timestamp)- this response will also include the server's unix time in the header
Server-Time
- this response will also include the server's unix time in the header
-
401, not registeredinvalid authentication credentials (identityKey & deviceId not registered) -
401, badly formed credentialsinvalid authentication credentials (basic_auth username & password missing or malformed) -
401, revokedinvalid authentication credentials (identityKey revoked) -
404requestedidentity_keynot found. -
404requestedidentity_keyhas been revoked. -
415badly formatted request body. -
200request succeeded. The body below is returned. -
205request succeeded. Must produce and upload more prekeys. The body below is returned.
{
"{deviceId}" : {
id : "{keyId}",
keyPair : {
public : "{publicKey}",
private : "{privateKey}"
}
},
...
}
-
deviceIdis the device id to which the prekey belongs. There will be a key/value pair for every device associated with the requestedidentity_key -
keyIdis an integer that is the prekey's id. It is created by the axolotl library. -
publicKeyis a base64 encoded string from the keyPair's public array buffer -
privateKeyis a base64 encoded string from the keyPair's private array buffer
POST /api/v1/message/
Authorization: basic_auth
Body (application/json):
{
messages: [{
headers: [
{
recipient : "{identityKey|deviceId}", //string
messageHeader: "{message_header}" //string
},
...
]
body: "{body}", //string
},
...,
]
}
- The body consists of an array of messages
- A message consists of an array of headers (one for each recipient of the message) and a body (one per message)
-
identityKey|deviceIdis the concatenation of a recipient's base64 encoded long-term public key, the '|' character, and the deviceId of the device to which this message is being sent. -
message_headeris a base64 encoded string that is unique to each recipient. -
bodyis a base64 encoded string containing the encrypted message.
-
401, signatureinvalid authentication credentials (bad signature) -
401, timeinvalid authentication credentials (stale timestamp)- this response will also include the server's unix time in the header
Server-Time
- this response will also include the server's unix time in the header
-
401, not registeredinvalid authentication credentials (identityKey & deviceId not registered) -
401, badly formed credentialsinvalid authentication credentials (basic_auth username & password missing or malformed) -
401, revokedinvalid authentication credentials (identityKey revoked) -
415badly formatted request body. -
200request succeeded. The body below is returned -
205request succeeded. Must produce and upload more prekeys. The body below is returned.
{
messagesQueued : 0,
keysNotFound : [],
revokedKeys : [],
missingDevices : []
}
-
messagesQueuedis the number of messages (a different message pre recipient/device) that have been successfully queued -
keysNotFoundis an array of recipients who'sindentityKeywas not found in the database. It contains 0 or more strings of the form<indentityKey>|<deviceId>. -
revokedKeysis an array of recipients who'sindentityKeyhas been revoked. It contains 0 or more strings of the form<indentityKey>|<deviceId>. -
missingDevicesis an array of recipients who'sindentityKeydoes not contain the associateddeviceId. It contains 0 or more strings of the form<indentityKey>|<deviceId>.
##Receiving a message See Push Socket Protocol wiki page.
#####username
The username is of the form base64(identityKey)|deviceId where base64(identityKey) is your longterm public key base 64 encoded and deviceId is the device ID of the device you are making the request from.
#####password
The password is of the form timestamp|signature(timestamp)where timestamp is the current unix time and signature(timestamp) is a signature of the unix time from your longterm private key.