@crvouga/mockingbird-runtime 0.3.2 → 0.5.0

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.
@@ -18,11 +18,11 @@ import {
18
18
  import {
19
19
  Collection,
20
20
  bootSqlite
21
- } from "./chunk-KD6FHYQP.js";
21
+ } from "./chunk-BK5KDNUE.js";
22
22
  import {
23
23
  clearNamespace
24
24
  } from "./chunk-2KDYLZXC.js";
25
- import "./chunk-M4HUKBLC.js";
25
+ import "./chunk-GAIPLMRY.js";
26
26
  import {
27
27
  requestBaseUrl
28
28
  } from "./chunk-U36J5GCB.js";
@@ -902,388 +902,86 @@ function parseCookies(header) {
902
902
  }
903
903
 
904
904
  // ../http/provider/dist/vendor/core/ui.js
905
- function escapeHtml(s) {
906
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
907
- }
908
- function escapeAttr(s) {
909
- return escapeHtml(s).replace(/'/g, "&#39;");
910
- }
911
- var CSS = `
912
- .inspector-json{white-space:pre-wrap;overflow-wrap:anywhere;font-size:.8125rem;line-height:1.6;max-height:70vh;overflow:auto}
913
- .inspector-detail{padding:14px 0;border-bottom:1px solid #0a3300}
914
- .inspector-detail summary{cursor:pointer;overflow-wrap:anywhere}
915
- .inspector-action{display:inline-block;margin-top:12px;padding:8px 12px;border:1px solid #0a3300;border-radius:6px;background:#001a00;color:#33ff00;font:inherit;font-size:.8125rem;cursor:pointer}
916
- .inspector-action:hover{background:#0a3300}
917
- .inspector-scroll{overflow-x:auto}
918
- *{box-sizing:border-box;margin:0;padding:0}
919
- body{
920
- font-family:'Geist',-apple-system,BlinkMacSystemFont,sans-serif;
921
- background:#000;color:#33ff00;min-height:100vh;
922
- -webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;
923
- }
924
- .emu-bar{
925
- border-bottom:1px solid #0a3300;padding:10px 20px;
926
- display:flex;align-items:center;gap:10px;font-size:.8125rem;color:#1a8c00;
927
- }
928
- .emu-bar-title{font-weight:600;color:#33ff00;font-family:'Geist Pixel',monospace;}
929
- .emu-bar-links{margin-left:auto;display:flex;gap:16px;}
930
- .emu-bar-links a{
931
- color:#1a8c00;font-size:.75rem;text-decoration:none;transition:color .15s;
932
- }
933
- .emu-bar-links a:hover{color:#33ff00;}
934
- .emu-bar-links a .full{display:inline;}
935
- .emu-bar-links a .short{display:none;}
936
- @media(max-width:600px){
937
- .emu-bar-links a .full{display:none;}
938
- .emu-bar-links a .short{display:inline;}
905
+ async function renderProviderPage(page) {
906
+ const { renderProviderPage: render } = await import("./server-SXO3PUBW.js");
907
+ return render(page);
939
908
  }
940
-
941
- .content{
942
- display:flex;align-items:center;justify-content:center;
943
- min-height:calc(100vh - 42px);padding:24px 16px;
944
- }
945
- .content-inner{width:100%;max-width:420px;}
946
- .card-title{
947
- font-family:'Geist Pixel',monospace;
948
- font-size:1.125rem;font-weight:600;margin-bottom:4px;color:#33ff00;
949
- }
950
- .card-subtitle{color:#1a8c00;font-size:.8125rem;margin-bottom:18px;line-height:1.45;}
951
- .powered-by{
952
- position:fixed;bottom:0;left:0;right:0;
953
- text-align:center;padding:12px;font-size:.6875rem;color:#0a3300;
954
- font-family:'Geist Pixel',monospace;
955
- }
956
- .powered-by a{color:#1a8c00;text-decoration:none;transition:color .15s;}
957
- .powered-by a:hover{color:#33ff00;}
958
-
959
- .error-title{
960
- font-family:'Geist Pixel',monospace;
961
- color:#ff4444;font-size:1.125rem;font-weight:600;margin-bottom:8px;
962
- }
963
- .error-msg{color:#1a8c00;font-size:.875rem;line-height:1.5;}
964
- .error-card{text-align:center;}
965
-
966
- .user-form{margin-bottom:8px;}
967
- .user-form:last-of-type{margin-bottom:0;}
968
- .user-btn{
969
- width:100%;display:flex;align-items:center;gap:12px;
970
- padding:10px 12px;border:1px solid #0a3300;border-radius:8px;
971
- background:#000;color:inherit;cursor:pointer;text-align:left;
972
- font:inherit;transition:border-color .15s;
973
- }
974
- .user-btn:hover{border-color:#33ff00;}
975
- .avatar{
976
- width:36px;height:36px;border-radius:50%;
977
- background:#0a3300;color:#33ff00;font-weight:600;font-size:.875rem;
978
- display:flex;align-items:center;justify-content:center;flex-shrink:0;
979
- font-family:'Geist Pixel',monospace;
980
- }
981
- .user-text{min-width:0;}
982
- .user-login{font-weight:600;font-size:.875rem;display:block;color:#33ff00;}
983
- .user-meta{color:#1a8c00;font-size:.75rem;margin-top:1px;}
984
- .user-email{font-size:.6875rem;color:#116600;word-break:break-all;margin-top:1px;}
985
-
986
- .settings-layout{
987
- max-width:920px;margin:0 auto;padding:28px 20px;
988
- display:flex;gap:28px;
989
- }
990
- .settings-sidebar{width:200px;flex-shrink:0;}
991
- .settings-sidebar a{
992
- display:block;padding:6px 10px;border-radius:6px;color:#1a8c00;
993
- text-decoration:none;font-size:.8125rem;transition:color .15s;
994
- }
995
- .settings-sidebar a:hover{color:#33ff00;}
996
- .settings-sidebar a.active{color:#33ff00;font-weight:600;}
997
- .settings-main{flex:1;min-width:0;}
998
-
999
- .s-card{
1000
- padding:18px 0;margin-bottom:14px;border-bottom:1px solid #0a3300;
1001
- }
1002
- .s-card:last-child{border-bottom:none;}
1003
- .s-card-header{display:flex;align-items:center;gap:14px;margin-bottom:14px;}
1004
- .s-icon{
1005
- width:42px;height:42px;border-radius:8px;
1006
- background:#0a3300;display:flex;align-items:center;justify-content:center;
1007
- font-size:1.125rem;font-weight:700;color:#116600;flex-shrink:0;
1008
- font-family:'Geist Pixel',monospace;
1009
- }
1010
- .s-title{
1011
- font-family:'Geist Pixel',monospace;
1012
- font-size:1.25rem;font-weight:600;color:#33ff00;
1013
- }
1014
- .s-subtitle{font-size:.75rem;color:#1a8c00;margin-top:2px;}
1015
- .section-heading{
1016
- font-size:.9375rem;font-weight:600;margin-bottom:10px;color:#33ff00;
1017
- display:flex;align-items:center;justify-content:space-between;
1018
- }
1019
- .perm-list{list-style:none;}
1020
- .perm-list li{padding:5px 0;font-size:.8125rem;display:flex;align-items:center;gap:6px;color:#1a8c00;}
1021
- .check{color:#33ff00;}
1022
- .org-row{
1023
- display:flex;align-items:center;gap:8px;padding:7px 0;
1024
- border-bottom:1px solid #0a3300;font-size:.8125rem;
1025
- }
1026
- .org-row:last-child{border-bottom:none;}
1027
- .org-icon{
1028
- width:22px;height:22px;border-radius:4px;background:#0a3300;
1029
- display:flex;align-items:center;justify-content:center;
1030
- font-size:.625rem;font-weight:700;color:#116600;flex-shrink:0;
1031
- font-family:'Geist Pixel',monospace;
1032
- }
1033
- .org-name{font-weight:600;color:#33ff00;}
1034
- .badge{font-size:.6875rem;padding:1px 7px;border-radius:999px;font-weight:500;}
1035
- .badge-granted{background:#0a3300;color:#33ff00;}
1036
- .badge-denied{background:#1a0a0a;color:#ff4444;}
1037
- .badge-requested{background:#0a3300;color:#1a8c00;}
1038
- .btn-revoke{
1039
- display:inline-block;padding:5px 14px;border-radius:6px;
1040
- border:1px solid #0a3300;background:transparent;color:#ff4444;
1041
- font-size:.75rem;font-weight:600;cursor:pointer;transition:border-color .15s;
1042
- }
1043
- .btn-revoke:hover{border-color:#ff4444;}
1044
- .info-text{color:#1a8c00;font-size:.75rem;line-height:1.5;margin-top:10px;}
1045
- .app-link{
1046
- display:flex;align-items:center;gap:12px;padding:12px;
1047
- border:1px solid #0a3300;border-radius:8px;background:#000;
1048
- text-decoration:none;color:inherit;margin-bottom:8px;transition:border-color .15s;
1049
- }
1050
- .app-link:hover{border-color:#33ff00;}
1051
- .app-link-name{font-weight:600;font-size:.875rem;color:#33ff00;}
1052
- .app-link-scopes{font-size:.6875rem;color:#1a8c00;margin-top:1px;}
1053
- .empty{color:#1a8c00;text-align:center;padding:28px 0;font-size:.875rem;}
1054
-
1055
- .inspector-layout{max-width:960px;margin:0 auto;padding:28px 20px;}
1056
- .inspector-tabs{display:flex;gap:4px;margin-bottom:20px;}
1057
- .inspector-tabs a{
1058
- padding:7px 16px;border-radius:6px;text-decoration:none;
1059
- font-size:.8125rem;color:#1a8c00;border:1px solid transparent;
1060
- transition:color .15s,border-color .15s;
1061
- }
1062
- .inspector-tabs a:hover{color:#33ff00;}
1063
- .inspector-tabs a.active{color:#33ff00;font-weight:600;border-color:#0a3300;background:#0a3300;}
1064
- .inspector-section{margin-bottom:24px;}
1065
- .inspector-section h2{
1066
- font-family:'Geist Pixel',monospace;
1067
- font-size:1rem;font-weight:600;color:#33ff00;margin-bottom:10px;
1068
- }
1069
- .inspector-section h3{
1070
- font-family:'Geist Pixel',monospace;
1071
- font-size:.875rem;font-weight:600;color:#1a8c00;margin:16px 0 8px;
1072
- }
1073
- .inspector-table{width:100%;border-collapse:collapse;margin-bottom:12px;}
1074
- .inspector-table th,.inspector-table td{
1075
- text-align:left;padding:8px 12px;border-bottom:1px solid #0a3300;
1076
- font-size:.8125rem;
1077
- }
1078
- .inspector-table th{color:#1a8c00;font-weight:600;font-size:.75rem;text-transform:uppercase;letter-spacing:.04em;}
1079
- .inspector-table td{color:#33ff00;}
1080
- .inspector-table tbody tr{transition:background .1s;}
1081
- .inspector-table tbody tr:hover{background:#0a3300;}
1082
- .inspector-empty{color:#1a8c00;text-align:center;padding:20px 0;font-size:.8125rem;}
1083
-
1084
- .checkout-layout{
1085
- display:flex;min-height:calc(100vh - 42px);
1086
- }
1087
- .checkout-summary{
1088
- flex:1;background:#020;padding:48px 40px 48px 10%;
1089
- display:flex;flex-direction:column;justify-content:center;
1090
- border-right:1px solid #0a3300;
1091
- }
1092
- .checkout-form-side{
1093
- flex:1;background:#000;padding:48px 10% 48px 40px;
1094
- display:flex;flex-direction:column;justify-content:center;
1095
- }
1096
- .checkout-merchant{
1097
- display:flex;align-items:center;gap:10px;margin-bottom:6px;
1098
- }
1099
- .checkout-merchant-name{
1100
- font-family:'Geist Pixel',monospace;
1101
- font-size:.9375rem;font-weight:600;color:#33ff00;
1102
- }
1103
- .checkout-test-badge{
1104
- font-size:.625rem;font-weight:700;letter-spacing:.04em;text-transform:uppercase;
1105
- background:#0a3300;color:#1a8c00;padding:2px 8px;border-radius:4px;
1106
- }
1107
- .checkout-total{
1108
- font-family:'Geist Pixel',monospace;
1109
- font-size:2rem;font-weight:700;color:#33ff00;margin:8px 0 28px;
1110
- }
1111
- .checkout-line-item{
1112
- display:flex;align-items:center;gap:14px;padding:14px 0;
1113
- border-bottom:1px solid #0a3300;
1114
- }
1115
- .checkout-line-item:first-child{border-top:1px solid #0a3300;}
1116
- .checkout-item-icon{
1117
- width:42px;height:42px;border-radius:6px;background:#0a3300;
1118
- display:flex;align-items:center;justify-content:center;flex-shrink:0;
1119
- font-family:'Geist Pixel',monospace;font-size:.875rem;font-weight:700;color:#116600;
1120
- }
1121
- .checkout-item-details{flex:1;min-width:0;}
1122
- .checkout-item-name{font-size:.875rem;font-weight:600;color:#33ff00;}
1123
- .checkout-item-qty{font-size:.75rem;color:#1a8c00;margin-top:2px;}
1124
- .checkout-item-price{
1125
- font-size:.875rem;font-weight:600;color:#33ff00;text-align:right;white-space:nowrap;
1126
- }
1127
- .checkout-item-unit{font-size:.6875rem;color:#1a8c00;text-align:right;margin-top:2px;}
1128
- .checkout-totals{margin-top:20px;}
1129
- .checkout-totals-row{
1130
- display:flex;justify-content:space-between;padding:6px 0;
1131
- font-size:.8125rem;color:#1a8c00;
1132
- }
1133
- .checkout-totals-row.total{
1134
- border-top:1px solid #0a3300;margin-top:8px;padding-top:14px;
1135
- font-size:.9375rem;font-weight:600;color:#33ff00;
1136
- }
1137
- .checkout-form-section{margin-bottom:24px;}
1138
- .checkout-form-label{
1139
- font-size:.8125rem;font-weight:600;color:#33ff00;margin-bottom:8px;display:block;
1140
- }
1141
- .checkout-input{
1142
- width:100%;padding:10px 12px;border:1px solid #0a3300;border-radius:6px;
1143
- background:#020;color:#33ff00;font:inherit;font-size:.875rem;
1144
- transition:border-color .15s;outline:none;
1145
- }
1146
- .checkout-input:focus{border-color:#33ff00;}
1147
- .checkout-input::placeholder{color:#116600;}
1148
- .checkout-card-box{
1149
- border:1px solid #0a3300;border-radius:6px;padding:14px;
1150
- background:#020;
1151
- }
1152
- .checkout-card-row{
1153
- display:flex;gap:12px;margin-top:10px;
1154
- }
1155
- .checkout-card-row .checkout-input{flex:1;}
1156
- .checkout-sim-note{
1157
- font-size:.6875rem;color:#1a8c00;margin-top:10px;text-align:center;
1158
- font-style:italic;
1159
- }
1160
- .checkout-pay-btn{
1161
- width:100%;padding:14px;border:none;border-radius:8px;
1162
- background:#33ff00;color:#000;font:inherit;font-size:.9375rem;font-weight:700;
1163
- cursor:pointer;transition:background .15s;
1164
- font-family:'Geist Pixel',monospace;
1165
- }
1166
- .checkout-pay-btn:hover{background:#44ff22;}
1167
- .checkout-cancel{
1168
- text-align:center;margin-top:14px;
1169
- }
1170
- .checkout-cancel a{
1171
- color:#1a8c00;text-decoration:none;font-size:.8125rem;
1172
- transition:color .15s;
1173
- }
1174
- .checkout-cancel a:hover{color:#33ff00;}
1175
- @media(max-width:768px){
1176
- .checkout-layout{flex-direction:column;}
1177
- .checkout-summary{padding:32px 20px;border-right:none;border-bottom:1px solid #0a3300;}
1178
- .checkout-form-side{padding:32px 20px;}
909
+ function renderCardPage(title, description, blocks, service) {
910
+ return renderProviderPage({
911
+ layout: "card",
912
+ title,
913
+ blocks,
914
+ ...description === void 0 ? {} : { description },
915
+ ...service ? { service } : {}
916
+ });
1179
917
  }
1180
- `;
1181
- var POWERED_BY = `<div class="powered-by">Powered by <a href="https://github.com/crvouga-organization/mockingbird" target="_blank" rel="noopener">Mockingbird</a></div>`;
1182
- function emuBar(service) {
1183
- const title = service ? `${escapeHtml(service)} Emulator` : "Emulator";
1184
- return `<div class="emu-bar">
1185
- <span class="emu-bar-title">${title}</span>
1186
- <nav class="emu-bar-links">
1187
- <a href="https://github.com/crvouga-organization/mockingbird/issues" target="_blank" rel="noopener"><span class="full">Report Issue</span><span class="short">Report</span></a>
1188
- <a href="https://github.com/crvouga-organization/mockingbird" target="_blank" rel="noopener"><span class="full">Source Code</span><span class="short">Source</span></a>
1189
- <a href="https://github.com/crvouga-organization/mockingbird" target="_blank" rel="noopener"><span class="full">Learn More</span><span class="short">Learn</span></a>
1190
- </nav>
1191
- </div>`;
1192
- }
1193
- function head(title) {
1194
- return `<!DOCTYPE html>
1195
- <html lang="en">
1196
- <head>
1197
- <meta charset="utf-8"/>
1198
- <meta name="viewport" content="width=device-width,initial-scale=1"/>
1199
-
1200
- <title>${escapeHtml(title)} | Mockingbird</title>
1201
- <style>${CSS}</style>
1202
- </head>`;
1203
- }
1204
- function renderCardPage(title, subtitle, body, service) {
1205
- return `${head(title)}
1206
- <body>
1207
- ${emuBar(service)}
1208
- <div class="content">
1209
- <div class="content-inner">
1210
- <div class="card-title">${escapeHtml(title)}</div>
1211
- <div class="card-subtitle">${subtitle}</div>
1212
- ${body}
1213
- </div>
1214
- </div>
1215
- ${POWERED_BY}
1216
- </body></html>`;
918
+ function renderSignInPage(title, description, accounts, service, empty = "No users in the emulator store.") {
919
+ return renderCardPage(title, description, [{ type: "accounts", accounts, empty }], service);
1217
920
  }
1218
921
  function renderErrorPage(title, message, service) {
1219
- return `${head(title)}
1220
- <body>
1221
- ${emuBar(service)}
1222
- <div class="content">
1223
- <div class="content-inner error-card">
1224
- <div class="error-title">${escapeHtml(title)}</div>
1225
- <div class="error-msg">${escapeHtml(message)}</div>
1226
- </div>
1227
- </div>
1228
- ${POWERED_BY}
1229
- </body></html>`;
1230
- }
1231
- function renderSettingsPage(title, sidebarHtml, bodyHtml, service) {
1232
- return `${head(title)}
1233
- <body>
1234
- ${emuBar(service)}
1235
- <div class="settings-layout">
1236
- <nav class="settings-sidebar">${sidebarHtml}</nav>
1237
- <div class="settings-main">${bodyHtml}</div>
1238
- </div>
1239
- ${POWERED_BY}
1240
- </body></html>`;
1241
- }
1242
- function renderInspectorPage(title, tabs, activeTab, body, service) {
1243
- const tabLinks = tabs.map((t) => `<a href="${escapeAttr(t.href)}" class="${t.id === activeTab ? "active" : ""}">${escapeHtml(t.label)}</a>`).join("");
1244
- return `${head(title)}
1245
- <body>
1246
- ${emuBar(service)}
1247
- <div class="inspector-layout">
1248
- <nav class="inspector-tabs">${tabLinks}</nav>
1249
- ${body}
1250
- </div>
1251
- ${POWERED_BY}
1252
- </body></html>`;
922
+ return renderProviderPage({ layout: "card", title, error: message, blocks: [], ...service ? { service } : {} });
923
+ }
924
+ function renderInspectorPage(title, tabs, activeTab, blocks, service) {
925
+ const nav = tabs.map((tab) => ({
926
+ label: tab.label,
927
+ href: tab.href,
928
+ ...tab.id === activeTab ? { current: true } : {}
929
+ }));
930
+ const active = tabs.find((tab) => tab.id === activeTab);
931
+ return renderProviderPage({
932
+ layout: "app",
933
+ title: active ? `${active.label} \xB7 ${title}` : title,
934
+ heading: active?.label ?? title,
935
+ description: title,
936
+ nav,
937
+ blocks,
938
+ ...service ? { service } : {}
939
+ });
1253
940
  }
1254
941
  function renderFormPostPage(action, fields, service) {
1255
- const hiddens = Object.entries(fields).filter(([, v]) => v != null).map(([k, v]) => `<input type="hidden" name="${escapeAttr(k)}" value="${escapeAttr(v)}"/>`).join("\n");
1256
- return `${head("Redirecting")}
1257
- <body onload="document.forms[0].submit()">
1258
- ${emuBar(service)}
1259
- <div class="content">
1260
- <div class="content-inner" style="text-align:center">
1261
- <div class="card-subtitle">Redirecting&hellip;</div>
1262
- <form method="POST" action="${escapeAttr(action)}">
1263
- ${hiddens}
1264
- <noscript><button type="submit" class="user-btn" style="margin-top:12px;justify-content:center">
1265
- <span class="user-login">Continue</span>
1266
- </button></noscript>
1267
- </form>
1268
- </div>
1269
- </div>
1270
- ${POWERED_BY}
1271
- </body></html>`;
1272
- }
1273
- function renderUserButton(opts) {
1274
- const hiddens = Object.entries(opts.hiddenFields).map(([k, v]) => `<input type="hidden" name="${escapeAttr(k)}" value="${escapeAttr(v)}"/>`).join("");
1275
- const nameLine = opts.name ? `<div class="user-meta">${escapeHtml(opts.name)}</div>` : "";
1276
- const emailLine = opts.email ? `<div class="user-email">${escapeHtml(opts.email)}</div>` : "";
1277
- return `<form class="user-form" method="post" action="${escapeAttr(opts.formAction)}">
1278
- ${hiddens}
1279
- <button type="submit" class="user-btn">
1280
- <span class="avatar">${escapeHtml(opts.letter)}</span>
1281
- <span class="user-text">
1282
- <span class="user-login">${escapeHtml(opts.login)}</span>
1283
- ${nameLine}${emailLine}
1284
- </span>
1285
- </button>
1286
- </form>`;
942
+ return renderProviderPage(formPostPage(action, fields, service));
943
+ }
944
+ function formPostPage(action, fields, service) {
945
+ return {
946
+ layout: "card",
947
+ title: "Redirecting\u2026",
948
+ description: "Returning you to the app.",
949
+ autoSubmit: true,
950
+ blocks: [
951
+ {
952
+ type: "form",
953
+ action,
954
+ label: "Continue",
955
+ fields: Object.fromEntries(Object.entries(fields).filter(([, value]) => value != null))
956
+ }
957
+ ],
958
+ ...service ? { service } : {}
959
+ };
960
+ }
961
+ function table(columns, rows, empty, label = "") {
962
+ return { type: "table", label, columns, rows, empty };
963
+ }
964
+ function section(title, ...blocks) {
965
+ return {
966
+ type: "section",
967
+ title,
968
+ blocks: blocks.map((block) => block.type === "table" && !block.label ? { ...block, label: title } : block)
969
+ };
970
+ }
971
+ var OK = /^(ok|active|enabled|open|delivered|sent|received|read|approved|completed?|success(ful)?|available|granted|verified|2\d\d)$/i;
972
+ var ERROR = /^(failed|error|revoked|inactive|disabled|closed|canceled|cancelled|bounced|denied|undelivered|archived|deleted|expired|used|busy|no-answer|[45]\d\d)$/i;
973
+ var WARNING = /^(pending|queued|sending|accepted|scheduled|in-progress|ringing|initiated|requested|processing|delayed)$/i;
974
+ function chip(label, status = statusOf(label)) {
975
+ return { chip: label, status };
976
+ }
977
+ function statusOf(label) {
978
+ if (OK.test(label))
979
+ return "ok";
980
+ if (ERROR.test(label))
981
+ return "error";
982
+ if (WARNING.test(label))
983
+ return "warning";
984
+ return "neutral";
1287
985
  }
1288
986
 
1289
987
  // ../http/provider/dist/vendor/github/index.js
@@ -2976,15 +2674,15 @@ function diffText(oldText, newText) {
2976
2674
  }
2977
2675
  function diffTrees(gh, repoId, baseTreeSha, headTreeSha) {
2978
2676
  const base = baseTreeSha ? flattenTree(gh, repoId, baseTreeSha) : { blobs: /* @__PURE__ */ new Map(), dirs: /* @__PURE__ */ new Map() };
2979
- const head2 = flattenTree(gh, repoId, headTreeSha);
2980
- const paths = [.../* @__PURE__ */ new Set([...base.blobs.keys(), ...head2.blobs.keys()])].sort();
2677
+ const head = flattenTree(gh, repoId, headTreeSha);
2678
+ const paths = [.../* @__PURE__ */ new Set([...base.blobs.keys(), ...head.blobs.keys()])].sort();
2981
2679
  const out = [];
2982
2680
  const pairedPaths = /* @__PURE__ */ new Set();
2983
2681
  const addedBySha = /* @__PURE__ */ new Map();
2984
2682
  for (const path of paths) {
2985
2683
  if (base.blobs.has(path))
2986
2684
  continue;
2987
- const entry = head2.blobs.get(path);
2685
+ const entry = head.blobs.get(path);
2988
2686
  if (!entry)
2989
2687
  continue;
2990
2688
  const candidates = addedBySha.get(entry.sha) ?? [];
@@ -2993,10 +2691,10 @@ function diffTrees(gh, repoId, baseTreeSha, headTreeSha) {
2993
2691
  }
2994
2692
  for (const previousPath of paths) {
2995
2693
  const before = base.blobs.get(previousPath);
2996
- if (!before || head2.blobs.has(previousPath))
2694
+ if (!before || head.blobs.has(previousPath))
2997
2695
  continue;
2998
2696
  const candidates = addedBySha.get(before.sha)?.filter((path) => !pairedPaths.has(path)) ?? [];
2999
- const filename = candidates.find((path) => head2.blobs.get(path)?.mode === before.mode) ?? candidates[0];
2697
+ const filename = candidates.find((path) => head.blobs.get(path)?.mode === before.mode) ?? candidates[0];
3000
2698
  if (!filename)
3001
2699
  continue;
3002
2700
  pairedPaths.add(previousPath);
@@ -3015,7 +2713,7 @@ function diffTrees(gh, repoId, baseTreeSha, headTreeSha) {
3015
2713
  if (pairedPaths.has(path))
3016
2714
  continue;
3017
2715
  const before = base.blobs.get(path);
3018
- const after = head2.blobs.get(path);
2716
+ const after = head.blobs.get(path);
3019
2717
  if (before && after && before.sha === after.sha && before.mode === after.mode)
3020
2718
  continue;
3021
2719
  const status = !before ? "added" : !after ? "removed" : "modified";
@@ -4561,8 +4259,8 @@ function updateBranchSha(gh, repo, branchName, newSha) {
4561
4259
  if (ref)
4562
4260
  gh.refs.update(ref.id, { sha: newSha });
4563
4261
  }
4564
- function resolveHeadTarget(gh, baseRepo, head2) {
4565
- const trimmed = head2.trim();
4262
+ function resolveHeadTarget(gh, baseRepo, head) {
4263
+ const trimmed = head.trim();
4566
4264
  if (!trimmed.includes(":")) {
4567
4265
  return { headRepo: baseRepo, headRef: trimmed };
4568
4266
  }
@@ -8605,10 +8303,10 @@ function commitsRoutes({ app, store, baseUrl }) {
8605
8303
  throw new ApiError(409, "Git Repository is empty.");
8606
8304
  }
8607
8305
  const shaParam = c.req.query("sha");
8608
- const head2 = resolveRefToCommit(gh, repo, shaParam);
8609
- if (!head2)
8306
+ const head = resolveRefToCommit(gh, repo, shaParam);
8307
+ if (!head)
8610
8308
  throw notFound();
8611
- let history = listAncestors(gh, repo.id, head2.sha);
8309
+ let history = listAncestors(gh, repo.id, head.sha);
8612
8310
  const path = c.req.query("path");
8613
8311
  if (path) {
8614
8312
  history = history.filter((commit) => commitTouchesPath(gh, repo.id, commit, path));
@@ -8652,19 +8350,19 @@ function commitsRoutes({ app, store, baseUrl }) {
8652
8350
  if (sep === -1)
8653
8351
  throw notFound();
8654
8352
  const base = resolveRefToCommit(gh, repo, basehead.slice(0, sep));
8655
- const head2 = resolveRefToCommit(gh, repo, basehead.slice(sep + 3));
8656
- if (!base || !head2)
8353
+ const head = resolveRefToCommit(gh, repo, basehead.slice(sep + 3));
8354
+ if (!base || !head)
8657
8355
  throw notFound();
8658
8356
  const baseAncestors = new Set(listAncestors(gh, repo.id, base.sha).map((x) => x.sha));
8659
- const headAncestry = listAncestors(gh, repo.id, head2.sha);
8357
+ const headAncestry = listAncestors(gh, repo.id, head.sha);
8660
8358
  const headAncestors = new Set(headAncestry.map((x) => x.sha));
8661
- const mergeBase = findMergeBase(gh, repo.id, base.sha, head2.sha);
8359
+ const mergeBase = findMergeBase(gh, repo.id, base.sha, head.sha);
8662
8360
  if (!mergeBase)
8663
8361
  throw notFound();
8664
8362
  const aheadCommits = headAncestry.filter((x) => !baseAncestors.has(x.sha)).reverse();
8665
8363
  const behindBy = listAncestors(gh, repo.id, base.sha).filter((x) => !headAncestors.has(x.sha)).length;
8666
- const status = base.sha === head2.sha || aheadCommits.length === 0 && behindBy === 0 ? "identical" : aheadCommits.length > 0 && behindBy === 0 ? "ahead" : aheadCommits.length === 0 ? "behind" : "diverged";
8667
- const allFiles = diffTrees(gh, repo.id, mergeBase.tree_sha, head2.tree_sha);
8364
+ const status = base.sha === head.sha || aheadCommits.length === 0 && behindBy === 0 ? "identical" : aheadCommits.length > 0 && behindBy === 0 ? "ahead" : aheadCommits.length === 0 ? "behind" : "diverged";
8365
+ const allFiles = diffTrees(gh, repo.id, mergeBase.tree_sha, head.tree_sha);
8668
8366
  const hasPagination = c.req.query("page") !== void 0 || c.req.query("per_page") !== void 0;
8669
8367
  let commits = aheadCommits;
8670
8368
  let files = allFiles.slice(0, 300);
@@ -8681,7 +8379,7 @@ function commitsRoutes({ app, store, baseUrl }) {
8681
8379
  return c.json({
8682
8380
  url: `${repoUrl}/compare/${basehead}`,
8683
8381
  html_url: `${baseUrl}/${repo.full_name}/compare/${basehead}`,
8684
- permalink_url: `${baseUrl}/${repo.full_name}/compare/${base.sha.slice(0, 12)}...${head2.sha.slice(0, 12)}`,
8382
+ permalink_url: `${baseUrl}/${repo.full_name}/compare/${base.sha.slice(0, 12)}...${head.sha.slice(0, 12)}`,
8685
8383
  diff_url: `${baseUrl}/${repo.full_name}/compare/${basehead}.diff`,
8686
8384
  patch_url: `${baseUrl}/${repo.full_name}/compare/${basehead}.patch`,
8687
8385
  base_commit: formatCommitItem(gh, repo, base, baseUrl),
@@ -8691,7 +8389,7 @@ function commitsRoutes({ app, store, baseUrl }) {
8691
8389
  behind_by: behindBy,
8692
8390
  total_commits: aheadCommits.length,
8693
8391
  commits: commits.map((commit) => formatCommitItem(gh, repo, commit, baseUrl)),
8694
- files: files.map((f) => formatFileDiff(f, repo, mergeBase.sha, head2.sha, baseUrl))
8392
+ files: files.map((f) => formatFileDiff(f, repo, mergeBase.sha, head.sha, baseUrl))
8695
8393
  });
8696
8394
  });
8697
8395
  app.get("/repos/:owner/:repo/commits/:ref{.+}", (c) => {
@@ -11014,10 +10712,10 @@ function searchRoutes({ app, store, baseUrl }) {
11014
10712
  if (!lang || !langs.some((l) => l.toLowerCase() === lang.toLowerCase()))
11015
10713
  continue;
11016
10714
  }
11017
- const head2 = resolveBranchToCommit(gh, repo, repo.default_branch);
11018
- if (!head2)
10715
+ const head = resolveBranchToCommit(gh, repo, repo.default_branch);
10716
+ if (!head)
11019
10717
  continue;
11020
- for (const [path, entry] of flattenTree(gh, repo.id, head2.tree_sha).blobs) {
10718
+ for (const [path, entry] of flattenTree(gh, repo.id, head.tree_sha).blobs) {
11021
10719
  const blob = gh.blobs.findBy("repo_id", repo.id).find((candidate) => candidate.sha === entry.sha);
11022
10720
  if (!blob)
11023
10721
  continue;
@@ -12820,7 +12518,7 @@ function oauthRoutes({ app, store, baseUrl, tokenMap }) {
12820
12518
  }
12821
12519
  return null;
12822
12520
  }
12823
- app.get("/login/oauth/authorize", (c) => {
12521
+ app.get("/login/oauth/authorize", async (c) => {
12824
12522
  const client_id = c.req.query("client_id") ?? "";
12825
12523
  const redirect_uri = c.req.query("redirect_uri") ?? "";
12826
12524
  const scope = c.req.query("scope") ?? "";
@@ -12830,20 +12528,20 @@ function oauthRoutes({ app, store, baseUrl, tokenMap }) {
12830
12528
  if (oauthAppsConfigured) {
12831
12529
  const oauthApp = gh.oauthApps.findOneBy("client_id", client_id);
12832
12530
  if (!oauthApp) {
12833
- return c.html(renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL), 400);
12531
+ return c.html(await renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL), 400);
12834
12532
  }
12835
12533
  if (redirect_uri && !matchesRedirectUri(redirect_uri, oauthApp.redirect_uris)) {
12836
12534
  console.warn(`[OAuth] redirect_uri mismatch: got "${redirect_uri}", registered: ${JSON.stringify(oauthApp.redirect_uris)}`);
12837
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL), 400);
12535
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL), 400);
12838
12536
  }
12839
12537
  oauthAppForSubtitle = oauthApp;
12840
12538
  }
12841
12539
  const users = [...gh.users.all()].sort((a, b) => a.login.localeCompare(b.login));
12842
- const subtitleText = oauthAppForSubtitle ? `Authorize <strong>${escapeHtml(oauthAppForSubtitle.name)}</strong> to access your account.` : "Choose a seeded user to authorize this application.";
12540
+ const subtitleText = oauthAppForSubtitle ? ["Authorize ", { strong: oauthAppForSubtitle.name }, " to access your account."] : "Choose a seeded user to authorize this application.";
12843
12541
  const userButtons = users.map((u) => {
12844
12542
  const brief = formatUser(u, baseUrl);
12845
12543
  const full = formatUserFull(u, baseUrl);
12846
- return renderUserButton({
12544
+ return {
12847
12545
  letter: (brief.login[0] ?? "?").toUpperCase(),
12848
12546
  login: full.login,
12849
12547
  name: full.name ?? void 0,
@@ -12856,10 +12554,9 @@ function oauthRoutes({ app, store, baseUrl, tokenMap }) {
12856
12554
  state,
12857
12555
  client_id
12858
12556
  }
12859
- });
12860
- }).join("\n");
12861
- const body = users.length === 0 ? '<p class="empty">No users in the emulator store.</p>' : userButtons;
12862
- return c.html(renderCardPage("Sign in to GitHub", subtitleText, body, SERVICE_LABEL));
12557
+ };
12558
+ });
12559
+ return c.html(await renderSignInPage("Sign in to GitHub", subtitleText, userButtons, SERVICE_LABEL));
12863
12560
  });
12864
12561
  app.post("/login/oauth/callback", async (c) => {
12865
12562
  const body = await c.req.parseBody();
@@ -13028,104 +12725,101 @@ function oauthRoutes({ app, store, baseUrl, tokenMap }) {
13028
12725
  function scopeLabel(scope) {
13029
12726
  return SCOPE_LABELS[scope] ?? scope;
13030
12727
  }
13031
- const sidebarHtml = `
13032
- <a href="/settings/applications" class="active">Authorized Apps</a>`;
13033
- app.get("/settings/applications", (c) => {
12728
+ const SETTINGS_NAV = [{ label: "Authorized apps", href: "/settings/applications", current: true }];
12729
+ app.get("/settings/applications", async (c) => {
13034
12730
  const sessionUser = resolveSessionUser(c);
13035
12731
  if (!sessionUser) {
13036
- return c.html(renderErrorPage("Unauthorized", "You must be authenticated to view this page.", SERVICE_LABEL), 401);
12732
+ return c.html(await renderErrorPage("Unauthorized", "You must be authenticated to view this page.", SERVICE_LABEL), 401);
13037
12733
  }
13038
12734
  const grants = gh.oauthGrants.findBy("user_id", sessionUser.id);
13039
- let bodyHtml;
13040
- if (grants.length === 0) {
13041
- bodyHtml = `
13042
- <div class="section-heading">Authorized OAuth Apps</div>
13043
- <div class="s-card">
13044
- <p class="empty">No authorized applications. Apps you authorize will appear here.</p>
13045
- </div>`;
13046
- } else {
13047
- const appLinks = grants.map((grant) => {
13048
- const oauthApp = gh.oauthApps.findOneBy("client_id", grant.client_id);
13049
- const name = oauthApp?.name ?? grant.client_id;
13050
- const letter = escapeHtml((name[0] ?? "?").toUpperCase());
13051
- const scopeText = grant.scopes.length > 0 ? grant.scopes.join(", ") : "No scopes";
13052
- return `<a href="/settings/connections/applications/${escapeAttr(grant.client_id)}" class="app-link">
13053
- <div class="s-icon">${letter}</div>
13054
- <div>
13055
- <div class="app-link-name">${escapeHtml(name)}</div>
13056
- <div class="app-link-scopes">${escapeHtml(scopeText)}</div>
13057
- </div>
13058
- </a>`;
13059
- }).join("\n");
13060
- bodyHtml = `
13061
- <div class="section-heading">Authorized OAuth Apps</div>
13062
- <div class="s-card">${appLinks}</div>`;
13063
- }
13064
- return c.html(renderSettingsPage("Authorized OAuth Apps", sidebarHtml, bodyHtml, SERVICE_LABEL));
13065
- });
13066
- app.get("/settings/connections/applications/:client_id", (c) => {
12735
+ const items = grants.map((grant) => {
12736
+ const oauthApp = gh.oauthApps.findOneBy("client_id", grant.client_id);
12737
+ const name = oauthApp?.name ?? grant.client_id;
12738
+ return {
12739
+ href: `/settings/connections/applications/${grant.client_id}`,
12740
+ title: name,
12741
+ description: grant.scopes.length > 0 ? grant.scopes.join(", ") : "No scopes",
12742
+ letter: (name[0] ?? "?").toUpperCase()
12743
+ };
12744
+ });
12745
+ return c.html(await renderProviderPage({
12746
+ layout: "app",
12747
+ service: SERVICE_LABEL,
12748
+ title: "Authorized OAuth Apps",
12749
+ description: "Applications you have granted access to your account.",
12750
+ nav: SETTINGS_NAV,
12751
+ blocks: [
12752
+ {
12753
+ type: "links",
12754
+ items,
12755
+ empty: "No authorized applications. Apps you authorize will appear here."
12756
+ }
12757
+ ]
12758
+ }));
12759
+ });
12760
+ app.get("/settings/connections/applications/:client_id", async (c) => {
13067
12761
  const sessionUser = resolveSessionUser(c);
13068
12762
  if (!sessionUser) {
13069
- return c.html(renderErrorPage("Unauthorized", "You must be authenticated to view this page.", SERVICE_LABEL), 401);
12763
+ return c.html(await renderErrorPage("Unauthorized", "You must be authenticated to view this page.", SERVICE_LABEL), 401);
13070
12764
  }
13071
12765
  const clientId = c.req.param("client_id");
13072
12766
  const grant = gh.oauthGrants.all().find((g) => g.user_id === sessionUser.id && g.client_id === clientId);
13073
12767
  if (!grant) {
13074
- return c.html(renderErrorPage("Not Found", "No authorization found for this application.", SERVICE_LABEL), 404);
12768
+ return c.html(await renderErrorPage("Not Found", "No authorization found for this application.", SERVICE_LABEL), 404);
13075
12769
  }
13076
12770
  const oauthApp = gh.oauthApps.findOneBy("client_id", clientId);
13077
12771
  const appName = oauthApp?.name ?? clientId;
13078
- const appLetter = escapeHtml((appName[0] ?? "?").toUpperCase());
13079
12772
  const lastUsed = new Date(grant.updated_at).toLocaleDateString("en-US", {
13080
12773
  year: "numeric",
13081
12774
  month: "long",
13082
12775
  day: "numeric"
13083
12776
  });
13084
- const permRows = grant.scopes.map((s) => `<li><span class="check">&#10003;</span> ${escapeHtml(scopeLabel(s))}</li>`).join("\n");
13085
- const orgRows = Object.entries(grant.org_access).map(([org, status]) => {
13086
- const letter = escapeHtml((org[0] ?? "?").toUpperCase());
13087
- const badgeClass = status === "granted" ? "badge-granted" : status === "denied" ? "badge-denied" : "badge-requested";
13088
- const icon = status === "granted" ? "&#10003;" : status === "denied" ? "&#10007;" : "&#8943;";
13089
- return `<div class="org-row">
13090
- <div class="org-icon">${letter}</div>
13091
- <span class="org-name">${escapeHtml(org)}</span>
13092
- <span class="badge ${badgeClass}">${icon}</span>
13093
- </div>`;
13094
- }).join("\n");
13095
- const bodyHtml = `
13096
- <div class="s-card">
13097
- <div class="s-card-header">
13098
- <div class="s-icon">${appLetter}</div>
13099
- <div>
13100
- <div class="s-title">${escapeHtml(appName)}</div>
13101
- <div class="s-subtitle">Last used: ${escapeHtml(lastUsed)}</div>
13102
- </div>
13103
- </div>
13104
- </div>
13105
-
13106
- <div class="s-card">
13107
- <div class="section-heading">
13108
- <span>Permissions</span>
13109
- <form method="post" action="/settings/connections/applications/${escapeAttr(clientId)}/revoke" style="display:inline">
13110
- <button type="submit" class="btn-revoke">Revoke access</button>
13111
- </form>
13112
- </div>
13113
- <ul class="perm-list">
13114
- ${permRows || '<li style="color:#1a8c00">No specific permissions granted.</li>'}
13115
- </ul>
13116
- </div>
13117
-
13118
- ${orgRows ? `<div class="s-card">
13119
- <div class="section-heading">Organization access</div>
13120
- ${orgRows}
13121
- <p class="info-text">Applications act on your behalf. Organizations control which apps may access their private data.</p>
13122
- </div>` : ""}`;
13123
- return c.html(renderSettingsPage(appName, sidebarHtml, bodyHtml, SERVICE_LABEL));
13124
- });
13125
- app.post("/settings/connections/applications/:client_id/revoke", (c) => {
12777
+ const orgs = Object.entries(grant.org_access);
12778
+ const blocks = [
12779
+ {
12780
+ type: "section",
12781
+ title: "Permissions",
12782
+ action: {
12783
+ type: "form",
12784
+ action: `/settings/connections/applications/${clientId}/revoke`,
12785
+ label: "Revoke access",
12786
+ variant: "danger"
12787
+ },
12788
+ blocks: [
12789
+ {
12790
+ type: "checklist",
12791
+ items: grant.scopes.map(scopeLabel),
12792
+ empty: "No specific permissions granted."
12793
+ }
12794
+ ]
12795
+ }
12796
+ ];
12797
+ if (orgs.length > 0) {
12798
+ blocks.push({
12799
+ type: "section",
12800
+ title: "Organization access",
12801
+ description: "Applications act on your behalf. Organizations control which apps may access their private data.",
12802
+ blocks: [
12803
+ table(["Organization", "Access"], orgs.map(([org, status]) => [
12804
+ org,
12805
+ { chip: status, status: status === "granted" ? "ok" : status === "denied" ? "error" : "neutral" }
12806
+ ]), "No organizations.", "Organization access")
12807
+ ]
12808
+ });
12809
+ }
12810
+ return c.html(await renderProviderPage({
12811
+ layout: "app",
12812
+ service: SERVICE_LABEL,
12813
+ title: appName,
12814
+ description: `Last used ${lastUsed}`,
12815
+ nav: SETTINGS_NAV,
12816
+ blocks
12817
+ }));
12818
+ });
12819
+ app.post("/settings/connections/applications/:client_id/revoke", async (c) => {
13126
12820
  const sessionUser = resolveSessionUser(c);
13127
12821
  if (!sessionUser) {
13128
- return c.html(renderErrorPage("Unauthorized", "You must be authenticated to perform this action.", SERVICE_LABEL), 401);
12822
+ return c.html(await renderErrorPage("Unauthorized", "You must be authenticated to perform this action.", SERVICE_LABEL), 401);
13129
12823
  }
13130
12824
  const clientId = c.req.param("client_id");
13131
12825
  const grant = gh.oauthGrants.all().find((g) => g.user_id === sessionUser.id && g.client_id === clientId);
@@ -14036,7 +13730,7 @@ function oauthRoutes2({ app, store, baseUrl, tokenMap }) {
14036
13730
  ]
14037
13731
  });
14038
13732
  });
14039
- app.get("/auth/authorize", (c) => {
13733
+ app.get("/auth/authorize", async (c) => {
14040
13734
  const client_id = c.req.query("client_id") ?? "";
14041
13735
  const redirect_uri = c.req.query("redirect_uri") ?? "";
14042
13736
  const scope = c.req.query("scope") ?? "";
@@ -14048,17 +13742,17 @@ function oauthRoutes2({ app, store, baseUrl, tokenMap }) {
14048
13742
  if (clientsConfigured) {
14049
13743
  const client = as.oauthClients.findOneBy("client_id", client_id);
14050
13744
  if (!client) {
14051
- return c.html(renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL2), 400);
13745
+ return c.html(await renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL2), 400);
14052
13746
  }
14053
13747
  if (redirect_uri && !matchesRedirectUri(redirect_uri, client.redirect_uris)) {
14054
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL2), 400);
13748
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL2), 400);
14055
13749
  }
14056
13750
  clientName = client.name;
14057
13751
  }
14058
- const subtitleText = clientName ? `Sign in to <strong>${escapeHtml(clientName)}</strong> with your Apple ID.` : "Choose a seeded user to continue.";
13752
+ const subtitleText = clientName ? ["Sign in to ", { strong: clientName }, " with your Apple ID."] : "Choose a seeded user to continue.";
14059
13753
  const users = as.users.all();
14060
13754
  const userButtons = users.map((user) => {
14061
- return renderUserButton({
13755
+ return {
14062
13756
  letter: (user.email[0] ?? "?").toUpperCase(),
14063
13757
  login: user.email,
14064
13758
  name: user.name,
@@ -14073,10 +13767,9 @@ function oauthRoutes2({ app, store, baseUrl, tokenMap }) {
14073
13767
  client_id,
14074
13768
  response_mode
14075
13769
  }
14076
- });
14077
- }).join("\n");
14078
- const body = users.length === 0 ? '<p class="empty">No users in the emulator store.</p>' : userButtons;
14079
- return c.html(renderCardPage("Sign in with Apple", subtitleText, body, SERVICE_LABEL2));
13770
+ };
13771
+ });
13772
+ return c.html(await renderSignInPage("Sign in with Apple", subtitleText, userButtons, SERVICE_LABEL2));
14080
13773
  });
14081
13774
  app.post("/auth/authorize/callback", async (c) => {
14082
13775
  const body = await c.req.parseBody();
@@ -14118,7 +13811,7 @@ function oauthRoutes2({ app, store, baseUrl, tokenMap }) {
14118
13811
  const fields = { code, state };
14119
13812
  if (userJson)
14120
13813
  fields.user = userJson;
14121
- return c.html(renderFormPostPage(redirect_uri, fields, SERVICE_LABEL2));
13814
+ return c.html(await renderFormPostPage(redirect_uri, fields, SERVICE_LABEL2));
14122
13815
  }
14123
13816
  const url = new URL(redirect_uri);
14124
13817
  url.searchParams.set("code", code);
@@ -15365,101 +15058,43 @@ var TABS = [
15365
15058
  function inspectorRoutes(ctx) {
15366
15059
  const { app, store } = ctx;
15367
15060
  const aws = () => getAwsStore(store);
15368
- app.get("/_inspector", (c) => {
15061
+ app.get("/_inspector", async (c) => {
15369
15062
  const tab = c.req.query("tab") ?? "s3";
15370
15063
  const s3Store = aws();
15371
15064
  const buckets = s3Store.s3Buckets.all();
15372
15065
  const queues = s3Store.sqsQueues.all();
15373
15066
  const users = s3Store.iamUsers.all();
15374
15067
  const roles = s3Store.iamRoles.all();
15375
- let contentHtml = "";
15068
+ const blocks = [];
15376
15069
  if (tab === "s3") {
15377
- const rows = buckets.map((b) => {
15378
- const objects = s3Store.s3Objects.findBy("bucket_name", b.bucket_name);
15379
- return `<tr>
15380
- <td>${escapeXml(b.bucket_name)}</td>
15381
- <td>${objects.length}</td>
15382
- <td>${escapeXml(b.region)}</td>
15383
- <td>${escapeXml(b.creation_date)}</td>
15384
- </tr>`;
15385
- }).join("\n");
15386
- contentHtml = `
15387
- <div class="inspector-section">
15388
- <h2>S3 Buckets (${buckets.length})</h2>
15389
- <table class="inspector-table">
15390
- <thead><tr><th>Bucket</th><th>Objects</th><th>Region</th><th>Created</th></tr></thead>
15391
- <tbody>${rows || `<tr><td colspan="4"><div class="inspector-empty">No buckets</div></td></tr>`}</tbody>
15392
- </table>
15393
- </div>`;
15070
+ blocks.push(counted("S3 Buckets", buckets.length, table(["Bucket", "Objects", "Region", "Created"], buckets.map((b) => [
15071
+ b.bucket_name,
15072
+ String(s3Store.s3Objects.findBy("bucket_name", b.bucket_name).length),
15073
+ b.region,
15074
+ b.creation_date
15075
+ ]), "No buckets")));
15394
15076
  for (const bucket of buckets) {
15395
15077
  const objects = s3Store.s3Objects.findBy("bucket_name", bucket.bucket_name);
15396
15078
  if (objects.length > 0) {
15397
- const objRows = objects.map((o) => `<tr>
15398
- <td>${escapeXml(o.key)}</td>
15399
- <td>${o.content_length}</td>
15400
- <td>${escapeXml(o.content_type)}</td>
15401
- <td>${escapeXml(o.last_modified)}</td>
15402
- </tr>`).join("\n");
15403
- contentHtml += `
15404
- <div class="inspector-section">
15405
- <h3>${escapeXml(bucket.bucket_name)} objects</h3>
15406
- <table class="inspector-table">
15407
- <thead><tr><th>Key</th><th>Size</th><th>Type</th><th>Last Modified</th></tr></thead>
15408
- <tbody>${objRows}</tbody>
15409
- </table>
15410
- </div>`;
15079
+ blocks.push(counted(`${bucket.bucket_name} objects`, objects.length, table(["Key", "Size", "Type", "Last Modified"], objects.map((o) => [o.key, String(o.content_length), o.content_type, o.last_modified]), "No objects")));
15411
15080
  }
15412
15081
  }
15413
15082
  } else if (tab === "sqs") {
15414
- const rows = queues.map((q) => {
15415
- const messages = s3Store.sqsMessages.findBy("queue_name", q.queue_name);
15416
- return `<tr>
15417
- <td>${escapeXml(q.queue_name)}</td>
15418
- <td>${messages.length}</td>
15419
- <td>${q.fifo ? "Yes" : "No"}</td>
15420
- <td>${q.visibility_timeout}s</td>
15421
- </tr>`;
15422
- }).join("\n");
15423
- contentHtml = `
15424
- <div class="inspector-section">
15425
- <h2>SQS Queues (${queues.length})</h2>
15426
- <table class="inspector-table">
15427
- <thead><tr><th>Queue</th><th>Messages</th><th>FIFO</th><th>Visibility Timeout</th></tr></thead>
15428
- <tbody>${rows || `<tr><td colspan="4"><div class="inspector-empty">No queues</div></td></tr>`}</tbody>
15429
- </table>
15430
- </div>`;
15083
+ blocks.push(counted("SQS Queues", queues.length, table(["Queue", "Messages", "FIFO", "Visibility Timeout"], queues.map((q) => [
15084
+ q.queue_name,
15085
+ String(s3Store.sqsMessages.findBy("queue_name", q.queue_name).length),
15086
+ q.fifo ? "Yes" : "No",
15087
+ `${q.visibility_timeout}s`
15088
+ ]), "No queues")));
15431
15089
  } else if (tab === "iam") {
15432
- const userRows = users.map((u) => `<tr>
15433
- <td>${escapeXml(u.user_name)}</td>
15434
- <td>${escapeXml(u.user_id)}</td>
15435
- <td>${u.access_keys.length}</td>
15436
- <td>${escapeXml(u.arn)}</td>
15437
- </tr>`).join("\n");
15438
- const roleRows = roles.map((r) => `<tr>
15439
- <td>${escapeXml(r.role_name)}</td>
15440
- <td>${escapeXml(r.role_id)}</td>
15441
- <td>${escapeXml(r.description)}</td>
15442
- <td>${escapeXml(r.arn)}</td>
15443
- </tr>`).join("\n");
15444
- contentHtml = `
15445
- <div class="inspector-section">
15446
- <h2>IAM Users (${users.length})</h2>
15447
- <table class="inspector-table">
15448
- <thead><tr><th>User</th><th>User ID</th><th>Access Keys</th><th>ARN</th></tr></thead>
15449
- <tbody>${userRows || `<tr><td colspan="4"><div class="inspector-empty">No users</div></td></tr>`}</tbody>
15450
- </table>
15451
- </div>
15452
- <div class="inspector-section">
15453
- <h2>IAM Roles (${roles.length})</h2>
15454
- <table class="inspector-table">
15455
- <thead><tr><th>Role</th><th>Role ID</th><th>Description</th><th>ARN</th></tr></thead>
15456
- <tbody>${roleRows || `<tr><td colspan="4"><div class="inspector-empty">No roles</div></td></tr>`}</tbody>
15457
- </table>
15458
- </div>`;
15459
- }
15460
- return c.html(renderInspectorPage("Inspector", TABS, tab, contentHtml, SERVICE_LABEL3));
15090
+ blocks.push(counted("IAM Users", users.length, table(["User", "User ID", "Access Keys", "ARN"], users.map((u) => [u.user_name, u.user_id, String(u.access_keys.length), u.arn]), "No users")), counted("IAM Roles", roles.length, table(["Role", "Role ID", "Description", "ARN"], roles.map((r) => [r.role_name, r.role_id, r.description, r.arn]), "No roles")));
15091
+ }
15092
+ return c.html(await renderInspectorPage("Inspector", TABS, tab, blocks, SERVICE_LABEL3));
15461
15093
  });
15462
15094
  }
15095
+ function counted(title, count, ...blocks) {
15096
+ return { ...section(title, ...blocks), count };
15097
+ }
15463
15098
 
15464
15099
  // ../http/provider/dist/vendor/aws/index.js
15465
15100
  function seedDefaults3(store, baseUrl) {
@@ -15864,7 +15499,7 @@ function oauthRoutes3({ app, store, baseUrl, tokenMap }) {
15864
15499
  keys: [{ ...jwk, kid: KID2, use: "sig", alg: "RS256" }]
15865
15500
  });
15866
15501
  });
15867
- app.get("/oauth/authorize", (c) => {
15502
+ app.get("/oauth/authorize", async (c) => {
15868
15503
  const clientId = c.req.query("client_id") ?? "";
15869
15504
  const redirectUri = c.req.query("redirect_uri") ?? "";
15870
15505
  const scope = c.req.query("scope") ?? "openid profile email";
@@ -15874,20 +15509,20 @@ function oauthRoutes3({ app, store, baseUrl, tokenMap }) {
15874
15509
  const codeChallenge = c.req.query("code_challenge") ?? "";
15875
15510
  const codeChallengeMethod = c.req.query("code_challenge_method") ?? "";
15876
15511
  if (responseType !== "code") {
15877
- return c.html(renderErrorPage("Unsupported response_type", "Only response_type=code is supported.", SERVICE_LABEL13), 400);
15512
+ return c.html(await renderErrorPage("Unsupported response_type", "Only response_type=code is supported.", SERVICE_LABEL13), 400);
15878
15513
  }
15879
15514
  if (!redirectUri) {
15880
- return c.html(renderErrorPage("Missing redirect URI", "The redirect_uri parameter is required.", SERVICE_LABEL13), 400);
15515
+ return c.html(await renderErrorPage("Missing redirect URI", "The redirect_uri parameter is required.", SERVICE_LABEL13), 400);
15881
15516
  }
15882
15517
  const oauthApps = clerkStore.oauthApps.all();
15883
15518
  let appName = "";
15884
15519
  if (oauthApps.length > 0) {
15885
15520
  const oauthApp = oauthApps.find((a) => a.client_id === clientId);
15886
15521
  if (!oauthApp) {
15887
- return c.html(renderErrorPage("Application not found", `The client_id '${clientId}' is not registered.`, SERVICE_LABEL13), 400);
15522
+ return c.html(await renderErrorPage("Application not found", `The client_id '${clientId}' is not registered.`, SERVICE_LABEL13), 400);
15888
15523
  }
15889
15524
  if (!matchesRedirectUri(redirectUri, oauthApp.redirect_uris)) {
15890
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL13), 400);
15525
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL13), 400);
15891
15526
  }
15892
15527
  appName = oauthApp.name;
15893
15528
  }
@@ -15895,7 +15530,7 @@ function oauthRoutes3({ app, store, baseUrl, tokenMap }) {
15895
15530
  const buttons = users.map((user) => {
15896
15531
  const emails = clerkStore.emailAddresses.findBy("user_id", user.clerk_id);
15897
15532
  const primaryEmail = emails.find((e) => e.is_primary) ?? emails[0];
15898
- return renderUserButton({
15533
+ return {
15899
15534
  letter: ((user.first_name ?? user.username ?? "?")[0] ?? "?").toUpperCase(),
15900
15535
  login: primaryEmail?.email_address ?? user.username ?? user.clerk_id,
15901
15536
  name: userDisplayName(user),
@@ -15911,10 +15546,10 @@ function oauthRoutes3({ app, store, baseUrl, tokenMap }) {
15911
15546
  code_challenge: codeChallenge,
15912
15547
  code_challenge_method: codeChallengeMethod
15913
15548
  }
15914
- });
15915
- }).join("\n");
15916
- const subtitle = appName ? `Sign in to <strong>${escapeHtml(appName)}</strong> with your Clerk account.` : "Choose a seeded user to continue.";
15917
- return c.html(renderCardPage("Sign in with Clerk", subtitle, users.length > 0 ? buttons : '<p class="empty">No users in the emulator store.</p>', SERVICE_LABEL13));
15549
+ };
15550
+ });
15551
+ const subtitle = appName ? ["Sign in to ", { strong: appName }, " with your Clerk account."] : "Choose a seeded user to continue.";
15552
+ return c.html(await renderSignInPage("Sign in with Clerk", subtitle, buttons, SERVICE_LABEL13));
15918
15553
  });
15919
15554
  app.post("/oauth/authorize/callback", async (c) => {
15920
15555
  const body = await c.req.parseBody();
@@ -15927,20 +15562,20 @@ function oauthRoutes3({ app, store, baseUrl, tokenMap }) {
15927
15562
  const codeChallenge = bodyStr(body.code_challenge);
15928
15563
  const codeChallengeMethod = bodyStr(body.code_challenge_method);
15929
15564
  if (!redirectUri) {
15930
- return c.html(renderErrorPage("Missing redirect URI", "The redirect_uri parameter is required.", SERVICE_LABEL13), 400);
15565
+ return c.html(await renderErrorPage("Missing redirect URI", "The redirect_uri parameter is required.", SERVICE_LABEL13), 400);
15931
15566
  }
15932
15567
  const user = clerkStore.users.findOneBy("clerk_id", userRef);
15933
15568
  if (!user) {
15934
- return c.html(renderErrorPage("Unknown user", "The selected user is not available.", SERVICE_LABEL13), 400);
15569
+ return c.html(await renderErrorPage("Unknown user", "The selected user is not available.", SERVICE_LABEL13), 400);
15935
15570
  }
15936
15571
  const oauthApps = clerkStore.oauthApps.all();
15937
15572
  if (oauthApps.length > 0) {
15938
15573
  const oauthApp = oauthApps.find((a) => a.client_id === clientId);
15939
15574
  if (!oauthApp) {
15940
- return c.html(renderErrorPage("Application not found", `The client_id '${clientId}' is not registered.`, SERVICE_LABEL13), 400);
15575
+ return c.html(await renderErrorPage("Application not found", `The client_id '${clientId}' is not registered.`, SERVICE_LABEL13), 400);
15941
15576
  }
15942
15577
  if (!matchesRedirectUri(redirectUri, oauthApp.redirect_uris)) {
15943
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL13), 400);
15578
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL13), 400);
15944
15579
  }
15945
15580
  }
15946
15581
  const code = randomBytes(20).toString("hex");
@@ -20286,7 +19921,7 @@ function oauthRoutes4({ app, store, baseUrl, tokenMap }) {
20286
19921
  ]
20287
19922
  });
20288
19923
  });
20289
- app.get("/o/oauth2/v2/auth", (c) => {
19924
+ app.get("/o/oauth2/v2/auth", async (c) => {
20290
19925
  const client_id = c.req.query("client_id") ?? "";
20291
19926
  const redirect_uri = c.req.query("redirect_uri") ?? "";
20292
19927
  const scope = c.req.query("scope") ?? "";
@@ -20299,17 +19934,17 @@ function oauthRoutes4({ app, store, baseUrl, tokenMap }) {
20299
19934
  if (clientsConfigured) {
20300
19935
  const client = gs.oauthClients.findOneBy("client_id", client_id);
20301
19936
  if (!client) {
20302
- return c.html(renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL4), 400);
19937
+ return c.html(await renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL4), 400);
20303
19938
  }
20304
19939
  if (redirect_uri && !matchesRedirectUri(redirect_uri, client.redirect_uris)) {
20305
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL4), 400);
19940
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL4), 400);
20306
19941
  }
20307
19942
  clientName = client.name;
20308
19943
  }
