# Class: User

## User(userPacket, mainKey)

Class that represents an user ID or attribute packet and the relevant signatures.

## Constructor

#### new User(userPacket, mainKey)

##### Parameters:

Name | Type | Description
--- | --- | ---
`userPacket` | UserIDPacket | UserAttributePacket | packet containing the user info
`mainKey` | Key | reference to main Key object containing the primary key and subkeys that the user is associated with

Source:
  - key/user.js, line 18

### Methods

#### (async) certify(signingKeys, dateopt, config) → {Promise.<User>}

Generate third-party certifications over this user and its primary key

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`signingKeys` | Array.<PrivateKey> |  | Decrypted private keys for signing
`date` | Date | <optional> | Date to use as creation date of the certificate, instead of the current time
`config` | Object |  | Full configuration

Source:
  - key/user.js, line 60

##### Returns:

New user with new certifications.

Type
  Promise.<User>

#### clone() → {User}

Shallow clone

Source:
  - key/user.js, line 44

##### Returns:

Type
  User

#### (async) isRevoked(certificate, keyPacketopt, dateopt, config) → {Promise.<Boolean>}

Checks if a given certificate of the user is revoked

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`certificate` | SignaturePacket |  | The certificate to verify
`keyPacket` | PublicSubkeyPacket | SecretSubkeyPacket | PublicKeyPacket | SecretKeyPacket | <optional> | The key packet to verify the signature, instead of the primary key
`date` | Date | <optional> | Use the given date for verification instead of the current time
`config` | Object |  | Full configuration

Source:
  - key/user.js, line 98

##### Returns:

True if the certificate is revoked.

Type
  Promise.<Boolean>

#### (async) revoke(primaryKey, reasonForRevocation, date, configopt) → {Promise.<User>}

Revokes the user

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`primaryKey` | SecretKeyPacket |  | decrypted private primary key for revocation
`reasonForRevocation` | Object |  | optional, object indicating the reason for revocation ###### Properties
Name | Type | Description
--- | --- | ---
`flag` | module:enums.reasonForRevocation | optional, flag indicating the reason for revocation
`string` | String | optional, string explaining the reason for revocation
`date` | Date |  | optional, override the creationtime of the revocation signature
`config` | Object | <optional> | Full configuration, defaults to openpgp.config

Source:
  - key/user.js, line 249

##### Returns:

New user with revocation signature.

Type
  Promise.<User>

#### toPacketList() → {PacketList}

Transforms structured user data to packetlist

Source:
  - key/user.js, line 31

##### Returns:

Type
  PacketList

#### (async) update(sourceUser, date, config) → {Promise.<undefined>}

Update user with new components from specified user

##### Parameters:

Name | Type | Description
--- | --- | ---
`sourceUser` | User | Source user to merge
`date` | Date | Date to verify the validity of signatures
`config` | Object | Full configuration

Source:
  - key/user.js, line 214

##### Returns:

Type
  Promise.<undefined>

#### (async) verify(date, config) → {Promise.<true>}

Verify User. Checks for existence of self signatures, revocation signatures and validity of self signature.

##### Parameters:

Name | Type | Description
--- | --- | ---
`date` | Date | Use the given date instead of the current time
`config` | Object | Full configuration

Source:
  - key/user.js, line 174

##### Throws:

if there are no valid self signatures.

Type
  Error

##### Returns:

Status of user.

Type
  Promise.<true>

#### (async) verifyAllCertifications(verificationKeys, dateopt, config) → {Promise.<Array.<{keyID: module:type/keyid~KeyID, valid: (Boolean|null)}>>}

Verifies all user certificates

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`verificationKeys` | Array.<PublicKey> |  | Array of keys to verify certificate signatures
`date` | Date | <optional> | Use the given date instead of the current time
`config` | Object |  | Full configuration

Source:
  - key/user.js, line 156

##### Returns:

List of signer's keyID and validity of signature. Signature validity is null if the verification keys do not correspond to the certificate.

Type
  Promise.<Array.<{keyID: module:type/keyid~KeyID, valid: (Boolean|null)}>>

#### (async) verifyCertificate(certificate, verificationKeys, dateopt, config) → {Promise.<(true|null)>}

Verifies the user certificate.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`certificate` | SignaturePacket |  | A certificate of this user
`verificationKeys` | Array.<PublicKey> |  | Array of keys to verify certificate signatures
`date` | Date | <optional> | Use the given date instead of the current time
`config` | Object |  | Full configuration

Source:
  - key/user.js, line 117

##### Throws:

if the user certificate is invalid.

##### Returns:

true if the certificate could be verified, or null if the verification keys do not correspond to the certificate

Type
  Promise.<(true|null)>