turnkey_api_key_stamper
This crate contains structs and utilities to work with P-256 keys, which Turnkey uses as a primary way of authentication.
Creating a new P-256 API key
use TurnkeyP256ApiKey;
let api_key = generate;
Loading API keys from env
If you keep API keys in env vars, load it with from_bytes or from_strings:
use env;
use TurnkeyP256ApiKey;
// Assuming the env var is a hex-encoded string
let api_private_key = var.expect;
let api_key = from_strings.expect;
If you want to store API keys in .env files, use dotenvy.
Load API keys from files
If you have generated API keys with Turnkey's command-line tool you can load them with:
use TurnkeyP256ApiKey;
let api_key = from_files;
Creating an API stamp to sign Turnkey requests
The API is straightforward, once you have a handle on an API key, call stamp:
use ;
let api_key = generate;
let stamp = api_key.stamp;
The stamp produced is a base64-encoded value, ready to be used as a stamp header. See our documentation for more information.
Error handling
Errors are centralized in StamperError.