@simulacrum/auth0-simulator 0.11.1 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/_virtual/rolldown_runtime.mjs +7 -0
  3. package/dist/auth/constants.cjs +15 -0
  4. package/dist/auth/constants.mjs +14 -0
  5. package/dist/auth/constants.mjs.map +1 -0
  6. package/dist/auth/date.cjs +8 -0
  7. package/dist/auth/date.mjs +7 -0
  8. package/dist/auth/date.mjs.map +1 -0
  9. package/dist/auth/jwt.cjs +16 -0
  10. package/dist/auth/jwt.mjs +15 -0
  11. package/dist/auth/jwt.mjs.map +1 -0
  12. package/dist/auth/refresh-token.cjs +24 -0
  13. package/dist/auth/refresh-token.mjs +23 -0
  14. package/dist/auth/refresh-token.mjs.map +1 -0
  15. package/dist/config/get-config.cjs +39 -0
  16. package/dist/config/get-config.mjs +39 -0
  17. package/dist/config/get-config.mjs.map +1 -0
  18. package/dist/handlers/auth0-handlers.cjs +207 -0
  19. package/dist/handlers/auth0-handlers.mjs +207 -0
  20. package/dist/handlers/auth0-handlers.mjs.map +1 -0
  21. package/dist/handlers/index.cjs +29 -0
  22. package/dist/handlers/index.mjs +27 -0
  23. package/dist/handlers/index.mjs.map +1 -0
  24. package/dist/handlers/login-redirect.cjs +24 -0
  25. package/dist/handlers/login-redirect.mjs +24 -0
  26. package/dist/handlers/login-redirect.mjs.map +1 -0
  27. package/dist/handlers/oauth-handlers.cjs +144 -0
  28. package/dist/handlers/oauth-handlers.mjs +144 -0
  29. package/dist/handlers/oauth-handlers.mjs.map +1 -0
  30. package/dist/handlers/openid-handlers.cjs +32 -0
  31. package/dist/handlers/openid-handlers.mjs +33 -0
  32. package/dist/handlers/openid-handlers.mjs.map +1 -0
  33. package/dist/handlers/url.cjs +6 -0
  34. package/dist/handlers/url.mjs +6 -0
  35. package/dist/handlers/url.mjs.map +1 -0
  36. package/dist/handlers/utils.cjs +25 -0
  37. package/dist/handlers/utils.mjs +24 -0
  38. package/dist/handlers/utils.mjs.map +1 -0
  39. package/dist/handlers/web-message.cjs +23 -0
  40. package/dist/handlers/web-message.mjs +23 -0
  41. package/dist/handlers/web-message.mjs.map +1 -0
  42. package/dist/index.cjs +15 -38751
  43. package/dist/index.d.cts +7 -175
  44. package/dist/index.d.cts.map +1 -1
  45. package/dist/index.d.mts +21 -0
  46. package/dist/index.d.mts.map +1 -0
  47. package/dist/index.mjs +22 -0
  48. package/dist/index.mjs.map +1 -0
  49. package/dist/middleware/create-cors.cjs +15 -0
  50. package/dist/middleware/create-cors.mjs +14 -0
  51. package/dist/middleware/create-cors.mjs.map +1 -0
  52. package/dist/middleware/error-handling.cjs +25 -0
  53. package/dist/middleware/error-handling.mjs +25 -0
  54. package/dist/middleware/error-handling.mjs.map +1 -0
  55. package/dist/middleware/no-cache.cjs +10 -0
  56. package/dist/middleware/no-cache.mjs +10 -0
  57. package/dist/middleware/no-cache.mjs.map +1 -0
  58. package/dist/middleware/session.cjs +19 -0
  59. package/dist/middleware/session.mjs +18 -0
  60. package/dist/middleware/session.mjs.map +1 -0
  61. package/dist/rules/extensionless-file-name.cjs +6 -0
  62. package/dist/rules/extensionless-file-name.mjs +6 -0
  63. package/dist/rules/extensionless-file-name.mjs.map +1 -0
  64. package/dist/rules/parse-rules-files.cjs +28 -0
  65. package/dist/rules/parse-rules-files.mjs +26 -0
  66. package/dist/rules/parse-rules-files.mjs.map +1 -0
  67. package/dist/rules/rules-runner.cjs +67 -0
  68. package/dist/rules/rules-runner.mjs +65 -0
  69. package/dist/rules/rules-runner.mjs.map +1 -0
  70. package/dist/store/entities.cjs +37 -0
  71. package/dist/store/entities.d.cts +99 -0
  72. package/dist/store/entities.d.cts.map +1 -0
  73. package/dist/store/entities.d.mts +100 -0
  74. package/dist/store/entities.d.mts.map +1 -0
  75. package/dist/store/entities.mjs +34 -0
  76. package/dist/store/entities.mjs.map +1 -0
  77. package/dist/store/index.cjs +44 -0
  78. package/dist/store/index.d.cts +22 -0
  79. package/dist/store/index.d.cts.map +1 -0
  80. package/dist/store/index.d.mts +22 -0
  81. package/dist/store/index.d.mts.map +1 -0
  82. package/dist/store/index.mjs +45 -0
  83. package/dist/store/index.mjs.map +1 -0
  84. package/dist/types.cjs +24 -0
  85. package/dist/types.d.cts +66 -0
  86. package/dist/types.d.cts.map +1 -0
  87. package/dist/types.d.mts +66 -0
  88. package/dist/types.d.mts.map +1 -0
  89. package/dist/types.mjs +24 -0
  90. package/dist/types.mjs.map +1 -0
  91. package/dist/views/login.cjs +145 -0
  92. package/dist/views/login.mjs +146 -0
  93. package/dist/views/login.mjs.map +1 -0
  94. package/dist/views/username-password.cjs +39 -0
  95. package/dist/views/username-password.mjs +39 -0
  96. package/dist/views/username-password.mjs.map +1 -0
  97. package/dist/views/web-message.cjs +66 -0
  98. package/dist/views/web-message.mjs +65 -0
  99. package/dist/views/web-message.mjs.map +1 -0
  100. package/package.json +9 -9
  101. package/dist/index.d.ts +0 -189
  102. package/dist/index.d.ts.map +0 -1
  103. package/dist/index.js +0 -38747
  104. package/dist/index.js.map +0 -1
  105. /package/dist/{public → views/public}/img/frontside-logo.png +0 -0
