Skip to content

Commit 33efe53

Browse files
authored
refine types, run tsc for server and auth0 (#329)
* refine types, run tsc for server and auth0 * change file * type check example repos as well * remove expect-errors, resolve some cyclical types in GH sim
1 parent d5533c9 commit 33efe53

37 files changed

+377
-209
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@simulacrum/server": patch:enhance
3+
"@simulacrum/foundation-simulator": patch:enhance
4+
"@simulacrum/auth0-simulator": patch:enhance
5+
"@simulacrum/github-api-simulator": patch:enhance
6+
---
7+
8+
Add additional TypeScript configure in workspace to further refine type checks. Run `tsc` in CI for every package.

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/auth0/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"test:watch": "NODE_EXTRA_CA_CERTS=\"$(mkcert -CAROOT)/rootCA.pem\" vitest watch --fileParallelism=false",
1212
"prepack": "npm run build",
1313
"build": "tsdown",
14-
"lint": "echo noop"
14+
"lint": "echo noop",
15+
"tsc": "tsc --noEmit"
1516
},
1617
"repository": {
1718
"type": "git",

packages/auth0/src/auth/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const PRIVATE_KEY =
2-
"-----BEGIN RSA PRIVATE KEY-----~~MIIEpAIBAAKCAQEAwzwwEqR5p7a6CaG61i3od+GLTyype3t/f0pwwtoA9NsZANcj~~HaAUR/qzqlNRQlLI687vF1OfbETYLeHIT5V36QGrMfrYR/tYAoaKFixC/wOjt8EB~~PoeHgaTOAyGf3V3YNwocNU+StyV1X4hPmDjCrapNYpbKIcAJwq5Ij0WBKGNXBcUU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uvLrUi+MAA4~~EaISkBZQo3ehUMjXm/0PdG4U9f2otAOhdwa2eT9irTkNS0TU+bi7VDEEhTmRKyfO~~yyVAGzTpAoGBAOmPbnMBAJYLk0SiQVspxIT+LW3tDWc7aFr/TtqAXkEVxI2xG6wA~~dEyRasBbPJDSWEljMre4g/6GG1fsPj0l5n2S8azy6jIu49ANvZPrrrBsuVYStR18~~MibzxjWWUht3vOCZBKtbqgHbC/oc49jMLPO5XrDFMTJPU5GkWRRLRZArAoGBANX+~~H6NQ7fUg8TUerXEB1WqA+FH4zVqJ/NKjbqaj9FPFWG59AjBVqQ335QzDWNCs/LjD~~REF/6qMeP2adehNhEVv2nK3rS+po9b4yLkiSysLivFPry9AxMGzFr3XzgoDb+y+y~~T02zj2k7nkGlNSSSanIxsp+TzTKsIY7ZbGx6d8y/AoGAS/kSDmq3DBe70cmNxN+z~~QyeDE4zWnUvfyCngNocnIbi49PY1cB+9tOJgfS2wZ9NkUIrqBoUIupRY9KKuJCnd~~7d8MqhtiPuytwhGWJzW030KejvcK3wp1LeKCCRBaqQCr+csMj8kDZhMgtD0NiInx~~3V3hBVM/i4PuRSPWrhlGCX0CgYEAq/xR8TBaD2kqc0b0np6ap75/1WHhqaK9T42K~~oOOkuq8hI6vU1oQCGvfhXyChgRWHB/foI7xrGC53RkHKm0ioawEJa75whTVWTEaI~~bEuOKpOQSOJ6LBlckg9PtbzAZlBm0S6+DfUCjdEcoCXnUD1cz+qhZR+lC9TMI8Mb~~IRRMtIECgYBrVlenf/rHK1UMC3FDmkOzH7agShcDHqzFMR1/NcMDolZNXXFy/u4t~~nDxci1smAUQr4oNs1lk9UzCdt0+pVCjmhbriBngwsS6sazOesDft53w6RTczsRpa~~09YDfcXhnI5yT+vd5r4xA5HhyniY7W1ahSzGDYIGlVm5IReC3P6Caw==~~-----END RSA PRIVATE KEY-----~~" as const;
33

44
export const JWKS = {
55
keys: [
@@ -12,4 +12,4 @@ export const JWKS = {
1212
use: "sig",
1313
},
1414
],
15-
};
15+
} as const;

