loopback4-cloudfront
Version:
A loopback4 extension for AWS Cloudfront integration
30 lines • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudFrontSignerProvider = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@loopback/core");
const aws_sdk_1 = require("aws-sdk");
const keys_1 = require("../keys");
let CloudFrontSignerProvider = class CloudFrontSignerProvider {
constructor(getCloudfrontSignerConfig) {
this.getCloudfrontSignerConfig = getCloudfrontSignerConfig;
}
async value() {
const options = await this.getCloudfrontSignerConfig();
if (options == null) {
throw new Error(`Cloudfornt signer is not configured. Please configure ${this.binding.key}.`);
}
const { keyPairId, privateKey } = options;
return new aws_sdk_1.CloudFront.Signer(keyPairId, privateKey);
}
};
tslib_1.__decorate([
core_1.inject.binding(),
tslib_1.__metadata("design:type", core_1.Binding)
], CloudFrontSignerProvider.prototype, "binding", void 0);
CloudFrontSignerProvider = tslib_1.__decorate([
tslib_1.__param(0, core_1.config.getter({ fromBinding: keys_1.CloudFrontBindings.SIGNER_CONFIG })),
tslib_1.__metadata("design:paramtypes", [Function])
], CloudFrontSignerProvider);
exports.CloudFrontSignerProvider = CloudFrontSignerProvider;
//# sourceMappingURL=cloud-front-signer.provider.js.map