> For the complete documentation index, see [llms.txt](https://dev.vulos.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.vulos.io/reference/identity-javascript-sdk/the-base-package/authentication/userinfo.md).

# UserInfo

## Members

### `response : any`

The [OpenID userinfo endpoint](/identity/scopes-and-claims.md#user-info) response that this object was created with.

## Methods

### `constructor(response)`

Create an object that contains user information

```javascript
const response = await fetch(/* arguments to fetch the OpenID userinfo endpoint */)
        .then(data => data.json())
const userInfo = new UserInfo(response)

// ... or

const userInfo = user.info()
```

{% hint style="warning" %}
This probably shouldn't get called directly, use [`User.info()`](/reference/identity-javascript-sdk/the-base-package/authentication/user.md#async-info) instead.
{% endhint %}

{% hint style="info" %}
See [`User`](/reference/identity-javascript-sdk/the-base-package/authentication/user.md) for more information.
{% endhint %}

{% hint style="info" %}
See [`BaseAuth`](/reference/identity-javascript-sdk/the-base-package/authentication/baseauth.md) for more information.
{% endhint %}

### `id()`

Get an unique identifier about the user.

{% hint style="info" %}
This is the same as [`sub()`](#sub), it exists for readability.
{% endhint %}

{% hint style="warning" %}
This function requires the [`openid`](/identity/scopes-and-claims.md#openid) scope.
{% endhint %}

```javascript
const identifier = userInfo.id()
```

### `sub()`

Get an unique identifier about the user.

{% hint style="info" %}
This is the same as [`id()`](#id), it exists for readability.
{% endhint %}

{% hint style="warning" %}
This function requires the [`openid`](/identity/scopes-and-claims.md#openid) scope.
{% endhint %}

```javascript
const identifier = userInfo.sub()
```

### `firstName()`

Get the user's first name.

{% hint style="warning" %}
This function requires the [`profile`](/identity/scopes-and-claims.md#profile) scope.
{% endhint %}

```javascript
const firstName = userInfo.firstName()
```

### `lastName()`

Get the user's last name.

{% hint style="warning" %}
This function requires the [`profile`](/identity/scopes-and-claims.md#profile) scope.
{% endhint %}

```javascript
const lastName = userInfo.lastName()
```

### `birthDate()`

Get the user's birth date.

{% hint style="warning" %}
This function requires the [`profile`](/identity/scopes-and-claims.md#profile) scope.
{% endhint %}

```javascript
const birthDate = userInfo.birthDate()
// birthDate is a JavaScript Date object
```

### `nationalId()`

Get the user's unique national identifier (for example their SSN in the US).

{% hint style="warning" %}
This function requires the [`private`](/identity/scopes-and-claims.md#private) scope.
{% endhint %}

```javascript
const nationalId = userInfo.nationalId()
```

### `trustLevel()`

Get the user's Vulos Identity trust level.

* `1` indicates that the user has done no KYC verification but has provided basic details.
* `2` indicates that the user has successfully KYC verification.
* Anything other than that indicates that the user has done some action to reduce or increase their trust level that hasn't been specified in this document.

{% hint style="warning" %}
This function requires the [`public`](/identity/scopes-and-claims.md#public) scope.
{% endhint %}

```javascript
if (userInfo.trustLevel() >= 2) {
    // allow the user to preform some action limited
    // to users that have confirmed their identity
}
```

### `isEmailVerified()`

Get the user's email verification status.

{% hint style="warning" %}
This function requires the [`email`](/identity/scopes-and-claims.md#email) scope.
{% endhint %}

```javascript
if (userInfo.isEmailVerified()) {
    // allow the user to use that email for some action
}
```

### `isKycVerified()`

Get the user's KYC verification status.

{% hint style="warning" %}
This function requires the [`public`](/identity/scopes-and-claims.md#public) scope.
{% endhint %}

```javascript
if (userInfo.isKycVerified()) {
    // allow the user to do some action that requires
    // KYC verification or a confirmed identity
}
```

### `address()`

Get the user's address.

{% hint style="warning" %}
This function requires the [`address`](/identity/scopes-and-claims.md#address) scope.
{% endhint %}

```javascript
const addressObj = userInfo.address()
```

### `email()`

Get the user's email address.

{% hint style="warning" %}
This function requires the [`email`](/identity/scopes-and-claims.md#email) scope.
{% endhint %}

```javascript
const email = userInfo.email()
```

### `hasRole(role)`

Check if the user has a specific role in the associated organization to the application.

{% hint style="warning" %}
This function requires the [`organization:roles`](/identity/scopes-and-claims.md#organization-roles) scope.
{% endhint %}

```javascript
if (userInfo.hasRole('SuperAdmin')) {
    // allow the user to have elevated access
}
```

### `isInOrganizationWithName(name)`

Check if the user is in a specific organization by name.

{% hint style="warning" %}
This function requires the [`organization:read`](/identity/scopes-and-claims.md#organization-read) scope.
{% endhint %}

```javascript
if (userInfo.isInOrganizationWithName('My Organization')) {
    // the user is in an organization with name 'My Organization'
}
```

{% hint style="warning" %}
It is recommended to use [`isInOrganizationWithId()`](#isinorganizationwithid-id) instead.
{% endhint %}

### `isInOrganizationWithId(id)`

Check if the user is in a specific organization by id.

{% hint style="info" %}
You can obtain the organization ID using the [Organization API](/reference/identity-javascript-sdk/the-base-package/organizations/organizationapi.md) or by checking the URL of the organization's page on the Vulos Identity dashboard.
{% endhint %}

{% hint style="warning" %}
This function requires the [`organization:read`](/identity/scopes-and-claims.md#organization-read) scope.
{% endhint %}

```javascript
const organizationId = 100;
if (userInfo.isInOrganizationWithId(organizationId)) {
    // the user is in the organization with ID 100
}
```

### `wallets()`

Get the user's Ethereum wallet addresses.

{% hint style="warning" %}
This function requires the [`wallet`](/identity/scopes-and-claims.md#wallet) scope.
{% endhint %}

```javascript
for (const walletAddress of userInfo.wallets()) {
    // do something with the wallet address
}
```

### `picture()`

Get the user's profile picture.

{% hint style="warning" %}
This function requires the [`profile`](/identity/scopes-and-claims.md#profile) scope.
{% endhint %}

```javascript
const profilePictureUrl = userInfo.picture()
```
