Common representation of Message in JWT form.

### Hierarchy

- Message
  - Claim

## Index

### Constructors

- constructor

### Properties

- metadata
- signature

### Methods

- payloadFromJSON
- payloadToJSON
- serialize
- serializeHeader
- serializePayload
- serializeUnsigned
- sign
- verify
- verifyExpiration
- verifyKeyOwnership
- deserializeHeader
- deserializeInternal
- deserializePayload

## Constructors

### constructor

- new Message(metadata: Metadata, signature: Signature | undefined): Message

- - Defined in claim/message.ts:142

  #### Parameters

  - ##### metadata: Metadata

  - ##### signature: Signature | undefined

  #### Returns Message

## Properties

### metadata

metadata: Metadata

- Defined in claim/message.ts:141

### Optional signature

signature: Signature

- Defined in claim/message.ts:142

## Methods

### Protected Abstract payloadFromJSON

- payloadFromJSON(json: any): void

- - Defined in claim/message.ts:282

  Retrieves data from JSON.

  #### Parameters

  - ##### json: any

    JSON object with data

  #### Returns void

### Protected Abstract payloadToJSON

- payloadToJSON(): any

- - Defined in claim/message.ts:275

  Converts claim data to JSON for serialization.

  #### Returns any

### serialize

- serialize(): string

- - Defined in claim/message.ts:234

  Serializes the message into JWT format.

  #### Returns string

### Protected serializeHeader

- serializeHeader(algorithm: SignatureScheme | undefined, publicKeyId: string | undefined): string

- - Defined in claim/message.ts:251

  Serializes the header into JWT encoded header.

  #### Parameters

  - ##### algorithm: SignatureScheme | undefined

    Signature algorithm used

  - ##### publicKeyId: string | undefined

    The ID of a signature public key

  #### Returns string

### Private serializePayload

- serializePayload(): string

- - Defined in claim/message.ts:313

  Serializes payload part of JWT message.

  #### Returns string

### serializeUnsigned

- serializeUnsigned(algorithm?: SignatureScheme, publicKeyId?: undefined | string): string

- - Defined in claim/message.ts:223

  Serializes the message without signature into JWT format.

  Header might contain algorithm and public key id.

  #### Parameters

  - ##### Optional algorithm: SignatureScheme

    Signature algorithm used

  - ##### Optional publicKeyId: undefined | string

    The ID of a signature public key

  #### Returns string

### sign

- sign(url: string, publicKeyId: string, privateKey: PrivateKey, algorithm?: SignatureScheme): Promise<void>

- - Defined in claim/message.ts:163

  Signs the message and store the signature inside the request.

  If the algorithm is not specified, then default algorithm for Private key type is used.

  #### Parameters

  - ##### url: string

    Restful endpoint of Ontology node

  - ##### publicKeyId: string

    The ID of a signature public key

  - ##### privateKey: PrivateKey

    Private key to sign the request with

  - ##### Optional algorithm: SignatureScheme

    Signature algorithm used

  #### Returns Promise<void>

### verify

- verify(url: string): Promise<boolean>

- - Defined in claim/message.ts:185

  Verifies the signature and check ownership of specified ONT ID through smart contract call.

  #### Parameters

  - ##### url: string

    Restful endpoint of Ontology node

  #### Returns Promise<boolean>

  Boolean if the ownership is confirmed

### Private verifyExpiration

- verifyExpiration(): boolean

- - Defined in claim/message.ts:287

  Verifies if the expiration date has passed

  #### Returns boolean

### Private verifyKeyOwnership

- verifyKeyOwnership(): boolean

- - Defined in claim/message.ts:298

  Verifies if the declared public key id belongs to issuer.

  #### Returns boolean

### Static Private deserializeHeader

- deserializeHeader(encoded: string): object

- - Defined in claim/message.ts:131

  Deserializes the header from JWT encoded header.

  #### Parameters

  - ##### encoded: string

    JWT encoded header

  #### Returns object

  - ##### algorithm: undefined | SignatureScheme

  - ##### publicKeyId: any

### Static Protected deserializeInternal

- deserializeInternal<T>(jwt: string, creator: MessageFactory<T>): T

- - Defined in claim/message.ts:81

  Deserializes the message from JWT format.

  A concrete instance will be creater through the message factory method. This method is called from concrete class.

  #### Type parameters

  - #### T: Message

  #### Parameters

  - ##### jwt: string

    Encoded message

  - ##### creator: MessageFactory<T>

    Factory method

  #### Returns T

### Static Private deserializePayload

- deserializePayload(encoded: string): object

- - Defined in claim/message.ts:110

  Deserializes payload part of JWT message.

  #### Parameters

  - ##### encoded: string

    JWT encoded payload

  #### Returns object

  - ##### metadata: Metadata

  - ##### rest: any

Generated using TypeDoc