{"size": 909, "ext": "js", "max_stars_repo_path": "node_modules/@redwoodjs/api/dist/auth/verifiers/secretKeyVerifier.js", "max_stars_repo_name": "metanoiaweblabs/redwoodblog", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/@redwoodjs/api/dist/auth/verifiers/secretKeyVerifier.js", "max_issues_repo_name": "metanoiaweblabs/redwoodblog", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/@redwoodjs/api/dist/auth/verifiers/secretKeyVerifier.js", "max_forks_repo_name": "metanoiaweblabs/redwoodblog", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.2, "max_line_length": 94, "alphanum_fraction": 0.6501650165}
"use strict";

var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");

_Object$defineProperty(exports, "__esModule", {
  value: true
});

exports.default = exports.secretKeyVerifier = void 0;

var _common = require("./common");

/**
 *
 * Secret Key Verifier
 *
 * Use when the payload is not signed, but rather authorized via a known secret key
 *
 */
const secretKeyVerifier = _options => {
  return {
    sign: ({
      secret
    }) => {
      return secret;
    },
    verify: ({
      signature,
      secret = _common.DEFAULT_WEBHOOK_SECRET
    }) => {
      const verified = signature === secret;

      if (!verified) {
        throw new _common.WebhookVerificationError();
      }

      return verified;
    },
    type: 'secretKeyVerifier'
  };
};

exports.secretKeyVerifier = secretKeyVerifier;
var _default = secretKeyVerifier;
exports.default = _default;