Skip to main content

User info

getUserInfo() returns the signed-in user's identity (username, user ID and attributes) by merging what Cognito holds with the profile your ESP RainMaker Neo deployment stores. It is the call to make when you need a display name, an email address, or the user ID that group sharing works in terms of.

const info = await user.getUserInfo();

console.log(info.username);
console.log(info.userId);
console.log(info.userAttributes.email);

Returns Promise<ESPRMNeoUserInfo>:

FieldContents
usernamePhone number if present, else email, else the Cognito username
userIdThe deployment's user ID
userAttributesMerged attribute map, values possibly undefined

How the merge works

Two sources are combined. Cognito supplies the attribute map and the raw username; the deployment's profile endpoint supplies the user ID and its own view of email and phone number. Where both carry a value, the deployment's wins.

username is resolved by preference, not by which source answered: a phone number if the attributes carry one, otherwise an email address, otherwise Cognito's own username field. An account registered by phone therefore reports its phone number here even though it may also have an email attribute.

userAttributes is keyed by Cognito attribute name, so expect email, phone_number and user_id alongside any custom attributes your deployment defines. Values are typed as possibly undefined, read defensively rather than asserting.

The user ID is not the Cognito subject

userId is the deployment's own identifier for the account, which is what sharing and group membership are expressed in. It is not interchangeable with the Cognito sub claim, and using the wrong one against group APIs is rejected rather than silently ignored.

Where the user ID is used

userId is the value you compare against when reading group membership, and the value you pass to remove somebody from a group:

const info = await user.getUserInfo();
const sharing = await group.getSharingInfo();

const me = sharing.users.find((u) => u.userId === info.userId);
console.log(me?.accessType);

To remove yourself from a group use group.leave() rather than group.removeMember(info.userId), the latter rejects the caller's own ID. See Sharing.

What this call does not cover

There is no profile-update method on this SDK, and no custom-data or tag API on the user. getUserInfo() is read-only, and the attributes it returns are managed by your deployment rather than by the app.