UserProfileClient

new UserProfileClient()

Methods used to access and modify information about the user

A note about access level and prompts:

Note: This section only applies to applications working within Eluvio Core

Users can choose whether or not their info is shared to applications. A user may choose to allow open access to their profile, no access to their profile, or they may choose to be prompted to give access when an application requests it. The user's access level can be determined using the AccessLevel method.

By default, users will be prompted to give access. For methods that access the user's private information, Eluvio Core will intercept the request and prompt the user for permission before proceeding. In these cases, the normal FrameClient timeout period will be ignored, and the response will come only after the user accepts or rejects the request.

Access and modification of user metadata is namespaced to the requesting application when using the FrameClient. Public user metadata can be accessed using the PublicUserMetadata method.

If the user refuses to give permission, an error will be thrown. Otherwise, the request will proceed as normal.

Usage

Access the UserProfileClient from ElvClient or FrameClient via client.userProfileClient

Example
let client = ElvClient.FromConfiguration({configuration: ClientConfiguration});

let wallet = client.GenerateWallet();
let signer = wallet.AddAccount({
  accountName: "Alice",
  privateKey: "0x0000000000000000000000000000000000000000000000000000000000000000"
});
client.SetSigner({signer});

await client.userProfileClient.UserMetadata()

let frameClient = new FrameClient();
await client.userProfileClient.UserMetadata()
Source:

Methods

async AccessLevel() → Promise.<string>

Return the permissions the current user allows for apps to access their profile.

"private" - No access allowed "prompt" - (default) - When access is requested by an app, the user will be prompted to give permission "public - Public - Any access allowed

Returns: Access setting
Examples
async AccessLevel();


"prompt"
async AccessLevel();


"public"
Source:

async CollectedTags() → Promise.<Object>

Get the accumulated tags for the current user

Note: Subject to user's access level

Returns: User tags
Source:

async DeleteUserMetadata({metadataSubtreeoptional})

Delete the specified subtree from the users profile metadata

Parameters:
Name Type Attributes Description
metadataSubtree string <optional>

Subtree to delete - deletes all metadata if not specified

Example
async DeleteUserMetadata({
  "metadataSubtree": "toDelete"
});


<No Return Value>
Source:

async MergeUserMetadata({
metadata,
metadataSubtreeoptional
})

Merge the current user's profile metadata

Parameters:
Name Type Attributes Description
metadata Object

New metadata

metadataSubtree string <optional>

Subtree to merge into - modifies root metadata if not specified

Examples
async MergeUserMetadata({
  "metadata": {
    "public": {
      "meta": "data"
    },
    "toMerge": {
      "meta": "data"
    },
    "toReplace": {
      "meta": "data"
    },
    "toDelete": {
      "meta": "data"
    }
  }
});


<No Return Value>
async MergeUserMetadata({
  "metadataSubtree": "toMerge",
  "metadata": {
    "new": "metadata"
  }
});


<No Return Value>
Source:

async PublicUserMetadata({
addressoptional,
metadataSubtreeoptional,
queryParamsoptional,
selectoptional,
resolveLinksoptional,
resolveIncludeSourceoptional,
resolveIgnoreErrorsoptional,
linkDepthLimitoptional
})
→ Promise.<(Object|string)>

Access the specified user's public profile metadata

Parameters:
Name Type Attributes Default Description
address string <optional>

The address of the user

metadataSubtree string <optional>

Subtree of the metadata to retrieve

queryParams Object <optional>
{}

Additional query params for the call

select Array.<string> <optional>

Limit the returned metadata to the specified attributes

  • Note: Selection is relative to "metadataSubtree". For example, metadataSubtree="public" and select=["name", "description"] would select "public/name" and "public/description"
resolveLinks boolean <optional>
false

If specified, links in the metadata will be resolved

resolveIncludeSource boolean <optional>
false

