An open API service indexing awesome lists of open source software.

https://github.com/dlenroc/node-wdp

Client for Windows/Xbox Device Portal (WDP)
https://github.com/dlenroc/node-wdp

hololens iot windows-desktop windows-device-portal windows-mobile xbox xbox-device-portal

Last synced: 3 months ago
JSON representation

Client for Windows/Xbox Device Portal (WDP)

Awesome Lists containing this project

README

          

# @dlenroc/wdp ยท [![NPM Version](https://img.shields.io/npm/v/@dlenroc/wdp)](https://www.npmjs.com/package/@dlenroc/wdp)

## Installation

```bash
npm install @dlenroc/wdp --save
```

## Usage

In this [Windows Device Portal (WDP)](https://learn.microsoft.com/en-us/windows/uwp/debug-test-perf/device-portal) binding, all functions are available in 2 styles:

- Via `Wdp` class

Allows you to initialize a class by passing the configuration once through the constructor.

```ts
import { Wdp } from '@dlenroc/wdp'; // ESM
// const { WDP } = require('@dlenroc/wdp'); // CJS

const wdp = new Wdp({ address: ... });
const packages = await wdp.getInstalledAppPackages()
console.log(packages);
```

- Via named import

Allows you to import/use individual methods, but requires passing the configuration as the first parameter.

```ts
import * as wdp from '@dlenroc/wdp'; // ESM
// const wdp = require('@dlenroc/wdp'); // CJS

const ctx = { address: ... };
const packages = await wdp.getInstalledAppPackages(ctx);
console.log(packages);
```

Regardless of which method you choose, the configuration will look the same.

```ts
type WdpCtx = {
// Target
address: string;
username?: string;
password?: string;

// Abort signal
signal?: AbortSignal;

// W3C compliant implementations
implementations?: {
fetch?: any;
FormData?: any;
WebSocket?: any;
};
}
```

> ๐Ÿ“ The ability to provide implementations allows you to provide only features that are missing in the engine, as well as customize those that may not meet your needs.

## Example

Below you can see a simple example for Node.js 16 LTS using [node-fetch](https://www.npmjs.com/package/node-fetch) and [ws](https://www.npmjs.com/package/ws).

```js
import { Wdp } from '@dlenroc/wdp';
import nodeFetch, { Blob, FormData } from 'node-fetch';
import { readFile } from 'node:fs/promises';
import https from 'node:https';
import { setTimeout as sleep } from 'node:timers/promises';
import { WebSocket as NodeWebSocket } from 'ws';

// Custom implementations without SSL verification
const agent = new https.Agent({ rejectUnauthorized: false });
const fetch = (url, init) => nodeFetch(url, { ...init, agent });
const WebSocket = function (url, protocols, options) {
return new NodeWebSocket(url, protocols, { ...options, agent });
};

const wdp = new Wdp({
address: 'https://192.168.18.5:11443',
username: 'auto-xbox',
password: 'secret',
implementations: { fetch, FormData, WebSocket },
});

// Install application
// const appContent = new Blob([await readFile('app.msix')]);
// await wdp.installApp('app.msix', appContent);
// while (true) {
// const state = await wdp.getInstallationState();
// if (!state.InstallRunning) break;
// await sleep(500);
// }

// Open "Microsoft Edge"
const app = await wdp.getInstalledAppPackages();
const edge = app.InstalledPackages.find((app) => app.Name === 'Microsoft Edge');
if (!edge) throw new Error('Microsoft Edge is not installed');
await wdp.startApp(edge.PackageRelativeId);
await sleep(5000);

// Scroll page
const input = await wdp.getRemoteInput();
input.move(50, 50);
for (let i = 0; i < 500; i++) {
input.verticalWheelMove(50, 80, -20);
await sleep(50);
}
input.disconnect();
```

## APIs

```ts
getInstalledAppPackages(options?: { streamable?: boolean; includeframeworkpackages?: boolean }): Promise
```

```ts
getContentGroups(packageFullName: string): Promise
```

```ts
installApp(name: string, content: Blob, extra?: Record): Promise
```

```ts
installCertificate(name: string, content: Blob): Promise
```

```ts
registerNetworkShareApp(app: NetworkAppPackages): Promise
```

```ts
getInstallationState(): Promise
```

```ts
uninstallAppPackage(packageFullName: string): Promise
```

```ts
registerLooseApp(folder: string): Promise
```

```ts
uploadLooseApp(folder: string, files: Record): Promise
```

```ts
pullInstallFromNetwork(install: Record): Promise
```

```ts
deleteSshPins(): Promise
```

```ts
getDeployInfo(packageFullName: string, overlayFolder?: string): Promise
```

```ts
getPairedBluetoothDevices(): Promise
```

```ts
getAvailableBluetoothDevices(): Promise
```

```ts
getBluetoothRadios(): Promise
```

```ts
setBluetoothRadioState(id: string, enable: boolean): Promise
```

```ts
removeBluetoothDevice(deviceId: string): Promise
```

```ts
disconnectBluetoothDevice(deviceId: string): Promise
```

```ts
connectBluetoothDevice(deviceId: string): Promise
```

```ts
getSSLCertificate(): Promise
```

```ts
getContainers(): Promise
```

```ts
getPluginTools(): Promise
```

```ts
getPluginWorkspaces(): Promise
```

```ts
getUniqueId(): Promise
```

```ts
getDevices(): Promise
```

```ts
getUsbDevices(): Promise
```

```ts
getServiceTags(): Promise
```

```ts
deleteAllServiceTags(): Promise
```

```ts
addServiceTag(tag: string): Promise
```

```ts
deleteServiceTag(tag: string): Promise
```

```ts
getCrashDumps(): Promise
```

```ts
getCrashDumpControlSettings(packageFullName: string): Promise
```

```ts
setCrashDumpControlSettings(packageFullName: string, enable: boolean): Promise
```

```ts
getCrashDump(packageFullName: string, fileName: string): Promise
```

```ts
deleteCrashDump(packageFullName: string, fileName: string): Promise
```

```ts
getProcessDump(pid: number): Promise
```

```ts
getKernelDump(): Promise
```

```ts
getBugCheckDumps(): Promise
```

```ts
getBugCheckDump(filename: string): Promise
```

```ts
getCrashControlSettings(): Promise
```

```ts
setCrashControlSettings(settings: DumpSetting): Promise
```

```ts
getWerReports(): Promise
```

```ts
getWerReportFiles(user: string, type: string, name: string): Promise
```

```ts
getWerReportFile(user: string, type: string, name: string, file: string): Promise
```

```ts
getEtwEvents(): Promise
```

```ts
getEtwProviders(): Promise
```

```ts
getCustomEtwProviders(): Promise
```

```ts
getFeatures(): Promise
```

```ts
setFeatureState(id: string, state: boolean): Promise
```

```ts
getFiddlerTracingState(): Promise
```

```ts
enableFiddler(proxyAddress: string, proxyPort: number, cert?: Blob): Promise
```

```ts
disableFiddler(): Promise
```

```ts
getKnownFolders(): Promise
```

```ts
getFiles(knownFolderId: string, options?: { packageFullName?: string; path?: string }): Promise
```

```ts
deleteFile(knownFolderId: string, filename: string, options: { packageFullName?: string; path?: string }): Promise
```

```ts
renameFile(knownFolderId: string, filename: string, newFilename: string, options: { packageFullName?: string; path?: string }): Promise
```

```ts
createFolder(knownFolderId: string, newFolderName: string, options: { packageFullName?: string; path?: string }): Promise
```

```ts
getFile(knownFolderId: string, filename: string, options?: { packageFullName?: string; path?: string }): Promise
```

```ts
uploadFiles(knownFolderId: string, files: Record, options: { packageFullName?: string; path?: string; extract?: boolean }): Promise
```

```ts
getHttpMonitorState(): Promise
```

```ts
getHttpMonitor(): Promise
```

```ts
getLocationOverrideMode(): Promise
```

```ts
setLocationOverrideMode(override: boolean): Promise
```

```ts
getLocation(): Promise
```

```ts
setLocation(position: Location): Promise
```

```ts
getScreenshot(): Promise
```

```ts
getNetworkCredentials(): Promise
```

```ts
addNetworkCredential(networkPath: string, username: string, password: string): Promise
```

```ts
deleteNetworkCredential(networkPath: string): Promise
```

```ts
getIpConfig(): Promise
```

```ts
setIpConfig(guid: string, options?: { ipAddress?: string; subnetMask?: string; defaultGateway?: string; primaryDNS?: string; secondaryDNS?: string }): Promise
```

```ts
setComputerName(name: string): Promise
```

```ts
getComputerName(): Promise
```

```ts
getXboxInfo(): Promise
```

```ts
getOsInfo(): Promise
```

```ts
getDeviceFamily(): Promise
```

```ts
startCustomWprTrace(name: string, content: Blob): Promise
```

```ts
startCustomWprBootTrace(name: string, content: Blob): Promise
```

```ts
startWprTrace(profile: string): Promise
```

```ts
startWprBootTrace(profile: string): Promise
```

```ts
stopWprTrace(): Promise
```

```ts
stopWprBootTrace(): Promise
```

```ts
getWprTraceState(): Promise
```

```ts
getWprTraces(): Promise
```

```ts
getWprTrace(filename: string): Promise
```

```ts
deleteWprTrace(filename: string): Promise
```

```ts
getPowerState(): Promise
```

```ts
getBatteryState(): Promise
```

```ts
getPowerConfig(scheme: string): Promise
```

```ts
setPowerConfig(scheme: string, valueAC: number, valueDC: number): Promise
```

```ts
setPowerActiveScheme(scheme: string): Promise
```

```ts
getPowerActiveScheme(): Promise
```

```ts
getSleepStudyReports(): Promise
```

```ts
getSleepStudyReport(fileName: string): Promise
```

```ts
getSleepStudyTransform(): Promise
```

```ts
getRootKeys(containerId?: string): Promise
```

```ts
getSubKeys(rootKey: string, options?: { regKey?: string; containerId?: string }): Promise
```

```ts
getRegValues(rootKey: string, options?: { regKey?: string; containerId?: string }): Promise
```

```ts
restart(): Promise
```

```ts
shutdown(): Promise
```

```ts
getPhysicalControllers(): Promise
```

```ts
disconnectPhysicalControllers(): Promise
```

```ts
getRemoteInput(options?: { timeout?: number }): Promise
```

```ts
getProcesses(options?: { containerId?: string }): Promise
```

```ts
getSystemPerformanceStatistics(): Promise
```

```ts
getSmbCredentials(): Promise
```

```ts
getSettings(): Promise
```

```ts
getSetting(name: string): Promise
```

```ts
setSetting(name: string, value: any): Promise
```

```ts
startApp(appId: string, options?: { holographic?: boolean; packageFullName?: string }): Promise
```

```ts
stopApp(packageFullName: string, force?: boolean): Promise
```

```ts
suspendApp(packageFullName: string): Promise
```

```ts
resumeApp(packageFullName: string): Promise
```

```ts
stopProcess(pid: number, options?: { containerId?: string }): Promise
```

```ts
getSignedInUser(): Promise
```

```ts
getUsers(): Promise
```

```ts
deleteUser(userId: number): Promise
```

```ts
addUser(email: string, password: string, autoSignIn?: boolean): Promise
```

```ts
setUserSignInState(userId: number, signIn: boolean): Promise
```

```ts
getWindows(containerId?: string): Promise
```

```ts
getWirelessInterfaces(): Promise
```

```ts
getAvailableWirelessNetworks(guid: string): Promise
```

```ts
connectToNetwork(guid: string, ssid: string, key: string, createProfile?: boolean): Promise
```

```ts
connectToNetworkUsingProfile(guid: string, profile: string): Promise
```

```ts
disconnectFromNetwork(guid: string): Promise
```

```ts
deleteWifiProfile(guid: string, profile: string): Promise
```

```ts
getXboxLiveSandbox(): Promise
```

```ts
setXboxLiveSandbox(sandbox: string): Promise
```