@crvouga/mockingbird-runtime 0.3.2 → 0.4.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.
- package/README.md +1 -1
- package/dist/adapter-node.js +11 -6
- package/dist/adapter-node.js.map +2 -2
- package/dist/admin-ui.js +1 -1
- package/dist/admin-ui.js.map +1 -1
- package/dist/{chunk-ZQBZSSSP.js → chunk-4XF56L2I.js} +3 -3
- package/dist/{chunk-KD6FHYQP.js → chunk-HGJXAIZJ.js} +4 -4
- package/dist/{chunk-M4HUKBLC.js → chunk-NW5GDYLU.js} +9 -31
- package/dist/{chunk-M4HUKBLC.js.map → chunk-NW5GDYLU.js.map} +3 -3
- package/dist/client.bundle-6XOKJ6BJ.js +6 -0
- package/dist/client.bundle-6XOKJ6BJ.js.map +7 -0
- package/dist/http-provider.d.ts +2 -2
- package/dist/http-provider.js +649 -1054
- package/dist/http-provider.js.map +3 -3
- package/dist/mqtt-broker/node.js +3 -3
- package/dist/mqtt-broker.js +3 -3
- package/dist/server-32IZ5ZMR.js +17379 -0
- package/dist/server-32IZ5ZMR.js.map +7 -0
- package/dist/server-SXO3PUBW.js +16059 -0
- package/dist/server-SXO3PUBW.js.map +7 -0
- package/dist/service/admin.js +1 -1
- package/dist/service.js +2 -2
- package/package.json +6 -6
- /package/dist/{chunk-ZQBZSSSP.js.map → chunk-4XF56L2I.js.map} +0 -0
- /package/dist/{chunk-KD6FHYQP.js.map → chunk-HGJXAIZJ.js.map} +0 -0
package/dist/http-provider.js
CHANGED
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
Collection,
|
|
20
20
|
bootSqlite
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-HGJXAIZJ.js";
|
|
22
22
|
import {
|
|
23
23
|
clearNamespace
|
|
24
24
|
} from "./chunk-2KDYLZXC.js";
|
|
25
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-NW5GDYLU.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
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
function escapeAttr(s) {
|
|
909
|
-
return escapeHtml(s).replace(/'/g, "'");
|
|
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
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
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
|
-
|
|
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
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
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
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
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
|
|
2980
|
-
const paths = [.../* @__PURE__ */ new Set([...base.blobs.keys(), ...
|
|
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 =
|
|
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 ||
|
|
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) =>
|
|
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 =
|
|
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,
|
|
4565
|
-
const trimmed =
|
|
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
|
|
8609
|
-
if (!
|
|
8306
|
+
const head = resolveRefToCommit(gh, repo, shaParam);
|
|
8307
|
+
if (!head)
|
|
8610
8308
|
throw notFound();
|
|
8611
|
-
let history = listAncestors(gh, repo.id,
|
|
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
|
|
8656
|
-
if (!base || !
|
|
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,
|
|
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,
|
|
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 ===
|
|
8667
|
-
const allFiles = diffTrees(gh, repo.id, mergeBase.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)}...${
|
|
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,
|
|
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
|
|
11018
|
-
if (!
|
|
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,
|
|
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 ?
|
|
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
|
|
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
|
-
})
|
|
12861
|
-
|
|
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
|
|
13032
|
-
|
|
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
|
-
|
|
13040
|
-
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
|
|
13046
|
-
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
13064
|
-
|
|
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
|
|
13085
|
-
const
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
13107
|
-
|
|
13108
|
-
|
|
13109
|
-
|
|
13110
|
-
|
|
13111
|
-
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
|
|
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 ?
|
|
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
|
|
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
|
-
})
|
|
14078
|
-
|
|
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
|
-
|
|
15068
|
+
const blocks = [];
|
|
15376
15069
|
if (tab === "s3") {
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
|
|
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
|
-
|
|
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
|
-
|
|
15415
|
-
|
|
15416
|
-
|
|
15417
|
-
|
|
15418
|
-
|
|
15419
|
-
|
|
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
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
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
|
|
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
|
-
})
|
|
15916
|
-
const subtitle = appName ?
|
|
15917
|
-
return c.html(
|
|
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
|
|
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
|
|
20312
|
-
return
|
|
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
|
-
})
|
|
20330
|
-
|
|
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" ?
|
|
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
|
-
}
|
|
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
|
-
}))
|
|
23133
|
-
return c.html(
|
|
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
|
-
|
|
23383
|
-
|
|
23384
|
-
|
|
23385
|
-
|
|
23386
|
-
|
|
23387
|
-
|
|
23388
|
-
|
|
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
|
-
|
|
23399
|
-
|
|
23400
|
-
|
|
23401
|
-
|
|
23402
|
-
|
|
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
|
-
|
|
23410
|
-
|
|
23411
|
-
|
|
23412
|
-
|
|
23413
|
-
|
|
23414
|
-
|
|
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
|
-
|
|
23421
|
-
|
|
23422
|
-
|
|
23423
|
-
|
|
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
|
-
|
|
23427
|
-
|
|
23428
|
-
|
|
23429
|
-
|
|
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
|
|
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
|
-
|
|
23439
|
-
|
|
23440
|
-
|
|
23441
|
-
|
|
23442
|
-
|
|
23443
|
-
|
|
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
|
-
|
|
23451
|
-
|
|
23452
|
-
|
|
23453
|
-
|
|
23454
|
-
|
|
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
|
-
|
|
23458
|
-
|
|
23459
|
-
|
|
23460
|
-
|
|
23461
|
-
|
|
23462
|
-
|
|
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
|
|
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
|
-
|
|
23469
|
-
|
|
23470
|
-
|
|
23471
|
-
|
|
23472
|
-
|
|
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
|
-
|
|
23476
|
-
|
|
23477
|
-
|
|
23478
|
-
|
|
23479
|
-
|
|
23480
|
-
|
|
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
|
|
23483
|
-
|
|
23484
|
-
|
|
23485
|
-
|
|
23486
|
-
|
|
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
|
|
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 ?
|
|
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
|
|
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
|
-
})
|
|
24238
|
-
|
|
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) =>
|
|
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
|
-
}))
|
|
26561
|
-
const subtitle = clientName ?
|
|
26562
|
-
return c.html(
|
|
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
|
-
|
|
27832
|
-
|
|
27833
|
-
|
|
27834
|
-
|
|
27835
|
-
|
|
27836
|
-
|
|
27837
|
-
|
|
27838
|
-
|
|
27839
|
-
|
|
27840
|
-
|
|
27841
|
-
|
|
27842
|
-
|
|
27843
|
-
|
|
27844
|
-
|
|
27845
|
-
|
|
27846
|
-
|
|
27847
|
-
|
|
27848
|
-
|
|
27849
|
-
|
|
27850
|
-
|
|
27851
|
-
|
|
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
|
-
|
|
27856
|
-
|
|
27857
|
-
|
|
27858
|
-
|
|
27859
|
-
|
|
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
|
-
|
|
27862
|
-
|
|
27863
|
-
|
|
27864
|
-
}
|
|
27865
|
-
|
|
27866
|
-
|
|
27867
|
-
|
|
27868
|
-
|
|
27869
|
-
|
|
27870
|
-
|
|
27871
|
-
|
|
27872
|
-
|
|
27873
|
-
|
|
27874
|
-
|
|
27875
|
-
|
|
27876
|
-
|
|
27877
|
-
|
|
27878
|
-
|
|
27879
|
-
|
|
27880
|
-
|
|
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 ?
|
|
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
|
|
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
|
-
})
|
|
30328
|
-
|
|
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
|
-
|
|
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
|
|
31672
|
+
return chip(label, TONE[tone]);
|
|
32066
31673
|
}
|
|
32067
31674
|
function renderReactionBadges(reactions) {
|
|
32068
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
32161
|
-
|
|
32162
|
-
|
|
32163
|
-
|
|
32164
|
-
|
|
32165
|
-
|
|
32166
|
-
|
|
32167
|
-
|
|
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
|
|
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
|
-
|
|
32176
|
-
|
|
31780
|
+
channelKind(ch),
|
|
31781
|
+
String(ch.num_members),
|
|
32177
31782
|
ch.is_archived ? badge("archived", "denied") : badge("open", "granted")
|
|
32178
31783
|
]);
|
|
32179
|
-
return
|
|
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
|
-
|
|
32187
|
-
|
|
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
|
-
|
|
32190
|
-
|
|
32191
|
-
|
|
32192
|
-
|
|
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
|
-
|
|
32196
|
-
|
|
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
|
-
|
|
32199
|
-
|
|
32200
|
-
|
|
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
|
-
]
|
|
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
|
-
|
|
32209
|
-
|
|
32210
|
-
|
|
32211
|
-
|
|
32212
|
-
|
|
32213
|
-
|
|
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
|
-
|
|
31820
|
+
new Date(file.created * 1e3).toISOString()
|
|
32216
31821
|
]), "No completed files in the emulator store.")),
|
|
32217
|
-
|
|
32218
|
-
|
|
32219
|
-
|
|
32220
|
-
|
|
32221
|
-
|
|
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
|
-
]
|
|
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
|
-
|
|
32234
|
-
|
|
32235
|
-
|
|
32236
|
-
]
|
|
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
|
-
|
|
32242
|
-
|
|
32243
|
-
|
|
32244
|
-
|
|
32245
|
-
|
|
32246
|
-
]
|
|
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
|
-
|
|
32256
|
-
|
|
32257
|
-
|
|
32258
|
-
]
|
|
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
|
|
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) ?
|
|
32265
|
-
const threadBadge = msg.reply_count > 0 ?
|
|
32266
|
-
const fileBadge = msg.files?.length ?
|
|
32267
|
-
const threadIndicator = msg.thread_ts && msg.thread_ts !== msg.ts ?
|
|
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
|
-
|
|
32270
|
-
|
|
32271
|
-
|
|
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
|
-
|
|
31878
|
+
msg.ts
|
|
32274
31879
|
];
|
|
32275
31880
|
}), empty);
|
|
32276
31881
|
}
|
|
32277
31882
|
function renderEphemeralTable(messages, users, empty, clockNow = Date.now) {
|
|
32278
|
-
return
|
|
32279
|
-
|
|
32280
|
-
|
|
32281
|
-
|
|
32282
|
-
|
|
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
|
|
32287
|
-
|
|
32288
|
-
|
|
32289
|
-
|
|
32290
|
-
|
|
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
|
|
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
|
-
|
|
32298
|
-
|
|
32299
|
-
|
|
32300
|
-
|
|
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
|
|
32306
|
-
|
|
32307
|
-
|
|
32308
|
-
|
|
32309
|
-
|
|
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
|
|
32314
|
-
|
|
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
|
-
|
|
32317
|
-
|
|
32318
|
-
|
|
32319
|
-
|
|
32320
|
-
|
|
32321
|
-
|
|
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
|
|
32327
|
-
|
|
32328
|
-
|
|
32329
|
-
|
|
32330
|
-
|
|
32331
|
-
|
|
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
|
|
32337
|
-
|
|
32338
|
-
|
|
32339
|
-
|
|
32340
|
-
|
|
32341
|
-
|
|
32342
|
-
|
|
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
|
|
32347
|
-
|
|
32348
|
-
|
|
32349
|
-
|
|
32350
|
-
|
|
32351
|
-
|
|
32352
|
-
|
|
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
|
|
32357
|
-
|
|
32358
|
-
|
|
32359
|
-
|
|
32360
|
-
|
|
32361
|
-
|
|
32362
|
-
|
|
32363
|
-
|
|
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
|
|
32368
|
-
|
|
32369
|
-
|
|
32370
|
-
|
|
32371
|
-
|
|
32372
|
-
|
|
32373
|
-
|
|
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
|
|
32378
|
-
|
|
32379
|
-
|
|
32380
|
-
|
|
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
|
|
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
|
-
|
|
32390
|
-
|
|
32391
|
-
|
|
32392
|
-
|
|
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
|
-
|
|
32395
|
-
|
|
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
|
-
|
|
34548
|
-
|
|
34549
|
-
|
|
34550
|
-
|
|
34551
|
-
|
|
34552
|
-
|
|
34553
|
-
|
|
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
|
|
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) => [
|
|
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
|
-
|
|
34561
|
-
|
|
34562
|
-
|
|
34563
|
-
|
|
34564
|
-
|
|
34565
|
-
|
|
34165
|
+
verification.sid,
|
|
34166
|
+
verification.to,
|
|
34167
|
+
verification.channel,
|
|
34168
|
+
chip(verification.status),
|
|
34169
|
+
verification.code,
|
|
34170
|
+
String(verification.attempts)
|
|
34566
34171
|
]);
|
|
34567
|
-
return
|
|
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
|
-
|
|
34572
|
-
|
|
34573
|
-
|
|
34574
|
-
|
|
34575
|
-
|
|
34576
|
-
|
|
34577
|
-
|
|
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
|
|
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
|
-
|
|
34584
|
-
|
|
34585
|
-
|
|
34586
|
-
|
|
34587
|
-
|
|
34191
|
+
number.sid,
|
|
34192
|
+
number.phone_number,
|
|
34193
|
+
number.friendly_name,
|
|
34194
|
+
number.sms_url ?? "",
|
|
34195
|
+
number.voice_url ?? ""
|
|
34588
34196
|
]);
|
|
34589
|
-
return
|
|
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
|
-
|
|
34594
|
-
|
|
34595
|
-
|
|
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
|
-
|
|
34599
|
-
|
|
34600
|
-
|
|
34601
|
-
|
|
34602
|
-
|
|
34603
|
-
|
|
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
|
|
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
|
-
|
|
34610
|
-
|
|
34611
|
-
|
|
34612
|
-
|
|
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
|
|
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
|
-
|
|
34619
|
-
|
|
34620
|
-
|
|
34621
|
-
|
|
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
|
-
|
|
34625
|
-
|
|
34626
|
-
|
|
34627
|
-
|
|
34628
|
-
|
|
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
|
|
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
|
-
|
|
34635
|
-
|
|
34636
|
-
|
|
34637
|
-
|
|
34638
|
-
|
|
34639
|
-
|
|
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
|
|
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 ?
|
|
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
|
|
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
|
-
})
|
|
36899
|
-
|
|
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();
|