def submit_credential():
    """
    Exposed method to proxy credential issuance requests.
    """
    start_time = time.perf_counter()
    method = 'submit_credential.batch'

    if not request.json:
        end_time = time.perf_counter()
        issuer.log_timing_method(method, start_time, end_time, False)
        abort(400)

    cred_input = request.json

    response = issuer.handle_send_credential(cred_input)

    end_time = time.perf_counter()
    issuer.log_timing_method(method, start_time, end_time, True)

    return response
Пример #2
0
def agent_callback(topic):
    """
    Main callback for aries agent.  Dispatches calls based on the supplied topic.
    """
    start_time = time.perf_counter()
    method = 'agent_callback.' + topic

    if not request.json:
        end_time = time.perf_counter()
        issuer.log_timing_method(method, start_time, end_time, False)
        abort(400)

    message = request.json
    issuer.log_timing_event(method, message, start_time, None, False)

    # dispatch based on the topic type
    if topic == issuer.TOPIC_CONNECTIONS:
        if "state" in message:
            method = method + '.' + message["state"]
            response = issuer.handle_connections(message["state"], message)
        else:
            response = jsonify({})

    elif topic == issuer.TOPIC_CONNECTIONS_ACTIVITY:
        response = jsonify({})

    elif topic == issuer.TOPIC_CREDENTIALS:
        if "state" in message:
            method = method + '.' + message["state"]
            response = issuer.handle_credentials(message["state"], message)
        else:
            response = jsonify({})

    elif topic == issuer.TOPIC_PRESENTATIONS:
        if "state" in message:
            method = method + '.' + message["state"]
            response = issuer.handle_presentations(message["state"], message)
        else:
            response = jsonify({})

    elif topic == issuer.TOPIC_GET_ACTIVE_MENU:
        response = issuer.handle_get_active_menu(message)

    elif topic == issuer.TOPIC_PERFORM_MENU_ACTION:
        response = issuer.handle_perform_menu_action(message)

    elif topic == issuer.TOPIC_ISSUER_REGISTRATION:
        response = issuer.handle_register_issuer(message)

    elif topic == issuer.TOPIC_PROBLEM_REPORT:
        response = issuer.handle_problem_report(message)

    else:
        print("Callback: topic=", topic, ", message=", message)
        end_time = time.perf_counter()
        issuer.log_timing_method(method, start_time, end_time, False)
        issuer.log_timing_event(method, message, start_time, end_time, False)
        abort(400, {'message': 'Invalid topic: ' + topic})

    end_time = time.perf_counter()
    issuer.log_timing_method(method, start_time, end_time, True)
    issuer.log_timing_event(method, message, start_time, end_time, True)

    return response