Spaces:
Running
Running
JOHN SILLVESTOR commited on
Secure bootstrap payload with domain-bound encrypted delivery
Browse files
server.js
CHANGED
|
@@ -1929,15 +1929,45 @@ async function handleStripeWebhook(req, res) {
|
|
| 1929 |
json(res, 200, { ok: true });
|
| 1930 |
}
|
| 1931 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1932 |
async function handleBootstrap(req, res, url) {
|
| 1933 |
if (!destOk(req, ["empty"])) return json(res, 403, { error: "forbidden" });
|
| 1934 |
if (denyHot(req, res)) return;
|
| 1935 |
-
|
| 1936 |
-
worker: SPACE_URLS[0] || "",
|
| 1937 |
spaces: SPACE_URLS,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1938 |
blogId: url.searchParams.get("bid") || "",
|
| 1939 |
role: ROLE,
|
| 1940 |
-
bots: bots.filter((b) => b.ready).length
|
|
|
|
| 1941 |
}, "private, max-age=30");
|
| 1942 |
}
|
| 1943 |
|
|
|
|
| 1929 |
json(res, 200, { ok: true });
|
| 1930 |
}
|
| 1931 |
|
| 1932 |
+
const FB_CLIENT_CFG = {
|
| 1933 |
+
apiKey: "AIzaSyCho6yF39MqCrWitmDqXnuBtbP6aANQ8EA",
|
| 1934 |
+
authDomain: "dublk2000-auth.firebaseapp.com",
|
| 1935 |
+
databaseURL: "wss://dublk2000-auth-default-rtdb.firebaseio.com/",
|
| 1936 |
+
projectId: "dublk2000-auth",
|
| 1937 |
+
storageBucket: "dublk2000-auth.firebasestorage.app",
|
| 1938 |
+
messagingSenderId: "475299842360",
|
| 1939 |
+
appId: "1:475299842360:web:7f0c4d346a7affe8e3d9cd",
|
| 1940 |
+
measurementId: "G-B8RYS5PYSQ"
|
| 1941 |
+
};
|
| 1942 |
+
const G_CLIENT_ID = "475299842360-crrejjs7b7krvpsuu16jc9mimg0qaing.apps.googleusercontent.com";
|
| 1943 |
+
|
| 1944 |
+
function encDomain(text, domain) {
|
| 1945 |
+
const dom = domain || "dublk2000.blogspot.com";
|
| 1946 |
+
const key = Buffer.from(dom, "utf8");
|
| 1947 |
+
const kLen = key.length;
|
| 1948 |
+
const out = [];
|
| 1949 |
+
for (let i = 0; i < text.length; i++) {
|
| 1950 |
+
const k = key[i % kLen];
|
| 1951 |
+
const c = (text.charCodeAt(i) ^ k ^ ((i * 7 + 13) & 0xff));
|
| 1952 |
+
out.push(c);
|
| 1953 |
+
}
|
| 1954 |
+
return out.join(",");
|
| 1955 |
+
}
|
| 1956 |
+
|
| 1957 |
async function handleBootstrap(req, res, url) {
|
| 1958 |
if (!destOk(req, ["empty"])) return json(res, 403, { error: "forbidden" });
|
| 1959 |
if (denyHot(req, res)) return;
|
| 1960 |
+
const bundle = {
|
|
|
|
| 1961 |
spaces: SPACE_URLS,
|
| 1962 |
+
worker: SPACE_URLS[0] || "",
|
| 1963 |
+
fb: FB_CLIENT_CFG,
|
| 1964 |
+
gc: G_CLIENT_ID
|
| 1965 |
+
};
|
| 1966 |
+
json(res, 200, {
|
| 1967 |
blogId: url.searchParams.get("bid") || "",
|
| 1968 |
role: ROLE,
|
| 1969 |
+
bots: bots.filter((b) => b.ready).length,
|
| 1970 |
+
p: encDomain(JSON.stringify(bundle), "dublk2000.blogspot.com")
|
| 1971 |
}, "private, max-age=30");
|
| 1972 |
}
|
| 1973 |
|