fix cache
diff --git a/package-lock.json b/package-lock.json
index 4005033..89a2f92 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,7 +8,7 @@
"license": "MIT",
"devDependencies": {
"@cloudflare/kv-asset-handler": "^0.2.0",
- "@jottocraft/yggdrasil": "^0.0.36",
+ "@jottocraft/yggdrasil": "^0.0.38",
"express": "^4.17.2",
"foodoc": "^0.0.9",
"glob": "^7.2.0",
@@ -84,9 +84,9 @@
}
},
"node_modules/@jottocraft/yggdrasil": {
- "version": "0.0.36",
- "resolved": "https://registry.npmjs.org/@jottocraft/yggdrasil/-/yggdrasil-0.0.36.tgz",
- "integrity": "sha512-FH9l7HfU4wts2gddxObiS/1k1F1CnSVR0B46nbIBs7YIyE8d3Y7+ilG2PmDVVJW+9wCw4twucVUBA/F+UcANCA==",
+ "version": "0.0.38",
+ "resolved": "https://registry.npmjs.org/@jottocraft/yggdrasil/-/yggdrasil-0.0.38.tgz",
+ "integrity": "sha512-Xyps0LnvcUimRr6huSmzZOWvh6Zpa1OK4+S/BksPxwvQAmdMsWgwJlMdCeYwQleMcDhix+D1LrAx3w3pkUwI3g==",
"dev": true,
"dependencies": {
"jsonwebtoken": "^8.5.1",
@@ -3832,9 +3832,9 @@
}
},
"@jottocraft/yggdrasil": {
- "version": "0.0.36",
- "resolved": "https://registry.npmjs.org/@jottocraft/yggdrasil/-/yggdrasil-0.0.36.tgz",
- "integrity": "sha512-FH9l7HfU4wts2gddxObiS/1k1F1CnSVR0B46nbIBs7YIyE8d3Y7+ilG2PmDVVJW+9wCw4twucVUBA/F+UcANCA==",
+ "version": "0.0.38",
+ "resolved": "https://registry.npmjs.org/@jottocraft/yggdrasil/-/yggdrasil-0.0.38.tgz",
+ "integrity": "sha512-Xyps0LnvcUimRr6huSmzZOWvh6Zpa1OK4+S/BksPxwvQAmdMsWgwJlMdCeYwQleMcDhix+D1LrAx3w3pkUwI3g==",
"dev": true,
"requires": {
"jsonwebtoken": "^8.5.1",
diff --git a/package.json b/package.json
index c4660c1..1d0cf1f 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,7 @@
"main": "server.js",
"devDependencies": {
"@cloudflare/kv-asset-handler": "^0.2.0",
- "@jottocraft/yggdrasil": "^0.0.36",
+ "@jottocraft/yggdrasil": "^0.0.38",
"express": "^4.17.2",
"foodoc": "^0.0.9",
"glob": "^7.2.0",
diff --git a/scripts/core.js b/scripts/core.js
index 61abc78..617267c 100644
--- a/scripts/core.js
+++ b/scripts/core.js
@@ -238,9 +238,9 @@
<div class="welcomeSection">
<i class="fluid-icon">security</i>
<h5>Privacy</h5>
- <p>Power+ records your device type, Canvas institution, country, and state/region when you load Power+.
+ <p>Power+ records your device & network type, Canvas institution, country, and state/region when you load Power+.
Power+ does <b>not</b> utilize cookies or fingerprinting when collecting data.
- Additionally, data is collected solely by Power+ and is never shared with or sold to any third parties.
+ Additionally, data is collected directly by Power+ and is never shared with or sold to any third parties.
Power+ does <b>not</b> and will <b>never</b> collect any personal information, such as names, classes, or grades.
</div>
<div class="welcomeSection">
diff --git a/server.js b/server.js
index 7f3a358..878147b 100644
--- a/server.js
+++ b/server.js
@@ -36,38 +36,56 @@
method: "GET",
path: "*"
}, async ctx => {
+ var page;
try {
- const page = await getAssetFromKV(ctx.event);
-
- //Store response
- ctx.response.body = page.body;
-
- //Set headers from KV
- Object.assign(ctx.response.headers, Object.fromEntries(page.headers.entries()));
-
- ctx.response.code = 200.1;
-
- //Log entrypoint requests for analytics
- const ref = ctx.request.headers.get("referer") && new URL(ctx.request.headers.get("referer"));
- const isEntryPoint = ctx.url.pathname === "/init.js" || ctx.url.pathname.startsWith("/scripts/lms/");
- const isOriginatingFromThirdParty = ref && !ref.hostname.endsWith("powerplus.app") && !ref.hostname.endsWith("jottocraft.com");
- const isDtechFollowUp = (ref.hostname === "dtechhs.instructure.com") && (ctx.url.pathname === "/scripts/lms/canvas.js");
-
- if (isEntryPoint && isOriginatingFromThirdParty && !isDtechFollowUp) {
- //Record User-Agent, requested entrypoint, institution, country, state, and the Cloudflare colocation/datacenter handling the request
- ctx.loggingEnabled = true;
- ctx.loggingProperties = {
- at: new Date().getTime(),
- ua: ctx.request.headers.get("user-agent") || "unknown",
- entry: ctx.url.pathname,
- institution: ref.hostname,
- country: ctx.event.request.cf.country,
- region: ctx.event.request.cf.regionCode,
- colo: ctx.event.request.cf.colo
- };
- }
+ page = await getAssetFromKV(ctx.event);
} catch(e) {
- ctx.response.code = 404.1;
+ return ctx.response.code = 404.1;
+ }
+
+ //Store response
+ ctx.response.body = page.body;
+
+ //Set headers from KV
+ Object.assign(ctx.response.headers, Object.fromEntries(page.headers.entries()));
+
+ ctx.response.code = page.status;
+ ctx.response.description = "No error; The asset corresponding to the request was successfully returned";
+
+ //Log entrypoint requests for analytics
+ const ref = ctx.request.headers.get("referer") && new URL(ctx.request.headers.get("referer"));
+ const isEntryPoint = ctx.url.pathname === "/init.js" || ctx.url.pathname.startsWith("/scripts/lms/");
+ const isOriginatingFromThirdParty = ref && !ref.hostname.endsWith("powerplus.app") && !ref.hostname.endsWith("jottocraft.com");
+ const isDtechFollowUp = (ref.hostname === "dtechhs.instructure.com") && (ctx.url.pathname === "/scripts/lms/canvas.js");
+
+ if (isEntryPoint && isOriginatingFromThirdParty && !isDtechFollowUp) {
+ const isInstructureHosted = ref.hostname.endsWith("instructure.com");
+ const isDtechStudent = ref.hostname === "dtechhs.instructure.com";
+ const onDNetwork = ctx.request.headers.get("cf-connecting-ip") === DTECH_IP;
+
+ /**
+ * Record analytics data:
+ * - time
+ * - user agent
+ * - loaded entrypoint
+ * - is on instructure.com
+ * - is d.tech student
+ * - is on d.tech oracle network
+ * - country / region
+ * - cloudflare colo datacenter
+ */
+ ctx.loggingEnabled = true;
+ ctx.loggingProperties = {
+ at: new Date().getTime(),
+ ua: ctx.request.headers.get("user-agent") || "unknown",
+ entry: ctx.url.pathname,
+ isInstructureHosted: isInstructureHosted,
+ isDtechStudent: isDtechStudent,
+ onDNetwork: onDNetwork,
+ country: ctx.event.request.cf.country,
+ region: ctx.event.request.cf.regionCode,
+ colo: ctx.event.request.cf.colo
+ };
}
});