packages/auth0/src/config/get-config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ function getPort({ domain, port }: Auth0Configuration): number {
1818
}
1919

2020
if (domain) {
21-
if (domain.split(":").length === 2) {
22-
return parseInt(domain.split(":")[1]);
21+
const parts = domain.split(":");
22+
if (parts.length === 2) {
23+
return parseInt(parts[1]!);
2324
}
2425
}
2526

packages/auth0/src/handlers/auth0-handlers.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,33 +268,37 @@ export const createAuth0Handlers = (
268268
res.status(200).json(userinfo);
269269
},
270270

271-
["/passwordless/start"]: async function (req, res, next) {
271+
["/passwordless/start"]: function (req, res, next) {
272272
logger.log({ "/passwordless/start": { body: req.body } });
273273

274274
try {
275275
const { client_id, connection, email, phone_number, send } = req.body;
276276

277277
// Validate required fields
278278
if (!client_id) {
279-
return res.status(400).json({ error: "client_id is required" });
279+
res.status(400).json({ error: "client_id is required" });
280+
return;
280281
}
281282

282283
if (!connection || (connection !== "email" && connection !== "sms")) {
283-
return res.status(400).json({
284+
res.status(400).json({
284285
error: "connection must be 'email' or 'sms'",
285286
});
287+
return;
286288
}
287289

288290
if (connection === "email" && !email) {
289-
return res.status(400).json({
291+
res.status(400).json({
290292
error: "email is required when connection is 'email'",
291293
});
294+
return;
292295
}
293296

294297
if (connection === "sms" && !phone_number) {
295-
return res.status(400).json({
298+
res.status(400).json({
296299
error: "phone_number is required when connection is 'sms'",
297300
});
301+
return;
298302
}
299303

300304
// Return appropriate response based on connection type

packages/auth0/src/handlers/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ import { defaultErrorHandler } from "../middleware/error-handling.ts";
77
import { createAuth0Handlers } from "./auth0-handlers.ts";
88
import { createOpenIdHandlers } from "./openid-handlers.ts";
99
import path from "path";
10-
import { fileURLToPath } from "url";
11-
import { Auth0Configuration } from "../types.ts";
10+
import { type Auth0Configuration } from "../types.ts";
1211

13-
const __filename = fileURLToPath(import.meta.url);
14-
const __dirname = path.dirname(__filename);
15-
const publicDir = path.join(__dirname, "..", "views", "public");
12+
const publicDir = path.join(import.meta.dirname, "..", "views", "public");
1613
export const extendRouter =
1714
(config: Auth0Configuration, debug = false) =>
1815
(router: Express, simulationStore: ExtendedSimulationStore) => {

packages/auth0/src/handlers/oauth-handlers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import {
1818
createRefreshToken,
1919
issueRefreshToken,
2020
} from "../auth/refresh-token.ts";
21-
import { ExtendedSimulationStore } from "../store/index.ts";
22-
import { Auth0User } from "../store/entities.ts";
21+
import { type ExtendedSimulationStore } from "../store/index.ts";
22+
import { type Auth0User } from "../store/entities.ts";
2323

2424
export const createTokens = async ({
2525
body,

packages/auth0/src/handlers/web-message.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { RequestHandler } from "express";
22
import { assert } from "assert-ts";
33
import { encode } from "base64-url";
4-
import type { QueryParams } from "src/types";
4+
import type { QueryParams } from "../types.ts";
55
import { webMessage } from "../views/web-message.ts";
66

77
export const createWebMessageHandler = (): RequestHandler =>

0 commit comments

Comments
 (0)