Skip to main content

FirefoxStore

Struct FirefoxStore 

Source
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

Source

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).

Source

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.

Source

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?;

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more