"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Config_1 = require("../lib/Config");
const REST_1 = require("./REST");
const crypto = require("crypto");
class Hikvision extends REST_1.default {
    constructor() {
        super(`${Config_1.default.hikvision.isc.baseUrl}`);
    }
    get additionalHeaders() {
        const { method, path } = this.params;
        // token拼装
        const date = new Date().toUTCString();
        const httpHeaders = `${method}\n*/*\napplication/json;charset=UTF-8\n${date}\n`;
        const customHeaders = `x-ca-key:${Config_1.default.hikvision.isc.key}\n`;
        const url = `/${path}`;
        const token = `${httpHeaders}${customHeaders}${url}`;
        // sha256加密
        const hmac = crypto.createHmac('sha256', Config_1.default.hikvision.isc.secret);
        hmac.update(token);
        const signature = hmac.digest('base64');
        const header = {
            Accept: '*/*',
            'Content-Type': 'application/json;charset=UTF-8',
            Date: date,
            'X-Ca-Key': Config_1.default.hikvision.isc.key,
            'X-Ca-Signature': signature,
            'X-Ca-Signature-Headers': 'x-ca-key',
        };
        return header;
    }
    get additionalQueries() {
        return {};
    }
    get accessToken() {
        return;
    }
    setParams(params) {
        this.params = params;
    }
}
exports.default = Hikvision;
