decord/source/modules/application_account_linking/AccountLinkManager.tsx
github-actions 20a21ad13f chore: update source for alpha 346.5
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4791.js (118.4 MB)
2026-09-11 19:12:58 +00:00

139 lines
5.1 KiB
TypeScript

// Module ID: 17027
// Function ID: 17028
// Name: AccountLinkManager
// Dependencies: [32, 5, 7180, 17028, 1074, 1090, 1272, 7191, 2]
// Exports: claimIncentivizedAccountLinkingReward
// Module 17027 (AccountLinkManager)
import DurationsDefault from "Durations" /* 1090 */;
import _slicedToArray from "module_32" /* 32 */;
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */;
import AuthorizedAppsStore from "AuthorizedAppsStore" /* 7180 */;
import AccountLinkStore from "AccountLinkStore" /* 17028 */;
import AutomaticLifecycleManager from "AutomaticLifecycleManager" /* 7191 */;
let require = fn;
let closure_9 = async function _claimIncentivizedAccountLinkingReward(arg0, arg1) {
closure_2 = tmp3;
closure_1 = tmp5;
({ applicationId: closure_129_0, onSuccess: closure_129_1, onError: closure_129_2 } = closure_0);
await "PX_16";
const HTTP = closure_130_0(closure_130_1[6]).HTTP;
const request = { url: closure_130_7.OAUTH2_ACCOUNT_LINKING_ACHIEVEMENT, body: { application_id: closure_129_0 }, rejectWithError: true };
await HTTP.post(request);
if (2 === tmp8) {
c4 = 0;
closure_129_3 = closure_3;
if (closure_129_2 != null) {
tmp14(closure_129_3);
}
c6 = 3;
} else if (arg0 === 1) {
c6 = 3;
throw arg1;
} else if (arg0 !== 2) {
if (closure_129_1 != null) {
closure_129_1();
}
c4 = 0;
}
return arg1;
};
const Constants = fn(1074);
({ AppStates: metroRequire, Endpoints: closure_7 } = Constants);
let closure_8 = 20 * DurationsDefault.Millis.MINUTE;
class AccountLinkManager extends tmp3 {
constructor() {
applyArgumentsResult = HermesBuiltin.applyArguments(new.target, new.target);
closure_0 = applyArgumentsResult;
applyArgumentsResult.actions = {
OAUTH2_TOKEN_CREATE(arg0) {
return applyArgumentsResult.handleOAuth2TokenCreate(arg0);
},
USER_AUTHORIZED_APPS_UPDATE() {
return applyArgumentsResult.handleAuthorizedAppsUpdate();
},
APP_STATE_UPDATE(arg0) {
return applyArgumentsResult.handleAppStateUpdate(arg0);
},
ACCOUNT_LINK_AUTHORIZATION_COMPLETED(applicationId) {
return applyArgumentsResult.handleAccountLinkAuthorizationCompleted(applicationId);
}
};
return applyArgumentsResult;
}
}
const prototype = AccountLinkManager.prototype;
prototype["evaluatePending"] = function evaluatePending() {
const pendingAuthorizations = AccountLinkStore.getPendingAuthorizations();
if (0 !== pendingAuthorizations.size) {
const _Date = Date;
const timestamp = Date.now();
const tmp26 = pendingAuthorizations[Symbol.iterator]();
while (tmp26 !== undefined) {
let tmp6 = _slicedToArray(tmp3, 2);
[tmp7, tmp8] = tmp6;
let tmp9 = tmp8;
if (timestamp - tmp8.startedAt > closure_8) {
let result = AccountLinkStore.deletePendingAuthorization(tmp7);
let accountLinkCallbacks2 = tmp9.accountLinkCallbacks;
if (accountLinkCallbacks2 != null) {
let onError = accountLinkCallbacks2.onError;
if (onError != null) {
let onErrorResult = onError("Account link authorization timed out");
}
}
} else if (null != AuthorizedAppsStore.getNewestTokenForApplication(tmp7)) {
let accountLinkCallbacks = tmp9.accountLinkCallbacks;
if (accountLinkCallbacks != null) {
let onSuccess = accountLinkCallbacks.onSuccess;
if (onSuccess != null) {
let onSuccessResult = onSuccess();
}
}
let result1 = AccountLinkStore.deletePendingAuthorization(tmp7);
}
continue;
}
}
};
prototype["handleOAuth2TokenCreate"] = function handleOAuth2TokenCreate(application) {
const pendingAuthorizations = AccountLinkStore.getPendingAuthorizations();
if (pendingAuthorizations.has(application.application.id)) {
const self = this;
this.evaluatePending();
}
};
prototype["handleAuthorizedAppsUpdate"] = function handleAuthorizedAppsUpdate() {
this.evaluatePending();
};
prototype["handleAccountLinkAuthorizationCompleted"] = function handleAccountLinkAuthorizationCompleted(applicationId) {
const pendingAuthorizations = AccountLinkStore.getPendingAuthorizations();
if (pendingAuthorizations.has(applicationId.applicationId)) {
const self = this;
this.evaluatePending();
}
};
prototype["handleAppStateUpdate"] = function handleAppStateUpdate(state) {
if (state.state === constants.ACTIVE) {
const self = this;
this.evaluatePending();
}
};
AccountLinkManager.displayName = "AccountLinkManager";
const accountLinkManager = new AccountLinkManager();
const size = fn(2);
let result = size.fileFinishedImporting("modules/application_account_linking/AccountLinkManager.tsx");
export default accountLinkManager;
export const claimIncentivizedAccountLinkingReward = function claimIncentivizedAccountLinkingReward() {
const self = this;
const apply = closure_9.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
};
export { AccountLinkManager };