@@ -0,0 +1,145 @@
1
+ const require_utils = require('../handlers/utils.cjs');
2
+
3
+ //#region src/views/login.ts
4
+ const loginView = ({ domain, scope: scopeConfig, redirectUri, clientID, audience, loginFailed = false }) => {
5
+ return `
6
+ <html lang="en">
7
+ <head>
8
+ <meta charset="UTF-8" />
9
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
+ <link
11
+ href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css"
12
+ rel="stylesheet"
13
+ />
14
+ <script src="https://cdn.auth0.com/js/auth0/9.19.0/auth0.js"><\/script>
15
+ </head>
16
+ <title>login</title>
17
+ <body>
18
+ <main
19
+ class="min-h-screen flex items-center justify-center bg-white py-12 px-4 sm:px-6 lg:px-8"
20
+ >
21
+ <div class="max-w-md w-full space-y-8">
22
+ <div class="flex justify-center">
23
+ <img
24
+ alt="frontside"
25
+ class="bg-transparent object-contain h-16"
26
+ src="/img/frontside-logo.png"
27
+ />
28
+ </div>
29
+ <h1 class="flex justify-center text-4xl">Welcome</h1>
30
+ <h2 class="flex justify-center">Login to continue to frontside</h2>
31
+ <form id="the-form" class="mt-8 space-y-6">
32
+ <div class="rounded-md shadow-sm -space-y-px">
33
+ <div>
34
+ <label for="username" class="sr-only">Email address</label>
35
+ <input
36
+ id="username"
37
+ name="username"
38
+ type="email"
39
+ autocomplete="email"
40
+ required=""
41
+ value=""
42
+ class="${loginFailed ? "border-red-500" : ""} 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"
43
+ placeholder="Email address"
44
+ />
45
+ </div>
46
+ <div>
47
+ <label for="password" class="sr-only">Password</label>
48
+ <input
49
+ id="password"
50
+ name="password"
51
+ type="password"
52
+ autocomplete="current-password"
53
+ required=""
54
+ class="my-4 ${loginFailed ? "border-red-500" : ""} 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"
55
+ placeholder="Password"
56
+ />
57
+ </div>
58
+ </div>
59
+ <div
60
+ class="error bg-red-500 text-white p-3 ${loginFailed ? "" : "hidden"}"
61
+ >
62
+ Wrong email or password
63
+ </div>
64
+
65
+ <div>
66
+ <button
67
+ id="submit"
68
+ type="submit"
69
+ class="group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
70
+ >
71
+ <span
72
+ class="absolute left-0 inset-y-0 flex items-center pl-3"
73
+ >
74
+ <svg
75
+ class="h-5 w-5 text-blue-500 group-hover:text-blue-400"
76
+ x-description="Heroicon name: solid/lock-closed"
77
+ xmlns="http://www.w3.org/2000/svg"
78
+ viewBox="0 0 20 20"
79
+ fill="currentColor"
80
+ aria-hidden="true"
81
+ >
82
+ <path
83
+ fill-rule="evenodd"
84
+ d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z"
85
+ clip-rule="evenodd"
86
+ ></path>
87
+ </svg>
88
+ </span>
89
+ Sign in
90
+ </button>
91
+ </div>
92
+ </form>
93
+ </div>
94
+ </main>
95
+ <script>
96
+ document.addEventListener("DOMContentLoaded", function () {
97
+ var webAuth = new window.auth0.default.WebAuth({
98
+ domain: "${domain}",
99
+ clientID: "${clientID}",
100
+ redirectUri: "${redirectUri}",
101
+ audience: "${audience}",
102
+ responseType: "token id_token",
103
+ });
104
+ var form = document.querySelector("#the-form");
105
+
106
+ form.addEventListener("submit", function (e) {
107
+ event.preventDefault();
108
+ event.stopPropagation();
109
+ let params = new URLSearchParams(window.location.search);
110
+
111
+ var username = document.querySelector("#username");
112
+ var password = document.querySelector("#password");
113
+
114
+ webAuth.login(
115
+ {
116
+ username: username.value,
117
+ password: password.value,
118
+ realm: "Username-Password-Authentication",
119
+ scope: "${require_utils.deriveScope({
120
+ scopeConfig,
121
+ clientID,
122
+ audience
123
+ })}",
124
+ nonce: params.get("nonce"),
125
+ state: params.get("state"),
126
+ },
127
+ function (err, authResult) {
128
+ if (err) {
129
+ [username, password].forEach((e) =>
130
+ e.classList.add("border-red-500")
131
+ );
132
+ document.querySelector(".error").classList.remove("hidden");
133
+ }
134
+ }
135
+ );
136
+ });
137
+ });
138
+ <\/script>
139
+ </body>
140
+ </html>
141
+ `;
142
+ };
143
+
144
+ //#endregion
145
+ exports.loginView = loginView;
@@ -0,0 +1,146 @@
1
+ import { deriveScope } from "../handlers/utils.mjs";
2
+
3
+ //#region src/views/login.ts
4
+ const loginView = ({ domain, scope: scopeConfig, redirectUri, clientID, audience, loginFailed = false }) => {
5
+ return `
6
+ <html lang="en">
7
+ <head>
8
+ <meta charset="UTF-8" />
9
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
+ <link
11
+ href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css"
12
+ rel="stylesheet"
13
+ />
14
+ <script src="https://cdn.auth0.com/js/auth0/9.19.0/auth0.js"><\/script>
15
+ </head>
16
+ <title>login</title>
17
+ <body>
18
+ <main
19
+ class="min-h-screen flex items-center justify-center bg-white py-12 px-4 sm:px-6 lg:px-8"
20
+ >
21
+ <div class="max-w-md w-full space-y-8">
22
+ <div class="flex justify-center">
23
+ <img
24
+ alt="frontside"
25
+ class="bg-transparent object-contain h-16"
26
+ src="/img/frontside-logo.png"
27
+ />
28
+ </div>
29
+ <h1 class="flex justify-center text-4xl">Welcome</h1>
30
+ <h2 class="flex justify-center">Login to continue to frontside</h2>
31
+ <form id="the-form" class="mt-8 space-y-6">
32
+ <div class="rounded-md shadow-sm -space-y-px">
33
+ <div>
34
+ <label for="username" class="sr-only">Email address</label>
35
+ <input
36
+ id="username"
37
+ name="username"
38
+ type="email"
39
+ autocomplete="email"
40
+ required=""
41
+ value=""
42
+ class="${loginFailed ? "border-red-500" : ""} 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"
43
+ placeholder="Email address"
44
+ />
45
+ </div>
46
+ <div>
47
+ <label for="password" class="sr-only">Password</label>
48
+ <input
49
+ id="password"
50
+ name="password"
51
+ type="password"
52
+ autocomplete="current-password"
53
+ required=""
54
+ class="my-4 ${loginFailed ? "border-red-500" : ""} 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"
55
+ placeholder="Password"
56
+ />
57
+ </div>
58
+ </div>
59
+ <div
60
+ class="error bg-red-500 text-white p-3 ${loginFailed ? "" : "hidden"}"
61
+ >
62
+ Wrong email or password
63
+ </div>
64
+
65
+ <div>
66
+ <button
67
+ id="submit"
68
+ type="submit"
69
+ class="group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
70
+ >
71
+ <span
72
+ class="absolute left-0 inset-y-0 flex items-center pl-3"
73
+ >
74
+ <svg
75
+ class="h-5 w-5 text-blue-500 group-hover:text-blue-400"
76
+ x-description="Heroicon name: solid/lock-closed"
77
+ xmlns="http://www.w3.org/2000/svg"
78
+ viewBox="0 0 20 20"
79
+ fill="currentColor"
80
+ aria-hidden="true"
81
+ >
82
+ <path
83
+ fill-rule="evenodd"
84
+ d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z"
85
+ clip-rule="evenodd"
86
+ ></path>
87
+ </svg>
88
+ </span>
89
+ Sign in
90
+ </button>
91
+ </div>
92
+ </form>
93
+ </div>
94
+ </main>
95
+ <script>
96
+ document.addEventListener("DOMContentLoaded", function () {
97
+ var webAuth = new window.auth0.default.WebAuth({
98
+ domain: "${domain}",
99
+ clientID: "${clientID}",
100
+ redirectUri: "${redirectUri}",
101
+ audience: "${audience}",
102
+ responseType: "token id_token",
103
+ });
104
+ var form = document.querySelector("#the-form");
105
+
106
+ form.addEventListener("submit", function (e) {
107
+ event.preventDefault();
108
+ event.stopPropagation();
109
+ let params = new URLSearchParams(window.location.search);
110
+
111
+ var username = document.querySelector("#username");
112
+ var password = document.querySelector("#password");
113
+
114
+ webAuth.login(
115
+ {
116
+ username: username.value,
117
+ password: password.value,
118
+ realm: "Username-Password-Authentication",
119
+ scope: "${deriveScope({
120
+ scopeConfig,
121
+ clientID,
122
+ audience
123
+ })}",
124
+ nonce: params.get("nonce"),
125
+ state: params.get("state"),
126
+ },
127
+ function (err, authResult) {
128
+ if (err) {
129
+ [username, password].forEach((e) =>
130
+ e.classList.add("border-red-500")
131
+ );
132
+ document.querySelector(".error").classList.remove("hidden");
133
+ }
134
+ }
135
+ );
136
+ });
137
+ });
138
+ <\/script>
139
+ </body>
140
+ </html>
141
+ `;
142
+ };
143
+
144
+ //#endregion
145
+ export { loginView };
146
+ //# sourceMappingURL=login.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.mjs","names":[],"sources":["../../src/views/login.ts"],"sourcesContent":["import type { ScopeConfig } from \"../types.ts\";\nimport { deriveScope } from \"../handlers/utils.ts\";\n\ninterface LoginViewProps {\n domain: string;\n scope: ScopeConfig;\n redirectUri: string;\n clientID: string;\n audience: string;\n loginFailed: boolean;\n}\n\nexport const loginView = ({\n domain,\n scope: scopeConfig,\n redirectUri,\n clientID,\n audience,\n loginFailed = false,\n}: LoginViewProps): string => {\n return /*html*/ `\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <link\n href=\"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css\"\n rel=\"stylesheet\"\n />\n <script src=\"https://cdn.auth0.com/js/auth0/9.19.0/auth0.js\"></script>\n </head>\n <title>login</title>\n <body>\n <main\n class=\"min-h-screen flex items-center justify-center bg-white py-12 px-4 sm:px-6 lg:px-8\"\n >\n <div class=\"max-w-md w-full space-y-8\">\n <div class=\"flex justify-center\">\n <img\n alt=\"frontside\"\n class=\"bg-transparent object-contain h-16\"\n src=\"/img/frontside-logo.png\"\n />\n </div>\n <h1 class=\"flex justify-center text-4xl\">Welcome</h1>\n <h2 class=\"flex justify-center\">Login to continue to frontside</h2>\n <form id=\"the-form\" class=\"mt-8 space-y-6\">\n <div class=\"rounded-md shadow-sm -space-y-px\">\n <div>\n <label for=\"username\" class=\"sr-only\">Email address</label>\n <input\n id=\"username\"\n name=\"username\"\n type=\"email\"\n autocomplete=\"email\"\n required=\"\"\n value=\"\"\n class=\"${\n loginFailed ? \"border-red-500\" : \"\"\n } 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\"\n placeholder=\"Email address\"\n />\n </div>\n <div>\n <label for=\"password\" class=\"sr-only\">Password</label>\n <input\n id=\"password\"\n name=\"password\"\n type=\"password\"\n autocomplete=\"current-password\"\n required=\"\"\n class=\"my-4 ${\n loginFailed ? \"border-red-500\" : \"\"\n } 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\"\n placeholder=\"Password\"\n />\n </div>\n </div>\n <div\n class=\"error bg-red-500 text-white p-3 ${\n loginFailed ? \"\" : \"hidden\"\n }\"\n >\n Wrong email or password\n </div>\n\n <div>\n <button\n id=\"submit\"\n type=\"submit\"\n class=\"group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500\"\n >\n <span\n class=\"absolute left-0 inset-y-0 flex items-center pl-3\"\n >\n <svg\n class=\"h-5 w-5 text-blue-500 group-hover:text-blue-400\"\n x-description=\"Heroicon name: solid/lock-closed\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n fill-rule=\"evenodd\"\n d=\"M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z\"\n clip-rule=\"evenodd\"\n ></path>\n </svg>\n </span>\n Sign in\n </button>\n </div>\n </form>\n </div>\n </main>\n <script>\n document.addEventListener(\"DOMContentLoaded\", function () {\n var webAuth = new window.auth0.default.WebAuth({\n domain: \"${domain}\",\n clientID: \"${clientID}\",\n redirectUri: \"${redirectUri}\",\n audience: \"${audience}\",\n responseType: \"token id_token\",\n });\n var form = document.querySelector(\"#the-form\");\n\n form.addEventListener(\"submit\", function (e) {\n event.preventDefault();\n event.stopPropagation();\n let params = new URLSearchParams(window.location.search);\n\n var username = document.querySelector(\"#username\");\n var password = document.querySelector(\"#password\");\n\n webAuth.login(\n {\n username: username.value,\n password: password.value,\n realm: \"Username-Password-Authentication\",\n scope: \"${deriveScope({ scopeConfig, clientID, audience })}\",\n nonce: params.get(\"nonce\"),\n state: params.get(\"state\"),\n },\n function (err, authResult) {\n if (err) {\n [username, password].forEach((e) =>\n e.classList.add(\"border-red-500\")\n );\n document.querySelector(\".error\").classList.remove(\"hidden\");\n }\n }\n );\n });\n });\n </script>\n </body>\n </html>\n `;\n};\n"],"mappings":";;;AAYA,MAAa,aAAa,EACxB,QACA,OAAO,aACP,aACA,UACA,UACA,cAAc,YACc;AAC5B,QAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAsCI,cAAc,mBAAmB,GAClC;;;;;;;;;;;;kCAaC,cAAc,mBAAmB,GAClC;;;;;;yDAOH,cAAc,KAAK,SACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAsCQ,OAAO;2BACL,SAAS;8BACN,YAAY;2BACf,SAAS;;;;;;;;;;;;;;;;;;4BAkBR,YAAY;EAAE;EAAa;EAAU;EAAU,CAAC,CAAC"}
@@ -0,0 +1,39 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let html_entities = require("html-entities");
3
+
4
+ //#region src/views/username-password.ts
5
+ const userNamePasswordForm = ({ auth0Domain = "/login/callback", redirect_uri, state, nonce, client_id, scope, audience, connection, response_type, tenant }) => {
6
+ return `
7
+ <form
8
+ method="post"
9
+ name="hiddenform"
10
+ action="${auth0Domain}"
11
+ >
12
+ <input type="hidden" name="wa" value="wsignin1.0" />
13
+ <input
14
+ type="hidden"
15
+ name="wresult"
16
+ value="eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1c2VyX2lkIjoiNjA1MzhjYWQ2YWI5ODQwMDY5OWIxZDZhIiwiZW1haWwiOiJpbXJhbi5zdWxlbWFuamlAcmVzaWRlby5jb20iLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsInNpZCI6Im5zSHZTQ0lYT2NGSUZINUIyRzdVdUFEWDVQTlR4cmRPIiwiaWF0IjoxNjE2MTU0ODA0LCJleHAiOjE2MTYxNTQ4NjQsImF1ZCI6InVybjphdXRoMDpyZXNpZGVvOlVzZXJuYW1lLVBhc3N3b3JkLUF1dGhlbnRpY2F0aW9uIiwiaXNzIjoidXJuOmF1dGgwIn0.CTl0A1hDc4YrErsrFBCCEG0ekIUU3bv0x12p_vUgoyD6zOg_QhaSZjKeZI2elaeYnAi7KUcohgOP9TApj3VlQtm6GlGNuWIiQke4866FtfhufGo2_uLBWyf4nmOgbNcmhpIg2bvVJHUqM-6OCNfnzPWAoFW2_g-DeIo20WBfK2E"
17
+ />
18
+ <input type="hidden" name="wctx" value="${(0, html_entities.encode)(JSON.stringify({
19
+ strategy: "auth0",
20
+ tenant,
21
+ connection,
22
+ client_id,
23
+ response_type,
24
+ scope,
25
+ redirect_uri,
26
+ state,
27
+ nonce,
28
+ audience,
29
+ realm: connection
30
+ }))}" />
31
+ <noscript>
32
+ <p>Script is disabled. Click Submit to continue.</p>
33
+ <input type="submit" value="Submit" />
34
+ </noscript>
35
+ </form>`;
36
+ };
37
+
38
+ //#endregion
39
+ exports.userNamePasswordForm = userNamePasswordForm;
@@ -0,0 +1,39 @@
1
+ import { encode } from "html-entities";
2
+
3
+ //#region src/views/username-password.ts
4
+ const userNamePasswordForm = ({ auth0Domain = "/login/callback", redirect_uri, state, nonce, client_id, scope, audience, connection, response_type, tenant }) => {
5
+ return `
6
+ <form
7
+ method="post"
8
+ name="hiddenform"
9
+ action="${auth0Domain}"
10
+ >
11
+ <input type="hidden" name="wa" value="wsignin1.0" />
12
+ <input
13
+ type="hidden"
14
+ name="wresult"
15
+ value="eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1c2VyX2lkIjoiNjA1MzhjYWQ2YWI5ODQwMDY5OWIxZDZhIiwiZW1haWwiOiJpbXJhbi5zdWxlbWFuamlAcmVzaWRlby5jb20iLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsInNpZCI6Im5zSHZTQ0lYT2NGSUZINUIyRzdVdUFEWDVQTlR4cmRPIiwiaWF0IjoxNjE2MTU0ODA0LCJleHAiOjE2MTYxNTQ4NjQsImF1ZCI6InVybjphdXRoMDpyZXNpZGVvOlVzZXJuYW1lLVBhc3N3b3JkLUF1dGhlbnRpY2F0aW9uIiwiaXNzIjoidXJuOmF1dGgwIn0.CTl0A1hDc4YrErsrFBCCEG0ekIUU3bv0x12p_vUgoyD6zOg_QhaSZjKeZI2elaeYnAi7KUcohgOP9TApj3VlQtm6GlGNuWIiQke4866FtfhufGo2_uLBWyf4nmOgbNcmhpIg2bvVJHUqM-6OCNfnzPWAoFW2_g-DeIo20WBfK2E"
16
+ />
17
+ <input type="hidden" name="wctx" value="${encode(JSON.stringify({
18
+ strategy: "auth0",
19
+ tenant,
20
+ connection,
21
+ client_id,
22
+ response_type,
23
+ scope,
24
+ redirect_uri,
25
+ state,
26
+ nonce,
27
+ audience,
28
+ realm: connection
29
+ }))}" />
30
+ <noscript>
31
+ <p>Script is disabled. Click Submit to continue.</p>
32
+ <input type="submit" value="Submit" />
33
+ </noscript>
34
+ </form>`;
35
+ };
36
+
37
+ //#endregion
38
+ export { userNamePasswordForm };
39
+ //# sourceMappingURL=username-password.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"username-password.mjs","names":[],"sources":["../../src/views/username-password.ts"],"sourcesContent":["import { encode } from \"html-entities\";\nimport type { QueryParams } from \"../types.ts\";\n\nexport type UserNamePasswordForm = {\n auth0Domain?: string;\n audience?: string;\n connection?: string;\n response_type?: string;\n tenant: string;\n} & Partial<QueryParams>;\n\nexport const userNamePasswordForm = ({\n auth0Domain = \"/login/callback\",\n redirect_uri,\n state,\n nonce,\n client_id,\n scope,\n audience,\n connection,\n response_type,\n tenant,\n}: UserNamePasswordForm): string => {\n let wctx = encode(\n JSON.stringify({\n strategy: \"auth0\",\n tenant,\n connection,\n client_id,\n response_type,\n scope,\n redirect_uri,\n state,\n nonce,\n audience,\n realm: connection,\n })\n );\n\n return /*html*/ `\n <form\n method=\"post\"\n name=\"hiddenform\"\n action=\"${auth0Domain}\"\n >\n <input type=\"hidden\" name=\"wa\" value=\"wsignin1.0\" />\n <input\n type=\"hidden\"\n name=\"wresult\"\n value=\"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1c2VyX2lkIjoiNjA1MzhjYWQ2YWI5ODQwMDY5OWIxZDZhIiwiZW1haWwiOiJpbXJhbi5zdWxlbWFuamlAcmVzaWRlby5jb20iLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsInNpZCI6Im5zSHZTQ0lYT2NGSUZINUIyRzdVdUFEWDVQTlR4cmRPIiwiaWF0IjoxNjE2MTU0ODA0LCJleHAiOjE2MTYxNTQ4NjQsImF1ZCI6InVybjphdXRoMDpyZXNpZGVvOlVzZXJuYW1lLVBhc3N3b3JkLUF1dGhlbnRpY2F0aW9uIiwiaXNzIjoidXJuOmF1dGgwIn0.CTl0A1hDc4YrErsrFBCCEG0ekIUU3bv0x12p_vUgoyD6zOg_QhaSZjKeZI2elaeYnAi7KUcohgOP9TApj3VlQtm6GlGNuWIiQke4866FtfhufGo2_uLBWyf4nmOgbNcmhpIg2bvVJHUqM-6OCNfnzPWAoFW2_g-DeIo20WBfK2E\"\n />\n <input type=\"hidden\" name=\"wctx\" value=\"${wctx}\" />\n <noscript>\n <p>Script is disabled. Click Submit to continue.</p>\n <input type=\"submit\" value=\"Submit\" />\n </noscript>\n </form>`;\n};\n"],"mappings":";;;AAWA,MAAa,wBAAwB,EACnC,cAAc,mBACd,cACA,OACA,OACA,WACA,OACA,UACA,YACA,eACA,aACkC;AAiBlC,QAAgB;;;;cAIJ,YAAY;;;;;;;;8CApBb,OACT,KAAK,UAAU;EACb,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;EACR,CAAC,CACH,CAcgD"}
@@ -0,0 +1,66 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let jsesc = require("jsesc");
3
+ jsesc = require_rolldown_runtime.__toESM(jsesc);
4
+
5
+ //#region src/views/web-message.ts
6
+ const webMessage = ({ state, code, redirect_uri, nonce }) => {
7
+ let data = (0, jsesc.default)({ redirect_uri }, {
8
+ json: true,
9
+ isScriptContext: true
10
+ });
11
+ return `
12
+ <!DOCTYPE html>
13
+ <html lang="en">
14
+ <head>
15
+ <title>Authorization Response</title>
16
+ </head>
17
+ <body>
18
+ <script ${nonce ? `nonce="${nonce}"` : ""} type="application/javascript">
19
+ (function(window, document) {
20
+ var data = ${data};
21
+ var targetOrigin = data.redirect_uri;
22
+ var webMessageRequest = {};
23
+
24
+ var authorizationResponse = {
25
+ type: "authorization_response",
26
+ response: {
27
+ "code":"${code}",
28
+ "state":"${state}"}
29
+ };
30
+
31
+ var mainWin = (window.opener) ? window.opener : window.parent;
32
+
33
+ if (webMessageRequest["web_message_uri"] && webMessageRequest["web_message_target"]) {
34
+ window.addEventListener("message", function(evt) {
35
+ if (evt.origin != targetOrigin) {
36
+ return;
37
+ }
38
+
39
+ switch (evt.data.type) {
40
+ case "relay_response":
41
+ var messageTargetWindow = evt.source.frames[webMessageRequest["web_message_target"]];
42
+
43
+ if (messageTargetWindow) {
44
+ messageTargetWindow.postMessage(authorizationResponse, webMessageRequest["web_message_uri"]);
45
+ window.close();
46
+ }
47
+ break;
48
+ }
49
+ }
50
+ );
51
+
52
+ mainWin.postMessage({
53
+ type: "relay_request"
54
+ }, targetOrigin);
55
+ } else {
56
+ mainWin.postMessage(authorizationResponse, targetOrigin);
57
+ }
58
+ })(this, this.document);
59
+ <\/script>
60
+ </body>
61
+ </html>
62
+ `;
63
+ };
64
+
65
+ //#endregion
66
+ exports.webMessage = webMessage;
@@ -0,0 +1,65 @@
1
+ import jsesc from "jsesc";
2
+
3
+ //#region src/views/web-message.ts
4
+ const webMessage = ({ state, code, redirect_uri, nonce }) => {
5
+ let data = jsesc({ redirect_uri }, {
6
+ json: true,
7
+ isScriptContext: true
8
+ });
9
+ return `
10
+ <!DOCTYPE html>
11
+ <html lang="en">
12
+ <head>
13
+ <title>Authorization Response</title>
14
+ </head>
15
+ <body>
16
+ <script ${nonce ? `nonce="${nonce}"` : ""} type="application/javascript">
17
+ (function(window, document) {
18
+ var data = ${data};
19
+ var targetOrigin = data.redirect_uri;
20
+ var webMessageRequest = {};
21
+
22
+ var authorizationResponse = {
23
+ type: "authorization_response",
24
+ response: {
25
+ "code":"${code}",
26
+ "state":"${state}"}
27
+ };
28
+
29
+ var mainWin = (window.opener) ? window.opener : window.parent;
30
+
31
+ if (webMessageRequest["web_message_uri"] && webMessageRequest["web_message_target"]) {
32
+ window.addEventListener("message", function(evt) {
33
+ if (evt.origin != targetOrigin) {
34
+ return;
35
+ }
36
+
37
+ switch (evt.data.type) {
38
+ case "relay_response":
39
+ var messageTargetWindow = evt.source.frames[webMessageRequest["web_message_target"]];
40
+
41
+ if (messageTargetWindow) {
42
+ messageTargetWindow.postMessage(authorizationResponse, webMessageRequest["web_message_uri"]);
43
+ window.close();
44
+ }
45
+ break;
46
+ }
47
+ }
48
+ );
49
+
50
+ mainWin.postMessage({
51
+ type: "relay_request"
52
+ }, targetOrigin);
53
+ } else {
54
+ mainWin.postMessage(authorizationResponse, targetOrigin);
55
+ }
56
+ })(this, this.document);
57
+ <\/script>
58
+ </body>
59
+ </html>
60
+ `;
61
+ };
62
+
63
+ //#endregion
64
+ export { webMessage };
65
+ //# sourceMappingURL=web-message.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-message.mjs","names":[],"sources":["../../src/views/web-message.ts"],"sourcesContent":["import jsesc from \"jsesc\";\nimport type { QueryParams } from \"../types.ts\";\n\nexport const webMessage = ({\n state,\n code,\n redirect_uri,\n nonce,\n}: Pick<QueryParams, \"state\" | \"code\" | \"redirect_uri\" | \"nonce\">): string => {\n let data = jsesc(\n {\n redirect_uri,\n },\n { json: true, isScriptContext: true }\n );\n\n return /*html*/ `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <title>Authorization Response</title>\n </head>\n <body>\n <script ${nonce ? `nonce=\"${nonce}\"` : \"\"} type=\"application/javascript\">\n (function(window, document) {\n var data = ${data};\n var targetOrigin = data.redirect_uri;\n var webMessageRequest = {};\n \n var authorizationResponse = {\n type: \"authorization_response\",\n response: {\n \"code\":\"${code}\",\n \"state\":\"${state}\"}\n };\n \n var mainWin = (window.opener) ? window.opener : window.parent;\n \n if (webMessageRequest[\"web_message_uri\"] && webMessageRequest[\"web_message_target\"]) {\n window.addEventListener(\"message\", function(evt) {\n if (evt.origin != targetOrigin) {\n return;\n }\n \n switch (evt.data.type) {\n case \"relay_response\":\n var messageTargetWindow = evt.source.frames[webMessageRequest[\"web_message_target\"]];\n \n if (messageTargetWindow) {\n messageTargetWindow.postMessage(authorizationResponse, webMessageRequest[\"web_message_uri\"]);\n window.close();\n }\n break;\n }\n }\n );\n \n mainWin.postMessage({\n type: \"relay_request\"\n }, targetOrigin);\n } else {\n mainWin.postMessage(authorizationResponse, targetOrigin);\n }\n })(this, this.document);\n </script>\n </body>\n </html>\n `;\n};\n"],"mappings":";;;AAGA,MAAa,cAAc,EACzB,OACA,MACA,cACA,YAC4E;CAC5E,IAAI,OAAO,MACT,EACE,cACD,EACD;EAAE,MAAM;EAAM,iBAAiB;EAAM,CACtC;AAED,QAAgB;;;;;;;gBAOF,QAAQ,UAAU,MAAM,KAAK,GAAG;;uBAEzB,KAAK;;;;;;;wBAOJ,KAAK;yBACJ,MAAM"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@simulacrum/auth0-simulator",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "description": "Run local instance of Auth0 API for local development and integration testing",
5
5
  "main": "./dist/index.cjs",