20309
- const subtitleText = clientName ? `Sign in to <strong>${escapeHtml(clientName)}</strong> with your Google account.` : "Choose a seeded user to continue.";
19944
+ const subtitle = clientName ? ["Sign in to ", { strong: clientName }, " with your Google account."] : "Choose a seeded user to continue.";
20310
19945
  const users = gs.users.all();
20311
- const userButtons = users.map((user) => {
20312
- return renderUserButton({
19946
+ const accounts = users.map((user) => {
19947
+ return {
20313
19948
  letter: (user.email[0] ?? "?").toUpperCase(),
20314
19949
  login: user.email,
20315
19950
  name: user.name,
@@ -20325,10 +19960,9 @@ function oauthRoutes4({ app, store, baseUrl, tokenMap }) {
20325
19960
  code_challenge,
20326
19961
  code_challenge_method
20327
19962
  }
20328
- });
20329
- }).join("\n");
20330
- const body = users.length === 0 ? '<p class="empty">No users in the emulator store.</p>' : userButtons;
20331
- return c.html(renderCardPage("Sign in to Google", subtitleText, body, SERVICE_LABEL4));
19963
+ };
19964
+ });
19965
+ return c.html(await renderSignInPage("Sign in to Google", subtitle, accounts, SERVICE_LABEL4));
20332
19966
  });
