mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
## Description <!-- Briefly describe the purpose and scope of your changes --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Upgraded API and authentication services with dynamic scaling, enhanced load balancing, and real-time interaction endpoints. - Introduced new commands to streamline local development and container builds. - Added new endpoints for retrieving Steam account information and managing connections. - Implemented a QR code authentication interface for Steam, enhancing user login experiences. - **Database Updates** - Rolled out comprehensive schema migrations that improve data integrity and indexing. - Introduced new tables for managing Steam user credentials and machine information. - **UI Enhancements** - Added refreshed animated assets and an improved QR code login flow for a more engaging experience. - Introduced new styled components for displaying friends and games. - **Maintenance** - Completed extensive refactoring and configuration updates to optimize performance and development workflows. - Updated logging configurations and improved error handling mechanisms. - Streamlined resource definitions in the configuration files. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { Resource } from "sst";
|
|
import { subjects } from "../subjects";
|
|
import { realtime } from "sst/aws/realtime";
|
|
import { createClient } from "@openauthjs/openauth/client";
|
|
|
|
export const handler = realtime.authorizer(async (token) => {
|
|
//TODO: Use the following criteria for a topic - team-slug/container-id (container ids are not unique globally)
|
|
//TODO: Allow the authorizer to subscriber/publisher to listen on - team-slug topics only (as the container will listen on the team-slug/container-id topic to be specific)
|
|
// Return the topics to subscribe and publish
|
|
|
|
const client = createClient({
|
|
clientID: "api",
|
|
issuer: Resource.Auth.url
|
|
});
|
|
|
|
const result = await client.verify(subjects, token);
|
|
|
|
if (result.err) {
|
|
console.log("error", result.err)
|
|
return {
|
|
subscribe: [],
|
|
publish: [],
|
|
};
|
|
}
|
|
|
|
if (result.subject.type != "user") {
|
|
return {
|
|
subscribe: [],
|
|
publish: [],
|
|
};
|
|
}
|
|
|
|
return {
|
|
//It can publish and listen to other instances under this team
|
|
subscribe: [`${Resource.App.name}/${Resource.App.stage}/*`],
|
|
publish: [`${Resource.App.name}/${Resource.App.stage}/*`],
|
|
};
|
|
}); |