8 releases
new 0.3.1 | May 19, 2025 |
---|---|
0.3.0 | May 19, 2025 |
0.2.1 | May 19, 2025 |
0.1.3 | May 19, 2025 |
#358 in Authentication
134 downloads per month
47KB
903 lines
cw-auths
Storage / Replay
The library is aim tp provide helpful primitives for verifying and then storing credentials in a secure and easy way
# first verify all the credentials and then store them stored in the storage
credential_data.save_cosmwasm(deps.api, deps.storage, &env, &info)?;
When replay attack protection is enabled, the library will enforce the message to include a contract address, a chain id and a nonce that should be equal to the current account number
After a successful verification an account contract must increment the nonce to prevent replay attacks
increment_account_number(deps.storage)?;
The library also provides a helper function to verify the signed actions which will verify the credentials and then increment the nonce automatically
verify_signed_actions(deps.api, deps.storage, &env, data)?;
Registries / Factories
In some cases you can want to use credemtials for accounts that are not yet created and therefire do not have an account number (unless instantiate2 is used).
In cases like that you can use address of a registry / factory contract in data to sign. Later after the account contract is created you can create a new Env
object with overwritten contract address
let registry_env = Env {
contract: ContractInfo { address: info.sender.clone() },
..env.clone()
};
data.save_cosmwasm(api, storage, ®istry_env, &info)?;
Dependencies
~4.5–8MB
~165K SLoC