UNPKG

@mindconnect/mindconnect-nodejs

Version:

NodeJS Library for Siemens Insights Hub Connectivity - TypeScript SDK for Insights Hub and Industrial IoT - Command Line Interface - Insights Hub Development Proxy (Siemens Insights Hub was formerly known as MindSphere)

179 lines (178 loc) 5.06 kB
/** * TokenRotation interface marks all classes which rotate the authentication token according to mindsphere specifications. * * @export * @interface TokenRotation */ export interface TokenRotation { /** * Checks if the token has expired and renews it if necessary. * * @returns {Promise<boolean>} * * @memberOf TokenRotation */ RenewToken(): Promise<boolean>; /** * Returns the current token * * @returns {Promise<string>} * * @memberOf TokenRotation */ GetToken(): Promise<string>; /** * returns the currently used MindSphere gateway * * @returns {string} * * @memberOf TokenRotation */ GetGateway(): string; /** * returns the currently used mindsphere tenant * * @returns {string} * * @memberOf TokenRotation */ GetTenant(): string; HttpAction({ verb, gateway, baseUrl, authorization, body, message, octetStream, multiPartFormData, additionalHeaders, noResponse, rawResponse, returnHeaders, ignoreCodes, }: { verb: "GET" | "POST" | "PATCH" | "PUT" | "DELETE"; gateway: string; baseUrl: string; authorization: string; body?: Object; message?: string; octetStream?: boolean; multiPartFormData?: boolean; additionalHeaders?: Object; noResponse?: boolean; rawResponse?: boolean; returnHeaders?: boolean; ignoreCodes?: number[]; }): Promise<Object | undefined>; } export declare function isTokenRotation(obj: any): boolean; /** * Base class for mindconnect agent (and setup) which provides headers and proxy handling. * * @export * @abstract * @class MindConnectBase */ export declare abstract class MindConnectBase { /** * This is a https proxy agent which is used in the fetch commands if the HTTP_PROXY variable is configured. * * @protected * @type {*} * @memberof MindConnectBase */ protected _proxyHttpAgent: any; protected _headers: { Accept: string; "X-Powered-By": string; "User-Agent": string; }; /** * Http headers used for /exchange endpoint handling. * * @protected * @memberof MindConnectBase */ protected _multipartHeaders: { "Content-Type": string; Accept: string; "X-Powered-By": string; "User-Agent": string; }; protected _multipartFormData: { "Content-Type": string; Accept: string; "X-Powered-By": string; "User-Agent": string; }; /** * Http headers used for onboarding message. * * @protected * @memberof MindConnectBase */ protected _apiHeaders: { "Content-Type": string; Accept: string; "X-Powered-By": string; "User-Agent": string; }; protected _octetStreamHeaders: { "Content-Type": string; Accept: string; "X-Powered-By": string; "User-Agent": string; }; /** * Http headers used to register the client assertion and acquire the /exchange token. * * @protected * @memberof MindConnectBase */ protected _urlEncodedHeaders: { "Content-Type": string; Accept: string; "X-Powered-By": string; "User-Agent": string; }; /** * perform http action * * @param {({ * verb: "GET" | "POST" | "PATCH" | "PUT" | "DELETE"; * gateway: string; * baseUrl: string; * authorization: string; * body?: Object; * message?: string; * octetStream?: boolean; * multiPartFormData?: boolean; * additionalHeaders?: Object; * noResponse?: boolean; * rawResponse?: boolean; * returnHeaders?: boolean; * ignoreCodes?: number[]; * })} { * verb, * gateway, * baseUrl, * authorization, * body, * message, * octetStream, * multiPartFormData, * additionalHeaders, * noResponse, * rawResponse, * returnHeaders, * ignoreCodes, * } * @returns {Promise<Object>} * * @memberOf MindConnectBase */ HttpAction({ verb, gateway, baseUrl, authorization, body, message, octetStream, multiPartFormData, additionalHeaders, noResponse, rawResponse, returnHeaders, ignoreCodes, }: { verb: "GET" | "POST" | "PATCH" | "PUT" | "DELETE"; gateway: string; baseUrl: string; authorization: string; body?: Object; message?: string; octetStream?: boolean; multiPartFormData?: boolean; additionalHeaders?: Object; noResponse?: boolean; rawResponse?: boolean; returnHeaders?: boolean; ignoreCodes?: number[]; }): Promise<Object | undefined>; constructor(); }