# Security

## Get User Security Settings

`client.user.security.get(RequestOptionsoptions?): UserSecurity`

**get** `/v1/user/security`

Get the current user's security settings

### Returns

- `UserSecurity`

  User security settings response.

  - `source_ip_rule: SourceIPRuleResponse`

    IP filter rules.

    - `allowed: Array<string>`

      List of IPv4 CIDR addresses to allow.

    - `blocked: Array<string>`

      List of IPv4 CIDR addresses to deny.

  - `created_at?: string`

    When the user security settings were created.

  - `updated_at?: string`

    When the user security settings were updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const userSecurity = await client.user.security.get();

console.log(userSecurity.source_ip_rule);
```

#### Response

```json
{
  "source_ip_rule": {
    "allowed": [
      "192.168.1.0/24",
      "10.0.0.0/8"
    ],
    "blocked": [
      "192.168.1.100/32"
    ]
  },
  "created_at": "2025-01-01T00:00:00Z",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Update User Security Settings

`client.user.security.update(SecurityUpdateParamsbody, RequestOptionsoptions?): UserSecurity`

**patch** `/v1/user/security`

Update the current user's security settings

### Parameters

- `body: SecurityUpdateParams`

  - `source_ip_rule?: SourceIPRule`

    IP filter rules.

    - `allowed?: Array<string>`

      List of IPv4 CIDR addresses to allow.

    - `blocked?: Array<string>`

      List of IPv4 CIDR addresses to deny.

### Returns

- `UserSecurity`

  User security settings response.

  - `source_ip_rule: SourceIPRuleResponse`

    IP filter rules.

    - `allowed: Array<string>`

      List of IPv4 CIDR addresses to allow.

    - `blocked: Array<string>`

      List of IPv4 CIDR addresses to deny.

  - `created_at?: string`

    When the user security settings were created.

  - `updated_at?: string`

    When the user security settings were updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const userSecurity = await client.user.security.update();

console.log(userSecurity.source_ip_rule);
```

#### Response

```json
{
  "source_ip_rule": {
    "allowed": [
      "192.168.1.0/24",
      "10.0.0.0/8"
    ],
    "blocked": [
      "192.168.1.100/32"
    ]
  },
  "created_at": "2025-01-01T00:00:00Z",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Domain Types

### User Security

- `UserSecurity`

  User security settings response.

  - `source_ip_rule: SourceIPRuleResponse`

    IP filter rules.

    - `allowed: Array<string>`

      List of IPv4 CIDR addresses to allow.

    - `blocked: Array<string>`

      List of IPv4 CIDR addresses to deny.

  - `created_at?: string`

    When the user security settings were created.

  - `updated_at?: string`

    When the user security settings were updated.