20333
19967
  app.post("/o/oauth2/v2/auth/callback", async (c) => {
20334
19968
  const body = await c.req.parseBody();
@@ -23062,7 +22696,7 @@ function pendingCodes(store) {
23062
22696
  }
23063
22697
  function oauthRoutes5({ app, store, tokenMap }) {
23064
22698
  const ls = () => getLinearStore(store);
23065
- app.get("/oauth/authorize", (c) => {
22699
+ app.get("/oauth/authorize", async (c) => {
23066
22700
  const clientId = c.req.query("client_id") ?? "";
23067
22701
  const redirectUri = c.req.query("redirect_uri") ?? "";
23068
22702
  const responseType = c.req.query("response_type") ?? "code";
@@ -23072,32 +22706,32 @@ function oauthRoutes5({ app, store, tokenMap }) {
23072
22706
  const codeChallenge = c.req.query("code_challenge") ?? "";
23073
22707
  const codeChallengeMethod = c.req.query("code_challenge_method") ?? "";
23074
22708
  if (responseType !== "code") {
23075
- return c.html(renderErrorPage("Unsupported response_type", "Only response_type=code is supported.", SERVICE_LABEL5), 400);
22709
+ return c.html(await renderErrorPage("Unsupported response_type", "Only response_type=code is supported.", SERVICE_LABEL5), 400);
23076
22710
  }
23077
22711
  if (!redirectUri) {
23078
- return c.html(renderErrorPage("Missing redirect URI", "The redirect_uri parameter is required.", SERVICE_LABEL5), 400);
22712
+ return c.html(await renderErrorPage("Missing redirect URI", "The redirect_uri parameter is required.", SERVICE_LABEL5), 400);
23079
22713
  }
23080
22714
  const oauthApp = resolveOAuthApp(clientId);
23081
22715
  if (ls().oauthApps.all().length > 0) {
23082
22716
  if (!oauthApp) {
23083
- return c.html(renderErrorPage("Application not found", `The client_id '${clientId}' is not registered.`, SERVICE_LABEL5), 400);
22717
+ return c.html(await renderErrorPage("Application not found", `The client_id '${clientId}' is not registered.`, SERVICE_LABEL5), 400);
23084
22718
  }
23085
22719
  if (!matchesRedirectUri(redirectUri, oauthApp.redirect_uris)) {
23086
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this app.", SERVICE_LABEL5), 400);
22720
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this app.", SERVICE_LABEL5), 400);
23087
22721
  }
23088
22722
  }
23089
22723
  const actor = requestedActor ?? oauthApp?.actor ?? "user";
23090
22724
  if (requestedActor && oauthApp && requestedActor !== oauthApp.actor) {
23091
- return c.html(renderErrorPage("Invalid actor", `This app is configured for actor=${oauthApp.actor}.`, SERVICE_LABEL5), 400);
22725
+ return c.html(await renderErrorPage("Invalid actor", `This app is configured for actor=${oauthApp.actor}.`, SERVICE_LABEL5), 400);
23092
22726
  }
23093
22727
  const requestedScopes = normalizeScopes(scope, oauthApp?.scopes ?? ["read"]);
23094
22728
  const invalidScopes = scopesOutsideApp(requestedScopes, oauthApp);
23095
22729
  if (invalidScopes.length > 0) {
23096
- return c.html(renderErrorPage("Invalid scope", `The app is not registered for scopes: ${invalidScopes.join(", ")}.`, SERVICE_LABEL5), 400);
22730
+ return c.html(await renderErrorPage("Invalid scope", `The app is not registered for scopes: ${invalidScopes.join(", ")}.`, SERVICE_LABEL5), 400);
23097
22731
  }
23098
22732
  const title = actor === "app" ? "Install Linear App" : "Authorize Linear App";
23099
22733
  const appName = oauthApp?.name ?? "Linear App";
23100
- const buttons = actor === "app" ? renderUserButton({
22734
+ const buttons = actor === "app" ? [{
23101
22735
  letter: "L",
23102
22736
  login: appName,
23103
22737
  name: `Install ${appName}`,
@@ -23113,7 +22747,7 @@ function oauthRoutes5({ app, store, tokenMap }) {
23113
22747
  code_challenge: codeChallenge,
23114
22748
  code_challenge_method: codeChallengeMethod
23115
22749
  }
23116
- }) : ls().users.all().filter((user) => !user.app && user.active).map((user) => renderUserButton({
22750
+ }] : ls().users.all().filter((user) => !user.app && user.active).map((user) => ({
23117
22751
  letter: (user.display_name[0] ?? "U").toUpperCase(),
23118
22752
  login: user.email,
23119
22753
  name: user.display_name,
@@ -23129,8 +22763,8 @@ function oauthRoutes5({ app, store, tokenMap }) {
23129
22763
  code_challenge: codeChallenge,
23130
22764
  code_challenge_method: codeChallengeMethod
23131
22765
  }
23132
- })).join("\n");
23133
- return c.html(renderCardPage(title, `Continue to <strong>${escapeHtml(appName)}</strong> with scopes <strong>${escapeHtml(requestedScopes.join(", "))}</strong>.`, buttons || '<p class="empty">No users in the Linear emulator store.</p>', SERVICE_LABEL5));
22766
+ }));
22767
+ return c.html(await renderSignInPage(title, ["Continue to ", { strong: appName }, " with scopes ", { strong: requestedScopes.join(", ") }, "."], buttons, SERVICE_LABEL5, "No users in the Linear emulator store."));
23134
22768
  });
23135
22769
  app.post("/oauth/authorize/callback", async (c) => {
23136
22770
  const body = await c.req.parseBody();
@@ -23145,24 +22779,24 @@ function oauthRoutes5({ app, store, tokenMap }) {
23145
22779
  const oauthApp = resolveOAuthApp(clientId);
23146
22780
  if (ls().oauthApps.all().length > 0) {
23147
22781
  if (!oauthApp) {
23148
- return c.html(renderErrorPage("Application not found", "The OAuth app is not registered.", SERVICE_LABEL5), 400);
22782
+ return c.html(await renderErrorPage("Application not found", "The OAuth app is not registered.", SERVICE_LABEL5), 400);
23149
22783
  }
23150
22784
  if (!matchesRedirectUri(redirectUri, oauthApp.redirect_uris)) {
23151
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this app.", SERVICE_LABEL5), 400);
22785
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this app.", SERVICE_LABEL5), 400);
23152
22786
  }
23153
22787
  }
23154
22788
  const actor = requestedActor ?? oauthApp?.actor ?? "user";
23155
22789
  if (requestedActor && oauthApp && requestedActor !== oauthApp.actor) {
23156
- return c.html(renderErrorPage("Invalid actor", `This app is configured for actor=${oauthApp.actor}.`, SERVICE_LABEL5), 400);
22790
+ return c.html(await renderErrorPage("Invalid actor", `This app is configured for actor=${oauthApp.actor}.`, SERVICE_LABEL5), 400);
23157
22791
  }
23158
22792
  const invalidScopes = scopesOutsideApp(scopes, oauthApp);
23159
22793
  if (invalidScopes.length > 0) {
23160
- return c.html(renderErrorPage("Invalid scope", `The app is not registered for scopes: ${invalidScopes.join(", ")}.`, SERVICE_LABEL5), 400);
22794
+ return c.html(await renderErrorPage("Invalid scope", `The app is not registered for scopes: ${invalidScopes.join(", ")}.`, SERVICE_LABEL5), 400);
23161
22795
  }
23162
22796
  const user = userRef && actor === "app" ? ls().users.findOneBy("linear_id", userRef) : ls().users.findOneBy("linear_id", userRef) ?? ls().users.all().find((u) => !u.app);
23163
22797
  const appUser = actor === "app" ? oauthApp?.app_user_id ? ls().users.findOneBy("linear_id", oauthApp.app_user_id) : user : user;
23164
22798
  if (!appUser) {
23165
- return c.html(renderErrorPage("No Linear actor", "No matching user or app actor is available.", SERVICE_LABEL5), 400);
22799
+ return c.html(await renderErrorPage("No Linear actor", "No matching user or app actor is available.", SERVICE_LABEL5), 400);
23166
22800
  }
23167
22801
  const code = token("lin_code");
23168
22802
  pendingCodes(store).set(code, {
@@ -23364,11 +22998,11 @@ var TABS2 = [
23364
22998
  ];
23365
22999
  function inspectorRoutes2({ app, store }) {
23366
23000
  const ls = () => getLinearStore(store);
23367
- app.get("/", (c) => {
23001
+ app.get("/", async (c) => {
23368
23002
  const requested = c.req.query("tab") ?? "issues";
23369
23003
  const active = TABS2.some((tab) => tab.id === requested) ? requested : "issues";
23370
23004
  const body = active === "teams" ? teamsView() : active === "users" ? usersView() : active === "projects" ? projectsView() : active === "agents" ? agentsView() : active === "auth" ? authView() : active === "webhooks" ? webhooksView() : issuesView();
23371
- return c.html(renderInspectorPage("Linear Inspector", TABS2, active, body, SERVICE_LABEL6));
23005
+ return c.html(await renderInspectorPage("Linear Inspector", TABS2, active, body, SERVICE_LABEL6));
23372
23006
  });
23373
23007
  function issuesView() {
23374
23008
  const rows = ls().issues.all().sort((a, b) => a.identifier.localeCompare(b.identifier)).map((issue) => {
@@ -23379,129 +23013,120 @@ function inspectorRoutes2({ app, store }) {
23379
23013
  const labels = issue.label_ids.map((labelId) => ls().issueLabels.findOneBy("linear_id", labelId)?.name).filter((name) => Boolean(name)).join(", ");
23380
23014
  return [
23381
23015
  linkCell(`/?tab=issues&issue=${encodeURIComponent(issue.linear_id)}`, issue.identifier),
23382
- escapeHtml(issue.title),
23383
- escapeHtml(team?.key ?? issue.team_id),
23384
- escapeHtml(state?.name ?? issue.state_id),
23385
- escapeHtml(userLabel(assignee)),
23386
- escapeHtml(userLabel(delegate)),
23387
- escapeHtml(labels),
23388
- escapeHtml(issue.updated_at)
23016
+ issue.title,
23017
+ team?.key ?? issue.team_id,
23018
+ state?.name ?? issue.state_id,
23019
+ userLabel(assignee),
23020
+ userLabel(delegate),
23021
+ labels,
23022
+ issue.updated_at
23389
23023
  ];
23390
23024
  });
23391
- return section("Issues", table(["ID", "Title", "Team", "State", "Assignee", "Delegate", "Labels", "Updated"], rows, "No issues."));
23025
+ return [section("Issues", table(["ID", "Title", "Team", "State", "Assignee", "Delegate", "Labels", "Updated"], rows, "No issues."))];
23392
23026
  }
23393
23027
  function teamsView() {
23394
23028
  const rows = ls().teams.all().sort((a, b) => a.key.localeCompare(b.key)).map((team) => {
23395
23029
  const stateNames = ls().workflowStates.findBy("team_id", team.linear_id).sort((a, b) => a.position - b.position).map((state) => state.name).join(", ");
23396
23030
  const issueCount = ls().issues.count((issue) => issue.team_id === team.linear_id);
23397
23031
  return [
23398
- escapeHtml(team.key),
23399
- escapeHtml(team.name),
23400
- escapeHtml(String(issueCount)),
23401
- escapeHtml(stateNames),
23402
- escapeHtml(team.private ? "private" : "public")
23032
+ team.key,
23033
+ team.name,
23034
+ String(issueCount),
23035
+ stateNames,
23036
+ team.private ? "private" : "public"
23403
23037
  ];
23404
23038
  });
23405
- return section("Teams", table(["Key", "Name", "Issues", "States", "Access"], rows, "No teams."));
23039
+ return [section("Teams", table(["Key", "Name", "Issues", "States", "Access"], rows, "No teams."))];
23406
23040
  }
23407
23041
  function usersView() {
23408
23042
  const rows = ls().users.all().sort((a, b) => a.email.localeCompare(b.email)).map((user) => [
23409
- escapeHtml(user.display_name),
23410
- escapeHtml(user.email),
23411
- escapeHtml(user.app ? "app" : "user"),
23412
- escapeHtml(user.admin ? "admin" : "member"),
23413
- escapeHtml(user.active ? "active" : "inactive"),
23414
- escapeHtml(String(ls().issues.count((issue) => issue.assignee_id === user.linear_id)))
23043
+ user.display_name,
23044
+ user.email,
23045
+ user.app ? "app" : "user",
23046
+ user.admin ? "admin" : "member",
23047
+ chip(user.active ? "active" : "inactive"),
23048
+ String(ls().issues.count((issue) => issue.assignee_id === user.linear_id))
23415
23049
  ]);
23416
- return section("Users", table(["Name", "Email", "Kind", "Role", "Status", "Assigned"], rows, "No users."));
23050
+ return [section("Users", table(["Name", "Email", "Kind", "Role", "Status", "Assigned"], rows, "No users."))];
23417
23051
  }
23418
23052
  function projectsView() {
23419
23053
  const projectRows = ls().projects.all().map((project) => [
23420
- escapeHtml(project.name),
23421
- escapeHtml(project.state),
23422
- escapeHtml(project.team_id ? ls().teams.findOneBy("linear_id", project.team_id)?.key ?? project.team_id : "workspace"),
23423
- escapeHtml(String(ls().issues.count((issue) => issue.project_id === project.linear_id)))
23054
+ project.name,
23055
+ project.state,
23056
+ project.team_id ? ls().teams.findOneBy("linear_id", project.team_id)?.key ?? project.team_id : "workspace",
23057
+ String(ls().issues.count((issue) => issue.project_id === project.linear_id))
23424
23058
  ]);
23425
23059
  const cycleRows = ls().cycles.all().map((cycle) => [
23426
- escapeHtml(cycle.name),
23427
- escapeHtml(String(cycle.number)),
23428
- escapeHtml(ls().teams.findOneBy("linear_id", cycle.team_id)?.key ?? cycle.team_id),
23429
- escapeHtml(String(ls().issues.count((issue) => issue.cycle_id === cycle.linear_id)))
23060
+ cycle.name,
23061
+ String(cycle.number),
23062
+ ls().teams.findOneBy("linear_id", cycle.team_id)?.key ?? cycle.team_id,
23063
+ String(ls().issues.count((issue) => issue.cycle_id === cycle.linear_id))
23430
23064
  ]);
23431
- return section("Projects", table(["Name", "State", "Team", "Issues"], projectRows, "No projects.")) + section("Cycles", table(["Name", "Number", "Team", "Issues"], cycleRows, "No cycles."));
23065
+ return [
23066
+ section("Projects", table(["Name", "State", "Team", "Issues"], projectRows, "No projects.")),
23067
+ section("Cycles", table(["Name", "Number", "Team", "Issues"], cycleRows, "No cycles."))
23068
+ ];
23432
23069
  }
23433
23070
  function agentsView() {
23434
23071
  const rows = ls().agentSessions.all().map((session) => {
23435
23072
  const issue = session.issue_id ? ls().issues.findOneBy("linear_id", session.issue_id) : void 0;
23436
23073
  const agent = ls().users.findOneBy("linear_id", session.agent_user_id);
23437
23074
  return [
23438
- escapeHtml(session.linear_id),
23439
- escapeHtml(session.state),
23440
- escapeHtml(issue?.identifier ?? ""),
23441
- escapeHtml(userLabel(agent)),
23442
- escapeHtml(String(ls().agentActivities.count((activity) => activity.session_id === session.linear_id))),
23443
- escapeHtml(session.updated_at)
23075
+ session.linear_id,
23076
+ chip(session.state),
23077
+ issue?.identifier ?? "",
23078
+ userLabel(agent),
23079
+ String(ls().agentActivities.count((activity) => activity.session_id === session.linear_id)),
23080
+ session.updated_at
23444
23081
  ];
23445
23082
  });
23446
- return section("Agent Sessions", table(["ID", "State", "Issue", "Agent", "Activities", "Updated"], rows, "No agent sessions."));
23083
+ return [section("Agent Sessions", table(["ID", "State", "Issue", "Agent", "Activities", "Updated"], rows, "No agent sessions."))];
23447
23084
  }
23448
23085
  function authView() {
23449
23086
  const appRows = ls().oauthApps.all().map((oauthApp) => [
23450
- escapeHtml(oauthApp.name),
23451
- escapeHtml(oauthApp.client_id),
23452
- escapeHtml(oauthApp.actor),
23453
- escapeHtml(oauthApp.scopes.join(", ")),
23454
- escapeHtml(oauthApp.app_user_id ? userLabel(ls().users.findOneBy("linear_id", oauthApp.app_user_id)) : "")
23087
+ oauthApp.name,
23088
+ oauthApp.client_id,
23089
+ oauthApp.actor,
23090
+ oauthApp.scopes.join(", "),
23091
+ oauthApp.app_user_id ? userLabel(ls().users.findOneBy("linear_id", oauthApp.app_user_id)) : ""
23455
23092
  ]);
23456
23093
  const tokenRows = ls().tokens.all().map((token2) => [
23457
- escapeHtml(maskToken(token2.token)),
23458
- escapeHtml(token2.type),
23459
- escapeHtml(token2.actor_type),
23460
- escapeHtml(token2.user_id ? userLabel(ls().users.findOneBy("linear_id", token2.user_id)) : token2.app_id ?? ""),
23461
- escapeHtml(token2.scopes.join(", ")),
23462
- escapeHtml(token2.revoked ? "revoked" : token2.expires_at ?? "active")
23094
+ maskToken(token2.token),
23095
+ token2.type,
23096
+ token2.actor_type,
23097
+ token2.user_id ? userLabel(ls().users.findOneBy("linear_id", token2.user_id)) : token2.app_id ?? "",
23098
+ token2.scopes.join(", "),
23099
+ token2.revoked ? chip("revoked") : token2.expires_at ?? chip("active")
23463
23100
  ]);
23464
- return section("OAuth Apps", table(["Name", "Client ID", "Actor", "Scopes", "App User"], appRows, "No OAuth apps.")) + section("Tokens", table(["Token", "Type", "Actor", "Subject", "Scopes", "Status"], tokenRows, "No tokens."));
23101
+ return [
23102
+ section("OAuth Apps", table(["Name", "Client ID", "Actor", "Scopes", "App User"], appRows, "No OAuth apps.")),
23103
+ section("Tokens", table(["Token", "Type", "Actor", "Subject", "Scopes", "Status"], tokenRows, "No tokens."))
23104
+ ];
23465
23105
  }
23466
23106
  function webhooksView() {
23467
23107
  const webhookRows = ls().webhooks.all().map((webhook) => [
23468
- escapeHtml(webhook.label),
23469
- escapeHtml(webhook.url),
23470
- escapeHtml(webhook.enabled ? "enabled" : "disabled"),
23471
- escapeHtml(webhook.resource_types.join(", ")),
23472
- escapeHtml(webhook.team_id ? ls().teams.findOneBy("linear_id", webhook.team_id)?.key ?? webhook.team_id : "all public teams")
23108
+ webhook.label,
23109
+ webhook.url,
23110
+ chip(webhook.enabled ? "enabled" : "disabled"),
23111
+ webhook.resource_types.join(", "),
23112
+ webhook.team_id ? ls().teams.findOneBy("linear_id", webhook.team_id)?.key ?? webhook.team_id : "all public teams"
23473
23113
  ]);
23474
23114
  const deliveryRows = ls().webhookDeliveries.all().slice(-30).reverse().map((delivery) => [
23475
- escapeHtml(delivery.event),
23476
- escapeHtml(delivery.action),
23477
- escapeHtml(String(delivery.status ?? "")),
23478
- escapeHtml(delivery.error ?? ""),
23479
- escapeHtml(delivery.url),
23480
- escapeHtml(delivery.created_at)
23115
+ delivery.event,
23116
+ delivery.action,
23117
+ delivery.status == null ? "" : chip(String(delivery.status)),
23118
+ delivery.error ?? "",
23119
+ delivery.url,
23120
+ delivery.created_at
23481
23121
  ]);
23482
- return section("Webhook Subscriptions", table(["Label", "URL", "Status", "Resources", "Scope"], webhookRows, "No webhooks.")) + section("Webhook Deliveries", table(["Event", "Action", "Status", "Error", "URL", "Created"], deliveryRows, "No deliveries."));
23483
- }
23484
- }
23485
- function section(title, body) {
23486
- return `<section class="inspector-section">
23487
- <h2>${escapeHtml(title)}</h2>
23488
- ${body}
23489
- </section>`;
23490
- }
23491
- function table(headers, rows, empty) {
23492
- if (rows.length === 0)
23493
- return `<p class="inspector-empty">${escapeHtml(empty)}</p>`;
23494
- const headerHtml = headers.map((header) => `<th>${escapeHtml(header)}</th>`).join("");
23495
- const rowHtml = rows.map((row) => `<tr>${row.map((cell) => `<td>${cell}</td>`).join("")}</tr>`).join("\n");
23496
- return `<table class="inspector-table">
23497
- <thead><tr>${headerHtml}</tr></thead>
23498
- <tbody>
23499
- ${rowHtml}
23500
- </tbody>
23501
- </table>`;
23122
+ return [
23123
+ section("Webhook Subscriptions", table(["Label", "URL", "Status", "Resources", "Scope"], webhookRows, "No webhooks.")),
23124
+ section("Webhook Deliveries", table(["Event", "Action", "Status", "Error", "URL", "Created"], deliveryRows, "No deliveries."))
23125
+ ];
23126
+ }
23502
23127
  }
23503
23128
  function linkCell(href, label) {
23504
- return `<a href="${escapeAttr(href)}">${escapeHtml(label)}</a>`;
23129
+ return { link: label, href };
23505
23130
  }
23506
23131
  function userLabel(user) {
23507
23132
  return user?.display_name ?? user?.email ?? "";
@@ -24192,7 +23817,7 @@ function oauthRoutes6({ app, store, baseUrl, tokenMap }) {
24192
23817
  ]
24193
23818
  });
24194
23819
  });
24195
- app.get("/oauth2/v2.0/authorize", (c) => {
23820
+ app.get("/oauth2/v2.0/authorize", async (c) => {
24196
23821
  const client_id = c.req.query("client_id") ?? "";
24197
23822
  const redirect_uri = c.req.query("redirect_uri") ?? "";
24198
23823
  const scope = c.req.query("scope") ?? "";
@@ -24206,17 +23831,17 @@ function oauthRoutes6({ app, store, baseUrl, tokenMap }) {
24206
23831
  if (clientsConfigured) {
24207
23832
  const client = ms.oauthClients.findOneBy("client_id", client_id);
24208
23833
  if (!client) {
24209
- return c.html(renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL7), 400);
23834
+ return c.html(await renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL7), 400);
24210
23835
  }
24211
23836
  if (redirect_uri && !matchesRedirectUri(redirect_uri, client.redirect_uris)) {
24212
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL7), 400);
23837
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL7), 400);
24213
23838
  }
24214
23839
  clientName = client.name;
24215
23840
  }
24216
- const subtitleText = clientName ? `Sign in to <strong>${escapeHtml(clientName)}</strong> with your Microsoft account.` : "Choose a seeded user to continue.";
23841
+ const subtitleText = clientName ? ["Sign in to ", { strong: clientName }, " with your Microsoft account."] : "Choose a seeded user to continue.";
24217
23842
  const users = ms.users.all();
24218
23843
  const userButtons = users.map((user) => {
24219
- return renderUserButton({
23844
+ return {
24220
23845
  letter: (user.email[0] ?? "?").toUpperCase(),
24221
23846
  login: user.email,
24222
23847
  name: user.name,
@@ -24233,10 +23858,9 @@ function oauthRoutes6({ app, store, baseUrl, tokenMap }) {
24233
23858
  code_challenge,
24234
23859
  code_challenge_method
24235
23860
  }
24236
- });
24237
- }).join("\n");
24238
- const body = users.length === 0 ? '<p class="empty">No users in the emulator store.</p>' : userButtons;
24239
- return c.html(renderCardPage("Sign in with Microsoft", subtitleText, body, SERVICE_LABEL7));
23861
+ };
23862
+ });
23863
+ return c.html(await renderSignInPage("Sign in with Microsoft", subtitleText, userButtons, SERVICE_LABEL7));
24240
23864
  });
24241
23865
  app.post("/oauth2/v2.0/authorize/callback", async (c) => {
24242
23866
  const body = await c.req.parseBody();
@@ -24253,10 +23877,10 @@ function oauthRoutes6({ app, store, baseUrl, tokenMap }) {
24253
23877
  if (clientsConfigured) {
24254
23878
  const client = ms.oauthClients.findOneBy("client_id", client_id);
24255
23879
  if (!client) {
24256
- return c.html(renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL7), 400);
23880
+ return c.html(await renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL7), 400);
24257
23881
  }
24258
23882
  if (redirect_uri && !matchesRedirectUri(redirect_uri, client.redirect_uris)) {
24259
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL7), 400);
23883
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL7), 400);
24260
23884
  }
24261
23885
  }
24262
23886
  const code = randomBytes(20).toString("hex");
@@ -24272,7 +23896,7 @@ function oauthRoutes6({ app, store, baseUrl, tokenMap }) {
24272
23896
  });
24273
23897
  debug("microsoft.oauth", `[Microsoft callback] code=${code.slice(0, 8)}... email=${email}`);
24274
23898
  if (response_mode === "form_post") {
24275
- return c.html(renderFormPostPage(redirect_uri, { code, state }, SERVICE_LABEL7));
23899
+ return c.html(await renderFormPostPage(redirect_uri, { code, state }, SERVICE_LABEL7));
24276
23900
  }
24277
23901
  const url = new URL(redirect_uri);
24278
23902
  url.searchParams.set("code", code);
@@ -26506,7 +26130,7 @@ function oauthRoutes7({ app, store, baseUrl, tokenMap }) {
26506
26130
  keys: [{ ...jwk, kid: KID5, use: "sig", alg: "RS256" }]
26507
26131
  });
