open_payments/client
Types
Holds the credentials used to sign requests to the Open Payments auth and resource servers on behalf of a wallet address.
pub type Client {
AuthenticatedClient(
wallet_address_url: String,
private_key: eddsa.PrivateKey,
key_id: String,
)
}
Constructors
-
AuthenticatedClient( wallet_address_url: String, private_key: eddsa.PrivateKey, key_id: String, )
Values
pub fn create(
wallet_address_url wallet_address_url: String,
key_id key_id: String,
private_key_path private_key_path: String,
) -> Result(Client, error.OpenPaymentsError)
Creates a Client for the given wallet address, reading and parsing the
Ed25519 private key used for HTTP message signatures from
private_key_path. key_id must match the ID of the corresponding
public key registered on the wallet address.
Returns Error(KeyError(_)) if the key file can’t be read or doesn’t
contain a valid PKCS#8 PEM-encoded Ed25519 private key.
pub fn create_from_env(
wallet_address_url wallet_address_url: String,
key_id key_id: String,
private_key_env_var private_key_env_var: String,
) -> Result(Client, error.OpenPaymentsError)
Creates a Client for the given wallet address, reading the Ed25519
private key as a PKCS#8 PEM string from the environment variable named
private_key_env_var. The variable must hold the PEM itself, with its
line breaks, not a path to a key file. key_id must match the ID of the
corresponding public key registered on the wallet address.
Returns Error(KeyError(_)) if the environment variable isn’t set or
doesn’t hold a valid PKCS#8 PEM-encoded Ed25519 private key.
pub fn create_from_pem(
wallet_address_url wallet_address_url: String,
key_id key_id: String,
private_key_pem private_key_pem: String,
) -> Result(Client, error.OpenPaymentsError)
Creates a Client for the given wallet address from the Ed25519 private
key in private_key_pem, a PKCS#8 PEM string. Use this when the key comes
from somewhere other than a file, such as a secret manager. key_id must
match the ID of the corresponding public key registered on the wallet
address.
Returns Error(KeyError(_)) if private_key_pem isn’t a valid PKCS#8
PEM-encoded Ed25519 private key.