xbr._config

Attributes

Classes

EthereumAddress

Ethereum address validator.

PrivateKey

Private key (32 bytes in HEX) validator.

Profile

User profile, stored as named section in ${HOME}/.xbrnetwork/config.ini:

UserConfig

Local user configuration file. The data is either a plain text (unencrypted)

WampUrl

WAMP transport URL validator.

Functions

load_or_create_profile([dotdir, profile, default_url, ...])

prompt_for_ethereum_address(msg)

Prompt user for an Ethereum (public) address.

prompt_for_key(msg, key_len[, default])

Prompt user for a binary key of given length (in HEX).

prompt_for_wamp_url(msg[, default])

Prompt user for WAMP transport URL (eg "wss://planet.xbr.network/ws").

style_error(text)

style_ok(text)

Module Contents

class EthereumAddress[source]

Bases: click.ParamType

Ethereum address validator.

convert(value, param, ctx)[source]

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters:
  • value – The value to convert.

  • param – The parameter that is using this type to convert its value. May be None.

  • ctx – The current context that arrived at this value. May be None.

name = 'Ethereum address'[source]
class PrivateKey(key_len)[source]

Bases: click.ParamType

Private key (32 bytes in HEX) validator.

_key_len[source]
convert(value, param, ctx)[source]

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters:
  • value – The value to convert.

  • param – The parameter that is using this type to convert its value. May be None.

  • ctx – The current context that arrived at this value. May be None.

name = 'Private key'[source]
class Profile(path: str | None = None, name: str | None = None, member_adr: str | None = None, ethkey: bytes | None = None, cskey: bytes | None = None, username: str | None = None, email: str | None = None, network_url: str | None = None, network_realm: str | None = None, member_oid: uuid.UUID | None = None, vaction_oid: uuid.UUID | None = None, vaction_requested: numpy.datetime64 | None = None, vaction_verified: numpy.datetime64 | None = None, data_url: str | None = None, data_realm: str | None = None, infura_url: str | None = None, infura_network: str | None = None, infura_key: str | None = None, infura_secret: str | None = None)[source]

Bases: object

User profile, stored as named section in ${HOME}/.xbrnetwork/config.ini:

[default]
# username used with this profile
username=joedoe

# user email used with the profile (e.g. for verification emails)
email=joe.doe@example.com

# XBR network node used as a directory server and gateway to XBR smart contracts
network_url=ws://localhost:8090/ws

# WAMP realm on network node, usually "xbrnetwork"
network_realm=xbrnetwork

# user private WAMP-cryptosign key (for client authentication)
cskey=0xb18bbe88ca0e189689e99f87b19addfb179d46aab3d59ec5d93a15286b949eb6

# user private Ethereum key (for signing transactions and e2e data encryption)
ethkey=0xfbada363e724d4db2faa2eeaa7d7aca37637b1076dd8cf6fefde13983abaa2ef
cskey = None[source]
data_realm = None[source]
data_url = None[source]
email = None[source]
ethkey = None[source]
infura_key = None[source]
infura_network = None[source]
infura_secret = None[source]
infura_url = None[source]
log[source]
marshal()[source]
member_adr = None[source]
member_oid = None[source]
name = None[source]
network_realm = None[source]
network_url = None[source]
static parse(path, name, items)[source]
path = None[source]
username = None[source]
vaction_oid = None[source]
vaction_requested = None[source]
vaction_verified = None[source]
class UserConfig(config_path)[source]

Bases: object

Local user configuration file. The data is either a plain text (unencrypted) .ini file, or such a file encrypted with XSalsa20-Poly1305, and with a binary file header of 48 octets.

_config_path = b'.'[source]
_profiles[source]
property config_path: List[str][source]

Return the path to the user configuration file exposed by this object.,

Returns:

Local filesystem path.

load(cb_get_password=None) List[str][source]

Load this object from the underlying user configuration file. When the file is encrypted, call back into cb_get_password to get the user password.

Parameters:

cb_get_password – Callback called when password is needed.

Returns:

List of profiles loaded.

log[source]
property profiles: Dict[str, object][source]

Access to a map of user profiles in this user configuration.

Returns:

Map of user profiles.

save(password: str | None = None)[source]

Save this user configuration to the underlying configuration file. The user configuration file can be encrypted using Argon2id when a password is given.

Parameters:

password – The optional Argon2id password.

Returns:

Number of octets written to the user configuration file.

class WampUrl[source]

Bases: click.ParamType

WAMP transport URL validator.

convert(value, param, ctx)[source]

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters:
  • value – The value to convert.

  • param – The parameter that is using this type to convert its value. May be None.

  • ctx – The current context that arrived at this value. May be None.

name = 'WAMP transport URL'[source]
_DEFAULT_CFC_URL[source]
_DEFAULT_CONFIG = Multiline-String[source]
Show Value
"""[default]
# username used with this profile
username={username}

# user email used with the profile (e.g. for verification emails)
email={email}

# XBR network node used as a directory server and gateway to XBR smart contracts
network_url={network_url}

# WAMP realm on network node, usually "xbrnetwork"
network_realm={network_realm}

# user private WAMP-cryptosign key (for client authentication)
cskey={cskey}

# user private Ethereum key (for signing transactions and e2e data encryption)
ethkey={ethkey}
"""
_HAS_COLOR_TERM = False[source]
load_or_create_profile(dotdir=None, profile=None, default_url=None, default_realm=None, default_email=None, default_username=None)[source]
prompt_for_ethereum_address(msg)[source]

Prompt user for an Ethereum (public) address.

prompt_for_key(msg, key_len, default=None)[source]

Prompt user for a binary key of given length (in HEX).

prompt_for_wamp_url(msg, default=None)[source]

Prompt user for WAMP transport URL (eg “wss://planet.xbr.network/ws”).

style_error(text)[source]
style_ok(text)[source]
term = None[source]