What is LON Signature?

LON Signature is a signature generation method for LON transactions. It is used to verified that the transactions are from the correct source. In the other words, if the signature is not matched with base64-encoded digest value, the request will be rejected.

Prerequisites

  • Channel Secret: A secret key given by Abbie Platform
  • Request Body of the transaction

How to generate LON Signature?

const crypto = require('crypto')
const channelSecret = '...' // Channel secret string
const body = '...' // Request body string

const signature = crypto.createHmac('SHA256', channelSecret).update(body).digest('base64')

Example

Channel Secret: 8bb530e7bb03397ecc41138b8b2ad97889a80c4d4f359cd3095b1e15926ae938ebcffbd38da70bab98df3f973b17fdac95fc6dbbebba08afb95c764a1dc91a14.d149ee5cb35a585f

Request Body:

{
  "phone_numbers": [
    {
      "target": "0812345678",
      "ref": "xxx"
    },
    {
      "target": "0812345679",
      "ref": "yyy"
    },
    {
      "target": "0812345670",
      "ref": "zzz"
    }
  ],
  "template_id": "1234567890",
  "description": "This is a test message.",
  "variables": {
    "service_name": "Abbie Platform",
    "service_url": "https://abbie.biz"
  }
}

Signature result: 164o2Od78aWv5BfR3LIZhoBRC1fZ4ObTWzTU2jvoi3M=