If specified, resolved links will include the hash of the link at the root of the metadata

   Example:

   {
      "resolved-link": {
        ".": {
          "source": "hq__HPXNia6UtXyuUr6G3Lih8PyUhvYYHuyLTt3i7qSfYgYBB7sF1suR7ky7YRXsUARUrTB1Um1x5a"
        },
        "public": {
          "name": "My Linked Object",
        }
        ...
      }
   }
resolveIgnoreErrors boolean <optional>
false

If specified, link errors within the requested metadata will not cause the entire response to result in an error

linkDepthLimit number <optional>
1

Limit link resolution to the specified depth. Default link depth is 1 (only links directly in the object's metadata will be resolved)

Examples
async PublicUserMetadata({
  "address": "0x793E41369eb3C8b579da28a41c350837c18b25Be"
});


{
  "meta": "data"
}
async PublicUserMetadata({
  "address": "0x793E41369eb3C8b579da28a41c350837c18b25Be",
  "metadataSubtree": "profile_image"
});


{
  ".": {
    "container": "hq__BAozYpEmQ3miKNDipwpTAaZNoNW8zQZqkEi2BT9m9uTgvVvMzaR2xpzzWcgZXH3akhbzjjRdEE"
  },
  "/": "./files/profile_image"
}
async PublicUserMetadata({
  "address": "0x793E41369eb3C8b579da28a41c350837c18b25Be",
  "metadataSubtree": "profile_image"
});


{
  ".": {
    "container": "hq__CzzwaXB2QQz76BcB8gbwz81BcXShdxb6YGxCv7GHy1KkWUTjEmfgKwMvCD19PL8ndntDW1Vqmx"
  },
  "/": "./files/profile_image"
}
Source:

async ReplaceUserMetadata({
metadata,
metadataSubtreeoptional
})

Replace the current user's profile metadata

Parameters:
Name Type Attributes Description
metadata Object

New metadata

metadataSubtree string <optional>

Subtree to replace - modifies root metadata if not specified

Examples
async ReplaceUserMetadata({
  "metadataSubtree": "toReplace",
  "metadata": {
    "new": "metadata"
  }
});


<No Return Value>
async ReplaceUserMetadata({
  "metadataSubtree": "access_level",
  "metadata": "public"
});


<No Return Value>
Source:

async SetAccessLevel({level})

Set the current user's access level.

Note: This method is not accessible to applications. Eluvio core will drop the request.

Parameters:
Name Type Description
level
Example
async SetAccessLevel({
  "level": "public"
});


<No Return Value>
Source:

async SetTenantContractId({
tenantContractId,
address
})

Set the current user's tenant contract.

Note: This method is not accessible to applications. Eluvio core will drop the request.

Parameters:
Name Type Description
tenantContractId string

The tenant contract ID in hash format

address string

The tenant address to use in the hash if id is not provided

Source:

async SetTenantId({
id,
address
})

Set the current user's tenant admin group ID

Note: This method is not accessible to applications. Eluvio core will drop the request.

Parameters:
Name Type Description
id string

The tenant ID in hash format

address string

The group address to use in the hash if id is not provided

Source:

async SetUserProfileImage({image})

Set a new profile image for the current user

Parameters:
Name Type Description
image blob

The new profile image for the current user

Examples
async SetUserProfileImage({
  "image": "<ArrayBuffer 101254>"
});


<No Return Value>
async SetUserProfileImage({
  "image": "<ArrayBuffer 102268>"
});


<No Return Value>
Source:

async TenantContractId() → Promise.<string>

Return the ID of the tenant contract this user belongs to, if set.

Returns: Tenant Contract ID
Source:

async TenantId() → Promise.<string>

Return the ID of the tenant admin group set for current user

Returns: Tenant ID
Example
async TenantId();


<No Return Value>
Source:

async UserMetadata({
metadataSubtreeoptional,
queryParamsoptional,
selectoptional,
resolveLinksoptional,
resolveIncludeSourceoptional,
resolveIgnoreErrorsoptional,
linkDepthLimitoptional
})
→ Promise.<(Object|string)>

Access the current user's metadata

Note: Subject to user's access level

Returns: The user's profile metadata - returns undefined if no metadata set or subtree doesn't exist
Parameters:
Name Type Attributes Default Description
metadataSubtree string <optional>

Subtree of the metadata to retrieve

queryParams Object <optional>
{}

Additional query params for the call

select Array.<string> <optional>

Limit the returned metadata to the specified attributes

  • Note: Selection is relative to "metadataSubtree". For example, metadataSubtree="public" and select=["name", "description"] would select "public/name" and "public/description"
resolveLinks boolean <optional>
false

If specified, links in the metadata will be resolved

resolveIncludeSource boolean <optional>
false

If specified, resolved links will include the hash of the link at the root of the metadata

   Example:

   {
      "resolved-link": {
        ".": {
          "source": "hq__HPXNia6UtXyuUr6G3Lih8PyUhvYYHuyLTt3i7qSfYgYBB7sF1suR7ky7YRXsUARUrTB1Um1x5a"
        },
        "public": {
          "name": "My Linked Object",
        }
        ...
      }
   }
resolveIgnoreErrors boolean <optional>
false

If specified, link errors within the requested metadata will not cause the entire response to result in an error

linkDepthLimit number <optional>
1

Limit link resolution to the specified depth. Default link depth is 1 (only links directly in the object's metadata will be resolved)

Examples
async UserMetadata({
  "metadataSubtree": "public/name"
});


<No Return Value>
async UserMetadata();


{
  "commit": {
    "author": "0x793e41369eb3c8b579da28a41c350837c18b25be",
    "author_address": "0x793e41369eb3c8b579da28a41c350837c18b25be",
    "message": "Merge user metadata",
    "timestamp": "2021-03-09T19:58:53.628Z"
  },
  "public": {
    "meta": "data"
  },
  "toDelete": {
    "meta": "data"
  },
  "toMerge": {
    "meta": "data"
  },
  "toReplace": {
    "meta": "data"
  }
}
async UserMetadata({
  "metadataSubtree": "toMerge"
});


{
  "meta": "data"
}
async UserMetadata({
  "metadataSubtree": "public/name"
});


<No Return Value>
async UserMetadata({
  "metadataSubtree": "public/name"
});


<No Return Value>
async UserMetadata({
  "metadataSubtree": "public/name"
});


<No Return Value>
async UserMetadata();


{
  "commit": {
    "author": "0x793e41369eb3c8b579da28a41c350837c18b25be",
    "author_address": "0x793e41369eb3c8b579da28a41c350837c18b25be",
    "message": "Delete user metadata",
    "timestamp": "2021-03-09T19:59:05.166Z"
  },
  "public": {
    "meta": "data"
  },
  "toMerge": {
    "meta": "data",
    "new": "metadata"
  },
  "toReplace": {
    "new": "metadata"
  }
}
async UserMetadata({
  "metadataSubtree": "public/name"
});


<No Return Value>
async UserMetadata({
  "metadataSubtree": "public/name"
});


<No Return Value>
async UserMetadata({
  "metadataSubtree": "tenantId"
});


<No Return Value>
async UserMetadata({
  "metadataSubtree": "public/name"
});


<No Return Value>
async UserMetadata({
  "metadataSubtree": "public/name"
});


<No Return Value>
async UserMetadata({
  "metadataSubtree": "public/name"
});


<No Return Value>
async UserMetadata({
  "metadataSubtree": "public/links/metadataLink",
  "resolveLinks": true
});


{
  "data": "metadata"
}
async UserMetadata({
  "metadataSubtree": "access_level"
});


<No Return Value>
async UserMetadata({
  "metadataSubtree": "public/name"
});


<No Return Value>
async UserMetadata({
  "metadataSubtree": "access_level"
});


"public"
Source:

async UserProfileImage({
addressoptional,
heightoptional
})
→ Promise.<(string|undefined)>

Get the URL of the current user's profile image

Note: Part hash of profile image will be appended to the URL as a query parameter to invalidate browser caching when the image is updated

Returns: URL of the user's profile image. Will be undefined if no profile image is set.
Parameters:
Name Type Attributes Description
address string <optional>

The address of the user. If not specified, the address of the current user will be used.

height number <optional>

If specified, the image will be scaled to the specified maximum height

Examples
async UserProfileImage();


"https://host-34-105-49-255.testv2.contentfabric.io/q/hq__BAozYpEmQ3miKNDipwpTAaZNoNW8zQZqkEi2BT9m9uTgvVvMzaR2xpzzWcgZXH3akhbzjjRdEE/meta/public/profile_image?authorization=eyJxc3BhY2VfaWQiOiJpc3BjNEJSbW9uVGlnOVFTRDg3TVJXUDhGNWlMZmRjdCIsImFkZHIiOiIweDc5M2U0MTM2OWViM2M4YjU3OWRhMjhhNDFjMzUwODM3YzE4YjI1YmUifQ%3D%3D.RVMyNTZLX0pSdkx2Vm5CR0dHM3F4NG1ZWXpLcktuZnkyRENWc3BGTVFneG1IM00xWkRwZndBZXVUc2ZpTUxOQzVvNEdYVlFIM3JzSHpzR2pTY0hSN1hITDhneTNSbVNi&resolve=true"
async UserProfileImage({
  "address": "0x793E41369eb3C8b579da28a41c350837c18b25Be"
});


"https://host-34-105-49-255.testv2.contentfabric.io/q/hq__CzzwaXB2QQz76BcB8gbwz81BcXShdxb6YGxCv7GHy1KkWUTjEmfgKwMvCD19PL8ndntDW1Vqmx/meta/public/profile_image?authorization=eyJxc3BhY2VfaWQiOiJpc3BjNEJSbW9uVGlnOVFTRDg3TVJXUDhGNWlMZmRjdCIsImFkZHIiOiIweDc5M2U0MTM2OWViM2M4YjU3OWRhMjhhNDFjMzUwODM3YzE4YjI1YmUifQ%3D%3D.RVMyNTZLX0pSdkx2Vm5CR0dHM3F4NG1ZWXpLcktuZnkyRENWc3BGTVFneG1IM00xWkRwZndBZXVUc2ZpTUxOQzVvNEdYVlFIM3JzSHpzR2pTY0hSN1hITDhneTNSbVNi&resolve=true"
Source:

async UserWalletAddress({address}) → Promise.<string>

Get the user wallet address for the specified user, if it exists

Returns: The wallet address of the specified user, if it exists
Parameters:
Name Type Description
address string

The address of the user

Example
async UserWalletAddress({
  "address": "0x793E41369eb3C8b579da28a41c350837c18b25Be"
});


"0x241a6aB51F92720FAe628FF193886be4844e03ef"
Source:

async UserWalletObjectInfo() → Promise.<{Object}>

Retrieve the user wallet object information (library ID and object ID)

The user's wallet can be modified in the same way as any other object, using EditContentObject to get a write token, modification methods to change it, and FinalizeContentObject to finalize the draft

Returns: An object containing the libraryId and objectId for the wallet object.
Examples
async UserWalletObjectInfo();


{
  "libraryId": "ilib4BRmonTig9QSD87MRWP8F5iLfdct",
  "objectId": "iq__WB24yeBj9Hb9rsyxoDBv4z9xi1t"
}
async UserWalletObjectInfo({
  "address": "0x793E41369eb3C8b579da28a41c350837c18b25Be"
});


{
  "libraryId": "ilib4BRmonTig9QSD87MRWP8F5iLfdct",
  "objectId": "iq__WB24yeBj9Hb9rsyxoDBv4z9xi1t"
}
Source:

async WalletAddress() → Promise.<string>

Get the contract address of the current user's BaseAccessWallet contract

Returns: The contract address of the current user's wallet contract
Examples
async WalletAddress();


"0x241a6aB51F92720FAe628FF193886be4844e03ef"
async WalletAddress(false);


"0x241a6aB51F92720FAe628FF193886be4844e03ef"
Source: