176 lines
5.2 KiB
TypeScript
176 lines
5.2 KiB
TypeScript
// Metro module 8956 (f8957).
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import SelectedChannelStore from "../../stores/SelectedChannelStore";
|
|
import { ChannelTypes, Endpoints } from "../../Constants";
|
|
import { HTTP, rejectWithMigratedError } from "../../_bundle/sendRequest";
|
|
import AuthenticationActionCreators from "../../actions/AuthenticationActionCreators";
|
|
import { getLoginPath } from "../../_bundle/getAuthenticationPath";
|
|
const getLocationContextServer = function getLocationContextServer() {
|
|
const basicChannel = ChannelStore.getBasicChannel(SelectedChannelStore.getChannelId());
|
|
let guild_id2 = basicChannel?.guild_id;
|
|
if (guild_id2 == null) {
|
|
guild_id2 = "10000";
|
|
}
|
|
let channel_id = basicChannel?.id;
|
|
if (channel_id == null) {
|
|
channel_id = "10000";
|
|
}
|
|
let channel_type = basicChannel?.type;
|
|
if (channel_type == null) {
|
|
channel_type = ChannelTypes.UNKNOWN;
|
|
}
|
|
return {
|
|
guild_id: guild_id2,
|
|
channel_id,
|
|
channel_type
|
|
};
|
|
};
|
|
export { getLocationContextServer };
|
|
export function acceptWhitelist(a0) {
|
|
return HTTP.post({
|
|
url: Endpoints.OAUTH2_WHITELIST_ACCEPT,
|
|
query: {
|
|
token: a0
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
}
|
|
export async function authorize(c26328_0) {
|
|
let c26328_2;
|
|
c26328_2 = void 0;
|
|
let c30009_0 = c26328_0.authorize;
|
|
let c30009_1 = c26328_0.clientId;
|
|
let c30009_2 = c26328_0.scopes;
|
|
let c30009_3 = c26328_0.responseType;
|
|
let c30009_4 = c26328_0.redirectUri;
|
|
let c30009_5 = c26328_0.codeChallenge;
|
|
let c30009_6 = c26328_0.codeChallengeMethod;
|
|
let c30009_7 = c26328_0.state;
|
|
let c30009_8 = c26328_0.permissions;
|
|
let c30009_9 = c26328_0.guildId;
|
|
let c30009_10 = c26328_0.channelId;
|
|
let c30009_11 = c26328_0.integrationType;
|
|
let c30009_12 = c26328_0.connectedAccountProvider;
|
|
let c30009_13 = c26328_0.nonce;
|
|
await void 0;
|
|
return (await HTTP.post({
|
|
url: Endpoints.OAUTH2_AUTHORIZE,
|
|
query: {
|
|
client_id: c30009_1,
|
|
response_type: c30009_3,
|
|
redirect_uri: c30009_4,
|
|
code_challenge: c30009_5,
|
|
code_challenge_method: c30009_6,
|
|
scope: c30009_2.join(" "),
|
|
state: c30009_7,
|
|
nonce: c30009_13
|
|
},
|
|
body: {
|
|
guild_id: c30009_9,
|
|
webhook_channel_id: c30009_9 != null ? c30009_10 != null ? c30009_10 : void 0 : void 0,
|
|
channel_id: c30009_9 == null ? c30009_10 != null ? c30009_10 : void 0 : void 0,
|
|
permissions: c30009_8,
|
|
authorize: c30009_0,
|
|
integration_type: c30009_11,
|
|
connected_account_provider: c30009_12,
|
|
location_context: (0, getLocationContextServer)()
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
})).body;
|
|
}
|
|
export async function fetchAuthorization(c26329_0) {
|
|
let c26329_2;
|
|
c26329_2 = void 0;
|
|
let c30010_0 = c26329_0.clientId;
|
|
let c30010_1 = c26329_0.scopes;
|
|
let c30010_2 = c26329_0.responseType;
|
|
let c30010_3 = c26329_0.redirectUri;
|
|
let c30010_4 = c26329_0.codeChallenge;
|
|
let c30010_5 = c26329_0.codeChallengeMethod;
|
|
let c30010_6 = c26329_0.state;
|
|
let c30010_7 = c26329_0.integrationType;
|
|
let c30010_8 = c26329_0.connectedAccountProvider;
|
|
let c30010_9 = c26329_0.nonce;
|
|
let c30010_10 = c26329_0.signal;
|
|
await void 0;
|
|
return (await HTTP.get({
|
|
url: Endpoints.OAUTH2_AUTHORIZE,
|
|
query: {
|
|
client_id: c30010_0,
|
|
response_type: c30010_2,
|
|
redirect_uri: c30010_3,
|
|
code_challenge: c30010_4,
|
|
code_challenge_method: c30010_5,
|
|
scope: c30010_1.join(" "),
|
|
state: c30010_6,
|
|
integration_type: c30010_7,
|
|
connected_account_provider: c30010_8,
|
|
nonce: c30010_9
|
|
},
|
|
signal: c30010_10,
|
|
retries: 3,
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
})).body;
|
|
}
|
|
export async function startSamsungAuthorization(client_id, c26330_1, response_type, redirect_uri, state) {
|
|
await HTTP.get({
|
|
url: Endpoints.OAUTH2_AUTHORIZE_SAMSUNG,
|
|
query: {
|
|
client_id,
|
|
state,
|
|
response_type,
|
|
redirect_uri,
|
|
prompt: "consent",
|
|
scope: c26330_1.join(" ")
|
|
},
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
}
|
|
export async function fetchChannels(guild_id) {
|
|
return (await HTTP.get({
|
|
url: Endpoints.OAUTH2_AUTHORIZE_WEBHOOK_CHANNELS,
|
|
query: {
|
|
guild_id
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
})).body;
|
|
}
|
|
export function logoutWithRedirect(a0, a1) {
|
|
AuthenticationActionCreators.logout(a1, getLoginPath(a0.pathname + a0.search, false));
|
|
}
|
|
export async function verifyUserCode(user_code) {
|
|
return await HTTP.post({
|
|
url: Endpoints.OAUTH2_DEVICE_VERIFY,
|
|
body: {
|
|
user_code
|
|
},
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
}
|
|
export async function finishUserCode(user_code2, result) {
|
|
return await HTTP.post({
|
|
url: Endpoints.OAUTH2_DEVICE_FINISH,
|
|
body: {
|
|
user_code: user_code2,
|
|
result
|
|
},
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
}
|
|
export async function finishUserCodeTwoWayLinkError(user_code3, error_code, error_source) {
|
|
return await HTTP.post({
|
|
url: Endpoints.OAUTH2_DEVICE_FINISH,
|
|
body: {
|
|
user_code: user_code3,
|
|
result: "two_way_link_error",
|
|
error_code,
|
|
error_source
|
|
},
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
}
|