open-index/open-npm huggingface dataset:
npm package: @iota/bundle-validator
Description: Syntactically validates bundle structure and signatures.
Latest version: 1.0.0-beta.30

# @iota/bundle-validator

Syntactically validates bundle structure and signatures.

## Installation

Install using [npm](https://www.npmjs.org/):
```
npm install @iota/bundle-validator
```

or using [yarn](https://yarnpkg.com/):

```
yarn add @iota/bundle-validator
```

## API Reference

    
* [bundle-validator](#module_bundle-validator)

    * [.validateBundleSignatures(bundle)](#module_bundle-validator.validateBundleSignatures)

    * [.isBundle(bundle)](#module_bundle-validator.isBundle)


<a name="module_bundle-validator.validateBundleSignatures"></a>

### *bundle-validator*.validateBundleSignatures(bundle)
**Summary**: Validates the signatures in a given bundle  

| Param | Type | Description |
| --- | --- | --- |
| bundle | <code>Array.&lt;Transaction&gt;</code> | Transaction trytes |

This method takes an array of transaction trytes and checks if the signatures are valid.

## Related methods

To get a bundle's transaction trytes from the Tangle, use the [`getBundle()`](#module_core.getBundle) method.

**Returns**: <code>boolean</code> - Whether the signatures are valid  
**Example**  
```js
let valid = Validator.validateBundleSignatures(bundle);
```
<a name="module_bundle-validator.isBundle"></a>

### *bundle-validator*.isBundle(bundle)
**Summary**: Validates the structure and contents of a given bundle.  

| Param | Type | Description |
| --- | --- | --- |
| bundle | <code>Array.&lt;Transaction&gt;</code> | Transaction trytes |

This method takes an array of transaction trytes and validates whether they form a valid bundle by checking the following:

- Addresses in value transactions have a 0 trit at the end, which means they were generated using the Kerl hashing function
- Transactions in the bundle array are in the same order as their `currentIndex` field
- The total value of all transactions in the bundle sums to 0
- The bundle hash is valid

## Related methods

To get a bundle's transaction trytes from the Tangle, use the [`getBundle()`](#module_core.getBundle) method.

**Returns**: <code>boolean</code> - bundle - Whether the bundle is valid  
**Example**  
```js
let bundle = Validator.isBundle(bundle);
```
npm package: @iota/extract-json
Description: Extracts JSON encoded messages from signature message fragments
Latest version: 1.0.0-beta.30

# @iota/extract-json

Extracts JSON encoded messages from signature message fragments.

## Installation

Install using [npm](https://www.npmjs.org/):
```
npm install @iota/extract-json
```

or using [yarn](https://yarnpkg.com/):

```
yarn add @iota/extract-json
```

## API Reference

    
* [extract-json](#module_extract-json)

    * [.extractJson(bundle)](#module_extract-json.extractJson)


<a name="module_extract-json.extractJson"></a>

### *extract-json*.extractJson(bundle)
**Summary**: Extracts JSON from transactions.  
**Throws**:

- <code>errors.INVALID\_BUNDLE</code> : Make sure that the `bundle` argument is an array of transaction trytes.
- <code>errors.INVALID\_JSON</code> : Make sure that the transactions' `signatureMessageFragment` fields contain valid JSON.


| Param | Type | Description |
| --- | --- | --- |
| bundle | <code>array</code> | Transaction trytes |

This method takes the `signatureMessageFragment` fields of all the given transaction trytes, and tries to extract any JSON data that's in them.

The following forms of JSON-encoded values are supported:
- `"{ \"message\": \"hello\" }"`
- `"[1, 2, 3]"`
- `"true"`, `"false"` & `"null"`
- `"\"hello\""`
- `123`

## Related methods

To get a bundle's transaction trytes from the Tangle, use the [`getBundle()`](#module_core.getBundle) method.

**Returns**: <code>string</code> \| <code>number</code> \| <code>null</code> - The JSON data in the transactions  
**Example**  
```js
try {
  const json = JSON.parse(extractJson(bundle))
} catch (error) {
  console.log(error);
}
```