User
Methods
name | type | Parameters Description | response |
---|---|---|---|
searchUsers | function | walletAddress: string | Promise:SearchUsersResponse |
getMyProfile | function | none | Promise:SearchUsersResponse |
updateMyProfile | function | 1.nickname: string 2.avatar_url: string | Promise:UpdateMyProfileResponse |
getUserBindDids | function | none | Promise:UserBindDidIdsResponse[ ] |
userBindDid | function | UserBindDidParams | Promise:SearchUsersResponse |
getUserPermissions | function | none | Promise:UserPermissionsType |
getTargetUserPermissions | function | userid: string | Promise:SearchUsersResponse |
updateUserPermissions | function | UpdateUserPermissionsParams | Promise: SearchUsersResponse |
Permission
User permission currently only has
user: chat
rule, which Indicates the setting of user chat permission.user: chat
rule haspublic
,follower
,following
,friends
values, and its value type is 'enum'
- 1.
public
: Everyone can send me messages.- 2.
follower
: Only those who follow me can send messages to me.- 3.
following
: Only those I follow can send me messages.- 4.
friends
: Only those who follow each other can send me messages.
UserChatPermissionsType
name | type | format | desc | eg |
---|---|---|---|---|
type | "enum" | - | Chat permission type in user permissions | "enum" |
value | "public"|"follower"|"following"|"friends" | - | Chat permission value in user permissions | "public" |
UserPermissionsType
name | type | format | desc | eg |
---|---|---|---|---|
user: chat | UserChatPermissionsType | - | chat permission in user permisson | {'user: chat': {type: "enum",value: "public"}} |
Prerequisites
init() see: init
register() see: register
login() see: login
event see: event
Init and get Client
To use the functions of the current module, please complete the following steps first.
tip
After successful login, you can get the secret key pair from the returned result
import { useEffect, useState } from 'react';
import { Client } from '@web3mq/client';
export const App = () => {
const [fastestUrl, setFastUrl] = useState<string | null>(null);
useEffect(() => {
Client.init({
connectUrl: '', //
app_key: 'app_key', // temporary authorization key obtained by applying, will be removed in future testnets and mainnet
}).then(data => {
setFastUrl(data);
});
}, [])
if (!fastestUrl) return;
const {
tempPrivateKey,
tempPublicKey,
pubkeyExpiredTimestamp,
mainPrivateKey,
mainPublicKey,
} = loginRes
const keys = {
PrivateKey: tempPrivateKey,
PublicKey: tempPublicKey,
userid: localStorage.getItem('userid')
};
const client = Client.getInstance(keys);
return (
<Child client={client} />
)
}
Methods
searchUsers
Search for users by wallet address, support eth and starknet.
import { Client } from '@web3mq/client';
interface IProps {
client: Client;
}
export const Child = (props: IProps) => {
const { client } = props;
return (
<button
onClick={async () => {
const data = await client.user.searchUsers('walletAddress');
console.log(data);
}}>
Search Users
</button>
);
};
getMyProfile
Get my profile.
import { Client } from '@web3mq/client';
interface IProps {
client: Client;
}
export const Child = (props: IProps) => {
const { client } = props;
return (
<div>
<button
onClick={async () => {
const data = await client.user.getMyProfile();
console.log(data);
}}>
Get My Profile
</button>
</div>
);
};
updateMyProfile
update my profile, such as nickname and avatar.
import { Client } from '@web3mq/client';
interface IProps {
client: Client;
}
export const Child = (props: IProps) => {
const { client } = props;
return (
<div>
<button
onClick={async () => {
const data = await client.user.updateMyProfile(
'nickname',
'avatar_url'
);
console.log(data);
}}>
Update My Profile
</button>
</div>
);
};
getUserBindDids
Get my bound dids.
import { Client } from '@web3mq/client';
interface IProps {
client: Client;
}
export const Child = (props: IProps) => {
const { client } = props;
return (
<div>
<button
onClick={async () => {
const data = await client.user.getUserBindDids();
console.log(data);
}}>
Get User Bind Dids
</button>
</div>
);
};
userBindDid
Bound dids.
import { Client } from '@web3mq/client';
interface IProps {
client: Client;
}
export const Child = (props: IProps) => {
const { client } = props;
return (
<div>
<button
onClick={async () => {
const data = await client.user.userBindDid({
provider_id: 'provider_id',
did_type: 'did_type',
did_value: 'did_value',
});
console.log(data);
}}>
User Bind Did
</button>
</div>
);
};
getUserPermissions
Get my user permissions.
import { Client } from '@web3mq/client';
interface IProps {
client: Client;
}
export const Child = (props: IProps) => {
const { client } = props;
return (
<div>
<button
onClick={async () => {
const data = await client.user.getUserPermissions();
console.log(data);
}}>
get my permissions
</button>
</div>
);
};
getTargetUserPermissions
Get the user permissions of target users.
import { Client } from '@web3mq/client';
interface IProps {
client: Client;
}
export const Child = (props: IProps) => {
const { client } = props;
return (
<div>
<button
onClick={async () => {
const data = await client.user.getTargetUserPermissions('userid or wallet_address');
console.log(data);
}}>
get other user permissions
</button>
</div>
);
};
updateUserPermissions
Change my user permissions.
import { Client } from '@web3mq/client';
interface IProps {
client: Client;
}
export const Child = (props: IProps) => {
const { client } = props;
return (
<div>
<button
onClick={async () => {
const data = await client.user.updateUserPermissions({
permissions: {
'user: chat': {
type: "enum",
value: "public"
}
}
});
console.log(data);
}}>
update my permissions
</button>
</div>
);
};