Skip to content

Module: multiauth

Multiauth APIs

npm install @self.id/multiauth

Type aliases

AuthAccount

Ƭ AuthAccount<Key>: Object

Type parameters

Name Type
Key extends ProviderKey = ProviderKey

Type declaration

Name Type
accountID AccountID
method AuthMethod
state AuthenticatedState<Key>

AuthMethod

Ƭ AuthMethod<Key>: Object

Type parameters

Name Type
Key extends NetworkKey = NetworkKey

Type declaration

Name Type
connector ConnectorConfig
key Key

AuthState

Ƭ AuthState<Key, Provider>: { status: "idle" } | { method?: AuthMethod<Key> ; modal: boolean ; promise: Deferred<AuthAccount<Provider> | null> ; status: "authenticating" } | { auth: AuthAccount<Provider> ; status: "authenticated" } | { error?: Error ; status: "failed" }

Type parameters

Name Type
Key extends NetworkKey = NetworkKey
Provider extends NetworkProvider<Key> = NetworkProvider<Key>

AuthenticateMode

Ƭ AuthenticateMode: "select" | "reset" | "reuse"


AuthenticateOptions

Ƭ AuthenticateOptions: Object

Type declaration

Name Type
mode? AuthenticateMode
showModal? boolean

AuthenticatedState

Ƭ AuthenticatedState<Key>: NetworkState<Key> & { account: string }

Type parameters

Name Type
Key extends ProviderKey = ProviderKey

Config

Ƭ Config: Object

Type declaration

Name Type
networks NetworkConfig[]

ConnectorConfig

Ƭ ConnectorConfig<Key>: ConnectorConfigDefaults & { key: Key ; providerKey: ProviderKey }

Type parameters

Name Type
Key extends ConnectorKey = ConnectorKey

ConnectorConfigDefaults

Ƭ ConnectorConfigDefaults: DisplayDefaults & { params?: unknown ; getNetworkProvider: (network: Key, params?: unknown) => null | NetworkProvider<Key> ; getProvider: (key: Key, params?: unknown) => Promise<ProviderTypes[Key]> }


ConnectorKey

Ƭ ConnectorKey: "fortmatic" | "injected" | "portis" | "torus" | "walletConnect"


DisplayDefaults

Ƭ DisplayDefaults: Object

Type declaration

Name Type
label string
logo string

EIP1193Provider

Ƭ EIP1193Provider: Object

Type declaration

Name Type
request (req: klzzwxh:0512) => Promise<Result>

GetNetworkState

Ƭ GetNetworkState<Key>: (providerKey: Key, provider: ProviderType<Key>, params?: NetworkStateParams) => Promise<NetworkState<Key>>

Type parameters

Name Type
Key extends ProviderKey = ProviderKey

Type declaration

▸ (providerKey, provider, params?): Promise<NetworkState<Key>>

Parameters
Name Type
providerKey Key
provider ProviderType<Key>
params? NetworkStateParams
Returns

Promise<NetworkState<Key>>


JSONRPCResponse

Ƭ JSONRPCResponse<Result>: Object

Type parameters

Name Type
Result unknown

Type declaration

Name Type
error? Error
id string | undefined
jsonrpc "2.0"
method string
result? Result

ModalConfig

Ƭ ModalConfig: Object

Type declaration

Name Type
closeIcon? string | ReactElement
selectedIcon? string | ReactElement
text? string
title? string

MultiAuthProviderConfig

Ƭ MultiAuthProviderConfig: Object

Type declaration

Name Type
modal? ModalConfig
networks? PartialNetworkConfig[]

NetworkConfig

Ƭ NetworkConfig<Key>: DisplayDefaults & { connectors: ConnectorConfig[] ; getState: GetNetworkState<NetworkProvider<Key>> ; key: Key }

Type parameters

Name Type
Key extends NetworkKey = NetworkKey

NetworkConfigDefaults

