435 lines
18 KiB
TypeScript
435 lines
18 KiB
TypeScript
/* Metro module 13038; source: modules/rpc/server/commands/providers.tsx; dependencies: [5, 5040, 4135, 661, 4237, 482, 8079, 8081, 4915, 8076, 694, 1239, 9354, 5042, 2] */
|
|
function _fun99519(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#99519, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:6, offset: 0x021cbb6f, size: 434 bytes, params: 8, frame: 26
|
|
var object2;
|
|
const env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const value = importDefault(5) /* metro dependency 5 */;
|
|
const connectedAccountsStore = importDefault(5040) /* metro dependency 5040: ConnectedAccountsStore */;
|
|
const {RPC_AUTHENTICATED_SCOPE, RPC_SCOPE_CONFIG} = require(4135) /* metro dependency 4135: Constants */;
|
|
const constantsModule = require(661) /* metro dependency 661: Constants */;
|
|
const env0_6 = constantsModule.AnalyticsLocations;
|
|
const env0_7 = constantsModule.ComponentActions;
|
|
const env0_8 = constantsModule.PlatformTypes;
|
|
const {AM_HARMONY_PRD_APPLICATION_ID,
|
|
AM_HARMONY_STG_APPLICATION_ID} = require(4237) /* metro dependency 4237: Constants */;
|
|
const constantsModule2 = require(482) /* metro dependency 482: Constants */;
|
|
const RPCCommands = constantsModule2.RPCCommands;
|
|
const env0_9 = constantsModule2.RPCErrors;
|
|
const Set = global.Set;
|
|
const set = new Set([AM_HARMONY_PRD_APPLICATION_ID, AM_HARMONY_STG_APPLICATION_ID]);
|
|
object2 = {};
|
|
const GET_PROVIDER_ACCESS_TOKEN = RPCCommands.GET_PROVIDER_ACCESS_TOKEN;
|
|
let ANY = RPC_SCOPE_CONFIG.ANY;
|
|
object2[GET_PROVIDER_ACCESS_TOKEN] = {scope: {[ANY]: [RPC_AUTHENTICATED_SCOPE]}, validation: validation_99520,
|
|
handler: handler_99521};
|
|
const MAYBE_GET_PROVIDER_ACCESS_TOKEN = RPCCommands.MAYBE_GET_PROVIDER_ACCESS_TOKEN;
|
|
const object3 = {};
|
|
ANY = RPC_SCOPE_CONFIG.ANY;
|
|
object3.scope = {[ANY]: [RPC_AUTHENTICATED_SCOPE]};
|
|
object3.validation = validation_99534;
|
|
const env0_3 = value(_fun99536);
|
|
object3.handler = handler_99537;
|
|
object2[MAYBE_GET_PROVIDER_ACCESS_TOKEN] = object3;
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/rpc/server/commands/providers.tsx');
|
|
exports.default = object2;
|
|
}
|
|
|
|
function validation_99520(a0) { // fn#99520, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:449, offset: 0x021cbd21, size: 95 bytes, params: 2, frame: 14
|
|
let value = (importDefault(8079) /* metro dependency 8079: createRpcJoiSchemaObject */)(a0);
|
|
value = value.required();
|
|
const keys = value.keys;
|
|
const object2 = {};
|
|
object2.provider = a0.string().required();
|
|
object2.connection_redirect = a0.string();
|
|
return Reflect.apply(keys, value, [object2]);
|
|
}
|
|
|
|
function handler_99521({socket, args}) { // fn#99521, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:552, offset: 0x021cbd80, size: 445 bytes, params: 2, frame: 20
|
|
var Promise;
|
|
var value5;
|
|
var promise;
|
|
var defaultImport4;
|
|
const provider = args.provider;
|
|
const env0_1 = args.connection_redirect;
|
|
var value;
|
|
const rpcHelpersModule = require(8081) /* metro dependency 8081: RPCHelpers */;
|
|
rpcHelpersModule.validatePostMessageTransport(socket.transport);
|
|
const moduleValue2 = rpcHelpersModule;
|
|
const value2 = moduleValue2.validateApplication(socket.application);
|
|
if ((importDefault(4915) /* metro dependency 4915: Platforms */).get(provider) == null) {
|
|
defaultImport4 = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
({}).errorCode = RPCErrors.INVALID_PROVIDER;
|
|
value = 'Platform not found for provider "' + provider + '"';
|
|
value = new defaultImport4();
|
|
throw value;
|
|
}
|
|
const AMAZON_MUSIC = PlatformTypes.AMAZON_MUSIC;
|
|
if (provider !== AMAZON_MUSIC) {
|
|
throw new (importDefault(8076) /* metro dependency 8076: RPCError */)({errorCode: RPCErrors.UNAUTHORIZED_FOR_APPLICATION},
|
|
|
|
'Command not available for this application');
|
|
}
|
|
const binding = env0_10;
|
|
if (binding.has(value2)) {
|
|
Promise = global.Promise;
|
|
value = _fun99522();
|
|
value5 = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
promise = new Promise();
|
|
return promise instanceof Object ? promise : value5;
|
|
}
|
|
const defaultImport2 = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
const UNAUTHORIZED_FOR_APPLICATION = RPCErrors.UNAUTHORIZED_FOR_APPLICATION;
|
|
throw new defaultImport2({errorCode: UNAUTHORIZED_FOR_APPLICATION}, 'Command not available for this application');
|
|
}
|
|
|
|
function validation_99534(a0) { // fn#99534, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:2265, offset: 0x021cc3dd, size: 81 bytes, params: 2, frame: 13
|
|
let value = (importDefault(8079) /* metro dependency 8079: createRpcJoiSchemaObject */)(a0);
|
|
value = value.required();
|
|
const keys = value.keys;
|
|
const object2 = {};
|
|
object2.provider = a0.string().required();
|
|
return Reflect.apply(keys, value, [object2]);
|
|
}
|
|
|
|
async function _fun99536({socket, args}) { // fn#99536, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:2343, offset: 0x021cc442, size: 641 bytes, params: 2, frame: 21
|
|
var account;
|
|
var value12;
|
|
var value13;
|
|
var value21;
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
const provider = args.provider;
|
|
await undefined;
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
value = environment.__proto__;
|
|
let binding = env1_0;
|
|
const binding2 = env1_2;
|
|
const value4 = binding(binding2[7]);
|
|
value4.validatePostMessageTransport(socket.transport);
|
|
const value5 = binding(binding2[7]);
|
|
const value6 = value5.validateApplication(socket.application);
|
|
const value8 = env1_1(binding2[8]).get(provider);
|
|
if (value8 == null) {
|
|
value21 = env1_1(env1_2[9]);
|
|
value = 'Platform not found for provider "' + provider + '"';
|
|
value = new value21({errorCode: env1_9.INVALID_PROVIDER}, value);
|
|
throw value;
|
|
}
|
|
const AMAZON_MUSIC = env1_8.AMAZON_MUSIC;
|
|
if (provider !== AMAZON_MUSIC) {
|
|
throw new env1_1(env1_2[9])({errorCode: env1_9.UNAUTHORIZED_FOR_APPLICATION},
|
|
'Command not available for this application');
|
|
}
|
|
if (Reflect.apply(env1_10.has, binding, [value6])) {
|
|
binding = env1_5;
|
|
account = binding.getAccount(null, provider);
|
|
if (account == null) {
|
|
throw new env1_1(env1_2[9])({errorCode: env1_9.NO_CONNECTION_FOUND}, 'No connection found');
|
|
}
|
|
binding = env1_1;
|
|
value12 = binding(env1_2[13]);
|
|
await value12.refreshAccessToken(value8.type, account.id);
|
|
value13 = undefined;
|
|
if (false) {
|
|
return value13;
|
|
}
|
|
if (value13 == null) {
|
|
throw new env1_1(env1_2[9])({errorCode: env1_9.OAUTH2_ERROR},
|
|
'Refreshing access token did not return a new access token');
|
|
}
|
|
return {access_token: value13};
|
|
}
|
|
const value9 = env1_1(env1_2[9]);
|
|
const UNAUTHORIZED_FOR_APPLICATION = env1_9.UNAUTHORIZED_FOR_APPLICATION;
|
|
throw new value9({errorCode: UNAUTHORIZED_FOR_APPLICATION}, 'Command not available for this application');
|
|
}
|
|
|
|
function _fun99522() { // fn#99522, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:1096, offset: 0x021cbf3d, size: 36 bytes, params: 1, frame: 12
|
|
const env0_0 = env1_4(_fun99523);
|
|
return _fun99533;
|
|
}
|
|
|
|
function* _fun99523(a0, a1) { // fn#99523, offset: 0x021cbf61, size: 44 bytes, params: 3, frame: 2
|
|
const cleanupPromise = function() {
|
|
importDefault(dependencyMap[10]).unsubscribe('USER_CONNECTIONS_UPDATE', handleConnectionsUpdate);
|
|
var ComponentDispatch = require(dependencyMap[11]).ComponentDispatch;
|
|
var CONNECTIONS_CALLBACK_ERROR = ComponentActions.CONNECTIONS_CALLBACK_ERROR;
|
|
ComponentDispatch.unsubscribe(CONNECTIONS_CALLBACK_ERROR, handleConnectionsCallbackError);
|
|
};
|
|
return _fun99524;
|
|
}
|
|
|
|
function* _fun99524(a0, a1) { // fn#99524, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:1116, offset: 0x021cbf8d, size: 417 bytes, params: 3, frame: 23
|
|
var environment;
|
|
var closure;
|
|
var closure2;
|
|
var getAccount;
|
|
var value3;
|
|
var value4;
|
|
var property;
|
|
var defaultImport;
|
|
var refreshAccessToken;
|
|
var binding;
|
|
var type;
|
|
var id;
|
|
var value5;
|
|
var value6;
|
|
var value7;
|
|
var value8;
|
|
var object2;
|
|
var defaultImport2;
|
|
var OAUTH2_ERROR;
|
|
var prototype;
|
|
var defaultImport22;
|
|
var error;
|
|
var defaultImport3;
|
|
var subscribe;
|
|
var ComponentDispatch;
|
|
var CONNECTIONS_CALLBACK_ERROR;
|
|
var defaultImport4;
|
|
var ACTIVITY_RPC;
|
|
let value = undefined;
|
|
if (false) {
|
|
return value;
|
|
}
|
|
reduciblePort39: while (true) {
|
|
exceptionLanding37: while (true) {
|
|
var env0_0 = a0;
|
|
var env0_1 = a1;
|
|
closure = handleConnectionsUpdate_99525;
|
|
var handleConnectionsUpdate_99525 = closure;
|
|
closure2 = function() {
|
|
var defaultImport = importDefault(dependencyMap[9]);
|
|
var object = {};
|
|
object.errorCode = RPCErrors.OAUTH2_ERROR;
|
|
var value4 = 'OAuth2 setup for "' + provider + '" failed';
|
|
var value5 = Object.create(defaultImport.prototype, {constructor: {value: defaultImport}});
|
|
var value6 = new defaultImport(object, value4);
|
|
require(value6 instanceof Object ? value6 : value5);
|
|
cleanupPromise_99528();
|
|
};
|
|
var handleConnectionsCallbackError_99527 = closure2;
|
|
var cleanupPromise_99528Binding = cleanupPromise_99528;
|
|
value = environment.__proto__.__proto__.__proto__;
|
|
getAccount = ConnectedAccountsStore.getAccount;
|
|
value3 = environment.__proto__.__proto__;
|
|
value4 = Reflect.apply(getAccount, ConnectedAccountsStore, [null, provider]);
|
|
if (value4 == null) {
|
|
defaultImport3 = importDefault(dependencyMap[10]);
|
|
subscribe = defaultImport3.subscribe;
|
|
Reflect.apply(subscribe, defaultImport3, ['USER_CONNECTIONS_UPDATE', closure]);
|
|
ComponentDispatch = require(dependencyMap[11]).ComponentDispatch;
|
|
subscribe = ComponentDispatch.subscribe;
|
|
CONNECTIONS_CALLBACK_ERROR = ComponentActions.CONNECTIONS_CALLBACK_ERROR;
|
|
Reflect.apply(subscribe, ComponentDispatch, [CONNECTIONS_CALLBACK_ERROR, closure2]);
|
|
defaultImport4 = importDefault(dependencyMap[12]);
|
|
type = env2_2.type;
|
|
ACTIVITY_RPC = AnalyticsLocations.ACTIVITY_RPC;
|
|
defaultImport4({platformType: type, location: ACTIVITY_RPC, successRedirect: connection_redirect});
|
|
break reduciblePort39;
|
|
}
|
|
try {
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
property = dependencyMap[13];
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
defaultImport = importDefault(property);
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
refreshAccessToken = defaultImport.refreshAccessToken;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
binding = env2_2;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
type = binding.type;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
id = value4.id;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
value5 = Reflect.apply(refreshAccessToken, defaultImport, [type, id]);
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
yield value5;
|
|
try {
|
|
value6 = undefined;
|
|
value7 = false;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
if (value7) {
|
|
return value6;
|
|
}
|
|
try {
|
|
value8 = value6 == null;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
if (!value8) {
|
|
try {
|
|
object2 = {};
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
object2.access_token = value6;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
a0(object2);
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
break reduciblePort39;
|
|
}
|
|
try {
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
property = dependencyMap[9];
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
defaultImport2 = importDefault(property);
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
object2 = {};
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
OAUTH2_ERROR = RPCErrors.OAUTH2_ERROR;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
object2.errorCode = OAUTH2_ERROR;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
prototype = defaultImport2.prototype;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
defaultImport22 = new defaultImport2(object2,
|
|
'Refreshing access token did not return a new access token');
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
value = defaultImport22 instanceof Object ? defaultImport22 : value;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
try {
|
|
throw value;
|
|
} catch (error) {
|
|
break exceptionLanding37;
|
|
}
|
|
}
|
|
a1(error);
|
|
break reduciblePort39;
|
|
}
|
|
}
|
|
|
|
function handleConnectionsUpdate(a0) { // fn#99529, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:1170, offset: 0x021cc284, size: 96 bytes, params: 2, frame: 12
|
|
var environment;
|
|
var value2;
|
|
let value = environment.__proto__.__proto__;
|
|
if (env2_2 != null) {
|
|
value = (a0.accounts ?? []).find(_fun99530);
|
|
if (value != null) {
|
|
value2 = environment.__proto__;
|
|
env1_0({access_token: value.access_token});
|
|
cleanupPromise();
|
|
}
|
|
}
|
|
}
|
|
|
|
function handleConnectionsCallbackError() { // fn#99531, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:1347, offset: 0x021cc2fe, size: 125 bytes, params: 1, frame: 17
|
|
let value = environment.__proto__.__proto__.__proto__;
|
|
const binding = env3_4;
|
|
const defaultImport = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
const OAUTH2_ERROR = RPCErrors.OAUTH2_ERROR;
|
|
value = environment.__proto__.__proto__;
|
|
value = 'OAuth2 setup for "' + provider + '" failed';
|
|
value = new defaultImport({errorCode: OAUTH2_ERROR}, value);
|
|
binding(value);
|
|
cleanupPromise();
|
|
}
|
|
|
|
function handleConnectionsUpdate_99525(a0) { // fn#99525, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:1170, offset: 0x021cc12e, size: 93 bytes, params: 2, frame: 12
|
|
var environment;
|
|
let value = environment.__proto__.__proto__.__proto__;
|
|
if (env3_2 != null) {
|
|
value = (a0.accounts ?? []).find(_fun99526);
|
|
if (value != null) {
|
|
env0_0({access_token: value.access_token});
|
|
cleanupPromise_99528();
|
|
}
|
|
}
|
|
}
|
|
|
|
function cleanupPromise_99528() { // fn#99528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:1483, offset: 0x021cc222, size: 98 bytes, params: 1, frame: 17
|
|
const defaultImport = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
let unsubscribe = defaultImport.unsubscribe;
|
|
Reflect.apply(unsubscribe, defaultImport, ['USER_CONNECTIONS_UPDATE', handleConnectionsUpdate_99525]);
|
|
const ComponentDispatch = (require(1239) /* metro dependency 1239: ComponentDispatchUtils */).ComponentDispatch;
|
|
unsubscribe = ComponentDispatch.unsubscribe;
|
|
const CONNECTIONS_CALLBACK_ERROR = ComponentActions.CONNECTIONS_CALLBACK_ERROR;
|
|
Reflect.apply(unsubscribe, ComponentDispatch, [CONNECTIONS_CALLBACK_ERROR, handleConnectionsCallbackError_99527]);
|
|
}
|
|
|
|
function _fun99530({type}) { // fn#99530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:1264, offset: 0x021cc2e4, size: 26 bytes, params: 2, frame: 2
|
|
return type === env3_2.type;
|
|
}
|
|
|
|
function _fun99526({type}) { // fn#99526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13228:1264, offset: 0x021cc18b, size: 26 bytes, params: 2, frame: 2
|
|
return type === env4_2.type;
|
|
}
|
|
|