;
+ autoLogin?: boolean;
}
diff --git a/packages/auth/src/auth.ts b/packages/auth/src/auth.ts
index e8b8620a6..5d06758da 100644
--- a/packages/auth/src/auth.ts
+++ b/packages/auth/src/auth.ts
@@ -1,22 +1,20 @@
-import { IRocketChatAuthOptions } from './IRocketChatAuthOptions';
-import RocketChatAuth from './RocketChatAuth';
+import { IRocketChatAuthOptions } from "./IRocketChatAuthOptions";
+import RocketChatAuth from "./RocketChatAuth";
const rocketChatAuth = ({
- host,
- saveToken,
- getToken,
- deleteToken,
- autoLogin,
+ host,
+ saveToken,
+ getToken,
+ deleteToken,
+ autoLogin,
}: IRocketChatAuthOptions) => {
- return new RocketChatAuth({
- host,
- saveToken,
- getToken,
- deleteToken,
- autoLogin,
- });
-}
+ return new RocketChatAuth({
+ host,
+ saveToken,
+ getToken,
+ deleteToken,
+ autoLogin,
+ });
+};
-export {
- rocketChatAuth
-}
+export { rocketChatAuth };
diff --git a/packages/auth/src/getAuthorizationUrl.ts b/packages/auth/src/getAuthorizationUrl.ts
index 1c9346706..32e9a5e15 100644
--- a/packages/auth/src/getAuthorizationUrl.ts
+++ b/packages/auth/src/getAuthorizationUrl.ts
@@ -1,12 +1,15 @@
const getAuthorizationUrl = (oauthService: any) => {
- if (oauthService.authorizePath?.startsWith('http')){
- return oauthService.authorizePath;
- }
- if (oauthService.serverURL) {
- return new URL(oauthService.authorizePath, oauthService.serverURL).toString();
- } else {
- return oauthService.authorizePath;
- }
-}
+ if (oauthService.authorizePath?.startsWith("http")) {
+ return oauthService.authorizePath;
+ }
+ if (oauthService.serverURL) {
+ return new URL(
+ oauthService.authorizePath,
+ oauthService.serverURL
+ ).toString();
+ } else {
+ return oauthService.authorizePath;
+ }
+};
export default getAuthorizationUrl;
diff --git a/packages/auth/src/index.ts b/packages/auth/src/index.ts
index 91b9edfc0..ff36dfb6a 100644
--- a/packages/auth/src/index.ts
+++ b/packages/auth/src/index.ts
@@ -1,4 +1,4 @@
-export * from './auth';
-export { default as RocketChatAuth } from './RocketChatAuth';
-export * from './IRocketChatAuthOptions';
-export {ApiError} from './Api';
\ No newline at end of file
+export * from "./auth";
+export { default as RocketChatAuth } from "./RocketChatAuth";
+export * from "./IRocketChatAuthOptions";
+export { ApiError } from "./Api";
diff --git a/packages/auth/src/loginWithOAuthServiceToken.ts b/packages/auth/src/loginWithOAuthServiceToken.ts
index bd823505b..64518ee44 100644
--- a/packages/auth/src/loginWithOAuthServiceToken.ts
+++ b/packages/auth/src/loginWithOAuthServiceToken.ts
@@ -1,17 +1,17 @@
import { Api } from "./Api";
const loginWithOAuthServiceToken = async (
- config: {
- api: Api
- },
- credentials: {
- service: string;
- access_token: string;
- [key:string]: string;
- }
+ config: {
+ api: Api;
+ },
+ credentials: {
+ service: string;
+ access_token: string;
+ [key: string]: string;
+ }
) => {
- const response = await config.api.post('/api/v1/login', credentials)
- return response.data;
-}
+ const response = await config.api.post("/api/v1/login", credentials);
+ return response.data;
+};
export default loginWithOAuthServiceToken;
diff --git a/packages/auth/src/loginWithPassword.ts b/packages/auth/src/loginWithPassword.ts
index c85a2ee1f..7843efb38 100644
--- a/packages/auth/src/loginWithPassword.ts
+++ b/packages/auth/src/loginWithPassword.ts
@@ -1,23 +1,25 @@
import { Api } from "./Api";
const loginWithPassword = async (
- config : {
- api: Api;
- }, {
- user,
- password,
- code,
- }: {
- user: string;
- password: string;
- code?: string | number;
-}) => {
- const response = await config.api.post('/api/v1/login', {
- user,
- password,
- code
- })
- return response.data;
-}
+ config: {
+ api: Api;
+ },
+ {
+ user,
+ password,
+ code,
+ }: {
+ user: string;
+ password: string;
+ code?: string | number;
+ }
+) => {
+ const response = await config.api.post("/api/v1/login", {
+ user,
+ password,
+ code,
+ });
+ return response.data;
+};
export default loginWithPassword;
diff --git a/packages/auth/src/loginWithResumeToken.ts b/packages/auth/src/loginWithResumeToken.ts
index e85407dbd..b9b1f2b6e 100644
--- a/packages/auth/src/loginWithResumeToken.ts
+++ b/packages/auth/src/loginWithResumeToken.ts
@@ -1,15 +1,15 @@
import { Api } from "./Api";
const loginWithResumeToken = async (
- config: {
- api: Api
- },
- credentials: {
- resume: string
- }
+ config: {
+ api: Api;
+ },
+ credentials: {
+ resume: string;
+ }
) => {
- const response = await config.api.post('/api/v1/login', credentials)
- return response.data;
-}
+ const response = await config.api.post("/api/v1/login", credentials);
+ return response.data;
+};
export default loginWithResumeToken;
diff --git a/packages/auth/src/loginWithRocketChatOAuth.ts b/packages/auth/src/loginWithRocketChatOAuth.ts
index 7eea59823..de01ae295 100644
--- a/packages/auth/src/loginWithRocketChatOAuth.ts
+++ b/packages/auth/src/loginWithRocketChatOAuth.ts
@@ -52,17 +52,17 @@ width=800,height=600,left=-1000,top=-1000,rel=opener`;
expiresIn,
serviceName,
});
- popup.close();
+ popup.close();
resolve(response.data);
}
};
window.addEventListener("message", onMessage);
const checkInterval = setInterval(() => {
- if (popup.closed) {
- clearInterval(checkInterval);
- window.removeEventListener("message", onMessage);
- }
- }, 1000);
+ if (popup.closed) {
+ clearInterval(checkInterval);
+ window.removeEventListener("message", onMessage);
+ }
+ }, 1000);
} else {
throw new Error("Popup blocked");
}
diff --git a/packages/auth/src/utils/constants.ts b/packages/auth/src/utils/constants.ts
index 25b9dd64f..846757b54 100644
--- a/packages/auth/src/utils/constants.ts
+++ b/packages/auth/src/utils/constants.ts
@@ -1 +1 @@
-export const ROCKETCHAT_APP_ID = '4c977b2e-eda2-4627-8bfe-2d0358304a79';
+export const ROCKETCHAT_APP_ID = "4c977b2e-eda2-4627-8bfe-2d0358304a79";
diff --git a/packages/auth/src/utils/getRCAppBaseURL.ts b/packages/auth/src/utils/getRCAppBaseURL.ts
index 4850de224..6416e06a6 100644
--- a/packages/auth/src/utils/getRCAppBaseURL.ts
+++ b/packages/auth/src/utils/getRCAppBaseURL.ts
@@ -1,6 +1,6 @@
-import { ROCKETCHAT_APP_ID } from "./constants"
+import { ROCKETCHAT_APP_ID } from "./constants";
export const getRCAppBaseURL = (host: string) => {
- const url = new URL(`api/apps/public/${ROCKETCHAT_APP_ID}`, host);
- return url.toString();
-}
+ const url = new URL(`api/apps/public/${ROCKETCHAT_APP_ID}`, host);
+ return url.toString();
+};
diff --git a/packages/auth/src/utils/getRCAppInfo.ts b/packages/auth/src/utils/getRCAppInfo.ts
index ea4e0d617..191cac93d 100644
--- a/packages/auth/src/utils/getRCAppInfo.ts
+++ b/packages/auth/src/utils/getRCAppInfo.ts
@@ -1,12 +1,12 @@
import { getRCAppBaseURL } from "./getRCAppBaseURL";
export const getRCAppInfo = async (host: string) => {
- const rcAppBaseUrl = getRCAppBaseURL(host);
- const infoUrl = rcAppBaseUrl + '/info';
- const response = await fetch(infoUrl.toString());
- if (!response.ok) {
- return null;
- }
- const info = await response.json();
- return info;
-}
+ const rcAppBaseUrl = getRCAppBaseURL(host);
+ const infoUrl = rcAppBaseUrl + "/info";
+ const response = await fetch(infoUrl.toString());
+ if (!response.ok) {
+ return null;
+ }
+ const info = await response.json();
+ return info;
+};
diff --git a/packages/auth/src/utils/getRCAuthorizeURL.ts b/packages/auth/src/utils/getRCAuthorizeURL.ts
index a8c0a71c2..6ddec5606 100644
--- a/packages/auth/src/utils/getRCAuthorizeURL.ts
+++ b/packages/auth/src/utils/getRCAuthorizeURL.ts
@@ -1,8 +1,12 @@
-export const getRCAuthorizeURL = (host: string, redirectUri: string, clientId: string) => {
- const url = new URL(`oauth/authorize`, host);
- url.searchParams.set('response_type', 'code');
- url.searchParams.set('client_id', clientId);
- url.searchParams.set('redirect_uri', redirectUri);
- url.searchParams.set('state', encodeURIComponent(window.location.origin));
- return url.toString();
-}
+export const getRCAuthorizeURL = (
+ host: string,
+ redirectUri: string,
+ clientId: string
+) => {
+ const url = new URL(`oauth/authorize`, host);
+ url.searchParams.set("response_type", "code");
+ url.searchParams.set("client_id", clientId);
+ url.searchParams.set("redirect_uri", redirectUri);
+ url.searchParams.set("state", encodeURIComponent(window.location.origin));
+ return url.toString();
+};
diff --git a/packages/e2e-react/package.json b/packages/e2e-react/package.json
index 95db2f5f7..12f62bd10 100644
--- a/packages/e2e-react/package.json
+++ b/packages/e2e-react/package.json
@@ -8,7 +8,9 @@
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
- "test": "playwright test"
+ "test": "playwright test",
+ "format": "prettier --write 'src/' ",
+ "format:check": "prettier --check 'src/' "
},
"dependencies": {
"@embeddedchat/react": "*",
diff --git a/packages/e2e-react/src/main.tsx b/packages/e2e-react/src/main.tsx
index e63eef4a8..95e2bdc2c 100644
--- a/packages/e2e-react/src/main.tsx
+++ b/packages/e2e-react/src/main.tsx
@@ -1,9 +1,9 @@
-import React from 'react'
-import ReactDOM from 'react-dom/client'
-import App from './App.tsx'
+import React from "react";
+import ReactDOM from "react-dom/client";
+import App from "./App.tsx";
-ReactDOM.createRoot(document.getElementById('root')!).render(
+ReactDOM.createRoot(document.getElementById("root")!).render(
- ,
-)
+
+);
diff --git a/packages/htmlembed/package.json b/packages/htmlembed/package.json
index ce5b68820..33a837024 100644
--- a/packages/htmlembed/package.json
+++ b/packages/htmlembed/package.json
@@ -8,7 +8,9 @@
"private": true,
"scripts": {
"build": "vite build && node postbuild.cjs",
- "preview": "npm run build && vite preview --port=4001"
+ "preview": "npm run build && vite preview --port=4001",
+ "format": "prettier --write 'src/' ",
+ "format:check": "prettier --check 'src/' "
},
"dependencies": {
"@embeddedchat/react": "0.1.12",
diff --git a/packages/htmlembed/src/EmbeddedChat.jsx b/packages/htmlembed/src/EmbeddedChat.jsx
index a771bfd1b..71fae93f4 100644
--- a/packages/htmlembed/src/EmbeddedChat.jsx
+++ b/packages/htmlembed/src/EmbeddedChat.jsx
@@ -1,37 +1,39 @@
-import React from 'react'
-import ReactDOM from 'react-dom/client'
-import { EmbeddedChat as EmbeddedChatComponent } from '@embeddedchat/react';
+import React from "react";
+import ReactDOM from "react-dom/client";
+import { EmbeddedChat as EmbeddedChatComponent } from "@embeddedchat/react";
const EmbeddedChat = {
- renderInElementWithId(config, id) {
- if (!id) {
- throw new Error("Please provide a valid id of the element to render embeddedchat");
- }
- ReactDOM.createRoot(document.getElementById(id)).render(
-
-
-
- )
- },
- renderInElementWithSelector(config, selector) {
- if(!selector) {
- throw new Error("Please provide a valid selector to render embeddedchat");
- }
- ReactDOM.createRoot(document.querySelector(selector)).render(
-
-
-
- )
- },
- renderInElement(config, element) {
- if (!element) {
- throw new Error("Please provide a valid element to render embeddedchat");
- }
- ReactDOM.createRoot(element).render(
-
-
-
- )
- }
-}
+ renderInElementWithId(config, id) {
+ if (!id) {
+ throw new Error(
+ "Please provide a valid id of the element to render embeddedchat"
+ );
+ }
+ ReactDOM.createRoot(document.getElementById(id)).render(
+
+
+
+ );
+ },
+ renderInElementWithSelector(config, selector) {
+ if (!selector) {
+ throw new Error("Please provide a valid selector to render embeddedchat");
+ }
+ ReactDOM.createRoot(document.querySelector(selector)).render(
+
+
+
+ );
+ },
+ renderInElement(config, element) {
+ if (!element) {
+ throw new Error("Please provide a valid element to render embeddedchat");
+ }
+ ReactDOM.createRoot(element).render(
+
+
+
+ );
+ },
+};
export default EmbeddedChat;
diff --git a/packages/rc-app/endpoints/CallbackEndpoint.ts b/packages/rc-app/endpoints/CallbackEndpoint.ts
index c230a716e..1a5e6560e 100644
--- a/packages/rc-app/endpoints/CallbackEndpoint.ts
+++ b/packages/rc-app/endpoints/CallbackEndpoint.ts
@@ -55,30 +55,42 @@ export class CallbackEndpoint extends ApiEndpoint {
const response = await http.post(tokenUrl, {
content: formData.toString(),
headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
+ "Content-Type": "application/x-www-form-urlencoded",
},
- })
+ });
if (response.statusCode !== 200) {
- return {
- status: response.statusCode,
- content: await getCallbackContent(read, null, origin, response.data.error_description || 'Unknown'),
- headers: {
- 'Content-Security-Policy': "default-src 'self'; script-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; frame-src 'self'; font-src 'self'; object-src 'none'",
- }
- }
+ return {
+ status: response.statusCode,
+ content: await getCallbackContent(
+ read,
+ null,
+ origin,
+ response.data.error_description || "Unknown"
+ ),
+ headers: {
+ "Content-Security-Policy":
+ "default-src 'self'; script-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; frame-src 'self'; font-src 'self'; object-src 'none'",
+ },
+ };
}
return {
status: 200,
- content: await getCallbackContent(read, {
- accessToken: response.data?.access_token,
- expiresIn: response.data?.expires_in,
- serviceName: customOAuthName,
- }, origin, false),
+ content: await getCallbackContent(
+ read,
+ {
+ accessToken: response.data?.access_token,
+ expiresIn: response.data?.expires_in,
+ serviceName: customOAuthName,
+ },
+ origin,
+ false
+ ),
headers: {
- 'Content-Security-Policy': "default-src 'self'; script-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; frame-src 'self'; font-src 'self'; object-src 'none'",
- }
+ "Content-Security-Policy":
+ "default-src 'self'; script-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; frame-src 'self'; font-src 'self'; object-src 'none'",
+ },
};
}
}
diff --git a/packages/rc-app/endpoints/InfoEndpoint.ts b/packages/rc-app/endpoints/InfoEndpoint.ts
index 8548bc8a1..ab0a69dd9 100644
--- a/packages/rc-app/endpoints/InfoEndpoint.ts
+++ b/packages/rc-app/endpoints/InfoEndpoint.ts
@@ -52,8 +52,8 @@ export class InfoEndpoint extends ApiEndpoint {
client_id: !!client_id,
client_secret: !!client_secret,
custom_oauth_name: !!serviceName,
- }
- }
- }
+ },
+ },
+ };
}
}
diff --git a/packages/rc-app/lib/getAllowedOrigins.ts b/packages/rc-app/lib/getAllowedOrigins.ts
index ea30e038c..aa94c4d7f 100644
--- a/packages/rc-app/lib/getAllowedOrigins.ts
+++ b/packages/rc-app/lib/getAllowedOrigins.ts
@@ -1,8 +1,13 @@
export const getAllowedOrigins = async (read) => {
- const allowedOrigins = await read.getEnvironmentReader().getSettings().getValueById("allowed-origins");
+ const allowedOrigins = await read
+ .getEnvironmentReader()
+ .getSettings()
+ .getValueById("allowed-origins");
if (!allowedOrigins) {
return [];
}
- const origins = allowedOrigins.split(',').filter((domain) => !!domain.trim());
+ const origins = allowedOrigins
+ .split(",")
+ .filter((domain) => !!domain.trim());
return origins;
-}
+};
diff --git a/packages/rc-app/lib/getCallbackContent.ts b/packages/rc-app/lib/getCallbackContent.ts
index c8c1a2898..165aa1c1b 100644
--- a/packages/rc-app/lib/getCallbackContent.ts
+++ b/packages/rc-app/lib/getCallbackContent.ts
@@ -5,22 +5,27 @@ interface ICredentials {
accessToken: string;
expiresIn: number;
serviceName: string;
-};
+}
-export const getCallbackContent = async (read: IRead, credentials: ICredentials | null, origin: string, error) => {
+export const getCallbackContent = async (
+ read: IRead,
+ credentials: ICredentials | null,
+ origin: string,
+ error
+) => {
const { accessToken, expiresIn = 3600, serviceName } = credentials || {};
- const isAllowed = await isAllowedOrigin(read, origin);;
+ const isAllowed = await isAllowedOrigin(read, origin);
let config: any = {};
if (error) {
config = {
success: false,
error,
- }
+ };
} else if (!isAllowed) {
config = {
success: false,
- error: 'origin not allowed',
- }
+ error: "origin not allowed",
+ };
} else {
config = {
success: true,
@@ -29,8 +34,8 @@ export const getCallbackContent = async (read: IRead, credentials: ICredentials
accessToken,
expiresIn,
serviceName,
- }
- }
+ },
+ };
}
const closeLinkHtml = `${
config.success ? "Login Successful" : "Login Failed: " + config.error
@@ -66,4 +71,4 @@ export const getCallbackContent = async (read: IRead, credentials: ICredentials