Skip to content

Commit

Permalink
Address feedback and generate access_token on the client side
Browse files Browse the repository at this point in the history
  • Loading branch information
cammellos committed Jun 26, 2020
1 parent c3d3be3 commit 729aaf6
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions docs/raw/push-notification-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ title: 16/PUSH-NOTIFICATION-SERVER
- [Protobuf description](#protobuf-description)
- [PushNotificationRegister](#pushnotificationregister)
- [PushNotificationPreferences](#pushnotificationpreferences)
- [PushNotificationDeviceToken](#pushnotificationdevicetoken)
- [PushNotificationOptions](#pushnotificationoptions)
- [PushNotificationFilterSettings](#pushnotificationfiltersettings)
- [PushNotificationRegistrationResponse](#pushnotificationregistrationresponse)
- [ContactCodeAdvertisement](#contactcodeadvertisement)
- [PushNotificationAdvertisementInfo](#pushnotificationadvertisementinfo)
Expand Down Expand Up @@ -110,14 +110,14 @@ The content of the message MUST contain the following [protobuf record](https://

```protobuf
message PushNotificationOptions {
message PushNotificationFilterSettings {
boolean enabled = 1;
repeated string allowed_user_list = 2;
repeated string blocked_user_list = 3;
repeated string blocked_chat_list = 4;
}
message PushNotificationDeviceToken {
message PushNotificationOptions {
enum TokenType {
UNKNOWN_TOKEN_TYPE = 0;
APN_TOKEN = 1;
Expand All @@ -126,13 +126,14 @@ message PushNotificationDeviceToken {
TokenType token_type = 1;
string token = 2;
string installation_id = 3;
PushNotificationPreferences preferences = 4;
PushNotificationFilterSettings filter_settings = 4;
}
message PushNotificationPreferences {
repeated DeviceToken device_tokens = 1;
repeated PushNotificationOptions options = 1;
uint version = 2;
boolean unregister = 3;
string access_token = 4;
}
message PushNotificationRegister {
Expand All @@ -148,27 +149,26 @@ A push notification server will handle the message according to the following ru
- it MUST verify that `token` is non empty
- it MUST verify that `installation_id` is non empty
- it MUST verify that `version` is non-zero and greater than the currently stored version for the public key of the sender, if any
- it MUST verify that `device_tokens` is non empty
- it MUST verify that `options` is non empty
- it MUST verify that `access_token` is a 36 characters string

If `signature` does not match the public key of the sender, the message MUST be discarded.

If `token_type` is not supported, a response MUST be sent with `error` set to
`UNSUPPORTED_TOKEN_TYPE`.

If `token`,`installation_id`,`device_tokens`,`version` are empty, a response MUST
If `token`,`installation_id`,`options`,`version` are empty, a response MUST
be sent with `error` set to `MALFORMED_MESSAGE`.

If the `version` is equal or less than the currently stored version, a response MUST
be sent with `error` set to `VERSION_MISMATCH`.

If any other error occurs the `error` should be set to `INTERNAL_ERROR`.

If the request is successful, an access token MUST be generated and sent back to the client
with `success` set to `true`.

Otherwise a response MUST be sent with `success` set to `false`.

It is RECOMMENDED to use a randomly generated string for `access_token` of at least 36 characters.

`request_id` should be set to the `SHA3-256` of the signature sent by the client.

Expand All @@ -182,7 +182,6 @@ message PushNotificationRegistrationResponse {
ErrorType error = 2;
bytes request_id = 3;
PushNotificationPreferences preferences = 4;
string access_token = 5;
enum ErrorType {
UNKNOWN_ERROR_TYPE = 0;
Expand Down Expand Up @@ -453,31 +452,32 @@ A `PushNotificationRegister` is used to register with a Push Notification server

A push notification preferences message describes the push notification options and tokens for all the devices associated with `PublicKeyClient`.

`device_tokens`: a list of `PushNotificationPreferences`, one for each device owned by the user.
`options`: a list of `PushNotificationOptions`, one for each device owned by the user.
`version`: an monotonically increasing number identifying the current `PushNotificationPreferences`. Any time anything is changed in the record it MUST be increased by the client, otherwise the request will not be accepted.
`unregister`: whether the account should be unregistered
`access_token`: the access token that will be given to clients to send push notifications

#### Data disclosed

- Number of devices with push notifications enabled for a given public key
- The times a push notification record has been modified by the user

### PushNotificationDeviceToken
### PushNotificationOptions

`PushNotificationDeviceToken` represent the token and preferences for a given device.
`PushNotificationOptions` represent the token and preferences for a given device.

`token_type`: the type of token. Currently supported is `APN_TOKEN` for Apple Push
Notification service and `FIREBASE_TOKEN` for `Firebase`.
`token`: the actual push notification token sent by `Firebase` or `APN`
`installation_id`: the [`installation_id`](./2-account.md) of the device
`preferences`: the push notification preferences for this device.
`filter_setttings`: the push notification filters for this device.

#### Data disclosed

- Type of device owned by a given user
- The `FIREBASE` or `APN` push notification token

### PushNotificationOptions
### PushNotificationFilterSettings

[//]: (Any of these can be sha3 in order not to store it on the server)

Expand All @@ -499,8 +499,6 @@ in this list MUST not be issued a token.
`error`: the error type, if any
`request_id`: the `SHA3-256` hash of the `signature` of the request
`preferences`: the server stored preferences in case of an error
`access_token`: the token that needs to be used by client to send a push notification,
in case the request is successful. This is generated by the push notification server.

### ContactCodeAdvertisement

Expand Down

0 comments on commit 729aaf6

Please sign in to comment.