Client: fix after merge develop
This commit is contained in:
parent
16ada7a735
commit
f129e8f1dc
@ -12,7 +12,7 @@ import {
|
|||||||
getScopeList,
|
getScopeList,
|
||||||
getConsentList,
|
getConsentList,
|
||||||
revokeUserClient,
|
revokeUserClient,
|
||||||
} from "@docspace/common/api/oauth";
|
} from "@docspace/shared/api/oauth";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IClientListProps,
|
IClientListProps,
|
||||||
@ -20,10 +20,9 @@ import {
|
|||||||
IClientReqDTO,
|
IClientReqDTO,
|
||||||
INoAuthClientProps,
|
INoAuthClientProps,
|
||||||
IScope,
|
IScope,
|
||||||
} from "@docspace/common/utils/oauth/interfaces";
|
} from "@docspace/shared/utils/oauth/interfaces";
|
||||||
|
|
||||||
//@ts-ignore
|
import { toastr } from "@docspace/shared/components/toast";
|
||||||
import toastr from "@docspace/components/toast/toastr";
|
|
||||||
|
|
||||||
import SettingsIcon from "PUBLIC_DIR/images/catalog.settings.react.svg?url";
|
import SettingsIcon from "PUBLIC_DIR/images/catalog.settings.react.svg?url";
|
||||||
import DeleteIcon from "PUBLIC_DIR/images/delete.react.svg?url";
|
import DeleteIcon from "PUBLIC_DIR/images/delete.react.svg?url";
|
||||||
@ -33,8 +32,9 @@ import PencilReactSvgUrl from "PUBLIC_DIR/images/pencil.react.svg?url";
|
|||||||
import CodeReactSvgUrl from "PUBLIC_DIR/images/code.react.svg?url";
|
import CodeReactSvgUrl from "PUBLIC_DIR/images/code.react.svg?url";
|
||||||
import ExternalLinkReactSvgUrl from "PUBLIC_DIR/images/external.link.react.svg?url";
|
import ExternalLinkReactSvgUrl from "PUBLIC_DIR/images/external.link.react.svg?url";
|
||||||
import OauthRevokeSvgUrl from "PUBLIC_DIR/images/oauth.revoke.svg?url";
|
import OauthRevokeSvgUrl from "PUBLIC_DIR/images/oauth.revoke.svg?url";
|
||||||
import { transformToClientProps } from "@docspace/common/utils/oauth";
|
import { transformToClientProps } from "@docspace/shared/utils/oauth";
|
||||||
import { AuthenticationMethod } from "@docspace/common/utils/oauth/enums";
|
import { AuthenticationMethod } from "@docspace/shared/enums";
|
||||||
|
import { TData } from "@docspace/shared/components/toast/Toast.type";
|
||||||
|
|
||||||
const PAGE_LIMIT = 100;
|
const PAGE_LIMIT = 100;
|
||||||
|
|
||||||
@ -260,8 +260,9 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
const client = await getClient(clientId);
|
const client = await getClient(clientId);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
} catch (e) {
|
} catch (e: unknown) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -284,7 +285,8 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
});
|
});
|
||||||
this.setClientsIsLoading(false);
|
this.setClientsIsLoading(false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -297,7 +299,8 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
this.consents = [...consentList];
|
this.consents = [...consentList];
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -343,7 +346,8 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -375,7 +379,8 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -392,7 +397,8 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -405,7 +411,8 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
|
|
||||||
return client_secret;
|
return client_secret;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -429,7 +436,8 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
|
|
||||||
this.setActiveClient("");
|
this.setActiveClient("");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -440,7 +448,8 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
|
|
||||||
return scope;
|
return scope;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
||||||
return {} as IScope;
|
return {} as IScope;
|
||||||
@ -453,7 +462,8 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
|
|
||||||
this.scopes = scopes;
|
this.scopes = scopes;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -477,7 +487,8 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
|
|
||||||
this.setActiveClient("");
|
this.setActiveClient("");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -602,7 +613,8 @@ class OAuthStore implements OAuthStoreProps {
|
|||||||
this.setActiveClient("");
|
this.setActiveClient("");
|
||||||
this.setSelection("");
|
this.setSelection("");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toastr.error(e);
|
const err = e as TData;
|
||||||
|
toastr.error(err);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.setActiveClient(clientId);
|
this.setActiveClient(clientId);
|
||||||
|
@ -90,9 +90,7 @@ const Consent = ({
|
|||||||
let clientState = "";
|
let clientState = "";
|
||||||
const scope = oauth.client.scopes;
|
const scope = oauth.client.scopes;
|
||||||
|
|
||||||
setCookie("client_id", clientId);
|
await api.oauth.onOAuthLogin(clientId);
|
||||||
|
|
||||||
await api.oauth.onOAuthLogin();
|
|
||||||
|
|
||||||
const cookie = document.cookie.split(";");
|
const cookie = document.cookie.split(";");
|
||||||
|
|
||||||
@ -101,7 +99,6 @@ const Consent = ({
|
|||||||
clientState = c.replace("client_state=", "").trim();
|
clientState = c.replace("client_state=", "").trim();
|
||||||
});
|
});
|
||||||
|
|
||||||
deleteCookie("client_id");
|
|
||||||
deleteCookie("client_state");
|
deleteCookie("client_state");
|
||||||
|
|
||||||
await api.oauth.onOAuthSubmit(clientId, clientState, scope);
|
await api.oauth.onOAuthSubmit(clientId, clientState, scope);
|
||||||
@ -112,9 +109,7 @@ const Consent = ({
|
|||||||
|
|
||||||
let clientState = "";
|
let clientState = "";
|
||||||
|
|
||||||
setCookie("client_id", clientId);
|
await api.oauth.onOAuthLogin(clientId);
|
||||||
|
|
||||||
await api.oauth.onOAuthLogin();
|
|
||||||
|
|
||||||
const cookie = document.cookie.split(";");
|
const cookie = document.cookie.split(";");
|
||||||
|
|
||||||
@ -123,7 +118,6 @@ const Consent = ({
|
|||||||
clientState = c.replace("client_state=", "").trim();
|
clientState = c.replace("client_state=", "").trim();
|
||||||
});
|
});
|
||||||
|
|
||||||
deleteCookie("client_id");
|
|
||||||
deleteCookie("client_state");
|
deleteCookie("client_state");
|
||||||
|
|
||||||
await api.oauth.onOAuthCancel(clientId, clientState);
|
await api.oauth.onOAuthCancel(clientId, clientState);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"date": "2024118_10460",
|
"date": "2024118_14311",
|
||||||
"checksums": {
|
"checksums": {
|
||||||
"api.js": "cc6df9a4cf6c0ce8bed75e8cd3890b9a",
|
"api.js": "cc6df9a4cf6c0ce8bed75e8cd3890b9a",
|
||||||
"api.poly.js": "586ce6831fa68f6bc33486e2cebc856e",
|
"api.poly.js": "586ce6831fa68f6bc33486e2cebc856e",
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
IScope,
|
IScope,
|
||||||
INoAuthClientProps,
|
INoAuthClientProps,
|
||||||
IClientReqDTO,
|
IClientReqDTO,
|
||||||
|
IGetConsentList,
|
||||||
} from "../../utils/oauth/interfaces";
|
} from "../../utils/oauth/interfaces";
|
||||||
|
|
||||||
export const getClient = async (
|
export const getClient = async (
|
||||||
@ -123,12 +124,12 @@ export const getScopeList = async (): Promise<IScope[]> => {
|
|||||||
return scopeList;
|
return scopeList;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const onOAuthLogin = () => {
|
export const onOAuthLogin = (clientId: string) => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
||||||
return request({
|
return request({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: `/oauth2/login`,
|
url: `/oauth2/login?client_id=${clientId}`,
|
||||||
data: formData,
|
data: formData,
|
||||||
withRedirect: true,
|
withRedirect: true,
|
||||||
headers: {
|
headers: {
|
||||||
@ -180,18 +181,23 @@ export const onOAuthCancel = (clientId: string, clientState: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getConsentList = async (): Promise<IClientProps[]> => {
|
export const getConsentList = async (): Promise<IClientProps[]> => {
|
||||||
const clients = await request({
|
const clients = (await request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "/clients/consents",
|
url: "/clients/consents",
|
||||||
});
|
})) as IGetConsentList[];
|
||||||
|
|
||||||
const consents: IClientProps[] = [];
|
const consents: IClientProps[] = [];
|
||||||
|
|
||||||
clients.forEach((item) => {
|
clients.forEach(({ client, invalidated, modified_at }: IGetConsentList) => {
|
||||||
const client = transformToClientProps(item.client);
|
const consentClient: IClientResDTO = {
|
||||||
|
...client,
|
||||||
|
client_secret: "",
|
||||||
|
logout_redirect_uri: "",
|
||||||
|
};
|
||||||
|
|
||||||
if (!item.invalidated)
|
const cl = transformToClientProps(consentClient);
|
||||||
consents.push({ ...client, modifiedOn: item.modified_at });
|
|
||||||
|
if (!invalidated) consents.push({ ...cl, modifiedOn: modified_at });
|
||||||
});
|
});
|
||||||
|
|
||||||
return consents;
|
return consents;
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
import axios, { AxiosInstance, AxiosRequestConfig } from "axios";
|
import axios, { AxiosInstance, AxiosRequestConfig } from "axios";
|
||||||
import { combineUrl } from "@docspace/shared/utils/combineUrl";
|
import { combineUrl } from "@docspace/shared/utils/combineUrl";
|
||||||
import defaultConfig from "PUBLIC_DIR/scripts/config.json";
|
import defaultConfig from "PUBLIC_DIR/scripts/config.json";
|
||||||
import { setCookie } from "./cookie";
|
|
||||||
|
|
||||||
const { api: apiConf, proxy: proxyConf } = defaultConfig;
|
const { api: apiConf, proxy: proxyConf } = defaultConfig;
|
||||||
const { origin: apiOrigin, prefix: apiPrefix, timeout: apiTimeout } = apiConf;
|
const { origin: apiOrigin, prefix: apiPrefix, timeout: apiTimeout } = apiConf;
|
||||||
@ -66,7 +65,7 @@ class AxiosClient {
|
|||||||
"Access-Control-Allow-Credentials": "true",
|
"Access-Control-Allow-Credentials": "true",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
setCookie("x-docspace-address", origin, {}, true);
|
|
||||||
const shareIndex = window.location.pathname.indexOf("share");
|
const shareIndex = window.location.pathname.indexOf("share");
|
||||||
const sharedIndex = window.location.pathname.indexOf("shared");
|
const sharedIndex = window.location.pathname.indexOf("shared");
|
||||||
|
|
||||||
@ -180,7 +179,11 @@ class AxiosClient {
|
|||||||
|
|
||||||
if (!response || !response.data || response.isAxiosError) return null;
|
if (!response || !response.data || response.isAxiosError) return null;
|
||||||
|
|
||||||
if (response.data && "total" in response.data)
|
if (
|
||||||
|
response.data &&
|
||||||
|
typeof response.data !== "string" &&
|
||||||
|
"total" in response.data
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
total: response.data.total ? +response.data.total : 0,
|
total: response.data.total ? +response.data.total : 0,
|
||||||
items: response.data.response,
|
items: response.data.response,
|
||||||
|
@ -118,3 +118,36 @@ export interface ISubmitReqDTO {
|
|||||||
state: string;
|
state: string;
|
||||||
scopes: string[];
|
scopes: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type TConsentClient = {
|
||||||
|
authentication_methods: AuthenticationMethod[];
|
||||||
|
client_id: string;
|
||||||
|
created_by: string;
|
||||||
|
created_on: Date;
|
||||||
|
description: string;
|
||||||
|
enabled: boolean;
|
||||||
|
invalidated: boolean;
|
||||||
|
tenant: number;
|
||||||
|
tenant_url: string;
|
||||||
|
terms_url: string;
|
||||||
|
website_url: string;
|
||||||
|
modified_by: string;
|
||||||
|
modified_on: Date;
|
||||||
|
name: string;
|
||||||
|
policy_url: string;
|
||||||
|
logo: string;
|
||||||
|
links: string[];
|
||||||
|
logout_redirect_uris: string[];
|
||||||
|
redirect_uris: string[];
|
||||||
|
scopes: string[];
|
||||||
|
allowed_origins: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IGetConsentList {
|
||||||
|
client: TConsentClient;
|
||||||
|
invalidated: boolean;
|
||||||
|
modified_at: Date;
|
||||||
|
principal_name: string;
|
||||||
|
registered_client_id: string;
|
||||||
|
scopes: string;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user