Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

fiskaly/fiskaly-sdk-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fiskaly SDK for Node.js

The fiskaly SDK includes an HTTP client that is needed1 for accessing the kassensichv.io API that implements a cloud-based, virtual CTSS (Certified Technical Security System) / TSE (Technische Sicherheitseinrichtung) as defined by the German KassenSichV (Kassen­sich­er­ungsver­ord­nung).

Supported Versions

  • Node 8.0+

Features

  • Automatic authentication handling (fetch/refresh JWT and re-authenticate upon 401 errors).
  • Automatic retries on failures (server errors or network timeouts/issues).
  • Automatic JSON parsing and serialization of request and response bodies.
  • Future: [1] compliance regarding BSI CC-PP-0105-2019 which mandates a locally executed SMA component for creating signed log messages.
  • Future: Automatic offline-handling (collection and documentation according to Anwendungserlass zu § 146a AO)

Integration

NPM

The Node.js SDK is available for a download via NPM.

Package Repository.

Simply execute this command from the shell in your project directory:

$ npm install fiskaly-sdk-node --save

Or you can manually add the package to your package.json file:

"dependencies": {
  "fiskaly-sdk-node": "*"
}

then run

$ npm install

Finally, be sure to include the sdk in your code:

const { FiskalyClient } = require('fiskaly-sdk-node');

Service

Additionally, to the SDK, you'll also need the fiskaly service. Follow these steps to integrate it into your project:

  1. Go to https://developer.fiskaly.com/downloads#service
  2. Download the appropriate service build for your platform
  3. Start the service

Client

Additionally to the service, Node SDK, support also fiskaly client. The client library is used if your constructor parameter "fiskalyServiceUrl" is not provided.

Follow these steps to integrate it into your project:

  1. Go to https://developer.fiskaly.com/downloads#client
  2. Download the appropriate client library for your platform
  3. Move it to node_modules/fiskaly-sdk-node/lib/client/ directory

SDK Usage

Demo

// Environment variables
const { FISKALY_SERVICE_URL, FISKALY_API_KEY, FISKALY_API_SECRET, FISKALY_BASE_URL } = process.env;

try {
  // SDK Setup
  const client = new FiskalyClient(FISKALY_SERVICE_URL);
  await client.createContext(FISKALY_API_KEY, FISKALY_API_SECRET, FISKALY_BASE_URL);

  const version = await client.getVersion();
  console.log("Version", version);
} catch (e) {
  // Handle Error
  console.error(e);
}

Client Configuration

The SDK is built on the fiskaly Client which can be configured through the SDK.

A reason why you would do this, is to enable the debug mode.

Enabling the debug mode

The following code snippet demonstrates how to enable the debug mode in the client.

try {
  const configParams = {
    debug_level: 3,
    debug_file: __dirname + '/../fiskaly.log',
    client_timeout: 5000,
    smaers_timeout: 2000,
  }
  const newConfig = await client.configure(configParams);
} catch (e) {
  // Handle Error
  console.error(e);
}

Related

About

fiskaly Cloud-TSE SDK for Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •