SwishServer - adonisv79/swish-protocol GitHub Wiki

Introduction

The SwishServer class is the blueprint for creating a service which utilizes the swish transaction protocol. This can be basically an API, Websocket or any service where you establish handshakes and messaging (transaction or communications).

Interface(s)

  • SwishDecryption - The Decryption private key response
    • nextPrivate (string) - Will contain the next decryption key in the transaction chain
    • createdDate (number) - The timestamp as to when the key was generated

Functions

handleHandshakeRequest

Handles a handshake request from a new client

Parameters

  • headers (SwishHeaders) - the request headers

decryptRequest

Decrypt the encrypted request with the session's next request decrypt key

Parameters

  • headers (SwishHeaders) - The request headers
  • body (SwishBody) - The request body
  • nextPrivate (string) - The next RSA private key used to decrypt the req_body
  • passphrase (string) - The Passphrase used to generate the RSA private key

encryptResponse

Encrypt the response with the session public key

  • swishSessionId (string) - the unique session identifier
  • body (BinaryLike | object) - the response body to encrypt
  • nextPublic (string) - The next RSA Public key in the chain to encrypt the body