26508
26132
  });
26509
- const renderAuthorizePage = (c, authServerId) => {
26133
+ const renderAuthorizePage = async (c, authServerId) => {
26510
26134
  const server = resolveServer(authServerId, baseUrl, oktaStore);
26511
26135
  if (!server)
26512
26136
  return oktaError(c, 404, "E0000007", `Not found: authorization server '${authServerId}'`, void 0, store.now);
@@ -26520,26 +26144,26 @@ function oauthRoutes7({ app, store, baseUrl, tokenMap }) {
26520
26144
  const codeChallenge = c.req.query("code_challenge") ?? "";
26521
26145
  const codeChallengeMethod = c.req.query("code_challenge_method") ?? "";
26522
26146
  if (responseType !== "code") {
26523
- return c.html(renderErrorPage("Unsupported response_type", "Only response_type=code is supported.", SERVICE_LABEL13), 400);
26147
+ return c.html(await renderErrorPage("Unsupported response_type", "Only response_type=code is supported.", SERVICE_LABEL13), 400);
26524
26148
  }
26525
26149
  if (!redirectUri) {
26526
- return c.html(renderErrorPage("Missing redirect URI", "The redirect_uri parameter is required.", SERVICE_LABEL13), 400);
26150
+ return c.html(await renderErrorPage("Missing redirect URI", "The redirect_uri parameter is required.", SERVICE_LABEL13), 400);
26527
26151
  }
26528
26152
  const configuredClients = getClientsForServer(oktaStore.oauthClients.all(), authServerId);
26529
26153
  let clientName = "";
26530
26154
  if (configuredClients.length > 0) {
26531
26155
  const client = configuredClients.find((entry) => entry.client_id === clientId);
26532
26156
  if (!client) {
26533
- return c.html(renderErrorPage("Application not found", `The client_id '${clientId}' is not registered.`, SERVICE_LABEL13), 400);
26157
+ return c.html(await renderErrorPage("Application not found", `The client_id '${clientId}' is not registered.`, SERVICE_LABEL13), 400);
26534
26158
  }
26535
26159
  if (!matchesRedirectUri(redirectUri, client.redirect_uris)) {
26536
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL13), 400);
26160
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL13), 400);
26537
26161
  }
