configuration/createWeb3AuthAdapter
Type Aliases
CreateWeb3AuthAdapterParams
CreateWeb3AuthAdapterParams: {
generateChallenge
: (params
) =>Promise
\<ChallengeResponse
>;verifyChallenge
: (params
) =>Promise
\<AuthSession
>;wallet
:Web3Wallet
; }
The parameters required to create a new auth adapter.
Type declaration
generateChallenge()
generateChallenge: (
params
) =>Promise
\<ChallengeResponse
>
Generates a challenge for Web3 authentication.
This function should:
- Call your back-end server with the provided parameters.
- Your back-end server should then call the ComPilot back-end to generate a challenge.
- Return the generated challenge string.
Note: After obtaining this challenge, it must be signed by the user's wallet as part of the authentication process.
Parameters
• params: GenerateWeb3ChallengeParams
The parameters required to generate the challenge.
Returns
Promise
\<ChallengeResponse
>
A promise that resolves to the challenge response.
verifyChallenge()?
optional
verifyChallenge: (params
) =>Promise
\<AuthSession
>
After the challenge has been signed by the user's wallet, this function should be called to verify the challenge and return an auth session. If not provided, the adapter will directly call the identity API to verify the challenge. Provide this if you need to perform additional verification steps or actions on login.
Parameters
• params: VerifyWalletChallengeRequest
The parameters required to verify the challenge.
Returns
Promise
\<AuthSession
>
A promise that resolves to the auth session.
wallet
wallet:
Web3Wallet
the wallet adapter to use for authentication
GenerateWeb3ChallengeParams
GenerateWeb3ChallengeParams: {
address
:BlockchainAddress
;blockchainId
:BlockchainId
;namespace
:BlockchainNamespace
;origin
:string
; }
The parameters passed to the challenge generation function.
This is used to generate a challenge for Web3 authentication.
Type declaration
address
address:
BlockchainAddress
the address of the user
blockchainId?
optional
blockchainId:BlockchainId
the blockchain id
namespace
namespace:
BlockchainNamespace
the namespace of the user's wallet
origin
origin:
string
the origin of the request to check against allowed origins
Variables
GenerateWeb3ChallengeParams
GenerateWeb3ChallengeParams:
ZodObject
\<{address
:BlockchainAddress
;blockchainId
:ZodOptional
\<ZodUnion
\<[ZodEffects
\<ZodEnum
\<[ETHEREUM
,POLYGON
,POLYGON_AMOY
,AVALANCHE
,AVALANCHE_FUJI
,ARBITRUM
,ARBITRUM_SEPOLIA
]>,ETHEREUM
|ARBITRUM
|ARBITRUM_SEPOLIA
|OPTIMISM
|OPTIMISM_SEPOLIA
|AVALANCHE
|AVALANCHE_FUJI
|POLYGON
|POLYGON_AMOY
|SEPOLIA
|BASE
|BASE_SEPOLIA
|MOONBEAM
|MOONRIVER
|BNB
|BNB_TESTNET
|SWISSTRONIK_TESTNET
,unknown
>,ZodEffects
\<ZodEnum
\<[TEZOS
,TEZOS_GHOSTNET
]>,NEXERA_TEZOS_CHAINS
,unknown
>,ZodEffects
\<ZodEnum
\<[COSMOS
,COSMOS_TESTNET
]>,NEXERA_COSMOS_CHAINS
,unknown
>,ZodEffects
\<ZodEnum
\<["0x534e5f4d41494e"
,"0x534e5f5345504f4c4941"
]>,"0x534e5f4d41494e"
|"0x534e5f5345504f4c4941"
,unknown
>]>>;namespace
:BlockchainNamespace
;origin
:ZodString
; },"strip"
,ZodTypeAny
, {address
:BlockchainAddress
;blockchainId
:ETHEREUM
|ARBITRUM
|ARBITRUM_SEPOLIA
|OPTIMISM
|OPTIMISM_SEPOLIA
|AVALANCHE
|AVALANCHE_FUJI
|POLYGON
|POLYGON_AMOY
|SEPOLIA
|BASE
|BASE_SEPOLIA
|MOONBEAM
|MOONRIVER
|BNB
|BNB_TESTNET
|SWISSTRONIK_TESTNET
|"0x534e5f4d41494e"
|"0x534e5f5345504f4c4941"
|TEZOS
|TEZOS_GHOSTNET
|COSMOS
|COSMOS_TESTNET
;namespace
:BlockchainNamespace
;origin
:string
; }, {address
:BlockchainAddress
;blockchainId
:unknown
;namespace
:BlockchainNamespace
;origin
:string
; }>
Type declaration
address
address:
ZodUnion
\<[ZodEffects
\<ZodEffects
\<ZodString
,string
,string
>, `0x${string}`,string
>,ZodUnion
\<[ZodEffects
\<ZodString
, `tz${string}`,string
>,ZodEffects
\<ZodString
, `KT1${string}`,string
>]>,ZodEffects
\<ZodString
,string
,string
>,ZodString
]> =BlockchainAddress
blockchainId
blockchainId:
ZodOptional
\<ZodUnion
\<[ZodEffects
\<ZodEnum
\<[ETHEREUM
,POLYGON
,POLYGON_AMOY
,AVALANCHE
,AVALANCHE_FUJI
,ARBITRUM
,ARBITRUM_SEPOLIA
]>,ETHEREUM
|ARBITRUM
|ARBITRUM_SEPOLIA
|OPTIMISM
|OPTIMISM_SEPOLIA
|AVALANCHE
|AVALANCHE_FUJI
|POLYGON
|POLYGON_AMOY
|SEPOLIA
|BASE
|BASE_SEPOLIA
|MOONBEAM
|MOONRIVER
|BNB
|BNB_TESTNET
|SWISSTRONIK_TESTNET
,unknown
>,ZodEffects
\<ZodEnum
\<[TEZOS
,TEZOS_GHOSTNET
]>,NEXERA_TEZOS_CHAINS
,unknown
>,ZodEffects
\<ZodEnum
\<[COSMOS
,COSMOS_TESTNET
]>,NEXERA_COSMOS_CHAINS
,unknown
>,ZodEffects
\<ZodEnum
\<["0x534e5f4d41494e"
,"0x534e5f5345504f4c4941"
]>,"0x534e5f4d41494e"
|"0x534e5f5345504f4c4941"
,unknown
>]>>
namespace
namespace:
ZodEnum
\<["tezos"
,"eip155"
,"aptos"
,"polkadot"
,"starknet"
,"cosmos"
,"solana"
,"cardano"
]> =BlockchainNamespace
origin
origin:
ZodString
Functions
createWeb3AuthAdapter()
createWeb3AuthAdapter(
params
):Web3AuthAdapter
Create a new web3 auth adapter.
Parameters
• params: CreateWeb3AuthAdapterParams
the parameters to create the adapter
Returns
the auth adapter