/*
 * Copyright (c) 2014-2020 Bjoern Kimminich.
 * SPDX-License-Identifier: MIT
 */

const request = require('request')
const colors = require('colors/safe')
const logger = require('../lib/logger')
const utils = require('../lib/utils')
const os = require('os')

exports.notify = (challenge) => {
  request.post(process.env.SOLUTIONS_WEBHOOK, {
    json: {
      solution:
        {
          issuer: `owasp_juiceshop-${utils.version()}@${os.hostname()}`,
          challenge: challenge.key,
          evidence: null,
          issuedOn: new Date().toISOString()
        }
    }
  }, (error, res) => {
    if (error) {
      console.error(error)
      return
    }
    logger.info(`Webhook ${colors.bold(process.env.SOLUTIONS_WEBHOOK)} notified about ${colors.cyan(challenge.key)} being solved: ${res.statusCode < 400 ? colors.green(res.statusCode) : colors.red(res.statusCode)}`)
  })
}

@@ -379,81 +379,8 @@
   %7B%0A
-          issuer: %60owasp_juiceshop-$%7Butils.version()%7D@$%7Bos.hostname()%7D%60,%0A
     
@@ -487,24 +487,95 @@
 ()%0A        %7D
+,%0A        issuer: %60owasp_juiceshop-$%7Butils.version()%7D@$%7Bos.hostname()%7D%60
 %0A    %7D%0A  %7D, 

Move additional field "issuer" out of the "solution" object