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

WalletAuthService

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

ParameterTypeDescription
credentialEncryptedVerifiableCredentialThe encrypted verifiable credential to decrypt.
challengestringThe challenge that was signed by the user’s wallet.
signaturestringThe signature of the challenge signed by the user’s wallet.
userAddressstringThe 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

services/walletAuth.ts:57


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

ParameterTypeDescription
userAddressstringThe 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.

Defined in

services/walletAuth.ts:20