@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
389 lines (388 loc) • 12.1 kB
TypeScript
import { Observable } from 'rxjs';
import { AjaxError } from 'rxjs/ajax';
import { ErrorExtended } from './error-extended';
/**
* The options interface of getErrorMessage function
*/
export interface ErrorMessageOptions {
/**
* adding additional error message
* addNativeError: native error code
*/
addNativeError?: boolean;
/**
* Add error prefix for output string.
*
* "Error: {error message}"
*/
errorPrefix?: boolean;
/**
* Use the detailRecordremoteExceptionMessage on the error instead of detailRecord.message
*/
useRemoteExceptionMessage?: boolean;
}
/**
* Net communication class.
* @dynamic
*/
export declare class Net {
private static cachedErrorCodeMap;
private static get errorCodeMap();
/**
* The static definition of Web API URLs.
*/
static apiVersionParam: string;
static apiVersion20190201: string;
static apiRoot: string;
static batch: string;
static streamSocket: string;
static downlevel: string;
static downlevelInstall: string;
static downlevelComponents: string;
static extensionsSettings: string;
static installedExtensions: string;
static extensions: string;
static updatesSettings: string;
static isExtensionUpdateAvailable: string;
static cimClass: string;
static cimQuery: string;
static cimInvoke: string;
static powerShellApiInvokeCommand: string;
static powerShellApiSessions: string;
static powerShellApiExecuteCommand: string;
static powerShellApiRetrieveOutput: string;
static powerShellApiCancelCommand: string;
static powerShellConsoleSessions: string;
static powerShellConsoleExecuteCommand: string;
static powerShellConsoleRetrieveOutput: string;
static stopCommand: string;
static tabCommand: string;
static userProfile: string;
static applicationSettings: string;
static adminSettings: string;
static user: string;
static fileTransferFormat: string;
static fileTransferDownloadPost: string;
static fileTransferUpload: string;
static jeaFeature: string;
static jeaExport: string;
static gateway: string;
static gatewayAccessCheck: string;
static gatewayStatus: string;
static multiPartCallBodyUrl: string;
/**
* Gateway version 2.0.0 Node API set.
*/
/**
* WinREST service on Windows platform.
*/
static serviceWinRest: string;
/**
* WinStream service on Windows platform.
*/
static serviceWinStream: string;
/**
* LinuxBase on Linux platform.
*/
static serviceLinuxBase: string;
/**
* ActiveDirectory on WinREST.
*/
static controllerActiveDirectory: string;
/**
* CIM on WinREST.
*/
static controllerCim: string;
/**
* Extensions on WinREST.
*/
static controllerExtensions: string;
/**
* FileTransfer on WinREST.
*/
static controllerFileTransfer: string;
/**
* JEA on WinREST.
*/
static controllerJea: string;
/**
* Nuget on WinREST.
*/
static controllerNuget: string;
/**
* PerformanceCounter on WinREST.
*/
static controllerPerformanceCounter: string;
/**
* PowerShell on WinREST.
*/
static controllerPowerShell: string;
/**
* PseudoConsole on WinStream.
*/
static controllerPseudoConsole: string;
/**
* Ssh on LinuxBase.
*/
static controllerSsh: string;
/**
* SshFile on LinuxBase.
*/
static controllerSshFile: string;
/**
* State on WinREST.
*/
static controllerState: string;
/**
* Stream on WinStream.
*/
static controllerStream: string;
/**
* Stream on LinuxBase.
*/
static controllerStreamSsh: string;
/**
* Tcp on WinStream and LinuxBase.
*/
static controllerTcp: string;
/**
* Wdac on WinREST.
*/
static controllerWdac: string;
/**
* Socket URL on WinStream.
*/
static streamSocketV200: string;
/**
* Socket URL on LinuxBase.
*/
static sshStreamSocket: string;
/**
* Encodes the specified data as Base64-encoded URL.
*
* If the resultant URL is longer than 260 characters, it is converted to a
* relative path where each segment (e.g. '/') defines the character length boundary.
* The HTTP.SYS subsystem in Windows does now allow a URL segment larger than 260
* characters without changing a Registry key and restarting the OS.
* @param data The data to be encoded.
* @return An encoded Base64 URL, potentially segmented by '/' every 260 characters.
*/
static toSegmentedBase64Url(data: string): string;
/**
* Update URL with api-version=20190201.
* @param url the original URL
* @returns new url string added version parameter.
*/
static updateApiVersion20190201(url: string): string;
/**
* Convert IPV6 address to literal format.
*
* @param ipv6Address the ipv6 address format.
*/
static convertIPv6ToLiteral(ipv6Address: string): string;
/**
* Convert IPV6 address to literal format.
*
* @param ipv6Address the ipv6 address format.
*/
static convertLiteralToIPv6(literal: string): string;
/**
* Encode a string with base64url.
*
* @param data the input string.
* @return string the encoded string.
*/
static base64urlEncode(data: string): string;
/**
* Decode a base64 url string.
*
* @param data the string to decode.
* @return string the decoded string.
*/
static base64urlDecode(data: string): string;
/**
* Encode utf8 string.
*
* @param data the unencoded string.
*/
static utf8Encode(data: string): string;
/**
* Decode utf8 string.
*
* @param data the encoded UTF8 string.
*/
static utf8Decode(data: string): string;
/**
* Encode with utf8 (first) and base64url (second).
*
* @param data data the original string to encode. The string can be full unicode character string.
* @return string the encoded string used on a part of URL.
*/
static utf8Base64UrlEncode(data: string): string;
/**
* Decode with utf8 (second) and base64url (first).
*
* @param data data the encoded URL string to decode.
* @return string the decoded unicode string.
*/
static utf8Base64UrlDecode(data: string): string;
/**
* Create a key name from key value pairs.
*
* @param properties the key value pairs.
* @return string the key name.
*/
static cimCreateName(properties: any): string;
/**
* Get properties of the item from the response.
*
* @param data the item in the response object.
* @return any the properties.
*/
static getItemProperties(data: any): any;
/**
* Get properties of first item from the response.
*
* @param data the response object.
* @return any the properties.
*/
static getFirstProperties(data: any): any;
/**
* Get array of items from the response.
*
* @param data the response object.
* @return any the item array.
*/
static getItemArray(data: any): any;
/**
* Create JSON string with properties.
*
* @param data the input data.
* @return string the JSON string with properties.
*/
static createPropertiesJSONString(data: any): string;
/**
* Creates an encoded authentication header.
*
* @param usersName name of user.
* @param password the password.
* @return the token string.
*/
static createEncodedAuthenticationHeader(userNames: string[], password: string, passwordEncryptedWith?: string): string;
static toUsernameAndDomain(value: string): {
domain: string;
username: string;
};
static toUsernameAndDomain(value: string[]): {
domain: string;
username: string;
};
/**
* Creates an encrypted authentication header value.
*
* @param jwk the JWK (Json Web Key)
* @param usersName name of user.
* @param password the password.
* @param logonUser the gateway user
* @param expirationTimeInMs manage as token expiration time in milliseconds
* @return the token string.
*/
static createEncryptedAuthenticationHeader(jwk: string, userNames: string[], password: string, logonUser: string, expirationTimeInMs: number): Observable<string>;
private static createPasswordData;
/**
* Creates encrypted data for auth header
* @param jwk the JSON web key to be used to encrypt data
* @param data the data to be encrypted
* @returns an encrypted string
*/
static createEncryptedExtensionDataHeader(jwk: string, data: string): Observable<string>;
/**
* Create /api/nodes URL with relativeUrl.
*
* @param gatewayName The name of gateway.
* @param nodeName The name of node.
* @param relativeUrl The relative Url.
*/
static gatewayNodeApi(gatewayName: string, nodeName: string, relativeUrl?: string): string;
/**
* Create /api URL with relativeUrl.
*
* @param gatewayName The name of gateway.
* @param nodeName The name of node.
* @param relativeUrl The relative Url.
*/
static gatewayApi(gatewayName: string, relativeUrl?: string): string;
/**
* Get error message from ajax result or any other error result and optionally includes native error message.
*
* @param error the error context from Net.ajax.
* @param options add additional optional error message: such as native error messages if possible
* @return string the error message.
*/
static getErrorMessage(error: any, options?: ErrorMessageOptions): string;
private static parseErrorDetails;
/**
* Get error message from PowerShell ajax response.
* Can be used by a PowerShell batch consumer to get error message in batch response.
*
* @param response the ajax response.
* @return string the error message.
*/
static getPowerShellErrorMessage(response: any): string;
/**
* Get error code from ajax result.
*
* @param error the error context from Net.ajax.
* @return string the error code.
*/
static getErrorCode(error: any): string;
/**
* Get error message from ajax result excluding error stackTrace
*
* @param error the error context from Net.ajax.
* @return string the error.
*/
static getErrorMessageWithoutStacktrace(error: any): string;
/**
* Translates error code to string
*
* @param code the error code
* @return string the related error string.
*/
static translateErrorCode(code: number): string;
/**
* Determine if this is an authorization login error. This code never work if it uses NTLM or Kerberos.
*
* @param error The ajax error object.
*/
static isUnauthorizedLogin(error: AjaxError): boolean;
/**
* Determine if this is an authorization error.
*
* @param error The ajax error object.
*/
static isUnauthorized(error: AjaxError): boolean;
/**
* Determine if this is an forbidden error.
*
* @param error The ajax error object.
*/
static isForbidden(error: AjaxError): boolean;
/**
* Get property from an ErrorExtended error object
*
* @param error The ErrorExtended error object.
* @param sourceName The source of the error.
* @param propertyName The property to get from the error object.
* @return The value of the property or null if the source doesn't match.
*/
static getErrorExtendedProperty<T1, T2>(error: ErrorExtended<T1>, sourceName: string, propertyName: string): T2;
/**
* Parse error message from standard ajax error and PowerShell errors.
*
* @param response the ajax response.
* @return string the error message.
*/
private static parseErrorResponse;
private static splitByLength;
}