Skip to main content

UserProfileClient

Constructor

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

AccessLevel

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

CollectedTags

CollectedTags() → Promise.<Object>

Get the accumulated tags for the current user

Note: Subject to user's access level

Returns: User tags

DeleteUserMetadata

DeleteUserMetadata({ metadataSubtree }) // optional

Delete the specified subtree from the users profile metadata

Parameters

NameTypeRequiredDescription
metadataSubtreestring

Subtree to delete - deletes all metadata if not specified

MergeUserMetadata

MergeUserMetadata({
  metadata,
  metadataSubtree // optional
})

Merge the current user's profile metadata

Parameters

NameTypeRequiredDescription
metadataObject

New metadata

metadataSubtreestring

Subtree to merge into - modifies root metadata if not specified

PublicUserMetadata

PublicUserMetadata({
  address, // optional
  metadataSubtree, // optional
  queryParams, // optional
  select, // optional
  resolveLinks, // optional
  resolveIncludeSource, // optional
  resolveIgnoreErrors, // optional
  linkDepthLimit // optional
}) → Promise.<(Object|string)>

Access the specified user's public profile metadata

Parameters

NameTypeRequiredDescription
addressstring

The address of the user

metadataSubtreestring

Subtree of the metadata to retrieve

queryParamsObject

Additional query params for the call

(default: {})
selectArray.<string>

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"
resolveLinksboolean

If specified, links in the metadata will be resolved

(default: false)
resolveIncludeSourceboolean

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",
}
...
}
}

(default: false)
resolveIgnoreErrorsboolean

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

(default: false)
linkDepthLimitnumber

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

(default: 1)

ReplaceUserMetadata

ReplaceUserMetadata({
  metadata,
  metadataSubtree // optional
})

Replace the current user's profile metadata

Parameters

NameTypeRequiredDescription
metadataObject

New metadata

metadataSubtreestring

Subtree to replace - modifies root metadata if not specified

SetAccessLevel

SetAccessLevel({ level })

Set the current user's access level.

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

Parameters

NameTypeRequiredDescription
level

SetTenantContractId

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

NameTypeRequiredDescription
tenantContractIdstring

The tenant contract ID in hash format

addressstring

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

SetTenantId

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

NameTypeRequiredDescription
idstring

The tenant ID in hash format

addressstring

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

SetUserProfileImage

SetUserProfileImage({ image })

Set a new profile image for the current user

Parameters

NameTypeRequiredDescription
imageblob

The new profile image for the current user

TenantContractId

TenantContractId() → Promise.<string>

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

Returns: Tenant Contract ID

TenantId

TenantId() → Promise.<string>

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

Returns: Tenant ID

UserMetadata

UserMetadata({
  metadataSubtree, // optional
  queryParams, // optional
  select, // optional
  resolveLinks, // optional
  resolveIncludeSource, // optional
  resolveIgnoreErrors, // optional
  linkDepthLimit // optional
}) → 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

NameTypeRequiredDescription
metadataSubtreestring

Subtree of the metadata to retrieve

queryParamsObject

Additional query params for the call

(default: {})
selectArray.<string>

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"
resolveLinksboolean

If specified, links in the metadata will be resolved

(default: false)
resolveIncludeSourceboolean

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",
}
...
}
}

(default: false)
resolveIgnoreErrorsboolean

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

(default: false)
linkDepthLimitnumber

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

(default: 1)

UserProfileImage

UserProfileImage({
  address, // optional
  height // optional
}) → 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

NameTypeRequiredDescription
addressstring

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

heightnumber

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

UserWalletAddress

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

NameTypeRequiredDescription
addressstring

The address of the user

UserWalletObjectInfo

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.

WalletAddress

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