26538
26162
  clientName = client.name;
26539
26163
  }
26540
26164
  const users = oktaStore.users.all();
26541
26165
  const callbackPath = `${buildOAuthBasePath(authServerId)}/authorize/callback`;
26542
- const buttons = users.map((user) => renderUserButton({
26166
+ const buttons = users.map((user) => ({
26543
26167
  letter: (user.login[0] ?? "?").toUpperCase(),
26544
26168
  login: user.login,
26545
26169
  name: userDisplayName2(user),
@@ -26557,9 +26181,9 @@ function oauthRoutes7({ app, store, baseUrl, tokenMap }) {
26557
26181
  code_challenge_method: codeChallengeMethod,
26558
26182
  auth_server_id: authServerId
26559
26183
  }
26560
- })).join("\n");
26561
- const subtitle = clientName ? `Sign in to <strong>${escapeHtml(clientName)}</strong> with your Okta account.` : "Choose a seeded user to continue.";
26562
- return c.html(renderCardPage("Sign in with Okta", subtitle, users.length > 0 ? buttons : '<p class="empty">No users in the emulator store.</p>', SERVICE_LABEL13));
26184
+ }));
26185
+ const subtitle = clientName ? ["Sign in to ", { strong: clientName }, " with your Okta account."] : "Choose a seeded user to continue.";
26186
+ return c.html(await renderSignInPage("Sign in with Okta", subtitle, buttons, SERVICE_LABEL13));
26563
26187
  };
26564
26188
  app.get("/oauth2/v1/authorize", (c) => renderAuthorizePage(c, ORG_AUTH_SERVER_ID));
26565
26189
  app.get("/oauth2/:authServerId/v1/authorize", (c) => renderAuthorizePage(c, c.req.param("authServerId")));
