custom flag (2) (#1303)

## Description:

This PR implements the permission check logic.

Other related parts will be handled in a separate UI update.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors
This commit is contained in:
Aotumuri
2025-07-03 00:24:52 +00:00
committed by GitHub
parent a83c2bda97
commit 4dd6c9bac3
9 changed files with 713 additions and 101 deletions
+4
View File
@@ -17,6 +17,8 @@ export const CosmeticsSchema = z.object({
z.string(),
z.object({
name: z.string(),
role_group: z.string().optional(),
flares: z.array(z.string()).optional(),
}),
),
color: z.record(
@@ -24,6 +26,8 @@ export const CosmeticsSchema = z.object({
z.object({
color: z.string(),
name: z.string(),
role_group: z.string().optional(),
flares: z.array(z.string()).optional(),
}),
),
}),
+5 -4
View File
@@ -1,5 +1,3 @@
import { base64url } from "jose";
export class PatternDecoder {
private bytes: Uint8Array;
@@ -7,8 +5,11 @@ export class PatternDecoder {
readonly width: number;
readonly scale: number;
constructor(base64: string) {
this.bytes = base64url.decode(base64);
constructor(
base64: string,
base64urlDecode: (input: Uint8Array | string) => Uint8Array,
) {
this.bytes = base64urlDecode(base64);
if (this.bytes.length < 3) {
throw new Error(
+2 -1
View File
@@ -1,3 +1,4 @@
import { base64url } from "jose";
import { z } from "zod/v4";
import quickChatData from "../../resources/QuickChat.json" with { type: "json" };
import {
@@ -190,7 +191,7 @@ export const RequiredPatternSchema = z
.refine(
(val) => {
try {
new PatternDecoder(val);
new PatternDecoder(val, base64url.decode);
return true;
} catch (e) {
console.error(JSON.stringify(e.message, null, 2));
+2 -1
View File
@@ -1,3 +1,4 @@
import { base64url } from "jose";
import { Config } from "../configuration/Config";
import { PatternDecoder } from "../PatternDecoder";
import { ClientID, GameID, Player } from "../Schemas";
@@ -163,7 +164,7 @@ export class PlayerView {
this.decoder =
this.cosmetics.pattern === undefined
? undefined
: new PatternDecoder(this.cosmetics.pattern);
: new PatternDecoder(this.cosmetics.pattern, base64url.decode);
}
patternDecoder(): PatternDecoder | undefined {