@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
1 lines • 4.22 kB
Source Map (JSON)
{"version":3,"sources":["../../../packages/core/data/wdac-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,MAAM,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAe,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEpE;;;GAGG;AACH,oBAAY,cAAc;IACtB,YAAY,IAAI;IAChB,kBAAkB,IAAI;IACtB,UAAU,IAAI;IACd,mBAAmB,IAAI;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IAEvB;;OAEG;IACH,cAAc,EAAE,cAAc,CAAC;CAClC;AAED;;GAEG;AACH,qBAAa,aAAa;IACtB;;OAEG;IACH,OAAc,iBAAiB,SAA6C;IAE5E;;OAEG;IACH,OAAc,iBAAiB,SAA6C;CAC/E;AAED;;GAEG;AACH,qBAAa,cAAc;IAMX,OAAO,CAAC,UAAU;IAL9B;;;;OAIG;gBACiB,UAAU,EAAE,UAAU;IAE1C;;;;OAIG;IACI,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,UAAU,CAAC,oBAAoB,CAAC;IAchH;;;;OAIG;IACI,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,UAAU,CAAC,IAAI,CAAC;CAIhG","file":"wdac-operations.d.ts","sourcesContent":["import { Observable, throwError } from 'rxjs';\r\nimport { catchError, map, switchMap } from 'rxjs/operators';\r\nimport { AppContext } from './app-context';\r\nimport { HttpStatusCode } from './http-constants';\r\nimport { NodeRequest, NodeRequestOptions } from './node-connection';\r\n\r\n/**\r\n * PowerShell Language mode values.\r\n * https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.pslanguagemode?view=powershellsdk-7.0.0\r\n */\r\nexport enum PSLanguageMode {\r\n FullLanguage = 0,\r\n RestrictedLanguage = 1,\r\n NoLanguage = 2,\r\n ConstrainedLanguage = 3\r\n}\r\n\r\n/**\r\n * Represents the data returned from the psLanguageMode endpoint - /api/nodes/<node>/features/wdac/operations/psLanguageMode\r\n */\r\nexport interface PsLanguageModeResult {\r\n /**\r\n * Status of the request/response.\r\n */\r\n status: HttpStatusCode;\r\n\r\n /**\r\n * PowerShell Language Mode of the target node.\r\n */\r\n psLanguageMode: PSLanguageMode;\r\n}\r\n\r\n/**\r\n * Windows Defender Application Control (WDAC) Constants.\r\n */\r\nexport class WdacConstants {\r\n /**\r\n * PowerShell Language mode API endpoint.\r\n */\r\n public static psLanguageModeUrl = 'features/wdac/operations/psLanguageMode';\r\n\r\n /**\r\n * Wdac cache reset API endpoint.\r\n */\r\n public static resetWdacCacheUrl = 'features/wdac/operations/resetWdacCache';\r\n}\r\n\r\n/**\r\n * Windows Defender Application Control (WDAC) operations class.\r\n */\r\nexport class WdacOperations {\r\n /**\r\n * Initializes a new instance of the WdacOperations class.\r\n *\r\n * @param appContext the application context.\r\n */\r\n constructor(private appContext: AppContext) { }\r\n\r\n /**\r\n * Gets the PowerShell Language Mode of a specified targetNodeName.\r\n * @param targetNodeName the machine name to get the WdacMode for.\r\n * @param options the NodeRequestOptions for this API call.\r\n */\r\n public getPsLanguageMode(targetNodeName: string, options?: NodeRequestOptions): Observable<PsLanguageModeResult> {\r\n return this.appContext.node.get(targetNodeName, WdacConstants.psLanguageModeUrl, <NodeRequest>options)\r\n .pipe(\r\n catchError((error, caught) => {\r\n // catch elevation error and retry after elevated.\r\n if (this.appContext.gateway.isElevationRequired(error)) {\r\n return this.appContext.gateway.pollingGatewayElevated()\r\n .pipe(switchMap(elevated => elevated ? caught : throwError(() => error)));\r\n }\r\n return throwError(() => error);\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Resets the WDAC cache of a specified targetNodeName.\r\n * @param targetNodeName the machine name to reset the WDAC cache for.\r\n * @param options the NodeRequestOptions for this API call.\r\n */\r\n public resetWdacCache(targetNodeName: string, options?: NodeRequestOptions): Observable<void> {\r\n return this.appContext.node.post(targetNodeName, WdacConstants.resetWdacCacheUrl, null, <NodeRequest>options)\r\n .pipe(map(() => null));\r\n }\r\n}\r\n"]}