Skip to content

Commit cfef6f8

Browse files
committed
Merge branch 'main' into starfx-with-effection-v4
2 parents 18105c6 + d4f2be5 commit cfef6f8

File tree

15 files changed

+1213
-343
lines changed

15 files changed

+1213
-343
lines changed

.changes/change-pr-349.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@simulacrum/auth0-simulator": patch
3+
"@simulacrum/github-api-simulator": patch
4+
"@simulacrum/foundation-simulator": patch
5+
"@simulacrum/server": patch
6+
---
7+
8+
Skip simulator asset minification. Also remove usage of `String.raw`. This was breaking the `/login` view in the Auth0 simulator with the way `tsdown` was escaping the strings.

package-lock.json

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

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
"npm": ">=11"
3434
},
3535
"volta": {
36-
"node": "20.19.5",
37-
"npm": "11.6.2"
36+
"node": "20.19.6",
37+
"npm": "11.7.0"
3838
},
3939
"devDependencies": {
4040
"@arethetypeswrong/core": "^0.18.2",
41-
"publint": "^0.3.13",
42-
"tsdown": "^0.15.4",
43-
"tsx": "^4.20.6",
41+
"publint": "^0.3.16",
42+
"tsdown": "^0.18.4",
43+
"tsx": "^4.21.0",
4444
"typescript": "5.8.3",
4545
"vitest": "^3.2.4"
4646
}

packages/auth0/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@
5757
"@types/jsesc": "^3.0.3",
5858
"@types/jsonwebtoken": "^9.0.9"
5959
},
60-
"module": "./dist/index.js",
60+
"module": "./dist/index.mjs",
6161
"types": "./dist/index.d.cts",
6262
"exports": {
6363
".": {
6464
"development": "./src/index.ts",
65-
"import": "./dist/index.js",
66-
"require": "./dist/index.cjs"
65+
"require": "./dist/index.cjs",
66+
"import": "./dist/index.mjs"
6767
},
6868
"./package.json": "./package.json"
6969
},
@@ -78,8 +78,8 @@
7878
"publishConfig": {
7979
"exports": {
8080
".": {
81-
"import": "./dist/index.js",
82-
"require": "./dist/index.cjs"
81+
"require": "./dist/index.cjs",
82+
"import": "./dist/index.mjs"
8383
},
8484
"./package.json": "./package.json"
8585
}

packages/auth0/src/views/login.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { ScopeConfig } from "../types.ts";
22
import { deriveScope } from "../handlers/utils.ts";
3-
const html = String.raw;
43

54
interface LoginViewProps {
65
domain: string;
@@ -19,7 +18,7 @@ export const loginView = ({
1918
audience,
2019
loginFailed = false,
2120
}: LoginViewProps): string => {
22-
return html`
21+
return /*html*/ `
2322
<html lang="en">
2423
<head>
2524
<meta charset="UTF-8" />
@@ -56,9 +55,9 @@ export const loginView = ({
5655
autocomplete="email"
5756
required=""
5857
value=""
59-
class="${loginFailed
60-
? "border-red-500"
61-
: ""} appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm"
58+
class="${
59+
loginFailed ? "border-red-500" : ""
60+
} appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm"
6261
placeholder="Email address"
6362
/>
6463
</div>
@@ -70,17 +69,17 @@ export const loginView = ({
7069
type="password"
7170
autocomplete="current-password"
7271
required=""
73-
class="my-4 ${loginFailed
74-
? "border-red-500"
75-
: ""} appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm"
72+
class="my-4 ${
73+
loginFailed ? "border-red-500" : ""
74+
} appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm"
7675
placeholder="Password"
7776
/>
7877
</div>
7978
</div>
8079
<div
81-
class="error bg-red-500 text-white p-3 ${loginFailed
82-
? ""
83-
: "hidden"}"
80+
class="error bg-red-500 text-white p-3 ${
81+
loginFailed ? "" : "hidden"
82+
}"
8483
>
8584
Wrong email or password
8685
</div>

packages/auth0/src/views/username-password.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,22 @@ export const userNamePasswordForm = ({
3737
})
3838
);
3939

