UNPKG

@ibm-cloud/cloudant

Version:
76 lines (75 loc) 3.09 kB
/** * © Copyright IBM Corporation 2020, 2021. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { OutgoingHttpHeaders } from 'node:http'; import { TokenManager, UserOptions } from 'ibm-cloud-sdk-core'; /** Configuration options for CouchDB session token retrieval. */ export interface SessionTokenManagerOptions extends UserOptions { /** The username portion of CouchDB session authentication. */ username: string; /** The password portion of CouchDB session authentication. */ password: string; } /** * Token Manager of CouchDB session token. * * The Token Manager performs basic auth with username and password * to acquire session tokens. */ export declare class SessionTokenManager extends TokenManager { protected requiredOptions: string[]; private tokenName; private options; /** * Create a new [[SessionTokenManager]] instance. For internal use by * CouchdbSessionAuthenticator only. * * @param {object} options Configuration options. * @param {string} options.username The username portion of CouchDB Session authentication. * @param {string} options.password The password portion of CouchDB Session authentication. * @param {string} options.serviceUrl The endpoint for session token requests. * @param {any} options.jar The Cookie jar for session token storage. * @param {boolean} [options.disableSslVerification] A flag that indicates * whether verification of the token server's SSL certificate should be * disabled or not. * @param {object<string, string>} [options.headers] Headers to be sent with every * outbound HTTP requests to token services. * @constructor */ constructor(options: SessionTokenManagerOptions); /** * Only base service specific headers are in use. * * @param {OutgoingHttpHeaders} headers - the new set of headers as an object * @returns {Error} */ setHeaders(headers: OutgoingHttpHeaders): void; /** * Request a session token using basic credentials. * * @returns {Promise} */ protected requestToken(): Promise<any>; /** * From the response parse and save session token into field `accessToken`. * Calculate expiration and refresh time from the received response * and store them in fields `expireTime` and `refreshTime`. * * @param tokenResponse - Response object from session token request * @private * @returns {void} */ protected saveTokenInfo(tokenResponse: any): void; }