UNPKG

@adobe/pdfservices-node-sdk

Version:

The Adobe PDF Services Node.js SDK provides APIs for creating, combining, exporting and manipulating PDFs.

93 lines 3.01 kB
"use strict"; /* * Copyright 2024 Adobe * All Rights Reserved. * * NOTICE: Adobe permits you to use, modify, and distribute this file in * accordance with the terms of the Adobe license agreement accompanying * it. If you have received this file from a source other than Adobe, * then your use, modification, or distribution of it requires the prior * written permission of Adobe. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpBaseRequest = void 0; const DefaultRequestHeaders_1 = require("./DefaultRequestHeaders"); class HttpBaseRequest { constructor(params) { this._httpMethod = params.httpMethod; this._uriTemplate = params.uriTemplate ?? ""; this._requestKey = params.requestKey; this._authenticationMethod = params.authenticationMethod; this._headers = params.headers ?? {}; this._authenticator = params.authenticator; this._httpRequestConfig = params.httpRequestConfig; this._data = params.data; this._responseType = params.responseType; } get uriTemplate() { return this._uriTemplate; } set uriTemplate(value) { this._uriTemplate = value; } get httpMethod() { return this._httpMethod; } set httpMethod(value) { this._httpMethod = value; } get headers() { return this._headers; } set headers(value) { this._headers = value; } get authenticationMethod() { return this._authenticationMethod; } set authenticationMethod(value) { this._authenticationMethod = value; } get requestKey() { return this._requestKey; } set requestKey(value) { this._requestKey = value; } get httpRequestConfig() { return this._httpRequestConfig; } set httpRequestConfig(value) { this._httpRequestConfig = value; } get authenticator() { return this._authenticator; } set authenticator(value) { this._authenticator = value; this._headers[DefaultRequestHeaders_1.DefaultRequestHeaders.X_API_KEY_HEADER_NAME] = this._authenticator.clientId; } get data() { return this._data; } set data(value) { this._data = value; } get responseType() { return this._responseType; } set responseType(value) { this._responseType = value; } async authenticate() { if (this.authenticationMethod.isAuthRequired) { if (!this.authenticator) { throw new TypeError("No authenticator provided for request. Cannot add authorization headers"); } const sessionToken = await this.authenticator.getSessionToken(this._httpRequestConfig); this.headers[DefaultRequestHeaders_1.DefaultRequestHeaders.AUTHORIZATION_HEADER_NAME] = `Bearer ${sessionToken?.accessToken}`; } } } exports.HttpBaseRequest = HttpBaseRequest; //# sourceMappingURL=HttpBaseRequest.js.map