apple_configurator/src/index.ts

44 lines
1.3 KiB
TypeScript

import { Plist } from "./plist.js";
const download = document.getElementById("download")! as HTMLLinkElement;
const font = document.getElementById("font")! as HTMLInputElement;
const generate = document.getElementById("generate")! as HTMLButtonElement;
const CONF_UUID = "45ee6279-6b4b-4b9d-8737-45300492aeaf";
const FONT_UUID = "36817e22-dcce-49f2-bea5-ded4aeb7085d";
generate.addEventListener("click", async (ev) => {
ev.preventDefault();
if (font.files == null || font.files.length == 0) {
window.alert("Please select a font file");
return;
}
const payload = Plist.stringify({
PayloadType: "Configuration",
PayloadVersion: 1n,
PayloadDisplayName: "Custom Configuration",
PayloadIdentifier: "eu.packageloss.conf",
PayloadUUID: CONF_UUID,
PayloadContent: [
{
PayloadType: "com.apple.font",
PayloadVersion: 1n,
PayloadDisplayName: "Font",
PayloadIdentifier: "eu.packageloss.conf.font",
PayloadUUID: FONT_UUID,
Name: "Font",
Font: new Uint8Array(await font.files[0].arrayBuffer()),
},
],
});
const blob = new Blob([new TextEncoder().encode(payload)], {
type: "application/xml",
});
download.setAttribute("download", "configuration.mobileconfig");
download.href = URL.createObjectURL(blob);
download.style.visibility = "visible";
});