Ƭ NetworkConfigDefaults: DisplayDefaults & { connectors: ConnectorKey[] ; getState: GetNetworkState<ProviderKey> }


NetworkKey

Ƭ NetworkKey: keyof Networks


NetworkProvider

Ƭ NetworkProvider<Key>: Networks[Key]

Type parameters

Name Type
Key extends NetworkKey

NetworkState

Ƭ NetworkState<Key>: Object

Type parameters

Name Type
Key extends ProviderKey

Type declaration

Name Type
account string | null
chainID ChainID
provider ProviderType<Key>
providerKey Key

NetworkStateParams

Ƭ NetworkStateParams: Object

Type declaration

Name Type
account? string
chainID? ChainID | ChainIDParams | string | number

Networks

Ƭ Networks: Object

Type declaration

Name Type
ethereum "eip1193" | "web3"

PartialConfig

Ƭ PartialConfig: Object

Type declaration

Name Type
networks? PartialNetworkConfig[]

PartialConnectorConfig

Ƭ PartialConnectorConfig<Key>: Key | Partial<ConnectorConfigDefaults> & { key: Key }

Type parameters

Name Type
Key extends ConnectorKey = ConnectorKey

PartialNetworkConfig

Ƭ PartialNetworkConfig<Key>: Key | Partial<DisplayDefaults> & { connectors?: PartialConnectorConfig[] ; key: Key }

Type parameters

Name Type
Key extends NetworkKey = NetworkKey

ProviderKey

Ƭ ProviderKey: keyof ProviderTypes


ProviderProps

Ƭ ProviderProps: MultiAuthProviderConfig & { children: ReactNode }


ProviderType

Ƭ ProviderType<Key>: ProviderTypes[Key]

Type parameters

Name Type
Key extends ProviderKey

ProviderTypes

Ƭ ProviderTypes: Object

Type declaration

Name Type
eip1193 EIP1193Provider
web3 Web3Provider

RequestArguments

Ƭ RequestArguments: Object

Type declaration

Name Type
method string
params? unknown[] | Record<string, any>

Web3Provider

Ƭ Web3Provider: Object

Type declaration

Name Type
enable () => Promise<string[]>
sendAsync <Result>(req: RequestArguments, callback: Web3ProviderSendCallback<Result>) => void

Web3ProviderSendCallback

Ƭ Web3ProviderSendCallback<Result>: (err?: Error, response?: JSONRPCResponse<Result>) => void

Type parameters

Name Type
Result unknown

Type declaration

▸ (err?, response?): void

Parameters
Name Type
err? Error
response? JSONRPCResponse<Result>
Returns

void

Functions

Provider

Provider(props): ReactElement

Parameters

Name Type
props ProviderProps

Returns

ReactElement


getConnectorConfig

getConnectorConfig<Key>(network, connector): ConnectorConfig<Key>

Type parameters

Name Type
Key extends ConnectorKey

Parameters

Name Type
network "ethereum"
connector PartialConnectorConfig<Key>

Returns

ConnectorConfig<Key>


getConnectorsConfig

getConnectorsConfig(network, connectors): ConnectorConfig[]

Parameters

Name Type
network "ethereum"
connectors PartialConnectorConfig<ConnectorKey>[]

Returns

ConnectorConfig[]


getNetworkConfig

getNetworkConfig<Key>(network): NetworkConfig<Key>

Type parameters

Name Type
Key extends "ethereum"

Parameters

Name Type
network PartialNetworkConfig<Key>

Returns

NetworkConfig<Key>


getNetworksConfig

getNetworksConfig(providers): NetworkConfig[]

Parameters

Name Type
providers PartialNetworkConfig<"ethereum">[]

Returns

NetworkConfig[]


useMultiAuth

useMultiAuth(): [AuthState, (options?: AuthenticateOptions) => Promise<AuthAccount | null>, () => void]

Returns

[AuthState, (options?: AuthenticateOptions) => Promise<AuthAccount | null>, () => void]