querysub 0.152.0 → 0.154.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/package.json +6 -6
- package/src/-b-authorities/cloudflareHelpers.ts +11 -2
- package/src/3-path-functions/PathFunctionRunner.ts +168 -97
- package/src/3-path-functions/PathFunctionRunnerMain.ts +8 -2
- package/src/3-path-functions/pathFunctionLoader.ts +11 -6
- package/src/3-path-functions/syncSchema.ts +10 -1
- package/src/4-deploy/edgeBootstrap.ts +10 -1
- package/src/4-querysub/Querysub.ts +77 -3
- package/src/4-querysub/QuerysubController.ts +22 -2
- package/src/4-querysub/permissions.ts +33 -2
- package/src/4-querysub/querysubPrediction.ts +52 -18
- package/src/archiveapps/archiveGCEntry.tsx +38 -0
- package/src/archiveapps/archiveJoinEntry.ts +121 -0
- package/src/archiveapps/archiveMergeEntry.tsx +47 -0
- package/src/archiveapps/compressTest.tsx +59 -0
- package/src/archiveapps/lockTest.ts +127 -0
- package/src/config.ts +5 -0
- package/src/diagnostics/managementPages.tsx +55 -0
- package/src/diagnostics/misc-pages/ArchiveInspect.tsx +325 -0
- package/src/diagnostics/misc-pages/ArchiveViewer.tsx +781 -0
- package/src/diagnostics/misc-pages/ArchiveViewerTable.tsx +156 -0
- package/src/diagnostics/misc-pages/ArchiveViewerTree.tsx +573 -0
- package/src/diagnostics/misc-pages/ComponentSyncStats.tsx +129 -0
- package/src/diagnostics/misc-pages/LocalWatchViewer.tsx +431 -0
- package/src/diagnostics/misc-pages/RequireAuditPage.tsx +218 -0
- package/src/diagnostics/misc-pages/SnapshotViewer.tsx +206 -0
- package/src/diagnostics/misc-pages/TimeRangeView.tsx +648 -0
- package/src/diagnostics/misc-pages/archiveViewerFilter.tsx +221 -0
- package/src/diagnostics/misc-pages/archiveViewerShared.tsx +76 -0
- package/src/email/postmark.tsx +40 -0
- package/src/email/sendgrid.tsx +44 -0
- package/src/functional/UndoWatch.tsx +133 -0
- package/src/functional/diff.ts +858 -0
- package/src/functional/promiseCache.ts +67 -0
- package/src/functional/random.ts +9 -0
- package/src/functional/runCommand.ts +42 -0
- package/src/functional/runOnce.ts +7 -0
- package/src/functional/stats.ts +61 -0
- package/src/functional/throttleRerender.tsx +80 -0
- package/src/library-components/AspectSizedComponent.tsx +88 -0
- package/src/library-components/Histogram.tsx +338 -0
- package/src/library-components/InlinePopup.tsx +67 -0
- package/src/library-components/Notifications.tsx +153 -0
- package/src/library-components/RenderIfVisible.tsx +80 -0
- package/src/library-components/SimpleNotification.tsx +133 -0
- package/src/library-components/TabbedUI.tsx +39 -0
- package/src/library-components/animateAnyElement.tsx +65 -0
- package/src/library-components/errorNotifications.tsx +81 -0
- package/src/library-components/placeholder.ts +18 -0
- package/src/misc/format2.ts +48 -0
- package/src/misc.ts +33 -0
- package/src/misc2.ts +5 -0
- package/src/server.ts +2 -1
- package/src/storage/diskCache.ts +227 -0
- package/src/storage/diskCache2.ts +122 -0
- package/src/storage/fileSystemPointer.ts +72 -0
- package/src/user-implementation/LoginPage.tsx +78 -0
- package/src/user-implementation/RequireAuditPage.tsx +219 -0
- package/src/user-implementation/SecurityPage.tsx +212 -0
- package/src/user-implementation/UserPage.tsx +320 -0
- package/src/user-implementation/addSuperUser.ts +21 -0
- package/src/user-implementation/canSeeSource.ts +41 -0
- package/src/user-implementation/loginEmail.tsx +159 -0
- package/src/user-implementation/setEmailKey.ts +20 -0
- package/src/user-implementation/userData.ts +974 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import preact from "preact"; import { qreact } from "../4-dom/qreact";
|
|
2
|
+
import { loginTokenURL } from "./userData";
|
|
3
|
+
import { list } from "socket-function/src/misc";
|
|
4
|
+
import { hslToRGB } from "socket-function/src/formatting/colors";
|
|
5
|
+
import { joinVNodes } from "../misc";
|
|
6
|
+
export function generateLoginEmail(config: {
|
|
7
|
+
userId: string;
|
|
8
|
+
loginToken: string;
|
|
9
|
+
ip: string;
|
|
10
|
+
machineId: string;
|
|
11
|
+
redirectURL: string;
|
|
12
|
+
timeoutTime: number;
|
|
13
|
+
noHTMLWrapper?: boolean;
|
|
14
|
+
}): { subject: string; contents: preact.VNode } {
|
|
15
|
+
const { userId, loginToken, ip, machineId, redirectURL } = config;
|
|
16
|
+
let url = new URL(redirectURL);
|
|
17
|
+
url.searchParams.set(loginTokenURL.urlKey, loginToken);
|
|
18
|
+
const subject = `${userId} Access Request (${new Date().toLocaleString()})`;
|
|
19
|
+
function center(jsx: preact.ComponentChild) {
|
|
20
|
+
return (
|
|
21
|
+
<table style={{ width: "100%" }}>
|
|
22
|
+
<tbody>
|
|
23
|
+
<tr>
|
|
24
|
+
<td {...{ "nowrap": true, align: "center" } as any}>
|
|
25
|
+
{jsx}
|
|
26
|
+
</td>
|
|
27
|
+
</tr>
|
|
28
|
+
</tbody>
|
|
29
|
+
</table>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
function line(jsx: preact.ComponentChild) {
|
|
33
|
+
return (
|
|
34
|
+
<table>
|
|
35
|
+
<tbody>
|
|
36
|
+
<tr>
|
|
37
|
+
<td>
|
|
38
|
+
{jsx}
|
|
39
|
+
</td>
|
|
40
|
+
</tr>
|
|
41
|
+
</tbody>
|
|
42
|
+
</table>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function hexColor(color: { r: number, g: number, b: number }) {
|
|
46
|
+
return `#${color.r.toString(16).padStart(2, "0")}${color.g.toString(16).padStart(2, "0")}${color.b.toString(16).padStart(2, "0")}`;
|
|
47
|
+
}
|
|
48
|
+
function hsl(h: number, s: number, l: number) {
|
|
49
|
+
let rgb = hslToRGB({ h, s, l });
|
|
50
|
+
return hexColor(rgb);
|
|
51
|
+
}
|
|
52
|
+
// TODO: Test with https://www.emailonacid.com/email-testing/
|
|
53
|
+
const innerContents = (
|
|
54
|
+
<>
|
|
55
|
+
{/* TODO: Logo, using a table to render it inline, so it shows no matter what. */}
|
|
56
|
+
<table width="100%">
|
|
57
|
+
<tbody>
|
|
58
|
+
<tr>
|
|
59
|
+
<td {...{ align: "right" } as any}>
|
|
60
|
+
<table cellSpacing={0} cellPadding={0}>
|
|
61
|
+
<tbody>
|
|
62
|
+
{list(10).map(x =>
|
|
63
|
+
<tr>
|
|
64
|
+
{list(10).map((y) =>
|
|
65
|
+
<td width="1" height="1" style={{
|
|
66
|
+
background: hexColor({ r: 255 - x * 20, g: 255 - y * 20, b: 50 }),
|
|
67
|
+
fontSize: "0px",
|
|
68
|
+
}}>
|
|
69
|
+
|
|
70
|
+
</td>
|
|
71
|
+
)}
|
|
72
|
+
</tr>
|
|
73
|
+
)}
|
|
74
|
+
</tbody>
|
|
75
|
+
</table>
|
|
76
|
+
</td>
|
|
77
|
+
</tr>
|
|
78
|
+
</tbody>
|
|
79
|
+
</table>
|
|
80
|
+
{line(<div style={{ color: "rgb(255, 255, 255)" }}>
|
|
81
|
+
{/* Mess up the email so it isn't turned into a link by gmail. */}
|
|
82
|
+
Greetings <b>{userId.replaceAll(".", ".")}</b>. You have requested access to <a href={redirectURL} style={{ color: "rgb(153, 204, 255)" }}>{new URL(redirectURL).hostname}</a>.
|
|
83
|
+
</div>)}
|
|
84
|
+
{line(<div style={{ color: "rgb(255, 255, 255)" }}>
|
|
85
|
+
If you did not make this request, please disregard this email. Your account is safe and no action is required.
|
|
86
|
+
</div>)}
|
|
87
|
+
<table><tbody><tr><td style={{ paddingTop: "30px" }}></td></tr></tbody></table>
|
|
88
|
+
{center(
|
|
89
|
+
<a
|
|
90
|
+
href={url.toString()}
|
|
91
|
+
style={{
|
|
92
|
+
// background: "rgb(175, 143, 239)",
|
|
93
|
+
// border: "20px solid rgb(175, 143, 239)",
|
|
94
|
+
// background: "rgb(207, 143, 239)",
|
|
95
|
+
// border: "20px solid rgb(207, 143, 239)",
|
|
96
|
+
// background: "rgb(216, 98, 188)",
|
|
97
|
+
// border: "20px solid rgb(216, 98, 188)",
|
|
98
|
+
background: hsl(282, 75, 72),
|
|
99
|
+
border: `20px solid ${hsl(282, 75, 72)}`,
|
|
100
|
+
color: "white",
|
|
101
|
+
fontSize: "30px",
|
|
102
|
+
fontWeight: 400,
|
|
103
|
+
textDecoration: "none",
|
|
104
|
+
minWidth: "500px",
|
|
105
|
+
textAlign: "center",
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
{joinVNodes(Array(8).fill(<> </>), "")}Click to access{joinVNodes(Array(8).fill(<> </>), "")}
|
|
109
|
+
</a>
|
|
110
|
+
)}
|
|
111
|
+
<table><tbody><tr><td style={{ paddingTop: "30px" }}></td></tr></tbody></table>
|
|
112
|
+
<table style={{ width: "100%" }}><tbody><tr>
|
|
113
|
+
<td {...{ "nowrap": true }} style={{ width: "100%", paddingTop: "1px", background: "rgb(211, 211, 211)" }}></td>
|
|
114
|
+
<td {...{ "nowrap": true }} style={{ paddingLeft: "40px", }}></td>
|
|
115
|
+
</tr></tbody></table>
|
|
116
|
+
<table><tbody><tr><td style={{ paddingTop: "20px" }}></td></tr></tbody></table>
|
|
117
|
+
{line(<div style={{ color: "rgb(140, 140, 140)", width: "100%" }}><b>Do NOT share or forward this email with anyone.</b></div>)}
|
|
118
|
+
<table><tbody><tr><td style={{ paddingTop: "10px" }}></td></tr></tbody></table>
|
|
119
|
+
{line(<div style={{ color: "rgb(140, 140, 140)", width: "100%" }}>
|
|
120
|
+
This link will only work with the current device and browser.
|
|
121
|
+
This link can only be used one time, until {new Date(config.timeoutTime).toLocaleString()}.
|
|
122
|
+
</div>)}
|
|
123
|
+
</>
|
|
124
|
+
);
|
|
125
|
+
// We have to use tables, because outlook uses "Word" as it's render, so we really don't have many options...
|
|
126
|
+
let contents = (
|
|
127
|
+
<table cellPadding={0} cellSpacing={0} style={{
|
|
128
|
+
background: "rgb(80, 80, 80)",
|
|
129
|
+
color: "rgb(255, 255, 255)",
|
|
130
|
+
fontFamily: "Inter, Arial, Helvetica, sans-serif",
|
|
131
|
+
fontSize: 12,
|
|
132
|
+
}}>
|
|
133
|
+
<tbody>
|
|
134
|
+
<tr><td style={{ height: "18px" }}></td><td /><td /></tr>
|
|
135
|
+
<tr>
|
|
136
|
+
<td style={{ width: "60px" }}></td>
|
|
137
|
+
<td style={{ width: "600px", color: "rgb(255, 255, 255)" }}>
|
|
138
|
+
{innerContents}
|
|
139
|
+
</td>
|
|
140
|
+
<td style={{ width: "20px" }}></td>
|
|
141
|
+
</tr>
|
|
142
|
+
<tr><td style={{ height: "40px" }}></td></tr>
|
|
143
|
+
</tbody>
|
|
144
|
+
</table>
|
|
145
|
+
);
|
|
146
|
+
if (!config.noHTMLWrapper) {
|
|
147
|
+
contents = (
|
|
148
|
+
<html>
|
|
149
|
+
<head>
|
|
150
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
|
151
|
+
</head>
|
|
152
|
+
<body>
|
|
153
|
+
{contents}
|
|
154
|
+
</body>
|
|
155
|
+
</html>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
return { subject, contents };
|
|
159
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Querysub } from "../4-querysub/Querysub";
|
|
2
|
+
import { pathValueCommitter } from "../0-path-value-core/PathValueCommitter";
|
|
3
|
+
import { scriptSetPostmarkAPIKey } from "./userData";
|
|
4
|
+
|
|
5
|
+
async function main() {
|
|
6
|
+
const howToCall = ` Call with yarn setemailkey <key>`;
|
|
7
|
+
const args = process.argv.slice(2).filter(x => !x.startsWith("--"));
|
|
8
|
+
const key = args[0];
|
|
9
|
+
console.log(process.argv);
|
|
10
|
+
if (!key) throw new Error("No key provided." + howToCall);
|
|
11
|
+
|
|
12
|
+
await Querysub.hostService("setSendgridKey");
|
|
13
|
+
|
|
14
|
+
await Querysub.commitSynced(() => {
|
|
15
|
+
scriptSetPostmarkAPIKey({ apiKey: key });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
await pathValueCommitter.waitForValuesToCommit();
|
|
19
|
+
}
|
|
20
|
+
main().catch(e => console.log(e)).finally(() => process.exit());
|