WalletAuthService
Service for handling wallet-based authentication and decryption with Crossmint.
The WalletAuthService
class provides methods to retrieve a challenge for wallet authentication and to decrypt credentials using that challenge.
Constructors
new WalletAuthService()
new WalletAuthService():
WalletAuthService
Returns
Methods
decrypt()
decrypt(
credential
,challenge
,signature
,userAddress
):Promise
<any
>
Decrypts an encrypted verifiable credential using a signed challenge.
This method sends the signed challenge, the user’s address, and the encrypted credential to Crossmint for decryption.
Parameters
Parameter | Type | Description |
---|---|---|
credential | EncryptedVerifiableCredential | The encrypted verifiable credential to decrypt. |
challenge | string | The challenge that was signed by the user’s wallet. |
signature | string | The signature of the challenge signed by the user’s wallet. |
userAddress | string | The blockchain address of the user requesting decryption. |
Returns
Promise
<any
>
A promise that resolves to the decrypted data.
Throws
Will throw an error if the decryption request fails or if the response is invalid.
Defined in
getChallenge()
getChallenge(
userAddress
):Promise
<string
>
Retrieves a challenge nonce for wallet authentication.
This method requests a challenge from Crossmint that can be signed by the user’s wallet to authenticate the user.
Parameters
Parameter | Type | Description |
---|---|---|
userAddress | string | The blockchain address of the user requesting the challenge. |
Returns
Promise
<string
>
A promise that resolves to a string representing the challenge to sign.
Throws
Will throw an error if the challenge request fails or if the response is invalid.