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

@vtfk/svarut

v1.3.0

Published

NodeJS SvarUt REST client

Downloads

18

Readme

SvarUt

This node module lets you use SvarUt's ForsendelseRestServiceV1 from node without having to think about the REST enpoints. It also verifies that the data provided is valid upon sending.

Installation

Use npm to install:

npm install @vtfk/svarut

Usage

This module now forces the use of TLSv1.2 as this is a requirement from SvarUT from 01.05.22

Please take a look at the forsendelse schema.

First - init svarut instance

const options = {
  username: 'svarut-username',
  password: 'svarut-password',
  url: 'svarut-url', // optional
  timeout: 5000 // optional, defaults to 16 minutes
}

const svarut = require('@vtfk/svarut')(options)

sendForsendelse (simple)

const forsendelse = {
  tittel: 'testforsendelse',
  mottaker: {
    postAdresse: {
      navn: 'Terje Tverrtryne',
      adresse1: 'Skogsveien 42',
      postNummer: '3710',
      postSted: 'Skien',
      land: 'Norge'
    },
    digitalAdresse: {
      fodselsNummer: '01029400475'
    }
  },
  dokumenter: [
    {
      filnavn: 'test.pdf',
      mimeType: 'application/pdf',

      // Send file from disk:
      filePath: 'test/data/test.pdf',

      // Or from base64 data:
      data: base64EncodedFile
    }
  ],
  utskriftsKonfigurasjon: {
    utskriftMedFarger: false,
    tosidig: true
  }
}

const result = svarut.sendForsendelse(forsendelse)

Output:

{ "id": "d24658e8-d65d-4c3e-b201-564b5e880cde" }

sendForsendelse (signing)

const forsendelse = {
  tittel: 'Test signeringsforsendelse #10',
  eksternReferanse: '12345',
  mottaker: {
    postAdresse: {
      navn: 'Terje Tverrtryne',
      adresse1: 'Skogsveien 42',
      postNummer: '3710',
      postSted: 'Skien',
      land: 'Norge'
    },
    digitalAdresse: {
      fodselsNummer: '01029400475'
    }
  },
  dokumenter: [
    {
      filnavn: 'test.pdf',
      mimeType: 'application/pdf',
      filePath: 'test/data/test.pdf',
      skalSigneres: true
    }
  ],
  utskriftsKonfigurasjon: {
    utskriftMedFarger: false,
    tosidig: true
  },
  signaturType: 'AUTENTISERT_SIGNATUR', // AUTENTISERT_SIGNATUR | AVANSERT_SIGNATUR
  signeringUtloper: new Date(Date.now() + 1 * 24 * 60 * 60 * 1000).getTime(),
  svarSendesTil: {
    postAdresse: {
      navn: 'Vestfold og Telemark fylkeskommune',
      adresse1: 'Postboks 2844',
      postNummer: '3702',
      postSted: 'Skien'
    },
    digitalAdresse: {
      organisasjonsNummer: '821227062'
    }
  }
}

const result = svarut.sendForsendelse(forsendelse)

Output:

{ "id": "d24658e8-d65d-4c3e-b201-564b5e880cde" }

getStatus

const forsendelseId = 'd24658e8-d65d-4c3e-b201-564b5e880cde'
const status = svarut.getStatus(forsendelseId)

Output:

{
  "statuser": [ 
    {
      "forsendelsesId": { "id": "d24658e8-d65d-4c3e-b201-564b5e880cde" },
      "sisteStatusEndring": 1571379874246,
      "status": "SENDT_PRINT"
    }
  ]
}

List of available status codes:

"MOTTAT",
"AKSEPTERT",
"AVVIST",
"VARSLET",
"LEST",
"SENDT_PRINT",
"PRINTET",
"MANUELT_HANDTERT",
"SENDT_DIGITALT",
"SENDT_SDP",
"LEVERT_SDP",
"KLAR_FOR_MOTTAK",
"IKKE_LEVERT"

getForsendelseHistorikk

const forsendelseId = 'd24658e8-d65d-4c3e-b201-564b5e880cde'
const status = svarut.getForsendelseHistorikk(forsendelseId)

Output:

{ 
  "hendelsesLogger": [ 
    { 
      "tidspunkt": "18.10.2019 15:28:30",
      "hendelse": "Mottatt, og tildelt forsendelse-id"
    },
    { 
      "tidspunkt": "18.10.2019 15:28:30",
      "hendelse": "Metadata er validert OK" 
    },
    [...]
  ]
}

getSigneringHistorikk

const forsendelseId = 'd24658e8-d65d-4c3e-b201-564b5e880cde'
const status = svarut.getSigneringHistorikk(forsendelseId)

Ikke startet signering

{
  "forsendelseid": "d24658e8-d65d-4c3e-b201-564b5e880cde",
  "logg": {
    "tidspunkt": "11.04.2018 09:48:20",
    "type": "SigneringsoppdragRegistrert",
    "hendelse": "Signeringsoppdrag av type AUTENTISERT_SIGNATUR registert og utløper 12.04.2018"
  }
}

Godtatt signering

{
  "forsendelseid": "d24658e8-d65d-4c3e-b201-564b5e880cde",
  "logg": [
    {
      "tidspunkt": "11.04.2018 09:48:20",
      "type": "SigneringsoppdragRegistrert",
      "hendelse": "Signeringsoppdrag av type AUTENTISERT_SIGNATUR registert og utløper 12.04.2018"
    },
    {
      "tidspunkt": "11.04.2018 09:57:28",
      "type": "SigneringsoppdragStartet",
      "hendelse": "Mottaker starter signeringsoppdraget."
    },
    {
      "tidspunkt": "11.04.2018 09:58:18",
      "type": "SigneringsoppdragFullfort",
      "hendelse": "Mottaker har fullført signeringsoppdraget og svar er sendt tilbake til avsender. Referanse: e324e614-4998-453b-a7a0-fba5cfa20ed0"
    }
  ]
}

Avvist signering

{
  "forsendelseid": "d24658e8-d65d-4c3e-b201-564b5e880cde",
  "logg": [
    {
      "tidspunkt": "11.04.2018 09:48:20",
      "type": "SigneringsoppdragRegistrert",
      "hendelse": "Signeringsoppdrag av type AUTENTISERT_SIGNATUR registert og utløper 12.04.2018"
    },
    {
      "tidspunkt": "11.04.2018 10:01:05",
      "type": "SigneringsoppdragStartet",
      "hendelse": "Mottaker starter signeringsoppdraget."
    },
    {
      "tidspunkt": "11.04.2018 10:01:23",
      "type": "SigneringsoppdragAvvistAvMottaker",
      "hendelse": "Mottaker har avvist signeringsoppdraget."
    }
  ]
}

getDokumentMetadata

const forsendelseId = 'd24658e8-d65d-4c3e-b201-564b5e880cde'
const metadata = await svarut.getDokumentMetadata(forsendelseId)

Output:

{ 
  "dokumentMetadata": [ 
    { 
      "mimeType": "application/pdf",
      "filnavn": "test.pdf",
      "kanSigneres": false,
      "sizeInBytes": 156993,
      "sha256hash": "042c2acd5123a4133b479fe165723b659d673bb530aba351745b76857bca21bb",
      "dokumentType": null,
      "nedlasningsUrl": "https://test.svarut.ks.no/forsendelse/d24658e8-d65d-4c3e-b201-564b5e880cde/1",
      "signeringsUrl": null,
      "ekstraMetadata": [],
      "inneholderPersonsensitivInformasjon": null
    } 
  ] 
}

setForsendelseLest

Marks the letter as read in an external system

const forsendelseId = 'd24658e8-d65d-4c3e-b201-564b5e880cde'
const lestav = {
  lestAvFodselsNummer: '01029400475',
  navnPaEksterntSystem: 'eksternt system',
  datoLest: Date.now()
}

const result = await svarut.setForsendelseLest(forsendelseId, lestav)

getForsendelseEksternref

Get list of letters with reference from external system

const eksternref = '123456'
const forsendelseIds = await svarut.getForsendelseEksternref(eksternref)

Output:

{ "forsendelseIder": [ { "id": "d24658e8-d65d-4c3e-b201-564b5e880cde" }, { "id": "..." } ] }

getForsendelseTyper

Get list of available letter types

const types = await svarut.getForsendelseTyper()

Output:

{ "forsendelseTyper": [ "Byggesøknad", "ks.signertforsendelse", "..." ] }

License

MIT