pub struct FirefoxStore { /* private fields */ }Expand description
Client for the AMO Add-on Versions API (v5).
The store holds the JWT credential pair and a reusable HTTP client; it is cheap to construct and intended to live for the duration of a single publish run.
Implementations§
Source§impl FirefoxStore
impl FirefoxStore
Sourcepub fn from_jwt_credentials(
addon_id: String,
jwt_issuer: String,
jwt_secret: String,
) -> Result<Self>
pub fn from_jwt_credentials( addon_id: String, jwt_issuer: String, jwt_secret: String, ) -> Result<Self>
Build a store bound to addon_id, signing requests with the supplied
HS256 JWT credential pair (issuer + secret).
Get the credentials from https://addons.mozilla.org/developers/addon/api/key/.
§Errors
Fails if the underlying HTTP client cannot be built (e.g. rustls platform-verifier initialization fails).
Sourcepub fn with_base_url(self, base_url: &str) -> Result<Self>
pub fn with_base_url(self, base_url: &str) -> Result<Self>
Override the AMO API base URL.
Defaults to https://addons.mozilla.org/api/v5/. Intended for tests
or when pointing at a local mozilla/addons-server instance. A
missing trailing slash is added automatically so that relative paths
join correctly.
§Errors
Returns WepubError::InvalidUrl if base_url does not parse as a
URL.
Sourcepub async fn publish(
&self,
zip: Vec<u8>,
options: FirefoxPublishOptions,
) -> Result<()>
pub async fn publish( &self, zip: Vec<u8>, options: FirefoxPublishOptions, ) -> Result<()>
Upload zip and create a new version on the bound add-on.
The call performs four steps internally: upload the archive, poll
AMO until validation finishes, create the version, and (if
options.source is set) attach the source archive in a follow-up
PATCH. The polling cadence is controlled by options.poll.
Progress (uploading..., polling AMO upload status, published version id=...) is emitted through the tracing crate; library
consumers configure their own subscriber to render or capture it.
§Errors
On failure, returns one of WepubError::Network,
WepubError::Api, WepubError::Auth, WepubError::Validation,
WepubError::Json, WepubError::Io or WepubError::Internal
depending on which step failed.
§Examples
use wepub_core::firefox::{FirefoxStore, FirefoxPublishOptions};
let store = FirefoxStore::from_jwt_credentials(
"myaddon@example.com".into(),
"user:12345:6789".into(),
"jwt-secret".into(),
)?;
let zip = std::fs::read("./addon.zip")?;
store.publish(zip, FirefoxPublishOptions::default()).await?;