appium-xcuitest-driver
Version:
Appium driver for iOS using XCUITest for backend
70 lines • 2.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CertificateClient = void 0;
const remotexpc_utils_1 = require("./remotexpc-utils");
/**
* Certificate (MDM profile) operations on real devices using RemoteXPC.
*
* Requires **iOS/tvOS 18+**, the optional **`appium-ios-remotexpc`** package, and
* {@link CertificateClient.create} to be called with `useRemoteXPC: true` (typically from
* `isIos18OrNewer` after session startup).
*/
class CertificateClient {
mobileConfigService;
log;
constructor(mobileConfigService, log) {
this.mobileConfigService = mobileConfigService;
this.log = log;
}
/**
* Opens a RemoteXPC mobile config service for the given device.
*
* @param udid - Device UDID
* @param log - Appium logger instance
* @param useRemoteXPC - Must be `true` for this client; callers derive this from `isIos18OrNewer(opts)` after `start()`
* @throws {Error} If `useRemoteXPC` is false, or RemoteXPC/mobile config setup fails
*/
static async create(udid, log, useRemoteXPC) {
if (!useRemoteXPC) {
throw new Error('Real device SSL/certificate operations require iOS/tvOS 18 or newer with the optional ' +
'appium-ios-remotexpc package installed.');
}
try {
const Services = await (0, remotexpc_utils_1.getRemoteXPCServices)();
const mobileConfigService = await Services.startMobileConfigService(udid);
return new CertificateClient(mobileConfigService, log);
}
catch (err) {
throw (0, remotexpc_utils_1.wrapRemoteXPCConnectionError)(err, 'Failed to start RemoteXPC mobile config service for certificate operations');
}
}
/**
* Install a certificate / profile from a PEM payload buffer.
*/
async installCertificate(options) {
const { payload } = options;
await this.mobileConfigService.installProfileFromBuffer(payload);
}
/**
* Remove a profile by name.
*
* @param name - Profile identifier to remove
* @returns `'Acknowledged'` when the service accepts the removal request
*/
async removeCertificate(name) {
await this.mobileConfigService.removeProfile(name);
return 'Acknowledged';
}
/**
* @returns Installed profiles metadata from the device
*/
async listCertificates() {
return await this.mobileConfigService.getProfileList();
}
/**
* No-op: discovery RSD is closed by remotexpc before the service is returned.
*/
async close() { }
}
exports.CertificateClient = CertificateClient;
//# sourceMappingURL=certificate-client.js.map