def start_local_tunnel(name): wallet_name = 'default' if name: wallet_name = name sub_domain = get_seed(wallet_name) utils.save_endpoint(sub_domain) configuration = utils.get_vsw_agent() port = configuration.get("inbound_transport_port") script_path = Path(__file__).parent.parent.joinpath("conf/local_tunnel.sh").resolve() os.system(f'chmod +x {script_path}') log_dir = Path(os.path.expanduser('~')) lt_log_file = str(Path(log_dir).joinpath("vsw_logs/lt.log").resolve()) os.system(f'nohup {script_path} {port} {sub_domain} > {lt_log_file} 2>&1 &')
def start_agent(argv): wallet_name = argv[1] wallet_key = argv[2] seed = argv[3] configuration = utils.get_vsw_agent() config_path = Path(__file__).parent.parent.joinpath("conf/genesis.txt").resolve() admin_port = configuration.get("admin_port") transport_port = configuration.get("inbound_transport_port") logger.info('genesis_file: ' + str(config_path)) try: args = ['--admin', configuration.get("admin_host"), admin_port, '--inbound-transport', configuration.get("inbound_transport_protocol"), configuration.get("inbound_transport_host"), transport_port, '--outbound-transport', configuration.get('outbound_transport_protocol'), '--endpoint', configuration.get("endpoint"), '--label', configuration.get("label"), '--seed', seed, '--webhook-url', configuration.get("webhook_url"), '--tails-server-base-url', utils.get_tails_server().get("host"), '--genesis-file', str(config_path), '--accept-taa', '1', '--wallet-type', 'indy', '--wallet-name', wallet_name, '--wallet-key', wallet_key, '--log-config', logger.aries_config_path, '--log-file', logger.aries_log_file, '--auto-accept-invites', '--preserve-exchange-records', '--auto-accept-requests', '--auto-ping-connection', '--auto-respond-messages', '--auto-respond-credential-proposal', '--auto-respond-credential-offer', '--auto-respond-credential-request', '--auto-store-credential', '--auto-respond-presentation-request', '--auto-verify-presentation', '--auto-respond-presentation-proposal', '--admin-api-key', seed] run_command('start', args) except BaseException as error: logger.error("started vsw failed.") logger.error('An exception occurred: {}'.format(error))
def provision(wallet_name, wallet_key): configuration = utils.get_vsw_agent() config_path = Path(__file__).parent.parent.joinpath("conf/genesis.txt").resolve() logger.info('genesis_file: ' + str(config_path)) endpoint = f'{configuration.get("outbound_transport_protocol")}://{configuration.get("inbound_transport_host")}:{configuration.get("inbound_transport_port")}/' try: args = [ '--endpoint', endpoint, '--seed', get_seed(wallet_name), '--genesis-file', str(config_path), '--wallet-type', 'indy', '--accept-taa', '1', '--log-config', logger.aries_config_path, '--log-file', logger.aries_log_file, '--wallet-name', wallet_name, '--wallet-key', wallet_key ] run_command('provision', args) except BaseException as e: logger.info(e.message) logger.info("vsw: error: please check if your public DID and verkey is registered in the ledger!")
def save_credential(msg): state = msg["state"] if state == 'credential_acked': credential = msg["credential"] revocation_id = msg.get("revocation_id", '') values = credential["values"] attrs = {} for key, value in values.items(): attrs[key] = value.get("raw", "") content = { "schema_id": credential["schema_id"], "cred_def_id": credential["cred_def_id"], "rev_reg_id": credential["rev_reg_id"], "cred_rev_id": revocation_id, "attrs": attrs } issuer_did = attrs.get("developerDid", "") software_name = attrs.get("softwareName", "") software_did = attrs.get("softwareDid", "") vsw_dao.save_credential(issuer_did, software_name, software_did, "success", content) if __name__ == '__main__': configuration = utils.get_vsw_agent() webhook_port = configuration.get("webhook_port") app.logger.info(f"Started controller, http://127.0.0.1:{webhook_port}") server = make_server('127.0.0.1', int(webhook_port), app) server.serve_forever() app.run()
def test_get_connections(): vsw_config = get_vsw_agent() get_connections(vsw_config)
def test_get_credential_definition(): vsw_config = get_vsw_agent() get_credential_definition(vsw_config)
def test_get_schema(): vsw_config = get_vsw_agent() get_schema(vsw_config)
def test_get_wallet(): vsw_config = get_vsw_agent() get_wallet(vsw_config)
import configparser import json import os import time import uuid from os.path import expanduser from pathlib import Path from typing import List from vsw.dao import vsw_dao import requests from aries_cloudagent_vsw.commands import run_command from vsw import utils from vsw.commands import init,exit from vsw.log import Log vsw_config = utils.get_vsw_agent() software_certificate = vsw_config.get("schema_name") logger = Log(__name__).logger def main(args: List[str]) -> bool: try: args = parse_args(args) if args.subcommand == "newwallet": wallet_name = args.name wallet_key = args.key if not wallet_name: print("vsw: error: the wallet name is required!") return if not wallet_key: print("vsw: error: the wallet key is required!")