Skip to content

Commit

Permalink
Windows MDM mostly moved to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
oscartbeaumont committed Sep 30, 2024
1 parent 24f10c7 commit 2303fa7
Show file tree
Hide file tree
Showing 17 changed files with 821 additions and 351 deletions.
1 change: 1 addition & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@mattrax/email": "workspace:*",
"@mattrax/mysql-planetscale": "^0.0.3",
"@mattrax/trpc-server-function": "workspace:*",
"@mattrax/ms-mde": "workspace:*",
"@microlabs/otel-cf-workers": "1.0.0-rc.48",
"@opentelemetry/api": "^1.9.0",
"@paralleldrive/cuid2": "^2.2.2",
Expand Down
34 changes: 23 additions & 11 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ const app = new Hono()
trace.getActiveSpan()?.recordException(err);
return c.json({ error: "Internal Server Error" }, 500);
})
.get("/api/__version", (c) => c.json(GIT_SHA))
.route("/api/waitlist", waitlistRouter)
.all("/api/trpc", async (c) => {
const opts: TrpcServerFunctionOpts = await c.req.json();
const result = await provideRequestEvent(
.use((c, next) =>
provideRequestEvent(
{
hono: c,
request: c.req.raw,
Expand All @@ -48,12 +45,29 @@ const app = new Hono()
response: c.res,
nativeEvent: undefined as any,
},
() => trpcServerFunction({ router, ctx: createTRPCContext(), opts }),
);
() => next(),
),
);

if (import.meta.env.DEV) app.use(logger());

app
.get("/api/__version", (c) => c.json(GIT_SHA))
.route("/api/waitlist", waitlistRouter)
.all("/api/trpc", async (c) => {
const opts: TrpcServerFunctionOpts = await c.req.json();
const result = await trpcServerFunction({
router,
ctx: createTRPCContext(),
opts,
});

c.header("Content-Type", "text/javascript");
c.status(200);
return c.body(toReadableStream(result));
const resp = c.body(toReadableStream(result));
// TODO: For some reason the `c.header` above isn't always respected.
resp.headers.set("Content-Type", "text/javascript");
return resp;
})
.route("/EnrollmentServer", enrollmentServerRouter)
.route("/ManagementServer", managementServerRouter)
Expand All @@ -65,8 +79,6 @@ const app = new Hono()
return c.text("404: Not Found");
});

if (import.meta.env.DEV) app.use(logger());

// TODO: Codegen from `wrangler.toml`
type Env = Record<string, any>;

Expand Down Expand Up @@ -121,7 +133,7 @@ console.trace = (...args) => {
export default {
fetch: async (request: Request, env: Env, ctx: ExecutionContext) => {
// biome-ignore lint/style/noParameterAssign:
if (!env) env = {};
if (!env) env = process.env;
if (!ctx)
// biome-ignore lint/style/noParameterAssign:
ctx = {
Expand Down
11 changes: 0 additions & 11 deletions apps/api/src/win/common.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import { XMLBuilder, XMLParser, XMLValidator } from "fast-xml-parser";

export const parser = new XMLParser({
ignoreAttributes: false,
allowBooleanAttributes: true,
attributeNamePrefix: "",
attributesGroupName: "@_",
});
export const builder = new XMLBuilder();
export const e = new TextEncoder();
export const d = new TextDecoder();

// microsoftDeviceIDExtension contains the OID for the Microsoft certificate extension which includes the MDM DeviceID
export const microsoftDeviceIDExtension = "1.3.6.1.4.1.311.66.1.0";

// export const providerId = "";

// TODO: Remove these
export const identityCertificate = `-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJF1U3FWYXGZFwMA0GCSqGSIb3DQEBCwUAMDUxITAfBgNV
Expand Down
Loading

0 comments on commit 2303fa7

Please sign in to comment.