app
components
data
functions
api
admin-apps
appeals
auth
data-transfers
events-team
game-appeals
game-bans
gme
inactivity
infractions
me
mod-queue
reports
uploads
[[id]].ts
_middleware.ts
status.ts
[[path]].ts
events.ts
webview-captcha.ts
_middleware.ts
common.ts
email.ts
gcloud.ts
permissions.ts
roblox-open-cloud.ts
public
.gitignore
.node-version
.prettierignore
OFL.txt
README.md
emotion-server.js
index.css
index.d.ts
package-lock.json
package.json
remix.config.js
server.ts
theme.ts
tsconfig.json
28 lines
852 B
TypeScript
28 lines
852 B
TypeScript
export async function onRequestGet(context: RequestContext) {
|
|
const attachment = (context.params.id as string[]).join("/");
|
|
const unsignedURL = `https://mediaproxy.carcrushers.cc/${attachment}?Expires=${(
|
|
Math.round(Date.now() / 1000) + 1800
|
|
).toString()}&KeyName=portal-media-linkgen`;
|
|
const signingKey = await crypto.subtle.importKey(
|
|
"raw",
|
|
Uint8Array.from(atob(context.env.URL_SIGNING_KEY), (c) => c.charCodeAt(0)),
|
|
{ hash: "SHA-1", name: "HMAC" },
|
|
false,
|
|
["sign"],
|
|
);
|
|
const signature = await crypto.subtle.sign(
|
|
"HMAC",
|
|
signingKey,
|
|
new TextEncoder().encode(unsignedURL),
|
|
);
|
|
|
|
return Response.redirect(
|
|
`${unsignedURL}&Signature=${btoa(
|
|
String.fromCharCode(...new Uint8Array(signature)),
|
|
)
|
|
.replaceAll("+", "-")
|
|
.replaceAll("/", "_")
|
|
.replaceAll("=", "")}`,
|
|
);
|
|
}
|