@@ -26578,20 +26202,20 @@ function oauthRoutes7({ app, store, baseUrl, tokenMap }) {
26578
26202
  const codeChallenge = bodyStr(body.code_challenge);
26579
26203
  const codeChallengeMethod = bodyStr(body.code_challenge_method);
26580
26204
  if (!redirectUri) {
26581
- return c.html(renderErrorPage("Missing redirect URI", "The redirect_uri parameter is required.", SERVICE_LABEL13), 400);
26205
+ return c.html(await renderErrorPage("Missing redirect URI", "The redirect_uri parameter is required.", SERVICE_LABEL13), 400);
26582
26206
  }
26583
26207
  const user = findUserByRef(oktaStore, userRef);
26584
26208
  if (!user) {
26585
- return c.html(renderErrorPage("Unknown user", "The selected user is not available.", SERVICE_LABEL13), 400);
26209
+ return c.html(await renderErrorPage("Unknown user", "The selected user is not available.", SERVICE_LABEL13), 400);
26586
26210
  }
26587
26211
  const configuredClients = getClientsForServer(oktaStore.oauthClients.all(), authServerId);
26588
26212
  if (configuredClients.length > 0) {
26589
26213
  const client = configuredClients.find((entry) => entry.client_id === clientId);
26590
26214
  if (!client) {
26591
- return c.html(renderErrorPage("Application not found", `The client_id '${clientId}' is not registered.`, SERVICE_LABEL13), 400);
26215
+ return c.html(await renderErrorPage("Application not found", `The client_id '${clientId}' is not registered.`, SERVICE_LABEL13), 400);
26592
26216
  }
26593
26217
  if (!matchesRedirectUri(redirectUri, client.redirect_uris)) {
26594
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL13), 400);
26218
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL13), 400);
26595
26219
  }
26596
26220
  }
26597
26221
  const code = randomBytes(20).toString("hex");
@@ -26608,7 +26232,7 @@ function oauthRoutes7({ app, store, baseUrl, tokenMap }) {
26608
26232
  });
26609
26233
  debug("okta.oauth", `[callback] code=${code.slice(0, 8)}... user=${user.login} server=${authServerId}`);
26610
26234
  if (responseMode === "form_post") {
26611
- return c.html(renderFormPostPage(redirectUri, { code, state }, SERVICE_LABEL13));
26235
+ return c.html(await renderFormPostPage(redirectUri, { code, state }, SERVICE_LABEL13));
26612
26236
  }
26613
26237
  const url = new URL(redirectUri);
26614
26238
  url.searchParams.set("code", code);
@@ -27823,82 +27447,83 @@ function contactRoutes(ctx) {
27823
27447
 
27824
27448
  // ../http/provider/dist/vendor/resend/routes/inbox.js
27825
27449
  var SERVICE_LABEL8 = "Resend";
27450
+ var NAV = [{ label: "Inbox", href: "/inbox", current: true }];
27451
+ function statusOf2(status) {
27452
+ return status === "delivered" ? "ok" : status === "bounced" ? "error" : "neutral";
27453
+ }
27826
27454
  function inboxRoutes(ctx) {
27827
27455
  const { app, store } = ctx;
27828
27456
  const rs = () => getResendStore(store);
27829
- app.get("/inbox", (c) => {
27457
+ app.get("/inbox", async (c) => {
27830
27458
  const emails = rs().emails.all().reverse();
27831
- let body = "";
27832
- if (emails.length === 0) {
27833
- body = `<div class="empty">No emails sent yet. Use POST /emails to send one.</div>`;
27834
- } else {
27835
- for (const email of emails) {
27836
- const letter = (email.from?.[0] ?? "?").toUpperCase();
27837
- const statusClass = email.status === "delivered" ? "badge-granted" : email.status === "bounced" ? "badge-denied" : "badge-requested";
27838
- body += `<a href="/inbox/${escapeAttr(email.uuid)}" class="app-link">
27839
- <span class="org-icon">${escapeHtml(letter)}</span>
27840
- <span class="user-text">
27841
- <span class="org-name">${escapeHtml(email.subject)}</span>
27842
- <span class="user-meta">${escapeHtml(email.from)} &rarr; ${escapeHtml(email.to.join(", "))}</span>
27843
- </span>
27844
- <span class="badge ${statusClass}">${escapeHtml(email.status)}</span>
27845
- </a>`;
27846
- }
27847
- }
27848
- const html = renderCardPage("Inbox", `${emails.length} email${emails.length !== 1 ? "s" : ""} sent`, body, SERVICE_LABEL8);
27849
- return c.html(html);
27850
- });
27851
- app.get("/inbox/:id", (c) => {
27459
+ return c.html(await renderProviderPage({
27460
+ layout: "app",
27461
+ service: SERVICE_LABEL8,
27462
+ title: "Inbox",
27463
+ description: `${emails.length} email${emails.length !== 1 ? "s" : ""} sent`,
27464
+ nav: NAV,
27465
+ blocks: [
27466
+ {
27467
+ type: "links",
27468
+ empty: "No emails sent yet. Use POST /emails to send one.",
27469
+ items: emails.map((email) => ({
27470
+ href: `/inbox/${email.uuid}`,
27471
+ title: email.subject,
27472
+ description: `${email.from} \u2192 ${email.to.join(", ")}`,
27473
+ letter: (email.from?.[0] ?? "?").toUpperCase(),
27474
+ status: { label: email.status, status: statusOf2(email.status) }
27475
+ }))
27476
+ }
27477
+ ]
27478
+ }));
27479
+ });
27480
+ app.get("/inbox/:id", async (c) => {
27852
27481
  const id = c.req.param("id");
27853
27482
  const email = rs().emails.findOneBy("uuid", id);
27854
27483
  if (!email) {
27855
- const html2 = renderCardPage("Not Found", "The requested email was not found.", `<div class="empty">Email not found</div>`, SERVICE_LABEL8);
27856
- return c.html(html2, 404);
27857
- }
27858
- const statusClass = email.status === "delivered" ? "badge-granted" : email.status === "bounced" ? "badge-denied" : "badge-requested";
27859
- let tagsHtml = "";
27484
+ return c.html(await renderProviderPage({
27485
+ layout: "app",
27486
+ service: SERVICE_LABEL8,
27487
+ title: "Not Found",
27488
+ nav: NAV,
27489
+ blocks: [{ type: "empty", title: "Email not found", description: "The requested email was not found." }]
27490
+ }), 404);
27491
+ }
27492
+ const details = [
27493
+ { label: "Status", value: chip(email.status, statusOf2(email.status)) },
27494
+ { label: "From", value: email.from },
27495
+ { label: "To", value: email.to.join(", ") }
27496
+ ];
27497
+ if (email.cc.length > 0)
27498
+ details.push({ label: "Cc", value: email.cc.join(", ") });
27499
+ if (email.bcc.length > 0)
27500
+ details.push({ label: "Bcc", value: email.bcc.join(", ") });
27501
+ details.push({ label: "Created", value: email.created_at, mono: true });
27502
+ details.push({ label: "Last event", value: email.last_event });
27503
+ if (email.scheduled_at)
27504
+ details.push({ label: "Scheduled", value: email.scheduled_at, mono: true });
27505
+ const blocks = [{ type: "details", items: details }];
27860
27506
  if (email.tags.length > 0) {
27861
- tagsHtml = `<div class="info-text">`;
27862
- for (const tag of email.tags) {
27863
- tagsHtml += `<span class="badge badge-requested">${escapeHtml(tag.name)}: ${escapeHtml(tag.value)}</span> `;
27864
- }
27865
- tagsHtml += `</div>`;
27866
- }
27867
- const recipientLines = [];
27868
- recipientLines.push(`<strong>To:</strong> ${escapeHtml(email.to.join(", "))}`);
27869
- if (email.cc.length > 0) {
27870
- recipientLines.push(`<strong>Cc:</strong> ${escapeHtml(email.cc.join(", "))}`);
27871
- }
27872
- if (email.bcc.length > 0) {
27873
- recipientLines.push(`<strong>Bcc:</strong> ${escapeHtml(email.bcc.join(", "))}`);
27874
- }
27875
- const srcdocHtml = email.html ? escapeAttr(`<base target="_blank">${email.html}`) : null;
27876
- const previewContent = srcdocHtml ? `<iframe
27877
- sandbox="allow-popups allow-popups-to-escape-sandbox"
27878
- srcdoc="${srcdocHtml}"
27879
- class="s-card"
27880
- style="width:100%;min-height:300px;border:1px solid #0a3300;border-radius:8px;background:#fff;"
27881
- ></iframe>` : email.text ? `<div class="s-card"><pre class="info-text">${escapeHtml(email.text)}</pre></div>` : `<div class="empty">No content</div>`;
27882
- const body = `
27883
- <div class="org-row">
27884
- <span class="badge ${statusClass}">${escapeHtml(email.status)}</span>
27885
- <span class="user-meta">${escapeHtml(email.created_at)}</span>
27886
- </div>
27887
- <div class="s-card">
27888
- <div class="perm-list">
27889
- <li><strong>From:</strong> ${escapeHtml(email.from)}</li>
27890
- ${recipientLines.map((line) => `<li>${line}</li>`).join("\n ")}
27891
- </div>
27892
- </div>
27893
- ${tagsHtml}
27894
- <div class="section-heading">Preview</div>
27895
- ${previewContent}
27896
- <div class="info-text">
27897
- <strong>Last event:</strong> ${escapeHtml(email.last_event)}
27898
- ${email.scheduled_at ? ` | <strong>Scheduled:</strong> ${escapeHtml(email.scheduled_at)}` : ""}
27899
- </div>`;
27900
- const html = renderCardPage(email.subject, `Email ${escapeHtml(email.uuid)}`, body, SERVICE_LABEL8);
27901
- return c.html(html);
27507
+ blocks.push({
27508
+ type: "chips",
27509
+ chips: email.tags.map((tag) => ({ label: `${tag.name}: ${tag.value}`, status: "neutral" }))
27510
+ });
27511
+ }
27512
+ blocks.push({
27513
+ type: "section",
27514
+ title: "Preview",
27515
+ blocks: [
27516
+ email.html ? { type: "frame", title: `Preview of ${email.subject}`, html: email.html } : email.text ? { type: "code", label: "text/plain", code: email.text } : { type: "empty", title: "No content" }
27517
+ ]
27518
+ });
27519
+ return c.html(await renderProviderPage({
27520
+ layout: "app",
27521
+ service: SERVICE_LABEL8,
27522
+ title: email.subject,
27523
+ description: `Email ${email.uuid}`,
27524
+ nav: NAV,
27525
+ blocks
27526
+ }));
27902
27527
  });
27903
27528
  }
27904
27529
 
@@ -30288,7 +29913,7 @@ function isPendingCodeExpired4(p, clockNow = Date.now) {
30288
29913
  }
30289
29914
  function oauthRoutes8({ app, store, tokenMap }) {
30290
29915
  const ss = () => getSlackStore(store);
30291
- app.get("/oauth/v2/authorize", (c) => {
29916
+ app.get("/oauth/v2/authorize", async (c) => {
30292
29917
  const client_id = c.req.query("client_id") ?? "";
30293
29918
  const redirect_uri = c.req.query("redirect_uri") ?? "";
30294
29919
  const scope = c.req.query("scope") ?? "";
@@ -30299,17 +29924,17 @@ function oauthRoutes8({ app, store, tokenMap }) {
30299
29924
  if (appsConfigured) {
30300
29925
  const oauthApp = ss().oauthApps.findOneBy("client_id", client_id);
30301
29926
  if (!oauthApp) {
30302
- return c.html(renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL9), 400);
29927
+ return c.html(await renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL9), 400);
30303
29928
  }
30304
29929
  if (redirect_uri && !matchesRedirectUri(redirect_uri, oauthApp.redirect_uris)) {
30305
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL9), 400);
29930
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL9), 400);
30306
29931
  }
30307
29932
  appName = oauthApp.name;
30308
29933
  }
30309
- const subtitleText = appName ? `Authorize <strong>${escapeHtml(appName)}</strong> to access your Slack workspace.` : "Choose a user to authorize.";
29934
+ const subtitleText = appName ? ["Authorize ", { strong: appName }, " to access your Slack workspace."] : "Choose a user to authorize.";
30310
29935
  const users = ss().users.all().filter((u) => !u.deleted && !u.is_bot);
30311
29936
  const userButtons = users.map((user) => {
30312
- return renderUserButton({
29937
+ return {
30313
29938
  letter: (user.name[0] ?? "?").toUpperCase(),
30314
29939
  login: user.name,
30315
29940
  name: user.real_name,
@@ -30323,10 +29948,9 @@ function oauthRoutes8({ app, store, tokenMap }) {
30323
29948
  state,
30324
29949
  client_id
30325
29950
  }
30326
- });
30327
- }).join("\n");
30328
- const body = users.length === 0 ? '<p class="empty">No users in the emulator store.</p>' : userButtons;
30329
- return c.html(renderCardPage("Sign in to Slack", subtitleText, body, SERVICE_LABEL9));
29951
+ };
29952
+ });
29953
+ return c.html(await renderSignInPage("Sign in to Slack", subtitleText, userButtons, SERVICE_LABEL9));
30330
29954
  });
