"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddressList = void 0;
var tslib_1 = require("tslib");
var superstruct_1 = require("superstruct");
var abstract_1 = require("./abstract");
var envConfig = (0, superstruct_1.defaulted)((0, superstruct_1.array)((0, superstruct_1.string)()), []);
var AddressList = (function (_super) {
    tslib_1.__extends(AddressList, _super);
    function AddressList(opts) {
        var _a, _b;
        return _super.call(this, (_a = opts === null || opts === void 0 ? void 0 : opts.name) !== null && _a !== void 0 ? _a : "process.env", (_b = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _b !== void 0 ? _b : "ACROSS_IGNORED_ADDRESSES", opts) || this;
    }
    AddressList.prototype.update = function () {
        var config = process.env[this.path];
        if (!config) {
            return Promise.resolve([]);
        }
        var addresses;
        try {
            addresses = JSON.parse(config);
            if (!envConfig.is(addresses)) {
                return this.error("Address format validation failure.");
            }
        }
        catch (err) {
            return this.error(err);
        }
        return Promise.resolve(addresses);
    };
    return AddressList;
}(abstract_1.AbstractAdapter));
exports.AddressList = AddressList;
//# sourceMappingURL=env.js.map