Files
discord-decomp/sources/modules/activate_device/useDeviceCodeAuthorizeCallback.tsx
2026-07-28 01:06:53 +03:00

769 lines
36 KiB
TypeScript

/* Metro module 12652; source: modules/activate_device/useDeviceCodeAuthorizeCallback.tsx; dependencies: [5, 31, 12651, 5042, 9338, 44, 5043, 9347, 2] */
import Module00005 from '../../by-id/module-00005.js'; /* Metro dependency 5 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */
function _fun96997(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#96997, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12842:6, offset: 0x0216f570, size: 170 bytes, params: 8, frame: 19
const env0_0 = require;
const silentlyFinishTwoWayLinkError = function() {
return _silentlyFinishTwoWayLinkError.apply(this, arguments);
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('modules/activate_device/useDeviceCodeAuthorizeCallback.tsx');
exports.useDeviceCodeAuthorizeCallback = useDeviceCodeAuthorizeCallback;
function _createTwoWayLink() { // fn#96998, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12842:118, offset: 0x0216f61a, size: 50 bytes, params: 1, frame: 14
return Module00005(_fun97000).apply(this, arguments);
function* _fun97000(a0, a1, a2) { // fn#97000, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12842:175, offset: 0x0216f657, size: 724 bytes, params: 4, frame: 34
var code;
var r7;
var r4;
var value;
var value2;
var value3;
var binding;
var value4;
var clientIdToActivateDevicePlatform;
var value5;
var binding2;
var property;
var value6;
var authorize;
var object;
var value7;
var TwoWayLinkType;
var DEVICE_CODE;
var value8;
var value9;
var value10;
var body;
var url;
var binding3;
var value11;
var value12;
var binding4;
var value13;
var getCallbackParamsFromURL;
var value14;
var state;
var value15;
var value16;
var binding5;
var value17;
var callback;
var value18;
var value19;
var value20;
var error;
var value21;
var value22;
var Error;
var prototype;
var value23;
var value24;
var value25;
exceptionSkip75: while (true) {
exceptionLanding75: while (true) {
exceptionSkip70: while (true) {
exceptionLanding70: while (true) {
exceptionSkip62: while (true) {
exceptionLanding62: while (true) {
value = undefined;
value2 = false;
if (value2) {
return value;
}
value = undefined;
value3 = environment.__proto__.__proto__;
binding = env2_0;
value4 = binding(env2_2[2]);
clientIdToActivateDevicePlatform = value4.clientIdToActivateDevicePlatform;
value5 = Reflect.apply(clientIdToActivateDevicePlatform, value4, [a0]);
if (value5 == null) {
yield env2_6(a2, 1, 'authorize');
if (false) {
return undefined;
}
throw new global.Error('Unsupported client_id for two way link');
}
try {
binding = env2_1;
} catch (error) {
break exceptionLanding75;
}
try {
binding2 = env2_2;
} catch (error) {
break exceptionLanding75;
}
try {
property = binding2[3];
} catch (error) {
break exceptionLanding75;
}
try {
value6 = binding(property);
} catch (error) {
break exceptionLanding75;
}
try {
authorize = value6.authorize;
} catch (error) {
break exceptionLanding75;
}
try {
object = {};
} catch (error) {
break exceptionLanding75;
}
try {
binding = env2_0;
} catch (error) {
break exceptionLanding75;
}
try {
property = binding2[4];
} catch (error) {
break exceptionLanding75;
}
try {
value7 = binding(property);
} catch (error) {
break exceptionLanding75;
}
try {
TwoWayLinkType = value7.TwoWayLinkType;
} catch (error) {
break exceptionLanding75;
}
try {
DEVICE_CODE = TwoWayLinkType.DEVICE_CODE;
} catch (error) {
break exceptionLanding75;
}
try {
object.twoWayLinkType = DEVICE_CODE;
} catch (error) {
break exceptionLanding75;
}
try {
object.userCode = a2;
} catch (error) {
break exceptionLanding75;
}
try {
value8 = Reflect.apply(authorize, value6, [value5, object]);
} catch (error) {
break exceptionLanding75;
}
yield value8;
try {
value9 = undefined;
value10 = false;
} catch (error) {
break exceptionLanding75;
}
if (value10) {
return value9;
}
try {
body = value9.body;
} catch (error) {
break exceptionLanding75;
}
try {
url = body.url;
} catch (error) {
break exceptionLanding75;
}
try {
binding = env2_1;
} catch (error) {
break exceptionLanding70;
}
try {
binding3 = env2_2;
} catch (error) {
break exceptionLanding70;
}
try {
property = binding3[5];
} catch (error) {
break exceptionLanding70;
}
try {
value11 = binding(property);
} catch (error) {
break exceptionLanding70;
}
try {
value12 = url != null;
} catch (error) {
break exceptionLanding70;
}
try {
value11(value12, 'No URL in authorize response');
} catch (error) {
break exceptionLanding70;
}
try {
binding4 = env2_0;
} catch (error) {
break exceptionLanding70;
}
try {
property = binding3[6];
} catch (error) {
break exceptionLanding70;
}
try {
value13 = binding4(property);
} catch (error) {
break exceptionLanding70;
}
try {
getCallbackParamsFromURL = value13.getCallbackParamsFromURL;
} catch (error) {
break exceptionLanding70;
}
try {
value14 = Reflect.apply(getCallbackParamsFromURL, value13, [url]);
} catch (error) {
break exceptionLanding70;
}
try {
state = value14.state;
} catch (error) {
break exceptionLanding70;
}
try {
property = binding3[5];
} catch (error) {
break exceptionLanding70;
}
try {
value15 = binding(property);
} catch (error) {
break exceptionLanding70;
}
try {
value16 = state != null;
} catch (error) {
break exceptionLanding70;
}
try {
value15(value16, 'Authorize URL state query parameter must be present');
} catch (error) {
break exceptionLanding70;
}
try {
binding = env2_1;
} catch (error) {
break exceptionLanding62;
}
try {
binding5 = env2_2;
} catch (error) {
break exceptionLanding62;
}
try {
property = binding5[3];
} catch (error) {
break exceptionLanding62;
}
try {
value17 = binding(property);
} catch (error) {
break exceptionLanding62;
}
try {
callback = value17.callback;
} catch (error) {
break exceptionLanding62;
}
try {
object = {};
} catch (error) {
break exceptionLanding62;
}
try {
object.code = a1;
} catch (error) {
break exceptionLanding62;
}
try {
object.state = state;
} catch (error) {
break exceptionLanding62;
}
try {
value18 = Reflect.apply(callback, value17, [value5, object]);
} catch (error) {
break exceptionLanding62;
}
yield value18;
try {
value19 = undefined;
value20 = false;
} catch (error) {
break exceptionLanding62;
}
return value20 ? value19 : value;
break exceptionSkip62;
}
binding = env2_6;
if (error == null) {
code = value;
value21 = 0;
if (code != null) {
yield binding(a2, code, 'callback');
if (false) {
return undefined;
}
throw new global.Error('error during two way callback');
}
yield binding(a2, value21, 'callback');
value = undefined;
if (false) {
return value;
}
throw new global.Error('error during two way callback');
}
body = error.body;
if (body == null) {
code = value;
value21 = 0;
if (code != null) {
yield binding(a2, code, 'callback');
if (false) {
return undefined;
}
throw new global.Error('error during two way callback');
}
yield binding(a2, value21, 'callback');
value = undefined;
if (false) {
return value;
}
throw new global.Error('error during two way callback');
}
code = body.code;
value21 = 0;
if (code != null) {
yield binding(a2, code, 'callback');
if (false) {
return undefined;
}
throw new global.Error('error during two way callback');
}
r7 = value21;
yield binding(a2, r7, 'callback');
value = undefined;
value22 = false;
if (value22) {
return value;
}
Error = global.Error;
prototype = Error.prototype;
value = Object.create(prototype, {constructor: {value: Error}});
error = new Error('error during two way callback');
value = error instanceof Object ? error : value;
throw value;
break exceptionSkip62;
}
break exceptionSkip70;
}
yield env2_6(a2, 2, 'authorize');
value = undefined;
value23 = false;
if (value23) {
return value;
}
Error = global.Error;
prototype = Error.prototype;
value = Object.create(prototype, {constructor: {value: Error}});
error = new Error('error parsing callback params');
value = error instanceof Object ? error : value;
throw value;
break exceptionSkip70;
}
break exceptionSkip75;
}
binding = env2_6;
if (error == null) {
code = value;
value24 = 0;
if (code != null) {
yield binding(a2, code, 'authorize');
if (false) {
return undefined;
}
throw new global.Error('error during two way authorize');
}
yield binding(a2, value24, 'authorize');
value = undefined;
if (false) {
return value;
}
throw new global.Error('error during two way authorize');
}
body = error.body;
if (body == null) {
code = value;
value24 = 0;
if (code != null) {
yield binding(a2, code, 'authorize');
if (false) {
return undefined;
}
throw new global.Error('error during two way authorize');
}
yield binding(a2, value24, 'authorize');
value = undefined;
if (false) {
return value;
}
throw new global.Error('error during two way authorize');
}
code = body.code;
value24 = 0;
if (code != null) {
yield binding(a2, code, 'authorize');
if (false) {
return undefined;
}
throw new global.Error('error during two way authorize');
}
r4 = value24;
yield binding(a2, r4, 'authorize');
value = undefined;
value25 = false;
if (value25) {
return value;
}
Error = global.Error;
prototype = Error.prototype;
value = Object.create(prototype, {constructor: {value: Error}});
error = new Error('error during two way authorize');
value = error instanceof Object ? error : value;
throw value;
break exceptionSkip75;
}
}
}
function _silentlyFinishTwoWayLinkError() { // fn#97002, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12842:1296, offset: 0x0216f92b, size: 50 bytes, params: 1, frame: 14
return Module00005(_fun97004).apply(this, arguments);
function* _fun97004(a0, a1, a2) { // fn#97004, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12842:1379, offset: 0x0216f968, size: 79 bytes, params: 4, frame: 17
var binding;
var binding2;
var property;
var finishUserCodeTwoWayLinkError;
var value3;
var error;
if (true) {
value = environment.__proto__.__proto__;
try {
binding = env2_0;
} catch (error) {
return undefined;
}
try {
binding2 = env2_2;
} catch (error) {
return undefined;
}
try {
property = binding2[7];
} catch (error) {
return undefined;
}
try {
value = binding(property);
} catch (error) {
return undefined;
}
try {
finishUserCodeTwoWayLinkError = value.finishUserCodeTwoWayLinkError;
} catch (error) {
return undefined;
}
try {
value = Reflect.apply(finishUserCodeTwoWayLinkError, value, [a0, a1, a2]);
} catch (error) {
return undefined;
}
yield value;
try {
value = undefined;
value3 = false;
} catch (error) {
return undefined;
}
if (value3) {
return value;
}
}
}
}
function useDeviceCodeAuthorizeCallback(a0, a1, a2) { // fn#97005, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12842:1614, offset: 0x0216f9b7, size: 72 bytes, params: 4, frame: 16
const env0_0 = a0;
const env0_1 = a1;
const env0_2 = a2;
return ReactModule.useCallback(_fun97006(), [a0, a1, a2]);
function _fun97006() { // fn#97006, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12842:1681, offset: 0x0216f9ff, size: 36 bytes, params: 1, frame: 12
const env0_0 = env1_3(_fun97008);
return _fun97010;
function* _fun97008(a0, a1) { // fn#97008, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12842:1701, offset: 0x0216fa2e, size: 321 bytes, params: 3, frame: 17
var environment;
var binding;
var binding2;
var property;
var finishUserCode;
var userCode;
var value3;
var error;
var twoWayLinkCode;
var clientId;
var createTwoWayLink2;
var value4;
var binding3;
var value5;
let value = undefined;
if (false) {
return value;
}
if (a1) {
twoWayLinkCode = a0.twoWayLinkCode;
if (twoWayLinkCode == null) {
value = environment.__proto__.__proto__.__proto__;
try {
binding = env3_0;
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
binding3 = env3_2;
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
property = binding3[7];
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
value = binding(property);
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
finishUserCode = value.finishUserCode;
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
userCode = a0.userCode;
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
value = Reflect.apply(finishUserCode, value, [userCode, 'granted']);
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
yield value;
try {
value = undefined;
value5 = false;
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
if (value5) {
return value;
}
value = environment.__proto__.__proto__;
try {
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
dependencyMap(a0);
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
}
return undefined;
}
try {
clientId = a0.clientId;
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
twoWayLinkCode = a0.twoWayLinkCode;
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
userCode = a0.userCode;
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
createTwoWayLink2 = createTwoWayLink;
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
value = createTwoWayLink2(clientId, twoWayLinkCode, userCode);
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
yield value;
try {
value = undefined;
value4 = false;
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
if (value4) {
return value;
}
value = environment.__proto__.__proto__;
try {
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
return undefined;
}
try {
dependencyMap(a0);
} catch (error) {
value = environment.__proto__.__proto__;
importDefault(a0);
}
} else {
value = environment.__proto__.__proto__.__proto__;
try {
binding = env3_0;
} catch (error) {
value = environment.__proto__.__proto__;
require();
return undefined;
}
try {
binding2 = env3_2;
} catch (error) {
value = environment.__proto__.__proto__;
require();
return undefined;
}
try {
property = binding2[7];
} catch (error) {
value = environment.__proto__.__proto__;
require();
return undefined;
}
try {
value = binding(property);
} catch (error) {
value = environment.__proto__.__proto__;
require();
return undefined;
}
try {
finishUserCode = value.finishUserCode;
} catch (error) {
value = environment.__proto__.__proto__;
require();
return undefined;
}
try {
userCode = a0.userCode;
} catch (error) {
value = environment.__proto__.__proto__;
require();
return undefined;
}
try {
value = Reflect.apply(finishUserCode, value, [userCode, 'denied']);
} catch (error) {
value = environment.__proto__.__proto__;
require();
return undefined;
}
yield value;
try {
value = undefined;
value3 = false;
} catch (error) {
value = environment.__proto__.__proto__;
require();
return undefined;
}
if (value3) {
return value;
}
value = environment.__proto__.__proto__;
require();
}
function createTwoWayLink() { // fn#97009, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12842:1836, offset: 0x0216fb6f, size: 30 bytes, params: 1, frame: 13
return env4_5.apply(this, arguments);
}
}
function _fun97010() { // fn#97010, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12842:2055, offset: 0x00c3945f, size: 30 bytes, params: 1, frame: 13
return env0_0.apply(this, arguments);
}
}
}
}
global.__d(_fun96997, 12652, [5, 31, 12651, 5042, 9338, 44, 5043, 9347,
2]) /* metro module 12652, dependencies: [5, 31, 12651, 5042, 9338, 44, 5043, 9347, 2] */;