/**
 * Communication protocol used to obtain client session.
 * @author Tomasz Lichon
 * @copyright (C) 2015 ACK CYFRONET AGH
 * @copyright This software is released under the MIT license cited in
 * 'LICENSE.txt'
 */

syntax = "proto2";

package one.clproto;

enum HandshakeStatus {
    OK                               = 1;
    MACAROON_EXPIRED                 = 2;
    MACAROON_NOT_FOUND               = 3;
    INVALID_METHOD                   = 4;
    ROOT_RESOURCE_NOT_FOUND          = 5;
    INVALID_PROVIDER                 = 6;
    BAD_SIGNATURE_FOR_MACAROON       = 7;
    FAILED_TO_DESCRYPT_CAVEAT        = 8;
    NO_DISCHARGE_MACAROON_FOR_CAVEAT = 9;
    INVALID_MACAROON                 = 10;
    INVALID_NONCE                    = 11;
    INCOMPATIBLE_VERSION             = 12;
    INTERNAL_SERVER_ERROR            = 13;
}

message ClientHandshakeRequest {
    optional bytes session_id                      = 1;
    optional Macaroon macaroon                     = 2;
    required bytes version                         = 3;
    repeated bytes compatible_oneprovider_versions = 4;
}

message ProviderHandshakeRequest {
    required bytes provider_id = 1;
    required bytes nonce       = 2;
}

message HandshakeResponse {
    required HandshakeStatus status                       = 1;
}

message Macaroon {
    required bytes macaroon        = 1;
    repeated bytes disch_macaroons = 2;
}
