diff --git a/README.md b/README.md index 7ccbd4b0..b810bba0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ -# nestri - -Opensource and selfhostable cloud gaming platform - -> TIP -> TODO: Finish up on this README \ No newline at end of file +

+ + + + + +

diff --git a/apps/docs/sst-env.d.ts b/apps/docs/sst-env.d.ts new file mode 100644 index 00000000..b6a7e906 --- /dev/null +++ b/apps/docs/sst-env.d.ts @@ -0,0 +1,9 @@ +/* This file is auto-generated by SST. Do not edit. */ +/* tslint:disable */ +/* eslint-disable */ +/* deno-fmt-ignore-file */ + +/// + +import "sst" +export {} \ No newline at end of file diff --git a/infra-old/api.ts b/infra-old/api.ts new file mode 100644 index 00000000..a93e8539 --- /dev/null +++ b/infra-old/api.ts @@ -0,0 +1,120 @@ +import { bus } from "./bus"; +import { vpc } from "./vpc"; +import { auth } from "./auth"; +import { domain } from "./dns"; +import { secret } from "./secret"; +import { postgres } from "./postgres"; + +const urls = new sst.Linkable("Urls", { + properties: { + api: `https://api.${domain}`, + auth: `https://auth.${domain}`, + site: $dev ? "http://localhost:3000" : `https://console.${domain}`, + } +}) + +const apiFn = new sst.aws.Function("ApiFn", { + vpc, + handler: "packages/functions/src/api/index.handler", + streaming: !$dev, + link: [ + bus, + urls, + auth, + postgres, + secret.SteamApiKey, + secret.PolarSecret, + secret.PolarWebhookSecret, + secret.NestriFamilyMonthly, + secret.NestriFamilyYearly, + secret.NestriFreeMonthly, + secret.NestriProMonthly, + secret.NestriProYearly, + ], + url: true, +}); + +const provider = new aws.Provider("UsEast1", { region: "us-east-1" }); + +const webAcl = new aws.wafv2.WebAcl( + "ApiWaf", + { + scope: "CLOUDFRONT", + defaultAction: { + allow: {}, + }, + visibilityConfig: { + cloudwatchMetricsEnabled: true, + metricName: "api-rate-limit-metric", + sampledRequestsEnabled: true, + }, + rules: [ + { + name: "rate-limit-rule", + priority: 1, + action: { + block: { + customResponse: { + responseCode: 429, + customResponseBodyKey: "rate-limit-response", + }, + }, + }, + statement: { + rateBasedStatement: { + limit: 2 * 60, // 2 rps per authorization header + evaluationWindowSec: 60, + aggregateKeyType: "CUSTOM_KEYS", + customKeys: [ + { + header: { + name: "Authorization", + textTransformations: [{ priority: 0, type: "NONE" }], + }, + }, + ], + }, + }, + visibilityConfig: { + cloudwatchMetricsEnabled: true, + metricName: "rate-limit-rule-metric", + sampledRequestsEnabled: true, + }, + }, + ], + customResponseBodies: [ + { + key: "rate-limit-response", + content: JSON.stringify({ + type: "rate_limit", + code: "too_many_requests", + message: "Rate limit exceeded. Please try again later.", + }), + contentType: "APPLICATION_JSON", + }, + ], + }, + { provider }, +); + +export const api = new sst.aws.Router("Api", { + routes: { + "/*": apiFn.url, + }, + domain: { + name: "api." + domain, + dns: sst.cloudflare.dns(), + }, + transform: { + cdn(args) { + if (!args.transform) { + args.transform = { + distribution: {}, + }; + } + args.transform!.distribution = { + webAclId: webAcl.arn, + }; + }, + }, +}); \ No newline at end of file diff --git a/infra/auth.ts b/infra-old/auth.ts similarity index 100% rename from infra/auth.ts rename to infra-old/auth.ts diff --git a/infra/bus.ts b/infra-old/bus.ts similarity index 100% rename from infra/bus.ts rename to infra-old/bus.ts diff --git a/infra/cluster.ts b/infra-old/cluster.ts similarity index 100% rename from infra/cluster.ts rename to infra-old/cluster.ts diff --git a/infra/dns.ts b/infra-old/dns.ts similarity index 100% rename from infra/dns.ts rename to infra-old/dns.ts diff --git a/infra/email.ts b/infra-old/email.ts similarity index 100% rename from infra/email.ts rename to infra-old/email.ts diff --git a/infra/postgres.ts b/infra-old/postgres.ts similarity index 100% rename from infra/postgres.ts rename to infra-old/postgres.ts diff --git a/infra/realtime.ts b/infra-old/realtime.ts similarity index 100% rename from infra/realtime.ts rename to infra-old/realtime.ts diff --git a/infra/secret.ts b/infra-old/secret.ts similarity index 100% rename from infra/secret.ts rename to infra-old/secret.ts diff --git a/infra/stage.ts b/infra-old/stage.ts similarity index 100% rename from infra/stage.ts rename to infra-old/stage.ts diff --git a/infra/storage.ts b/infra-old/storage.ts similarity index 100% rename from infra/storage.ts rename to infra-old/storage.ts diff --git a/infra/vpc.ts b/infra-old/vpc.ts similarity index 100% rename from infra/vpc.ts rename to infra-old/vpc.ts diff --git a/infra/www.ts b/infra-old/www.ts similarity index 100% rename from infra/www.ts rename to infra-old/www.ts diff --git a/infra/zero.ts b/infra-old/zero.ts similarity index 100% rename from infra/zero.ts rename to infra-old/zero.ts diff --git a/infra/api.ts b/infra/api.ts index a93e8539..8b137891 100644 --- a/infra/api.ts +++ b/infra/api.ts @@ -1,120 +1 @@ -import { bus } from "./bus"; -import { vpc } from "./vpc"; -import { auth } from "./auth"; -import { domain } from "./dns"; -import { secret } from "./secret"; -import { postgres } from "./postgres"; -const urls = new sst.Linkable("Urls", { - properties: { - api: `https://api.${domain}`, - auth: `https://auth.${domain}`, - site: $dev ? "http://localhost:3000" : `https://console.${domain}`, - } -}) - -const apiFn = new sst.aws.Function("ApiFn", { - vpc, - handler: "packages/functions/src/api/index.handler", - streaming: !$dev, - link: [ - bus, - urls, - auth, - postgres, - secret.SteamApiKey, - secret.PolarSecret, - secret.PolarWebhookSecret, - secret.NestriFamilyMonthly, - secret.NestriFamilyYearly, - secret.NestriFreeMonthly, - secret.NestriProMonthly, - secret.NestriProYearly, - ], - url: true, -}); - -const provider = new aws.Provider("UsEast1", { region: "us-east-1" }); - -const webAcl = new aws.wafv2.WebAcl( - "ApiWaf", - { - scope: "CLOUDFRONT", - defaultAction: { - allow: {}, - }, - visibilityConfig: { - cloudwatchMetricsEnabled: true, - metricName: "api-rate-limit-metric", - sampledRequestsEnabled: true, - }, - rules: [ - { - name: "rate-limit-rule", - priority: 1, - action: { - block: { - customResponse: { - responseCode: 429, - customResponseBodyKey: "rate-limit-response", - }, - }, - }, - statement: { - rateBasedStatement: { - limit: 2 * 60, // 2 rps per authorization header - evaluationWindowSec: 60, - aggregateKeyType: "CUSTOM_KEYS", - customKeys: [ - { - header: { - name: "Authorization", - textTransformations: [{ priority: 0, type: "NONE" }], - }, - }, - ], - }, - }, - visibilityConfig: { - cloudwatchMetricsEnabled: true, - metricName: "rate-limit-rule-metric", - sampledRequestsEnabled: true, - }, - }, - ], - customResponseBodies: [ - { - key: "rate-limit-response", - content: JSON.stringify({ - type: "rate_limit", - code: "too_many_requests", - message: "Rate limit exceeded. Please try again later.", - }), - contentType: "APPLICATION_JSON", - }, - ], - }, - { provider }, -); - -export const api = new sst.aws.Router("Api", { - routes: { - "/*": apiFn.url, - }, - domain: { - name: "api." + domain, - dns: sst.cloudflare.dns(), - }, - transform: { - cdn(args) { - if (!args.transform) { - args.transform = { - distribution: {}, - }; - } - args.transform!.distribution = { - webAclId: webAcl.arn, - }; - }, - }, -}); \ No newline at end of file diff --git a/package.json b/package.json index f32a2c7f..61ecc9de 100644 --- a/package.json +++ b/package.json @@ -11,20 +11,18 @@ "engines": { "node": ">=18" }, - "packageManager": "bun@1.2.4", + "packageManager": "bun@1.2.18", "private": true, "scripts": { "format": "prettier --write \"**/*.{ts,tsx,md}\"", "sso": "aws sso login --sso-session=nestri --no-browser --use-device-code" }, "overrides": { - "@openauthjs/openauth": "0.4.3", - "steam-session": "1.9.3" + "@openauthjs/openauth": "0.4.3" }, "patchedDependencies": { "@macaron-css/solid@1.5.3": "patches/@macaron-css%2Fsolid@1.5.3.patch", - "drizzle-orm@0.36.1": "patches/drizzle-orm@0.36.1.patch", - "steam-session@1.9.3": "patches/steam-session@1.9.3.patch" + "drizzle-orm@0.36.1": "patches/drizzle-orm@0.36.1.patch" }, "trustedDependencies": [ "core-js-pure", @@ -39,4 +37,4 @@ "dependencies": { "sst": "^3.17.8" } -} \ No newline at end of file +} diff --git a/patches/steam-session@1.9.3.patch b/patches/steam-session@1.9.3.patch deleted file mode 100644 index 6e127970..00000000 --- a/patches/steam-session@1.9.3.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/dist/AuthenticationClient.js b/dist/AuthenticationClient.js -index a7144534a4c27b25e63804aeb4ae87a1f9c7a4e0..068250690a7b6bc4c2c5270cd603f7190a925956 100644 ---- a/dist/AuthenticationClient.js -+++ b/dist/AuthenticationClient.js -@@ -314,7 +314,7 @@ class AuthenticationClient extends events_1.EventEmitter { - cookie: 'mobileClient=android; mobileClientVersion=777777 3.0.0' - }, - deviceDetails: { -- device_friendly_name: 'Galaxy S22', -+ device_friendly_name: 'Nestri Mobile', - platform_type: EAuthTokenPlatformType_1.default.MobileApp, - os_type: EOSType_1.default.AndroidUnknown, - gaming_device_type: 528 // dunno -diff --git a/src/AuthenticationClient.ts b/src/AuthenticationClient.ts -index 9e1c5bcf8b36d304d313c5b35795b4b543da27dd..17bce1acc689c7210060e5cea196ca63e973355b 100644 ---- a/src/AuthenticationClient.ts -+++ b/src/AuthenticationClient.ts -@@ -414,7 +414,7 @@ export default class AuthenticationClient extends EventEmitter { - cookie: 'mobileClient=android; mobileClientVersion=777777 3.0.0' - }, - deviceDetails: { -- device_friendly_name: 'Galaxy S22', -+ device_friendly_name: 'Nestri Mobile', - platform_type: EAuthTokenPlatformType.MobileApp, - os_type: EOSType.AndroidUnknown, - gaming_device_type: 528 // dunno \ No newline at end of file diff --git a/sst-env.d.ts b/sst-env.d.ts index 65e99aa6..4b23c118 100644 --- a/sst-env.d.ts +++ b/sst-env.d.ts @@ -6,132 +6,6 @@ import "sst" declare module "sst" { export interface Resource { - "Api": { - "type": "sst.aws.Router" - "url": string - } - "ApiFn": { - "name": string - "type": "sst.aws.Function" - "url": string - } - "Auth": { - "type": "sst.aws.Auth" - "url": string - } - "Bus": { - "arn": string - "name": string - "type": "sst.aws.Bus" - } - "CDNRouter": { - "type": "sst.aws.Router" - "url": string - } - "Database": { - "clusterArn": string - "database": string - "host": string - "password": string - "port": number - "reader": string - "secretArn": string - "type": "sst.aws.Aurora" - "username": string - } - "DiscordClientID": { - "type": "sst.sst.Secret" - "value": string - } - "DiscordClientSecret": { - "type": "sst.sst.Secret" - "value": string - } - "Dlq": { - "type": "sst.aws.Queue" - "url": string - } - "Email": { - "configSet": string - "sender": string - "type": "sst.aws.Email" - } - "GithubClientID": { - "type": "sst.sst.Secret" - "value": string - } - "GithubClientSecret": { - "type": "sst.sst.Secret" - "value": string - } - "NestriFamilyMonthly": { - "type": "sst.sst.Secret" - "value": string - } - "NestriFamilyYearly": { - "type": "sst.sst.Secret" - "value": string - } - "NestriFreeMonthly": { - "type": "sst.sst.Secret" - "value": string - } - "NestriProMonthly": { - "type": "sst.sst.Secret" - "value": string - } - "NestriProYearly": { - "type": "sst.sst.Secret" - "value": string - } - "PolarSecret": { - "type": "sst.sst.Secret" - "value": string - } - "PolarWebhookSecret": { - "type": "sst.sst.Secret" - "value": string - } - "Realtime": { - "authorizer": string - "endpoint": string - "type": "sst.aws.Realtime" - } - "RetryQueue": { - "type": "sst.aws.Queue" - "url": string - } - "SteamApiKey": { - "type": "sst.sst.Secret" - "value": string - } - "Storage": { - "name": string - "type": "sst.aws.Bucket" - } - "Urls": { - "api": string - "auth": string - "site": string - "type": "sst.sst.Linkable" - } - "VPC": { - "bastion": string - "type": "sst.aws.Vpc" - } - "Web": { - "type": "sst.aws.StaticSite" - "url": string - } - "Zero": { - "service": string - "type": "sst.aws.Service" - "url": string - } - "ZeroStorage": { - "name": string - "type": "sst.aws.Bucket" - } } }