30331
29955
  app.post("/oauth/v2/authorize/callback", async (c) => {
30332
29956
  const body = await c.req.parseBody();
@@ -32043,34 +31667,15 @@ function viewPreview(view) {
32043
31667
  return view.external_id;
32044
31668
  return `${view.blocks.length} ${view.blocks.length === 1 ? "block" : "blocks"}`;
32045
31669
  }
32046
- function renderSection(title, body) {
32047
- return `<section class="inspector-section">
32048
- <h2>${escapeHtml(title)}</h2>
32049
- ${body}
32050
- </section>`;
32051
- }
32052
- function renderTable(headers, rows, empty) {
32053
- if (rows.length === 0)
32054
- return `<p class="inspector-empty">${escapeHtml(empty)}</p>`;
32055
- const headerHtml = headers.map((header) => `<th>${escapeHtml(header)}</th>`).join("");
32056
- const rowsHtml = rows.map((row) => `<tr>${row.map((cell) => `<td>${cell}</td>`).join("")}</tr>`).join("\n");
32057
- return `<table class="inspector-table">
32058
- <thead><tr>${headerHtml}</tr></thead>
32059
- <tbody>
32060
- ${rowsHtml}
32061
- </tbody>
32062
- </table>`;
32063
- }
31670
+ var TONE = { granted: "ok", requested: "neutral", denied: "error" };
32064
31671
  function badge(label, tone = "requested") {
32065
- return `<span class="badge badge-${tone}">${escapeHtml(label)}</span>`;
31672
+ return chip(label, TONE[tone]);
32066
31673
  }
32067
31674
  function renderReactionBadges(reactions) {
32068
- if (reactions.length === 0)
32069
- return "";
32070
- return reactions.map((reaction) => badge(`:${reaction.name}: ${reaction.count}`, "granted")).join(" ");
31675
+ return reactions.map((reaction) => badge(`:${reaction.name}: ${reaction.count}`, "granted"));
32071
31676
  }
32072
31677
  function linkCell2(href, label) {
32073
- return `<a href="${escapeAttr(href)}">${escapeHtml(label)}</a>`;
31678
+ return { link: label, href };
32074
31679
  }
32075
31680
  function scopePreview(scopes) {
32076
31681
  if (!scopes || scopes.length === 0)
@@ -32116,13 +31721,13 @@ function sortedChannels(channels) {
32116
31721
  function inspectorRoutes3(ctx) {
32117
31722
  const { app, store, webhooks } = ctx;
32118
31723
  const ss = () => getSlackStore(store);
32119
- app.get("/", (c) => {
31724
+ app.get("/", async (c) => {
32120
31725
  const team = ss().teams.all()[0];
32121
31726
  const requestedTab = c.req.query("tab") ?? "messages";
32122
31727
  const activeTab = INSPECTOR_TABS.some((tab) => tab.id === requestedTab) ? requestedTab : "messages";
32123
31728
  const users = buildUserMap();
32124
31729
  const body = activeTab === "channels" ? renderChannelsView(users) : activeTab === "files" ? renderFilesView(users) : activeTab === "views" ? renderViewsView(users) : activeTab === "auth" ? renderAuthView() : activeTab === "events" ? renderEventsView() : renderMessagesView(c.req.query("channel") ?? "", users);
32125
- return c.html(renderInspectorPage(`${team?.name ?? "Slack"} - Message Inspector`, INSPECTOR_TABS, activeTab, body, SERVICE_LABEL10));
31730
+ return c.html(await renderInspectorPage(`${team?.name ?? "Slack"} - Message Inspector`, INSPECTOR_TABS, activeTab, body, SERVICE_LABEL10));
32126
31731
  });
32127
31732
  function buildUserMap() {
32128
31733
  const userMap = /* @__PURE__ */ new Map();
@@ -32142,7 +31747,7 @@ function inspectorRoutes3(ctx) {
32142
31747
  const visibleChannels = channels.filter((ch) => !ch.is_archived);
32143
31748
  const activeChannel = channels.find((ch) => ch.channel_id === requestedChannel) ?? visibleChannels[0] ?? channels[0];
32144
31749
  if (!activeChannel) {
32145
- return renderSection("Messages", '<p class="inspector-empty">No conversations in the emulator store.</p>');
31750
+ return [section("Messages", { type: "empty", title: "No conversations in the emulator store." })];
32146
31751
  }
32147
31752
  const channelMessages = ss().messages.findBy("channel_id", activeChannel.channel_id).sort((a, b) => b.ts > a.ts ? 1 : -1);
32148
31753
  const messages = channelMessages.slice(0, 50);
@@ -32157,72 +31762,72 @@ function inspectorRoutes3(ctx) {
32157
31762
  const stats = `${ss().users.all().length} users, ${channels.length} conversations, ${ss().messages.all().length} messages, ${ss().views.all().length} views`;
32158
31763
  const body = [
32159
31764
  renderConversationSelector(channels, activeChannel.channel_id),
32160
- renderSection(`Messages In ${channelLabel(activeChannel)}`, `<p class="info-text">${escapeHtml(activeChannel.topic.value || "No topic set")} - ${escapeHtml(stats)}</p>` + renderMessagesTable(messages, users, "No messages yet. Post one with chat.postMessage or an incoming webhook.", store.now)),
32161
- renderSection("Threads", renderMessagesTable(threads, users, "No thread replies for this conversation.", store.now)),
32162
- renderSection("Ephemeral", renderEphemeralTable(ephemeralMessages, users, "No ephemeral messages for this conversation.", store.now)),
32163
- renderSection("Scheduled", renderScheduledTable(scheduledMessages, users, "No scheduled messages for this conversation.")),
32164
- renderSection("Pins", renderPinsTable(pins, channelMessages, users, "No pins for this conversation.")),
32165
- renderSection("Bookmarks", renderBookmarksTable(bookmarks, "No bookmarks for this conversation.")),
32166
- renderSection("App Home", renderViewsTable(homeViews, users, "No App Home views have been published.")),
32167
- renderSection("Modals", renderViewsTable(modalViews, users, "No modal views have been opened."))
31765
+ section(`Messages In ${channelLabel(activeChannel)}`, { type: "text", text: `${activeChannel.topic.value || "No topic set"} - ${stats}` }, renderMessagesTable(messages, users, "No messages yet. Post one with chat.postMessage or an incoming webhook.", store.now)),
31766
+ section("Threads", renderMessagesTable(threads, users, "No thread replies for this conversation.", store.now)),
31767
+ section("Ephemeral", renderEphemeralTable(ephemeralMessages, users, "No ephemeral messages for this conversation.", store.now)),
31768
+ section("Scheduled", renderScheduledTable(scheduledMessages, users, "No scheduled messages for this conversation.")),
31769
+ section("Pins", renderPinsTable(pins, channelMessages, users, "No pins for this conversation.")),
31770
+ section("Bookmarks", renderBookmarksTable(bookmarks, "No bookmarks for this conversation.")),
31771
+ section("App Home", renderViewsTable(homeViews, users, "No App Home views have been published.")),
31772
+ section("Modals", renderViewsTable(modalViews, users, "No modal views have been opened."))
32168
31773
  ];
32169
- return body.join("\n");
31774
+ return body;
32170
31775
  }
32171
31776
  function renderConversationSelector(channels, activeChannelId) {
32172
31777
  const rows = channels.map((ch) => [
32173
31778
  ch.channel_id === activeChannelId ? badge("active", "granted") : "",
32174
31779
  linkCell2(`/?tab=messages&channel=${encodeURIComponent(ch.channel_id)}`, channelLabel(ch)),
32175
- escapeHtml(channelKind(ch)),
32176
- escapeHtml(String(ch.num_members)),
31780
+ channelKind(ch),
31781
+ String(ch.num_members),
32177
31782
  ch.is_archived ? badge("archived", "denied") : badge("open", "granted")
32178
31783
  ]);
32179
- return renderSection("Conversations", renderTable(["", "Name", "Type", "Members", "State"], rows, "No conversations in the emulator store."));
31784
+ return section("Conversations", table(["", "Name", "Type", "Members", "State"], rows, "No conversations in the emulator store."));
32180
31785
  }
32181
31786
  function renderChannelsView(users) {
32182
31787
  const channels = sortedChannels(ss().channels.all());
32183
31788
  const conversations = channels.filter((channel) => !channel.is_im && !channel.is_mpim);
32184
31789
  const dms = channels.filter((channel) => channel.is_im || channel.is_mpim);
32185
31790
  return [
32186
- renderSection("Channels", renderTable(["ID", "Name", "Type", "Members", "Topic", "Purpose", "State"], conversations.map((ch) => [
32187
- escapeHtml(ch.channel_id),
31791
+ section("Channels", table(["ID", "Name", "Type", "Members", "Topic", "Purpose", "State"], conversations.map((ch) => [
31792
+ ch.channel_id,
32188
31793
  linkCell2(`/?tab=messages&channel=${encodeURIComponent(ch.channel_id)}`, channelLabel(ch)),
32189
- escapeHtml(channelKind(ch)),
32190
- escapeHtml(ch.members.map((member) => userLabel2(users, member)).join(", ")),
32191
- escapeHtml(ch.topic.value),
32192
- escapeHtml(ch.purpose.value),
31794
+ channelKind(ch),
31795
+ ch.members.map((member) => userLabel2(users, member)).join(", "),
31796
+ ch.topic.value,
31797
+ ch.purpose.value,
32193
31798
  ch.is_archived ? badge("archived", "denied") : badge("open", "granted")
32194
31799
  ]), "No channels in the emulator store.")),
32195
- renderSection("Direct Messages", renderTable(["ID", "Name", "Type", "Members", "Open State"], dms.map((ch) => [
32196
- escapeHtml(ch.channel_id),
31800
+ section("Direct Messages", table(["ID", "Name", "Type", "Members", "Open State"], dms.map((ch) => [
31801
+ ch.channel_id,
32197
31802
  linkCell2(`/?tab=messages&channel=${encodeURIComponent(ch.channel_id)}`, channelLabel(ch)),
32198
- escapeHtml(channelKind(ch)),
32199
- escapeHtml(ch.members.map((member) => userLabel2(users, member)).join(", ")),
32200
- escapeHtml(openStateLabel(ch, users))
31803
+ channelKind(ch),
31804
+ ch.members.map((member) => userLabel2(users, member)).join(", "),
31805
+ openStateLabel(ch, users)
32201
31806
  ]), "No DMs or MPIMs in the emulator store."))
32202
- ].join("\n");
31807
+ ];
32203
31808
  }
32204
31809
  function renderFilesView(users) {
32205
31810
  const files = ss().files.all().sort((a, b) => b.created - a.created || b.id - a.id);
32206
31811
  const sessions = ss().fileUploadSessions.all().filter((session) => !session.completed).sort((a, b) => b.id - a.id);
32207
31812
  return [
32208
- renderSection("Files", renderTable(["ID", "Title", "User", "Channels", "Size", "State", "Created"], files.map((file) => [
32209
- escapeHtml(file.file_id),
32210
- escapeHtml(file.title || file.name),
32211
- escapeHtml(userLabel2(users, file.user)),
32212
- escapeHtml([...file.channels, ...file.groups, ...file.ims].join(", ")),
32213
- escapeHtml(String(file.size)),
31813
+ section("Files", table(["ID", "Title", "User", "Channels", "Size", "State", "Created"], files.map((file) => [
31814
+ file.file_id,
31815
+ file.title || file.name,
31816
+ userLabel2(users, file.user),
31817
+ [...file.channels, ...file.groups, ...file.ims].join(", "),
31818
+ String(file.size),
32214
31819
  file.deleted ? badge("deleted", "denied") : badge("available", "granted"),
32215
- escapeHtml(new Date(file.created * 1e3).toISOString())
31820
+ new Date(file.created * 1e3).toISOString()
32216
31821
  ]), "No completed files in the emulator store.")),
32217
- renderSection("Pending Uploads", renderTable(["File ID", "Filename", "Title", "Length", "Uploaded", "Completed"], sessions.map((session) => [
32218
- escapeHtml(session.file_id),
32219
- escapeHtml(session.filename),
32220
- escapeHtml(session.title),
32221
- escapeHtml(String(session.length)),
31822
+ section("Pending Uploads", table(["File ID", "Filename", "Title", "Length", "Uploaded", "Completed"], sessions.map((session) => [
31823
+ session.file_id,
31824
+ session.filename,
31825
+ session.title,
31826
+ String(session.length),
32222
31827
  session.uploaded ? badge("uploaded", "granted") : badge("pending"),
32223
31828
  session.completed ? badge("complete", "granted") : badge("pending")
32224
31829
  ]), "No pending external upload sessions."))
32225
- ].join("\n");
31830
+ ];
32226
31831
  }
32227
31832
  function renderViewsView(users) {
32228
31833
  const views = ss().views.all().sort((a, b) => b.updated - a.updated || b.id - a.id);
@@ -32230,20 +31835,20 @@ function inspectorRoutes3(ctx) {
32230
31835
  const modalViews = views.filter((view) => view.type === "modal");
32231
31836
  const triggers = ss().viewTriggers.all().sort((a, b) => b.expires_at - a.expires_at || b.id - a.id);
32232
31837
  return [
32233
- renderSection("App Home", renderViewsTable(homeViews, users, "No App Home views have been published.")),
32234
- renderSection("Modals", renderViewsTable(modalViews, users, "No modal views have been opened.")),
32235
- renderSection("Trigger IDs", renderTriggerTable(triggers, users, store.now))
32236
- ].join("\n");
31838
+ section("App Home", renderViewsTable(homeViews, users, "No App Home views have been published.")),
31839
+ section("Modals", renderViewsTable(modalViews, users, "No modal views have been opened.")),
31840
+ section("Trigger IDs", renderTriggerTable(triggers, users, store.now))
31841
+ ];
32237
31842
  }
32238
31843
  function renderAuthView() {
32239
31844
  const subscriptions = webhooks.getSubscriptions("slack");
32240
31845
  return [
32241
- renderSection("OAuth Apps", renderOAuthAppsTable(ss().oauthApps.all())),
32242
- renderSection("Installations", renderInstallationsTable(ss().installations.all())),
32243
- renderSection("Tokens", renderTokensTable(ss().tokens.all())),
32244
- renderSection("Incoming Webhooks", renderIncomingWebhooksTable(ss().incomingWebhooks.all())),
32245
- renderSection("Event Subscriptions", renderSubscriptionsTable(subscriptions))
32246
- ].join("\n");
31846
+ section("OAuth Apps", renderOAuthAppsTable(ss().oauthApps.all())),
31847
+ section("Installations", renderInstallationsTable(ss().installations.all())),
31848
+ section("Tokens", renderTokensTable(ss().tokens.all())),
31849
+ section("Incoming Webhooks", renderIncomingWebhooksTable(ss().incomingWebhooks.all())),
31850
+ section("Event Subscriptions", renderSubscriptionsTable(subscriptions))
31851
+ ];
32247
31852
  }
32248
31853
  function renderEventsView() {
32249
31854
  const subscriptions = webhooks.getSubscriptions("slack");
@@ -32252,147 +31857,147 @@ function inspectorRoutes3(ctx) {
32252
31857
  const deliveries = allDeliveries.slice(0, 100);
32253
31858
  const failed = allDeliveries.filter((delivery) => !delivery.success).slice(0, 100);
32254
31859
  return [
32255
- renderSection("Event Subscriptions", renderSubscriptionsTable(subscriptions)),
32256
- renderSection("Event Deliveries", renderDeliveriesTable(deliveries, subscriptions, "No Slack event deliveries yet.")),
32257
- renderSection("Last Errors", renderDeliveriesTable(failed, subscriptions, "No failed Slack event deliveries."))
32258
- ].join("\n");
31860
+ section("Event Subscriptions", renderSubscriptionsTable(subscriptions)),
31861
+ section("Event Deliveries", renderDeliveriesTable(deliveries, subscriptions, "No Slack event deliveries yet.")),
31862
+ section("Last Errors", renderDeliveriesTable(failed, subscriptions, "No failed Slack event deliveries."))
31863
+ ];
32259
31864
  }
32260
31865
  }
32261
31866
  function renderMessagesTable(messages, users, empty, clockNow = Date.now) {
32262
- return renderTable(["Time", "User", "Message", "Reactions", "TS"], messages.map((msg) => {
31867
+ return table(["Time", "User", "Message", "Reactions", "TS"], messages.map((msg) => {
32263
31868
  const isBot = msg.subtype === "bot_message";
32264
- const richBadge = msg.text.length === 0 && ((msg.blocks?.length ?? 0) > 0 || (msg.attachments?.length ?? 0) > 0) ? ` ${badge("rich", "granted")}` : "";
32265
- const threadBadge = msg.reply_count > 0 ? ` ${badge(`${msg.reply_count} ${msg.reply_count === 1 ? "reply" : "replies"}`, "requested")}` : "";
32266
- const fileBadge = msg.files?.length ? ` ${badge(`${msg.files.length} ${msg.files.length === 1 ? "file" : "files"}`, "granted")}` : "";
32267
- const threadIndicator = msg.thread_ts && msg.thread_ts !== msg.ts ? `${badge("thread", "denied")} ` : "";
31869
+ const richBadge = msg.text.length === 0 && ((msg.blocks?.length ?? 0) > 0 || (msg.attachments?.length ?? 0) > 0) ? [badge("rich", "granted")] : [];
31870
+ const threadBadge = msg.reply_count > 0 ? [badge(`${msg.reply_count} ${msg.reply_count === 1 ? "reply" : "replies"}`, "requested")] : [];
31871
+ const fileBadge = msg.files?.length ? [badge(`${msg.files.length} ${msg.files.length === 1 ? "file" : "files"}`, "granted")] : [];
31872
+ const threadIndicator = msg.thread_ts && msg.thread_ts !== msg.ts ? [badge("thread", "denied")] : [];
32268
31873
  return [
32269
- escapeHtml(timeAgo(msg.created_at, clockNow)),
32270
- `${escapeHtml(userLabel2(users, msg.user))}${isBot ? ` ${badge("bot", "granted")}` : ""}`,
32271
- `${threadIndicator}${escapeHtml(richMessagePreview(msg))}${richBadge}${fileBadge}${threadBadge}`,
31874
+ timeAgo(msg.created_at, clockNow),
31875
+ isBot ? [userLabel2(users, msg.user), badge("bot", "granted")] : userLabel2(users, msg.user),
31876
+ [...threadIndicator, richMessagePreview(msg), ...richBadge, ...fileBadge, ...threadBadge],
32272
31877
  renderReactionBadges(msg.reactions),
32273
- escapeHtml(msg.ts)
31878
+ msg.ts
32274
31879
  ];
32275
31880
  }), empty);
32276
31881
  }
32277
31882
  function renderEphemeralTable(messages, users, empty, clockNow = Date.now) {
32278
- return renderTable(["Time", "Target", "Message", "TS"], messages.map((msg) => [
32279
- escapeHtml(timeAgo(msg.created_at, clockNow)),
32280
- `${escapeHtml(userLabel2(users, msg.target_user))} ${badge("ephemeral", "requested")}`,
32281
- escapeHtml(richMessagePreview(msg)),
32282
- escapeHtml(msg.ts)
31883
+ return table(["Time", "Target", "Message", "TS"], messages.map((msg) => [
31884
+ timeAgo(msg.created_at, clockNow),
31885
+ [userLabel2(users, msg.target_user), badge("ephemeral", "requested")],
31886
+ richMessagePreview(msg),
31887
+ msg.ts
32283
31888
  ]), empty);
32284
31889
  }
32285
31890
  function renderScheduledTable(messages, users, empty) {
32286
- return renderTable(["Post At", "User", "Message", "ID"], messages.map((msg) => [
32287
- escapeHtml(new Date(msg.post_at * 1e3).toISOString()),
32288
- escapeHtml(userLabel2(users, msg.user)),
32289
- escapeHtml(richMessagePreview(msg)),
32290
- escapeHtml(msg.scheduled_message_id)
31891
+ return table(["Post At", "User", "Message", "ID"], messages.map((msg) => [
31892
+ new Date(msg.post_at * 1e3).toISOString(),
31893
+ userLabel2(users, msg.user),
31894
+ richMessagePreview(msg),
31895
+ msg.scheduled_message_id
32291
31896
  ]), empty);
32292
31897
  }
32293
31898
  function renderPinsTable(pins, channelMessages, users, empty) {
32294
- return renderTable(["Created", "Creator", "Message", "TS"], pins.map((pin) => {
31899
+ return table(["Created", "Creator", "Message", "TS"], pins.map((pin) => {
32295
31900
  const message = channelMessages.find((candidate) => candidate.ts === pin.message_ts);
32296
31901
  return [
32297
- escapeHtml(new Date(pin.created * 1e3).toISOString()),
32298
- escapeHtml(userLabel2(users, pin.created_by)),
32299
- escapeHtml(message ? richMessagePreview(message) : pin.message_ts),
32300
- escapeHtml(pin.message_ts)
31902
+ new Date(pin.created * 1e3).toISOString(),
31903
+ userLabel2(users, pin.created_by),
31904
+ message ? richMessagePreview(message) : pin.message_ts,
31905
+ pin.message_ts
32301
31906
  ];
32302
31907
  }), empty);
32303
31908
  }
32304
31909
  function renderBookmarksTable(bookmarks, empty) {
32305
- return renderTable(["Title", "Type", "Link", "Rank"], bookmarks.map((bookmark) => [
32306
- escapeHtml(bookmark.title),
32307
- escapeHtml(bookmark.type),
32308
- escapeHtml(bookmark.link),
32309
- escapeHtml(bookmark.rank)
31910
+ return table(["Title", "Type", "Link", "Rank"], bookmarks.map((bookmark) => [
31911
+ bookmark.title,
31912
+ bookmark.type,
31913
+ bookmark.link,
31914
+ bookmark.rank
32310
31915
  ]), empty);
32311
31916
  }
32312
31917
  function renderViewsTable(views, users, empty) {
32313
- return renderTable(["ID", "Type", "User", "App", "Preview", "Hash", "Root", "Previous"], views.map((view) => [
32314
- escapeHtml(view.view_id),
31918
+ return table(["ID", "Type", "User", "App", "Preview", "Hash", "Root", "Previous"], views.map((view) => [
31919
+ view.view_id,
32315
31920
  view.type === "home" ? badge("app home", "granted") : badge("modal", "requested"),
32316
- escapeHtml(userLabel2(users, view.user_id)),
32317
- escapeHtml(view.app_id),
32318
- escapeHtml(viewPreview(view)),
32319
- escapeHtml(view.hash),
32320
- escapeHtml(view.root_view_id),
32321
- escapeHtml(view.previous_view_id ?? "")
31921
+ userLabel2(users, view.user_id),
31922
+ view.app_id,
31923
+ viewPreview(view),
31924
+ view.hash,
31925
+ view.root_view_id,
31926
+ view.previous_view_id ?? ""
32322
31927
  ]), empty);
32323
31928
  }
32324
31929
  function renderTriggerTable(triggers, users, clockNow = Date.now) {
32325
31930
  const now = Math.floor(clockNow() / 1e3);
32326
- return renderTable(["Trigger ID", "User", "App", "View", "Expires", "State"], triggers.map((trigger) => [
32327
- escapeHtml(trigger.trigger_id),
32328
- escapeHtml(userLabel2(users, trigger.user_id)),
32329
- escapeHtml(trigger.app_id),
32330
- escapeHtml(trigger.view_id ?? ""),
32331
- escapeHtml(new Date(trigger.expires_at * 1e3).toISOString()),
31931
+ return table(["Trigger ID", "User", "App", "View", "Expires", "State"], triggers.map((trigger) => [
31932
+ trigger.trigger_id,
31933
+ userLabel2(users, trigger.user_id),
31934
+ trigger.app_id,
31935
+ trigger.view_id ?? "",
31936
+ new Date(trigger.expires_at * 1e3).toISOString(),
32332
31937
  trigger.used ? badge("used", "denied") : trigger.expires_at <= now ? badge("expired", "denied") : badge("active", "granted")
32333
31938
  ]), "No local trigger ids have been generated.");
32334
31939
  }
32335
31940
  function renderOAuthAppsTable(apps) {
32336
- return renderTable(["App ID", "Client ID", "Name", "Bot", "Scopes", "User Scopes"], apps.map((app) => [
32337
- escapeHtml(app.app_id ?? ""),
32338
- escapeHtml(app.client_id),
32339
- escapeHtml(app.name),
32340
- escapeHtml(app.bot_id ?? app.bot_name ?? ""),
32341
- escapeHtml(scopePreview(app.scopes)),
32342
- escapeHtml(scopePreview(app.user_scopes))
31941
+ return table(["App ID", "Client ID", "Name", "Bot", "Scopes", "User Scopes"], apps.map((app) => [
31942
+ app.app_id ?? "",
31943
+ app.client_id,
31944
+ app.name,
31945
+ app.bot_id ?? app.bot_name ?? "",
31946
+ scopePreview(app.scopes),
31947
+ scopePreview(app.user_scopes)
32343
31948
  ]), "No OAuth apps are configured.");
32344
31949
  }
32345
31950
  function renderInstallationsTable(installations) {
32346
- return renderTable(["Installation", "App", "Team", "Bot User", "Installer", "Scopes"], installations.map((installation) => [
32347
- escapeHtml(installation.installation_id),
32348
- escapeHtml(installation.app_id),
32349
- escapeHtml(installation.team_id),
32350
- escapeHtml(installation.bot_user_id),
32351
- escapeHtml(installation.installer_user_id),
32352
- escapeHtml(scopePreview(installation.scopes))
31951
+ return table(["Installation", "App", "Team", "Bot User", "Installer", "Scopes"], installations.map((installation) => [
31952
+ installation.installation_id,
31953
+ installation.app_id,
31954
+ installation.team_id,
31955
+ installation.bot_user_id,
31956
+ installation.installer_user_id,
31957
+ scopePreview(installation.scopes)
32353
31958
  ]), "No OAuth installations have been recorded.");
32354
31959
  }
32355
31960
  function renderTokensTable(tokens) {
32356
- return renderTable(["Token", "Type", "Team", "User", "App", "Bot", "Scopes"], tokens.map((token2) => [
32357
- escapeHtml(maskToken2(token2.token)),
32358
- escapeHtml(token2.token_type),
32359
- escapeHtml(token2.team_id),
32360
- escapeHtml(token2.user_id),
32361
- escapeHtml(token2.app_id ?? ""),
32362
- escapeHtml(token2.bot_id ?? token2.bot_user_id ?? ""),
32363
- escapeHtml(scopePreview(token2.scopes))
31961
+ return table(["Token", "Type", "Team", "User", "App", "Bot", "Scopes"], tokens.map((token2) => [
31962
+ maskToken2(token2.token),
31963
+ token2.token_type,
31964
+ token2.team_id,
31965
+ token2.user_id,
31966
+ token2.app_id ?? "",
31967
+ token2.bot_id ?? token2.bot_user_id ?? "",
31968
+ scopePreview(token2.scopes)
32364
31969
  ]), "No Slack token records have been seeded or exchanged.");
32365
31970
  }
32366
31971
  function renderIncomingWebhooksTable(webhooks) {
32367
- return renderTable(["Token", "Team", "Bot", "Default Channel", "Label", "URL"], webhooks.map((webhook) => [
32368
- escapeHtml(maskToken2(webhook.token)),
32369
- escapeHtml(webhook.team_id),
32370
- escapeHtml(webhook.bot_id),
32371
- escapeHtml(webhook.default_channel),
32372
- escapeHtml(webhook.label),
32373
- escapeHtml(webhook.url)
31972
+ return table(["Token", "Team", "Bot", "Default Channel", "Label", "URL"], webhooks.map((webhook) => [
31973
+ maskToken2(webhook.token),
31974
+ webhook.team_id,
31975
+ webhook.bot_id,
31976
+ webhook.default_channel,
31977
+ webhook.label,
31978
+ webhook.url
32374
31979
  ]), "No incoming webhooks are configured.");
32375
31980
  }
32376
31981
  function renderSubscriptionsTable(subscriptions) {
32377
- return renderTable(["ID", "URL", "Events", "State"], subscriptions.map((subscription) => [
32378
- escapeHtml(String(subscription.id)),
32379
- escapeHtml(subscription.url),
32380
- escapeHtml(subscription.events.join(", ")),
31982
+ return table(["ID", "URL", "Events", "State"], subscriptions.map((subscription) => [
31983
+ String(subscription.id),
31984
+ subscription.url,
31985
+ subscription.events.join(", "),
32381
31986
  subscription.active ? badge("active", "granted") : badge("inactive", "denied")
32382
31987
  ]), "No Slack event subscriptions are registered.");
32383
31988
  }
32384
31989
  function renderDeliveriesTable(deliveries, subscriptions, empty) {
32385
31990
  const subscriptionsById = new Map(subscriptions.map((subscription) => [subscription.id, subscription]));
32386
- return renderTable(["ID", "Event", "Hook", "URL", "Status", "Duration", "Delivered"], deliveries.map((delivery) => {
31991
+ return table(["ID", "Event", "Hook", "URL", "Status", "Duration", "Delivered"], deliveries.map((delivery) => {
32387
31992
  const subscription = subscriptionsById.get(delivery.hook_id);
32388
31993
  return [
32389
- escapeHtml(String(delivery.id)),
32390
- escapeHtml(delivery.event),
32391
- escapeHtml(String(delivery.hook_id)),
32392
- escapeHtml(subscription?.url ?? ""),
31994
+ String(delivery.id),
31995
+ delivery.event,
31996
+ String(delivery.hook_id),
31997
+ subscription?.url ?? "",
32393
31998
  delivery.success ? badge(String(delivery.status_code ?? "ok"), "granted") : badge(String(delivery.status_code ?? "failed"), "denied"),
32394
- escapeHtml(delivery.duration === null ? "" : `${delivery.duration}ms`),
32395
- escapeHtml(delivery.delivered_at)
31999
+ delivery.duration === null ? "" : `${delivery.duration}ms`,
32000
+ delivery.delivered_at
32396
32001
  ];
32397
32002
  }), empty);
32398
32003
  }
@@ -34536,128 +34141,119 @@ var TABS3 = [
34536
34141
  ];
34537
34142
  function inspectorRoutes4({ app, store }) {
34538
34143
  const ts = () => getTwilioStore(store);
34539
- app.get("/", (c) => {
34144
+ app.get("/", async (c) => {
34540
34145
  const requested = c.req.query("tab") ?? "messages";
34541
34146
  const active = TABS3.some((tab) => tab.id === requested) ? requested : "messages";
34542
34147
  const body = active === "verify" ? verifyView() : active === "calls" ? callsView() : active === "conversations" ? conversationsView() : active === "numbers" ? numbersView() : active === "services" ? servicesView() : active === "auth" ? authView() : active === "webhooks" ? webhooksView() : messagesView();
34543
- return c.html(renderInspectorPage("Twilio Inspector", TABS3, active, body, SERVICE_LABEL11));
34148
+ return c.html(await renderInspectorPage("Twilio Inspector", TABS3, active, body, SERVICE_LABEL11));
34544
34149
  });
34545
34150
  function messagesView() {
34546
34151
  const rows = ts().messages.all().sort((a, b) => b.id - a.id).map((message) => [
34547
- escapeHtml(message.sid),
34548
- escapeHtml(message.direction),
34549
- escapeHtml(message.status),
34550
- escapeHtml(message.from ?? ""),
34551
- escapeHtml(message.to),
34552
- escapeHtml(message.body ?? ""),
34553
- escapeHtml(message.created_at)
34152
+ message.sid,
34153
+ message.direction,
34154
+ chip(message.status),
34155
+ message.from ?? "",
34156
+ message.to,
34157
+ message.body ?? "",
34158
+ message.created_at
34554
34159
  ]);
34555
- return section2("Messages", table2(["SID", "Direction", "Status", "From", "To", "Body", "Created"], rows, "No messages."));
34160
+ return [section("Messages", table(["SID", "Direction", "Status", "From", "To", "Body", "Created"], rows, "No messages."))];
34556
34161
  }
34557
34162
  function verifyView() {
34558
- const serviceRows = ts().verifyServices.all().map((service) => [escapeHtml(service.sid), escapeHtml(service.friendly_name), escapeHtml(service.code)]);
34163
+ const serviceRows = ts().verifyServices.all().map((service) => [service.sid, service.friendly_name, service.code]);
34559
34164
  const verificationRows = ts().verifications.all().sort((a, b) => b.id - a.id).map((verification) => [
34560
- escapeHtml(verification.sid),
34561
- escapeHtml(verification.to),
34562
- escapeHtml(verification.channel),
34563
- escapeHtml(verification.status),
34564
- escapeHtml(verification.code),
34565
- escapeHtml(String(verification.attempts))
34165
+ verification.sid,
34166
+ verification.to,
34167
+ verification.channel,
34168
+ chip(verification.status),
34169
+ verification.code,
34170
+ String(verification.attempts)
34566
34171
  ]);
34567
- return section2("Verify Services", table2(["SID", "Name", "Code"], serviceRows, "No Verify services.")) + section2("Verifications", table2(["SID", "To", "Channel", "Status", "Code", "Attempts"], verificationRows, "No verifications."));
34172
+ return [
34173
+ section("Verify Services", table(["SID", "Name", "Code"], serviceRows, "No Verify services.")),
34174
+ section("Verifications", table(["SID", "To", "Channel", "Status", "Code", "Attempts"], verificationRows, "No verifications."))
34175
+ ];
34568
34176
  }
34569
34177
  function callsView() {
34570
34178
  const rows = ts().calls.all().sort((a, b) => b.id - a.id).map((call) => [
34571
- escapeHtml(call.sid),
34572
- escapeHtml(call.direction),
34573
- escapeHtml(call.status),
34574
- escapeHtml(call.from),
34575
- escapeHtml(call.to),
34576
- escapeHtml(call.twiml_steps.join(", ")),
34577
- escapeHtml(call.created_at)
34179
+ call.sid,
34180
+ call.direction,
34181
+ chip(call.status),
34182
+ call.from,
34183
+ call.to,
34184
+ call.twiml_steps.join(", "),
34185
+ call.created_at
34578
34186
  ]);
34579
- return section2("Calls", table2(["SID", "Direction", "Status", "From", "To", "TwiML", "Created"], rows, "No calls."));
34187
+ return [section("Calls", table(["SID", "Direction", "Status", "From", "To", "TwiML", "Created"], rows, "No calls."))];
34580
34188
  }
34581
34189
  function numbersView() {
34582
34190
  const rows = ts().phoneNumbers.all().map((number) => [
34583
- escapeHtml(number.sid),
34584
- escapeHtml(number.phone_number),
34585
- escapeHtml(number.friendly_name),
34586
- escapeHtml(number.sms_url ?? ""),
34587
- escapeHtml(number.voice_url ?? "")
34191
+ number.sid,
34192
+ number.phone_number,
34193
+ number.friendly_name,
34194
+ number.sms_url ?? "",
34195
+ number.voice_url ?? ""
34588
34196
  ]);
34589
- return section2("Phone Numbers", table2(["SID", "Number", "Name", "SMS URL", "Voice URL"], rows, "No phone numbers."));
34197
+ return [section("Phone Numbers", table(["SID", "Number", "Name", "SMS URL", "Voice URL"], rows, "No phone numbers."))];
34590
34198
  }
34591
34199
  function conversationsView() {
34592
34200
  const serviceRows = ts().conversationServices.all().map((service) => [
34593
- escapeHtml(service.sid),
34594
- escapeHtml(service.friendly_name),
34595
- escapeHtml(String(ts().conversations.count((item) => item.service_sid === service.sid)))
34201
+ service.sid,
34202
+ service.friendly_name,
34203
+ String(ts().conversations.count((item) => item.service_sid === service.sid))
34596
34204
  ]);
34597
34205
  const conversationRows = ts().conversations.all().map((conversation) => [
34598
- escapeHtml(conversation.sid),
34599
- escapeHtml(conversation.friendly_name ?? ""),
34600
- escapeHtml(conversation.unique_name ?? ""),
34601
- escapeHtml(conversation.state),
34602
- escapeHtml(String(ts().conversationParticipants.count((item) => item.conversation_sid === conversation.sid))),
34603
- escapeHtml(String(ts().conversationMessages.count((item) => item.conversation_sid === conversation.sid)))
34206
+ conversation.sid,
34207
+ conversation.friendly_name ?? "",
34208
+ conversation.unique_name ?? "",
34209
+ chip(conversation.state),
34210
+ String(ts().conversationParticipants.count((item) => item.conversation_sid === conversation.sid)),
34211
+ String(ts().conversationMessages.count((item) => item.conversation_sid === conversation.sid))
34604
34212
  ]);
34605
- return section2("Conversation Services", table2(["SID", "Name", "Conversations"], serviceRows, "No Conversation Services.")) + section2("Conversations", table2(["SID", "Name", "Unique Name", "State", "Participants", "Messages"], conversationRows, "No conversations."));
34213
+ return [
34214
+ section("Conversation Services", table(["SID", "Name", "Conversations"], serviceRows, "No Conversation Services.")),
34215
+ section("Conversations", table(["SID", "Name", "Unique Name", "State", "Participants", "Messages"], conversationRows, "No conversations."))
34216
+ ];
34606
34217
  }
34607
34218
  function servicesView() {
34608
34219
  const messagingRows = ts().messagingServices.all().map((service) => [
34609
- escapeHtml(service.sid),
34610
- escapeHtml(service.friendly_name),
34611
- escapeHtml(String(ts().messagingServicePhoneNumbers.count((item) => item.service_sid === service.sid))),
34612
- escapeHtml(service.status_callback ?? "")
34220
+ service.sid,
34221
+ service.friendly_name,
34222
+ String(ts().messagingServicePhoneNumbers.count((item) => item.service_sid === service.sid)),
34223
+ service.status_callback ?? ""
34613
34224
  ]);
34614
- return section2("Messaging Services", table2(["SID", "Name", "Senders", "Status Callback"], messagingRows, "No Messaging Services."));
34225
+ return [section("Messaging Services", table(["SID", "Name", "Senders", "Status Callback"], messagingRows, "No Messaging Services."))];
34615
34226
  }
34616
34227
  function authView() {
34617
34228
  const accountRows = ts().accounts.all().map((account) => [
34618
- escapeHtml(account.sid),
34619
- escapeHtml(account.friendly_name),
34620
- escapeHtml(account.status),
34621
- escapeHtml(maskSecret(account.auth_token))
34229
+ account.sid,
34230
+ account.friendly_name,
34231
+ chip(account.status),
34232
+ maskSecret(account.auth_token)
34622
34233
  ]);
34623
34234
  const keyRows = ts().apiKeys.all().map((key) => [
34624
- escapeHtml(key.sid),
34625
- escapeHtml(key.friendly_name),
34626
- escapeHtml(key.account_sid),
34627
- escapeHtml(key.active ? "active" : "inactive"),
34628
- escapeHtml(maskSecret(key.secret))
34235
+ key.sid,
34236
+ key.friendly_name,
34237
+ key.account_sid,
34238
+ chip(key.active ? "active" : "inactive"),
34239
+ maskSecret(key.secret)
34629
34240
  ]);
34630
- return section2("Accounts", table2(["SID", "Name", "Status", "Auth Token"], accountRows, "No accounts.")) + section2("API Keys", table2(["SID", "Name", "Account", "Status", "Secret"], keyRows, "No API keys."));
34241
+ return [
34242
+ section("Accounts", table(["SID", "Name", "Status", "Auth Token"], accountRows, "No accounts.")),
34243
+ section("API Keys", table(["SID", "Name", "Account", "Status", "Secret"], keyRows, "No API keys."))
34244
+ ];
34631
34245
  }
34632
34246
  function webhooksView() {
34633
34247
  const rows = ts().webhookDeliveries.all().slice(-50).reverse().map((delivery) => [
34634
- escapeHtml(delivery.event),
34635
- escapeHtml(delivery.url),
34636
- escapeHtml(String(delivery.response_status ?? "")),
34637
- escapeHtml(delivery.success ? "ok" : "failed"),
34638
- escapeHtml(delivery.error ?? ""),
34639
- escapeHtml(delivery.created_at)
34248
+ delivery.event,
34249
+ delivery.url,
34250
+ String(delivery.response_status ?? ""),
34251
+ chip(delivery.success ? "ok" : "failed"),
34252
+ delivery.error ?? "",
34253
+ delivery.created_at
34640
34254
  ]);
34641
- return section2("Webhook Deliveries", table2(["Event", "URL", "Status", "Result", "Error", "Created"], rows, "No webhook deliveries."));
34642
- }
34643
- }
34644
- function section2(title, body) {
34645
- return `<section class="inspector-section">
34646
- <h2>${escapeHtml(title)}</h2>
34647
- ${body}
34648
- </section>`;
34649
- }
34650
- function table2(headers, rows, empty) {
34651
- if (rows.length === 0)
34652
- return `<p class="inspector-empty">${escapeHtml(empty)}</p>`;
34653
- const headerHtml = headers.map((header) => `<th>${escapeHtml(header)}</th>`).join("");
34654
- const rowHtml = rows.map((row) => `<tr>${row.map((cell) => `<td>${cell}</td>`).join("")}</tr>`).join("\n");
34655
- return `<table class="inspector-table">
34656
- <thead><tr>${headerHtml}</tr></thead>
34657
- <tbody>
34658
- ${rowHtml}
34659
- </tbody>
34660
- </table>`;
34255
+ return [section("Webhook Deliveries", table(["Event", "URL", "Status", "Result", "Error", "Created"], rows, "No webhook deliveries."))];
34256
+ }
34661
34257
  }
34662
34258
 
34663
34259
  // ../http/provider/dist/vendor/twilio/index.js
@@ -36855,7 +36451,7 @@ function isPendingCodeExpired5(p, clockNow = Date.now) {
36855
36451
  var SERVICE_LABEL12 = "Vercel";
36856
36452
  function oauthRoutes9({ app, store, tokenMap }) {
36857
36453
  const vs = getVercelStore(store);
36858
- app.get("/oauth/authorize", (c) => {
36454
+ app.get("/oauth/authorize", async (c) => {
36859
36455
  const client_id = c.req.query("client_id") ?? "";
36860
36456
  const redirect_uri = c.req.query("redirect_uri") ?? "";
36861
36457
  const scope = c.req.query("scope") ?? "";
@@ -36867,19 +36463,19 @@ function oauthRoutes9({ app, store, tokenMap }) {
36867
36463
  if (integrationsConfigured) {
36868
36464
  const integration = vs.integrations.findOneBy("client_id", client_id);
36869
36465
  if (!integration) {
36870
- return c.html(renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL12), 400);
36466
+ return c.html(await renderErrorPage("Application not found", `The client_id '${client_id}' is not registered.`, SERVICE_LABEL12), 400);
36871
36467
  }
36872
36468
  if (redirect_uri && !matchesRedirectUri(redirect_uri, integration.redirect_uris)) {
36873
36469
  console.warn(`[OAuth] redirect_uri mismatch: got "${redirect_uri}", registered: ${JSON.stringify(integration.redirect_uris)}`);
36874
- return c.html(renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL12), 400);
36470
+ return c.html(await renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL12), 400);
36875
36471
  }
36876
36472
  integrationName = integration.name;
36877
36473
  }
36878
- const subtitleText = integrationName ? `Authorize <strong>${escapeHtml(integrationName)}</strong> to access your account.` : "Choose a seeded user to continue.";
36474
+ const subtitleText = integrationName ? ["Authorize ", { strong: integrationName }, " to access your account."] : "Choose a seeded user to continue.";
36879
36475
  const users = vs.users.all();
36880
36476
  const userButtons = users.map((user) => {
36881
36477
  const u = formatUser5(user);
36882
- return renderUserButton({
36478
+ return {
36883
36479
  letter: (u.username[0] ?? "?").toUpperCase(),
36884
36480
  login: u.username,
36885
36481
  name: u.name ?? void 0,
@@ -36894,10 +36490,9 @@ function oauthRoutes9({ app, store, tokenMap }) {
36894
36490
  code_challenge,
36895
36491
  code_challenge_method
36896
36492
  }
36897
- });
36898
- }).join("\n");
36899
- const body = users.length === 0 ? '<p class="empty">No users in the emulator store.</p>' : userButtons;
36900
- return c.html(renderCardPage("Sign in to Vercel", subtitleText, body, SERVICE_LABEL12));
36493
+ };
36494
+ });
36495
+ return c.html(await renderSignInPage("Sign in to Vercel", subtitleText, userButtons, SERVICE_LABEL12));
36901
36496
  });
36902
36497
  app.post("/oauth/authorize/callback", async (c) => {
36903
36498
  const body = await c.req.parseBody();