35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
// Metro module 11306 (f11307).
|
|
import { Routes } from "../../Constants";
|
|
export function getActivityLaunchURL({ applicationId, customId, referrerId, linkId }) {
|
|
const uRL = new URL(Routes.ACTIVITY_DETAILS(applicationId), `${location.protocol}//${location.host}`);
|
|
const searchParams = uRL.searchParams;
|
|
if (linkId != null) {
|
|
searchParams.set("link_id", linkId);
|
|
}
|
|
if (referrerId != null) {
|
|
searchParams.set("referrer_id", referrerId);
|
|
}
|
|
if (customId != null) {
|
|
searchParams.set("custom_id", customId);
|
|
}
|
|
return uRL.toString();
|
|
}
|
|
export function getApplicationInstallURL({ id, customInstallUrl, installParams, integrationTypesConfig }) {
|
|
if (customInstallUrl != null) {
|
|
return customInstallUrl;
|
|
}
|
|
const uRLSearchParams = new URLSearchParams();
|
|
uRLSearchParams.set("client_id", id);
|
|
const r23 = integrationTypesConfig != null && Object.values(integrationTypesConfig).some((item) => item?.oauth2_install_params != null || item?.oauth2InstallParams != null);
|
|
if (installParams != null && !r23) {
|
|
const { permissions, scopes } = installParams;
|
|
if (permissions != null) {
|
|
uRLSearchParams.set("permissions", permissions);
|
|
}
|
|
if (scopes != null) {
|
|
uRLSearchParams.set("scope", scopes.join(" "));
|
|
}
|
|
}
|
|
return `${location.protocol}//${location.host}${Routes.OAUTH2_AUTHORIZE}?${uRLSearchParams.toString()}`;
|
|
}
|