40-
return `
41-
<form method="post" name="hiddenform" action="${auth0Domain}">
42-
<input type="hidden" name="wa" value="wsignin1.0">
43-
<input type="hidden"
44-
name="wresult"
45-
value="eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1c2VyX2lkIjoiNjA1MzhjYWQ2YWI5ODQwMDY5OWIxZDZhIiwiZW1haWwiOiJpbXJhbi5zdWxlbWFuamlAcmVzaWRlby5jb20iLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsInNpZCI6Im5zSHZTQ0lYT2NGSUZINUIyRzdVdUFEWDVQTlR4cmRPIiwiaWF0IjoxNjE2MTU0ODA0LCJleHAiOjE2MTYxNTQ4NjQsImF1ZCI6InVybjphdXRoMDpyZXNpZGVvOlVzZXJuYW1lLVBhc3N3b3JkLUF1dGhlbnRpY2F0aW9uIiwiaXNzIjoidXJuOmF1dGgwIn0.CTl0A1hDc4YrErsrFBCCEG0ekIUU3bv0x12p_vUgoyD6zOg_QhaSZjKeZI2elaeYnAi7KUcohgOP9TApj3VlQtm6GlGNuWIiQke4866FtfhufGo2_uLBWyf4nmOgbNcmhpIg2bvVJHUqM-6OCNfnzPWAoFW2_g-DeIo20WBfK2E">
46-
<input type="hidden" name="wctx" value="${wctx}">
40+
return /*html*/ `
41+
<form
42+
method="post"
43+
name="hiddenform"
44+
action="${auth0Domain}"
45+
>
46+
<input type="hidden" name="wa" value="wsignin1.0" />
47+
<input
48+
type="hidden"
49+
name="wresult"
50+
value="eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1c2VyX2lkIjoiNjA1MzhjYWQ2YWI5ODQwMDY5OWIxZDZhIiwiZW1haWwiOiJpbXJhbi5zdWxlbWFuamlAcmVzaWRlby5jb20iLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsInNpZCI6Im5zSHZTQ0lYT2NGSUZINUIyRzdVdUFEWDVQTlR4cmRPIiwiaWF0IjoxNjE2MTU0ODA0LCJleHAiOjE2MTYxNTQ4NjQsImF1ZCI6InVybjphdXRoMDpyZXNpZGVvOlVzZXJuYW1lLVBhc3N3b3JkLUF1dGhlbnRpY2F0aW9uIiwiaXNzIjoidXJuOmF1dGgwIn0.CTl0A1hDc4YrErsrFBCCEG0ekIUU3bv0x12p_vUgoyD6zOg_QhaSZjKeZI2elaeYnAi7KUcohgOP9TApj3VlQtm6GlGNuWIiQke4866FtfhufGo2_uLBWyf4nmOgbNcmhpIg2bvVJHUqM-6OCNfnzPWAoFW2_g-DeIo20WBfK2E"
51+
/>
52+
<input type="hidden" name="wctx" value="${wctx}" />
4753
<noscript>
48-
<p>
49-
Script is disabled. Click Submit to continue.
50-
</p>
51-
<input type="submit" value="Submit">
54+
<p>Script is disabled. Click Submit to continue.</p>
55+
<input type="submit" value="Submit" />
5256
</noscript>
5357
</form>`;
5458
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const webMessage = ({
1414
{ json: true, isScriptContext: true }
1515
);
1616

17-
return `
17+
return /*html*/ `
1818
<!DOCTYPE html>
1919
<html lang="en">
2020
<head>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { describe, it, expect } from "vitest";
2+
import { run, until, sleep, useAbortSignal, Err, Ok } from "effection";
3+
import { execSync } from "child_process";
4+
import { existsSync } from "fs";
5+
import { useService } from "@simulacrum/server";
6+
7+
const AUTH0_PORT = 4400;
8+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
9+
const AUTH0_URL = `https://localhost:${AUTH0_PORT}`;
10+
11+
// Ensure built distribution is present; if not, build it so the smoke test can run locally
12+
if (!existsSync("./dist/index.cjs")) {
13+
console.log("ci-smoke: dist not found, running `npm run build`...");
14+
execSync("npm run prepack", { stdio: "inherit" });
15+
}
16+
17+
// Helper to start the built auth0 service with a wellness check (reused by tests)
18+
function startAuth0() {
19+
return useService("auth0", "node ./bin/start.cjs", {
20+
wellnessCheck: {
21+
timeout: 30000,
22+
*operation(_stdio) {
23+
const signal = yield* useAbortSignal();
24+
const start = Date.now();
25+
while (true) {
26+
try {
27+
yield* until(
28+
fetch(`${AUTH0_URL}/login`, {
29+
headers: { accept: "text/html" },
30+
signal,
31+
}).then((r) => {
32+
if (!r.ok) throw new Error(`not ready: ${r.status}`);
33+
return true;
34+
})
35+
);
36+
return Ok<void>(void 0);
37+
} catch (err) {
38+
// ignore and retry
39+
}
40+
if (Date.now() - start > 30000)
41+
return Err(new Error("service did not start"));
42+
yield* sleep(200);
43+
}
44+
},
45+
},
46+
});
47+
}
48+
49+
describe("CI smoke: built dist server", () => {
50+
it("returns /login without escaped closing script tags", async () => {
51+
await run(function* () {
52+
yield* startAuth0();
53+
54+
const signal = yield* useAbortSignal();
55+
const text = yield* until(
56+
fetch(`${AUTH0_URL}/login`, { signal }).then((r) => {
57+
if (!r.ok) throw new Error(`fetch failed: ${r.status}`);
58+
return r.text();
59+
})
60+
);
61+
62+
expect(text).toMatch(/<\/script>/);
63+
expect(text).not.toContain("<\\/script>");
64+
});
65+
}, 60000);
66+
67+
it("returns /authorize?response_mode=web_message without escaped closing script tags", async () => {
68+
await run(function* () {
69+
yield* startAuth0();
70+
71+
const url = `${AUTH0_URL}/authorize?response_mode=web_message&redirect_uri=http://localhost:3000&currentUser=default`;
72+
const signal2 = yield* useAbortSignal();
73+
const text = yield* until(
74+
fetch(url, { headers: { accept: "text/html" }, signal: signal2 }).then(
75+
(r) => {
76+
if (!r.ok) throw new Error(`fetch failed: ${r.status}`);
77+
return r.text();
78+
}
79+
)
80+
);
81+
82+
expect(text).toMatch(/<\/script>/);
83+
expect(text).not.toContain("<\\/script>");
84+
});
85+
}, 60000);
86+
});

