npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

share-module-federation-tutorial

v0.1.5

Published

Example to share theme and context using module federation

Downloads

9

Readme

DGII-eCF

npm version Node.js CI

DGII-eCF (DGII) - Dirección General de Impuestos Internos de República Dominicana.

  • Este paquete contiene las herramientas necesarias para autenticar y firmar archivos eletrónicos para realizar la facturación electrónica para aplicaciones nodejs.

  • This package contains the necessary tools to authenticate and sign electronic files to perform electronic invoicing for nodejs applications.

Do not try to use on frontend application like Reactjs, only use it on the server side due to sensitive informations

Installation

Install dgii-ecf with npm

  npm install dgii-ecf

Usage/Examples

This package expose three main clases ECF, P12Reader, Signature

Requirements

You need a valid certificate if you don't have one you need to request a new one your business or client business DigiFirma

Step One

Use P12Reader to read the certificate .p12

import { P12Reader } from 'dgii-ecf';

const secret = 'certificate_passphrase'

const reader = new P12Reader(secret);
    const certs = reader.getKeyFromFile(
      path.resolve(__dirname, '../../test_cert/[your_identity.p12]')
    );

certs will contain a object P12ReaderData with

{ cert: string, key: string }

Step two

Use the cert object to initialize the ECF object, is important to pass this object, with the certificate we will be able to authenticate with the DGII, sign documents and interact with the api.

import ECF, { P12Reader } from 'dgii-ecf'

const auth = new ECF(certs);
const tokenData = await auth.authenticate();

The method authenticate will perform two API requests:

  • Get the initial XML called SEED
  • After getting the seed, the method will sign the document using Signature and will make another API request to get the access token

auth.authenticate return an optional object with the token and expiration, however, internally the token gets set into the header of every following request, Authorization: access token.

Target diferent environment

By default the ECF class init target the development environment, currently the class support the three environment supported by DGII:

  • TesteCF Test environment
  • CerteCF Certification environment
  • eCF Production
import ECF, { ENVIRONMENT } from 'dgii-ecf'

const auth = new ECF(certs, ENVIRONMENT.PROD); //PRODUCTION ENV

Options

Signature this class help to sign XML documents.

import { Signature } from 'dgii-ecf'

//Read the certificate
const reader = new P12Reader(secret);
const certs = reader.getKeyFromFile(
    path.resolve(__dirname, '../../test_cert/4303328_identity.p12')
);

if (!certs.key || !certs.cert) {
  return;
}

//Get the XML file to add the signature

const seedXml = fs.readFileSync(
    path.resolve(__dirname, 'sample/seed.xml'),
    'utf-8'
);

//Sign the document
const signature = new Signature(certs.key, certs.cert);
const signedXml = signature.signXml(seedXml, 'SemillaModel');

Run Test local environment

This repo performs the unit test connecting to the DGII test environment

  • First: In order to pass the test locally the first step is to plate your certificate into the directory src/test_cert current emtpy, for security reason .p12 gets ignored.
  • Second: create a .env file and set a variable CERTIFICATE_TEST_PASSWORD='' with the passphrase secret of your certificate.

Install dependencies

  npm install

Run the test

  npm run test

Test watcher

  npm run test:watch

Authors

🔗 Links

portfolio linkedin twitter

Related

For more technical documentation related with Electronic Invoice: