ISMEDID
Developers do not have to instantiate ISMEDID
themselves, ISMEClient
already contains its instance, which can be accessed through client.did
Property
identifier
string
,logged in DID
Method
config
used to configure the authentication details of DID, the config can be wallet private key or wallet provider.
Type
type NetworkType = 'ethereum' | 'solana'
class ISMEDID {
config(options: {
network: NetworkType
privateKey?: string
signKey?: string
signer?: Signer
}): void
}
Parameters
network
: the type of network to useprivateKey
: optional parameter, wallet private key, which needs to correspond to the network typesignKey
: optional parameters, sessionKey, session credentialssigner
: optional parameter, wallet provider
privateKey
、signer
You need to choose one of them, otherwise DID cannot complete the authentication. Usually, privateKey
is used in the Node.js environment. However wallet provide will be used in the browser environment due to the wallet private key cannot be directly accessed.
login
Authorized login DID
Type
class ISMEDID {
login(): Promise<{
result: boolean
identifier: string
needRegister: boolean
}>
}
Details
If the login is successful, it will return identifier
, if the current wallet address is not registered, it will return false
{
result: false,
needRegister: true
}
register
registered DID
Type
class ISMEDID {
register(identifier: string): Promise<{
result: boolean
identifier: string
}>
}
Details
To register DID, you need to pass the full 'identifier', for exampe did:nft3:bob
logout
Logout DID
Type
class ISMEDID {
logout(): void
}
Details
logout
will clean your local login status.
checkLogin
check the current login status
Type
class ISMEDID {
checkLogin(): Promise<{
result: boolean
identifier: string | undefined
}>
}
Details
If will return the DID if the checking result is valid.
addKey
Bind the current connected wallet to the registered DID.
Type
class ISMEDID {
addKey(): Promise<{
result: boolean
}>
}
Details
If you want to bind another wallet address to the current DID, you first need to log in to the DID, then connect to the new wallet address, and then call addKey
, this operation will call up the new wallet to sign
All wallet addresses bound to the DID can control the DID account
removeKey
Remove the connected wallet address from current logged in DID.
Type
class ISMEDID {
removeKey(): Promise<{
result: boolean
}>
}
Details
If the current DID is bound to multiple wallet addresses, and if you want to remove an address from it, you first need to log in to the DID, then connect to the wallet address to be removed, and call this method
DID requires the existence of at least one wallet address bound to it
accounts
List all wallet addresses bound to the current DID
Type
class ISMEDID {
accounts(): Promise<string[]>
}
info
Query the details of the DID.
Type
interface DIDInfo {
addresses: string[]
created_at: number
ctrl_keys: string[]
did: string
updated_at: number
}
class ISMEDID {
info(identifier?: string): Promise<DIDInfo>
}
Details
The parameter identifier
is optional. If it is not passed, SDK will use current logged in DID. If there is no current logged in DID, an error will be reported.
search
search DID users
Type
interface DIDSearchRecord {
didname: string
identifier: string
addresses: string[]
}
class ISMEDID {
search(params: {
keyword: string
mode: 'didname' | 'address'
offset?: number
limit?: number
}): Promise<DIDSearchRecord[]>
}
Parameters
keyword
: keyword to search formode
: search mode,didname
searches by DID,address
searches by wallet address bound to DIDoffset
: number of skips, used for paginationlimit
: the number of items to be returned by the query