6
6
  "bin": "bin/start.cjs",
7
7
  "scripts": {
8
- "start": "node --import=tsx ./example/index.ts",
9
- "start:bin": "node ./bin/start.js",
8
+ "start": "node --import=tsx ./example/index.mts",
9
+ "start:bin": "node ./bin/start.cjs",
10
10
  "test": "NODE_EXTRA_CA_CERTS=\"$(mkcert -CAROOT)/rootCA.pem\" vitest run --fileParallelism=false",
11
11
  "test:watch": "NODE_EXTRA_CA_CERTS=\"$(mkcert -CAROOT)/rootCA.pem\" vitest watch --fileParallelism=false",
12
12
  "prepack": "npm run build",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "homepage": "https://github.com/thefrontside/simulacrum#readme",
42
42
  "dependencies": {
43
- "@simulacrum/foundation-simulator": "0.5.1",
43
+ "@simulacrum/foundation-simulator": "0.6.1",
44
44
  "@faker-js/faker": "^9.3.0",
45
45
  "assert-ts": "^0.3.4",
46
46
  "base64-url": "^2.3.3",
@@ -57,13 +57,13 @@
57
57
  "@types/jsesc": "^3.0.3",
58
58
  "@types/jsonwebtoken": "^9.0.9"
59
59
  },
60
- "module": "./dist/index.js",
60
+ "module": "./dist/index.mjs",
61
61
  "types": "./dist/index.d.cts",
62
62
  "exports": {
63
63
  ".": {
64
64
  "development": "./src/index.ts",
65
- "import": "./dist/index.js",
66
- "require": "./dist/index.cjs"
65
+ "require": "./dist/index.cjs",
66
+ "import": "./dist/index.mjs"
67
67
  },
68
68
  "./package.json": "./package.json"
69
69
  },
@@ -78,8 +78,8 @@
78
78
  "publishConfig": {
79
79
  "exports": {
80
80
  ".": {
81
- "import": "./dist/index.js",
82
- "require": "./dist/index.cjs"
81
+ "require": "./dist/index.cjs",
82
+ "import": "./dist/index.mjs"
83
83
  },
84
84
  "./package.json": "./package.json"
85
85
  }