This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,212 @@
// Metro module 13794 (f13795).
import { Endpoints, AnalyticEvents } from "../../Constants";
import { intl, t } from "../../intl/index.native";
import Dispatcher from "../../Dispatcher";
import { HTTP } from "../../_bundle/sendRequest";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
import TrackedHTTPUtils from "../../utils/TrackedHTTPUtils";
import { NetworkActionNames } from "../../_bundle/Module503";
import { APIError } from "../../errors/index";
let env9602 = {};
const r19 = {
resetSuggestions: () => Dispatcher.dispatch({
type: "UNIQUE_USERNAME_SUGGESTIONS_RESET"
}),
fetchSuggestionsRegistration: async function fetchSuggestionsRegistration(global_name, r4 = 1500) {
let r89;
const timeout = r4;
let c27573_3 = 0;
let c30668_0;
L18: {
L16: {
try {
c30668_0 = void 0;
Dispatcher.dispatch({
type: "UNIQUE_USERNAME_SUGGESTIONS_RESET"
});
c27573_3 = 1;
c30668_0 = await HTTP.get({
url: Endpoints.POMELO_SUGGESTIONS_UNAUTHED,
query: global_name == null ? void 0 : {
global_name
},
timeout,
rejectWithError: true,
failImmediatelyWhenRateLimited: true
});
if (c30668_0.ok) {
if (c30668_0.body?.username != null) {
r89 = Dispatcher.dispatch({
type: "UNIQUE_USERNAME_REGISTRATION_SUGGESTIONS_SUCCESS",
suggestion: c30668_0.body,
source: global_name
});
c27573_3 = 0;
break L16;
}
}
c27573_3 = 0;
break L18;
} catch ($e) {
let r12 = $e;
if (c27573_3 !== 0) {
while (true) {
try {
c27573_3 = 0;
break L18;
} catch ($e) {
r12 = $e;
if (c27573_3 === 0) {
break;
}
}
}
}
throw r12;
}
}
return r89;
}
},
attemptUsername: async function attemptUsername(username, r5 = "modal") {
let r58;
const location2 = r5;
let r6 = arguments[2];
if (r6 === void 0) {
r6 = false;
}
let c20731_2 = r6;
let r4 = arguments[3];
if (r4 === void 0) {
r4 = false;
}
const one_click_flow = r4;
let anyErrorMessage, c27574_1, c27574_2, c27574_3;
let c27574_4 = 0;
const r20 = void 0;
const r19 = env9602;
L18: {
L17: {
try {
let env30669;
c27574_2 = r20;
const r41 = env30669 = {
$parent: r19
};
c27574_1 = r41;
env30669[0] = void 0;
env30669[1] = void 0;
env30669[2] = void 0;
const reason = (function validate(a0) {
let r16;
L9: {
if (/^[A-Za-z0-9_.]*$/.test(a0) === false) {
r16 = intl.string(t.z7c4bP);
} else if (a0.includes("..")) {
r16 = intl.string(t["C7G+gr"]);
} else {
if (!(a0.length < 2)) {
const r15 = a0.length > 32;
r16 = void 0;
if (!r15) {
break L9;
}
}
r16 = intl.formatToPlainString(t.IpijXA, {
maxNum: 32,
minNum: 2
});
}
}
return r16;
})(username);
if (reason != null) {
AnalyticsUtils.track(AnalyticEvents.POMELO_ERRORS, {
reason,
username_error: true,
location: location2,
one_click_flow
});
r58 = Dispatcher.dispatch({
type: "UNIQUE_USERNAME_ATTEMPT_FAILURE",
username,
error: reason
});
break L18;
}
c27574_4 = 1;
env30669[0] = await TrackedHTTPUtils.post({
url: c20731_2 ? Endpoints.POMELO_ATTEMPT_UNAUTHED : Endpoints.POMELO_ATTEMPT,
body: {
username
},
trackedActionData: {
event: NetworkActionNames.POMELO_ATTEMPT,
properties: {
requested_username: username
}
},
rejectWithError: false
});
if (env30669[0].body.taken) {
AnalyticsUtils.track(AnalyticEvents.POMELO_ERRORS, {
reason: "already_taken",
username_error: true,
location: location2,
one_click_flow
});
}
Dispatcher.dispatch({
type: "UNIQUE_USERNAME_ATTEMPT_SUCCESS",
username,
taken: env30669[0].body.taken
});
c27574_4 = 0;
} catch ($e) {
const r39 = $e;
let r14 = r39;
c27574_3 = r39;
if (c27574_4 !== 0) {
while (true) {
try {
const r138 = c27574_3;
c27574_4 = 0;
env30669[3] = r138;
env30669[1] = new APIError(env30669[3]);
anyErrorMessage = env30669[1].getAnyErrorMessage();
if (anyErrorMessage == null) {
anyErrorMessage = void 0;
}
env30669[2] = anyErrorMessage;
AnalyticsUtils.track(AnalyticEvents.POMELO_ERRORS, {
reason: env30669[2],
username_error: true,
location: location2,
one_click_flow
});
Dispatcher.dispatch({
username,
type: "UNIQUE_USERNAME_ATTEMPT_FAILURE",
error: env30669[1].status != null ? env30669[1].status < 500 ? env30669[1].status !== 401 ? env30669[2] : void 0 : void 0 : void 0,
statusCode: env30669[1].status,
retryAfter: env30669[1].retryAfter
});
break L17;
} catch (r134) {
r14 = r134;
c27574_3 = r134;
if (c27574_4 === 0) {
break;
}
}
}
}
throw r14;
}
}
return void 0;
}
return r58;
}
};
export default r19;
@@ -0,0 +1,145 @@
// Metro module 13793 (f13794).
import LRUCache from "../../_bundle/LRUCache";
import Durations from "../../utils/Durations";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c9601_2 = {
taken: null,
error: void 0,
rateLimited: true
};
let c9601_3 = {
validations: new LRUCache({
max: 100,
maxAge: 60000
}),
currentUsernameInvalid: false,
retryAfterTime: null,
suggestions: {
migration: {
suggestion: {
username: void 0
},
fetched: false,
usernameSuggestionLoading: false
},
registration: {
suggestion: {
username: void 0
},
source: void 0,
fetched: false
}
}
};
class UniqueUsernamesStore extends Module589.Store {
static displayName = "UniqueUsernamesStore";
isRateLimited() {
return c9601_3.retryAfterTime != null && Date.now() < c9601_3.retryAfterTime;
}
validate(a0) {
let r7, r15;
L9: {
L3: {
r7 = c9601_3.validations.get(a0);
if (this.isRateLimited()) {
if (r7 != null && !r7.rateLimited) {
break L3;
}
r15 = c9601_2;
break L9;
}
}
r15 = !this.isRateLimited() && r7 != null ? r7.rateLimited ? void 0 : r7 : r7;
}
return r15;
}
registrationUsernameSuggestion() {
return c9601_3.suggestions.registration.suggestion.username;
}
usernameSuggestion() {
return c9601_3.suggestions.migration.suggestion.username;
}
usernameSuggestionLoading() {
return c9601_3.suggestions.migration.usernameSuggestionLoading;
}
isCurrentUsernameInvalid() {
return c9601_3.currentUsernameInvalid;
}
wasRegistrationSuggestionFetched(a0) {
return c9601_3.suggestions.registration.source === a0 && c9601_3.suggestions.registration.fetched;
}
wasSuggestionsFetched() {
return c9601_3.suggestions.migration.fetched;
}
}
const uniqueUsernamesStore = new UniqueUsernamesStore(Dispatcher, {
UNIQUE_USERNAME_ATTEMPT_SUCCESS: function handleUniqueUsernameAttemptSuccess(a0) {
c9601_3.validations.set(a0.username, {
taken: a0.taken
});
},
UNIQUE_USERNAME_ATTEMPT_FAILURE: function handleUniqueUsernameAttemptFailure({ username, error, statusCode, retryAfter }) {
if (statusCode === 429) {
const validations = c9601_3.validations;
const r18 = {
taken: null,
error,
rateLimited: true
};
let r11 = retryAfter;
if (r11 == null) {
r11 = 7;
}
validations.set(username, r18, r11 * Durations.Millis.SECOND);
} else {
c9601_3.validations.set(username, {
taken: null,
error
});
}
if (retryAfter != null) {
c9601_3.retryAfterTime = Date.now() + retryAfter * Durations.Millis.SECOND;
}
},
UNIQUE_USERNAME_SUGGESTIONS_RESET: function handleUniqueUsernameSuggestionsReset() {
c9601_3.suggestions.migration = {
suggestion: {
username: void 0
},
fetched: false,
usernameSuggestionLoading: false
};
c9601_3.suggestions.registration = {
suggestion: {
username: void 0
},
source: void 0,
fetched: false
};
},
UNIQUE_USERNAME_SUGGESTIONS_SUCCESS: function handleUniqueUsernameSuggestionsSuccess({ suggestion }) {
c9601_3.suggestions.migration = {
suggestion,
fetched: true,
usernameSuggestionLoading: false
};
if (suggestion?.invalid_current_username === true) {
c9601_3.currentUsernameInvalid = true;
}
},
UNIQUE_USERNAME_REGISTRATION_SUGGESTIONS_SUCCESS: function handleUniqueUsernameRegistrationSuggestionsSuccess(a0) {
const suggestion = a0.suggestion;
c9601_3.suggestions.registration = {
suggestion,
source: a0.source,
fetched: true
};
if (suggestion?.username != null) {
c9601_3.validations.set(suggestion.username, {
taken: false
});
}
}
});
export default uniqueUsernamesStore;
@@ -0,0 +1,8 @@
// Metro module 13790 (f13791).
const r8 = {
AVAILABLE: "AVAILABLE",
ERROR: "ERROR",
RATE_LIMIT: "RATE_LIMIT",
INTERNAL_ERROR: "INTERNAL_ERROR"
};
export { r8 as NameValidationState };
@@ -0,0 +1,32 @@
// Metro module 13795 (f13796).
import { match, P } from "../../_bundle/Module4389";
import { NameValidationState } from "./UniqueUsernamesTypes";
import { intl, t } from "../../intl/index.native";
export function formatUsernameLiveCheckValidation(a0) {
return match(a0).with({
rateLimited: true
}, () => ({
type: NameValidationState.RATE_LIMIT,
message: intl.string(t.T15lqn)
})).with({
error: P.not(P.nullish)
}, (a0) => ({
type: NameValidationState.ERROR,
message: a0.error
})).with({
taken: false
}, () => ({
type: NameValidationState.AVAILABLE,
message: intl.string(t.PgfBSx)
})).with({
taken: true
}, () => ({
type: NameValidationState.ERROR,
message: intl.string(t.mCrAUb)
})).with({
error: P.nullish
}, () => ({
type: NameValidationState.INTERNAL_ERROR,
message: ""
})).otherwise(() => {});
}
@@ -0,0 +1,37 @@
// Metro module 13792 (f13793).
import { useMemo, useEffect } from "react";
import UniqueUsernamesStore from "./UniqueUsernamesStore";
import { useStateFromStores } from "../../_bundle/defaultAreStatesEqual";
import { debounce } from "../../_bundle/Module12";
import UniqueUsernamesActionCreators from "./UniqueUsernamesActionCreators";
import { formatUsernameLiveCheckValidation } from "./UniqueUsernamesUtils";
export function useUsernameLiveCheck(a0) {
let stateFromStores2, memo;
let c20729_0 = a0;
let r10 = arguments[1];
if (r10 === void 0) {
r10 = true;
}
let c20729_1 = r10;
let r11 = arguments[2];
if (r11 === void 0) {
r11 = false;
}
let c20729_2 = r11;
let r3 = arguments[3];
if (r3 === void 0) {
r3 = false;
}
let c20729_3 = r3;
stateFromStores2 = void 0;
memo = void 0;
const stateFromStores = useStateFromStores([UniqueUsernamesStore], () => UniqueUsernamesStore.validate(c20729_0), [a0]);
stateFromStores2 = useStateFromStores([UniqueUsernamesStore], () => UniqueUsernamesStore.isRateLimited());
memo = useMemo(() => debounce((a0) => UniqueUsernamesActionCreators.attemptUsername(a0, c20729_2 ? "registration" : "modal", c20729_2, c20729_3), 800), [r11, r3]);
useEffect(() => {
if (c20729_1 && !stateFromStores2 && stateFromStores == null && c20729_0 !== "") {
memo(c20729_0);
}
}, [r10, stateFromStores2, stateFromStores, a0, memo]);
return useMemo(() => stateFromStores != null ? formatUsernameLiveCheckValidation(stateFromStores) : void 0, [stateFromStores]);
}
@@ -0,0 +1,33 @@
// Metro module 13791 (f13792).
import { useState, useEffect } from "react";
import { useUsernameLiveCheck } from "./useUsernameLiveCheck";
export const useUsernameStatus = function(a0) {
let r10 = arguments[1];
if (r10 === void 0) {
r10 = true;
}
let r7 = arguments[2];
if (r7 === void 0) {
r7 = false;
}
let r8 = arguments[3];
if (r8 === void 0) {
r8 = void 0;
}
let c20728_1 = r8;
const usernameLiveCheck = useUsernameLiveCheck(a0, r10, r7);
const [state, setState] = useState(void 0);
useEffect(() => {
L5: {
if (a0 !== "" && a0 !== c20728_1) {
if (usernameLiveCheck == null) {
break L5;
}
setState(usernameLiveCheck);
} else {
setState(void 0);
}
}
}, [usernameLiveCheck, a0, r8]);
return state;
};