# sefaz-communicator

> Simple way to communicate with SEFAZ SOAP web services

Latest version **1.4.1** (published 2021-10-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install sefaz-communicator
pnpm add sefaz-communicator
yarn add sefaz-communicator
bun add sefaz-communicator
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2021-10-01 |
| First published | 2019-09-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Andre Macedo |
| Maintainers | andreiox |
| Keywords | sefaz, communication, soap |

## Links

- npm: https://www.npmjs.com/package/sefaz-communicator
- Repository: https://github.com/andreiox/sefaz-communicator
- Homepage: https://github.com/andreiox/sefaz-communicator#readme
- Issues: https://github.com/andreiox/sefaz-communicator/issues
- npm.io page: https://npm.io/package/sefaz-communicator

## Dependencies (1)

- [soap](https://npm.io/package/soap.md) ^0.29.0

## Recent versions

- 1.4.1 (latest) — 2021-10-01
- 1.4.0 — 2021-07-07
- 1.3.3 — 2021-05-12
- 1.3.2 — 2021-05-05
- 1.3.1 — 2021-04-26
- 1.3.0 — 2021-04-23
- 1.2.6 — 2021-01-12
- 1.2.5 — 2020-10-05
- 1.2.4 — 2020-09-16
- 1.2.3 — 2020-07-01
- 1.2.2 — 2020-01-27
- 1.2.1 — 2019-12-12
- 1.2.0 — 2019-12-04
- 1.1.0 — 2019-11-26
- 1.0.6 — 2019-11-19
- … 6 more at https://npm.io/package/sefaz-communicator/versions

## README

sefaz-communicator
==================

> Simple way to communicate with SEFAZ SOAP web services

Install
-------

```shell
npm install sefaz-communicator
```

Usage
-----

```js
const sefaz = require('sefaz-communicator')

const url = 'https://hnfe.sefaz.ba.gov.br/webservices/NFeStatusServico4/NFeStatusServico4.asmx'
const methodName = 'nfeStatusServicoNF'
const message = {
    $xml: `<consStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00">
            <tpAmb>2</tpAmb>
            <cUF>29</cUF>
            <xServ>STATUS</xServ>
          </consStatServ>`,
}

const certificate = Buffer.from('Pfx certificate in base64 string', 'base64')
const password = 'password'

const response = await sefaz.communicate(url, methodName, message, {
    certificate,
    password,
})
```

API
---

### communicate(url, method, message, options)

#### url

Type: `string`

Web service URL

#### methodName

Type: `string`

Name of Wsdl Method

#### message

Type: `object`

Examples

> message: { \$xml: '<?xml>...'}

or

> message: { nfeDadosMsg: '<?xml>...'}

#### (optional) options.certificate

Type: `Buffer`

Pfx Certificate as Buffer

#### (optional) options.password

Type: `string`

Certificate password

#### (optional) options.headers

Type: `string array`

Headers in xml

Example

> headers: ['`<cteCabecMsg>...</cteCabecMsg>`']

#### (optional) options.httpClient

Type: `http.HttpClient`

Custom node-soap HttpClient

#### (optional) options.escapeXML

Type: `boolean`

Escape XML message (default: false)

#### (optional) options.forceSoap12Headers

Type: `boolean`

Force Soap12 Headers (default: true)

#### (optional) options.contentType

Type: `string`

Communication content type (default: application/soap+xml)

#### (optional) options.proxy

Type: `string`

Proxy url to use in the communication

#### (optional) options.customFormatLocation

Type: `Function`

Function to format location that the method is called

#### (optional) options.rawResponse

Type: `boolean`

If true, returns raw XML response (default: false)

---
_Source: https://npm.io/package/sefaz-communicator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
