Profile Claim
The Profile Claim is used to request personal information from a user's DID Wallet. It is a fundamental part of many applications, commonly used for user registration, personalizing the user experience, or establishing contact details. Your application can specify exactly which pieces of information it requires.
How it Works#
When you request a profile claim, the user's wallet will present a screen displaying your application's name, the description you provided, and a list of the specific data points you've requested (e.g., Full Name, Email). The user can then choose to approve or decline the sharing of this information.
Parameters#
The profile claim object is configured with the following parameters:
Parameter | Type | Description |
---|---|---|
|
| A message displayed to the user in their wallet explaining why their profile information is being requested. Defaults to |
|
| An array specifying which pieces of profile information to request. The alias |
Available Profile Items#
You can request any combination of the following items in the items
array:
Item | Description |
---|---|
| The user's Decentralized Identifier. |
| The user's full name. |
| The user's email address. |
| The user's phone number. |
| A signature of the profile data, proving its authenticity and binding it to the user's DID. |
| A URL to the user's avatar image. |
| The user's date of birth. |
| A URL to the user's personal website or social profile. |
How to Use#
To request a user's profile, you define a profile
claim within the claims
object of your DID Connect configuration. You specify the desired information in the items
(or fields
) array.
// Example of defining a profile claim in a handler
module.exports = {
action: 'profile',
claims: {
profile: () => ({
description: 'Please provide your full profile to create an account.',
// You can use 'items' or 'fields' to specify the required data.
items: ['fullName', 'email', 'avatar', 'birthday'],
}),
},
onAuth: async ({ userDid, claims }) => {
// After the user approves, the profile data is in the `claims` array.
const profileData = claims.find(c => c.type === 'profile');
console.log('Authenticated user DID:', userDid);
console.log('Received profile data:', profileData);
// Here you would typically find or create a user in your database
// using userDid as the primary identifier and profileData to populate their account.
},
};
In this example, the application asks for the user's full name, email, avatar, and birthday to set up their account. The onAuth
callback receives this information after the user consents.
Wallet Response#
If the user approves the request, the wallet will send a response containing the profile data. The claims
array in the verified response will include an object with type: 'profile'
and the requested fields as key-value pairs.
{
"userDid": "z1...",
"userPk": "z2...",
"claims": [
{
"type": "profile",
"fullName": "Alice Smith",
"email": "alice@example.com",
"avatar": "https://arcblock.oss-cn-beijing.aliyuncs.com/images/wallet-round.png",
"birthday": "1990-01-15"
}
],
"action": "responseAuth",
"challenge": "...",
"timestamp": 1678886400
}
After retrieving a user's profile, you might need to verify their control over their DID by asking for a signature. Learn how in the Signature Claim documentation.