SigninInput

Struct SigninInput 

Source
pub struct SigninInput(/* private fields */);
Expand description

The Sign In input used as parameters when performing SignInWithSolana (SIWS) requests as defined by the SIWS standard. A backup fork can be found at https://github.com/JamiiDao/sign-in-with-solana

Implementations§

Source§

impl SigninInput

Source

pub fn new() -> Self

Same as Self::default() as it initializes Self with default values

Source

pub fn set_domain(&mut self, window: &Window) -> WalletResult<&mut Self>

An EIP-4361 domain requesting the sign-in. If not provided, the wallet must determine the domain to include in the message. Sets the domain name by fetching the details from window.location().host() .

Source

pub fn set_custom_domain(&mut self, domain: &str) -> &mut Self

An EIP-4361 domain requesting the sign-in. If not provided, the wallet must determine the domain to include in the message. Sets a custom domain name instead of fetching from window.location().host()

Source

pub fn set_address(&mut self, address: &str) -> WalletResult<&mut Self>

The Base58 public key address NOTE: Some wallets require this field or an error MessageResponseMismatch which is as a result of the sent message not corresponding with the signed message

Source

pub fn set_statement(&mut self, statement: &str) -> &mut Self

An EIP-4361 Statement which is a human readable string and should not have new-line characters (\n). Sets the message that is shown to the user during Sign In With Solana

Source

pub fn set_uri(&mut self, window: &Window) -> WalletResult<&mut Self>

An EIP-4361 URI is automatically set to the window.location.href since if it is not the same, the wallet will ignore it and show the user an error. This is the URL that is requesting the sign-in.

Source

pub fn set_version(&mut self, version: &str) -> &mut Self

An EIP-4361 version. Sets the version

Source

pub fn set_chain_id(&mut self, cluster: Cluster) -> &mut Self

An EIP-4361 Chain ID. The chainId can be one of the following: mainnet, testnet, devnet, localnet, solana:mainnet, solana:testnet, solana:devnet.

Source

pub fn set_nonce(&mut self) -> &mut Self

An EIP-4361 Nonce which is an alphanumeric string containing a minimum of 8 characters. This is generated from the Cryptographically Secure Random Number Generator and the bytes converted to hex formatted string.

Source

pub fn custom_nonce(&mut self, nonce: &str) -> WalletResult<&mut Self>

An EIP-4361 Nonce which is an alphanumeric string containing a minimum of 8 characters. This is generated from the Cryptographically Secure Random Number Generator and the bytes converted to hex formatted string.

Source

pub fn time_now() -> WalletResult<SystemTime>

Fetches the time from JavaScript Date Now . This is converted to SystemTime

Source

pub fn set_issued_at(&mut self) -> WalletResult<&mut Self>

This represents the time at which the sign-in request was issued to the wallet. Note: For Phantom, issuedAt has a threshold and it should be within +- 10 minutes from the timestamp at which verification is taking place. If not provided, the wallet does not include Issued At in the message. This also follows the ISO 8601 datetime.

Source

pub fn set_expiration_time_millis( &mut self, expiration_time_milliseconds: u64, ) -> WalletResult<&mut Self>

An ergonomic method for Self::set_expiration_time() where you can add milliseconds and SystemTime is automatically calculated for you

Source

pub fn set_expiration_time_seconds( &mut self, expiration_time_seconds: u64, ) -> WalletResult<&mut Self>

An ergonomic method for Self::set_expiration_time() where you can add seconds and SystemTime is automatically calculated for you

Source

pub fn set_expiration_time( &mut self, expiration_time: SystemTime, ) -> WalletResult<&mut Self>

An ISO 8601 datetime string. This represents the time at which the sign-in request should expire. If not provided, the wallet does not include Expiration Time in the message. Expiration time should be in future or an error will be thrown even before a request to the wallet is sent

Source

pub fn set_not_before_time_millis( &mut self, expiration_time_milliseconds: u64, ) -> WalletResult<&mut Self>

An ergonomic method for Self::set_not_before_time() where you can add milliseconds and SystemTime is automatically calculated for you

Source

pub fn set_not_before_time_seconds( &mut self, expiration_time_seconds: u64, ) -> WalletResult<&mut Self>

An ergonomic method for Self::set_not_before_time() where you can add seconds and SystemTime is automatically calculated for you

Source

pub fn set_not_before_time( &mut self, not_before: SystemTime, ) -> WalletResult<&mut Self>

An ISO 8601 datetime string. This represents the time at which the sign-in request becomes valid. If not provided, the wallet does not include Not Before in the message. Time must be after IssuedTime

Source

pub fn get_object(&self) -> WalletResult<JsValue>

Converts Self to a JsValue to pass to the wallet where it’s internal representation is a js_sys::Object

Source

pub fn set_request_id(&mut self, id: &str) -> &mut Self

An EIP-4361 Request ID. In addition to using nonce to avoid replay attacks, dapps can also choose to include a unique signature in the requestId . Once the wallet returns the signed message, dapps can then verify this signature against the state to add an additional, strong layer of security. If not provided, the wallet must not include Request ID in the message.

Source

pub fn add_resource(&mut self, resource: &str) -> &mut Self

An EIP-4361 Resources. Usually a list of references in the form of URIs that the dapp wants the user to be aware of. These URIs should be separated by \n-, ie, URIs in new lines starting with the character -. If not provided, the wallet must not include Resources in the message.

Source

pub fn add_resources(&mut self, resources: &[&str]) -> &mut Self

Helper for Self::add_resource() when you want to add multiple resources at the same time

Source

pub fn domain(&self) -> Option<&String>

Get the domain field

Source

pub fn address(&self) -> Option<&String>

Get the address field

Source

pub fn statement(&self) -> Option<&String>

Get the statement field

Source

pub fn uri(&self) -> Option<&String>

Get the uri field

Source

pub fn version(&self) -> Option<&String>

Get the version field

Source

pub fn chain_id(&self) -> Option<&Cluster>

Get the chain_id field

Source

pub fn nonce(&self) -> Option<&String>

Get the nonce field

Source

pub fn issued_at(&self) -> Option<&SystemTime>

Get the issued_at field

Source

pub fn expiration_time(&self) -> Option<&SystemTime>

Get the expiration_time field

Source

pub fn not_before(&self) -> Option<&SystemTime>

Get the not_before field

Source

pub fn issued_at_iso8601(&self) -> Option<String>

Get the issued_at field as ISO8601 date time string

Source

pub fn expiration_time_iso8601(&self) -> Option<String>

Get the expiration_time field as ISO8601 date time string

Source

pub fn not_before_iso8601(&self) -> Option<String>

Get the not_before field as ISO8601 date time string

Source

pub fn request_id(&self) -> Option<&String>

Get the request_id field

Source

pub fn resources(&self) -> &[String]

Get the resources field

Trait Implementations§

Source§

impl Clone for SigninInput

Source§

fn clone(&self) -> SigninInput

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SigninInput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SigninInput

Source§

fn default() -> SigninInput

Returns the “default value” for a type. Read more
Source§

impl Hash for SigninInput

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for SigninInput

Source§

fn cmp(&self, other: &SigninInput) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for SigninInput

Source§

fn eq(&self, other: &SigninInput) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for SigninInput

Source§

fn partial_cmp(&self, other: &SigninInput) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for SigninInput

Source§

impl StructuralPartialEq for SigninInput

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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