rategame-shared 1.1.423 → 1.1.425
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/containsFancyText.d.ts +24 -0
- package/dist/helpers/containsFancyText.js +107 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/models/pick.d.ts +6 -10
- package/dist/schemas/pick.d.ts +5 -23471
- package/dist/schemas/pick.js +18 -47
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects "fancy font" / disguised characters produced by web generators
|
|
3
|
+
* like https://pixelied.com/font-generator/fancy-text or
|
|
4
|
+
* https://www.namecheap.com/visual/font-generator/italic/.
|
|
5
|
+
*
|
|
6
|
+
* Covers:
|
|
7
|
+
* - Mathematical Alphanumeric Symbols (U+1D400–U+1D7FF):
|
|
8
|
+
* bold, italic, script, fraktur, double-struck, sans-serif,
|
|
9
|
+
* sans-serif italic, monospace, etc.
|
|
10
|
+
* - Halfwidth/Fullwidth Latin letters and digits (Type)
|
|
11
|
+
* - Enclosed Alphanumerics (Ⓐ, ⓐ, 🅐, 🅰️)
|
|
12
|
+
* - "Upside-down" / "turned" letters used by flip-text generators
|
|
13
|
+
* (⊥, ǝ, ɹ, ʇ, ʞ, ʎ, ɥ, ɐ, ɔ, ∀, ᗺ, ⅄, ...). Requires ≥2 of these
|
|
14
|
+
* to avoid false positives from a stray IPA character.
|
|
15
|
+
*
|
|
16
|
+
* Shared by the API (server-side guard) and clients (pre-submit guard).
|
|
17
|
+
*/
|
|
18
|
+
export declare function containsFancyText(text: string | null | undefined): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Standard user-facing copy when a submission is rejected because it
|
|
21
|
+
* contains fancy/disguised text. Centralised so the same string is shown
|
|
22
|
+
* regardless of which form the user hit.
|
|
23
|
+
*/
|
|
24
|
+
export declare const FANCY_TEXT_ERROR_MESSAGE = "Your post contains styled or upside-down characters. Please rewrite it using standard letters.";
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Detects "fancy font" / disguised characters produced by web generators
|
|
4
|
+
* like https://pixelied.com/font-generator/fancy-text or
|
|
5
|
+
* https://www.namecheap.com/visual/font-generator/italic/.
|
|
6
|
+
*
|
|
7
|
+
* Covers:
|
|
8
|
+
* - Mathematical Alphanumeric Symbols (U+1D400–U+1D7FF):
|
|
9
|
+
* bold, italic, script, fraktur, double-struck, sans-serif,
|
|
10
|
+
* sans-serif italic, monospace, etc.
|
|
11
|
+
* - Halfwidth/Fullwidth Latin letters and digits (Type)
|
|
12
|
+
* - Enclosed Alphanumerics (Ⓐ, ⓐ, 🅐, 🅰️)
|
|
13
|
+
* - "Upside-down" / "turned" letters used by flip-text generators
|
|
14
|
+
* (⊥, ǝ, ɹ, ʇ, ʞ, ʎ, ɥ, ɐ, ɔ, ∀, ᗺ, ⅄, ...). Requires ≥2 of these
|
|
15
|
+
* to avoid false positives from a stray IPA character.
|
|
16
|
+
*
|
|
17
|
+
* Shared by the API (server-side guard) and clients (pre-submit guard).
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.FANCY_TEXT_ERROR_MESSAGE = exports.containsFancyText = void 0;
|
|
21
|
+
const TURNED_LETTERS = [
|
|
22
|
+
"\u0250",
|
|
23
|
+
"\u0254",
|
|
24
|
+
"\u025F",
|
|
25
|
+
"\u0183",
|
|
26
|
+
"\u0265",
|
|
27
|
+
"\u0131",
|
|
28
|
+
"\u027E",
|
|
29
|
+
"\u029E",
|
|
30
|
+
"\u026F",
|
|
31
|
+
"\u0279",
|
|
32
|
+
"\u0287",
|
|
33
|
+
"\u028C",
|
|
34
|
+
"\u028D",
|
|
35
|
+
"\u028E",
|
|
36
|
+
"\u01DD",
|
|
37
|
+
"\u22A5",
|
|
38
|
+
"\u2200",
|
|
39
|
+
"\u2144",
|
|
40
|
+
"\u15BA",
|
|
41
|
+
"\u1D1A",
|
|
42
|
+
"\u15E1",
|
|
43
|
+
"\u2143",
|
|
44
|
+
"\u2142",
|
|
45
|
+
"\u0186",
|
|
46
|
+
"\u018E",
|
|
47
|
+
"\u2141",
|
|
48
|
+
"\u019F",
|
|
49
|
+
"\u01EB",
|
|
50
|
+
"\u0282", // ʂ
|
|
51
|
+
];
|
|
52
|
+
const TURNED_LETTERS_SET = new Set(TURNED_LETTERS);
|
|
53
|
+
function containsMathAlphanumeric(text) {
|
|
54
|
+
for (const ch of text) {
|
|
55
|
+
const cp = ch.codePointAt(0);
|
|
56
|
+
if (cp >= 0x1d400 && cp <= 0x1d7ff)
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
function containsFullwidthAlphanumeric(text) {
|
|
62
|
+
for (const ch of text) {
|
|
63
|
+
const cp = ch.codePointAt(0);
|
|
64
|
+
if ((cp >= 0xff10 && cp <= 0xff19) ||
|
|
65
|
+
(cp >= 0xff21 && cp <= 0xff3a) ||
|
|
66
|
+
(cp >= 0xff41 && cp <= 0xff5a)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
function containsEnclosedAlphanumeric(text) {
|
|
73
|
+
for (const ch of text) {
|
|
74
|
+
const cp = ch.codePointAt(0);
|
|
75
|
+
if (cp >= 0x2460 && cp <= 0x24ff)
|
|
76
|
+
return true;
|
|
77
|
+
if (cp >= 0x1f100 && cp <= 0x1f1ff)
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
function containsTurnedLetters(text) {
|
|
83
|
+
let count = 0;
|
|
84
|
+
for (const ch of text) {
|
|
85
|
+
if (TURNED_LETTERS_SET.has(ch)) {
|
|
86
|
+
count++;
|
|
87
|
+
if (count >= 2)
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
function containsFancyText(text) {
|
|
94
|
+
if (!text)
|
|
95
|
+
return false;
|
|
96
|
+
return (containsMathAlphanumeric(text) ||
|
|
97
|
+
containsFullwidthAlphanumeric(text) ||
|
|
98
|
+
containsEnclosedAlphanumeric(text) ||
|
|
99
|
+
containsTurnedLetters(text));
|
|
100
|
+
}
|
|
101
|
+
exports.containsFancyText = containsFancyText;
|
|
102
|
+
/**
|
|
103
|
+
* Standard user-facing copy when a submission is rejected because it
|
|
104
|
+
* contains fancy/disguised text. Centralised so the same string is shown
|
|
105
|
+
* regardless of which form the user hit.
|
|
106
|
+
*/
|
|
107
|
+
exports.FANCY_TEXT_ERROR_MESSAGE = "Your post contains styled or upside-down characters. Please rewrite it using standard letters.";
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export * from "./models/userEvent";
|
|
|
39
39
|
export * from "./models/content";
|
|
40
40
|
export * from "./models/advertisement";
|
|
41
41
|
export * from "./helpers/index";
|
|
42
|
+
export * from "./helpers/containsFancyText";
|
|
42
43
|
export * from "./models/player";
|
|
43
44
|
export * from "./models/voting";
|
|
44
45
|
export * from "./models/stadium";
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,7 @@ __exportStar(require("./models/userEvent"), exports);
|
|
|
55
55
|
__exportStar(require("./models/content"), exports);
|
|
56
56
|
__exportStar(require("./models/advertisement"), exports);
|
|
57
57
|
__exportStar(require("./helpers/index"), exports);
|
|
58
|
+
__exportStar(require("./helpers/containsFancyText"), exports);
|
|
58
59
|
__exportStar(require("./models/player"), exports);
|
|
59
60
|
__exportStar(require("./models/voting"), exports);
|
|
60
61
|
__exportStar(require("./models/stadium"), exports);
|
package/dist/models/pick.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { pickSchema, miniPickSchema, pickSubmissionDtoSchema, pickSubmissionResponseDtoSchema, pickUpdateDtoSchema, pickDeleteDtoSchema, pickDeleteResponseDtoSchema, gamePickStatsResponseDtoSchema, userPickResponseDtoSchema, userPicksLeagueStatsSchema, userPicksStatsResponseDtoSchema, userPicksTeamStatsSchema, userPicksByTeamResponseDtoSchema, gamePickUsersResponseDtoSchema, gamePickUsersPaginatedResponseDtoSchema,
|
|
2
|
+
import { pickSchema, miniPickSchema, pickSubmissionDtoSchema, pickSubmissionResponseDtoSchema, pickUpdateDtoSchema, pickDeleteDtoSchema, pickDeleteResponseDtoSchema, gamePickStatsResponseDtoSchema, userPickResponseDtoSchema, userPicksLeagueStatsSchema, userPicksStatsResponseDtoSchema, userPicksTeamStatsSchema, userPicksByTeamResponseDtoSchema, gamePickUsersResponseDtoSchema, gamePickUsersPaginatedResponseDtoSchema, pickEmKindSchema, pickEmRoundStatsSchema, pickEmPicksResponseDtoSchema, pickEmLeaderboardEntrySchema, pickEmLeaderboardResponseDtoSchema } from "../schemas/pick";
|
|
3
3
|
export type Pick = z.infer<typeof pickSchema>;
|
|
4
4
|
export type MiniPick = z.infer<typeof miniPickSchema>;
|
|
5
5
|
export type PickSubmissionDto = z.infer<typeof pickSubmissionDtoSchema>;
|
|
@@ -15,12 +15,8 @@ export type UserPicksByTeamResponseDto = z.infer<typeof userPicksByTeamResponseD
|
|
|
15
15
|
export type GamePickUsersResponseDto = z.infer<typeof gamePickUsersResponseDtoSchema>;
|
|
16
16
|
export type GamePickUsersPaginatedResponseDto = z.infer<typeof gamePickUsersPaginatedResponseDtoSchema>;
|
|
17
17
|
export type PickDeleteResponseDto = z.infer<typeof pickDeleteResponseDtoSchema>;
|
|
18
|
-
export type
|
|
19
|
-
export type
|
|
20
|
-
export type
|
|
21
|
-
export type
|
|
22
|
-
export type
|
|
23
|
-
export type FifaPickEmRoundStats = z.infer<typeof fifaPickEmRoundStatsSchema>;
|
|
24
|
-
export type FifaPickEmPicksResponseDto = z.infer<typeof fifaPickEmPicksResponseDtoSchema>;
|
|
25
|
-
export type FifaPickEmLeaderboardEntry = z.infer<typeof fifaPickEmLeaderboardEntrySchema>;
|
|
26
|
-
export type FifaPickEmLeaderboardResponseDto = z.infer<typeof fifaPickEmLeaderboardResponseDtoSchema>;
|
|
18
|
+
export type PickEmKind = z.infer<typeof pickEmKindSchema>;
|
|
19
|
+
export type PickEmRoundStats = z.infer<typeof pickEmRoundStatsSchema>;
|
|
20
|
+
export type PickEmPicksResponseDto = z.infer<typeof pickEmPicksResponseDtoSchema>;
|
|
21
|
+
export type PickEmLeaderboardEntry = z.infer<typeof pickEmLeaderboardEntrySchema>;
|
|
22
|
+
export type PickEmLeaderboardResponseDto = z.infer<typeof pickEmLeaderboardResponseDtoSchema>;
|