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,kBAAmB,KAAK,kBACxB,UAAW,EACX,aAAc,EAAa,OAC3B,UAAW,GAEf,OAAO,MAAM,WAAa,KAAK,KAAO,IAAM,KAAK,SAAU,CACvD,OAAQ,OACR,KAAM,KAAK,iBAAiB,KAC7B,MAAK,SAAU,GAAY,OAAO,EAAS,MAAQ,GAC1D,EACO,CACX,CA3DwB,GA4DxB,OAAO,QAAU","file":"/npm/acrcloud@1.4.0/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/acrcloud@1.4.0/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\n/// <reference types=\"./\" />\nexports.__esModule = true;\nvar fetch = require(\"node-fetch\");\nvar FormData = require(\"form-data\");\nvar crypto = require(\"crypto\");\nvar acr = /** @class */ (function () {\n    function acr(config) {\n        this.endpoint = \"/v1/identify\";\n        this.signature_version = \"1\";\n        var host = config.host, access_key = config.access_key, access_secret = config.access_secret, data_type = config.data_type, audio_format = config.audio_format, sample_rate = config.sample_rate, audio_channels = config.audio_channels;\n        this.host = host || \"identify-us-west-2.acrcloud.com\";\n        this.access_key = access_key;\n        this.access_secret = access_secret;\n        this.data_type = data_type || \"audio\";\n        // Optional settings\n        this.audio_format = audio_format || \"\";\n        this.sample_rate = sample_rate || \"\";\n        this.audio_channels = audio_channels || 2;\n    }\n    //  Builds a signature string for making API requests\n    acr.prototype.buildStringToSign = function (method, uri, accessKey, dataType, signatureVersion, timestamp) {\n        return [method, uri, accessKey, dataType, signatureVersion, timestamp].join(\"\\n\");\n    };\n    //  Signs a signature string\n    acr.prototype.sign = function (string, access_secret) {\n        return crypto\n            .createHmac(\"sha1\", access_secret)\n            .update(Buffer.from(string, \"utf-8\"))\n            .digest()\n            .toString(\"base64\");\n    };\n    //  Generates form data from an object\n    acr.prototype.generateFormData = function (object) {\n        var form = new FormData();\n        Object.keys(object).forEach(function (key) {\n            form.append(key, object[key]);\n        });\n        return form;\n    };\n    /**\n     * Identify an audio track from a file path\n     * @param {Buffer} audio_sample A file path to an audio file or a buffer from an audio sample of the audio you want to identify\n     * @returns {Promise<ACRCloudResponse>} response JSON from ACRCloud https://www.acrcloud.com/docs/acrcloud/metadata/music/\n     */\n    acr.prototype.identify = function (audio_sample) {\n        var current_date = new Date();\n        var timestamp = current_date.getTime() / 1000;\n        var stringToSign = this.buildStringToSign(\"POST\", this.endpoint, this.access_key, this.data_type, this.signature_version, timestamp);\n        var signature = this.sign(stringToSign, this.access_secret);\n        var formData = {\n            sample: audio_sample,\n            access_key: this.access_key,\n            data_type: this.data_type,\n            signature_version: this.signature_version,\n            signature: signature,\n            sample_bytes: audio_sample.length,\n            timestamp: timestamp\n        };\n        return fetch(\"https://\" + this.host + \"/\" + this.endpoint, {\n            method: \"POST\",\n            body: this.generateFormData(formData)\n        }).then(function (response) { return response.json(); });\n    };\n    return acr;\n}());\nmodule.exports = acr;\n"]}