packages/auth0/tsdown.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ export default defineConfig({
88
dts: {
99
sourcemap: true,
1010
},
11-
copy: ["src/views/public"],
11+
copy: [{ from: "src/views/public", to: "dist", flatten: false }],
12+
// not really required and can mangle things
13+
minify: false,
14+
// don't bundle up as have some relative path imports for static assets
15+
unbundle: true,
16+
// if we unbundle, we want to skip this as well
17+
skipNodeModulesBundle: true,
1218
// runs with @arethetypeswrong/core which checks types
1319
attw: false,
1420
publint: true,

packages/foundation/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
"exports": {
5959
".": {
6060
"development": "./src/index.ts",
61-
"import": "./dist/index.js",
62-
"require": "./dist/index.cjs"
61+
"require": "./dist/index.cjs",
62+
"import": "./dist/index.mjs"
6363
},
6464
"./package.json": "./package.json"
6565
},
@@ -72,13 +72,13 @@
7272
}
7373
},
7474
"main": "./dist/index.cjs",
75-
"module": "./dist/index.js",
75+
"module": "./dist/index.mjs",
7676
"types": "./dist/index.d.cts",
7777
"publishConfig": {
7878
"exports": {
7979
".": {
80-
"import": "./dist/index.js",
81-
"require": "./dist/index.cjs"
80+
"require": "./dist/index.cjs",
81+
"import": "./dist/index.mjs"
8282
},
8383
"./package.json": "./package.json"
8484
}

0 commit comments

Comments
 (0)